Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1 | From 5bc97be388485a5f8dd85db34372a1299bffd263 Mon Sep 17 00:00:00 2001 |
| 2 | From: Hongxu Jia <hongxu.jia@windriver.com> |
| 3 | Date: Thu, 24 Mar 2016 11:23:14 -0400 |
| 4 | Subject: [PATCH 43/47] gcc/final.c: -fdebug-prefix-map support to remap |
| 5 | sources with relative path |
| 6 | |
| 7 | PR other/70428 |
| 8 | * final.c (remap_debug_filename): Use lrealpath to translate |
| 9 | relative path before remapping |
| 10 | |
| 11 | https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70428 |
| 12 | Upstream-Status: Submitted [gcc-patches@gcc.gnu.org] |
| 13 | |
| 14 | Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> |
| 15 | --- |
| 16 | gcc/final.c | 15 ++++++++++++--- |
| 17 | 1 file changed, 12 insertions(+), 3 deletions(-) |
| 18 | |
| 19 | diff --git a/gcc/final.c b/gcc/final.c |
| 20 | index 820162b2d28..d74cb901abd 100644 |
| 21 | --- a/gcc/final.c |
| 22 | +++ b/gcc/final.c |
| 23 | @@ -1559,16 +1559,25 @@ remap_debug_filename (const char *filename) |
| 24 | const char *name; |
| 25 | size_t name_len; |
| 26 | |
| 27 | + /* Support to remap filename with relative path */ |
| 28 | + char *realpath = lrealpath (filename); |
| 29 | + if (realpath == NULL) |
| 30 | + return filename; |
| 31 | + |
| 32 | for (map = debug_prefix_maps; map; map = map->next) |
| 33 | - if (filename_ncmp (filename, map->old_prefix, map->old_len) == 0) |
| 34 | + if (filename_ncmp (realpath, map->old_prefix, map->old_len) == 0) |
| 35 | break; |
| 36 | if (!map) |
| 37 | - return filename; |
| 38 | - name = filename + map->old_len; |
| 39 | + { |
| 40 | + free (realpath); |
| 41 | + return filename; |
| 42 | + } |
| 43 | + name = realpath + map->old_len; |
| 44 | name_len = strlen (name) + 1; |
| 45 | s = (char *) alloca (name_len + map->new_len); |
| 46 | memcpy (s, map->new_prefix, map->new_len); |
| 47 | memcpy (s + map->new_len, name, name_len); |
| 48 | + free (realpath); |
| 49 | return ggc_strdup (s); |
| 50 | } |
| 51 | |
| 52 | -- |
| 53 | 2.12.2 |
| 54 | |