making stabs visible to gdb

Tavis Ormandy
Sat Aug 20 04:49:14 GMT 2022

On 2022-08-20, Tavis Ormandy via Binutils wrote:
> On 2022-08-05, Tom Tromey wrote:
>>>> Also, is there a better way to accomplish what I'm trying to do?
>> In the gdb test suite, we have some Tcl code that makes it relatively
>> simple to create synthetic DWARF.  So, I'd consider extracting that and
>> using it to describe your program.
> Hmm thanks, it kinda works - but it generates tons of warnings like
> this:
> warning: (Internal error: pc 0x8129250 in read in psymtab, but not in
> symtab.)

Nevermind, I figured it out - just making sure a matching section exists
that overlaps that region hides the warning.

This actually works really well, I made some gas macros to make the
syntax nice:

.include "symbols.s"

# bool rddec(char **numstr, uint16_t *num) @ 0x81dac90
function rddec, %bool, 0x81dac90
    param numstr, ** %char
    param num, * %uint16_t

It works perfectly:

(gdb) add-symbol-file symbols.dbg
(gdb) pt rddec
type = boolean (char **, unsigned short *)
(gdb) x/i rddec
0x81dac90 <rddec>:   push   ebp
(gdb) b rddec
Breakpoint 1 at 0x81dac96
(gdb) r

Even parameters work nicely:

Breakpoint 1, 0x081dac96 in rddec (numstr=0xffffc044, num=0x8350dbe)
(gdb) pt numstr
type = char **
(gdb) p *numstr
$1 = 0xffffc048 "06"

I'm really pleased with how this turned out, thanks for the hints!


 _o)            $ lynx
 /\\  _o)  _o)  $ finger
_\_V _( ) _( )  @taviso

More information about the Binutils mailing list