Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: "Jim Blandy" <jimb@red-bean.com>
To: "Eli Zaretskii" <eliz@gnu.org>
Cc: kushneeraj@gmail.com, gdb@sourceware.org
Subject: Re: value of local variable stored in register
Date: Wed, 06 Feb 2008 00:27:00 -0000	[thread overview]
Message-ID: <8f2776cb0802051626s7189fd87t12eef4fa45366f7d@mail.gmail.com> (raw)
In-Reply-To: <u3as7ta4b.fsf@gnu.org>

On Feb 5, 2008 12:35 PM, Eli Zaretskii <eliz@gnu.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 ("%d\n", 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/licenses/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)


  reply	other threads:[~2008-02-06  0:27 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-04  4:53 Neeraj kushwaha
2008-02-04  5:28 ` Rohit Arul Raj
2008-02-04  6:39   ` Neeraj kushwaha
2008-02-04  7:03     ` Rohit Arul Raj
2008-02-04  7:42       ` Rohit Arul Raj
2008-02-04 20:32 ` Eli Zaretskii
2008-02-05 19:42   ` Jim Blandy
2008-02-05 20:35     ` Eli Zaretskii
2008-02-06  0:27       ` Jim Blandy [this message]
2008-02-06  4:18         ` Eli Zaretskii
2008-02-06  6:26           ` Jim Blandy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8f2776cb0802051626s7189fd87t12eef4fa45366f7d@mail.gmail.com \
    --to=jimb@red-bean.com \
    --cc=eliz@gnu.org \
    --cc=gdb@sourceware.org \
    --cc=kushneeraj@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox