start debugging

This commit is contained in:
Jean-Marie 'Histausse' Mineau 2025-02-27 16:40:43 +01:00
parent 540e0223fc
commit e16252907a
Signed by: histausse
GPG key ID: B66AEEDA9B645AD2
3 changed files with 18 additions and 2 deletions

View file

@ -12,6 +12,16 @@ use serde::{Deserialize, Serialize};
// https://cs.android.com/android/platform/superproject/main/+/main:art/runtime/reflection.cc;drc=83db0626fad8c6e0508754fffcbbd58e539d14a5;l=698
// does.
/// Inject arbitrary text in the instructions array as 'source file' debug info.
/// It's cursed, but it work XD
fn debug_info(data: &str) -> Vec<Instruction> {
data.split("\n")
.map(|data| Instruction::DebugSourceFile {
file: Some(format!(" {data: <70}").into()),
})
.collect()
}
#[derive(Clone, PartialEq, Debug, Deserialize, Serialize)]
pub struct ReflectionData {
pub invoke_data: Vec<ReflectionInvokeData>,
@ -1140,7 +1150,12 @@ fn test_method(
args: vec![method_obj_reg],
},
Instruction::MoveResultObject { to: reg_inf.array },
// First check the number of args
];
// First check the number of args
// TODO: remove, test
insns.append(&mut debug_info(&format!("{:#?}", reg_inf)));
// --------------------
insns.append(&mut vec![
Instruction::ArrayLength {
dest: reg_inf.array_index,
arr: reg_inf.array,
@ -1154,7 +1169,7 @@ fn test_method(
b: reg_inf.array_val,
label: abort_label.clone(),
},
];
]);
// then the type of each arg
for (i, param) in id_method.proto.get_parameters().into_iter().enumerate() {
insns.push(Instruction::Const {

View file

@ -0,0 +1 @@
{"invoke_data": [{"method": "Lcom/example/theseus/reflection/Reflectee;->transfer(Ljava/lang/String;)Ljava/lang/String;", "caller_method": "Lcom/example/theseus/reflection/MainActivity;->callVirtualMethodReflectCall()V", "addr": 43}, {"method": "Lcom/example/theseus/reflection/Reflectee;->transfer(Ljava/lang/String;)Ljava/lang/String;", "caller_method": "Lcom/example/theseus/reflection/MainActivity;->callConstructorVirtualMethodReflectConstr()V", "addr": 56}, {"method": "Lcom/example/theseus/reflection/Reflectee;->transfer(Ljava/lang/String;)Ljava/lang/String;", "caller_method": "Lcom/example/theseus/reflection/MainActivity;->callVirtualMethodReflectOldConst()V", "addr": 40}, {"method": "Lcom/example/theseus/reflection/Reflectee;->transfer(ZBSCIJFDLjava/lang/String;)Ljava/lang/String;", "caller_method": "Lcom/example/theseus/reflection/MainActivity;->callVirtualMethodReflectCallAllScalar()V", "addr": 153}, {"method": "Lcom/example/theseus/reflection/Reflectee;->transfer(Ljava/lang/String;[Ljava/lang/String;)Ljava/lang/String;", "caller_method": "Lcom/example/theseus/reflection/MainActivity;->callVirtualMethodReflectVarArg()V", "addr": 65}], "class_new_inst_data": [{"constructor": "Landroid/app/Application;-><init>()V", "caller_method": "Landroid/app/AppComponentFactory;->instantiateApplication(Ljava/lang/ClassLoader;Ljava/lang/String;)Landroid/app/Application;", "addr": 4}, {"constructor": "Lcom/example/theseus/reflection/MainActivity;-><init>()V", "caller_method": "Landroid/app/AppComponentFactory;->instantiateActivity(Ljava/lang/ClassLoader;Ljava/lang/String;Landroid/content/Intent;)Landroid/app/Activity;", "addr": 4}, {"constructor": "Lcom/example/theseus/reflection/Reflectee;-><init>()V", "caller_method": "Lcom/example/theseus/reflection/MainActivity;->callVirtualMethodReflectOldConst()V", "addr": 18}], "cnstr_new_inst_data": [{"constructor": "Lcom/example/theseus/reflection/Reflectee;-><init>(Ljava/lang/String;)V", "caller_method": "Lcom/example/theseus/reflection/MainActivity;->callConstructorVirtualMethodReflectConstr()V", "addr": 34}]}