[Dwarf-discuss] libdwarf has a problem with register numbers of DW_FRAME_LAST_REG_NUM and higher

David Anderson davea
Wed Mar 29 09:19:27 GMT 2006


>libdwarf does not like register numbers (in frame info) that are higher
>than DW_FRAME_LAST_REG_NUM (66 at the moment). I can't find it anywhere
>defined in the standard, right?
>
>It looks like it will be a major undertaking to get rid of that limitation
>in lebdwarf. That's a pitty because it has already been a great help
>discovering some problems with our generated DWARF. And we have targets with
>no less than 300 registers that we want to identify in our debugger.
>
>Oh, it looks like the current implementation has a bug in dwarf_frame.c
>related to that. There is an array
>
>   struct Dwarf_Reg_Rule_s reg[DW_FRAME_LAST_REG_NUM];
>
>but a register with number DW_FRAME_LAST_REG_NUM is still accepted and used
>>as an index in that array. For example look at this:


Good point, I'll fix those issues shortly.

The DWARF standard leaves it up to each implementation to
declare the registers in use.   The problem is
the current libdwarf implementation assumes folks modified
DW_REG_TABLE_SIZE  to match their object files
(at least to be large enough: too large is ok).
(it's defined in libdwarf.h)

Notice that the latest libdwarf.h allows you to set that
outside of libdwarf.h (on compiler command lines, for example)
by use of #ifndef DW_REG_TABLE_SIZE

Nontheless, libdwarf needs a bit of fixing to catch
the problem so memory is not corrupted and to give
a little bit more  flexibility.  The new interface for
the DWARF3 regs info, being new, can be changed and I will do so.

Thanks for the detailed bug report.
In the mean time, modify DW_REG_TABLE_SIZE to be large enough for
(all) your cpu chip(s)!

David Anderson



More information about the Dwarf-discuss mailing list