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

Kees Bakker kees.bakker
Wed Mar 29 05:42:36 GMT 2006


Hello,

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:

dwarf_frame.c:
	case DW_CFA_undefined:{
		Dwarf_Unsigned lreg;

		DECODE_LEB128_UWORD(instr_ptr, lreg)
		    reg_no = (Dwarf_Small) lreg;
		if (reg_no > DW_FRAME_LAST_REG_NUM) {
		    *returned_error = (DW_DLE_DF_REG_NUM_TOO_HIGH);
		    return DW_DLV_ERROR;
		}

		reg[reg_no].ru_is_off = 0;
		reg[reg_no].ru_register = DW_FRAME_UNDEFINED_VAL;
		reg[reg_no].ru_offset = 0;
-- 
**************************************
Kees Bakker
Senior Software Designer
Altium - Think it, Design it, Build it
Phone  : +31 33 455 8584
E-Mail : Kees.Bakker at altium.nl
URL    : http://www.altium.com/
**************************************
Computing is a terminal disease.....



More information about the Dwarf-discuss mailing list