@@ -55,10 +55,8 @@ extern "C" {
55
55
#include " panda/plog.h"
56
56
#include " callstack_instr_int_fns.h"
57
57
58
- bool translate_callback (CPUState* cpu, target_ulong pc);
59
- int exec_callback (CPUState* cpu, target_ulong pc);
60
- void before_block_exec (CPUState* cpu, TranslationBlock *tb);
61
- void after_block_exec (CPUState* cpu, TranslationBlock *tb, uint8_t exitCode);
58
+ void start_block_exec (CPUState* cpu, TranslationBlock *tb);
59
+ void end_block_exec (CPUState* cpu, TranslationBlock *tb);
62
60
void after_block_translate (CPUState* cpu, TranslationBlock *tb);
63
61
64
62
bool init_plugin (void *);
@@ -322,7 +320,7 @@ void after_block_translate(CPUState *cpu, TranslationBlock *tb) {
322
320
return ;
323
321
}
324
322
325
- void before_block_exec (CPUState *cpu, TranslationBlock *tb) {
323
+ void start_block_exec (CPUState *cpu, TranslationBlock *tb) {
326
324
// if the block a call returns to was interrupted before it completed, this
327
325
// function will be called twice - only want to remove the return value from
328
326
// the stack once
@@ -366,7 +364,7 @@ void before_block_exec(CPUState *cpu, TranslationBlock *tb) {
366
364
}
367
365
}
368
366
369
- void after_block_exec (CPUState* cpu, TranslationBlock *tb, uint8_t exitCode ) {
367
+ void end_block_exec (CPUState* cpu, TranslationBlock *tb) {
370
368
target_ulong pc = 0x0 ;
371
369
target_ulong cs_base = 0x0 ;
372
370
uint32_t flags = 0x0 ;
@@ -377,35 +375,19 @@ void after_block_exec(CPUState* cpu, TranslationBlock *tb, uint8_t exitCode) {
377
375
378
376
// sometimes an attempt to run a block is interrupted, but this callback is
379
377
// still made - only update the callstack if the block has run to completion
380
- if (exitCode <= TB_EXIT_IDX1) {
381
- if (tb_type == INSTR_CALL) {
382
- stack_entry se = {tb->pc + tb->size , tb_type};
383
- callstacks[curStackid].push_back (se);
384
-
385
- // Also track the function that gets called
386
- // This retrieves the pc in an architecture-neutral way
387
- cpu_get_tb_cpu_state (env, &pc, &cs_base, &flags);
388
- function_stacks[curStackid].push_back (pc);
389
-
390
- PPP_RUN_CB (on_call, cpu, pc);
391
- } else if (tb_type == INSTR_RET) {
392
- // printf("Just executed a RET in TB " TARGET_FMT_lx "\n", tb->pc);
393
- // if (next) printf("Next TB: " TARGET_FMT_lx "\n", next->pc);
394
- }
395
- }
396
- // in case this block is one that a call returns to, need to node that its
397
- // execution was interrupted, so don't try to remove it from the callstack
398
- // when try (as already removed before this attempt)
399
- else {
400
- // verbose output is helpful in regression testing
401
- if (tb_type == INSTR_CALL) {
402
- verbose_log (" callstack_instr not adding Stopped caller to stack" ,
403
- tb, curStackid, true );
404
- }
378
+ if (tb_type == INSTR_CALL) {
379
+ stack_entry se = {tb->pc + tb->size , tb_type};
380
+ callstacks[curStackid].push_back (se);
381
+
382
+ // Also track the function that gets called
383
+ // This retrieves the pc in an architecture-neutral way
405
384
cpu_get_tb_cpu_state (env, &pc, &cs_base, &flags);
406
- // erase nicely does nothing if key DNE
407
- stoppedInfo.erase (curStackid);
408
- stoppedInfo[curStackid] = pc;
385
+ function_stacks[curStackid].push_back (pc);
386
+
387
+ PPP_RUN_CB (on_call, cpu, pc);
388
+ } else if (tb_type == INSTR_RET) {
389
+ // printf("Just executed a RET in TB " TARGET_FMT_lx "\n", tb->pc);
390
+ // if (next) printf("Next TB: " TARGET_FMT_lx "\n", next->pc);
409
391
}
410
392
}
411
393
@@ -611,10 +593,10 @@ bool init_plugin(void *self) {
611
593
612
594
pcb.after_block_translate = after_block_translate;
613
595
panda_register_callback (self, PANDA_CB_AFTER_BLOCK_TRANSLATE, pcb);
614
- pcb.after_block_exec = after_block_exec ;
615
- panda_register_callback (self, PANDA_CB_AFTER_BLOCK_EXEC , pcb);
616
- pcb.before_block_exec = before_block_exec ;
617
- panda_register_callback (self, PANDA_CB_BEFORE_BLOCK_EXEC , pcb);
596
+ pcb.end_block_exec = end_block_exec ;
597
+ panda_register_callback (self, PANDA_CB_END_BLOCK_EXEC , pcb);
598
+ pcb.start_block_exec = start_block_exec ;
599
+ panda_register_callback (self, PANDA_CB_START_BLOCK_EXEC , pcb);
618
600
619
601
bool setup_ok = true ;
620
602
0 commit comments