Looking for a gdb function to handle alias addresses

Paul Koning
2003-12-30T22:19:59Z

Gentlepeople,

I'm working on a kernel dump analyzer integrated with gdb (similar to
the corefile support -- but with a pile of added wrinkles many of
which are specific to our particular platform).

One thing we run into from time to time is that there are several
legal addresses for the same object. The target is MIPS-based, so an
obvious one is that a KSEG1 address (0xa0000000-0xbfffffff) aliases a
KSEG0 address (KSEG1 - 0x02000000). Similarly, in MIPS64 there are
64-bit addresses of various forms that also alias, sometimes in more
complex ways than simply a numeric bias.

The ELF image of course has its symbols associated with one of these
addresses, typically the KSEG0 address. As a result, when I'm dealing
with an alias address, the mapping of address to symbol doesn't work
right. It's easy to get the right data from the dump file, but for
commands like "bt" to work, the symbol references have to come out
right.

So... is there a standard gdb hook (say, part of the gdbarch
machinery) that is supposed to take an alias address and map it to the
"canonical" form which is the one expected to be found in the symtab?

I thought of tweaking gdbarch_frame_saved_pc, but then I end up with
false (numeric) addresses showing up in "bt" -- the canonical ones
rather than the ones that are really in the call stack.

Is there a function that's called at a later spot, so I can get the
raw addresses in the callstack and yet have them resolved to symbols
correctly? Similarly, would that allow things like "disassemble
<alias>" to work with the symbol names "correctly" shown in the
disassembly output?

If this doesn't currently exist, could anyone offer hints as to where
such a beast could be added (and what form, roughly, it should take)?

Thanks,
paul