I am using the Intel CMT-CAT distribution (cache management technology - cache allocation technology) at https://github.com/intel/intel-cmt-cat on Ubuntu 18.04.
One of the programs in the distribution (_pqos_api_lock) calls lockf.c from the C std library glibc. Lockf produces a segmentation fault (SIGSEGV). Further debugging shows that it segfaults at the point where rdx switches from 0 to 0x7fffffffe0c8 (140737488347336).
Here is the output from my gdb session:
Breakpoint 1, lockf (fd=4, cmd=cmd@entry=1, len=len@entry=0) at lockf.c:36
36 lockf.c: No such file or directory.
(gdb) ni
39 in lockf.c
(gdb) i r rdi
rdi 0x4 4
(gdb) i r rsi
rsi 0x1 1
(gdb) i r rdx
rdx 0x0 0
(gdb) ni
36 in lockf.c
(gdb) i r rdi
rdi 0x4 4
(gdb) i r rsi
rsi 0x1 1
(gdb) i r rdx
rdx 0x0 0
(gdb) ni
42 in lockf.c
(gdb) i r rdi
rdi 0x4 4
(gdb) i r rsi
rsi 0x1 1
(gdb) i r rdx
rdx 0x0 0
(gdb) ni
36 in lockf.c
(gdb) i r rdi
rdi 0x4 4
(gdb) i r rsi
rsi 0x1 1
(gdb) i r rdx
rdx 0x0 0
(gdb) ni
36 in lockf.c
(gdb) i r rdi
rdi 0x4 4
(gdb) i r rsi
rsi 0x1 1
(gdb) i r rdx
rdx 0x0 0
(gdb) ni
0x00007ffff78f07bb 36 in lockf.c
(gdb) i r rdi
rdi 0x4 4
(gdb) i r rsi
rsi 0x1 1
(gdb) i r rdx
rdx 0x0 0
(gdb) ni
0x00007ffff78f07c0 36 in lockf.c
(gdb) i r rdi
rdi 0x4 4
(gdb) i r rsi
rsi 0x1 1
(gdb) i r rdx
rdx 0x0 0
(gdb) ni
46 in lockf.c
(gdb) i r rdi
rdi 0x4 4
(gdb) i r rsi
rsi 0x1 1
(gdb) i r rdx
rdx 0x0 0
(gdb) ni
39 in lockf.c
(gdb) i r rdi
rdi 0x4 4
(gdb) i r rsi
rsi 0x1 1
(gdb) i r rdx
rdx 0x0 0
(gdb) ni
0x00007ffff78f07c8 39 in lockf.c
(gdb) i r rdi
rdi 0x4 4
(gdb) i r rsi
rsi 0x1 1
(gdb) i r rdx
rdx 0x7fffffffe0c8 140737488347336
(gdb) ni
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff78f07c8 in lockf (fd=4, cmd=cmd@entry=1, len=len@entry=0)
at lockf.c:39
39 in lockf.c
At each new instruction, I show the state of rdi, rsi and rdx (the three registers used for a call to lockf). I am able to see debug line numbers in lockf, but not the source code lines. I want to see the source code lines to understand why I get this error.
I downloaded source for lockf.c from https://code.woboq.org/userspace/glibc/io/lockf.c.html, but the line numbers do not appear to match what's installed on my system. WIthout the source lines of the lockf.c version installed locally, I can't debug why it segfaults.
The libc6-dbg package is already installed and it's the latest version (according to Ubuntu). The installed version of glibc is 2.27-3:
$ ldd --version
ldd (Ubuntu GLIBC 2.27-3ubuntu1) 2.27
So to sum it up, given the scenario described above, how can I see the source code lines in lockf.c (or any other glibc function) from a debug session in gdb.
Finally, I'm calling these programs from a shared object, but I don't think that makes a difference in this case.
UPDATE:
At the point where gdb goes into lockf.c, I issued info source:
info source Current source file is lockf.c Compilation directory is /build/glibc-OTsEL5/glibc-2.27/io Source language is c. Producer is GNU C11 7.3.0 -mtune=generic -march=x86-64 -g -O2 -O3 -std=gnu11 -fgnu89-inline -fmerge-all-constants -frounding-math -fstack-protector-strong -fPIC -fexceptions -ftls-model=initial-exec -fstack-protector-strong. Compiled with DWARF 2 debugging format. Does not include preprocessor macro info.
But there is no /build/glibc-OTsEL5/glibc-2.27/io on my Ubuntu 18.04.