Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/gpl3 add -fdebug-regex-map=regex=subst which works ...
details: https://anonhg.NetBSD.org/src/rev/56f3a0ec34da
branches: trunk
changeset: 812935:56f3a0ec34da
user: christos <christos%NetBSD.org@localhost>
date: Sat Jan 09 02:00:14 2016 +0000
description:
add -fdebug-regex-map=regex=subst which works like sed -e s/regex/subst/
to aid with /usr/obj remapping for MKREPRO
diffstat:
external/gpl3/gcc.old/dist/gcc/Makefile.in | 1 +
external/gpl3/gcc.old/dist/gcc/common.opt | 6 +-
external/gpl3/gcc.old/dist/gcc/config/rs6000/ppc-asm.h | 2 +-
external/gpl3/gcc.old/dist/gcc/debug.h | 1 +
external/gpl3/gcc.old/dist/gcc/final.c | 86 ++++++++-
external/gpl3/gcc.old/dist/gcc/opts-global.c | 4 +
external/gpl3/gcc.old/dist/gcc/opts.c | 4 +
external/gpl3/gcc.old/dist/gcc/regsub.c | 161 +++++++++++++++++
external/gpl3/gcc.old/usr.bin/backend/Makefile | 4 +-
external/gpl3/gcc/dist/gcc/Makefile.in | 1 +
external/gpl3/gcc/dist/gcc/common.opt | 6 +-
external/gpl3/gcc/dist/gcc/config/rs6000/ppc-asm.h | 2 +-
external/gpl3/gcc/dist/gcc/debug.h | 1 +
external/gpl3/gcc/dist/gcc/final.c | 86 ++++++++-
external/gpl3/gcc/dist/gcc/opts-global.c | 4 +
external/gpl3/gcc/dist/gcc/opts.c | 4 +
external/gpl3/gcc/dist/gcc/regsub.c | 161 +++++++++++++++++
external/gpl3/gcc/usr.bin/backend/Makefile | 4 +-
18 files changed, 526 insertions(+), 12 deletions(-)
diffs (truncated from 724 to 300 lines):
diff -r a1b5f50218e2 -r 56f3a0ec34da external/gpl3/gcc.old/dist/gcc/Makefile.in
--- a/external/gpl3/gcc.old/dist/gcc/Makefile.in Sat Jan 09 01:13:42 2016 +0000
+++ b/external/gpl3/gcc.old/dist/gcc/Makefile.in Sat Jan 09 02:00:14 2016 +0000
@@ -1336,6 +1336,7 @@
regmove.o \
regrename.o \
regstat.o \
+ regsub.o \
reload.o \
reload1.o \
reorg.o \
diff -r a1b5f50218e2 -r 56f3a0ec34da external/gpl3/gcc.old/dist/gcc/common.opt
--- a/external/gpl3/gcc.old/dist/gcc/common.opt Sat Jan 09 01:13:42 2016 +0000
+++ b/external/gpl3/gcc.old/dist/gcc/common.opt Sat Jan 09 02:00:14 2016 +0000
@@ -974,7 +974,11 @@
fdebug-prefix-map=
Common Joined RejectNegative Var(common_deferred_options) Defer
-Map one directory name to another in debug information
+Map one directory name prefix to another in debug information
+
+fdebug-regex-map=
+Common Joined RejectNegative Var(common_deferred_options) Defer
+Map one directory name to another in debug information using regular expression matching
fdebug-types-section
Common Report Var(flag_debug_types_section) Init(0)
diff -r a1b5f50218e2 -r 56f3a0ec34da external/gpl3/gcc.old/dist/gcc/config/rs6000/ppc-asm.h
--- a/external/gpl3/gcc.old/dist/gcc/config/rs6000/ppc-asm.h Sat Jan 09 01:13:42 2016 +0000
+++ b/external/gpl3/gcc.old/dist/gcc/config/rs6000/ppc-asm.h Sat Jan 09 02:00:14 2016 +0000
@@ -375,7 +375,7 @@
#endif
#endif
-#if defined __linux__ && !defined __powerpc64__
+#if defined(__ELF__) && defined(__linux__) && !defined(__powerpc64__)
.section .note.GNU-stack
.previous
#endif
diff -r a1b5f50218e2 -r 56f3a0ec34da external/gpl3/gcc.old/dist/gcc/debug.h
--- a/external/gpl3/gcc.old/dist/gcc/debug.h Sat Jan 09 01:13:42 2016 +0000
+++ b/external/gpl3/gcc.old/dist/gcc/debug.h Sat Jan 09 02:00:14 2016 +0000
@@ -186,6 +186,7 @@
const char *remap_debug_filename (const char *);
void add_debug_prefix_map (const char *);
+void add_debug_regex_map (const char *);
/* For -fdump-go-spec. */
diff -r a1b5f50218e2 -r 56f3a0ec34da external/gpl3/gcc.old/dist/gcc/final.c
--- a/external/gpl3/gcc.old/dist/gcc/final.c Sat Jan 09 01:13:42 2016 +0000
+++ b/external/gpl3/gcc.old/dist/gcc/final.c Sat Jan 09 02:00:14 2016 +0000
@@ -1535,8 +1535,8 @@
/* Perform user-specified mapping of debug filename prefixes. Return
the new name corresponding to FILENAME. */
-const char *
-remap_debug_filename (const char *filename)
+static const char *
+remap_debug_prefix_filename (const char *filename)
{
debug_prefix_map *map;
char *s;
@@ -1555,6 +1555,88 @@
memcpy (s + map->new_len, name, name_len);
return ggc_strdup (s);
}
+
+#include <regex.h>
+
+typedef struct debug_regex_map
+{
+ regex_t re;
+ const char *sub;
+ struct debug_regex_map *next;
+} debug_regex_map;
+
+/* Linked list of such structures. */
+debug_regex_map *debug_regex_maps;
+
+
+/* Record a debug file regex mapping. ARG is the argument to
+ -fdebug-regex-map and must be of the form OLD=NEW. */
+
+void
+add_debug_regex_map (const char *arg)
+{
+ debug_regex_map *map;
+ const char *p;
+ char *old;
+ char buf[1024];
+ regex_t re;
+ int e;
+
+ p = strchr (arg, '=');
+ if (!p)
+ {
+ error ("invalid argument %qs to -fdebug-regex-map", arg);
+ return;
+ }
+
+ old = xstrndup (arg, p - arg);
+ if ((e = regcomp(&re, old, REG_EXTENDED)) != 0)
+ {
+ regerror(e, &re, buf, sizeof(buf));
+ warning (0, "regular expression compilation for %qs in argument to "
+ "-fdebug-regex-map failed: %qs", old, buf);
+ free(old);
+ return;
+ }
+ free(old);
+
+ map = XNEW (debug_regex_map);
+ map->re = re;
+ p++;
+ map->sub = xstrdup (p);
+ map->next = debug_regex_maps;
+ debug_regex_maps = map;
+}
+
+extern ssize_t aregsub(char **, const char *,
+ const regmatch_t *rm, const char *);
+
+/* Perform user-specified mapping of debug filename regular expressions. Return
+ the new name corresponding to FILENAME. */
+
+static const char *
+remap_debug_regex_filename (const char *filename)
+{
+ debug_regex_map *map;
+ char *s;
+ regmatch_t rm[10];
+
+ for (map = debug_regex_maps; map; map = map->next)
+ if (regexec (&map->re, filename, 10, rm, 0) == 0
+ && aregsub (&s, map->sub, rm, filename) >= 0)
+ {
+ const char *name = ggc_strdup(s);
+ free(s);
+ return name;
+ }
+ return filename;
+}
+
+const char *
+remap_debug_filename (const char *filename)
+{
+ return remap_debug_regex_filename (remap_debug_prefix_filename (filename));
+}
/* Return true if DWARF2 debug info can be emitted for DECL. */
diff -r a1b5f50218e2 -r 56f3a0ec34da external/gpl3/gcc.old/dist/gcc/opts-global.c
--- a/external/gpl3/gcc.old/dist/gcc/opts-global.c Sat Jan 09 01:13:42 2016 +0000
+++ b/external/gpl3/gcc.old/dist/gcc/opts-global.c Sat Jan 09 02:00:14 2016 +0000
@@ -384,6 +384,10 @@
add_debug_prefix_map (opt->arg);
break;
+ case OPT_fdebug_regex_map_:
+ add_debug_regex_map (opt->arg);
+ break;
+
case OPT_fdump_:
if (!dump_switch_p (opt->arg))
error ("unrecognized command line option %<-fdump-%s%>", opt->arg);
diff -r a1b5f50218e2 -r 56f3a0ec34da external/gpl3/gcc.old/dist/gcc/opts.c
--- a/external/gpl3/gcc.old/dist/gcc/opts.c Sat Jan 09 01:13:42 2016 +0000
+++ b/external/gpl3/gcc.old/dist/gcc/opts.c Sat Jan 09 02:00:14 2016 +0000
@@ -1489,6 +1489,10 @@
/* Deferred. */
break;
+ case OPT_fdebug_regex_map_:
+ /* Deferred. */
+ break;
+
case OPT_fdiagnostics_show_location_:
diagnostic_prefixing_rule (dc) = (diagnostic_prefixing_rule_t) value;
break;
diff -r a1b5f50218e2 -r 56f3a0ec34da external/gpl3/gcc.old/dist/gcc/regsub.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/external/gpl3/gcc.old/dist/gcc/regsub.c Sat Jan 09 02:00:14 2016 +0000
@@ -0,0 +1,161 @@
+/* $NetBSD: regsub.c,v 1.1 2016/01/09 02:00:14 christos Exp $ */
+
+/*-
+ * Copyright (c) 2015 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: regsub.c,v 1.1 2016/01/09 02:00:14 christos Exp $");
+
+#include <sys/param.h>
+
+#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
+#include <regex.h>
+
+struct str {
+ char *s_ptr;
+ size_t s_max;
+ size_t s_len;
+ int s_fixed;
+};
+
+static int
+addspace(struct str *s, size_t len)
+{
+ void *v;
+
+ if (s->s_max - s->s_len > len)
+ return 0;
+
+ if (s->s_fixed)
+ return -1;
+
+ s->s_max += MAX(len, 64);
+
+ v = realloc(s->s_ptr, s->s_max);
+ if (v == NULL)
+ return -1;
+ s->s_ptr = (char *)v;
+
+ return 0;
+}
+
+static void
+addchar(struct str *s, int c)
+{
+ if (addspace(s, 1) == -1)
+ s->s_len++;
+ else
+ s->s_ptr[s->s_len++] = c;
+ if (c == 0) {
+ --s->s_len;
+ s->s_ptr[s->s_max - 1] = c;
+ }
+}
+
+static void
+addnstr(struct str *s, const char *buf, size_t len)
+{
+ if (addspace(s, len) != -1)
+ memcpy(s->s_ptr + s->s_len, buf, len);
+ s->s_len += len;
+}
+
+static int
+initstr(struct str *s, char *buf, size_t len)
+{
+ s->s_max = len;
+ s->s_ptr = buf == NULL ? (char *)malloc(len) : buf;
+ s->s_fixed = buf != NULL;
+ s->s_len = 0;
+ return s->s_ptr == NULL ? -1 : 0;
+}
+
+static ssize_t
+regsub1(char **buf, size_t len, const char *sub,
+ const regmatch_t *rm, const char *str)
+{
+ ssize_t i;
+ char c;
+ struct str s;
+
+ if (initstr(&s, *buf, len) == -1)
+ return -1;
+
+ while ((c = *sub++) != '\0') {
+
+ switch (c) {
+ case '&':
+ i = 0;
Home |
Main Index |
Thread Index |
Old Index