2002-11-21 Andrew Cagney <ac131313@redhat.com>
* Makefile.in: Update copyright. IGEN contributed to the FSF.
* filter.c, filter.h, filter_host.c, filter_host.h: Ditto.
* gen-engine.c, gen-engine.h, gen-icache.c, gen-icache.h: Ditto.
* gen-idecode.c, gen-idecode.h, gen-itable.c: Ditto.
* gen-itable.h, gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h, gen.c: Ditto.
* gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 05:09:40 +01:00
|
|
|
/* The IGEN simulator generator for GDB, the GNU Debugger.
|
|
|
|
|
2012-01-04 09:28:28 +01:00
|
|
|
Copyright 2002, 2007-2012 Free Software Foundation, Inc.
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* Makefile.in: Update copyright. IGEN contributed to the FSF.
* filter.c, filter.h, filter_host.c, filter_host.h: Ditto.
* gen-engine.c, gen-engine.h, gen-icache.c, gen-icache.h: Ditto.
* gen-idecode.c, gen-idecode.h, gen-itable.c: Ditto.
* gen-itable.h, gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h, gen.c: Ditto.
* gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 05:09:40 +01:00
|
|
|
|
|
|
|
Contributed by Andrew Cagney.
|
|
|
|
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2007-08-24 16:30:15 +02:00
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* Makefile.in: Update copyright. IGEN contributed to the FSF.
* filter.c, filter.h, filter_host.c, filter_host.h: Ditto.
* gen-engine.c, gen-engine.h, gen-icache.c, gen-icache.h: Ditto.
* gen-idecode.c, gen-idecode.h, gen-itable.c: Ditto.
* gen-itable.h, gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h, gen.c: Ditto.
* gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 05:09:40 +01:00
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2007-08-24 16:30:15 +02:00
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* Read a table, line by line, from a file.
|
|
|
|
|
|
|
|
A table line has several forms:
|
|
|
|
|
|
|
|
Field line:
|
|
|
|
|
|
|
|
<text> { ":" <text> }
|
|
|
|
type == table_colon_entry
|
|
|
|
|
|
|
|
Fields points to a NULL terminated list of pointers.
|
|
|
|
|
|
|
|
Tab indented block:
|
|
|
|
|
|
|
|
<tab> <text> <nl> { <tab> <text> <nl> }
|
|
|
|
type == table_code_entry
|
|
|
|
|
|
|
|
The leading tab at the start of each line is discarded.
|
|
|
|
fields[i] is the i'th line with the <nl> discarded.
|
|
|
|
|
|
|
|
|
|
|
|
Code block:
|
|
|
|
|
|
|
|
"{" <ignore-text> <nl> { <text> <nl> } "}" <ignore-text> <nl>
|
|
|
|
type == table_code_entry
|
|
|
|
|
|
|
|
The leading/trailing {/} lines are discarded.
|
|
|
|
Lines containing two leading spaces have those spaces striped.
|
|
|
|
fields[i] is the i'th line with the <nl> discarded.
|
|
|
|
|
|
|
|
In addition, the table parser reconises and handles internally the
|
|
|
|
following (when not in a code block):
|
|
|
|
|
|
|
|
"#" <line-nr> '"' <file> '"'
|
|
|
|
|
|
|
|
As per CPP/CC, treat following lines as if they were taken from
|
|
|
|
<file> starting at <line-nr>
|
|
|
|
|
|
|
|
No support for CPP's "#if/#else/#endif" style conditions are
|
|
|
|
planned. */
|
|
|
|
|
|
|
|
typedef struct _table table;
|
|
|
|
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 05:20:49 +01:00
|
|
|
typedef enum
|
|
|
|
{
|
1999-04-16 03:35:26 +02:00
|
|
|
table_colon_entry,
|
|
|
|
table_code_entry,
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 05:20:49 +01:00
|
|
|
}
|
|
|
|
table_entry_type;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
|
|
typedef struct _table_entry table_entry;
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 05:20:49 +01:00
|
|
|
struct _table_entry
|
|
|
|
{
|
1999-04-16 03:35:26 +02:00
|
|
|
table *file;
|
|
|
|
line_ref *line;
|
|
|
|
table_entry_type type;
|
|
|
|
int nr_fields;
|
|
|
|
char **field;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* List of directories to search when opening a pushed file. Current
|
|
|
|
directory is always searched first */
|
|
|
|
typedef struct _table_include table_include;
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 05:20:49 +01:00
|
|
|
struct _table_include
|
|
|
|
{
|
1999-04-16 03:35:26 +02:00
|
|
|
char *dir;
|
|
|
|
table_include *next;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* Open/read a table file. Since the file is read once during open
|
|
|
|
(and then closed immediatly) there is no close method. */
|
|
|
|
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 05:20:49 +01:00
|
|
|
extern table *table_open (const char *file_name);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 05:20:49 +01:00
|
|
|
extern table_entry *table_read (table *file);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* Push the the state of the current file and open FILE_NAME. When
|
|
|
|
the end of FILE_NAME is reached, return to the pushed file */
|
|
|
|
|
|
|
|
extern void table_push
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 05:20:49 +01:00
|
|
|
(table *file, line_ref *line, table_include *search, const char *file_name);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* Expand the specified field_nr using the internal expansion table.
|
|
|
|
A field is only expanded when explicitly specified. */
|
|
|
|
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 05:20:49 +01:00
|
|
|
extern void table_expand_field (table_entry *entry, int field_nr);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* Given a code entry, write the code to FILE. Since any
|
|
|
|
leading/trailing braces were striped as part of the read, they are
|
|
|
|
not written. */
|
|
|
|
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 05:20:49 +01:00
|
|
|
extern void table_print_code (lf *file, table_entry *entry);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* Debugging */
|
|
|
|
|
|
|
|
extern void dump_line_ref
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 05:20:49 +01:00
|
|
|
(lf *file, char *prefix, const line_ref *line, char *suffix);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
extern void dump_table_entry
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 05:20:49 +01:00
|
|
|
(lf *file, char *prefix, const table_entry *entry, char *suffix);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Utilities for skipping around text */
|
|
|
|
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 05:20:49 +01:00
|
|
|
extern char *skip_digits (char *chp);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 05:20:49 +01:00
|
|
|
extern char *skip_spaces (char *chp);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 05:20:49 +01:00
|
|
|
extern char *skip_to_separator (char *chp, char *separators);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent.
* filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
* gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
* gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
* gen-model.c, gen-model.h, gen-semantics.c: Ditto.
* gen-semantics.h, gen-support.c, gen-support.h: Ditto.
* gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
* ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
* lf.h, misc.c, misc.h, table.c, table.h: Ditto.
2002-11-22 05:20:49 +01:00
|
|
|
extern char *back_spaces (char *start, char *chp);
|