From: Joel Brobecker <brobecker@adacore.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: gdb@sources.redhat.com
Subject: Re: Should "dir" override the full path encoded in debug info?
Date: Sat, 24 Jun 2006 07:04:00 -0000 [thread overview]
Message-ID: <20060624065920.GB22750@adacore.com> (raw)
In-Reply-To: <u8xnn9i8s.fsf@gnu.org>
> As Daniel points out, this is a complicated issue; the relevant code
> was changed several times during the last year to cater to several
> popular practices wrt source location. I think, to judge whether this
> is a bug or a feature, we need to see more information, like the
> original location of the sources during compilation, what file names
> are recorded in the debug info, the "dir" command that was issued at
> debug time, and the unwanted behavior and/or the error message(s), if
> any, from GDB.
OK, here goes an example using C. Consider the following source file
called foo.c, located in <path>/src.
#include <stdio.h>
int
main (void)
{
printf ("Hello world.\n");
}
Cd to <path>/src, and then compile it as follow:
% gcc -c -g `pwd`/foo.c
% gcc -o foo foo.o
Then cd one level up to <path> and do the following:
% cp -R src dup
Now, let's simulate the action of our test engine that undoes the
changes that we just tested. For that, I simply edited the original
file in src/, and change the string.
Next step, we debug the binary we copied. Because we know the relevant
sources are in dup, and not in the original location where they were
located when we did the built, the user used the "dir" command to
point GDB to the new location:
(gdb) dir dup
Source directories searched: /<path>/dup:$cdir:$cwd
But then, trying to print the contents of foo.c reveals that we display
the file from the original location. So the "dir" command was not taken
into account:
(gdb) list foo.c:1
warning: Source file is more recent than executable.
1 #include <stdio.h>
2
3 int
4 main (void)
5 {
6 printf ("Hello modified.\n");
7 }
It seems from Daniel's answer that this is by design. The document
is not that clear about that, which explained why I asked before
going in and "fixing" it.
The debugging information generated by foo.c is as follow:
<0><b>: Abbrev Number: 1 (DW_TAG_compile_unit)
DW_AT_stmt_list : 0
DW_AT_high_pc : 0x21 33
DW_AT_low_pc : 0 0
DW_AT_producer : GNU C 3.4.6 for GNAT Pro 5.05w (20060507)
DW_AT_language : 1 (ANSI C)
DW_AT_name : /t.a/brobecke/moved/ex/src/foo.c
As you can see, the DW_AT_name attribute contains a full path name,
and the DW_AT_comp_dir attribute is ommitted. Normally, what we see
is a relative path name in AT_name, and a comp_dir attribute that
provides the path for that file. For instance:
<0><b>: Abbrev Number: 1 (DW_TAG_compile_unit)
DW_AT_stmt_list : 0
DW_AT_high_pc : 0x21 33
DW_AT_low_pc : 0 0
DW_AT_producer : GNU C 3.4.6 for GNAT Pro 5.05w (20060507)
DW_AT_language : 1 (ANSI C)
DW_AT_name : foo.c
DW_AT_comp_dir : /t.a/brobecke/moved/ex/src
The above debugging data is obtained if I compile the file with
the same command, but ommitting the `pwd` part. It's interesting
to notice that in this case, the scenario above leads to a different
behavior which actually matches what my coworker expected.
--
Joel
next prev parent reply other threads:[~2006-06-24 6:59 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-23 20:18 Joel Brobecker
2006-06-23 21:51 ` Daniel Jacobowitz
2006-06-24 7:11 ` Joel Brobecker
2006-06-24 13:27 ` Paul Koning
2006-06-24 6:59 ` Eli Zaretskii
2006-06-24 7:04 ` Joel Brobecker [this message]
2006-06-24 7:08 ` Eli Zaretskii
2006-06-24 7:15 ` Joel Brobecker
2006-06-24 7:51 ` Eli Zaretskii
2006-06-24 11:19 ` Joel Brobecker
2006-06-24 13:38 ` Daniel Jacobowitz
2006-06-25 13:00 ` Joel Brobecker
2006-06-25 18:49 ` Paul Koning
2006-06-25 22:58 ` Eli Zaretskii
2006-06-26 1:56 ` Joel Brobecker
2006-06-26 2:03 ` Daniel Jacobowitz
2006-06-26 2:19 ` Bob Rossi
2006-06-26 2:44 ` Daniel Jacobowitz
2006-06-26 3:23 ` Daniel Jacobowitz
2006-06-26 3:25 ` Joel Brobecker
2006-06-26 8:38 ` Joel Brobecker
2006-06-26 12:58 ` Andreas Schwab
2006-06-26 12:38 ` Andreas Schwab
2006-06-26 15:39 ` Joel Brobecker
2006-06-26 15:54 ` Joel Brobecker
2006-06-27 10:03 ` Bob Rossi
2006-06-27 8:25 ` Bob Rossi
2006-06-28 2:26 ` Andrew STUBBS
2006-06-27 23:10 ` Andrew STUBBS
2006-06-27 12:17 ` Joel Brobecker
2006-06-27 10:06 ` Joel Brobecker
2006-06-27 18:31 ` Andreas Schwab
2006-06-27 12:18 ` Andreas Schwab
2006-06-26 10:42 ` Eli Zaretskii
2006-06-26 9:51 ` Eli Zaretskii
2006-06-24 21:31 ` Eli Zaretskii
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=20060624065920.GB22750@adacore.com \
--to=brobecker@adacore.com \
--cc=eliz@gnu.org \
--cc=gdb@sources.redhat.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