Simplify references to dtp
PATCH v2 3/6 Simplify references to dtp
From: Eugene Loh <[email protected]>
Signed-off-by Eugene Loh <[email protected]>
--- libdtrace/dt_pid.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
libdtrace/dt_pid.c +8 -9
@@ -231,7 +231,7 @@ dt_pid_per_sym(dt_pid_probe_t *pp, const GElf_Sym *symp, const char *func) psp->pps_nameoff = off; psp->pps_off = symp->st_value - pp->dpp_vaddr + off; -if (dt_pid_create_one_probe (pp->dpp_pr, pp->dpp_dtp, +if (dt_pid_create_one_probe (pp->dpp_pr, dtp, psp, symp,DTPPT_OFFSETS ) <0 ) { rc = dt_pid_error( dtp, pcb, dpr, D_PROC_CREATEFAIL,
@@ -362,7 +362,7 @@ dt_pid_per_sym(dt_pid_probe_t *pp, const GElf_Sym *symp, const char *func) psp->pps_nameoff = off; psp->pps_off = symp->st_value - pp->dpp_vaddr + off; -if (dt_pid_create_one_probe (pp->dpp_pr, pp->dpp_dtp, +if (dt_pid_create_one_probe (pp->dpp_pr, dtp, psp, symp,DTPPT_OFFSETS ) >=0 ) nmatches++; }
@@ -434,7 +434,7 @@ dt_pid_per_mod(void *arg, const prmap_t *pmp, const char *obj)if (obj ==NULL )return 0 ; -dt_Plmid (pp->dpp_dtp, pid, pmp->pr_vaddr, &pp->dpp_lmid); +dt_Plmid (dtp, pid, pmp->pr_vaddr, &pp->dpp_lmid); pp->dpp_dev = pmp->pr_dev; pp->dpp_inum = pmp->pr_inum;
@@ -466,7 +466,7 @@ dt_pid_per_mod(void *arg, const prmap_t *pmp, const char *obj)* just fail silently in the hopes that some other object will * contain the desired symbol. */ -if (dt_Pxlookup_by_name (pp->dpp_dtp, pid, pp->dpp_lmid, obj, +if (dt_Pxlookup_by_name (dtp, pid, pp->dpp_lmid, obj, pp->dpp_func, &sym,NULL ) !=0 ) {if (strcmp ("-" , pp->dpp_func) ==0 ) { sym.st_name =0 ;
@@ -496,17 +496,17 @@ dt_pid_per_mod(void *arg, const prmap_t *pmp, const char *obj)* dynamically rewritten, and, so, inherently dicey to * instrument. */ -if (dt_Pwritable_mapping (pp->dpp_dtp, pid, sym.st_value)) +if (dt_Pwritable_mapping (dtp, pid, sym.st_value))return 0 ; -dt_Plookup_by_addr (pp->dpp_dtp, pid, sym.st_value, +dt_Plookup_by_addr (dtp, pid, sym.st_value, &pp->dpp_func, &sym);return dt_pid_per_sym (pp, &sym, pp->dpp_func); }else {uint_t nmatches = pp->dpp_nmatches; -if (dt_Psymbol_iter_by_addr (pp->dpp_dtp, pid, obj,PR_SYMTAB , +if (dt_Psymbol_iter_by_addr (dtp, pid, obj,PR_SYMTAB ,BIND_ANY |TYPE_FUNC , dt_pid_sym_filt, pp) ==1 )return 1 ;
@@ -516,8 +516,7 @@ dt_pid_per_mod(void *arg, const prmap_t *pmp, const char *obj)* If we didn't match anything in the PR_SYMTAB, try * the PR_DYNSYM. */ -if (dt_Psymbol_iter_by_addr ( - pp->dpp_dtp, pid, obj, +if (dt_Psymbol_iter_by_addr (dtp, pid, obj,PR_DYNSYM ,BIND_ANY |TYPE_FUNC , dt_pid_sym_filt, pp) ==1 )return 1 ;
Signature · 1 line
2.43.5
PATCH v2 5/6 test: Move disassembly and extracting PCs earlier
From: Eugene Loh <[email protected]>
This will allow a future patch to use the PCs earlier in the test.
Signed-off-by Eugene Loh <[email protected]>
--- test/unittest/usdt/tst.pidprobes.sh | 33 +++++++++++++++++------------ 1 file changed, 19 insertions(+), 14 deletions(-)
test/unittest/usdt/tst.pidprobes.sh +19 -14
@@ -102,6 +102,25 @@ if ! diff -q main.out main.out.expected > /dev/null; then exit 1 fi +# Disassemble foo(). (simplify with --disassemble=foo) + +objdump -d main | awk ' +BEGIN { use = 0 } # start by not printing lines +use == 1 && NF == 0 { exit } # if printing lines but hit a blank, then exit +use == 1 { print } # print lines +/<foo>:/ { use = 1 } # turn on printing when we hit "<foo>:" (without printing this line itself) +' > disasm_foo.txt +if [ $? -ne 0 ]; then + echo cannot objdump main + objdump -d main + exit 1 +fi + +# From the disassembly, get the PCs for foo()'s instructions. + +pcs=`awk '{print strtonum("0x"$1)}' disasm_foo.txt` +pc0=`echo $pcs | awk '{print $1}'` + # Run dtrace. cat >> pidprobes.d <<'EOF'
@@ -153,20 +172,6 @@ if [ `awk 'NF != 0 { print $1 }' dtrace.out | uniq | wc -l` -ne 1 ]; then fi pid=`awk 'NF != 0 { print $1 }' dtrace.out | uniq` -# Disassemble foo(). - -objdump -d main | awk ' -BEGIN { use = 0 } # start by not printing lines -use == 1 && NF == 0 { exit } # if printing lines but hit a blank, then exit -use == 1 { print } # print lines -/<foo>:/ { use = 1 } # turn on printing when we hit "<foo>:" (without printing this line itself) -' > disasm_foo.txt - -# From the disassembly, get the PCs for foo()'s instructions. - -pcs=`awk '{print strtonum("0x"$1)}' disasm_foo.txt` -pc0=`echo $pcs | awk '{print $1}'` - # From the disassembly, get the PCs for USDT probes. # Check libdtrace/dt_link.c's arch-dependent dt_modtext() to see # what sequence of instructions signal a USDT probe.
Signature · 1 line
2.43.5
Re: [PATCH v2 5/6] test: Move disassembly and extracting PCs earlier
Quoted 5 lines · On Fri, Dec 20, 2024 at 06:25:47PM -0500, [email protected] wrote:
From: Eugene Loh <[email protected]>
This will allow a future patch to use the PCs earlier in the test.
Signed-off-by Eugene Loh <[email protected]>
Reviewed-by Kris Van Hees <[email protected]>
Quoted 58 lines
--- test/unittest/usdt/tst.pidprobes.sh | 33 +++++++++++++++++------------ 1 file changed, 19 insertions(+), 14 deletions(-)test/unittest/usdt/tst.pidprobes.sh +19
-14@@ -102,6 +102,25 @@ if ! diff -q main.out main.out.expected > /dev/null; then exit 1 fi +# Disassemble foo(). (simplify with --disassemble=foo) + +objdump -d main | awk ' +BEGIN { use = 0 } # start by not printing lines +use == 1 && NF == 0 { exit } # if printing lines but hit a blank, then exit +use == 1 { print } # print lines +/<foo>:/ { use = 1 } # turn on printing when we hit "<foo>:" (without printing this line itself) +' > disasm_foo.txt +if [ $? -ne 0 ]; then + echo cannot objdump main + objdump -d main + exit 1 +fi + +# From the disassembly, get the PCs for foo()'s instructions. + +pcs=`awk '{print strtonum("0x"$1)}' disasm_foo.txt` +pc0=`echo $pcs | awk '{print $1}'` + # Run dtrace. cat >> pidprobes.d <<'EOF'@@ -153,20 +172,6 @@ if [ `awk 'NF != 0 { print $1 }' dtrace.out | uniq | wc -l` -ne 1 ]; then fi pid=`awk 'NF != 0 { print $1 }' dtrace.out | uniq` -# Disassemble foo(). - -objdump -d main | awk ' -BEGIN { use = 0 } # start by not printing lines -use == 1 && NF == 0 { exit } # if printing lines but hit a blank, then exit -use == 1 { print } # print lines -/<foo>:/ { use = 1 } # turn on printing when we hit "<foo>:" (without printing this line itself) -' > disasm_foo.txt - -# From the disassembly, get the PCs for foo()'s instructions. - -pcs=`awk '{print strtonum("0x"$1)}' disasm_foo.txt` -pc0=`echo $pcs | awk '{print $1}'` - # From the disassembly, get the PCs for USDT probes. # Check libdtrace/dt_link.c's arch-dependent dt_modtext() to see # what sequence of instructions signal a USDT probe.Signature · 1 line
2.43.5