This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

relocated local static variables


Hello,

We are porting GDB to debug MIPS relocatables.

We use -gdwarf-2, and most of debugging features works,
notably functions and global variables (.data and .bss)
can be accessed correctly after relocation (we use the
objfile_relocate function to relocate the symbols of
the executable file in memory after it has been loaded on
the target). But we have some problems with local static variables.

For example:

main()
{
    static int localStaticBss;
    ...
}

section .text is  relocated at 0xfa964000
section .bss  is  relocated at 0xfa963070

(gdb)info address localStaticBss
Symbol "localStaticBss"   is static storage at address 0xfa964000.

==> So gdb thinks that localStaticBss is in the .text section!

Dumping the Debug Attributes with dwarfdump:

<2><  155>      DW_TAG_variable
                DW_AT_name                  localStaticBss
                DW_AT_decl_file             1
                DW_AT_decl_line             19
                DW_AT_type                  <200>
                DW_AT_location              DW_OP_addr 0

Dumping the Symbol Table with nm:

[ 2] b 0x00 localStaticBss.3  section .bss

(gdb)info address localStaticBss.3
Symbol "localStaticBss.3" is static storage at address 0xfa963070.

So GDB does not see that these 2 symbols are in fact
the same variable.

First, I incorporated the following patch:
[PATCH RFA] dwarf2read.c: symbol relocation in new_symbol()
which relocate address of symbol by the base address
of the section it is in rather than always using
the base address of the .text section.
The function fixup_symbol_section call
lookup_minimal_symbol ("localStaticBss", ...)
But only "localStaticBss.3" is in the minimal
symbol table (name generated by the assembler).
So, the section field can't be updated.

The .symtab and .debug_info sections contains enough
informations to retrieve such value, but it doesn't
seem to be the right way to do.

Is there any patch or future implementation which deals with that ?

note: we use gcc version 2.8.1 and GNU gdb version 20001004
       -gstab is unsupported by this compiler.


Eric.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]