gdb: add target_ops::supports_displaced_step
[deliverable/binutils-gdb.git] / sim / common / gentmap.c
1 /* Generate targ-vals.h and targ-map.c. */
2
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <string.h>
6
7 struct tdefs {
8 char *symbol;
9 int value;
10 };
11
12 static struct tdefs sys_tdefs[] = {
13 #define sys_defs
14 #include "nltvals.def"
15 #undef sys_defs
16 { 0, 0 }
17 };
18
19 static struct tdefs errno_tdefs[] = {
20 #define errno_defs
21 #include "nltvals.def"
22 #undef errno_defs
23 { 0, 0 }
24 };
25
26 static struct tdefs open_tdefs[] = {
27 #define open_defs
28 #include "nltvals.def"
29 #undef open_defs
30 { 0, 0 }
31 };
32
33 static void
34 gen_targ_vals_h (void)
35 {
36 struct tdefs *t;
37
38 printf ("/* Target header values needed by the simulator and gdb. */\n");
39 printf ("/* This file is machine generated by gentmap.c. */\n\n");
40
41 printf ("#ifndef TARG_VALS_H\n");
42 printf ("#define TARG_VALS_H\n\n");
43
44 printf ("/* syscall values */\n");
45 for (t = &sys_tdefs[0]; t->symbol; ++t)
46 printf ("#define TARGET_%s %d\n", t->symbol, t->value);
47 printf ("\n");
48
49 printf ("/* errno values */\n");
50 for (t = &errno_tdefs[0]; t->symbol; ++t)
51 printf ("#define TARGET_%s %d\n", t->symbol, t->value);
52 printf ("\n");
53
54 printf ("/* open flag values */\n");
55 for (t = &open_tdefs[0]; t->symbol; ++t)
56 printf ("#define TARGET_%s 0x%x\n", t->symbol, t->value);
57 printf ("\n");
58
59 printf ("#endif /* TARG_VALS_H */\n");
60 }
61
62 static void
63 gen_targ_map_c (void)
64 {
65 struct tdefs *t;
66
67 printf ("/* Target value mapping utilities needed by the simulator and gdb. */\n");
68 printf ("/* This file is machine generated by gentmap.c. */\n\n");
69
70 printf ("#include \"config.h\"\n");
71 printf ("#include <errno.h>\n");
72 printf ("#include <fcntl.h>\n");
73 printf ("#include \"ansidecl.h\"\n");
74 printf ("#include \"gdb/callback.h\"\n");
75 printf ("#include \"targ-vals.h\"\n");
76 printf ("\n");
77
78 printf ("/* syscall mapping table */\n");
79 printf ("CB_TARGET_DEFS_MAP cb_init_syscall_map[] = {\n");
80 for (t = &sys_tdefs[0]; t->symbol; ++t)
81 {
82 printf ("#ifdef CB_%s\n", t->symbol);
83 /* Skip the "SYS_" prefix for the name. */
84 printf (" { \"%s\", CB_%s, TARGET_%s },\n", t->symbol + 4, t->symbol, t->symbol);
85 printf ("#endif\n");
86 }
87 printf (" { 0, -1, -1 }\n");
88 printf ("};\n\n");
89
90 printf ("/* errno mapping table */\n");
91 printf ("CB_TARGET_DEFS_MAP cb_init_errno_map[] = {\n");
92 for (t = &errno_tdefs[0]; t->symbol; ++t)
93 {
94 printf ("#ifdef %s\n", t->symbol);
95 printf (" { \"%s\", %s, TARGET_%s },\n", t->symbol, t->symbol, t->symbol);
96 printf ("#endif\n");
97 }
98 printf (" { 0, 0, 0 }\n");
99 printf ("};\n\n");
100
101 printf ("/* open flags mapping table */\n");
102 printf ("CB_TARGET_DEFS_MAP cb_init_open_map[] = {\n");
103 for (t = &open_tdefs[0]; t->symbol; ++t)
104 {
105 printf ("#ifdef %s\n", t->symbol);
106 printf (" { \"%s\", %s, TARGET_%s },\n", t->symbol, t->symbol, t->symbol);
107 printf ("#endif\n");
108 }
109 printf (" { 0, -1, -1 }\n");
110 printf ("};\n\n");
111 }
112
113 int
114 main (int argc, char *argv[])
115 {
116 if (argc != 2)
117 abort ();
118
119 if (strcmp (argv[1], "-h") == 0)
120 gen_targ_vals_h ();
121 else if (strcmp (argv[1], "-c") == 0)
122 gen_targ_map_c ();
123 else
124 abort ();
125
126 exit (0);
127 }
This page took 0.032373 seconds and 4 git commands to generate.