aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2007-08-24 21:49:55 +0000
committerJoseph Myers <joseph@codesourcery.com>2007-08-24 21:49:55 +0000
commit3d6b762c68c6e19bdf387c0f1db7773fd22aab9a (patch)
treeaaed967f4fb27d39d98495f58b5aa56c5d102381
parent534a31f6908dfec77b02051240630059e3ad7520 (diff)
downloadgdb-3d6b762c68c6e19bdf387c0f1db7773fd22aab9a.zip
gdb-3d6b762c68c6e19bdf387c0f1db7773fd22aab9a.tar.gz
gdb-3d6b762c68c6e19bdf387c0f1db7773fd22aab9a.tar.bz2
2007-08-24 Joseph Myers <joseph@codesourcery.com>
Paul Brook <paul@codesourcery.com> * remap.c: New. * as.h (remap_debug_filename, add_debug_prefix_map): Declare. * as.c (show_usage): Document --debug-prefix-map option. (parse_args): Handle --debug-prefix-map. * dwarf2dbg.c (out_file_list, out_debug_info): Remap debug paths. * stabs.c (stabs_generate_asm_file): Remap debug paths. * Makefile.am (GAS_CFILES): Add remap.c (GENERIC_OBJS): Add remap.o. Regenerate dependencies. * Makefile.in: Regenerate. * doc/as.texinfo (--debug-prefix-map): Document.
-rw-r--r--gas/ChangeLog15
-rw-r--r--gas/Makefile.am8
-rw-r--r--gas/Makefile.in15
-rw-r--r--gas/as.c8
-rw-r--r--gas/as.h3
-rw-r--r--gas/doc/as.texinfo5
-rw-r--r--gas/dwarf2dbg.c16
-rw-r--r--gas/remap.c89
-rw-r--r--gas/stabs.c5
9 files changed, 153 insertions, 11 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 2412503..1e8d61a 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,18 @@
+2007-08-24 Joseph Myers <joseph@codesourcery.com>
+ Paul Brook <paul@codesourcery.com>
+
+ * remap.c: New.
+ * as.h (remap_debug_filename, add_debug_prefix_map): Declare.
+ * as.c (show_usage): Document --debug-prefix-map option.
+ (parse_args): Handle --debug-prefix-map.
+ * dwarf2dbg.c (out_file_list, out_debug_info): Remap debug paths.
+ * stabs.c (stabs_generate_asm_file): Remap debug paths.
+ * Makefile.am (GAS_CFILES): Add remap.c
+ (GENERIC_OBJS): Add remap.o.
+ Regenerate dependencies.
+ * Makefile.in: Regenerate.
+ * doc/as.texinfo (--debug-prefix-map): Document.
+
2007-08-24 Aurelien Jarno <aurel32@debian.org>
* config/tc-arm.c (md_apply_fix): Cast bfd_vma values to long
diff --git a/gas/Makefile.am b/gas/Makefile.am
index 6704236..f2a3611 100644
--- a/gas/Makefile.am
+++ b/gas/Makefile.am
@@ -195,6 +195,7 @@ GAS_CFILES = \
messages.c \
output-file.c \
read.c \
+ remap.c \
sb.c \
stabs.c \
subsegs.c \
@@ -439,6 +440,7 @@ GENERIC_OBJS = \
messages.o \
output-file.o \
read.o \
+ remap.o \
subsegs.o \
symbols.o \
write.o \
@@ -1490,6 +1492,11 @@ DEPOBJ_bfin_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \
$(INCDIR)/bfdlink.h $(srcdir)/config/tc-bfin.h dwarf2dbg.h \
$(INCDIR)/safe-ctype.h subsegs.h $(INCDIR)/obstack.h \
$(INCDIR)/obstack.h struc-symbol.h dwarf2dbg.h $(INCDIR)/aout/aout64.h
+DEPOBJ_cr16_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \
+ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
+ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-cr16.h dwarf2dbg.h \
+ $(INCDIR)/safe-ctype.h subsegs.h $(INCDIR)/obstack.h \
+ $(INCDIR)/obstack.h struc-symbol.h dwarf2dbg.h $(INCDIR)/aout/aout64.h
DEPOBJ_cris_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-cris.h \
$(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h $(INCDIR)/aout/aout64.h \
$(INCDIR)/obstack.h
@@ -2158,6 +2165,7 @@ messages.o: messages.c
output-file.o: output-file.c output-file.h
read.o: read.c $(INCDIR)/safe-ctype.h subsegs.h $(INCDIR)/obstack.h \
sb.h macro.h ecoff.h dw2gencfi.h $(INCDIR)/elf/dwarf2.h
+remap.o: remap.c
sb.o: sb.c sb.h
stabs.o: stabs.c $(INCDIR)/obstack.h subsegs.h ecoff.h \
$(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def
diff --git a/gas/Makefile.in b/gas/Makefile.in
index 6a43cca..1c5958d 100644
--- a/gas/Makefile.in
+++ b/gas/Makefile.in
@@ -76,9 +76,9 @@ am__objects_1 = app.$(OBJEXT) as.$(OBJEXT) atof-generic.$(OBJEXT) \
flonum-mult.$(OBJEXT) frags.$(OBJEXT) hash.$(OBJEXT) \
input-file.$(OBJEXT) input-scrub.$(OBJEXT) listing.$(OBJEXT) \
literal.$(OBJEXT) macro.$(OBJEXT) messages.$(OBJEXT) \
- output-file.$(OBJEXT) read.$(OBJEXT) sb.$(OBJEXT) \
- stabs.$(OBJEXT) subsegs.$(OBJEXT) symbols.$(OBJEXT) \
- write.$(OBJEXT)
+ output-file.$(OBJEXT) read.$(OBJEXT) remap.$(OBJEXT) \
+ sb.$(OBJEXT) stabs.$(OBJEXT) subsegs.$(OBJEXT) \
+ symbols.$(OBJEXT) write.$(OBJEXT)
am_as_new_OBJECTS = $(am__objects_1)
as_new_OBJECTS = $(am_as_new_OBJECTS)
am__DEPENDENCIES_1 = tc-@target_cpu_type@.o
@@ -439,6 +439,7 @@ GAS_CFILES = \
messages.c \
output-file.c \
read.c \
+ remap.c \
sb.c \
stabs.c \
subsegs.c \
@@ -682,6 +683,7 @@ GENERIC_OBJS = \
messages.o \
output-file.o \
read.o \
+ remap.o \
subsegs.o \
symbols.o \
write.o \
@@ -1341,6 +1343,12 @@ DEPOBJ_bfin_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \
$(INCDIR)/safe-ctype.h subsegs.h $(INCDIR)/obstack.h \
$(INCDIR)/obstack.h struc-symbol.h dwarf2dbg.h $(INCDIR)/aout/aout64.h
+DEPOBJ_cr16_elf = $(srcdir)/config/obj-elf.h $(BFDDIR)/elf-bfd.h \
+ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
+ $(INCDIR)/bfdlink.h $(srcdir)/config/tc-cr16.h dwarf2dbg.h \
+ $(INCDIR)/safe-ctype.h subsegs.h $(INCDIR)/obstack.h \
+ $(INCDIR)/obstack.h struc-symbol.h dwarf2dbg.h $(INCDIR)/aout/aout64.h
+
DEPOBJ_cris_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-cris.h \
$(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h $(INCDIR)/aout/aout64.h \
$(INCDIR)/obstack.h
@@ -2996,6 +3004,7 @@ messages.o: messages.c
output-file.o: output-file.c output-file.h
read.o: read.c $(INCDIR)/safe-ctype.h subsegs.h $(INCDIR)/obstack.h \
sb.h macro.h ecoff.h dw2gencfi.h $(INCDIR)/elf/dwarf2.h
+remap.o: remap.c
sb.o: sb.c sb.h
stabs.o: stabs.c $(INCDIR)/obstack.h subsegs.h ecoff.h \
$(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def
diff --git a/gas/as.c b/gas/as.c
index bcb827b..b636396 100644
--- a/gas/as.c
+++ b/gas/as.c
@@ -244,6 +244,8 @@ Options:\n\
fprintf (stream, _("\
-D produce assembler debugging messages\n"));
fprintf (stream, _("\
+ --debug-prefix-map OLD=NEW Map OLD to NEW in debug information\n"));
+ fprintf (stream, _("\
--defsym SYM=VAL define symbol SYM to given value\n"));
#ifdef USE_EMULATIONS
{
@@ -407,6 +409,7 @@ parse_args (int * pargc, char *** pargv)
OPTION_DUMPCONFIG,
OPTION_VERBOSE,
OPTION_EMULATION,
+ OPTION_DEBUG_PREFIX_MAP,
OPTION_DEFSYM,
OPTION_INSTTBL,
OPTION_LISTING_LHS_WIDTH,
@@ -445,6 +448,7 @@ parse_args (int * pargc, char *** pargv)
,{"a", optional_argument, NULL, 'a'}
/* Handle -al=<FILE>. */
,{"al", optional_argument, NULL, OPTION_AL}
+ ,{"debug-prefix-map", required_argument, NULL, OPTION_DEBUG_PREFIX_MAP}
,{"defsym", required_argument, NULL, OPTION_DEFSYM}
,{"dump-config", no_argument, NULL, OPTION_DUMPCONFIG}
,{"emulation", required_argument, NULL, OPTION_EMULATION}
@@ -620,6 +624,10 @@ This program has absolutely no warranty.\n"));
#endif
exit (EXIT_SUCCESS);
+ case OPTION_DEBUG_PREFIX_MAP:
+ add_debug_prefix_map (optarg);
+ break;
+
case OPTION_DEFSYM:
{
char *s;
diff --git a/gas/as.h b/gas/as.h
index 9ec6589..f6138eb 100644
--- a/gas/as.h
+++ b/gas/as.h
@@ -567,6 +567,9 @@ void register_dependency (char *);
void print_dependencies (void);
segT subseg_get (const char *, int);
+const char *remap_debug_filename (const char *);
+void add_debug_prefix_map (const char *);
+
struct expressionS;
struct fix;
typedef struct symbol symbolS;
diff --git a/gas/doc/as.texinfo b/gas/doc/as.texinfo
index b6f7f32..bf8bab7 100644
--- a/gas/doc/as.texinfo
+++ b/gas/doc/as.texinfo
@@ -226,6 +226,7 @@ gcc(1), ld(1), and the Info entries for @file{binutils} and @file{ld}.
@smallexample
@c man begin SYNOPSIS
@value{AS} [@b{-a}[@b{cdhlns}][=@var{file}]] [@b{--alternate}] [@b{-D}]
+ [@b{--debug-prefix-map} @var{old}=@var{new}]
[@b{--defsym} @var{sym}=@var{val}] [@b{-f}] [@b{-g}] [@b{--gstabs}]
[@b{--gstabs+}] [@b{--gdwarf-2}] [@b{--help}] [@b{-I} @var{dir}] [@b{-J}]
[@b{-K}] [@b{-L}] [@b{--listing-lhs-width}=@var{NUM}]
@@ -501,6 +502,10 @@ Begin in alternate macro mode.
Ignored. This option is accepted for script compatibility with calls to
other assemblers.
+@item --debug-prefix-map @var{old}=@var{new}
+When assembling files in directory @file{@var{old}}, record debugging
+information describing them as in @file{@var{new}} instead.
+
@item --defsym @var{sym}=@var{value}
Define the symbol @var{sym} to be @var{value} before assembling the input file.
@var{value} must be an integer constant. As in C, a leading @samp{0x}
diff --git a/gas/dwarf2dbg.c b/gas/dwarf2dbg.c
index 105a834..93b5f48 100644
--- a/gas/dwarf2dbg.c
+++ b/gas/dwarf2dbg.c
@@ -1224,15 +1224,17 @@ static void
out_file_list (void)
{
size_t size;
+ const char *dir;
char *cp;
unsigned int i;
/* Emit directory list. */
for (i = 1; i < dirs_in_use; ++i)
{
- size = strlen (dirs[i]) + 1;
+ dir = remap_debug_filename (dirs[i]);
+ size = strlen (dir) + 1;
cp = frag_more (size);
- memcpy (cp, dirs[i], size);
+ memcpy (cp, dir, size);
}
/* Terminate it. */
out_byte ('\0');
@@ -1514,7 +1516,8 @@ static void
out_debug_info (segT info_seg, segT abbrev_seg, segT line_seg, segT ranges_seg)
{
char producer[128];
- char *comp_dir;
+ const char *comp_dir;
+ const char *dirname;
expressionS expr;
symbolS *info_start;
symbolS *info_end;
@@ -1604,9 +1607,10 @@ out_debug_info (segT info_seg, segT abbrev_seg, segT line_seg, segT ranges_seg)
abort ();
if (files[1].dir)
{
- len = strlen (dirs[files[1].dir]);
+ dirname = remap_debug_filename (dirs[files[1].dir]);
+ len = strlen (dirname);
p = frag_more (len + 1);
- memcpy (p, dirs[files[1].dir], len);
+ memcpy (p, dirname, len);
INSERT_DIR_SEPARATOR (p, len);
}
len = strlen (files[1].filename) + 1;
@@ -1614,7 +1618,7 @@ out_debug_info (segT info_seg, segT abbrev_seg, segT line_seg, segT ranges_seg)
memcpy (p, files[1].filename, len);
/* DW_AT_comp_dir */
- comp_dir = getpwd ();
+ comp_dir = remap_debug_filename (getpwd ());
len = strlen (comp_dir) + 1;
p = frag_more (len);
memcpy (p, comp_dir, len);
diff --git a/gas/remap.c b/gas/remap.c
new file mode 100644
index 0000000..ae07896
--- /dev/null
+++ b/gas/remap.c
@@ -0,0 +1,89 @@
+/* Remap file names for debug info for GNU assembler.
+ Copyright 2007 Free Software Foundation, Inc.
+
+ This file is part of GAS, the GNU Assembler.
+
+ GAS is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3, or (at your option)
+ any later version.
+
+ GAS is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GAS; see the file COPYING. If not, write to the Free
+ Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
+ 02110-1301, USA. */
+
+#include "as.h"
+
+/* Structure recording the mapping from source file and directory
+ names at compile time to those to be embedded in debug
+ information. */
+typedef struct debug_prefix_map
+{
+ const char *old_prefix;
+ const char *new_prefix;
+ size_t old_len;
+ size_t new_len;
+ struct debug_prefix_map *next;
+} debug_prefix_map;
+
+/* Linked list of such structures. */
+debug_prefix_map *debug_prefix_maps;
+
+
+/* Record a debug file prefix mapping. ARG is the argument to
+ -fdebug-prefix-map and must be of the form OLD=NEW. */
+
+void
+add_debug_prefix_map (const char *arg)
+{
+ debug_prefix_map *map;
+ const char *p;
+ char *o;
+
+ p = strchr (arg, '=');
+ if (!p)
+ {
+ as_fatal (_("invalid argument '%s' to -fdebug-prefix-map"), arg);
+ return;
+ }
+ map = xmalloc (sizeof (debug_prefix_map));
+ o = xstrdup (arg);
+ map->old_prefix = o;
+ map->old_len = p - arg;
+ o[map->old_len] = 0;
+ p++;
+ map->new_prefix = xstrdup (p);
+ map->new_len = strlen (p);
+ map->next = debug_prefix_maps;
+ debug_prefix_maps = map;
+}
+
+/* Perform user-specified mapping of debug filename prefixes. Return
+ the new name corresponding to FILENAME. */
+
+const char *
+remap_debug_filename (const char *filename)
+{
+ debug_prefix_map *map;
+ char *s;
+ const char *name;
+ size_t name_len;
+
+ for (map = debug_prefix_maps; map; map = map->next)
+ if (strncmp (filename, map->old_prefix, map->old_len) == 0)
+ break;
+ if (!map)
+ return filename;
+ name = filename + map->old_len;
+ name_len = strlen (name) + 1;
+ s = (char *) alloca (name_len + map->new_len);
+ memcpy (s, map->new_prefix, map->new_len);
+ memcpy (s + map->new_len, name, name_len);
+ return xstrdup (s);
+}
diff --git a/gas/stabs.c b/gas/stabs.c
index fc207f6..d295bea 100644
--- a/gas/stabs.c
+++ b/gas/stabs.c
@@ -492,9 +492,10 @@ stabs_generate_asm_file (void)
as_where (&file, &lineno);
if (use_gnu_debug_info_extensions)
{
- char *dir, *dir2;
+ const char *dir;
+ char *dir2;
- dir = getpwd ();
+ dir = remap_debug_filename (getpwd ());
dir2 = alloca (strlen (dir) + 2);
sprintf (dir2, "%s%s", dir, "/");
generate_asm_file (N_SO, dir2);