This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 3/6] sysroot: debuginfo lookup with sysroot case do not remove sysroot from file_name




On Thu, 8 Mar 2018, Victor Kamensky wrote:

Hi David,

On Thu, 8 Mar 2018, David Smith wrote:

Hmm, the problem I have here is the code your patch wants to delete
was added to fix a sysroot problem in the following commit:

====
commit df932a3175284fa75a4c6bdb3aa7af1a34c15cd6
Author: Torsten Polle <Torsten.Polle@gmx.de>
Date:   Thu Mar 6 21:38:49 2014 +0100

   Fix: Debug links are not found if the sysroot is used.

   Signed-off-by: Torsten Polle <Torsten.Polle@gmx.de>
====

Thank you for bring my attention to it. Unfortunately above
commit message is too terse, and it is not clear what was the
use case that did not work.

But I looked closely into it again, and I think I know what
is happening:

It boils down to three different types of entries that
SYSTEMTAP_DEBUGINFO_PATH environment (or its default) may have. SYSTEMTAP_DEBUGINFO_PATH value is passed through debuginfo_usr_path
to mod->dwfl->callbacks.debuginfo_path and that is passed
to dwfl_standard_find_debuginfo function of elfutils.

Note fila_name passed to function may have sysroot stripped
from it (current code), or may include sysroot as it was
before df932a3175284 and after my fix.

debuginfo_path may contain the following entries, each
may preceeded by optional "+" or "-"

1) empty entry, in this case fila_name passed to the function
is checked directly. If file_name does not have sysroot in
it dwfl_standard_find_debuginfo will try to look for file
in current root. Which is clearly very wrong thing to do in
case of sysroot build, since it may pick up file with the
same name in host. Current code with default debuginfo_path
has this issue

2) Local path like ".debug". In this case function will look
for `dirname file_name`/.debug/`basename file_name'. Again
if file_name does not have sysroot in it, host files system
will be looked and it is wrong. That is actually my case,
in for /bin/mkdir.coreutils in my sysroot there is
/bin/.debug/mkdir.coreutils with symbols. So if file_name
does have sysroot in it, correct symbols file is picked and
that is what I made this fix.

3) Absolute path like '/<sysroot>/usr/lib/debug'. In this
case function will look at
'/<sysroot>/usr/lib/debug'/file_name or
'/<sysroot>/usr/lib/debug'/`basename file_name`. And in
this case if file_name contains sysroot it will not work.
I believe it is what df932a317528 has fixed and that is
what my fix would break again. But note df932a317528 broke
lookup for case 2).

I've tried to implement fix as per my understanding
above, but I discovered
that I missed important piece yesterday wrt how
dwfl_standard_find_debuginfo function handles absolute
entries. It turns out if function receives file_name it
will try one by one chipping of directories from the front of
file_name so eventually it comes to short name within
sysroot. I.e it gets file_name as /my/sys/root/bin/hello.debug
it will try:

<absolute_debuginfo>/my/sys/root/bin/hello.debug

<absolute_debuginfo>/sys/root/bin/hello.debug

<absolute_debuginfo>/root/bin/hello.debug

<absolute_debuginfo>/bin/hello.debug

<absolute_debuginfo>/hello.debug

So now, I stand by my original patch - df932a317528 should be
reverted. And reverted case works for all debuginof_path entries
types. I've unit tested either local or absolute entries all
work with my originally proposed patch.

df932a317528 was done in 'Thu Mar 6 21:38:49 2014' but
dwfl_standard_find_debuginfo logic to explore all sub-subdirs
for absolute entries was added in elfutils in 2015-08-13
by b901b5e7. I think that explains it.

Please merge my original patch or revert df932a317528.

Here is snipet from 'git blame ./libdwfl/find-debuginfo.c'
around explore all sub-subdirs in dwfl_standard_find_debuginfo code

b901b5e7 (Dodji Seketeli 2015-08-13 15:59:41 +0200 268) subdir = file_dirname; b901b5e7 (Dodji Seketeli 2015-08-13 15:59:41 +0200 269) /* We want to explore all sub-subdirs. Chop off one slash b901b5e7 (Dodji Seketeli 2015-08-13 15:59:41 +0200 270) at a time. */ b901b5e7 (Dodji Seketeli 2015-08-13 15:59:41 +0200 271) explore_dir: b901b5e7 (Dodji Seketeli 2015-08-13 15:59:41 +0200 272) subdir = strchr (subdir, '/'); b901b5e7 (Dodji Seketeli 2015-08-13 15:59:41 +0200 273) if (subdir != NULL) b901b5e7 (Dodji Seketeli 2015-08-13 15:59:41 +0200 274) subdir = subdir + 1; b901b5e7 (Dodji Seketeli 2015-08-13 15:59:41 +0200 275) if (subdir && *subdir == 0) b901b5e7 (Dodji Seketeli 2015-08-13 15:59:41 +0200 276) continue;

Thanks,
Victor

I am not sure how to fix it to work in all cases. I will
think about it tomorrow. Any suggestions are welcome.

For now it is clear in sysroot case, passing empty entry
is wrong. Instead sysroot itself should be passed.

Local path and absolute path debuginfo_path contradict
each other wrt expectation whether file_name contains
sysroot or not. Maybe debuginfo_path in case of
non-empty sysroot should be split into two diferent
sets: one with absolute entries and other with local entries
and dwfl_standard_find_debuginfo should be called twice
with different variants of file_name.

If interseted please find below my gdb session that
illustrates behavior of dwfl_standard_find_debuginfo described
above. Gdb session has run against current code.

Thanks,
Victor

In this example /bin/hello executable compiled in such way that it's
.gnu_debuglink has value hello.debug, so it could be distingushable
from executable itself.

(gdb) show args
Argument list to give program being debugged when it is started is "--sysroot=/home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs -a x86_64 -r /home/wd8/yocto/20180128/build_x86_64/tmp/work/corei7-64-intel-common-poky-linux/linux-yocto/4.9.78+gitAUTOINC+ef2f5d9a0a_f7a6d45fff-r0/linux-corei7-64-intel-common-standard-build -B CROSS_COMPILE=/home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs/usr/bin/x86_64-poky-linux- --sysenv=PATH=/usr/bin:/bin:/usr/sbin:/sbin --sysenv=LD_LIBRARY_PATH=/lib:/usr/lib -v -l 'process("/bin/hello").function("*")'".
...

(gdb) bt
#0 find_debuginfo_in_path (mod=mod@entry=0x62d6950, file_name=file_name@entry=0x62d6bf2 "/bin/hello", debuglink_file=debuglink_file@entry=0x7ffff7fed044 "hello.debug", debuglink_crc=debuglink_crc@entry=611974856, debuginfo_file_name=debuginfo_file_name@entry=0x62d69a8) at find-debuginfo.c:165 #1 0x00007ffff7bb2855 in dwfl_standard_find_debuginfo (mod=0x62d6950, userdata=<optimized out>, modname=<optimized out>, base=<optimized out>, file_name=0x62d6bf2 "/bin/hello", debuglink_file=0x7ffff7fed044 "hello.debug", debuglink_crc=611974856, debuginfo_file_name=0x62d69a8) at find-debuginfo.c:383 #2 0x0000000000657719 in internal_find_debuginfo (mod=0x62d6950, userdata=0x62d6960, modname=0x62d6af0 "/home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs/bin/hello", base=65536, file_name=0x62d6bf2 "/bin/hello", debuglink_file=0x7ffff7fed044 "hello.debug", debuglink_crc=611974856, debuginfo_file_name=0x62d69a8) at ../systemtap/setupdwfl.cxx:645 #3 0x00007ffff7bb0153 in find_debuginfo (mod=0x62d6950) at dwfl_module_getdwarf.c:539 #4 0x00007ffff7bb1393 in find_dw (mod=0x62d6950) at dwfl_module_getdwarf.c:1400 #5 dwfl_module_getdwarf (mod=0x62d6950, bias=0x7fffffff79d8) at dwfl_module_getdwarf.c:1434
#6  0x0000000000530b2c in validate_module_elf (mod=0x62d6950,
name=0x62d6af0 "/home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs/bin/hello", q=0x7fffffff8110)
   at ../systemtap/tapsets.cxx:2471
#7  0x000000000053169e in query_module (mod=0x62d6950,
name=0x62d6af0 "/home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs/bin/hello", addr=65536, q=0x7fffffff8110)
   at ../systemtap/tapsets.cxx:2605
#8 0x00007ffff7baed71 in dwfl_getmodules (dwfl=0x62d5020, callback=0x53137c <query_module(Dwfl_Module*, void**, char const*, Dwarf_Addr, base_query*)>, arg=0x7fffffff8110, offset=0)
   at dwfl_getmodules.c:86
#9 0x0000000000623215 in dwflpp::iterate_over_modules<void> (this=0x62d4b80, callback=0x53137c <query_module(Dwfl_Module*, void**, char const*, Dwarf_Addr, base_query*)>,
   data=0x7fffffff8110) at ../systemtap/dwflpp.cxx:409
#10 0x000000000058b7a3 in dwflpp::iterate_over_modules<base_query> (this=0x62d4b80, callback=0x53137c <query_module(Dwfl_Module*, void**, char const*, Dwarf_Addr, base_query*)>,
   data=0x7fffffff8110) at ../systemtap/dwflpp.h:238
#11 0x00000000005664f7 in dwarf_builder::build (this=0x62c7960, sess=..., base=0x4b538d0, location=0x1028eb0, parameters=std::map with 2 elements = {...}, finished_results=std::vector of length 0, capacity 0) at ../systemtap/tapsets.cxx:8616 #12 0x000000000049dcbf in match_node::find_and_build (this=0x62cc660, s=..., p=0x4b538d0, loc=0x1028eb0, pos=2, results=std::vector of length 0, capacity 0, builders=std::set with 0 elements)
   at ../systemtap/elaborate.cxx:474
#13 0x000000000049ee12 in match_node::find_and_build (this=0x4b4d920, s=..., p=0x4b538d0, loc=0x1028eb0, pos=1, results=std::vector of length 0, capacity 0, builders=std::set with 0 elements)
   at ../systemtap/elaborate.cxx:648
#14 0x000000000049ee12 in match_node::find_and_build (this=0xa1b2d0, s=..., p=0x4b538d0, loc=0x1028eb0, pos=0, results=std::vector of length 0, capacity 0, builders=std::set with 0 elements)
   at ../systemtap/elaborate.cxx:648
#15 0x00000000004a0ca5 in derive_probes (s=..., p=0x4b538d0, dps=std::vector of length 0, capacity 0, optional=false, rethrow_errors=false) at ../systemtap/elaborate.cxx:1022 #16 0x00000000004a4332 in semantic_pass_symbols (s=...) at ../systemtap/elaborate.cxx:1890 #17 0x00000000004a88c5 in semantic_pass (s=...) at ../systemtap/elaborate.cxx:2441
#18 0x0000000000413a48 in passes_0_4 (s=...) at ../systemtap/main.cxx:914
#19 0x00000000004161a8 in main (argc=13, argv=0x7fffffffdd68) at ../systemtap/main.cxx:1381
(gdb) p *mod
$43 = {dwfl = 0x62d5020, next = 0x0, userdata = 0x0,
name = 0x62d6af0 "/home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs/bin/hello", low_addr = 65536, high_addr = 2166840, main = {name = 0x62d6b80 "/home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs/bin/hello", fd = -1, valid = false, relocated = false, elf = 0x62d50b0, vaddr = 0, address_sync = 2304}, debug = {name = 0x0, fd = 0, valid = false, relocated = false, elf = 0x0, vaddr = 0, address_sync = 0}, aux_sym = { name = 0x0, fd = 0, valid = false, relocated = false, elf = 0x0, vaddr = 0, address_sync = 0}, main_bias = 65536, ebl = 0x0, e_type = 3, elferr = DWFL_E_NOERROR, reloc_info = 0x0, symfile = 0x0, symdata = 0x0, aux_symdata = 0x0, syments = 0, aux_syments = 0, first_global = 0, aux_first_global = 0, symstrdata = 0x0, aux_symstrdata = 0x0, symxndxdata = 0x0, aux_symxndxdata = 0x0, dw = 0x0, alt = 0x0, alt_fd = 0, alt_elf = 0x0, symerr = DWFL_E_NOERROR, dwerr = DWFL_E_NO_DWARF, first_cu = 0x0, cu = 0x0, lazy_cu_root = 0x0, aranges = 0x0, build_id_bits = 0x62d4b60, build_id_vaddr = 66180, build_id_len = 20, ncu = 0, lazycu = 0, naranges = 0, dwarf_cfi = 0x0, eh_cfi = 0x0, segment = 0, gc = false, is_executable = false}
(gdb) p *mod->dwfl->callbacks
$44 = {find_elf = 0x0, find_debuginfo = 0x657103 <internal_find_debuginfo(Dwfl_Module*, void**, char const*, unsigned long, char const*, char const*, unsigned int, char**)>,
 section_address = 0x0, debuginfo_path = 0xa07db8 <debuginfo_usr_path>}
(gdb) p debuginfo_usr_path
$45 = 0xa28bc0 "+:.debug:/home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs/usr/lib/debug:/home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs/var/cache/abrt-di/usr/lib/debug"
(gdb) c

Breakpoint 5, try_open (dir=dir@entry=0x62d8c50 "/bin", subdir=subdir@entry=0x0, debuglink=debuglink@entry=0x7ffff7fed044 "hello.debug", debuginfo_file_name=debuginfo_file_name@entry=0x7fffffff7340, main_stat=<optimized out>, main_stat=<optimized out>) at find-debuginfo.c:44
44	try_open (const struct stat *main_stat,
(gdb) c
Continuing.

Breakpoint 6, try_open (dir=dir@entry=0x62d8c50 "/bin", subdir=subdir@entry=0x0, debuglink=debuglink@entry=0x7ffff7fed044 "hello.debug", debuginfo_file_name=debuginfo_file_name@entry=0x7fffffff7340, main_stat=<optimized out>, main_stat=<optimized out>) at find-debuginfo.c:61
61	  int fd = TEMP_FAILURE_RETRY (open (fname, O_RDONLY));
(gdb) p fname
$46 = 0x62d9320 "/bin/hello.debug"
(gdb) c
Continuing.

Breakpoint 5, try_open (dir=dir@entry=0x62d8c50 "/bin", subdir=subdir@entry=0xa28e42 ".debug", debuglink=debuglink@entry=0x7ffff7fed044 "hello.debug", debuginfo_file_name=debuginfo_file_name@entry=0x7fffffff7340, main_stat=<optimized out>, main_stat=<optimized out>) at find-debuginfo.c:44
44	try_open (const struct stat *main_stat,
(gdb) c
Continuing.

Breakpoint 6, try_open (dir=dir@entry=0x62d8c50 "/bin", subdir=subdir@entry=0xa28e42 ".debug", debuglink=debuglink@entry=0x7ffff7fed044 "hello.debug", debuginfo_file_name=debuginfo_file_name@entry=0x7fffffff7340, main_stat=<optimized out>, main_stat=<optimized out>) at find-debuginfo.c:61
61	  int fd = TEMP_FAILURE_RETRY (open (fname, O_RDONLY));
(gdb) p fname
$47 = 0x62d9320 "/bin/.debug/hello.debug"
(gdb) c
Continuing.

Breakpoint 5, try_open (dir=dir@entry=0x62d8c50 "/bin", subdir=subdir@entry=0x0, debuglink=debuglink@entry=0x7ffff7fed044 "hello.debug", debuginfo_file_name=debuginfo_file_name@entry=0x7fffffff7340, main_stat=<optimized out>, main_stat=<optimized out>) at find-debuginfo.c:44
44	try_open (const struct stat *main_stat,
(gdb) c
Continuing.

Breakpoint 6, try_open (dir=dir@entry=0x62d8c50 "/bin", subdir=subdir@entry=0x0, debuglink=debuglink@entry=0x7ffff7fed044 "hello.debug", debuginfo_file_name=debuginfo_file_name@entry=0x7fffffff7340, main_stat=<optimized out>, main_stat=<optimized out>) at find-debuginfo.c:61
61	  int fd = TEMP_FAILURE_RETRY (open (fname, O_RDONLY));
(gdb) p fname
$48 = 0x62d9320 "/bin/hello.debug"
(gdb) c
Continuing.

Breakpoint 5, try_open (dir=dir@entry=0xa28e49 "/home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs/usr/lib/debug", subdir=subdir@entry=0x62d8c51 "bin", debuglink=debuglink@entry=0x7ffff7fed044 "hello.debug", debuginfo_file_name=debuginfo_file_name@entry=0x7fffffff7340, main_stat=<optimized out>,
   main_stat=<optimized out>) at find-debuginfo.c:44
44	try_open (const struct stat *main_stat,
(gdb) c
Continuing.

Breakpoint 6, try_open (dir=dir@entry=0xa28e49 "/home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs/usr/lib/debug", subdir=subdir@entry=0x62d8c51 "bin", debuglink=debuglink@entry=0x7ffff7fed044 "hello.debug", debuginfo_file_name=debuginfo_file_name@entry=0x7fffffff7340, main_stat=<optimized out>,
   main_stat=<optimized out>) at find-debuginfo.c:61
61	  int fd = TEMP_FAILURE_RETRY (open (fname, O_RDONLY));
(gdb) p fname
$49 = 0x62d9fd0 "/home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs/usr/lib/debug/bin/hello.debug"
(gdb) c
Continuing.

Breakpoint 5, try_open (dir=dir@entry=0xa28e49 "/home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs/usr/lib/debug", subdir=subdir@entry=0x0, debuglink=debuglink@entry=0x7ffff7fed044 "hello.debug", debuginfo_file_name=debuginfo_file_name@entry=0x7fffffff7340, main_stat=<optimized out>,
   main_stat=<optimized out>) at find-debuginfo.c:44
44	try_open (const struct stat *main_stat,
(gdb) c
Continuing.

Breakpoint 6, try_open (dir=dir@entry=0xa28e49 "/home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs/usr/lib/debug", subdir=subdir@entry=0x0, debuglink=debuglink@entry=0x7ffff7fed044 "hello.debug", debuginfo_file_name=debuginfo_file_name@entry=0x7fffffff7340, main_stat=<optimized out>,
   main_stat=<optimized out>) at find-debuginfo.c:61
61	  int fd = TEMP_FAILURE_RETRY (open (fname, O_RDONLY));
(gdb) p fname
$50 = 0x62d9fd0 "/home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs/usr/lib/debug/hello.debug"
(gdb) c
Continuing.

Breakpoint 5, try_open (
dir=dir@entry=0xa28eca "/home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs/var/cache/abrt-di/usr/lib/debug", subdir=subdir@entry=0x62d8c51 "bin", debuglink=debuglink@entry=0x7ffff7fed044 "hello.debug", debuginfo_file_name=debuginfo_file_name@entry=0x7fffffff7340, main_stat=<optimized out>,
   main_stat=<optimized out>) at find-debuginfo.c:44
44	try_open (const struct stat *main_stat,
(gdb) c
Continuing.

Breakpoint 6, try_open (
dir=dir@entry=0xa28eca "/home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs/var/cache/abrt-di/usr/lib/debug", subdir=subdir@entry=0x62d8c51 "bin", debuglink=debuglink@entry=0x7ffff7fed044 "hello.debug", debuginfo_file_name=debuginfo_file_name@entry=0x7fffffff7340, main_stat=<optimized out>,
   main_stat=<optimized out>) at find-debuginfo.c:61
61	  int fd = TEMP_FAILURE_RETRY (open (fname, O_RDONLY));
(gdb) p fname
$51 = 0x62d9e90 "/home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs/var/cache/abrt-di/usr/lib/debug/bin/hello.debug"
(gdb) c
Continuing.

Breakpoint 5, try_open (
dir=dir@entry=0xa28eca "/home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs/var/cache/abrt-di/usr/lib/debug", subdir=subdir@entry=0x0, debuglink=debuglink@entry=0x7ffff7fed044 "hello.debug", debuginfo_file_name=debuginfo_file_name@entry=0x7fffffff7340, main_stat=<optimized out>,
   main_stat=<optimized out>) at find-debuginfo.c:44
44	try_open (const struct stat *main_stat,
(gdb) c
Continuing.

Breakpoint 6, try_open (
dir=dir@entry=0xa28eca "/home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs/var/cache/abrt-di/usr/lib/debug", subdir=subdir@entry=0x0, debuglink=debuglink@entry=0x7ffff7fed044 "hello.debug", debuginfo_file_name=debuginfo_file_name@entry=0x7fffffff7340, main_stat=<optimized out>,
   main_stat=<optimized out>) at find-debuginfo.c:61
61	  int fd = TEMP_FAILURE_RETRY (open (fname, O_RDONLY));
(gdb) p fname
$52 = 0x62da070 "/home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs/var/cache/abrt-di/usr/lib/debug/hello.debug"


Torsten, have you tried using --sysroot recently?

On Mon, Mar 5, 2018 at 11:37 AM, Victor Kamensky <kamensky@cisco.com> wrote:
If sysroot option is passed, and debug symbols reside in sysroot along
with executable <foo> in <foo_dir>/.debug/<foo_file> directory, stap
fails to find debuginfo because it strips out sysroot path from file_name
so dwfl_standard_find_debuginfo ends up looking at host
<foo_dir>/.debug/<foo_file> rather then checking
<sysroot>/<foo_dir>/.debug/<foo_file>.

Note in cross compile environment, it is good idea to set and export
proper SYSTEMTAP_DEBUGINFO_PATH variable because usual built defaults that
work for native distros very often not applicable to cross sysroot
based environment. For example for yocto poky/OE build the following
setting seems proper "+:.debug:build".

Here are steps how to reproduce the issue. Note <sysroot> is produced by
yocto poky build.

[kamensky@coreos-lnx2 tests]$ ls /home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs/bin/mkdir.coreutils
/home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs/bin/mkdir.coreutils
[kamensky@coreos-lnx2 tests]$ ls /home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs/bin/.debug/mkdir.coreutils
/home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs/bin/.debug/mkdir.coreutils
[kamensky@coreos-lnx2 tests]$ /home/wd8/systemtap/20180208_2/packages/bin/stap --sysroot=/home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs -a x86_64 -r 4.9.78-yocto-standard -B CROSS_COMPILE=x86_64-poky-linux- --sysenv=PATH=/usr/bin:/bin:/usr/sbin:/sbin --sysenv=LD_LIBRARY_PATH=/lib:/usr/lib -v -l 'process("/bin/mkdir.coreutils").function("*")' Pass 1: parsed user script and 480 library scripts using 230184virt/93416res/5344shr/88612data kb, in 350usr/30sys/378real ms.
process("/bin/mkdir.coreutils").function("_fini")
process("/bin/mkdir.coreutils").function("_init")
process("/bin/mkdir.coreutils").function("fts_children")
process("/bin/mkdir.coreutils").function("fts_close")
process("/bin/mkdir.coreutils").function("fts_open")
process("/bin/mkdir.coreutils").function("fts_read")
process("/bin/mkdir.coreutils").function("fts_set")
Pass 2: analyzed script: 7 probes, 0 functions, 0 embeds, 0 globals using 233484virt/97928res/6212shr/91912data kb, in 20usr/0sys/26real ms.

running above example under strace shows that stap tries to access
/bin/.debug/mkdir.coreutils on host, rather then sysroot

13064 openat(AT_FDCWD, "/bin/mkdir.coreutils", O_RDONLY) = -1 ENOENT (No such file or directory) 13064 openat(AT_FDCWD, "/bin/.debug/mkdir.coreutils", O_RDONLY) = -1 ENOENT (No such file or directory) 13064 openat(AT_FDCWD, "/bin/mkdir.coreutils", O_RDONLY) = -1 ENOENT (No such file or directory) 13064 openat(AT_FDCWD, "/bin/build/mkdir.coreutils", O_RDONLY) = -1 ENOENT (No such file or directory) 13064 openat(AT_FDCWD, "/bin/mkdir.coreutils", O_RDONLY) = -1 ENOENT (No such file or directory)

After fix applied stap is able to find /bin/.debug/mkdir.coreutils under
sysroot:

[kamensky@coreos-lnx2 tests]$ /home/wd8/systemtap/20180208_2/packages/bin/stap --sysroot=/home/wd8/yocto/20180128/build_x86_64/tmp/work/intel_corei7_64-poky-linux/kdevel-console-devel-image/1.0-r0/rootfs -a x86_64 -r 4.9.78-yocto-standard -B CROSS_COMPILE=x86_64-poky-linux- --sysenv=PATH=/usr/bin:/bin:/usr/sbin:/sbin --sysenv=LD_LIBRARY_PATH=/lib:/usr/lib -v -l 'process("/bin/mkdir.coreutils").function("*")' | wc Pass 1: parsed user script and 480 library scripts using 230184virt/93440res/5368shr/88612data kb, in 330usr/40sys/371real ms. Pass 2: analyzed script: 401 probes, 0 functions, 0 embeds, 0 globals using 235092virt/99484res/6256shr/93520data kb, in 30usr/0sys/35real ms.
    249     249   29671

Also verified on target that script like example below, once compiled
against sysroot on host and copied back on target can trace 'mkdir'
invocation functions:

[kamensky@coreos-lnx2 tests]$ cat mkdir1.stp
probe process("/bin/mkdir.coreutils").function("*").call {
  printf ("%s -> %s\n", thread_indent(1), ppfunc())
}
probe process("/bin/mkdir.coreutils").function("*").return {
  printf ("%s <- %s\n", thread_indent(-1), ppfunc())
}

Signed-off-by: Victor Kamensky <kamensky@cisco.com>
---
 setupdwfl.cxx | 12 ------------
 1 file changed, 12 deletions(-)

diff --git a/setupdwfl.cxx b/setupdwfl.cxx
index f00cf755b..e5bfa28f0 100644
--- a/setupdwfl.cxx
+++ b/setupdwfl.cxx
@@ -637,18 +637,6 @@ internal_find_debuginfo (Dwfl_Module *mod,

   call_dwfl_standard_find_debuginfo:

-  if (current_session_for_find_debuginfo)
-    {
- string sysroot = current_session_for_find_debuginfo->sysroot + "/*";
-      int    found   = fnmatch(sysroot.c_str(), file_name, 0);
-
-      if (found)
-       {
-         file_name = file_name
-           + current_session_for_find_debuginfo->sysroot.length() - 1;
-       }
-    }
-
   /* Call the original dwfl_standard_find_debuginfo */
   return dwfl_standard_find_debuginfo(mod, userdata, modname, base,
               file_name, debuglink_file,
--
2.14.3




--
David Smith
Associate Manager
Red Hat




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]