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

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



>
>
>----------------------------------------------------------------------
>From: Gili Gamliel <gilig@flextronics.co.il>
>Date: Wed, 11 Sep 2002 14:47:21 +0300
>Subject: 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.
>
>  
>
Thanks for your suggestions. However, I'm not compiling with any 
optimization-flags. (I should
have supplied them too.. sorry..).  Anyway, I take your answer as a 
suggestion that it is supposed
to work and that perhaps my system is misconfigured somehow.
Anyway, here's a smaller testcase to demonstrate the difference between 
the behavior on my
linux workstation compared to the behavior of the or32-tools (here i use 
the compiler supplied link-script).
Can you see the variable xx in the debugger using the or32-tools on the 
example below?

thanks
/Andreas Rasmusson, Voxi

--- program ---

int xx[2];
int main() {
  return 0;
}
---------------

linux session:

~> gcc test.c -Wall -g -o test
~> gdb test
[...]
(gdb) p xx
$1 = {0, 0}

--------------

or32-session:

~> or32-elf-gcc -nostdlib -g test.c -o test.or32
[warning that _start is not defined]
~> or32-elf-gdb test.or32
[...]
(gdb) p xx
Address of symbol "xx" is unknown.

-------------




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