Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: add pc-address #6

Closed
skoperst opened this issue Jan 6, 2021 · 4 comments
Closed

Request: add pc-address #6

skoperst opened this issue Jan 6, 2021 · 4 comments

Comments

@skoperst
Copy link

skoperst commented Jan 6, 2021

Hi, it will be useful to get the pc-address , something like this:

thread: 0, lwp: 3840, type: 0
#0 0x00007f18c7270376 + 0x47c62a in __pthread_cond_wait()+534 in /lib/x86_64-linux-gnu/libpthread.so.0 at futex-internal.h:183
#1 0x00007f18badfe62b + 0x10376 in () in /usr/lib/x86_64-linux-gnu/dri/radeonsi_dri.so
#2 0x00007f18badfe23b + 0x10223 in () in /usr/lib/x86_64-linux-gnu/dri/radeonsi_dri.so

What do you think?

@peadar
Copy link
Owner

peadar commented Jan 22, 2021

Hey,
I'm not sure what you mean - for example -
#0 0x00007fada8f49e3c in __sigsuspend()+28 in /lib64/libc.so.6 at sigsuspend.c:26

In this case 0x00007fada8f49e3c is the PC (I assume you program counter, or, on x86, the RIP register)
The symbol "__sigsuspend" starts 28 bytes before that, hence the +28 there, to indicate you're 28 bytes into that function.

What, in your case, do you intend the 0x47c62a above to indicate at the topmost frame?

@skoperst
Copy link
Author

skoperst commented Feb 6, 2021

Hey, so my previous example is not correct, I'll try to explain again.
Here I ran '/usr/bin/sleep' and used pstack on it:
$ sudo ~/projects/pstack/build/pstack 171909

process: /proc/171909/mem
thread: 0, lwp: 171909, type: 0
#0  0x00007fdeb737e334 in __clock_nanosleep()+84 in /lib/x86_64-linux-gnu/libc.so.6 at clock_nanosleep.c:78
#1  0x00007fdeb7384047 in __nanosleep()+22 in /lib/x86_64-linux-gnu/libc.so.6 at nanosleep.c:27
warning: no compiled support for LZMA - can't decode debug data in /usr/bin/sleep
#2  0x00005635f46f0827 in <unknown>() in /usr/bin/sleep
#3  0x00005635f46f0600 in <unknown>() in /usr/bin/sleep
#4  0x00005635f46ed7b0 in <unknown>() in /usr/bin/sleep
#5  0x00007fdeb72c50b3 in __libc_start_main()+242 in /lib/x86_64-linux-gnu/libc.so.6 at libc-start.c:308
#6  0x00005635f46ed87e in <unknown>() in /usr/bin/sleep

This is my maps:

sudo cat /proc/171909/maps
5635f46eb000-5635f46ed000 r--p 00000000 08:02 12846161                   /usr/bin/sleep
5635f46ed000-5635f46f1000 r-xp 00002000 08:02 12846161                   /usr/bin/sleep
5635f46f1000-5635f46f3000 r--p 00006000 08:02 12846161                   /usr/bin/sleep
5635f46f4000-5635f46f5000 r--p 00008000 08:02 12846161                   /usr/bin/sleep
5635f46f5000-5635f46f6000 rw-p 00009000 08:02 12846161                   /usr/bin/sleep
5635f539b000-5635f53bc000 rw-p 00000000 00:00 0                          [heap]
7fdeb6d2e000-7fdeb729e000 r--p 00000000 08:02 12847762                   /usr/lib/locale/locale-archive
7fdeb729e000-7fdeb72c3000 r--p 00000000 08:02 12847219                   /usr/lib/x86_64-linux-gnu/libc-2.31.so
7fdeb72c3000-7fdeb743b000 r-xp 00025000 08:02 12847219                   /usr/lib/x86_64-linux-gnu/libc-2.31.so
7fdeb743b000-7fdeb7485000 r--p 0019d000 08:02 12847219                   /usr/lib/x86_64-linux-gnu/libc-2.31.so
7fdeb7485000-7fdeb7486000 ---p 001e7000 08:02 12847219                   /usr/lib/x86_64-linux-gnu/libc-2.31.so
7fdeb7486000-7fdeb7489000 r--p 001e7000 08:02 12847219                   /usr/lib/x86_64-linux-gnu/libc-2.31.so
7fdeb7489000-7fdeb748c000 rw-p 001ea000 08:02 12847219                   /usr/lib/x86_64-linux-gnu/libc-2.31.so
7fdeb748c000-7fdeb7492000 rw-p 00000000 00:00 0 
7fdeb74b6000-7fdeb74b7000 r--p 00000000 08:02 12845269                   /usr/lib/x86_64-linux-gnu/ld-2.31.so
7fdeb74b7000-7fdeb74da000 r-xp 00001000 08:02 12845269                   /usr/lib/x86_64-linux-gnu/ld-2.31.so
7fdeb74da000-7fdeb74e2000 r--p 00024000 08:02 12845269                   /usr/lib/x86_64-linux-gnu/ld-2.31.so
7fdeb74e3000-7fdeb74e4000 r--p 0002c000 08:02 12845269                   /usr/lib/x86_64-linux-gnu/ld-2.31.so
7fdeb74e4000-7fdeb74e5000 rw-p 0002d000 08:02 12845269                   /usr/lib/x86_64-linux-gnu/ld-2.31.so
7fdeb74e5000-7fdeb74e6000 rw-p 00000000 00:00 0 
7fff5da5b000-7fff5da7c000 rw-p 00000000 00:00 0                          [stack]
7fff5dae4000-7fff5dae8000 r--p 00000000 00:00 0                          [vvar]
7fff5dae8000-7fff5daea000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 --xp 00000000 00:00 0                  [vsyscall]

Then I want to investigate where exactly is frame number 2:
#2 0x00005635f46f0827 in <unknown>() in /usr/bin/sleep

It could be easier if it was shown as:
#2 0x00005635f46f0827 in <unknown>() [/usr/bin/sleep + 0x5826] in /usr/bin/sleep @0x5635f46eb000+0x5826

This way I can go to my non-stripped version of /usr/bin/sleep and use gdb with the command: info symbol 0x5826

Hope it makes more sense now.

@peadar
Copy link
Owner

peadar commented Feb 9, 2021 via email

@peadar peadar closed this as completed Feb 12, 2021
peadar added a commit that referenced this issue Feb 12, 2021
This adds @<addr> to the end of the name of the ELF file for the frame,
to help associate it with an unrelocated address in the object
Fixes issue #6
@peadar
Copy link
Owner

peadar commented Feb 12, 2021

Fixed in master. Pass -v, and get "@offset" added to the image name. LMK if it works for you -

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants