[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [openrisc] Gdb Debuginfo for variables in the data-segment



Andreas Rasmusson wrote:

> Hi!
>
> I'm trying to debug a very simple program using
> gdb over the jtag-port. It works mostly fine, but
> the variables in the data-segment seem to have no
> debug info, whereas static variables and variables
> on the stack have correct debug info.
>
> Below is my simple test-program and link-script.
> and a sample gdb-debugging-session. As you see
> gdb has no info about the variable 'a' (the adress
> to it can be retrieved using _a, though, but then
> all type-info is lost).  I've tried to add more stuff
> to the link-script but winthout sucess.
> Does anyone know if its possible to get this info
> for variables in the data-segment?
>
> ----- c-file ----------------
>
> int a[] = {1,2};
> static int b[] = {3,4};
> void start() {
>  int c[] = {5,6};
> }
>
> ----- link-script ------------
>
> MEMORY
>        {
>        ram : ORIGIN = 0x08110000, LENGTH = 0x01000000
>        }
>
> SECTIONS
> {
>        .text : { *(.text) } > ram
>        .data : { *(.data) } > ram
>        .rodata : { *(.rodata) } > ram
>
>        . = ALIGN( 0x4 );
>        __bss_start = .;
>
>        .bss : { *(.bss) } > ram
>
>        . = ALIGN( 0x4 );
>        _end = .; /* needed by newlib */
> }
>
> ----- sample gdbsession -------------
>
>
> (gdb) file simple2.or32
> A program is being debugged already.  Kill it? (y or n) y
>
> Load new symbol table from "simple2.or32"? (y or n) y
>
> Reading symbols from simple2.or32...done.
> (gdb) target jtag jtag://localhost:9999
> Remote or1k debugging using jtag://localhost:9999
> 0x0 in ?? ()
> (gdb) load
> Loading section .text, size 0x28 lma 0x8110000
> Loading section .data, size 0x10 lma 0x8110028
> Start address 0x8110000 , load size 56
> Transfer rate: 448 bits in <1 sec, 28 bytes/write.
> (gdb) p a
> Address of symbol "a" is unknown.
> (gdb) p b
> $2 = {3, 4}
> (gdb) p (&_a)
> $5 = (<data variable, no debug info> *) 0x8110028
> (gdb) p *(int*)(&_a)
> $7 = 1
> (gdb) p *(int*)(&_a+1)
> $8 = 2
> (gdb)
>
>
> -- 
> To unsubscribe from openrisc mailing list please visit 
> http://www.opencores.org/mailinglists.shtml 


Maybe its because you compile your program with '-g -O' ,Then  the 
optimiser is rearranging
your code , if you define a variable, but never use it , gdb can't sees 
that variable because the
compiler optimizes it out of existence, try to compile without optimize.

Gili.


**************************************************************************************************
The contents of this email and any attachments are confidential.
It is intended for the named recipient(s) only.
If you have received this email in error please notify the system manager or  the 
sender immediately and do not disclose the contents to any one or make copies.

** eSafe scanned this email for viruses, vandals and malicious content **
**************************************************************************************************

--
To unsubscribe from openrisc mailing list please visit http://www.opencores.org/mailinglists.shtml