diff --git a/androscalpel/src/dex_writer.rs b/androscalpel/src/dex_writer.rs index 78a8e44..8dd0aaf 100644 --- a/androscalpel/src/dex_writer.rs +++ b/androscalpel/src/dex_writer.rs @@ -503,9 +503,14 @@ impl DexWriter { // for context } Instruction::Goto { label } => { - let (min_addr, max_addr) = label_min_max_addrs - .get(label) - .ok_or(anyhow!("Label {label} not found in label estimation map"))?; + let (min_addr, max_addr) = label_min_max_addrs.get(label).ok_or(anyhow!( + "Label {label} not found in label estimation map, known labels are {}", + label_min_max_addrs + .keys() + .map(|string| string.as_str()) + .collect::>() + .join(", ") + ))?; let size = Instruction::goto_size_from_branch_offset_interval( addr, *min_addr, *max_addr, )?; @@ -948,7 +953,8 @@ impl DexWriter { // No if let because ownership gunfooterie let code_off = if class.direct_methods.get(id).unwrap().code.is_some() { let code_off = self.section_manager.get_aligned_size(Section::CodeItem); - self.insert_code_item(id.clone(), true)?; + self.insert_code_item(id.clone(), true) + .with_context(|| format!("Failed to serialize code of {}", id.__str__()))?; Uleb128(code_off + 1) } else { Uleb128(0) @@ -983,7 +989,8 @@ impl DexWriter { // No if let because ownership gunfooterie let code_off = if class.virtual_methods.get(id).unwrap().code.is_some() { let code_off = self.section_manager.get_aligned_size(Section::CodeItem); - self.insert_code_item(id.clone(), false)?; + self.insert_code_item(id.clone(), false) + .with_context(|| format!("Failed to serialize code of {}", id.__str__()))?; Uleb128(code_off + 1) } else { Uleb128(0)