From: Bryce McKinlay <mckinlay@redhat.com>
To: gdb-patches@sources.redhat.com
Subject: Patch: Handle relative paths in .debug_line
Date: Thu, 22 Jul 2004 23:31:00 -0000 [thread overview]
Message-ID: <41004E5D.5020403@redhat.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1476 bytes --]
When debugging mainline gcc, GDB has a problem locating source for files
which are only referenced from .debug_line. For example: debugging gcj,
and trying to put a breakpoint on the parse.y file, I get the following:
Breakpoint 1, lookup_method_invoke (lc=1, cl=0xf6dee5f0, class=0xf6def244,
name=0xf6dee550, arg_list=0xf6e574b0) at parse.y:10956
10956 parse.y: No such file or directory.
in parse.y
(gdb) info source
Current source file is parse.y
Compilation directory is ../../gcc/java
Source language is c.
Compiled with unknown debugging format.
Does not include preprocessor macro info.
This is because the contents of the directory table in .debug_line can
be paths relative to the DW_AT_comp_dir:
The Directory Table:
../../gcc/java
java
/usr/include/bits
.
../../gcc
../../gcc/../libcpp/include
../../gcc/config/i386
../../gcc/../include
/local/gcc-clean/lib/gcc/i686-pc-linux-gnu/3.5.0/include
/usr/include
The File Name Table:
Entry Dir Time Size Name
1 1 0 0 keyword.h
2 1 0 0 lex.c
3 2 0 0 parse.c
4 1 0 0 parse.y
... etc...
DW_AT_comp_dir : (indirect string, offset: 0x658c):
/home/mckinlay/cvs/gcc-really-clean/build/gcc
This patch fixes the problem by appending the path from the directory
table, if it is not absolute already, to the DW_AT_comp_dir path when
creating subfiles from the .debug_line info.
OK to commit?
Bryce
[-- Attachment #2: gdb-subfile-compdir.patch --]
[-- Type: text/x-patch, Size: 4315 bytes --]
2004-07-22 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 22 Jul 2004 23:07:41 -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,28 +6128,44 @@
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 *fullname;
+ struct subfile *subfile;
+ struct cleanup *back_to = make_cleanup (null_cleanup, 0);
+
+ /* If we have a relative dirname, append comp_dir to it. */
+ if (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. */
- if (!IS_ABSOLUTE_PATH (filename) && dirname != NULL)
+ if (!IS_ABSOLUTE_PATH (filename))
{
- struct subfile *subfile;
- char *fullname = concat (dirname, "/", filename, NULL);
+ fullname = concat (dirname, "/", filename, NULL);
+ make_cleanup (xfree, fullname);
+ }
+ else
+ fullname = filename;
- for (subfile = subfiles; subfile; subfile = subfile->next)
+ for (subfile = subfiles; subfile; subfile = subfile->next)
+ {
+ if (FILENAME_CMP (subfile->name, fullname) == 0)
{
- if (FILENAME_CMP (subfile->name, fullname) == 0)
- {
- current_subfile = subfile;
- xfree (fullname);
- return;
- }
+ current_subfile = subfile;
+ do_cleanups (back_to);
+ return;
}
- xfree (fullname);
}
+
start_subfile (filename, dirname);
+ do_cleanups (back_to);
}
static void
next reply other threads:[~2004-07-22 23:31 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-07-22 23:31 Bryce McKinlay [this message]
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
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=41004E5D.5020403@redhat.com \
--to=mckinlay@redhat.com \
--cc=gdb-patches@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