From: Frederic RISS <frederic.riss@st.com>
To: Daniel Jacobowitz <drow@false.org>
Cc: Jim Blandy <jimb@red-bean.com>, GDB Patches <gdb-patches@sourceware.org>
Subject: Re: [RFC] Don't lose compilation directory in Dwarf2 line-tables
Date: Tue, 18 Apr 2006 14:00:00 -0000 [thread overview]
Message-ID: <1145368299.14807.889.camel@crx549.cro.st.com> (raw)
In-Reply-To: <20060418130432.GC10130@nevyn.them.org>
[-- Attachment #1: Type: text/plain, Size: 1484 bytes --]
On Tue, 2006-04-18 at 09:04 -0400, Daniel Jacobowitz wrote:
> On Tue, Apr 18, 2006 at 02:32:09PM +0200, Frederic RISS wrote:
> > All this file matching seems quite fragile, and the current approach
> > will get it wrong sometimes. Shouldn't the loop in dwarf2_start_subfile
> > be killed in favor of a search using both xfullpath(dirname'/'filename)
> > at the start of buildsym.c::start_subfile?
>
> The problem with using xfullpath is that it requires the file to exist
I realized that after having sent the patch.
> and already be found; as long as we are consistent, it's not too
> fragile, because we're checking against our own output.
I just made that comment because of the testsuite breakage that ensued
from modifying dirname before the loop... which seemed to imply that the
mechanism was fragile.
> > +
> > + if (dirname == NULL)
> > + dirname = comp_dir;
> > + else
> > + if (!IS_ABSOLUTE_PATH (dirname) && comp_dir != NULL)
> > + {
> > + dirname = concat (comp_dir, SLASH_STRING, dirname, (char *)NULL);
> > + /* do_cleanups is called after line info procesing */
> > + make_cleanup (xfree, dirname);
>
> Comment formatting again (and "processing"). But this is really nasty.
> Why not free it before we return? We don't return dirname, and
> start_subfile takes a copy.
I kind of copied it from the end of decode_dwarf_lines where
make_cleanups are used for the same kind of things.
Thanks for your review, I'm attaching an updated patch.
Fred.
[-- Attachment #2: dwarf2-keep-compdir.patch --]
[-- Type: text/x-patch, Size: 3558 bytes --]
2006-04-18 Frederic Riss <frederic.riss@st.com>
* dwarf2read.c (dwarf2_start_subfile): Change prototype to accept
compilation directory as last argument. Prepend the passed comp_dir
to dirname when necessary.
(dwarf_decode_lines): Pass the compilation directory to
dwarf2_start_subfile.
--- dwarf2read.c.orig 2006-04-13 11:17:40.000000000 +0200
+++ dwarf2read.c 2006-04-18 15:34:47.000000000 +0200
@@ -846,7 +846,7 @@ static struct line_header *(dwarf_decode
static void dwarf_decode_lines (struct line_header *, char *, bfd *,
struct dwarf2_cu *, struct partial_symtab *);
-static void dwarf2_start_subfile (char *, char *);
+static void dwarf2_start_subfile (char *, char *, char *);
static struct symbol *new_symbol (struct die_info *, struct type *,
struct dwarf2_cu *);
@@ -6529,13 +6529,12 @@ dwarf_decode_lines (struct line_header *
directory and file name numbers in the statement program
are 1-based. */
struct file_entry *fe = &lh->file_names[file - 1];
- char *dir;
+ char *dir = NULL;
if (fe->dir_index)
dir = lh->include_dirs[fe->dir_index - 1];
- else
- dir = comp_dir;
- dwarf2_start_subfile (fe->name, dir);
+
+ dwarf2_start_subfile (fe->name, dir, comp_dir);
}
/* Decode the table. */
@@ -6627,17 +6626,16 @@ dwarf_decode_lines (struct line_header *
0-based, but the directory and file name numbers in
the statement program are 1-based. */
struct file_entry *fe;
- char *dir;
+ char *dir = NULL;
file = read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
line_ptr += bytes_read;
fe = &lh->file_names[file - 1];
if (fe->dir_index)
dir = lh->include_dirs[fe->dir_index - 1];
- else
- dir = comp_dir;
+
if (!decode_for_pst_p)
- dwarf2_start_subfile (fe->name, dir);
+ dwarf2_start_subfile (fe->name, dir, comp_dir);
}
break;
case DW_LNS_set_column:
@@ -6717,7 +6715,8 @@ dwarf_decode_lines (struct line_header *
/* Start a subfile for DWARF. FILENAME is the name of the file and
DIRNAME the name of the source directory which contains FILENAME
- or NULL if not known.
+ or NULL if not known. COMP_DIR is the compilation directory for the
+ linetable's compilation unit or NULL if not known.
This routine tries to keep line numbers from identical absolute and
relative file names in a common subfile.
@@ -6736,8 +6735,10 @@ dwarf_decode_lines (struct line_header *
subfile, so that `break /srcdir/list0.c:1' works as expected. */
static void
-dwarf2_start_subfile (char *filename, char *dirname)
+dwarf2_start_subfile (char *filename, char *dirname, char *comp_dir)
{
+ char *dir = dirname;
+
/* If the filename isn't absolute, try to match an existing subfile
with the full pathname. */
@@ -6757,7 +6758,18 @@ dwarf2_start_subfile (char *filename, ch
}
xfree (fullname);
}
- start_subfile (filename, dirname);
+
+ /* Make the dirname as absolute as possible. */
+
+ if (dirname == NULL)
+ dir = comp_dir;
+ else if (!IS_ABSOLUTE_PATH (dirname) && comp_dir != NULL)
+ dir = concat (comp_dir, SLASH_STRING, dirname, (char *)NULL);
+
+ start_subfile (filename, dir);
+
+ if (dirname != NULL && dir != dirname)
+ xfree(dir);
}
static void
next prev parent reply other threads:[~2006-04-18 14:00 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-04-13 11:25 [RFC] Don't loose " Frederic RISS
2006-04-13 17:49 ` Jim Blandy
2006-04-14 7:32 ` [RFC] Don't lose " Frederic RISS
2006-04-14 7:41 ` Jim Blandy
2006-04-14 8:23 ` Frederic RISS
2006-04-14 14:04 ` Daniel Jacobowitz
2006-04-14 14:51 ` Frederic RISS
2006-04-18 12:32 ` Frederic RISS
2006-04-18 13:04 ` Daniel Jacobowitz
2006-04-18 14:00 ` Frederic RISS [this message]
2006-04-20 16:27 ` Daniel Jacobowitz
2006-04-21 7:14 ` Frederic RISS
2006-04-21 1:10 ` Jim Blandy
2006-04-21 8:35 ` Frederic RISS
2006-04-21 16:46 ` Jim Blandy
2006-04-21 17:00 ` Frederic RISS
2006-04-24 12:49 ` Andrew STUBBS
2006-04-14 8:44 ` Eli Zaretskii
2006-04-14 11:44 ` Frederic RISS
2006-04-14 13:08 ` Eli Zaretskii
2006-04-14 13:42 ` Frederic RISS
2006-04-14 14:21 ` Eli Zaretskii
2006-04-14 14:58 ` Daniel Jacobowitz
2006-04-14 15:03 ` Eli Zaretskii
2006-04-14 18:39 ` Frédéric Riss
2006-04-13 19:58 ` [RFC] Don't loose " Jason Molenda
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=1145368299.14807.889.camel@crx549.cro.st.com \
--to=frederic.riss@st.com \
--cc=drow@false.org \
--cc=gdb-patches@sourceware.org \
--cc=jimb@red-bean.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