public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] sim: drop unused gentmap & nltvals.def logic
@ 2021-11-28 18:54 Michael Frysinger
  0 siblings, 0 replies; only message in thread
From: Michael Frysinger @ 2021-11-28 18:54 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1e42d01772d6b3faf74e622e318eada133e3c695

commit 1e42d01772d6b3faf74e622e318eada133e3c695
Author: Mike Frysinger <vapier@gentoo.org>
Date:   Sun Nov 28 00:31:57 2021 -0500

    sim: drop unused gentmap & nltvals.def logic
    
    Now that all ports have switched to target-newlib-* files, there's
    no need for these files & generating things at build time.  So punt
    the logic and make target-newlib-syscall a hard requirement.

Diff:
---
 sim/.gitignore            |   2 -
 sim/common/Make-common.in |  38 +------
 sim/common/gennltvals.py  |  84 ++++++----------
 sim/common/gentmap.c      |  79 ---------------
 sim/common/nltvals.def    | 248 ----------------------------------------------
 sim/mips/Makefile.in      |   2 +-
 6 files changed, 31 insertions(+), 422 deletions(-)

diff --git a/sim/.gitignore b/sim/.gitignore
index 0ba781c2234..bcccc0232a9 100644
--- a/sim/.gitignore
+++ b/sim/.gitignore
@@ -1,7 +1,5 @@
 ChangeLog
 
-/*/gentmap
 /*/run
 /*/hw-config.h
-/*/targ-*
 /*/version.c
diff --git a/sim/common/Make-common.in b/sim/common/Make-common.in
index f834edbec8a..2d4159393ac 100644
--- a/sim/common/Make-common.in
+++ b/sim/common/Make-common.in
@@ -235,18 +235,12 @@ COMMON_OBJS_NAMES = \
 	target-newlib-errno.o \
 	target-newlib-open.o \
 	target-newlib-signal.o \
+	target-newlib-syscall.o \
 	version.o
 COMMON_OBJS = $(COMMON_OBJS_NAMES:%=../common/common_libcommon_a-%)
 
 LIB_OBJS = modules.o syscall.o $(COMMON_OBJS) $(SIM_OBJS)
 
-# TODO: Migrate everyone to target-newlib-syscall.o.
-ifeq ($(NL_TARGET),)
-COMMON_OBJS_NAMES += target-newlib-syscall.o
-else
-LIB_OBJS += targ-map.o
-endif
-
 COMPILE_FOR_BUILD = $(CC_FOR_BUILD) $(BUILD_CFLAGS)
 LINK_FOR_BUILD = $(CC_FOR_BUILD) $(BUILD_CFLAGS) $(LDFLAGS_FOR_BUILD) -o $@
 
@@ -266,29 +260,6 @@ run$(EXEEXT): $(SIM_RUN_OBJS) libsim.a $(LIBDEPS)
 	$(ECHO_CCLD) $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o run$(EXEEXT) \
 	  $(SIM_RUN_OBJS) libsim.a $(EXTRA_LIBS)
 
-# FIXME: Ideally, callback.o and friends live in a library outside of
-# both the gdb and simulator source trees (e.g. devo/remote.  Not
-# devo/libremote because this directory would contain more than just
-# a library).
-
-gentmap.o: Makefile $(srccom)/gentmap.c $(srccom)/nltvals.def
-	$(ECHO_CC) $(COMPILE_FOR_BUILD) -o $@ -c $(srccom)/gentmap.c $(NL_TARGET)
-
-gentmap: gentmap.o
-	$(ECHO_CC) $(LINK_FOR_BUILD) $<
-
-targ-vals.h targ-map.c: stamp-tvals
-stamp-tvals: gentmap
-	$(ECHO_STAMP) targ-vals.h
-	$(SILENCE) ./gentmap -h >tmp-tvals.h
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-tvals.h targ-vals.h
-ifneq ($(NL_TARGET),)
-	$(ECHO_STAMP) targ-tmap.c
-	$(SILENCE) ./gentmap -c >tmp-tmap.c
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-tmap.c targ-map.c
-endif
-	$(SILENCE) touch $@
-
 #
 # Rules for building sim-* components.  Triggered by listing the corresponding
 # .o file in the list of simulator targets.
@@ -413,11 +384,7 @@ all_object_files = $(LIB_OBJS) $(SIM_RUN_OBJS)
 generated_files = \
 	$(SIM_EXTRA_DEPS) \
 	hw-config.h \
-	modules.c \
-	targ-vals.h
-ifneq ($(NL_TARGET),)
-generated_files += targ-map.c
-endif
+	modules.c
 
 # Ensure that generated files are created early.  Use order-only
 # dependencies if available.  They require GNU make 3.80 or newer,
@@ -532,7 +499,6 @@ mostlyclean clean: $(SIM_EXTRA_CLEAN)
 		run$(EXEEXT) libsim.a \
 		hw-config.h stamp-hw \
 		modules.c stamp-modules \
-		gentmap targ-map.c targ-vals.h stamp-tvals \
 		tmp-mloop.hin tmp-mloop.h tmp-mloop.cin tmp-mloop.c
 
 distclean maintainer-clean realclean: clean $(SIM_EXTRA_DISTCLEAN)
diff --git a/sim/common/gennltvals.py b/sim/common/gennltvals.py
index 1e98691cb3d..3f2422c4216 100755
--- a/sim/common/gennltvals.py
+++ b/sim/common/gennltvals.py
@@ -16,9 +16,9 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-"""Helper to generate nltvals.def.
+"""Helper to generate target-newlib-* files.
 
-nltvals.def is a file that describes various newlib/libgloss target values used
+target-newlib-* are files that describe various newlib/libgloss values used
 by the host/target interface.  This needs to be rerun whenever the newlib source
 changes.  Developers manually run it.
 
@@ -99,7 +99,7 @@ def extract_syms(cpp: str, srcdir: Path,
     return ret
 
 
-def gentvals(output_dir: Path, output: TextIO,
+def gentvals(output_dir: Path,
              cpp: str, srctype: str, srcdir: Path,
              headers: Iterable[str],
              pattern: str,
@@ -118,62 +118,37 @@ def gentvals(output_dir: Path, output: TextIO,
 
     syms = extract_syms(cpp, srcdir, headers, pattern, filter)
 
-    # If we have a map file, use it directly.
     target_map = output_dir / f'target-newlib-{srctype}.c'
-    if target_map.exists():
-        old_lines = target_map.read_text().splitlines()
-        start_i = end_i = None
-        for i, line in enumerate(old_lines):
-            if START_MARKER in line:
-                start_i = i
-            if END_MARKER in line:
-                end_i = i
-        assert start_i and end_i
-        new_lines = old_lines[0:start_i + 1]
-        new_lines.extend(
-            f'#ifdef {sym}\n'
-            f'  {{ "{sym}", {sym}, {val} }},\n'
-            f'#endif' for sym, val in sorted(syms.items()))
-        new_lines.extend(old_lines[end_i:])
-        target_map.write_text('\n'.join(new_lines) + '\n')
-        return
-
-    # Fallback to classic nltvals.def.
-    if target is not None:
-        print(f'#ifdef NL_TARGET_{target}', file=output)
-    print(f'#ifdef {srctype}_defs', file=output)
-
-    print('\n'.join(f'/* from {x} */' for x in headers), file=output)
-
-    if target is None:
-        print(f'/* begin {srctype} target macros */', file=output)
-    else:
-        print(f'/* begin {target} {srctype} target macros */', file=output)
-
-    for sym, val in sorted(syms.items()):
-        print(f' {{ "{sym}", {val} }},', file=output)
-
-    print(f'#undef {srctype}_defs', file=output)
-    if target is None:
-        print(f'/* end {srctype} target macros */', file=output)
-    else:
-        print(f'/* end {target} {srctype} target macros */', file=output)
-        print('#endif', file=output)
-    print('#endif', file=output)
+    assert target_map.exists(), f'{target_map}: Missing skeleton'
+    old_lines = target_map.read_text().splitlines()
+    start_i = end_i = None
+    for i, line in enumerate(old_lines):
+        if START_MARKER in line:
+            start_i = i
+        if END_MARKER in line:
+            end_i = i
+    assert start_i and end_i
+    new_lines = old_lines[0:start_i + 1]
+    new_lines.extend(
+        f'#ifdef {sym}\n'
+        f'  {{ "{sym}", {sym}, {val} }},\n'
+        f'#endif' for sym, val in sorted(syms.items()))
+    new_lines.extend(old_lines[end_i:])
+    target_map.write_text('\n'.join(new_lines) + '\n')
 
 
-def gen_common(output_dir: Path, output: TextIO, newlib: Path, cpp: str):
+def gen_common(output_dir: Path, newlib: Path, cpp: str):
     """Generate the common C library constants.
 
     No arch should override these.
     """
-    gentvals(output_dir, output, cpp, 'errno', newlib / 'newlib/libc/include',
+    gentvals(output_dir, cpp, 'errno', newlib / 'newlib/libc/include',
              ('errno.h', 'sys/errno.h'), 'E[A-Z0-9]*')
 
-    gentvals(output_dir, output, cpp, 'signal', newlib / 'newlib/libc/include',
+    gentvals(output_dir, cpp, 'signal', newlib / 'newlib/libc/include',
              ('signal.h', 'sys/signal.h'), r'SIG[A-Z0-9]*', filter=r'SIGSTKSZ')
 
-    gentvals(output_dir, output, cpp, 'open', newlib / 'newlib/libc/include',
+    gentvals(output_dir, cpp, 'open', newlib / 'newlib/libc/include',
              ('fcntl.h', 'sys/fcntl.h', 'sys/_default_fcntl.h'), r'O_[A-Z0-9]*')
 
 
@@ -248,16 +223,15 @@ def gen_target_syscall(output_dir: Path, newlib: Path, cpp: str):
     target_map_h.write_text('\n'.join(new_lines_h) + '\n')
 
 
-def gen_targets(output_dir: Path, output: TextIO, newlib: Path, cpp: str):
+def gen_targets(output_dir: Path, newlib: Path, cpp: str):
     """Generate the target-specific lists."""
     gen_target_syscall(output_dir, newlib, cpp)
 
 
-def gen(output_dir: Path, output: TextIO, newlib: Path, cpp: str):
+def gen(output_dir: Path, newlib: Path, cpp: str):
     """Generate all the things!"""
-    print(FILE_HEADER, file=output)
-    gen_common(output_dir, output, newlib, cpp)
-    gen_targets(output_dir, output, newlib, cpp)
+    gen_common(output_dir, newlib, cpp)
+    gen_targets(output_dir, newlib, cpp)
 
 
 def get_parser() -> argparse.ArgumentParser:
@@ -315,9 +289,7 @@ def main(argv: List[str]) -> int:
     """The main entry point for scripts."""
     opts = parse_args(argv)
 
-    output = (opts.output / 'nltvals.def').open('w', encoding='utf-8')
-
-    gen(opts.output, output, opts.newlib, opts.cpp)
+    gen(opts.output, opts.newlib, opts.cpp)
     return 0
 
 
diff --git a/sim/common/gentmap.c b/sim/common/gentmap.c
deleted file mode 100644
index 4a55c296694..00000000000
--- a/sim/common/gentmap.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/* Generate targ-vals.h and targ-map.c.  */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-struct tdefs {
-  char *symbol;
-  int value;
-};
-
-static struct tdefs sys_tdefs[] = {
-#define sys_defs
-#include "nltvals.def"
-#undef sys_defs
-  { 0, 0 }
-};
-
-static void
-gen_targ_vals_h (void)
-{
-  struct tdefs *t;
-
-  printf ("/* Target header values needed by the simulator and gdb.  */\n");
-  printf ("/* This file is machine generated by gentmap.c.  */\n\n");
-
-  printf ("#ifndef TARG_VALS_H\n");
-  printf ("#define TARG_VALS_H\n\n");
-
-  printf ("/* syscall values */\n");
-  for (t = &sys_tdefs[0]; t->symbol; ++t)
-    printf ("#define TARGET_%s %d\n", t->symbol, t->value);
-  printf ("\n");
-
-  printf ("#endif /* TARG_VALS_H */\n");
-}
-
-static void
-gen_targ_map_c (void)
-{
-  struct tdefs *t;
-
-  printf ("/* Target value mapping utilities needed by the simulator and gdb.  */\n");
-  printf ("/* This file is machine generated by gentmap.c.  */\n\n");
-
-  printf ("#include \"defs.h\"\n");
-  printf ("#include \"ansidecl.h\"\n");
-  printf ("#include \"sim/callback.h\"\n");
-  printf ("#include \"targ-vals.h\"\n");
-  printf ("\n");
-
-  printf ("/* syscall mapping table */\n");
-  printf ("CB_TARGET_DEFS_MAP cb_init_syscall_map[] = {\n");
-  for (t = &sys_tdefs[0]; t->symbol; ++t)
-    {
-      printf ("#ifdef CB_%s\n", t->symbol);
-      /* Skip the "SYS_" prefix for the name.  */
-      printf ("  { \"%s\", CB_%s, TARGET_%s },\n", t->symbol + 4, t->symbol, t->symbol);
-      printf ("#endif\n");
-    }
-  printf ("  { 0, -1, -1 }\n");
-  printf ("};\n\n");
-}
-
-int
-main (int argc, char *argv[])
-{
-  if (argc != 2)
-    abort ();
-
-  if (strcmp (argv[1], "-h") == 0)
-    gen_targ_vals_h ();
-  else if (strcmp (argv[1], "-c") == 0)
-    gen_targ_map_c ();
-  else
-    abort ();
-
-  exit (0);
-}
diff --git a/sim/common/nltvals.def b/sim/common/nltvals.def
deleted file mode 100644
index 2425b70e490..00000000000
--- a/sim/common/nltvals.def
+++ /dev/null
@@ -1,248 +0,0 @@
-/* Newlib/libgloss macro values needed by remote target support.  */
-/* This file is machine generated by gennltvals.py.  */
-#ifdef NL_TARGET_cr16
-#ifdef sys_defs
-/* from syscall.h */
-/* begin cr16 sys target macros */
- { "SYS_ARG", 24 },
- { "SYS_chdir", 12 },
- { "SYS_chmod", 15 },
- { "SYS_chown", 16 },
- { "SYS_close", 0x402 },
- { "SYS_create", 8 },
- { "SYS_execv", 11 },
- { "SYS_execve", 59 },
- { "SYS_exit", 0x410 },
- { "SYS_fork", 2 },
- { "SYS_fstat", 22 },
- { "SYS_getpid", 20 },
- { "SYS_isatty", 21 },
- { "SYS_kill", 60 },
- { "SYS_link", 9 },
- { "SYS_lseek", 0x405 },
- { "SYS_mknod", 14 },
- { "SYS_open", 0x401 },
- { "SYS_pipe", 42 },
- { "SYS_read", 0x403 },
- { "SYS_rename", 0x406 },
- { "SYS_stat", 38 },
- { "SYS_time", 0x300 },
- { "SYS_unlink", 0x407 },
- { "SYS_utime", 201 },
- { "SYS_wait", 202 },
- { "SYS_wait4", 7 },
- { "SYS_write", 0x404 },
-#undef sys_defs
-/* end cr16 sys target macros */
-#endif
-#endif
-#ifdef NL_TARGET_d10v
-#ifdef sys_defs
-/* from syscall.h */
-/* begin d10v sys target macros */
- { "SYS_ARG", 24 },
- { "SYS_chdir", 12 },
- { "SYS_chmod", 15 },
- { "SYS_chown", 16 },
- { "SYS_close", 6 },
- { "SYS_creat", 8 },
- { "SYS_execv", 11 },
- { "SYS_execve", 59 },
- { "SYS_exit", 1 },
- { "SYS_fork", 2 },
- { "SYS_fstat", 22 },
- { "SYS_getpid", 20 },
- { "SYS_isatty", 21 },
- { "SYS_kill", 60 },
- { "SYS_link", 9 },
- { "SYS_lseek", 19 },
- { "SYS_mknod", 14 },
- { "SYS_open", 5 },
- { "SYS_pipe", 42 },
- { "SYS_read", 3 },
- { "SYS_stat", 38 },
- { "SYS_time", 23 },
- { "SYS_unlink", 10 },
- { "SYS_utime", 201 },
- { "SYS_wait", 202 },
- { "SYS_wait4", 7 },
- { "SYS_write", 4 },
-#undef sys_defs
-/* end d10v sys target macros */
-#endif
-#endif
-#ifdef NL_TARGET_mcore
-#ifdef sys_defs
-/* from syscall.h */
-/* begin mcore sys target macros */
- { "SYS_access", 33 },
- { "SYS_close", 6 },
- { "SYS_creat", 8 },
- { "SYS_link", 9 },
- { "SYS_lseek", 19 },
- { "SYS_open", 5 },
- { "SYS_read", 3 },
- { "SYS_time", 13 },
- { "SYS_times", 43 },
- { "SYS_unlink", 10 },
- { "SYS_write", 4 },
-#undef sys_defs
-/* end mcore sys target macros */
-#endif
-#endif
-#ifdef NL_TARGET_riscv
-#ifdef sys_defs
-/* from syscall.h */
-/* begin riscv sys target macros */
- { "SYS_access", 1033 },
- { "SYS_brk", 214 },
- { "SYS_chdir", 49 },
- { "SYS_clock_gettime64", 403 },
- { "SYS_close", 57 },
- { "SYS_dup", 23 },
- { "SYS_exit", 93 },
- { "SYS_exit_group", 94 },
- { "SYS_faccessat", 48 },
- { "SYS_fcntl", 25 },
- { "SYS_fstat", 80 },
- { "SYS_fstatat", 79 },
- { "SYS_getcwd", 17 },
- { "SYS_getdents", 61 },
- { "SYS_getegid", 177 },
- { "SYS_geteuid", 175 },
- { "SYS_getgid", 176 },
- { "SYS_getmainvars", 2011 },
- { "SYS_getpid", 172 },
- { "SYS_gettimeofday", 169 },
- { "SYS_getuid", 174 },
- { "SYS_kill", 129 },
- { "SYS_link", 1025 },
- { "SYS_lseek", 62 },
- { "SYS_lstat", 1039 },
- { "SYS_mkdir", 1030 },
- { "SYS_mmap", 222 },
- { "SYS_mremap", 216 },
- { "SYS_munmap", 215 },
- { "SYS_open", 1024 },
- { "SYS_openat", 56 },
- { "SYS_pread", 67 },
- { "SYS_pwrite", 68 },
- { "SYS_read", 63 },
- { "SYS_rt_sigaction", 134 },
- { "SYS_stat", 1038 },
- { "SYS_time", 1062 },
- { "SYS_times", 153 },
- { "SYS_uname", 160 },
- { "SYS_unlink", 1026 },
- { "SYS_write", 64 },
- { "SYS_writev", 66 },
-#undef sys_defs
-/* end riscv sys target macros */
-#endif
-#endif
-#ifdef NL_TARGET_sh
-#ifdef sys_defs
-/* from syscall.h */
-/* begin sh sys target macros */
- { "SYS_ARG", 24 },
- { "SYS_argc", 172 },
- { "SYS_argn", 174 },
- { "SYS_argnlen", 173 },
- { "SYS_chdir", 12 },
- { "SYS_chmod", 15 },
- { "SYS_chown", 16 },
- { "SYS_close", 6 },
- { "SYS_creat", 8 },
- { "SYS_execv", 11 },
- { "SYS_execve", 59 },
- { "SYS_exit", 1 },
- { "SYS_fork", 2 },
- { "SYS_fstat", 22 },
- { "SYS_ftruncate", 130 },
- { "SYS_getpid", 20 },
- { "SYS_isatty", 21 },
- { "SYS_link", 9 },
- { "SYS_lseek", 19 },
- { "SYS_mknod", 14 },
- { "SYS_open", 5 },
- { "SYS_pipe", 42 },
- { "SYS_read", 3 },
- { "SYS_stat", 38 },
- { "SYS_time", 23 },
- { "SYS_truncate", 129 },
- { "SYS_unlink", 10 },
- { "SYS_utime", 201 },
- { "SYS_wait", 202 },
- { "SYS_wait4", 7 },
- { "SYS_write", 4 },
-#undef sys_defs
-/* end sh sys target macros */
-#endif
-#endif
-#ifdef NL_TARGET_v850
-#ifdef sys_defs
-/* from syscall.h */
-/* begin v850 sys target macros */
- { "SYS_ARG", 24 },
- { "SYS_chdir", 12 },
- { "SYS_chmod", 15 },
- { "SYS_chown", 16 },
- { "SYS_close", 6 },
- { "SYS_creat", 8 },
- { "SYS_execv", 11 },
- { "SYS_execve", 59 },
- { "SYS_exit", 1 },
- { "SYS_fork", 2 },
- { "SYS_fstat", 22 },
- { "SYS_getpid", 20 },
- { "SYS_gettimeofday", 116 },
- { "SYS_isatty", 21 },
- { "SYS_link", 9 },
- { "SYS_lseek", 19 },
- { "SYS_mknod", 14 },
- { "SYS_open", 5 },
- { "SYS_pipe", 42 },
- { "SYS_read", 3 },
- { "SYS_rename", 134 },
- { "SYS_stat", 38 },
- { "SYS_time", 23 },
- { "SYS_times", 43 },
- { "SYS_unlink", 10 },
- { "SYS_utime", 201 },
- { "SYS_wait", 202 },
- { "SYS_wait4", 7 },
- { "SYS_write", 4 },
-#undef sys_defs
-/* end v850 sys target macros */
-#endif
-#endif
-#ifdef sys_defs
-/* from syscall.h */
-/* begin sys target macros */
- { "SYS_argc", 22 },
- { "SYS_argn", 24 },
- { "SYS_argnlen", 23 },
- { "SYS_argv", 13 },
- { "SYS_argvlen", 12 },
- { "SYS_chdir", 14 },
- { "SYS_chmod", 16 },
- { "SYS_close", 3 },
- { "SYS_exit", 1 },
- { "SYS_fstat", 10 },
- { "SYS_getpid", 8 },
- { "SYS_gettimeofday", 19 },
- { "SYS_kill", 9 },
- { "SYS_link", 21 },
- { "SYS_lseek", 6 },
- { "SYS_open", 2 },
- { "SYS_read", 4 },
- { "SYS_reconfig", 25 },
- { "SYS_stat", 15 },
- { "SYS_time", 18 },
- { "SYS_times", 20 },
- { "SYS_unlink", 7 },
- { "SYS_utime", 17 },
- { "SYS_write", 5 },
-#undef sys_defs
-/* end sys target macros */
-#endif
diff --git a/sim/mips/Makefile.in b/sim/mips/Makefile.in
index 8a9241dd680..5c669279ae6 100644
--- a/sim/mips/Makefile.in
+++ b/sim/mips/Makefile.in
@@ -454,7 +454,7 @@ BUILT_SRC_FROM_MULTI = @sim_multi_src@
 SIM_MULTI_IGEN_CONFIGS = @sim_multi_igen_configs@
 
 $(BUILT_SRC_FROM_MULTI): tmp-multi
-tmp-multi: tmp-mach-multi tmp-itable-multi tmp-run-multi targ-vals.h
+tmp-multi: tmp-mach-multi tmp-itable-multi tmp-run-multi
 tmp-mach-multi: $(IGEN_INSN) $(IGEN_DC) $(IGEN) $(IGEN_INCLUDE)
 	for t in $(SIM_MULTI_IGEN_CONFIGS); do \
 	  p=`echo $${t} | sed -e 's/:.*//'` ; \


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-11-28 18:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-28 18:54 [binutils-gdb] sim: drop unused gentmap & nltvals.def logic Michael Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).