How to use a recording that has no debugging symbols
For various reasons you might find yourself recording a program that has been stripped of its symbols or you might want to keep the size of the recording to a minimum and not saving the symbol files is an easy win.
A recording is not like a live process and adding symbols to it in UDB can be somewhat confusing.
In this article I’ll explain how to add symbols to a recording in UDB in order to render it usable.
This is a quick overview of the most common commands you might wan to use when you need to add symbols to your recording.
What’s in your toolbox
UDB (and GDB) have several commands that allow you to control all aspects of symbol loading. Let’s take a look.
Commands to modify the path where to look for symbols
A running program is composed by (mainly) 2 components: the binary file that constitutes the main application and a number of shared libraries linked into it at runtime.
You might therefore face a recording that is lacking symbols for the main binary or for one or more shared libraries.
A sysroot is the path from which all searches start. It can be set and shown with
set sysroot <path>
When a recording is loaded UDB automatically sets the sysroot to be the temporary directory where it decompressed all files. If the debug symbol files are not included it might be a good idea to
- start UDB
set sysroot <path>
Specifies directories where GDB will search for shared libraries with symbols.
Can be set and shown with
set solib-search-path <path1:path2:path3:...>
if the recordings is of a stripped binary it is possible to point UDB to the symbol file to use with
Forces UDB to load symbols for the specified shared libraries or all loaded shared libraries.
In order for UDB to find the symbols these need to be in a PATH known to UDB (see sysroot / solib-search-path).
sharedlibrary <library name>
sharedlibrary <regular expression>
If you specify the a regular expression then UDB will load the symbols for all matching libraries.
Example: recording of a stripped binary with no shared libraries
This is probably the most common case when working with stripped binaries:
you load up your recording and you are greeted with a wonderful
0x0000000000404f18 in ?? () (udb)
As disappointing it is it is also rather easy to fix (the secret here is to know where the debugging symbol file is!)
(udb) symbol-file ~/tmp/recordings_and_symbols/home/etesta/u3/release-x64/undolr/live-record_x64.dbg
Here I knew exactly where to look and UDB picked it up with no problems:
(udb) bt #0 0x0000000000404f18 in _start ()
Now we see the backtrace makes sense.
(udb) b main Breakpoint 1 at 0x402d70: file src/apps/lr/undolr_controller.c, line 4847.
Setting a breakpoint on a symbol works
(udb) c Continuing.
Breakpoint 1, main (argc=4, argv=0x7ffeb73ea5d8) at src/apps/lr/undolr_controller.c:4847 4847 config_init(NULL, environ); (udb)
And we actually hit the breakpoint.