fix fix fix!
This commit is contained in:
parent
1d62277f42
commit
65176749bb
5 changed files with 31 additions and 36 deletions
|
|
@ -2761,7 +2761,7 @@ impl Apk {
|
||||||
let mut insns = vec![];
|
let mut insns = vec![];
|
||||||
for (addr, ins) in instructions {
|
for (addr, ins) in instructions {
|
||||||
while current_debug_info != DebugInfo::EndOfData
|
while current_debug_info != DebugInfo::EndOfData
|
||||||
&& addr <= current_debug_info.get_addr() as usize
|
&& current_debug_info.get_addr() as usize <= addr
|
||||||
{
|
{
|
||||||
insns.push(match current_debug_info {
|
insns.push(match current_debug_info {
|
||||||
DebugInfo::DefLocal { reg, val, .. } => Instruction::DebugLocal {
|
DebugInfo::DefLocal { reg, val, .. } => Instruction::DebugLocal {
|
||||||
|
|
|
||||||
|
|
@ -2273,19 +2273,19 @@ impl Instruction {
|
||||||
format!("if-eqz {} {}", a, label)
|
format!("if-eqz {} {}", a, label)
|
||||||
}
|
}
|
||||||
Self::IfNeZ { label, a } => {
|
Self::IfNeZ { label, a } => {
|
||||||
format!("if-neq {} {}", a, label)
|
format!("if-nez {} {}", a, label)
|
||||||
}
|
}
|
||||||
Self::IfLtZ { label, a } => {
|
Self::IfLtZ { label, a } => {
|
||||||
format!("if-lt {} {}", a, label)
|
format!("if-ltz {} {}", a, label)
|
||||||
}
|
}
|
||||||
Self::IfGeZ { label, a } => {
|
Self::IfGeZ { label, a } => {
|
||||||
format!("if-ge {} {}", a, label)
|
format!("if-gez {} {}", a, label)
|
||||||
}
|
}
|
||||||
Self::IfGtZ { label, a } => {
|
Self::IfGtZ { label, a } => {
|
||||||
format!("if-gt {} {}", a, label)
|
format!("if-gtz {} {}", a, label)
|
||||||
}
|
}
|
||||||
Self::IfLeZ { label, a } => {
|
Self::IfLeZ { label, a } => {
|
||||||
format!("if-le {} {}", a, label)
|
format!("if-lez {} {}", a, label)
|
||||||
}
|
}
|
||||||
Self::AGet { arr, idx, dest } => {
|
Self::AGet { arr, idx, dest } => {
|
||||||
format!("aget {} {} {}", dest, arr, idx)
|
format!("aget {} {} {}", dest, arr, idx)
|
||||||
|
|
@ -3015,19 +3015,19 @@ impl Instruction {
|
||||||
format!("Instruction::IfEqZ({}, {})", a, label)
|
format!("Instruction::IfEqZ({}, {})", a, label)
|
||||||
}
|
}
|
||||||
Self::IfNeZ { a, label } => {
|
Self::IfNeZ { a, label } => {
|
||||||
format!("Instruction::IfNe({}, {})", a, label)
|
format!("Instruction::IfNeZ({}, {})", a, label)
|
||||||
}
|
}
|
||||||
Self::IfLtZ { a, label } => {
|
Self::IfLtZ { a, label } => {
|
||||||
format!("Instruction::IfLt({}, {})", a, label)
|
format!("Instruction::IfLtZ({}, {})", a, label)
|
||||||
}
|
}
|
||||||
Self::IfGeZ { a, label } => {
|
Self::IfGeZ { a, label } => {
|
||||||
format!("Instruction::IfGe({}, {})", a, label)
|
format!("Instruction::IfGeZ({}, {})", a, label)
|
||||||
}
|
}
|
||||||
Self::IfGtZ { a, label } => {
|
Self::IfGtZ { a, label } => {
|
||||||
format!("Instruction::IfGt({}, {})", a, label)
|
format!("Instruction::IfGtZ({}, {})", a, label)
|
||||||
}
|
}
|
||||||
Self::IfLeZ { a, label } => {
|
Self::IfLeZ { a, label } => {
|
||||||
format!("Instruction::IfLe({}, {})", a, label)
|
format!("Instruction::IfLeZ({}, {})", a, label)
|
||||||
}
|
}
|
||||||
Self::AGet { idx, arr, dest } => {
|
Self::AGet { idx, arr, dest } => {
|
||||||
format!("Instruction::AGet({}, {}, {})", dest, arr, idx)
|
format!("Instruction::AGet({}, {}, {})", dest, arr, idx)
|
||||||
|
|
@ -4748,7 +4748,7 @@ impl Instruction {
|
||||||
jump_data: Some((addr, label_addrs)),
|
jump_data: Some((addr, label_addrs)),
|
||||||
..
|
..
|
||||||
},
|
},
|
||||||
) => raw_ins_ifz!(0x3b, label_addrs, label, addr, a),
|
) => raw_ins_ifz!(0x3d, label_addrs, label, addr, a),
|
||||||
(
|
(
|
||||||
Self::IGet { .. },
|
Self::IGet { .. },
|
||||||
GetRawInsParam {
|
GetRawInsParam {
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ use androscalpel_serializer::consts::*;
|
||||||
|
|
||||||
/// Represent a method.
|
/// Represent a method.
|
||||||
#[pyclass]
|
#[pyclass]
|
||||||
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
|
#[derive(Debug, Clone, Deserialize, Serialize)] //, PartialEq)]
|
||||||
pub struct Method {
|
pub struct Method {
|
||||||
/// The structure used to reference this method.
|
/// The structure used to reference this method.
|
||||||
#[pyo3(get)]
|
#[pyo3(get)]
|
||||||
|
|
@ -70,16 +70,15 @@ pub struct Method {
|
||||||
#[pyo3(get)]
|
#[pyo3(get)]
|
||||||
pub code: Option<Code>,
|
pub code: Option<Code>,
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
impl PartialEq for Method {
|
impl PartialEq for Method {
|
||||||
fn eq(&self, other: &Self) -> bool {
|
fn eq(&self, other: &Self) -> bool {
|
||||||
let res = self.code.eq(other.code);
|
let res = self.code.eq(&other.code);
|
||||||
if !res {
|
if !res {
|
||||||
panic!("{} code don't match", self.descriptor.__str__());
|
//panic!("{} code don't match", self.descriptor.__str__());
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
|
|
||||||
/// Represent the visibility of a field
|
/// Represent the visibility of a field
|
||||||
#[pyclass]
|
#[pyclass]
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,6 @@ use std::ops::Deref;
|
||||||
use std::sync::{Mutex, OnceLock};
|
use std::sync::{Mutex, OnceLock};
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
|
|
||||||
//use pretty_assertions::assert_eq;
|
|
||||||
|
|
||||||
fn write_to_report(data: &str) {
|
fn write_to_report(data: &str) {
|
||||||
static REPORT_FILE: Mutex<Option<File>> = Mutex::new(None);
|
static REPORT_FILE: Mutex<Option<File>> = Mutex::new(None);
|
||||||
let mut report_file = REPORT_FILE.lock().unwrap();
|
let mut report_file = REPORT_FILE.lock().unwrap();
|
||||||
|
|
@ -146,13 +144,11 @@ fn test_generated_apk_equivalence() {
|
||||||
new_apk
|
new_apk
|
||||||
.add_dex_file("classes.dex", &new_dex, false, false)
|
.add_dex_file("classes.dex", &new_dex, false, false)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
use pretty_assertions::assert_eq;
|
||||||
let method = IdMethod::from_smali(
|
let method = IdMethod::from_smali(
|
||||||
"Lkotlinx/coroutines/flow/internal/SafeCollector_commonKt$unsafeFlow$1$collect$1;->\
|
"Lcom/google/android/material/datepicker/DateFormatTextWatcher;->lambda$new$0$com-google-android-material-datepicker-DateFormatTextWatcher(Ljava/lang/String;)V"
|
||||||
invokeSuspend(\
|
|
||||||
Ljava/lang/Object;\
|
|
||||||
)\
|
|
||||||
Ljava/lang/Object;",
|
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|
|
||||||
|
|
@ -384,7 +384,7 @@ impl DebugInfoReader {
|
||||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||||
pub struct DebugInfoBuilder {
|
pub struct DebugInfoBuilder {
|
||||||
debug_infos: Vec<DbgBytecode>,
|
debug_infos: Vec<DbgBytecode>,
|
||||||
line_start: u32,
|
line_start: Option<u32>,
|
||||||
parameter_names: Vec<Uleb128p1>,
|
parameter_names: Vec<Uleb128p1>,
|
||||||
|
|
||||||
//pub pc: usize,
|
//pub pc: usize,
|
||||||
|
|
@ -402,7 +402,7 @@ impl DebugInfoBuilder {
|
||||||
pub fn new(parameter_names: Vec<Uleb128p1>) -> Self {
|
pub fn new(parameter_names: Vec<Uleb128p1>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
debug_infos: vec![],
|
debug_infos: vec![],
|
||||||
line_start: 0,
|
line_start: None,
|
||||||
parameter_names,
|
parameter_names,
|
||||||
//pc: 0,
|
//pc: 0,
|
||||||
address: 0,
|
address: 0,
|
||||||
|
|
@ -578,19 +578,12 @@ impl DebugInfoBuilder {
|
||||||
self.address
|
self.address
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
if self.line_start == 0 {
|
if self.line_start.is_none() {
|
||||||
self.line_start = *line_num;
|
self.line_start = Some(*line_num);
|
||||||
self.line = *line_num;
|
self.line = *line_num;
|
||||||
}
|
}
|
||||||
let mut line_diff = *line_num as i32 - self.line as i32;
|
let mut line_diff = *line_num as i32 - self.line as i32;
|
||||||
let mut addr_diff = addr - self.address;
|
let mut addr_diff = addr - self.address;
|
||||||
if addr_diff > (0xff - 0x0a) / 15 {
|
|
||||||
self.debug_infos.push(DbgBytecode::AdvancePC {
|
|
||||||
addr_diff: Uleb128(addr_diff),
|
|
||||||
});
|
|
||||||
self.address = *addr;
|
|
||||||
addr_diff = 0;
|
|
||||||
}
|
|
||||||
if !(-4..15 - 4).contains(&line_diff) {
|
if !(-4..15 - 4).contains(&line_diff) {
|
||||||
self.debug_infos.push(DbgBytecode::AdvanceLine {
|
self.debug_infos.push(DbgBytecode::AdvanceLine {
|
||||||
line_diff: Sleb128(line_diff),
|
line_diff: Sleb128(line_diff),
|
||||||
|
|
@ -598,6 +591,13 @@ impl DebugInfoBuilder {
|
||||||
self.line = *line_num;
|
self.line = *line_num;
|
||||||
line_diff = 0;
|
line_diff = 0;
|
||||||
}
|
}
|
||||||
|
if addr_diff as i32 * 15 + 0x0a + line_diff + 4 > 0xff {
|
||||||
|
self.debug_infos.push(DbgBytecode::AdvancePC {
|
||||||
|
addr_diff: Uleb128(addr_diff),
|
||||||
|
});
|
||||||
|
self.address = *addr;
|
||||||
|
addr_diff = 0;
|
||||||
|
}
|
||||||
let op = 0x0a + addr_diff as u8 * 15 + (line_diff + 4) as u8;
|
let op = 0x0a + addr_diff as u8 * 15 + (line_diff + 4) as u8;
|
||||||
self.debug_infos.push(DbgBytecode::SpecialOpcode(op));
|
self.debug_infos.push(DbgBytecode::SpecialOpcode(op));
|
||||||
self.address += addr_diff;
|
self.address += addr_diff;
|
||||||
|
|
@ -637,7 +637,7 @@ impl DebugInfoBuilder {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Some(DebugInfoItem {
|
Some(DebugInfoItem {
|
||||||
line_start: Uleb128(self.line_start),
|
line_start: Uleb128(self.line_start.unwrap_or(0)),
|
||||||
parameter_names: self.parameter_names,
|
parameter_names: self.parameter_names,
|
||||||
bytecode: self.debug_infos,
|
bytecode: self.debug_infos,
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue