5.18 跟踪
可用于跟踪的函数,大多会仔细检查,一个指定的跟踪类型是否设置了,例如,打开或关闭一个跟踪类型,还有获取跟踪事件。下面的函数定义在 dbg.hpp。
5.18.1 set_trace_size
定义 | bool idaapi set_trace_size(int size) |
含义 | 设置跟踪缓冲区为 size 大小。如果分配失败,则返回 false。置 size 为 0,则缓冲区为无限大小(危险)。如果您设置的 size 比当前跟踪事件的数量更少,size 事件被删除。 |
示例 | #include <dbg.hpp> // 1000 trace events allowed if (set_trace_size(1000)) msg("Successfully set the trace buffer to 1000\n"); |
5.18.2 clear_trace*
定义 | void idaapi clear_trace(void) |
含义 | 清楚跟踪缓冲区 |
示例 | #include <dbg.hpp> // Start our plug-in with a clean slate clear_trace(); |
5.18.3 is_step_trace_enabled
定义 | bool idaapi is_step_trace_enabled(void) |
含义 | 如果当前的单步跟踪是打开的,则返回 true. |
示例 | #include <dbg.hpp> if (is_step_trace_enabled()) msg("Step tracing is enabled.\n"); |
5.18.4 enable_step_trace*
定义 | bool idaapi enable_step_trace(int enable = true) |
含义 | 打开但不跟踪。如果 enable 参数置为 false,单步跟踪被关闭。 |
示例 | #include <dbg.hpp> // Toggle step tracing if (is_step_trace_enabled()) enable_step_trace(false); else enable_step_trace(); |
5.18.5 is_insn_trace_enabled
定义 | bool idaapi is_insn_trace_enabled(void) |
含义 | 如果指令跟踪被打开,返回 true. |
示例 | #include <dbg.hpp> if (is_insn_trace_enabled()) msg("Instruction tracing is enabled.\n"); |
5.18.6 enable_insn_trace*
定义 | bool idaapi enalbe_insn_trace(int enalbe = true) |
含义 | 打开指令跟踪。如果 enalbe 置为 false,指令跟踪就被关闭。 |
示例 | #include <dbg.hpp> // Toggle instruction tracing if (is_insn_trace_enabled()) enable_insn_trace(false); else enable_insn_trace(); |
5.18.7 is_func_trace_enalbed
定义 | bool idaapi is_func_trace_enabled(void) |
含义 | 如果函数跟踪是打开的,则返回 true。 |
示例 | #include <dbg.hpp> if (is_func_trace_enabled()) msg("Function tracing is enabled.\n"); |
5.18.8 enable_func_trace*
定义 | bool idaapi enable_func_trace(int enable = true) |
含义 | 打开函数跟踪,如果 enable 置为 false,函数跟踪就被关闭。 |
示例 | #include <dbg.hpp> // Toggle function tracing if (is_func_trace_enabled()) enable_func_trace(false); else enable_func_trace(); |
5.18.9 get_tev_qty
定义 | int idaapi get_tev_qty(void) |
含义 | 返回在跟踪缓冲区中,跟踪事件的数量。 |
示例 | #include <dbg.hpp> msg("There are %d trace events in the trace buffer.\n", get_tev_qty()); |
5.18.10 get_tev_info
定义 | bool idaapi get_tev_info(int n, tev_info_t *tev_info) |
含义 | 把跟踪缓冲区中,序数为 n 的相关信息填充到*tev_info。如果没有该跟踪事件序数 n,则返回 false。 |
示例 | #include <dbg.hpp> // Loop through all trace events for (int i = 0; i < get_tev_qty(); i++) { tev_info_t tev; // Get the trace event information get_tev_info(i, &tev); // Display the address the event took place msg("Trace event occurred at %a\n", tev.ea); } |
5.18.11 get_insn_tev_reg_val
定义 | bool idaapi get_insn_tev_reg_val(int n, const char *regname, regval_t *regval) |
含义 | 在执行某指令前,当序数为 n 的指令跟踪事件发生时,保存寄存器*regname 的值到*regval。如果该事件不是指令跟踪事件,则返回 false。 要在执行后获取寄存器,参阅 get_insn_tev_reg_result()。 |
示例 | #include <dbg.hpp> // Loop through all trace events for (int i = 0; i < get_tev_qty(); i++) { regval_t esp; tev_info_t tev; // Get the trace event information get_tev_info(i, &tev); // If it's an instruction trace event... if (tev.type == tev_insn) { // Get ESP, store into &esp if (get_insn_tev_reg_val(i, "ESP", &esp)) // Display the value of ESP msg("TEV #%d before exec: %a\n", i, esp.ival); else msg("No ESP change for TEV #%d\n", i); } } |
5.18.12 get_insn_tev_reg_result
定义 | bool idaapi get_insn_tev_reg_result(int n, const char *regname, regval_t *regval) |
含义 | 在执行某指令前,当序数为 n 的指令跟踪事件发生时,保存寄存器*regname 的值到*regval。如果该事件不是指令跟踪事件,则返回 false。 要在执行前获取寄存器,参阅 get_insn_tev_reg_val()。 |
示例 | #include <dbg.hpp> // Loop through all trace events for (int i = 0; i < get_tev_qty(); i++) { regval_t esp; tev_info_t tev; // Get the trace event information get_tev_info(i, &tev); // If it's an instruction trace event... if (tev.type == tev_insn) { // Get ESP, store into &esp if (get_insn_tev_reg_result(i, "ESP", &esp)) // Display the value of ESP msg("TEV #%d after exec: %a\n", i, esp.ival); else msg("No ESP change for TEV #%d\n", i); } } |
5.18.13 get_call_tev_callee
定义 | ea_t idaapi get_call_tev_callee(int n) |
含义 | 返回调用了序数为 n 函数跟踪事件的函数地址。如果没有该函数跟踪事件序数 n,则返回 BADADDR。函数跟踪事件的类型必须为 tev_call。 |
示例 | #include <dbg.hpp> // Loop through all trace events for (int i = 0; i < get_tev_qty(); i++) { regval_t esp; tev_info_t tev; // Get the trace event information get_tev_info(i, &tev); // If it's an function call trace event... if (tev.type == tev_call) { ea_t addr; // Get ESP, store into &esp if ((addr = get_call_tev_callee(i)) != BADADDR) msg("Function at %a was called\n", addr); } } |
5.18.14 get_ret_tev_return
定义 | ea_t idaapi get_ret_tev_return(int n) |
含义 | 返回被序数为 n 的函数事件通知调用的函数地址。如果没有该函数事件通知序数 n,则返回 BADADDR。函数事件通知的类型必须为 tev_ret。 |
示例 | #include <dbg.hpp> // Loop through all trace events for (int i = 0; i < get_tev_qty(); i++) { tev_info_t tev; // Get the trace event information get_tev_info(i, &tev); // If it's an function return trace event... if (tev.type == tev_ret) { ea_t addr; if ((addr = get_ret_tev_return(i)) != BADADDR) msg("Function returned to %a\n", addr); } } |
5.18.15 get_bpt_tev_ea
定义 | ea_t idaapi get_bpt_tev_ea(int n) |
含义 | 返回序数为 n 的读/写/执行事件通知的地址。如果该事件不是读/写/执行事件,则返回 false。 |
示例 | #include <dbg.hpp> // Loop through all trace events for (int i = 0; i < get_tev_qty(); i++) { tev_info_t tev; // Get the trace event information get_tev_info(i, &tev); // If it's an breakpoint trace event... if (tev.type == tev_bpt) { ea_t addr; if ((addr = get_bpt_tev_ea(i)) != BADADDR) msg("Breakpoint trace hit at %a\n", addr); } } |
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论