debuginfod doesn't provide debug info of glibc malloc/arena.c - gdb

I use debuginfod service to view glibc source code. It successfully download debug info of malloc/malloc.c. However, when I step into the function ptmalloc_init() which is defined in malloc/arena.c, the debuginfod says:
315 /usr/src/debug/glibc/malloc/arena.c: Directory not empty.
and gdb's list command cannot show source code of ptmalloc_init(). I check the files in ~/.cache/debuginfod_client, and find out <BUILDID>/source##usr##src##debug##glibc##malloc##malloc.c has content while <BUILDID>/source##usr##src##debug##glibc##malloc##arena.c is a empty file.
How can I debug with malloc/arena.c source code?

Related

nacl-gdb fails to read .pexe?

Is nacl-gdb only for *.nexe and not *.pexe files? im following the guide at https://developers.google.com/native-client/devguide/devcycle/debugging#gdb
./$NACL_SDK_ROOT/toolchain/mac_x86_newlib/bin/x86_64-nacl-gdb
...
This GDB was configured as "--host=i386-apple-darwin10.8.0 --target=x86_64-nacl".
...
(gdb) nacl-manifest code.nmf
(gdb) nacl-irt pnacl/Release/code.pexe
`pnacl/Release/code.pexe': can't read symbols: File format not recognized.
The .pexe is not the final executable, and nacl-gdb does not understand its format. It's a target-independent "intermediate format" file that has to be translated by the browser to a native module before it can be executed and/or debugged.
You can debug .nexes produced by the PNaCl toolchain, by compiling all the way to a .nexe with debug information and then debugging that. In other words, just as you debug a .nexe produced by the gcc toolchains.

Need GLIBC debug information from rpmbuild of updated source

I'm working on RHEL WS 4.5.
I've obtained the glibc source rpm matching this system, opened it to get its contents using rpm2cpio.
Working in that tree, I've created a patch to mtrace.c (i want to add more stack backtrace levels) and incorporated it in the spec file and created a new set of RPMs including the debuginfo rpms.
I installed all of these on a test vm (created from the same RH base image) and can confirm that my changes are included.
But with more complex executions, I crash in mtrace.c ... but gdb can't find the debug information so I don't get line number info and I can't actually debug the failure.
Based on dates, I think I can confirm that the debug information is installed on the test system in /usr/src/debug/glibc-2.3.6/
I tried
sharedlibrary libc*
in gdb and it tells me the symbols are already loaded.
My test includes a locally built python and full symbols are found for python.
My sense is that perhaps glibc isn't being built under rpmbuild with debug enabled. I've reviewed the glibc.spec file and even built with
_enable_debug_packages
defined as 1 which looked like it might influence the result. My review of the configure scripts invoked during the rpmbuild build step didn't give me any hints.
Hmmmm .. just found /usr/lib/debug/lib/libc-2.3.4.so.debug
and /usr/lib/debug/lib/tls/i486/libc-2.3.4.so.debug
but both of these are reported as stripped by the file command.
It appears that you are installing non-matching RPMs:
/usr/src/debug/glibc-2.3.6
just found /usr/lib/debug/lib/libc-2.3.4.so.debug
There are not for the same version; there is no way they came from the same -debuginfo RPM.
both of these are reported as stripped by the file command.
These should not show as stripped. Either they were not built correctly, or your strip is busted.
Also note that you don't actually have to get all of this working to debug your problem. In the RPMBUILD directory, you should be able to find the glibc build directory, with full-debug libc.so.6. Just copy that library into your VM, and you wouldn't have to worry about the debuginfo RPM.
Try verifying that debug info for mtrace.c is indeed present. First see if the separate debug info for GLIBC knows about a compilation unit called mtrace.c:
$ eu-readelf -w /usr/lib/debug/lib64/libc-2.15.so.debug > t
$ grep mtrace t
name (strp) "mtrace.c"
name (strp) "mtrace"
1 0 0 0 mtrace.c
[10480] "mtrace.c"
[104bb] "mtrace"
[5052] symbol: mtrace, CUs: 446
Then see if GDB actually finds the source file from the glibc-debuginfo RPM:
(gdb) set pagination off
(gdb) start # pause your test program right after main()
(gdb) set logging on
Copying output to gdb.txt.
(gdb) info sources
Quit GDB then grep for mtrace in gdb.txt and you should find something like /usr/src/debug/glibc-2.15-a316c1f/malloc/mtrace.c
This works with GDB 7.4. I'm not sure the GDB version shipped with RHEL 4.5 supports all the command used above. Building upstream GDB from source is in fact easier than Python though.
When trying to add strack traces to mtrace, make sure you don't call malloc() directly or indirectly in the GLIBC malloc hooks.

Eclipse CDT 4.2 debug remote external program

I'd like to debug to debug a remote application with GDB.
My target system is a FreeBSD 8.3 box with gdbserver running. The application has been compiled successfully on that box. My Eclipse CDT 4.2 runs on Windows 7 with recent MinGW installed.
This is an external program I'd like to debug. It is neither written by me nor I do have it as a library. I do not intend to write my own program. In this case it is Subversion 1.8.0-dev which I want to debug.
I have created a simple C project, attached the source of Subversion. Created a remote debug config and attached the sources to the running thread in gdbserver.
Now, eclipse enters the main function of Subversion but when I set a breakpoint in another attached source file, Eclipse says: No source file named ra_loader.c or it simply says "No source available".
Then It simply exists the application.
What am I missing here?
Try the suggestion made on this thread
Quote :
1) run a debug session and open the gdb console inside Eclipse
('Console' tab -> 'Display Selected Console' button -> choose the one
ending with 'gdb')
2) use command 'pwd' in the console to print
gdb's current working dir
3) use command 'info line main' to get
the source file where gdb expect to find of my "int main(...)"
function
4) concatenate the result of step 2 with result of step
3 (which should be a relative path) to see if it matches the
correct source file I want
5) use the 'cd' command in gdb (to
change the current working dir) till I get the correct match in
step 4
Knowing the initial working directory (2) and the correct working directory (5) for gdb , I had 2 options: 1) Use gdb's 'cd'
command every time I launch a debug session (I could setup a
.gdbinit file in the gdb initial working directory to do this
automatically) or 2) Setup the 'Source' tab, in 'Debug
Configurations', to make Eclipse use paths that match with gdb's
initial working dir ('Project - Path Relative to Source Folders'
worked for me)

I can't debug in Code::Blocks

I know this is a very common problem, but I tried a lot of stuff, I no one give me a solution. I have a program in C++ with C::B, and I cannot debug. I have the tick in the "-g" option at the "Build Options" in my project. And I have the "gdb.exe" as debugger. But the result is this:
Building to ensure sources are up-to-date
Build succeeded
Selecting target:
Release
Adding source dir: I:\Juego para practicar\
Adding source dir: I:\Juego para practicar\
Adding file: bin\Release\Juego para practicar.exe
Starting debugger:
done
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints
**(no debugging symbols found)...(gdb)**
Debugger name and version: GNU gdb 5.2.1
No symbol table is loaded. Use the "file" command.
Program exited with code 030000000472.
Debugger finished with status 0
What can I do? I proved everything, but it remains with no debugging.
"..
Selecting target:
Release
.."
You are in release build, try to rebuild in debug
Paste your buildlog showing us that you are getting the correct compiler flags.
For example, you should have -g for producing symbols.. You shouldn't have -s (strip) which removes all symbols not needed for relocations, etc.

source lines while debugging a core dump

In c or c++ While debugging a core dump,i.e., if we are left with a coredump file and try to debug using that core file is there a way we can see the last few lines of code before the dump occured.the stack trace only shows the function call.
for eg:during debugging a running process in dbx or gdb list command
list Display lines of a source file
will give the part of the code currently under execution.in the same way do we have the option while looking into a core dump?
i am working on solaris mdb
The list command in gdb should provide details of source code line numbers and the corresponding source listing from a core file if:
The executable was compiled with debug symbols enabled (eg. -g in gcc and g++)
A non-stripped version of the executable is available (ie. has not had the debug information removed by running strip)
The debugger is able to find the relevant source files
The debugger should still be able to provide file and line numbers even if it is unable to find the source files as the line number information forms a part of the debug symbols. This information should be available through the bt (backtrace) command, as well as the info symbol command.
Note that even if the core file was generated from a stripped executable, as long as you have access to a non-stripped version you can load that in gdb as well as specifying the core file.
Take a look at chapter 13 and 15 of the gdb manual to assist in giving gdb access to your source files.
If you compiled with -g option you can display source lines. In dbx you can use use command to set dbx source directories.
You can use list (l) command to display source lines.
See help command to learn how to use dbx and gdb commands.
If you have set your source path properly using use command in dbx or started it with -I option, then there's hardly any difference between debugging a core dump and a normal process when it comes to reading source lines.