diff options
author | Christos Margiolis <christos@FreeBSD.org> | 2023-09-15 15:33:41 +0000 |
---|---|---|
committer | Christos Margiolis <christos@FreeBSD.org> | 2023-09-15 15:33:41 +0000 |
commit | bbe8195bfad620e01a7b1cfdb0de3e4b65a72949 (patch) | |
tree | c045cdcf31105b4550c31a6e5c081fda18a0b89c | |
parent | 03bfee175269960c67cab64d761bbb5eb9ac5878 (diff) | |
download | src-bbe8195bfad620e01a7b1cfdb0de3e4b65a72949.tar.gz src-bbe8195bfad620e01a7b1cfdb0de3e4b65a72949.zip |
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
-rw-r--r-- | sys/cddl/dev/kinst/amd64/kinst_isa.c | 18 | ||||
-rw-r--r-- | sys/cddl/dev/kinst/riscv/kinst_isa.c | 11 |
2 files changed, 15 insertions, 14 deletions
diff --git a/sys/cddl/dev/kinst/amd64/kinst_isa.c b/sys/cddl/dev/kinst/amd64/kinst_isa.c index 398f30a281c0..b1d3d8727ead 100644 --- a/sys/cddl/dev/kinst/amd64/kinst_isa.c +++ b/sys/cddl/dev/kinst/amd64/kinst_isa.c @@ -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; diff --git a/sys/cddl/dev/kinst/riscv/kinst_isa.c b/sys/cddl/dev/kinst/riscv/kinst_isa.c index 9c1f4a239f83..1fabde189712 100644 --- a/sys/cddl/dev/kinst/riscv/kinst_isa.c +++ b/sys/cddl/dev/kinst/riscv/kinst_isa.c @@ -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; |