diff --git a/panda/plugins/textprinter/textprinter.cpp b/panda/plugins/textprinter/textprinter.cpp index e663af6a30d..4bf0590fdc6 100644 --- a/panda/plugins/textprinter/textprinter.cpp +++ b/panda/plugins/textprinter/textprinter.cpp @@ -35,6 +35,7 @@ PANDAENDCOMMENT */ #include #include #include +#include #include "panda/plugin.h" @@ -53,33 +54,38 @@ void write_mem_callback(CPUState *env, target_ulong pc, target_ulong addr, size_ uint64_t mem_counter; std::set tap_points; +std::unordered_set tap_pc; gzFile read_tap_buffers; gzFile write_tap_buffers; void mem_callback(CPUState *env, target_ulong pc, target_ulong addr, size_t size, uint8_t *buf, gzFile f) { + mem_counter++; + if (tap_pc.find(pc) == tap_pc.end()) { + return; + } prog_point p = {}; get_prog_point(env, &p); - - if (tap_points.find(p) != tap_points.end()) { - target_ulong callers[16] = {0}; - int nret = get_callers(callers, 16, env); - unsigned char *buf_uc = static_cast(buf); - for (unsigned int i = 0; i < size; i++) { - for (int j = nret-1; j > 0; j--) { - gzprintf(f, TARGET_FMT_lx " ", callers[j]); - } - gzprintf(f, - TARGET_FMT_lx " " TARGET_FMT_lx " %d " TARGET_FMT_lx - " " TARGET_FMT_lx " %s " TARGET_FMT_lx - " %ld %02x\n", - p.caller, p.pc, p.stackKind, p.sidFirst, p.sidSecond, - p.isKernelMode ? "kernel" : "user", addr + i, mem_counter, - buf_uc[i]); + if (tap_points.find(p) == tap_points.end()) { + return; + } + + target_ulong callers[16] = {0}; + int nret = get_callers(callers, 16, env); + unsigned char *buf_uc = static_cast(buf); + for (unsigned int i = 0; i < size; i++) { + for (int j = nret-1; j > 0; j--) { + gzprintf(f, TARGET_FMT_lx " ", callers[j]); } + gzprintf(f, + TARGET_FMT_lx " " TARGET_FMT_lx " %d " TARGET_FMT_lx + " " TARGET_FMT_lx " %s " TARGET_FMT_lx + " %ld %02x\n", + p.caller, p.pc, p.stackKind, p.sidFirst, p.sidSecond, + p.isKernelMode ? "kernel" : "user", addr + i, mem_counter, + buf_uc[i]); } - mem_counter++; - + return; } @@ -142,6 +148,7 @@ bool init_plugin(void *self) { printf("Adding tap point (" TARGET_FMT_lx "," TARGET_FMT_lx ", %s)\n", p.caller, p.pc, sid_string); tap_points.insert(p); + tap_pc.insert(p.pc); g_free(sid_string); } taps.close();