List Info

Thread: Re: value of local variable stored in register




Re: value of local variable stored in register
user name
2008-02-05 18:26:46
On Feb 5, 2008 12:35 PM, Eli Zaretskii <elizgnu.org> wrote:
> > The output of 'info address' isn't very helpful if
c has a non-trivial
> > DWARF location expression.
>
> Can you show an example?
>
> Also, is this problem relevant to the case in point
(the OP presented
> a test program)?

Even simple programs can have this trouble.  In the example
below, GDB
can't print the address of parameter 'x', even though its
home is a
fixed offset from the base address of the frame.

$ cat recur.c
#include <stdio.h>

int
recur (int x)
{
  if (x > 0)
    return 2 * recur (x - 2);
  else
    return 1;
}

int
main (int argc, char **argv)
{
  printf ("%dn", recur (7));
}
$ gcc -g recur.c -o recur
$ ~/gdb/pub/nat/gdb/gdb recur
GNU gdb 6.7.50.20080111-cvs
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/l
icenses/gpl.html>
This is free software: you are free to change and
redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type
"show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...
(gdb) break recur
Breakpoint 1 at 0x804838a: file recur.c, line 6.
(gdb) run
Starting program: /home/jimb/play/recur

Breakpoint 1, recur (x=7) at recur.c:6
6         if (x > 0)
(gdb) info address x
Symbol "x" is a variable with complex or multiple
locations (DWARF2).
(gdb) shell readelf -wi recur
The section .debug_info contains:

  Compilation Unit  offset 0x0:
   Length:        369
   Version:       2
   Abbrev Offset: 0
   Pointer Size:  4
 <0><b>: Abbrev Number: 1 (DW_TAG_compile_unit)
     DW_AT_stmt_list   : 0
     DW_AT_high_pc     : 0x80483e7
     DW_AT_low_pc      : 0x8048384
     DW_AT_producer    : GNU C 4.1.2 20070626 (Red Hat
4.1.2-13)
     DW_AT_language    : 1      (ANSI C)
     DW_AT_name        : recur.c
     DW_AT_comp_dir    : /home/jimb/play
...
 <1><10b>: Abbrev Number: 5 (DW_TAG_subprogram)
     DW_AT_sibling     : <137>
     DW_AT_external    : 1
     DW_AT_name        : recur
     DW_AT_decl_file   : 1
     DW_AT_decl_line   : 5
     DW_AT_prototyped  : 1
     DW_AT_type        : <b8>
     DW_AT_low_pc      : 0x8048384
     DW_AT_high_pc     : 0x80483b1
     DW_AT_frame_base  : 0      (location list)
 <2><12a>: Abbrev Number: 6
(DW_TAG_formal_parameter)
     DW_AT_name        : x
     DW_AT_decl_file   : 1
     DW_AT_decl_line   : 4
     DW_AT_type        : <b8>
     DW_AT_location    : 2 byte block: 91 0    
(DW_OP_fbreg: 0)
...
(gdb)

Re: value of local variable stored in register
country flaguser name
Israel
2008-02-05 22:17:45
> Date: Tue, 5 Feb 2008 16:26:46 -0800
> From: "Jim Blandy" <jimbred-bean.com>
> Cc: kushneerajgmail.com, gdbsourceware.org
> 
> (gdb) info address x
> Symbol "x" is a variable with complex or
multiple locations (DWARF2).

That's a bad misfeature.  How about displaying all the
possible
locations, if we cannot say which one is used at the time
the command
is issued?

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )