Commit 421edbd added dyninst support to the testsuite/systemtap.base/externalvar.exp testcase. Every dyninst test fails, with compilation errors: ==== cmd: stap --runtime=dyninst -d /discer.farm/es/scratch/dsmith/systemtap/rawhide-64/testsuite/libexternalvar.so -d /discer.farm/es/scratch/dsmith/systemtap/rawhide-64/testsuite/externalvar -c /discer.farm/es/scratch/dsmith/systemtap/rawhide-64/testsuite/externalvar ../../src/testsuite/systemtap.base/externalvar.stp cmd output: /tmp/stapBAGO8A/stap_35d9039386514fc1089dd9c31c183d48_27486_src.c: In function 'function__dwarf_tvar_get_lib_s_20': /tmp/stapBAGO8A/stap_35d9039386514fc1089dd9c31c183d48_27486_src.c:1763:163: error: 'current' undeclared (first use in this function) /tmp/stapBAGO8A/stap_35d9039386514fc1089dd9c31c183d48_27486_src.c:1763:163: note: each undeclared identifier is reported only once for each function it appears in /tmp/stapBAGO8A/stap_35d9039386514fc1089dd9c31c183d48_27486_src.c: In function 'function__dwarf_tvar_get_lib_s_21': /tmp/stapBAGO8A/stap_35d9039386514fc1089dd9c31c183d48_27486_src.c:1830:163: error: 'current' undeclared (first use in this function) /tmp/stapBAGO8A/stap_35d9039386514fc1089dd9c31c183d48_27486_src.c: In function 'function__dwarf_tvar_get_lib_s_22': /tmp/stapBAGO8A/stap_35d9039386514fc1089dd9c31c183d48_27486_src.c:1897:163: error: 'current' undeclared (first use in this function) /tmp/stapBAGO8A/stap_35d9039386514fc1089dd9c31c183d48_27486_src.c: In function 'function__dwarf_tvar_get_lib_s_26': /tmp/stapBAGO8A/stap_35d9039386514fc1089dd9c31c183d48_27486_src.c:1964:163: error: 'current' undeclared (first use in this function) /tmp/stapBAGO8A/stap_35d9039386514fc1089dd9c31c183d48_27486_src.c: In function 'function__dwarf_tvar_get_lib_s_27': /tmp/stapBAGO8A/stap_35d9039386514fc1089dd9c31c183d48_27486_src.c:2023:163: error: 'current' undeclared (first use in this function) /tmp/stapBAGO8A/stap_35d9039386514fc1089dd9c31c183d48_27486_src.c: In function 'function__dwarf_tvar_get_lib_s_28': /tmp/stapBAGO8A/stap_35d9039386514fc1089dd9c31c183d48_27486_src.c:2093:163: error: 'current' undeclared (first use in this function) /tmp/stapBAGO8A/stap_35d9039386514fc1089dd9c31c183d48_27486_src.c: In function 'function__dwarf_tvar_get_libvar_18': /tmp/stapBAGO8A/stap_35d9039386514fc1089dd9c31c183d48_27486_src.c:2163:163: error: 'current' undeclared (first use in this function) /tmp/stapBAGO8A/stap_35d9039386514fc1089dd9c31c183d48_27486_src.c: In function 'function__dwarf_tvar_get_stat_lib_s_23': /tmp/stapBAGO8A/stap_35d9039386514fc1089dd9c31c183d48_27486_src.c:2717:163: error: 'current' undeclared (first use in this function) /tmp/stapBAGO8A/stap_35d9039386514fc1089dd9c31c183d48_27486_src.c: In function 'function__dwarf_tvar_get_stat_lib_s_24': /tmp/stapBAGO8A/stap_35d9039386514fc1089dd9c31c183d48_27486_src.c:2784:163: error: 'current' undeclared (first use in this function) /tmp/stapBAGO8A/stap_35d9039386514fc1089dd9c31c183d48_27486_src.c: In function 'function__dwarf_tvar_get_stat_lib_s_25': /tmp/stapBAGO8A/stap_35d9039386514fc1089dd9c31c183d48_27486_src.c:2851:163: error: 'current' undeclared (first use in this function) /tmp/stapBAGO8A/stap_35d9039386514fc1089dd9c31c183d48_27486_src.c: In function 'function__dwarf_tvar_get_stat_lib_s_29': /tmp/stapBAGO8A/stap_35d9039386514fc1089dd9c31c183d48_27486_src.c:2918:163: error: 'current' undeclared (first use in this function) /tmp/stapBAGO8A/stap_35d9039386514fc1089dd9c31c183d48_27486_src.c: In function 'function__dwarf_tvar_get_stat_lib_s_31': /tmp/stapBAGO8A/stap_35d9039386514fc1089dd9c31c183d48_27486_src.c:2977:163: error: 'current' undeclared (first use in this function) /tmp/stapBAGO8A/stap_35d9039386514fc1089dd9c31c183d48_27486_src.c: In function 'function__dwarf_tvar_get_stat_libvar_19': /tmp/stapBAGO8A/stap_35d9039386514fc1089dd9c31c183d48_27486_src.c:3047:163: error: 'current' undeclared (first use in this function) /tmp/stapBAGO8A/stap_35d9039386514fc1089dd9c31c183d48_27486_src.c: In function 'systemtap_module_init': /tmp/stapBAGO8A/stap_35d9039386514fc1089dd9c31c183d48_27486_src.c:3926:3: error: implicit declaration of function '_stp_vma_init' [-Werror=implicit-function-declaration] /tmp/stapBAGO8A/stap_35d9039386514fc1089dd9c31c183d48_27486_src.c:3930:5: error: implicit declaration of function 'stap_start_task_finder' [-Werror=implicit-function-declaration] /tmp/stapBAGO8A/stap_35d9039386514fc1089dd9c31c183d48_27486_src.c:3932:7: error: implicit declaration of function 'stap_stop_task_finder' [-Werror=implicit-function-declaration] /tmp/stapBAGO8A/stap_35d9039386514fc1089dd9c31c183d48_27486_src.c:3946:5: error: implicit declaration of function 'stap_task_finder_post_init' [-Werror=implicit-function-declaration] /tmp/stapBAGO8A/stap_35d9039386514fc1089dd9c31c183d48_27486_src.c: In function 'systemtap_module_exit': /tmp/stapBAGO8A/stap_35d9039386514fc1089dd9c31c183d48_27486_src.c:3981:3: error: implicit declaration of function '_stp_vma_done' [-Werror=implicit-function-declaration] In file included from /usr/local/share/systemtap/runtime/dyninst/sym.c:2:0, from /usr/local/share/systemtap/runtime/dyninst/runtime.h:127, from /usr/local/share/systemtap/runtime/runtime.h:28, from /tmp/stapBAGO8A/stap_35d9039386514fc1089dd9c31c183d48_27486_src.c:21: /tmp/stapBAGO8A/stap_35d9039386514fc1089dd9c31c183d48_27486_src.c: At top level: /usr/local/share/systemtap/runtime/dyninst/../sym.h:111:22: error: '_stp_umodule_relocate' used but never defined [-Werror] cc1: all warnings being treated as errors WARNING: gcc exited with status: 1 Pass 4: compilation failed. [man error::pass4] FAIL: externalvar-m64-dyninst ==== It looks like there is some kernel code sneaking in there - references to "current", the task_finder, etc. It also looks _stp_umodule_relocate() may need a dyninst version.
(In reply to comment #0) > Commit 421edbd added dyninst support to the > testsuite/systemtap.base/externalvar.exp testcase. Every dyninst test fails, > with compilation errors: [...] > It looks like there is some kernel code sneaking in there - references to > "current", the task_finder, etc. It also looks _stp_umodule_relocate() may need > a dyninst version. This is coming from dwflpp::emit_address, for any address that requires relocation. That will be true mostly for global $var or @var("name") accesses. We should probably add a sanity check so enable_task_finder() is rejected in dyninst mode. Then the relocation function itself is an unfinished piece from the PR14179 runtime split, but it will need dyninst-specific implementation. We certainly have access to all the relocations from stapdyn itself, and could implement something like the vma-tracking of kernel mode, but the trick then is how to present that to in-target probe handlers. Some data within shared memory, I guess, but that has to be a fixed allocation. The in-target probes could instead use dl_iterate_phdr() to figure it out on their own, of course only for libraries loaded via glibc. I don't know how performant that would be, especially repeated every time, but perhaps it's good enough for a first round. If it needs optimization, later we could cache what pieces we need and even hook dlopen/dlclose to catch changes.
Here's an update on this bug. The testcase itself has been cleaned up a bit by the following commit: commit b5ca36bda9c8a5c83eb594ed4a29a3414038792f Author: Josh Stone <jistone@redhat.com> Date: Mon Jun 24 17:10:08 2013 -0700 Mark externalvar.exp as KFAIL on stapdyn, PR15052 Some of the underlying functionality has also changed. We no longer get compile errors, instead we get the following error message: ==== # stap --runtime=dyninst -d testsuite/libexternalvar.so -d testsuite/externalvar -c testsuite/externalvar testsuite/systemtap.base/externalvar.stp cmd output: semantic error: VMA-tracking is only supported by the kernel runtime (PR15052): identifier '$libvar' at testsuite/systemtap.base/externalvar.stp:42:27 source: printf("libvar = %d\n", $libvar); ^ Pass 2: analysis failed. [man error::pass2] ==== The underlying relocation problem is still present.
Date: Fri Jan 8 15:38:42 2021 -0500 Add stapdyn VMA-tracking. Added VMA-tracking to stapdyn. externalvar.exp now passes except for the bug 14490 cases.