diff options
Diffstat (limited to 'gcc/final.c')
-rw-r--r-- | gcc/final.c | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/gcc/final.c b/gcc/final.c index 759bf101d7b..008a773ca23 100644 --- a/gcc/final.c +++ b/gcc/final.c @@ -77,6 +77,7 @@ along with GCC; see the file COPYING3. If not see #include "coverage.h" #include "df.h" #include "vecprim.h" +#include "ggc.h" #ifdef XCOFF_DEBUGGING_INFO #include "xcoffout.h" /* Needed for external data @@ -1350,6 +1351,72 @@ asm_insn_count (rtx body) } #endif +/* ??? This is probably the wrong place for these. */ +/* 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; + + p = strchr (arg, '='); + if (!p) + { + error ("invalid argument %qs to -fdebug-prefix-map", arg); + return; + } + map = XNEW (debug_prefix_map); + map->old_prefix = ggc_alloc_string (arg, p - arg); + map->old_len = p - arg; + p++; + map->new_prefix = ggc_strdup (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 ggc_strdup (s); +} + /* Output assembler code for the start of a function, and initialize some of the variables in this file for the new function. The label for the function and associated |