diff --git a/androscalpel/src/class.rs b/androscalpel/src/class.rs index 8df4661..e5c2096 100644 --- a/androscalpel/src/class.rs +++ b/androscalpel/src/class.rs @@ -392,32 +392,32 @@ impl Visitable for Class { fn default_visit(&self, v: &mut V) -> Result<()> { v.visit_type(&self.descriptor)?; if let Some(superclass) = &self.superclass { - v.visit_type(&superclass)?; + v.visit_type(superclass)?; } for interface in &self.interfaces { - v.visit_type(&interface)?; + v.visit_type(interface)?; } if let Some(source_file) = &self.source_file { - v.visit_string(&source_file)?; + v.visit_string(source_file)?; } for (id, field) in &self.static_fields { - v.visit_field_id(&id)?; - v.visit_field(&field)?; + v.visit_field_id(id)?; + v.visit_field(field)?; } for (id, field) in &self.instance_fields { - v.visit_field_id(&id)?; - v.visit_field(&field)?; + v.visit_field_id(id)?; + v.visit_field(field)?; } for (id, meth) in &self.direct_methods { - v.visit_method_id(&id)?; - v.visit_method(&meth)?; + v.visit_method_id(id)?; + v.visit_method(meth)?; } for (id, meth) in &self.virtual_methods { - v.visit_method_id(&id)?; - v.visit_method(&meth)?; + v.visit_method_id(id)?; + v.visit_method(meth)?; } for annot in &self.annotations { - v.visit_annotation_item(&annot)?; + v.visit_annotation_item(annot)?; } Ok(()) } diff --git a/androscalpel/src/code.rs b/androscalpel/src/code.rs index 806ac22..1a706ff 100644 --- a/androscalpel/src/code.rs +++ b/androscalpel/src/code.rs @@ -424,12 +424,12 @@ impl Code { end_label ))? .clone(); - for i in 0..handlers.len() { - handlers[i].1 = new_labels - .get(&handlers[i].1) + for handler in &mut handlers { + handler.1 = new_labels + .get(&handler.1) .ok_or(anyhow!( "Internal error: {} not found in renamed label", - handlers[i].1 + handler.1 ))? .clone(); } @@ -498,7 +498,7 @@ impl Code { impl Visitable for Code { fn default_visit(&self, v: &mut V) -> Result<()> { for ins in &self.insns { - v.visit_instruction(&ins)?; + v.visit_instruction(ins)?; } Ok(()) } diff --git a/androscalpel/src/dex_id.rs b/androscalpel/src/dex_id.rs index 454727a..b49b6c0 100644 --- a/androscalpel/src/dex_id.rs +++ b/androscalpel/src/dex_id.rs @@ -30,7 +30,7 @@ impl Visitable for IdMethodType { v.visit_string(&self.shorty)?; v.visit_type(&self.return_type)?; for ty in &self.parameters { - v.visit_type(&ty)?; + v.visit_type(ty)?; } Ok(()) } diff --git a/androscalpel/src/dex_writer.rs b/androscalpel/src/dex_writer.rs index fb04835..d44b479 100644 --- a/androscalpel/src/dex_writer.rs +++ b/androscalpel/src/dex_writer.rs @@ -611,7 +611,7 @@ impl DexWriter { } Instruction::InvokeCustom { call_site, .. } => { let call_site_idx = self.call_site_ids.len(); - self.insert_call_site_item(&call_site)?; + self.insert_call_site_item(call_site)?; let ins = ins.get_raw_ins(GetRawInsParam { call_site_idx: Some(call_site_idx), ..GetRawInsParam::default() @@ -628,7 +628,7 @@ impl DexWriter { } Instruction::ConstMethodHandle { handle, .. } => { let method_handle_idx = self.method_handles.len(); - self.insert_method_handle(&handle)?; + self.insert_method_handle(handle)?; let ins = ins.get_raw_ins(GetRawInsParam { method_handle_idx: Some(method_handle_idx), ..GetRawInsParam::default() diff --git a/androscalpel/src/field.rs b/androscalpel/src/field.rs index 410e442..522dcf9 100644 --- a/androscalpel/src/field.rs +++ b/androscalpel/src/field.rs @@ -263,13 +263,13 @@ impl Visitable for Field { v.visit_field_id(&self.descriptor)?; v.visit_field_visibility(&self.visibility)?; if let Some(val) = &self.value { - v.visit_value(&val)?; + v.visit_value(val)?; } for annot in &self.annotations { - v.visit_annotation_item(&annot)?; + v.visit_annotation_item(annot)?; } if let Some(hiddenapi) = &self.hiddenapi { - v.visit_hidden_api_data(&hiddenapi)?; + v.visit_hidden_api_data(hiddenapi)?; } Ok(()) diff --git a/androscalpel/src/instructions.rs b/androscalpel/src/instructions.rs index 6ed5653..5ec2b4f 100644 --- a/androscalpel/src/instructions.rs +++ b/androscalpel/src/instructions.rs @@ -635,6 +635,23 @@ pub enum Instruction { /// Label marker. It does not match an dalvik instruction, but it's use as a marker for a /// jump destination. Label { name: String }, + /// Debug information. Define a local variable associated with a register. + DebugLocal { + reg: u32, + name: Option, + type_: Option, + signature: Option, + }, + /// Debug information. Undefine a local variable associated with a register. + DebugEndLocal { reg: u32 }, + /// Debug information. Indicate the end of the prologue. + DebugEndPrologue {}, + /// Debug information. Indicate the beginning of the Epilogue + DebugBeginEpilogue {}, + /// Debug information. Indicate the source file of the following instructions. + DebugSourceFile { file: String }, + /// Debug information. Indicate the line number of the following instructions. + DebugLine { number: usize }, } impl Visitable for Instruction { @@ -1197,6 +1214,23 @@ impl Visitable for Instruction { Ok(()) } Self::Label { name: _ } => Ok(()), + Self::DebugLocal { + reg: _, + name: _, + type_, + signature: _, + } => { + if let Some(type_) = type_ { + v.visit_type(type_) + } else { + Ok(()) + } + } + Self::DebugEndLocal { reg: _ } => Ok(()), + Self::DebugEndPrologue {} => Ok(()), + Self::DebugBeginEpilogue {} => Ok(()), + Self::DebugSourceFile { file } => v.visit_string(&(file.as_str().into())), + Self::DebugLine { number: _ } => Ok(()), } } } @@ -1841,6 +1875,24 @@ impl VisitableMut for Instruction { default_handler, }), Self::Label { name: _ } => Ok(self), + Self::DebugLocal { + reg, + name, + type_, + signature, + } => Ok(Self::DebugLocal { + reg, + name, + type_: type_.map(|type_| v.visit_type(type_)).transpose()?, + signature, + }), + Self::DebugEndLocal { reg: _ } => Ok(self), + Self::DebugEndPrologue {} => Ok(self), + Self::DebugBeginEpilogue {} => Ok(self), + Self::DebugSourceFile { file } => v + .visit_string(file.as_str().into()) + .map(|file| Self::DebugSourceFile { file: file.into() }), + Self::DebugLine { number: _ } => Ok(self), } } } @@ -2757,6 +2809,27 @@ impl Instruction { Self::Label { name } => { format!("{}:", name) } + Self::DebugLocal { + reg, + name, + type_, + signature, + } => { + // TODO: check if/how apktool/smali handles empty name and type + let name = name.clone().unwrap_or(String::new()); + let ty = type_.as_ref().map(IdType::__str__).unwrap_or(String::new()); + if let Some(signature) = signature { + format!(".local {reg}, \"{name}\":{ty}, \"{signature}\"") + } else { + format!(".local {reg}, \"{name}\":{ty}") + } + } + Self::DebugEndLocal { reg } => format!(".end local {reg}"), + Self::DebugEndPrologue {} => ".prologue".into(), + Self::DebugBeginEpilogue {} => ".epilogue".into(), + // TODO: check if/how apktool/smali handles empty change of src file + Self::DebugSourceFile { file } => format!(".source_file {file}"), + Self::DebugLine { number } => format!(".line {number}"), } } @@ -2764,74 +2837,74 @@ impl Instruction { match self { Self::Nop {} => "Instruction(Nop)".into(), Self::Move { from, to } => { - format!("Instruction(Move({}, {}))", to, from) + format!("Instruction::Move({}, {})", to, from) } Self::MoveWide { from, to } => { - format!("Instruction(MoveWide({}, {}))", to, from) + format!("Instruction::MoveWide({}, {})", to, from) } Self::MoveObject { from, to } => { - format!("Instruction(MoveObject({}, {}))", to, from) + format!("Instruction::MoveObject({}, {})", to, from) } Self::MoveResult { to } => { - format!("Instruction(MoveResult({}))", to) + format!("Instruction::MoveResult({})", to) } Self::MoveResultWide { to } => { - format!("Instruction(MoveResultWide({}))", to) + format!("Instruction::MoveResultWide({})", to) } Self::MoveResultObject { to } => { - format!("Instruction(MoveResultObject({}))", to) + format!("Instruction::MoveResultObject({})", to) } Self::MoveException { to } => { - format!("Instruction(MoveException({}))", to) + format!("Instruction::MoveException({})", to) } - Self::ReturnVoid {} => "Instruction(ReturnVoid)".into(), + Self::ReturnVoid {} => "Instruction::ReturnVoid)".into(), Self::Return { reg } => { - format!("Instruction(Return({}))", reg) + format!("Instruction::Return({})", reg) } Self::ReturnWide { reg } => { - format!("Instruction(ReturnWide({}))", reg) + format!("Instruction::ReturnWide({})", reg) } Self::ReturnObject { reg } => { - format!("Instruction(ReturnObject({}))", reg) + format!("Instruction::ReturnObject({})", reg) } Self::Const { reg, lit } => { - format!("Instruction(Const({}, {}))", reg, lit) + format!("Instruction::Const({}, {})", reg, lit) } Self::ConstWide { reg, lit } => { - format!("Instruction(ConstWide({}, {}))", reg, lit) + format!("Instruction::ConstWide({}, {})", reg, lit) } Self::ConstString { reg, lit } => { - format!("Instruction(ConstString({}, {}))", reg, lit.__repr__()) + format!("Instruction::ConstString({}, {})", reg, lit.__repr__()) } Self::ConstClass { reg, lit } => { - format!("Instruction(ConstClass({}, {}))", reg, lit.__repr__()) + format!("Instruction::ConstClass({}, {})", reg, lit.__repr__()) } Self::MonitorEnter { reg } => { - format!("Instruction(MonitorEnter({}))", reg) + format!("Instruction::MonitorEnter({})", reg) } Self::MonitorExit { reg } => { - format!("Instruction(MonitorExit({}))", reg) + format!("Instruction::MonitorExit({})", reg) } Self::CheckCast { reg, lit } => { - format!("Instruction(CheckCast({}, {}))", reg, lit.__repr__()) + format!("Instruction::CheckCast({}, {})", reg, lit.__repr__()) } Self::InstanceOf { obj, lit, dest } => { format!( - "Instruction(InstanceOf({}, {}, {}))", + "Instruction::InstanceOf({}, {}, {})", dest, obj, lit.__repr__() ) } Self::ArrayLength { arr, dest } => { - format!("Instruction(ArrayLength({}, {}))", dest, arr,) + format!("Instruction::ArrayLength({}, {})", dest, arr,) } Self::NewInstance { reg, lit } => { - format!("Instruction(NewInstance({}, {}))", reg, lit.__repr__()) + format!("Instruction::NewInstance({}, {})", reg, lit.__repr__()) } Self::NewArray { reg, lit, size_reg } => { format!( - "Instruction(NewArray({}, {}, {}))", + "Instruction::NewArray({}, {}, {})", reg, size_reg, lit.__repr__() @@ -2852,7 +2925,7 @@ impl Instruction { .join(", ") }; format!( - "Instruction(FilledNewArray([{}], {}))", + "Instruction::FilledNewArray([{}], {})", args, type_.__repr__() ) @@ -2887,116 +2960,116 @@ impl Instruction { arr }; - format!("Instruction(FillArrayData({}, [{}]))", arr, data) + format!("Instruction::FillArrayData({}, [{}])", arr, data) } Self::Throw { reg } => { - format!("Instruction(Throw({}))", reg) + format!("Instruction::Throw({})", reg) } Self::Goto { label } => { - format!("Instruction(Goto({}))", label) + format!("Instruction::Goto({})", label) } Self::Switch { reg, .. } => { - format!("Instruction(Switch({}, ...))", reg) + format!("Instruction::Switch({}, ...)", reg) } Self::CmpLFloat { b, c, dest } => { - format!("Instruction(CmpLFloat({}, {}, {}))", dest, b, c) + format!("Instruction::CmpLFloat({}, {}, {})", dest, b, c) } Self::CmpGFloat { b, c, dest } => { - format!("Instruction(CmpGFloat({}, {}, {}))", dest, b, c) + format!("Instruction::CmpGFloat({}, {}, {})", dest, b, c) } Self::CmpLDouble { b, c, dest } => { - format!("Instruction(CmpLDouble({}, {}, {}))", dest, b, c) + format!("Instruction::CmpLDouble({}, {}, {})", dest, b, c) } Self::CmpGDouble { b, c, dest } => { - format!("Instruction(CmpGDouble({}, {}, {}))", dest, b, c) + format!("Instruction::CmpGDouble({}, {}, {})", dest, b, c) } Self::CmpLong { b, c, dest } => { - format!("Instruction(CmpLong({}, {}, {}))", dest, b, c) + format!("Instruction::CmpLong({}, {}, {})", dest, b, c) } Self::IfEq { a, b, label } => { - format!("Instruction(IfEq({}, {}, {}))", a, b, label) + format!("Instruction::IfEq({}, {}, {})", a, b, label) } Self::IfNe { a, b, label } => { - format!("Instruction(IfNe({}, {}, {}))", a, b, label) + format!("Instruction::IfNe({}, {}, {})", a, b, label) } Self::IfLt { a, b, label } => { - format!("Instruction(IfLt({}, {}, {}))", a, b, label) + format!("Instruction::IfLt({}, {}, {})", a, b, label) } Self::IfGe { a, b, label } => { - format!("Instruction(IfGe({}, {}, {}))", a, b, label) + format!("Instruction::IfGe({}, {}, {})", a, b, label) } Self::IfGt { a, b, label } => { - format!("Instruction(IfGt({}, {}, {}))", a, b, label) + format!("Instruction::IfGt({}, {}, {})", a, b, label) } Self::IfLe { a, b, label } => { - format!("Instruction(IfLe({}, {}, {}))", a, b, label) + format!("Instruction::IfLe({}, {}, {})", a, b, label) } Self::IfEqZ { a, label } => { - format!("Instruction(IfEqZ({}, {}))", a, label) + format!("Instruction::IfEqZ({}, {})", a, label) } Self::IfNeZ { a, label } => { - format!("Instruction(IfNe({}, {}))", a, label) + format!("Instruction::IfNe({}, {})", a, label) } Self::IfLtZ { a, label } => { - format!("Instruction(IfLt({}, {}))", a, label) + format!("Instruction::IfLt({}, {})", a, label) } Self::IfGeZ { a, label } => { - format!("Instruction(IfGe({}, {}))", a, label) + format!("Instruction::IfGe({}, {})", a, label) } Self::IfGtZ { a, label } => { - format!("Instruction(IfGt({}, {}))", a, label) + format!("Instruction::IfGt({}, {})", a, label) } Self::IfLeZ { a, label } => { - format!("Instruction(IfLe({}, {}))", a, label) + format!("Instruction::IfLe({}, {})", a, label) } Self::AGet { idx, arr, dest } => { - format!("Instruction(AGet({}, {}, {}))", dest, arr, idx) + format!("Instruction::AGet({}, {}, {})", dest, arr, idx) } Self::AGetWide { idx, arr, dest } => { - format!("Instruction(AGetWide({}, {}, {}))", dest, arr, idx) + format!("Instruction::AGetWide({}, {}, {})", dest, arr, idx) } Self::AGetObject { idx, arr, dest } => { - format!("Instruction(AGetObject({}, {}, {}))", dest, arr, idx) + format!("Instruction::AGetObject({}, {}, {})", dest, arr, idx) } Self::AGetBoolean { idx, arr, dest } => { - format!("Instruction(AGetBoolean({}, {}, {}))", dest, arr, idx) + format!("Instruction::AGetBoolean({}, {}, {})", dest, arr, idx) } Self::AGetByte { idx, arr, dest } => { - format!("Instruction(AGetByte({}, {}, {}))", dest, arr, idx) + format!("Instruction::AGetByte({}, {}, {})", dest, arr, idx) } Self::AGetChar { idx, arr, dest } => { - format!("Instruction(AGetChar({}, {}, {}))", dest, arr, idx) + format!("Instruction::AGetChar({}, {}, {})", dest, arr, idx) } Self::AGetShort { idx, arr, dest } => { - format!("Instruction(AGetShort({}, {}, {}))", dest, arr, idx) + format!("Instruction::AGetShort({}, {}, {})", dest, arr, idx) } Self::APut { idx, arr, from } => { - format!("Instruction(APut({}, {}, {}))", from, arr, idx) + format!("Instruction::APut({}, {}, {})", from, arr, idx) } Self::APutWide { idx, arr, from } => { - format!("Instruction(APutWide({}, {}, {}))", from, arr, idx) + format!("Instruction::APutWide({}, {}, {})", from, arr, idx) } Self::APutObject { idx, arr, from } => { - format!("Instruction(APutObject({}, {}, {}))", from, arr, idx) + format!("Instruction::APutObject({}, {}, {})", from, arr, idx) } Self::APutBoolean { idx, arr, from } => { - format!("Instruction(APutBoolean({}, {}, {}))", from, arr, idx) + format!("Instruction::APutBoolean({}, {}, {})", from, arr, idx) } Self::APutByte { idx, arr, from } => { - format!("Instruction(APutByte({}, {}, {}))", from, arr, idx) + format!("Instruction::APutByte({}, {}, {})", from, arr, idx) } Self::APutChar { idx, arr, from } => { - format!("Instruction(APutChar({}, {}, {}))", from, arr, idx) + format!("Instruction::APutChar({}, {}, {})", from, arr, idx) } Self::APutShort { idx, arr, from } => { - format!("Instruction(APutShort({}, {}, {}))", from, arr, idx) + format!("Instruction::APutShort({}, {}, {})", from, arr, idx) } Self::IGet { obj, field, to } => { - format!("Instruction(IGet({}, {}, {}))", to, obj, field.__repr__()) + format!("Instruction::IGet({}, {}, {})", to, obj, field.__repr__()) } Self::IGetWide { obj, field, to } => { format!( - "Instruction(IGetWide({}, {}, {}))", + "Instruction::IGetWide({}, {}, {})", to, obj, field.__repr__() @@ -3004,7 +3077,7 @@ impl Instruction { } Self::IGetObject { obj, field, to } => { format!( - "Instruction(IGetObject({}, {}, {}))", + "Instruction::IGetObject({}, {}, {})", to, obj, field.__repr__() @@ -3012,7 +3085,7 @@ impl Instruction { } Self::IGetBoolean { obj, field, to } => { format!( - "Instruction(IGetBoolean({}, {}, {}))", + "Instruction::IGetBoolean({}, {}, {})", to, obj, field.__repr__() @@ -3020,7 +3093,7 @@ impl Instruction { } Self::IGetByte { obj, field, to } => { format!( - "Instruction(IGetByte({}, {}, {}))", + "Instruction::IGetByte({}, {}, {})", to, obj, field.__repr__() @@ -3028,7 +3101,7 @@ impl Instruction { } Self::IGetChar { obj, field, to } => { format!( - "Instruction(IGetChar({}, {}, {}))", + "Instruction::IGetChar({}, {}, {})", to, obj, field.__repr__() @@ -3036,18 +3109,18 @@ impl Instruction { } Self::IGetShort { obj, field, to } => { format!( - "Instruction(IGetShort({}, {}, {}))", + "Instruction::IGetShort({}, {}, {})", to, obj, field.__repr__() ) } Self::IPut { obj, field, from } => { - format!("Instruction(IPut({}, {}, {}))", from, obj, field.__repr__()) + format!("Instruction::IPut({}, {}, {})", from, obj, field.__repr__()) } Self::IPutWide { obj, field, from } => { format!( - "Instruction(IPutWide({}, {}, {}))", + "Instruction::IPutWide({}, {}, {})", from, obj, field.__repr__() @@ -3055,7 +3128,7 @@ impl Instruction { } Self::IPutObject { obj, field, from } => { format!( - "Instruction(IPutObject({}, {}, {}))", + "Instruction::IPutObject({}, {}, {})", from, obj, field.__repr__() @@ -3063,7 +3136,7 @@ impl Instruction { } Self::IPutBoolean { obj, field, from } => { format!( - "Instruction(IPutBoolean({}, {}, {}))", + "Instruction::IPutBoolean({}, {}, {})", from, obj, field.__repr__() @@ -3071,7 +3144,7 @@ impl Instruction { } Self::IPutByte { obj, field, from } => { format!( - "Instruction(IPutByte({}, {}, {}))", + "Instruction::IPutByte({}, {}, {})", from, obj, field.__repr__() @@ -3079,7 +3152,7 @@ impl Instruction { } Self::IPutChar { obj, field, from } => { format!( - "Instruction(IPutChar({}, {}, {}))", + "Instruction::IPutChar({}, {}, {})", from, obj, field.__repr__() @@ -3087,53 +3160,53 @@ impl Instruction { } Self::IPutShort { obj, field, from } => { format!( - "Instruction(IPutShort({}, {}, {}))", + "Instruction::IPutShort({}, {}, {})", from, obj, field.__repr__() ) } Self::SGet { field, to } => { - format!("Instruction(SGet({}, {}))", to, field.__repr__()) + format!("Instruction::SGet({}, {})", to, field.__repr__()) } Self::SGetWide { field, to } => { - format!("Instruction(SGetWide({}, {}))", to, field.__repr__()) + format!("Instruction::SGetWide({}, {})", to, field.__repr__()) } Self::SGetObject { field, to } => { - format!("Instruction(SGetObject({}, {}))", to, field.__repr__()) + format!("Instruction::SGetObject({}, {})", to, field.__repr__()) } Self::SGetBoolean { field, to } => { - format!("Instruction(SGetBoolean({}, {}))", to, field.__repr__()) + format!("Instruction::SGetBoolean({}, {})", to, field.__repr__()) } Self::SGetByte { field, to } => { - format!("Instruction(SGetByte({}, {}))", to, field.__repr__()) + format!("Instruction::SGetByte({}, {})", to, field.__repr__()) } Self::SGetChar { field, to } => { - format!("Instruction(SGetChar({}, {}))", to, field.__repr__()) + format!("Instruction::SGetChar({}, {})", to, field.__repr__()) } Self::SGetShort { field, to } => { - format!("Instruction(SGetShort({}, {}))", to, field.__repr__()) + format!("Instruction::SGetShort({}, {})", to, field.__repr__()) } Self::SPut { field, from } => { - format!("Instruction(SPut({}, {}))", from, field.__repr__()) + format!("Instruction::SPut({}, {})", from, field.__repr__()) } Self::SPutWide { field, from } => { - format!("Instruction(SPutWide({}, {}))", from, field.__repr__()) + format!("Instruction::SPutWide({}, {})", from, field.__repr__()) } Self::SPutObject { field, from } => { - format!("Instruction(SPutObject({}, {}))", from, field.__repr__()) + format!("Instruction::SPutObject({}, {})", from, field.__repr__()) } Self::SPutBoolean { field, from } => { - format!("Instruction(SPutBoolean({}, {}))", from, field.__repr__()) + format!("Instruction::SPutBoolean({}, {})", from, field.__repr__()) } Self::SPutByte { field, from } => { - format!("Instruction(SPutByte({}, {}))", from, field.__repr__()) + format!("Instruction::SPutByte({}, {})", from, field.__repr__()) } Self::SPutChar { field, from } => { - format!("Instruction(SPutChar({}, {}))", from, field.__repr__()) + format!("Instruction::SPutChar({}, {})", from, field.__repr__()) } Self::SPutShort { field, from } => { - format!("Instruction(SPutShort({}, {}))", from, field.__repr__()) + format!("Instruction::SPutShort({}, {})", from, field.__repr__()) } Self::InvokeVirtual { args, method } => { let args = if args.len() >= 5 { @@ -3144,7 +3217,7 @@ impl Instruction { .collect::>() .join(" ") }; - format!("Instruction(InvokeVirtual({}, {}))", args, method.__str__()) + format!("Instruction::InvokeVirtual({}, {})", args, method.__str__()) } Self::InvokeSuper { args, method } => { let args = if args.len() >= 5 { @@ -3155,7 +3228,7 @@ impl Instruction { .collect::>() .join(" ") }; - format!("Instruction(InvokeSuper({}, {}))", args, method.__str__()) + format!("Instruction::InvokeSuper({}, {})", args, method.__str__()) } Self::InvokeDirect { args, method } => { let args = if args.len() >= 5 { @@ -3166,7 +3239,7 @@ impl Instruction { .collect::>() .join(" ") }; - format!("Instruction(InvokeDirect({}, {}))", args, method.__str__()) + format!("Instruction::InvokeDirect({}, {})", args, method.__str__()) } Self::InvokeStatic { args, method } => { let args = if args.len() >= 5 { @@ -3177,7 +3250,7 @@ impl Instruction { .collect::>() .join(" ") }; - format!("Instruction(InvokeStatic({}, {}))", args, method.__str__()) + format!("Instruction::InvokeStatic({}, {})", args, method.__str__()) } Self::InvokeInterface { args, method } => { let args = if args.len() >= 5 { @@ -3189,298 +3262,298 @@ impl Instruction { .join(" ") }; format!( - "Instruction(InvokeInterface({}, {}))", + "Instruction::InvokeInterface({}, {})", args, method.__str__() ) } Self::NegInt { val, dest } => { - format!("Instruction(NegInt({}, {}))", dest, val) + format!("Instruction::NegInt({}, {})", dest, val) } Self::NotInt { val, dest } => { - format!("Instruction(NotInt({}, {}))", dest, val) + format!("Instruction::NotInt({}, {})", dest, val) } Self::NegLong { val, dest } => { - format!("Instruction(NegLong({}, {}))", dest, val) + format!("Instruction::NegLong({}, {})", dest, val) } Self::NotLong { val, dest } => { - format!("Instruction(NotLong({}, {}))", dest, val) + format!("Instruction::NotLong({}, {})", dest, val) } Self::NegFloat { val, dest } => { - format!("Instruction(NegFloat({}, {}))", dest, val) + format!("Instruction::NegFloat({}, {})", dest, val) } Self::NegDouble { val, dest } => { - format!("Instruction(NegDouble({}, {}))", dest, val) + format!("Instruction::NegDouble({}, {})", dest, val) } Self::IntToLong { val, dest } => { - format!("Instruction(IntToLong({}, {}))", dest, val) + format!("Instruction::IntToLong({}, {})", dest, val) } Self::IntToFloat { val, dest } => { - format!("Instruction(IntToFloat({}, {}))", dest, val) + format!("Instruction::IntToFloat({}, {})", dest, val) } Self::IntToDouble { val, dest } => { - format!("Instruction(IntToDouble({}, {}))", dest, val) + format!("Instruction::IntToDouble({}, {})", dest, val) } Self::LongToInt { val, dest } => { - format!("Instruction(LongToInt({}, {}))", dest, val) + format!("Instruction::LongToInt({}, {})", dest, val) } Self::LongToFloat { val, dest } => { - format!("Instruction(LongToFloat({}, {}))", dest, val) + format!("Instruction::LongToFloat({}, {})", dest, val) } Self::LongToDouble { val, dest } => { - format!("Instruction(LongToDouble({}, {}))", dest, val) + format!("Instruction::LongToDouble({}, {})", dest, val) } Self::FloatToInt { val, dest } => { - format!("Instruction(FloatToInt({}, {}))", dest, val) + format!("Instruction::FloatToInt({}, {})", dest, val) } Self::FloatToLong { val, dest } => { - format!("Instruction(FloatToLong({}, {}))", dest, val) + format!("Instruction::FloatToLong({}, {})", dest, val) } Self::FloatToDouble { val, dest } => { - format!("Instruction(FloatToDouble({}, {}))", dest, val) + format!("Instruction::FloatToDouble({}, {})", dest, val) } Self::DoubleToInt { val, dest } => { - format!("Instruction(DoubleToInt({}, {}))", dest, val) + format!("Instruction::DoubleToInt({}, {})", dest, val) } Self::DoubleToLong { val, dest } => { - format!("Instruction(DoubleToLong({}, {}))", dest, val) + format!("Instruction::DoubleToLong({}, {})", dest, val) } Self::DoubleToFloat { val, dest } => { - format!("Instruction(DoubleToFloat({}, {}))", dest, val) + format!("Instruction::DoubleToFloat({}, {})", dest, val) } Self::IntToByte { val, dest } => { - format!("Instruction(IntToByte({}, {}))", dest, val) + format!("Instruction::IntToByte({}, {})", dest, val) } Self::IntToChar { val, dest } => { - format!("Instruction(IntToChar({}, {}))", dest, val) + format!("Instruction::IntToChar({}, {})", dest, val) } Self::IntToShort { val, dest } => { - format!("Instruction(IntToShort({}, {}))", dest, val) + format!("Instruction::IntToShort({}, {})", dest, val) } Self::AddInt { b, c, dest } => { - format!("Instruction(AddInt({}, {}, {}))", dest, b, c) + format!("Instruction::AddInt({}, {}, {})", dest, b, c) } Self::SubInt { b, c, dest } => { - format!("Instruction(SubInt({}, {}, {}))", dest, b, c) + format!("Instruction::SubInt({}, {}, {})", dest, b, c) } Self::MulInt { b, c, dest } => { - format!("Instruction(MulInt({}, {}, {}))", dest, b, c) + format!("Instruction::MulInt({}, {}, {})", dest, b, c) } Self::DivInt { b, c, dest } => { - format!("Instruction(DivInt({}, {}, {}))", dest, b, c) + format!("Instruction::DivInt({}, {}, {})", dest, b, c) } Self::RemInt { b, c, dest } => { - format!("Instruction(RemInt({}, {}, {}))", dest, b, c) + format!("Instruction::RemInt({}, {}, {})", dest, b, c) } Self::AndInt { b, c, dest } => { - format!("Instruction(AndInt({}, {}, {}))", dest, b, c) + format!("Instruction::AndInt({}, {}, {})", dest, b, c) } Self::OrInt { b, c, dest } => { - format!("Instruction(OrInt({}, {}, {}))", dest, b, c) + format!("Instruction::OrInt({}, {}, {})", dest, b, c) } Self::XorInt { b, c, dest } => { - format!("Instruction(XorInt({}, {}, {}))", dest, b, c) + format!("Instruction::XorInt({}, {}, {})", dest, b, c) } Self::ShlInt { b, c, dest } => { - format!("Instruction(ShlInt({}, {}, {}))", dest, b, c) + format!("Instruction::ShlInt({}, {}, {})", dest, b, c) } Self::ShrInt { b, c, dest } => { - format!("Instruction(ShrInt({}, {}, {}))", dest, b, c) + format!("Instruction::ShrInt({}, {}, {})", dest, b, c) } Self::UshrInt { b, c, dest } => { - format!("Instruction(UshrInt({}, {}, {}))", dest, b, c) + format!("Instruction::UshrInt({}, {}, {})", dest, b, c) } Self::AddLong { b, c, dest } => { - format!("Instruction(AddLong({}, {}, {}))", dest, b, c) + format!("Instruction::AddLong({}, {}, {})", dest, b, c) } Self::SubLong { b, c, dest } => { - format!("Instruction(SubLong({}, {}, {}))", dest, b, c) + format!("Instruction::SubLong({}, {}, {})", dest, b, c) } Self::MulLong { b, c, dest } => { - format!("Instruction(MulLong({}, {}, {}))", dest, b, c) + format!("Instruction::MulLong({}, {}, {})", dest, b, c) } Self::DivLong { b, c, dest } => { - format!("Instruction(DivLong({}, {}, {}))", dest, b, c) + format!("Instruction::DivLong({}, {}, {})", dest, b, c) } Self::RemLong { b, c, dest } => { - format!("Instruction(RemLong({}, {}, {}))", dest, b, c) + format!("Instruction::RemLong({}, {}, {})", dest, b, c) } Self::AndLong { b, c, dest } => { - format!("Instruction(AndLong({}, {}, {}))", dest, b, c) + format!("Instruction::AndLong({}, {}, {})", dest, b, c) } Self::OrLong { b, c, dest } => { - format!("Instruction(OrLong({}, {}, {}))", dest, b, c) + format!("Instruction::OrLong({}, {}, {})", dest, b, c) } Self::XorLong { b, c, dest } => { - format!("Instruction(XorLong({}, {}, {}))", dest, b, c) + format!("Instruction::XorLong({}, {}, {})", dest, b, c) } Self::ShlLong { b, c, dest } => { - format!("Instruction(ShlLong({}, {}, {}))", dest, b, c) + format!("Instruction::ShlLong({}, {}, {})", dest, b, c) } Self::ShrLong { b, c, dest } => { - format!("Instruction(ShrLong({}, {}, {}))", dest, b, c) + format!("Instruction::ShrLong({}, {}, {})", dest, b, c) } Self::UshrLong { b, c, dest } => { - format!("Instruction(UshrLong({}, {}, {}))", dest, b, c) + format!("Instruction::UshrLong({}, {}, {})", dest, b, c) } Self::AddFloat { b, c, dest } => { - format!("Instruction(AddFloat({}, {}, {}))", dest, b, c) + format!("Instruction::AddFloat({}, {}, {})", dest, b, c) } Self::SubFloat { b, c, dest } => { - format!("Instruction(SubFloat({}, {}, {}))", dest, b, c) + format!("Instruction::SubFloat({}, {}, {})", dest, b, c) } Self::MulFloat { b, c, dest } => { - format!("Instruction(MulFloat({}, {}, {}))", dest, b, c) + format!("Instruction::MulFloat({}, {}, {})", dest, b, c) } Self::DivFloat { b, c, dest } => { - format!("Instruction(DivFloat({}, {}, {}))", dest, b, c) + format!("Instruction::DivFloat({}, {}, {})", dest, b, c) } Self::RemFloat { b, c, dest } => { - format!("Instruction(RemFloat({}, {}, {}))", dest, b, c) + format!("Instruction::RemFloat({}, {}, {})", dest, b, c) } Self::AddDouble { b, c, dest } => { - format!("Instruction(AddDouble({}, {}, {}))", dest, b, c) + format!("Instruction::AddDouble({}, {}, {})", dest, b, c) } Self::SubDouble { b, c, dest } => { - format!("Instruction(SubDouble({}, {}, {}))", dest, b, c) + format!("Instruction::SubDouble({}, {}, {})", dest, b, c) } Self::MulDouble { b, c, dest } => { - format!("Instruction(MulDouble({}, {}, {}))", dest, b, c) + format!("Instruction::MulDouble({}, {}, {})", dest, b, c) } Self::DivDouble { b, c, dest } => { - format!("Instruction(DivDouble({}, {}, {}))", dest, b, c) + format!("Instruction::DivDouble({}, {}, {})", dest, b, c) } Self::RemDouble { b, c, dest } => { - format!("Instruction(RemDouble({}, {}, {}))", dest, b, c) + format!("Instruction::RemDouble({}, {}, {})", dest, b, c) } Self::AddInt2Addr { b, dest } => { - format!("Instruction(AddInt2Addr({}, {}))", dest, b) + format!("Instruction::AddInt2Addr({}, {})", dest, b) } Self::SubInt2Addr { b, dest } => { - format!("Instruction(SubInt2Addr({}, {}))", dest, b) + format!("Instruction::SubInt2Addr({}, {})", dest, b) } Self::MulInt2Addr { b, dest } => { - format!("Instruction(MulInt2Addr({}, {}))", dest, b) + format!("Instruction::MulInt2Addr({}, {})", dest, b) } Self::DivInt2Addr { b, dest } => { - format!("Instruction(DivInt2Addr({}, {}))", dest, b) + format!("Instruction::DivInt2Addr({}, {})", dest, b) } Self::RemInt2Addr { b, dest } => { - format!("Instruction(RemInt2Addr({}, {}))", dest, b) + format!("Instruction::RemInt2Addr({}, {})", dest, b) } Self::AndInt2Addr { b, dest } => { - format!("Instruction(AndInt2Addr({}, {}))", dest, b) + format!("Instruction::AndInt2Addr({}, {})", dest, b) } Self::OrInt2Addr { b, dest } => { - format!("Instruction(OrInt2Addr({}, {}))", dest, b) + format!("Instruction::OrInt2Addr({}, {})", dest, b) } Self::XorInt2Addr { b, dest } => { - format!("Instruction(XorInt2Addr({}, {}))", dest, b) + format!("Instruction::XorInt2Addr({}, {})", dest, b) } Self::ShlInt2Addr { b, dest } => { - format!("Instruction(ShlInt2Addr({}, {}))", dest, b) + format!("Instruction::ShlInt2Addr({}, {})", dest, b) } Self::ShrInt2Addr { b, dest } => { - format!("Instruction(ShrInt2Addr({}, {}))", dest, b) + format!("Instruction::ShrInt2Addr({}, {})", dest, b) } Self::UshrInt2Addr { b, dest } => { - format!("Instruction(UshrInt2Addr({}, {}))", dest, b) + format!("Instruction::UshrInt2Addr({}, {})", dest, b) } Self::AddLong2Addr { b, dest } => { - format!("Instruction(AddLong2Addr({}, {}))", dest, b) + format!("Instruction::AddLong2Addr({}, {})", dest, b) } Self::SubLong2Addr { b, dest } => { - format!("Instruction(SubLong2Addr({}, {}))", dest, b) + format!("Instruction::SubLong2Addr({}, {})", dest, b) } Self::MulLong2Addr { b, dest } => { - format!("Instruction(MulLong2Addr({}, {}))", dest, b) + format!("Instruction::MulLong2Addr({}, {})", dest, b) } Self::DivLong2Addr { b, dest } => { - format!("Instruction(DivLong2Addr({}, {}))", dest, b) + format!("Instruction::DivLong2Addr({}, {})", dest, b) } Self::RemLong2Addr { b, dest } => { - format!("Instruction(RemLong2Addr({}, {}))", dest, b) + format!("Instruction::RemLong2Addr({}, {})", dest, b) } Self::AndLong2Addr { b, dest } => { - format!("Instruction(AndLong2Addr({}, {}))", dest, b) + format!("Instruction::AndLong2Addr({}, {})", dest, b) } Self::OrLong2Addr { b, dest } => { - format!("Instruction(OrLong2Addr({}, {}))", dest, b) + format!("Instruction::OrLong2Addr({}, {})", dest, b) } Self::XorLong2Addr { b, dest } => { - format!("Instruction(XorLong2Addr({}, {}))", dest, b) + format!("Instruction::XorLong2Addr({}, {})", dest, b) } Self::ShlLong2Addr { b, dest } => { - format!("Instruction(ShlLong2Addr({}, {}))", dest, b) + format!("Instruction::ShlLong2Addr({}, {})", dest, b) } Self::ShrLong2Addr { b, dest } => { - format!("Instruction(ShrLong2Addr({}, {}))", dest, b) + format!("Instruction::ShrLong2Addr({}, {})", dest, b) } Self::UshrLong2Addr { b, dest } => { - format!("Instruction(UshrLong2Addr({}, {}))", dest, b) + format!("Instruction::UshrLong2Addr({}, {})", dest, b) } Self::AddFloat2Addr { b, dest } => { - format!("Instruction(AddFloat2Addr({}, {}))", dest, b) + format!("Instruction::AddFloat2Addr({}, {})", dest, b) } Self::SubFloat2Addr { b, dest } => { - format!("Instruction(SubFloat2Addr({}, {}))", dest, b) + format!("Instruction::SubFloat2Addr({}, {})", dest, b) } Self::MulFloat2Addr { b, dest } => { - format!("Instruction(MulFloat2Addr({}, {}))", dest, b) + format!("Instruction::MulFloat2Addr({}, {})", dest, b) } Self::DivFloat2Addr { b, dest } => { - format!("Instruction(DivFloat2Addr({}, {}))", dest, b) + format!("Instruction::DivFloat2Addr({}, {})", dest, b) } Self::RemFloat2Addr { b, dest } => { - format!("Instruction(RemFloat2Addr({}, {}))", dest, b) + format!("Instruction::RemFloat2Addr({}, {})", dest, b) } Self::AddDouble2Addr { b, dest } => { - format!("Instruction(AddDouble2Addr({}, {}))", dest, b) + format!("Instruction::AddDouble2Addr({}, {})", dest, b) } Self::SubDouble2Addr { b, dest } => { - format!("Instruction(SubDouble2Addr({}, {}))", dest, b) + format!("Instruction::SubDouble2Addr({}, {})", dest, b) } Self::MulDouble2Addr { b, dest } => { - format!("Instruction(MulDouble2Addr({}, {}))", dest, b) + format!("Instruction::MulDouble2Addr({}, {})", dest, b) } Self::DivDouble2Addr { b, dest } => { - format!("Instruction(DivDouble2Addr({}, {}))", dest, b) + format!("Instruction::DivDouble2Addr({}, {})", dest, b) } Self::RemDouble2Addr { b, dest } => { - format!("Instruction(RemDouble2Addr({}, {}))", dest, b) + format!("Instruction::RemDouble2Addr({}, {})", dest, b) } Self::AddIntLit { b, lit, dest } => { - format!("Instruction(AddIntLit({}, {}, {}))", dest, b, lit) + format!("Instruction::AddIntLit({}, {}, {})", dest, b, lit) } Self::RsubIntLit { b, lit, dest } => { - format!("Instruction(RsubIntLit({}, {}, {}))", dest, b, lit) + format!("Instruction::RsubIntLit({}, {}, {})", dest, b, lit) } Self::MulIntLit { b, lit, dest } => { - format!("Instruction(MulIntLit({}, {}, {}))", dest, b, lit) + format!("Instruction::MulIntLit({}, {}, {})", dest, b, lit) } Self::DivIntLit { b, lit, dest } => { - format!("Instruction(DivIntLit({}, {}, {}))", dest, b, lit) + format!("Instruction::DivIntLit({}, {}, {})", dest, b, lit) } Self::RemIntLit { b, lit, dest } => { - format!("Instruction(RemIntLit({}, {}, {}))", dest, b, lit) + format!("Instruction::RemIntLit({}, {}, {})", dest, b, lit) } Self::AndIntLit { b, lit, dest } => { - format!("Instruction(AndIntLit({}, {}, {}))", dest, b, lit) + format!("Instruction::AndIntLit({}, {}, {})", dest, b, lit) } Self::OrIntLit { b, lit, dest } => { - format!("Instruction(OrIntLit({}, {}, {}))", dest, b, lit) + format!("Instruction::OrIntLit({}, {}, {})", dest, b, lit) } Self::XorIntLit { b, lit, dest } => { - format!("Instruction(XorIntLit({}, {}, {}))", dest, b, lit) + format!("Instruction::XorIntLit({}, {}, {})", dest, b, lit) } Self::ShlIntLit { b, lit, dest } => { - format!("Instruction(ShlIntLit({}, {}, {}))", dest, b, lit) + format!("Instruction::ShlIntLit({}, {}, {})", dest, b, lit) } Self::ShrIntLit { b, lit, dest } => { - format!("Instruction(ShrIntLit({}, {}, {}))", dest, b, lit) + format!("Instruction::ShrIntLit({}, {}, {})", dest, b, lit) } Self::UshrIntLit { b, lit, dest } => { - format!("Instruction(UshrIntLit({}, {}, {}))", dest, b, lit) + format!("Instruction::UshrIntLit({}, {}, {})", dest, b, lit) } Self::InvokePolymorphic { args, @@ -3496,7 +3569,7 @@ impl Instruction { .join(" ") }; format!( - "Instruction(InvokePolymorphic({}, {}, {}))", + "Instruction::InvokePolymorphic({}, {}, {})", args, method.__str__(), proto.__str__() @@ -3512,20 +3585,20 @@ impl Instruction { .join(" ") }; format!( - "Instruction(InvokeCustom({}, {}))", + "Instruction::InvokeCustom({}, {})", args, call_site.__str__(), ) } Self::ConstMethodHandle { handle, to } => { format!( - "Instruction(ConstMethodHandle({}, {}))", + "Instruction::ConstMethodHandle({}, {})", to, handle.__repr__() ) } Self::ConstMethodType { proto, to } => { - format!("Instruction(ConstMethodType({}, {}))", to, proto.__repr__()) + format!("Instruction::ConstMethodType({}, {})", to, proto.__repr__()) } Self::Try { end_label, @@ -3538,13 +3611,33 @@ impl Instruction { .collect::>() .join(", "); format!( - "Instruction(Try({}, [{}], {:?}))", + "Instruction::Try({}, [{}], {:?})", end_label, handlers, default_handler, ) } Self::Label { name } => { - format!("Instruction(Label({}))", name) + format!("Instruction::Label({})", name) } + Self::DebugLocal { + reg, + name, + type_, + signature, + } => { + let name = name.clone().unwrap_or("None".into()); + let type_ = type_ + .as_ref() + .map(IdType::__repr__) + .unwrap_or("None".into()); + let signature = signature.clone().unwrap_or("None".into()); + format!("Instruction::DebugLoca({reg}, {name}, {type_}, {signature}") + } + Self::DebugEndLocal { reg } => format!("Instruction::DebugEndLocal({reg})"), + Self::DebugEndPrologue {} => "Instruction::DebugEndPrologue".into(), + Self::DebugBeginEpilogue {} => "Instruction::DebugBeginEpilogue".into(), + // TODO: check if/how apktool/smali handles empty change of src file + Self::DebugSourceFile { file } => format!("Instruction::DebugSourceFile({file})"), + Self::DebugLine { number } => format!("Instruction::DebugLine({number})"), } } @@ -3652,6 +3745,12 @@ impl Instruction { Self::ConstMethodType { .. } => Ok(4), Self::Try { .. } => Ok(0), Self::Label { .. } => Ok(0), + Self::DebugLocal { .. } => Ok(0), + Self::DebugEndLocal { .. } => Ok(0), + Self::DebugEndPrologue {} => Ok(0), + Self::DebugBeginEpilogue {} => Ok(0), + Self::DebugSourceFile { .. } => Ok(0), + Self::DebugLine { .. } => Ok(0), _ => self .get_raw_ins(GetRawInsParam::default()) .map(|ins| ins.size()), @@ -4160,6 +4259,12 @@ impl Instruction { /// /// - `Try` /// - `Label` + /// - `DebugLocal` + /// - `DebugEndLocal` + /// - `DebugEndPrologue` + /// - `DebugBeginEpilogue` + /// - `DebugSourceFile` + /// - `DebugLine` /// pub fn get_raw_ins(&self, param: GetRawInsParam) -> Result { match (self, param) { @@ -5373,6 +5478,24 @@ impl Instruction { (Self::Label { .. }, GetRawInsParam { .. }) => { Err(anyhow!("Label cannot be converted to raw instruction")) } + (Self::DebugLocal { .. }, GetRawInsParam { .. }) => Err(anyhow!( + "Debug information cannot be converted to raw instruction" + )), + (Self::DebugEndLocal { .. }, GetRawInsParam { .. }) => Err(anyhow!( + "Debug information cannot be converted to raw instruction" + )), + (Self::DebugEndPrologue {}, GetRawInsParam { .. }) => Err(anyhow!( + "Debug information cannot be converted to raw instruction" + )), + (Self::DebugBeginEpilogue {}, GetRawInsParam { .. }) => Err(anyhow!( + "Debug information cannot be converted to raw instruction" + )), + (Self::DebugSourceFile { .. }, GetRawInsParam { .. }) => Err(anyhow!( + "Debug information cannot be converted to raw instruction" + )), + (Self::DebugLine { .. }, GetRawInsParam { .. }) => Err(anyhow!( + "Debug information cannot be converted to raw instruction" + )), (Self::Nop {}, GetRawInsParam { .. }) => Ok(InsFormat::Format10X { op: 0x00 }), (Self::Move { from, to }, GetRawInsParam { .. }) => match (to, from) { (0..=0b0000_1111, 0..=0b0000_1111) => Ok(InsFormat::Format12X { @@ -6615,7 +6738,7 @@ impl Visitable for CallSite { v.visit_string(&self.name)?; v.visit_method_type(&self.type_)?; for arg in &self.args { - v.visit_value(&arg)?; + v.visit_value(arg)?; } Ok(()) } diff --git a/androscalpel/src/method.rs b/androscalpel/src/method.rs index 448718d..585b368 100644 --- a/androscalpel/src/method.rs +++ b/androscalpel/src/method.rs @@ -304,18 +304,18 @@ impl Visitable for Method { v.visit_method_id(&self.descriptor)?; v.visit_method_visibility(&self.visibility)?; for annot in &self.annotations { - v.visit_annotation_item(&annot)?; + v.visit_annotation_item(annot)?; } for parameter_annotations in &self.parameters_annotations { for annot in parameter_annotations { - v.visit_annotation_item(&annot)?; + v.visit_annotation_item(annot)?; } } if let Some(hiddenapi) = &self.hiddenapi { - v.visit_hidden_api_data(&hiddenapi)?; + v.visit_hidden_api_data(hiddenapi)?; } if let Some(code) = &self.code { - v.visit_code(&code)?; + v.visit_code(code)?; } Ok(()) } diff --git a/androscalpel/src/scalar.rs b/androscalpel/src/scalar.rs index f11a174..4db05da 100644 --- a/androscalpel/src/scalar.rs +++ b/androscalpel/src/scalar.rs @@ -424,7 +424,7 @@ impl DexArray { impl Visitable for DexArray { fn default_visit(&self, v: &mut V) -> Result<()> { for val in &self.0 { - v.visit_value(&val)?; + v.visit_value(val)?; } Ok(()) } diff --git a/androscalpel_serializer/src/debug.rs b/androscalpel_serializer/src/debug.rs index ad1006f..8cbac6f 100644 --- a/androscalpel_serializer/src/debug.rs +++ b/androscalpel_serializer/src/debug.rs @@ -199,7 +199,7 @@ impl DebugInfoItem { address = addr; addr_diff = 0; } - if line_diff < -4 || line_diff >= 15 - 4 { + if !(-4..15 - 4).contains(&line_diff) { bytecode.push(DbgBytecode::AdvanceLine { line_diff: Sleb128(line_diff), }); @@ -215,7 +215,7 @@ impl DebugInfoItem { } } } - if bytecode.len() == 0 || bytecode[bytecode.len() - 1] != DbgBytecode::EndSequence { + if bytecode.is_empty() || bytecode[bytecode.len() - 1] != DbgBytecode::EndSequence { bytecode.push(DbgBytecode::EndSequence); } Self {