Remove libctf/mkerrors.sed
This patch removes libctf/mkerrors.sed, replacing it with a macro in ctf-api.h. This simplifies the build and avoids possible unportable code in the sed script. 2020-10-21 Tom Tromey <tromey@adacore.com> * ctf-api.h (_CTF_ERRORS): New macro. libctf/ChangeLog 2020-10-21 Tom Tromey <tromey@adacore.com> * mkerrors.sed: Remove. * ctf-error.c (_CTF_FIRST): New define. (_CTF_ITEM): Define this, not _CTF_STR. (_ctf_errlist, _ctf_erridx): Use _CTF_ERRORS. (ERRSTRFIELD): Rewrite. (ERRSTRFIELD1): Remove. * Makefile.in: Rebuild. * Makefile.am (BUILT_SOURCES): Remove. (ctf-error.h): Remove.
This commit is contained in:
parent
ffd73a8b9e
commit
0d01fbe64f
@ -1,3 +1,7 @@
|
||||
2020-10-21 Tom Tromey <tromey@adacore.com>
|
||||
|
||||
* ctf-api.h (_CTF_ERRORS): New macro.
|
||||
|
||||
2020-10-16 Nelson Chu <nelson.chu@sifive.com>
|
||||
|
||||
* elf/riscv.h: Add R_RISCV_IRELATIVE to 58.
|
||||
|
@ -158,68 +158,79 @@ typedef struct ctf_snapshot_id
|
||||
a straight integral -1 also use ctf_errno(). */
|
||||
#define CTF_ERR ((ctf_id_t) -1L)
|
||||
|
||||
#define ECTF_BASE 1000 /* Base value for libctf errnos. */
|
||||
/* This macro holds information about all the available ctf errors.
|
||||
It is used to form both an enum holding all the error constants,
|
||||
and also the error strings themselves. To use, define _CTF_FIRST
|
||||
and _CTF_ITEM to expand as you like, then mention the macro name.
|
||||
See the enum after this for an example. */
|
||||
#define _CTF_ERRORS \
|
||||
_CTF_FIRST (ECTF_FMT, "File is not in CTF or ELF format.") \
|
||||
_CTF_ITEM (ECTF_BFDERR, "BFD error.") \
|
||||
_CTF_ITEM (ECTF_CTFVERS, "CTF dict version is too new for libctf.") \
|
||||
_CTF_ITEM (ECTF_BFD_AMBIGUOUS, "Ambiguous BFD target.") \
|
||||
_CTF_ITEM (ECTF_SYMTAB, "Symbol table uses invalid entry size.") \
|
||||
_CTF_ITEM (ECTF_SYMBAD, "Symbol table data buffer is not valid.") \
|
||||
_CTF_ITEM (ECTF_STRBAD, "String table data buffer is not valid.") \
|
||||
_CTF_ITEM (ECTF_CORRUPT, "File data structure corruption detected.") \
|
||||
_CTF_ITEM (ECTF_NOCTFDATA, "File does not contain CTF data.") \
|
||||
_CTF_ITEM (ECTF_NOCTFBUF, "Buffer does not contain CTF data.") \
|
||||
_CTF_ITEM (ECTF_NOSYMTAB, "Symbol table information is not available.") \
|
||||
_CTF_ITEM (ECTF_NOPARENT, "The parent CTF dictionary is unavailable.") \
|
||||
_CTF_ITEM (ECTF_DMODEL, "Data model mismatch.") \
|
||||
_CTF_ITEM (ECTF_LINKADDEDLATE, "File added to link too late.") \
|
||||
_CTF_ITEM (ECTF_ZALLOC, "Failed to allocate (de)compression buffer.") \
|
||||
_CTF_ITEM (ECTF_DECOMPRESS, "Failed to decompress CTF data.") \
|
||||
_CTF_ITEM (ECTF_STRTAB, "External string table is not available.") \
|
||||
_CTF_ITEM (ECTF_BADNAME, "String name offset is corrupt.") \
|
||||
_CTF_ITEM (ECTF_BADID, "Invalid type identifier.") \
|
||||
_CTF_ITEM (ECTF_NOTSOU, "Type is not a struct or union.") \
|
||||
_CTF_ITEM (ECTF_NOTENUM, "Type is not an enum.") \
|
||||
_CTF_ITEM (ECTF_NOTSUE, "Type is not a struct, union, or enum.") \
|
||||
_CTF_ITEM (ECTF_NOTINTFP, "Type is not an integer, float, or enum.") \
|
||||
_CTF_ITEM (ECTF_NOTARRAY, "Type is not an array.") \
|
||||
_CTF_ITEM (ECTF_NOTREF, "Type does not reference another type.") \
|
||||
_CTF_ITEM (ECTF_NAMELEN, "Buffer is too small to hold type name.") \
|
||||
_CTF_ITEM (ECTF_NOTYPE, "No type found corresponding to name.") \
|
||||
_CTF_ITEM (ECTF_SYNTAX, "Syntax error in type name.") \
|
||||
_CTF_ITEM (ECTF_NOTFUNC, "Symbol table entry or type is not a function.") \
|
||||
_CTF_ITEM (ECTF_NOFUNCDAT, "No function information available for function.") \
|
||||
_CTF_ITEM (ECTF_NOTDATA, "Symbol table entry does not refer to a data object.") \
|
||||
_CTF_ITEM (ECTF_NOTYPEDAT, "No type information available for symbol.") \
|
||||
_CTF_ITEM (ECTF_NOLABEL, "No label found corresponding to name.") \
|
||||
_CTF_ITEM (ECTF_NOLABELDATA, "File does not contain any labels.") \
|
||||
_CTF_ITEM (ECTF_NOTSUP, "Feature not supported.") \
|
||||
_CTF_ITEM (ECTF_NOENUMNAM, "Enum element name not found.") \
|
||||
_CTF_ITEM (ECTF_NOMEMBNAM, "Member name not found.") \
|
||||
_CTF_ITEM (ECTF_RDONLY, "CTF container is read-only.") \
|
||||
_CTF_ITEM (ECTF_DTFULL, "CTF type is full (no more members allowed).") \
|
||||
_CTF_ITEM (ECTF_FULL, "CTF container is full.") \
|
||||
_CTF_ITEM (ECTF_DUPLICATE, "Duplicate member or variable name.") \
|
||||
_CTF_ITEM (ECTF_CONFLICT, "Conflicting type is already defined.") \
|
||||
_CTF_ITEM (ECTF_OVERROLLBACK, "Attempt to roll back past a ctf_update.") \
|
||||
_CTF_ITEM (ECTF_COMPRESS, "Failed to compress CTF data.") \
|
||||
_CTF_ITEM (ECTF_ARCREATE, "Error creating CTF archive.") \
|
||||
_CTF_ITEM (ECTF_ARNNAME, "Name not found in CTF archive.") \
|
||||
_CTF_ITEM (ECTF_SLICEOVERFLOW, "Overflow of type bitness or offset in slice.") \
|
||||
_CTF_ITEM (ECTF_DUMPSECTUNKNOWN, "Unknown section number in dump.") \
|
||||
_CTF_ITEM (ECTF_DUMPSECTCHANGED, "Section changed in middle of dump.") \
|
||||
_CTF_ITEM (ECTF_NOTYET, "Feature not yet implemented.") \
|
||||
_CTF_ITEM (ECTF_INTERNAL, "Internal error: assertion failure.") \
|
||||
_CTF_ITEM (ECTF_NONREPRESENTABLE, "Type not representable in CTF.") \
|
||||
_CTF_ITEM (ECTF_NEXT_END, "End of iteration.") \
|
||||
_CTF_ITEM (ECTF_NEXT_WRONGFUN, "Wrong iteration function called.") \
|
||||
_CTF_ITEM (ECTF_NEXT_WRONGFP, "Iteration entity changed in mid-iterate.") \
|
||||
_CTF_ITEM (ECTF_FLAGS, "CTF header contains flags unknown to libctf.") \
|
||||
_CTF_ITEM (ECTF_NEEDSBFD, "This feature needs a libctf with BFD support.")
|
||||
|
||||
#define ECTF_BASE 1000 /* Base value for libctf errnos. */
|
||||
|
||||
enum
|
||||
{
|
||||
ECTF_FMT = ECTF_BASE, /* File is not in CTF or ELF format. */
|
||||
ECTF_BFDERR, /* BFD error. */
|
||||
ECTF_CTFVERS, /* CTF dict version is too new for libctf. */
|
||||
ECTF_BFD_AMBIGUOUS, /* Ambiguous BFD target. */
|
||||
ECTF_SYMTAB, /* Symbol table uses invalid entry size. */
|
||||
ECTF_SYMBAD, /* Symbol table data buffer is not valid. */
|
||||
ECTF_STRBAD, /* String table data buffer is not valid. */
|
||||
ECTF_CORRUPT, /* File data structure corruption detected. */
|
||||
ECTF_NOCTFDATA, /* File does not contain CTF data. */
|
||||
ECTF_NOCTFBUF, /* Buffer does not contain CTF data. */
|
||||
ECTF_NOSYMTAB, /* Symbol table information is not available. */
|
||||
ECTF_NOPARENT, /* The parent CTF dictionary is unavailable. */
|
||||
ECTF_DMODEL, /* Data model mismatch. */
|
||||
ECTF_LINKADDEDLATE, /* File added to link too late. */
|
||||
ECTF_ZALLOC, /* Failed to allocate (de)compression buffer. */
|
||||
ECTF_DECOMPRESS, /* Failed to decompress CTF data. */
|
||||
ECTF_STRTAB, /* External string table is not available. */
|
||||
ECTF_BADNAME, /* String name offset is corrupt. */
|
||||
ECTF_BADID, /* Invalid type identifier. */
|
||||
ECTF_NOTSOU, /* Type is not a struct or union. */
|
||||
ECTF_NOTENUM, /* Type is not an enum. */
|
||||
ECTF_NOTSUE, /* Type is not a struct, union, or enum. */
|
||||
ECTF_NOTINTFP, /* Type is not an integer, float, or enum. */
|
||||
ECTF_NOTARRAY, /* Type is not an array. */
|
||||
ECTF_NOTREF, /* Type does not reference another type. */
|
||||
ECTF_NAMELEN, /* Buffer is too small to hold type name. */
|
||||
ECTF_NOTYPE, /* No type found corresponding to name. */
|
||||
ECTF_SYNTAX, /* Syntax error in type name. */
|
||||
ECTF_NOTFUNC, /* Symbol table entry or type is not a function. */
|
||||
ECTF_NOFUNCDAT, /* No function information available for function. */
|
||||
ECTF_NOTDATA, /* Symbol table entry does not refer to a data object. */
|
||||
ECTF_NOTYPEDAT, /* No type information available for symbol. */
|
||||
ECTF_NOLABEL, /* No label found corresponding to name. */
|
||||
ECTF_NOLABELDATA, /* File does not contain any labels. */
|
||||
ECTF_NOTSUP, /* Feature not supported. */
|
||||
ECTF_NOENUMNAM, /* Enum element name not found. */
|
||||
ECTF_NOMEMBNAM, /* Member name not found. */
|
||||
ECTF_RDONLY, /* CTF container is read-only. */
|
||||
ECTF_DTFULL, /* CTF type is full (no more members allowed). */
|
||||
ECTF_FULL, /* CTF container is full. */
|
||||
ECTF_DUPLICATE, /* Duplicate member or variable name. */
|
||||
ECTF_CONFLICT, /* Conflicting type is already defined. */
|
||||
ECTF_OVERROLLBACK, /* Attempt to roll back past a ctf_update. */
|
||||
ECTF_COMPRESS, /* Failed to compress CTF data. */
|
||||
ECTF_ARCREATE, /* Error creating CTF archive. */
|
||||
ECTF_ARNNAME, /* Name not found in CTF archive. */
|
||||
ECTF_SLICEOVERFLOW, /* Overflow of type bitness or offset in slice. */
|
||||
ECTF_DUMPSECTUNKNOWN, /* Unknown section number in dump. */
|
||||
ECTF_DUMPSECTCHANGED, /* Section changed in middle of dump. */
|
||||
ECTF_NOTYET, /* Feature not yet implemented. */
|
||||
ECTF_INTERNAL, /* Internal error: assertion failure. */
|
||||
ECTF_NONREPRESENTABLE, /* Type not representable in CTF. */
|
||||
ECTF_NEXT_END, /* End of iteration. */
|
||||
ECTF_NEXT_WRONGFUN, /* Wrong iteration function called. */
|
||||
ECTF_NEXT_WRONGFP, /* Iteration entity changed in mid-iterate. */
|
||||
ECTF_FLAGS, /* CTF header contains flags unknown to libctf. */
|
||||
ECTF_NEEDSBFD /* This feature needs a libctf with BFD support. */
|
||||
#define _CTF_FIRST(NAME, STR) NAME = ECTF_BASE
|
||||
#define _CTF_ITEM(NAME, STR) , NAME
|
||||
_CTF_ERRORS
|
||||
#undef _CTF_ITEM
|
||||
#undef _CTF_FIRST
|
||||
};
|
||||
|
||||
#define ECTF_NERR (ECTF_NEEDSBFD - ECTF_BASE + 1) /* Count of CTF errors. */
|
||||
|
@ -1,3 +1,15 @@
|
||||
2020-10-21 Tom Tromey <tromey@adacore.com>
|
||||
|
||||
* mkerrors.sed: Remove.
|
||||
* ctf-error.c (_CTF_FIRST): New define.
|
||||
(_CTF_ITEM): Define this, not _CTF_STR.
|
||||
(_ctf_errlist, _ctf_erridx): Use _CTF_ERRORS.
|
||||
(ERRSTRFIELD): Rewrite.
|
||||
(ERRSTRFIELD1): Remove.
|
||||
* Makefile.in: Rebuild.
|
||||
* Makefile.am (BUILT_SOURCES): Remove.
|
||||
(ctf-error.h): Remove.
|
||||
|
||||
2020-08-27 Nick Alcock <nick.alcock@oracle.com>
|
||||
|
||||
* ctf-subr.c (open_errors): New list.
|
||||
|
@ -55,8 +55,3 @@ libctf_la_CPPFLAGS = $(AM_CPPFLAGS) -DNOBFD=0
|
||||
libctf_la_DEPENDENCIES = @BFD_DEPENDENCIES@
|
||||
libctf_la_LDFLAGS = $(libctf_nobfd_la_LDFLAGS)
|
||||
libctf_la_SOURCES = $(libctf_nobfd_la_SOURCES) ctf-open-bfd.c
|
||||
|
||||
BUILT_SOURCES = ctf-error.h
|
||||
|
||||
ctf-error.h: $(srcdir)/mkerrors.sed $(srcdir)/../include/ctf-api.h
|
||||
sed -nf $(srcdir)/mkerrors.sed < $(srcdir)/../include/ctf-api.h > $@
|
||||
|
@ -465,8 +465,7 @@ libctf_la_CPPFLAGS = $(AM_CPPFLAGS) -DNOBFD=0
|
||||
libctf_la_DEPENDENCIES = @BFD_DEPENDENCIES@
|
||||
libctf_la_LDFLAGS = $(libctf_nobfd_la_LDFLAGS)
|
||||
libctf_la_SOURCES = $(libctf_nobfd_la_SOURCES) ctf-open-bfd.c
|
||||
BUILT_SOURCES = ctf-error.h
|
||||
all: $(BUILT_SOURCES) config.h
|
||||
all: config.h
|
||||
$(MAKE) $(AM_MAKEFLAGS) all-am
|
||||
|
||||
.SUFFIXES:
|
||||
@ -1133,15 +1132,13 @@ distcleancheck: distclean
|
||||
$(distcleancheck_listfiles) ; \
|
||||
exit 1; } >&2
|
||||
check-am: all-am
|
||||
check: $(BUILT_SOURCES)
|
||||
$(MAKE) $(AM_MAKEFLAGS) check-am
|
||||
check: check-am
|
||||
all-am: Makefile $(LTLIBRARIES) $(HEADERS) config.h
|
||||
installdirs:
|
||||
for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)"; do \
|
||||
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
|
||||
done
|
||||
install: $(BUILT_SOURCES)
|
||||
$(MAKE) $(AM_MAKEFLAGS) install-am
|
||||
install: install-am
|
||||
install-exec: install-exec-am
|
||||
install-data: install-data-am
|
||||
uninstall: uninstall-am
|
||||
@ -1171,7 +1168,6 @@ distclean-generic:
|
||||
maintainer-clean-generic:
|
||||
@echo "This command is intended for maintainers to use"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
-test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
|
||||
clean: clean-am
|
||||
|
||||
clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
|
||||
@ -1246,7 +1242,7 @@ ps-am:
|
||||
|
||||
uninstall-am: uninstall-includeHEADERS uninstall-libLTLIBRARIES
|
||||
|
||||
.MAKE: all check install install-am install-strip
|
||||
.MAKE: all install-am install-strip
|
||||
|
||||
.PHONY: CTAGS GTAGS TAGS all all-am am--refresh check check-am clean \
|
||||
clean-cscope clean-generic clean-libLTLIBRARIES clean-libtool \
|
||||
@ -1270,9 +1266,6 @@ uninstall-am: uninstall-includeHEADERS uninstall-libLTLIBRARIES
|
||||
.PRECIOUS: Makefile
|
||||
|
||||
|
||||
ctf-error.h: $(srcdir)/mkerrors.sed $(srcdir)/../include/ctf-api.h
|
||||
sed -nf $(srcdir)/mkerrors.sed < $(srcdir)/../include/ctf-api.h > $@
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
||||
|
@ -24,10 +24,13 @@
|
||||
/* This construct is due to Bruno Haible: much thanks. */
|
||||
|
||||
/* Give each structure member a unique name. The name does not matter, so we
|
||||
use the line number in ctf-error.h to uniquify them. */
|
||||
use the enum constant to uniquify them. */
|
||||
|
||||
#define ERRSTRFIELD(line) ERRSTRFIELD1 (line)
|
||||
#define ERRSTRFIELD1(line) ctf_errstr##line
|
||||
#define ERRSTRFIELD(N) ctf_errstr##N
|
||||
|
||||
/* In this file, we want to treat the first item of the ctf error
|
||||
macro like subsequent items. */
|
||||
#define _CTF_FIRST(NAME, VALUE) _CTF_ITEM(NAME, VALUE)
|
||||
|
||||
/* The error message strings, each in a unique structure member precisely big
|
||||
enough for that error, plus a str member to access them all as a string
|
||||
@ -37,17 +40,17 @@ static const union _ctf_errlist_t
|
||||
{
|
||||
__extension__ struct
|
||||
{
|
||||
#define _CTF_STR(n, s) char ERRSTRFIELD (__LINE__) [sizeof (s)];
|
||||
#include "ctf-error.h"
|
||||
#undef _CTF_STR
|
||||
#define _CTF_ITEM(n, s) char ERRSTRFIELD (n) [sizeof (s)];
|
||||
_CTF_ERRORS
|
||||
#undef _CTF_ITEM
|
||||
};
|
||||
char str[1];
|
||||
} _ctf_errlist =
|
||||
{
|
||||
{
|
||||
#define _CTF_STR(n, s) N_(s),
|
||||
#include "ctf-error.h"
|
||||
#undef _CTF_STR
|
||||
#define _CTF_ITEM(n, s) N_(s),
|
||||
_CTF_ERRORS
|
||||
#undef _CTF_ITEM
|
||||
}
|
||||
};
|
||||
|
||||
@ -55,9 +58,9 @@ static const union _ctf_errlist_t
|
||||
|
||||
static const unsigned int _ctf_erridx[] =
|
||||
{
|
||||
#define _CTF_STR(n, s) [n - ECTF_BASE] = offsetof (union _ctf_errlist_t, ERRSTRFIELD (__LINE__)),
|
||||
#include "ctf-error.h"
|
||||
#undef _CTF_STR
|
||||
#define _CTF_ITEM(n, s) [n - ECTF_BASE] = offsetof (union _ctf_errlist_t, ERRSTRFIELD (n)),
|
||||
_CTF_ERRORS
|
||||
#undef _CTF_ITEM
|
||||
};
|
||||
|
||||
const char *
|
||||
|
@ -1,28 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2020 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (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
|
||||
# along with this program; see the file COPYING. If not see
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
# Only process lines in the error-define block
|
||||
/= ECTF_BASE/,/ECTF_NERR/ {
|
||||
# Do not process non-errors (braces, ECTF_NERR, etc).
|
||||
/^ *ECTF_/!n;
|
||||
# Strip out the base initializer.
|
||||
s, = ECTF_BASE,,;
|
||||
# Transform errors into _STR(...).
|
||||
s@^ *\(ECTF_[^[:blank:],]*\),\{0,1\}[[:blank:]]*/\* \(.*\). \*/$@_CTF_STR (\1, "\2")@;
|
||||
p;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user