I'm sure that the program I'm debugging has debug info, and I'm pretty sure that dlls I'm trying to get into are also compiled with the debug info. Yet I can't follow a dll call.
Tools are gdb, gcc, msys2, codeblocks, windows 7.
How to get the list of loaded dll? I need to check the paths at least.
The exe is suspiciously big, 500 KB, almost makes me think that libraries are linked statically instead of dinamically.
I'm pretty sure that dlls I'm trying to get into are also compiled
with the debug info
Use info sharedlibrary to verify that debug info was loaded. For example in the following output all shared libraries are missing debugging information.
(Note the last line: (*): Shared library is missing debugging information.)
(gdb) info sharedlibrary
From To Syms Read Shared Object Library
0x00007ffff7dd5d50 0x00007ffff7df4e20 Yes (*) /lib64/ld-linux-x86-64.so.2
0x00007ffff7adb100 0x00007ffff7b8b7f8 Yes (*) /lib64/libstdc++.so.6
0x00007ffff7701880 0x00007ffff77aa985 Yes (*) /lib64/libm.so.6
0x00007ffff74e5ac0 0x00007ffff74f5de5 Yes (*) /lib64/libgcc_s.so.1
0x00007ffff7120770 0x00007ffff728d0fc Yes (*) /lib64/libc.so.6
(*): Shared library is missing debugging information.
Related
ADD : This link (https://stackoverflow.com/a/48287761/2554472) had the answer for my question (Mark Plotnick's answer). Different title, duplicate answer.
I'm using ddd(with gdb) to analyze a program(qemu).
Before the main() starts, there are some codes running using functions in glibc.
For example I want to see what libc_csu_init is doing(initializing static variables maybe..).
But since my qemu program is linked to release version of libc, I can't see the libc code.
How can I install debug info for libc and see the source code during debug? Do I have to install the debug version libc and compile qemu using that? or can I just install the debug version libc and see the libc source while running dbg?
By the way, if I do ldd qemu-system-aarch64, I can see a line below.
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f2feafb3000)
this means it was compiled against glibc because the libc is under x86_64-linux-gnu directory, isn't it? Please correct me if I'm wrong.
I'm Trying to make my executable portable on linux, to do this i need to copy all the shared library used by the program itself, to check which one do I need I use:
ldd program_name
The output of the program helps me find all the required .so, between these libraries there is:
libc.so.6 => /lib64/libc.so.6 (0x00007f5b61ac2000)
At this point I copied all the libraries in a folder called shared_libs and shipped them alongside the program to another pc, the problem arise when i do:
LD_LIBRARY_PATH=./shared_libs ./program_name
which gives:
[1] 4619 segmentation fault (core dumped) LD_LIBRARY_PATH=./shared_libs ./program_name
I'm pretty sure that libc.so.6 is causing the problem because if I do:
LD_LIBRARY_PATH=./shared_libs ls
with just that library in the shared_libs folder, ls gives seg fault as well.
How can i bundle my application?
EDIT 1: Why i don't link statically everything?
I tried it, The only thing i got was headache...
to do this i need to copy all the shared library used by the program itself
No, you don't. In particular, copying GLIBC simply doesn't work (as you've discovered).
What you actually need is to build your program against an old enough (not newer than any of systems you distribute your program to) libc, and then depend on GLIBC ABI compatibility (which guarantees that programs linked against old GLIBC continue to run correctly when bound to newer GLIBC at runtime).
This can be achieved by either building your program on an old system, or using a chroot, or building a "linux to older linux" cross-compiler.
I'm pretty sure that libc.so.6 is causing the problem
Correct. The reason this doesn't work is explained e.g. here.
The problem is that GLIBC is composed of multiple binaries which all must match. And the path to one of these binaries (the ld-linux) is hard-coded into the program at static link time and can not be changed.
I debugged an application using shared library on target linux system. And I came across the following errors:
(gdb) set sysroot /mnt/hgfs/sharefolders/mksdboot-tl/filesystem
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
(gdb)
Does the shared library have any problem or the GDB debugger is wrongly configured?
Any help would be great.
While debugging a Qt 5 application, I am sometimes not interested in the internals of Qt 5 but in the structure of the application itself. Therefore I do not need to load all debugging symbols of the Qt 5 libraries since these take a few seconds to load.
Is it possible to prevent GDB from loading symbols for these Qt 5 libraries while keeping the debugging symbols for my application?
Is it possible to prevent GDB from loading symbols for these Qt 5 libraries while keeping the debugging symbols for my application?
Yes.
As Richard Critten's comment mentions, setting auto-solib-add to 0 will prevent loading of symbols for all shared libraries, and you can then add files manually with the sharedlibrary command (which accepts a regex). If this regex is omitted, then all shared libraries are loaded.
That however would prevent auto-loading of all symbols (not just debug symbols), and would also prevent auto-loading of symbols for system libraries, which are often required to unwind the stack.
A better approach may be to save a copy of Qt5 libraries with full debug info somewhere, e.g. ~/Qt5-debug/, then run strip -g on the original libraries. That way, you will get symbolic info for all libraries, and in the rare case when you actually need full-debug info for Qt5, you can still do that using the GDB file ~/Qt5-debug/libQt5Core.so.5.2 or similar commands.
The chapter GDB Files from the GDB manual has more documentation on using such separate debugging symbols.
I'm running gdb with set verbose on and I'm trying to understand one of the messages I am getting:
Reading symbols from system-supplied DSO at 0x7ffff7ffb000...(no debugging symbols found)...done.
What is thesystem-supplied DSO? After some search I think that DSO might stand for "dynamic shared object". But I still don't understand exactly what gdb is doing here and how I might solve the problem with the debugging symbols not being found (or if it even matters).
Also the program that I am debugging is being compiled with llvm-gcc and has an LLVM pass applied to it. I think that is effecting the behavior of gdb, but I"m not exactly sure how.
So essentially my question is what does the message that gdb prints mean, is it likely to cause a problem, and if so any suggestions on how I could help gdb find the debugging symbols.
According to this document a DSO is:
A dynamic shared object (DSO) is an object file that’s meant to be
used simultaneously— or shared—by multiple applications (a.out files)
while they’re executing.
I believe that a system supplied DSO is just a DLL provided by the OS and loaded by the main executable. Since this is an external library you don't have the debugging symbols of such object unless you download them separately. Typically the release binaries are stripped of debugging symbols but they can have a link to a separate file. A typical Linux distribution provides a package containing the debugging symbols of such binaries ( like the xxx-debuginfo-xxx.rpm for RedHat based distributions).
In this context, system-supplied-DSO means a shared library provided directly by the linux kernel such as VDSO. Debuginfo is indeed available for them, but is packaged along with the kernel rather than userspace. Use debuginfod to automatically fetch them if your distro supports that.