From: Bryce McKinlay <mckinlay@redhat.com>
To: Jim Blandy <jimb@redhat.com>
Cc: gdb-patches@sources.redhat.com
Subject: Re: Patch: Handle relative paths in .debug_line
Date: Thu, 29 Jul 2004 20:54:00 -0000 [thread overview]
Message-ID: <4109641D.7090301@redhat.com> (raw)
In-Reply-To: <vt28yd21sbx.fsf@zenia.home>
[-- Attachment #1: Type: text/plain, Size: 772 bytes --]
Jim Blandy wrote:
>Bryce McKinlay <mckinlay@redhat.com> writes:
>
>
>
>>Jim Blandy wrote:
>>
>>
>>
>>>Thanks for this patch!
>>>
>>>In the revised dwarf2_start_subfile:
>>>
>>>- It looks to me as if the new code doesn't handle the case where both
>>> dirname and comp_dir are null.
>>>
>>>- It seems to me that, when fullname == filename, the loop over the
>>> subfiles duplicates the loop at the top of start_subfile. So that
>>> loop should remain conditional. Its comment should be moved and
>>> adjusted, too.
>>>
>>>
>>>
>>>
>>Here's a revised patch that should address this. OK to commit?
>>
>>
>
>Almost --- dwarf2_start_subfile still passes comp_dir to concat
>without checking whether it's NULL.
>
>
Fixed in the following patch. OK?
Bryce
[-- Attachment #2: gdb-subfile-compdir-3.patch --]
[-- Type: text/x-patch, Size: 3953 bytes --]
2004-07-29 Bryce McKinlay <mckinlay@redhat.com>
* dwarf2read.c (dwarf_decode_lines): Pass comp_dir to
dwarf2_start_subfile.
(dwarf2_start_subfile): New comp_dir parameter. Handle relative paths
in .debug_line by appending them to comp_dir. Use make_cleanup to
free strings used in directory concatenation.
Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.156
diff -u -r1.156 dwarf2read.c
--- dwarf2read.c 6 Jul 2004 19:29:30 -0000 1.156
+++ dwarf2read.c 29 Jul 2004 20:52:10 -0000
@@ -762,7 +762,7 @@
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 *);
@@ -5951,12 +5951,10 @@
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. */
@@ -6044,17 +6042,15 @@
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];
fe->included_p = 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:
@@ -6112,7 +6108,8 @@
/* 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 value of DW_AT_comp_dir. If
+ DIRNAME specifies a relative path, it is appended to COMP_DIR.
This routine tries to keep line numbers from identical absolute and
relative file names in a common subfile.
@@ -6131,8 +6128,19 @@
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)
{
+ struct cleanup *back_to = make_cleanup (null_cleanup, 0);
+
+ /* If we have a relative dirname, append it to comp_dir. */
+ if (comp_dir != NULL && dirname != NULL && !IS_ABSOLUTE_PATH (dirname))
+ {
+ dirname = concat (comp_dir, "/", dirname, NULL);
+ make_cleanup (xfree, dirname);
+ }
+ else if (dirname == NULL)
+ dirname = comp_dir;
+
/* If the filename isn't absolute, try to match an existing subfile
with the full pathname. */
@@ -6140,19 +6148,20 @@
{
struct subfile *subfile;
char *fullname = concat (dirname, "/", filename, NULL);
+ make_cleanup (xfree, fullname);
for (subfile = subfiles; subfile; subfile = subfile->next)
{
if (FILENAME_CMP (subfile->name, fullname) == 0)
{
current_subfile = subfile;
- xfree (fullname);
+ do_cleanups (back_to);
return;
}
}
- xfree (fullname);
}
start_subfile (filename, dirname);
+ do_cleanups (back_to);
}
static void
next prev parent reply other threads:[~2004-07-29 20:54 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-07-22 23:31 Bryce McKinlay
2004-07-23 21:13 ` Jim Blandy
2004-07-23 23:54 ` Bryce McKinlay
2004-07-29 20:19 ` Jim Blandy
2004-07-29 20:54 ` Bryce McKinlay [this message]
2004-07-31 4:16 ` Jim Blandy
2004-07-31 19:23 ` Bryce McKinlay
2004-07-31 20:51 ` Andrew Cagney
2004-08-01 0:24 ` Michael Chastain
2004-09-14 19:53 ` Andrew Cagney
2004-09-14 20:09 ` Bryce McKinlay
2004-09-24 19:12 ` Andrew Cagney
2004-09-30 0:40 Garrison
2004-09-30 0:49 ` Garrison
2004-10-01 18:23 ` Igor Kovalenko
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=4109641D.7090301@redhat.com \
--to=mckinlay@redhat.com \
--cc=gdb-patches@sources.redhat.com \
--cc=jimb@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