mirror of
https://github.com/opnsense/src.git
synced 2026-06-04 06:15:33 -04:00
kinst: do not look for a function epilogue
kinst currently only traces functions that start and end with the usual function prologue and epilogue respectively. Ignoring functions that do not have an epilogue however, makes the filtering too strict, as this means that we can not trace functions that never return (e.g vnlru_proc()). This patch relaxes the filtering and only checks whether the function pushes the frame pointer. Reviewed by: markj Approved by: markj Differential Revision: https://reviews.freebsd.org/D41876
This commit is contained in:
parent
03bfee1752
commit
bbe8195bfa
2 changed files with 15 additions and 14 deletions
|
|
@ -22,7 +22,6 @@
|
|||
#include "kinst.h"
|
||||
|
||||
#define KINST_PUSHL_RBP 0x55
|
||||
#define KINST_POPL_RBP 0x5d
|
||||
#define KINST_STI 0xfb
|
||||
#define KINST_POPF 0x9d
|
||||
|
||||
|
|
@ -502,7 +501,7 @@ kinst_make_probe(linker_file_t lf, int symindx, linker_symval_t *symval,
|
|||
const char *func;
|
||||
int error, instrsize, n, off;
|
||||
uint8_t *instr, *limit, *tmp;
|
||||
bool push_found, pop_found;
|
||||
bool push_found;
|
||||
|
||||
pd = opaque;
|
||||
func = symval->name;
|
||||
|
|
@ -521,17 +520,20 @@ kinst_make_probe(linker_file_t lf, int symindx, linker_symval_t *symval,
|
|||
* manipulations since they might correspond to exception handlers.
|
||||
*/
|
||||
tmp = instr;
|
||||
push_found = pop_found = false;
|
||||
push_found = false;
|
||||
while (tmp < limit) {
|
||||
if (*tmp == KINST_PUSHL_RBP)
|
||||
/*
|
||||
* Checking for 'pop %rbp' as well makes the filtering too
|
||||
* strict as it would skip functions that never return (e.g.,
|
||||
* vnlru_proc()).
|
||||
*/
|
||||
if (*tmp == KINST_PUSHL_RBP) {
|
||||
push_found = true;
|
||||
else if (*tmp == KINST_POPL_RBP)
|
||||
pop_found = true;
|
||||
if (push_found && pop_found)
|
||||
break;
|
||||
}
|
||||
tmp += dtrace_instr_size(tmp);
|
||||
}
|
||||
if (!push_found || !pop_found)
|
||||
if (!push_found)
|
||||
return (0);
|
||||
|
||||
n = 0;
|
||||
|
|
|
|||
|
|
@ -448,7 +448,7 @@ kinst_make_probe(linker_file_t lf, int symindx, linker_symval_t *symval,
|
|||
kinst_patchval_t *insn, v;
|
||||
uint8_t *instr, *limit;
|
||||
int instrsize, n, off;
|
||||
bool lrsc_block, store_found, ret_found;
|
||||
bool lrsc_block, store_found;
|
||||
|
||||
pd = opaque;
|
||||
func = symval->name;
|
||||
|
|
@ -464,16 +464,15 @@ kinst_make_probe(linker_file_t lf, int symindx, linker_symval_t *symval,
|
|||
return (0);
|
||||
|
||||
/* Check for the usual function prologue. */
|
||||
store_found = false;
|
||||
for (insn = (kinst_patchval_t *)instr;
|
||||
insn < (kinst_patchval_t *)limit; insn++) {
|
||||
if (dtrace_instr_sdsp(&insn) || dtrace_instr_c_sdsp(&insn))
|
||||
if (dtrace_instr_sdsp(&insn) || dtrace_instr_c_sdsp(&insn)) {
|
||||
store_found = true;
|
||||
else if (dtrace_instr_ret(&insn) || dtrace_instr_c_ret(&insn))
|
||||
ret_found = true;
|
||||
if (store_found && ret_found)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!store_found || !ret_found)
|
||||
if (!store_found)
|
||||
return (0);
|
||||
|
||||
n = 0;
|
||||
|
|
|
|||
Loading…
Reference in a new issue