diff options
author | Jan Beulich <jbeulich@novell.com> | 2018-07-19 08:28:29 +0200 |
---|---|---|
committer | Jan Beulich <jbeulich@suse.com> | 2018-07-19 08:28:29 +0200 |
commit | c30be56ebf7989e36f5c7d4a703cb00f7d4ca2ab (patch) | |
tree | 6f5a4a23c2d56878e002fe9b566dc9dc81f06503 /opcodes/i386-gen.c | |
parent | e387da76fc6ee61f6bc30edfa1210be173e96db4 (diff) | |
download | gdb-c30be56ebf7989e36f5c7d4a703cb00f7d4ca2ab.zip gdb-c30be56ebf7989e36f5c7d4a703cb00f7d4ca2ab.tar.gz gdb-c30be56ebf7989e36f5c7d4a703cb00f7d4ca2ab.tar.bz2 |
x86: pre-process opcodes table before parsing
Instead of expanding macro-like constructs in i386-gen, have the C pre-
processor do this for us. Besides being a prerequisite for the next
template folding steps, this also paves the way for removing various
hidden dependencies between #define-s in i386-opc.h and plain literal
numbers used in i386-opc.tbl.
The #undef of None is solely to leave the generated i386-tbl.h entirely
unchanged.
Diffstat (limited to 'opcodes/i386-gen.c')
-rw-r--r-- | opcodes/i386-gen.c | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/opcodes/i386-gen.c b/opcodes/i386-gen.c index 9b5314c..860d318 100644 --- a/opcodes/i386-gen.c +++ b/opcodes/i386-gen.c @@ -1262,14 +1262,10 @@ process_i386_opcodes (FILE *table) htab_t opcode_hash_table; struct opcode_hash_entry **opcode_array; unsigned int opcode_array_size = 1024; - int lineno = 0; + int lineno = 0, marker = 0; filename = "i386-opc.tbl"; - fp = fopen (filename, "r"); - - if (fp == NULL) - fail (_("can't find i386-opc.tbl for reading, errno = %s\n"), - xstrerror (errno)); + fp = stdin; i = 0; opcode_array = (struct opcode_hash_entry **) @@ -1303,11 +1299,32 @@ process_i386_opcodes (FILE *table) switch (p[0]) { case '#': + if (!strcmp("### MARKER ###", buf)) + marker = 1; + else + { + /* Since we ignore all included files (we only care about their + #define-s here), we don't need to monitor filenames. The final + line number directive is going to refer to the main source file + again. */ + char *end; + unsigned long ln; + + p = remove_leading_whitespaces (p + 1); + if (!strncmp(p, "line", 4)) + p += 4; + ln = strtoul (p, &end, 10); + if (ln > 1 && ln < INT_MAX + && *remove_leading_whitespaces (end) == '"') + lineno = ln - 1; + } /* Ignore comments. */ case '\0': continue; break; default: + if (!marker) + continue; break; } |