[PATCH 0/9] using libdw as an alternative unwinder

Dmitry V. Levin ldv at altlinux.org
Fri Mar 16 15:25:03 UTC 2018


On Tue, Mar 13, 2018 at 08:46:15PM +0300, Dmitry V. Levin wrote:
> On Wed, Mar 14, 2018 at 02:28:05AM +0900, Masatake YAMATO wrote:
> > This patch set make strace utilize libdw of elfutils as an alternative
> > unwinder. This is mostly based on
> > 
> > https://anonscm.debian.org/cgit/collab-maint/ltrace.git/commit/?id=dfefa9f057857735a073ea655f5cb34351032c8e
> > 
> > written by Mark Wielaard <mjw at redhat.com>.
> > 
> > If both unwinders(libunwind and libdw) are linked to strace, you can
> > choose one with -klibunwind or -klibdw option.
> > 
> > Example output:
> > 
> >     [yamato at master]~/var/strace% ./strace  -e open -klibunwind ls > /dev/null
> >     open("/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
> >      > /usr/lib64/libc-2.26.so(_nl_load_locale_from_archive+0x433) [0x2e333]
> >      > /usr/lib64/libc-2.26.so(_nl_find_locale+0xf4) [0x2cef4]
> >      > /usr/lib64/libc-2.26.so(setlocale+0x1ee) [0x2c6de]
> [...]
> >     [yamato at master]~/var/strace% ./strace  -e open -klibdw ls > /dev/null
> >     open("/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
> >      > /usr/lib64/libc-2.26.so(_nl_load_locale_from_archive+0x433) [0x2e333]
> >      > /usr/lib64/libc-2.26.so(_nl_find_locale+0xf3) [0x2cef3]
> >      > /usr/lib64/libc-2.26.so(setlocale+0x1ed) [0x2c6dd]
> 
> I wonder where does this off-by-one difference come from?
> They cannot be both correct at the same time, can they?

Also I wonder why both libunwind and libdw use legacy ptrace calls?

$ ./strace -qq -esignal=none -eptrace -o'|grep PTRACE_PEEKDATA' ./strace -eexit_group cat /dev/null 
exit_group(0)                           = ?
+++ exited with 0 +++

$ ./strace -qq -esignal=none -eptrace -o'|grep PTRACE_PEEKDATA' ./strace -klibdw -eexit_group cat /dev/null 
ptrace(PTRACE_PEEKDATA, 5678, 0x7ffc5ece1328, [0x7f2fb0c12ad2]) = 0
ptrace(PTRACE_PEEKDATA, 5678, 0x7ffc5ece1348, [NULL]) = 0
ptrace(PTRACE_PEEKDATA, 5678, 0x7ffc5ece1350, [0x4052f0]) = 0
ptrace(PTRACE_PEEKDATA, 5678, 0x7ffc5ece1358, [0x402150]) = 0
ptrace(PTRACE_PEEKDATA, 5678, 0x7ffc5ece1360, [0x7ffc5ece1460]) = 0
ptrace(PTRACE_PEEKDATA, 5678, 0x7ffc5ece1368, [NULL]) = 0
ptrace(PTRACE_PEEKDATA, 5678, 0x7ffc5ece1370, [NULL]) = 0
ptrace(PTRACE_PEEKDATA, 5678, 0x7ffc5ece1378, [0x7f2fb0c12afa]) = 0
ptrace(PTRACE_PEEKDATA, 5678, 0x7ffc5ece1388, [0x7f2fb0bfcc1e]) = 0
ptrace(PTRACE_PEEKDATA, 5678, 0x7ffc5ece1428, [NULL]) = 0
ptrace(PTRACE_PEEKDATA, 5678, 0x7ffc5ece1430, [NULL]) = 0
ptrace(PTRACE_PEEKDATA, 5678, 0x7ffc5ece1438, [0x402150]) = 0
ptrace(PTRACE_PEEKDATA, 5678, 0x7ffc5ece1440, [0x7ffc5ece1460]) = 0
ptrace(PTRACE_PEEKDATA, 5678, 0x7ffc5ece1448, [0x40217a]) = 0
exit_group(0)                           = ?
+++ exited with 0 +++
 > /lib64/libc-2.27.so(_exit+0x36) [0xc4bc6]
 > /lib64/libc-2.27.so() [0x37ad1]
 > /lib64/libc-2.27.so(exit+0x19) [0x37af9]
 > /lib64/libc-2.27.so(__libc_start_main+0xed) [0x21c1d]
 > /bin/cat() [0x402179]

As you can see, all these PTRACE_PEEKDATA calls are made for addresses from the same page,
one can use a single process_vm_readv call to fetch the whole page.


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20180316/fddd9469/attachment.bin>


More information about the Strace-devel mailing list