Skip to content

Commit 5ef7b3b

Browse files
committed
Add more debugs to confirm why ARM-32 hypercalls are failing for LAVA
1 parent 8f5a213 commit 5ef7b3b

2 files changed

Lines changed: 31 additions & 11 deletions

File tree

panda/plugins/dwarf2/dwarf2.cpp

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2321,7 +2321,7 @@ void dwarf_get_vma_symbol (CPUState *cpu, target_ulong pc, target_ulong vma, cha
23212321
// This is the function called by 'pri_get_pc_source_info' in pri_taint.cpp
23222322
void dwarf_get_pc_source_info(CPUState *cpu, target_ulong pc, SrcInfo *info, int *rc) {
23232323
if (!correct_asid(cpu)) {
2324-
dprintf("Not in a correct asid in dwarf_get_pc_source_info\n");
2324+
dprintf("[dwarf2] Not in a correct asid in dwarf_get_pc_source_info\n");
23252325
*rc = -1;
23262326
return;
23272327
}
@@ -2344,23 +2344,35 @@ void dwarf_get_pc_source_info(CPUState *cpu, target_ulong pc, SrcInfo *info, int
23442344
*rc = 1;
23452345
}
23462346
else {
2347-
dprintf("Error found in plt function\n");
2347+
dprintf("[dwarf2] Error found in plt function\n");
23482348
*rc = -1;
23492349
}
23502350
return;
23512351
}
23522352

23532353
if (it->lowpc == it->highpc) {
2354-
dprintf("In a a plt function\n");
2354+
dprintf("[dwarf2] In a a plt function\n");
23552355
*rc = 1;
23562356
return;
23572357
}
23582358
// we are in dwarf-land, so populate info struct
23592359
target_ulong call_site_fn = it->function_addr;
2360-
info->filename = it->filename.c_str();
2360+
if (it->filename.empty()) {
2361+
info->filename = "unknown_file";
2362+
} else {
2363+
info->filename = it->filename.c_str();
2364+
}
23612365
info->line_number = it->line_number;
2362-
std::string funct_name = funcaddrs[call_site_fn];
2363-
info->funct_name = funct_name.c_str();
2366+
2367+
auto func_it = funcaddrs.find(call_site_fn);
2368+
if (func_it != funcaddrs.end()) {
2369+
// CRITICAL: Point directly to the string inside the global map.
2370+
// This memory persists long after this function returns!
2371+
info->funct_name = func_it->second.c_str();
2372+
} else {
2373+
dprintf("[dwarf2] Warning: function address 0x%lx not found in funcaddrs map\n", call_site_fn);
2374+
info->funct_name = "unknown_function";
2375+
}
23642376
*rc = 0;
23652377
return;
23662378
}

panda/plugins/pri_taint/pri_taint.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ void lava_hypercall(CPUState *cpu) {
449449
#endif
450450
}
451451
else if (pandalog) {
452-
dprintf("[pri_taint] Hypercall is OK and Panda Log is set\n");
452+
dprintf("[pri_taint] Hypercall is OK and Panda Log is set\n");
453453
PandaHypercallStruct phs;
454454
#if defined(TARGET_ARM) && !defined(TARGET_AARCH64)
455455
panda_virtual_memory_read(cpu, env->regs[0], (uint8_t *) &phs, sizeof(phs));
@@ -461,23 +461,31 @@ void lava_hypercall(CPUState *cpu) {
461461
panda_virtual_memory_read(cpu, env->regs[R_EDI], (uint8_t *) &phs, sizeof(phs));
462462
#endif
463463

464+
dprintf("[pri_taint] Completed memory read of PANDA Hypercall Struct\n");
465+
464466
// To be used for chaff bugs?
465467
uint64_t funcaddr = 0;
466468
panda_virtual_memory_read(cpu, phs.info, (uint8_t*)&funcaddr, sizeof(target_ulong));
469+
dprintf("[pri_taint] Completed memory read of the phs.info for Chaff Bugs\n");
467470
// if the phs action is a pri_query point, see
468471
// lava/include/pirate_mark_lava.h
469472
if (phs.action == 13) {
470473
target_ulong pc = panda_current_pc(cpu);
474+
dprintf("[pri_taint] ABOUT TO CALL pri_get_pc_source_info for PC: 0x%lx\n", (uint64_t) pc);
471475
// Calls 'pri_get_pc_source_info' in pri.c, which calls 'on_get_pc_source_info'
472476
// In Dwarf2, the function 'on_get_pc_source_info' is mapped to 'dwarf_get_pc_source_info'
473477
SrcInfo info;
474478
int rc = pri_get_pc_source_info(cpu, pc, &info);
479+
dprintf("[pri_taint] SURVIVED pri_get_pc_source_info! rc = %d\n", rc);
475480
if (!rc) {
476481
struct args args = {cpu, info.filename, info.line_number, phs.src_filename, funcaddr};
477-
dprintf("[pri_taint] panda hypercall: [%s], "
478-
"ln: %4ld, pc @ 0x" TARGET_FMT_lx "\n",
479-
info.filename,
480-
info.line_number, pc);
482+
if (info.filename == NULL) {
483+
dprintf("[pri_taint] CRITICAL: info.filename is NULL! Cannot print.\n");
484+
} else {
485+
dprintf("[pri_taint] panda hypercall: [%s], ln: %4ld, pc @ 0x" TARGET_FMT_lx "\n",
486+
info.filename, info.line_number, pc);
487+
}
488+
481489
// Calls 'pri_funct_livevar_iter' in pri.c, which calls 'on_funct_livevar_iter'
482490
// In Dwarf2, the function 'on_funct_livevar_iter' is mapped to 'dwarf_funct_livevar_iter'
483491
// This is passing the function 'pfun' to 'pri_funct_livevar_iter', which is called at the end

0 commit comments

Comments
 (0)