public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Nick Alcock <nick.alcock@oracle.com>
To: binutils@sourceware.org
Subject: [PATCH v2 02/19] include: new header ctf-api.h
Date: Fri, 17 May 2019 22:10:00 -0000	[thread overview]
Message-ID: <20190517221002.408822-3-nick.alcock@oracle.com> (raw)
In-Reply-To: <20190517221002.408822-1-nick.alcock@oracle.com>

This non-installed header is the means by which libctf consumers
communicate with libctf.

This header will be extended in subsequent commits.

Changes from v1:
 - Correct erroneous license (GPLv2+ -> v3+) and reset copyright years.
 - Flip a bunch of errors no longer generatable nor used by any callers
   currently in existence to ECTF_UNUSED*, allowing their reuse later.

include/
	* ctf-api.h: New file.
---
 include/ctf-api.h | 130 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 130 insertions(+)
 create mode 100644 include/ctf-api.h

diff --git a/include/ctf-api.h b/include/ctf-api.h
new file mode 100644
index 0000000000..f2f7ce1b43
--- /dev/null
+++ b/include/ctf-api.h
@@ -0,0 +1,130 @@
+/* Public API to libctf.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+
+   This file is part of libctf.
+
+   libctf 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 3, 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/>.  */
+
+/* This header file defines the interfaces available from the CTF debugger
+   library, libctf.  This API can be used by a debugger to operate on data in
+   the Compact ANSI-C Type Format (CTF).  */
+
+#ifndef	_CTF_API_H
+#define	_CTF_API_H
+
+#include <sys/param.h>
+#include <sys/types.h>
+#include <ctf.h>
+
+#ifdef	__cplusplus
+extern "C"
+  {
+#endif
+
+/* Clients can open one or more CTF containers and obtain a pointer to an
+   opaque ctf_file_t.  Types are identified by an opaque ctf_id_t token.
+   They can also open or create read-only archives of CTF containers in a
+   ctf_archive_t.
+
+   These opaque definitions allow libctf to evolve without breaking clients.  */
+
+typedef struct ctf_file ctf_file_t;
+typedef struct ctf_archive ctf_archive_t;
+typedef long ctf_id_t;
+
+/* Functions that return integer status or a ctf_id_t use the following value
+   to indicate failure.  ctf_errno() can be used to obtain an error code.  */
+#define	CTF_ERR	(-1L)
+
+#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 version is more recent than libctf.  */
+   ECTF_UNUSED1,		/* Unused error.  */
+   ECTF_SYMTAB,			/* Symbol table uses invalid entry size.  */
+   ECTF_SYMBAD,			/* Symbol table data buffer invalid.  */
+   ECTF_STRBAD,			/* String table data buffer invalid.  */
+   ECTF_CORRUPT,		/* File data corruption detected.  */
+   ECTF_NOCTFDATA,		/* ELF file does not contain CTF data.  */
+   ECTF_NOCTFBUF,		/* Buffer does not contain CTF data.  */
+   ECTF_NOSYMTAB,		/* Symbol table data is not available.  */
+   ECTF_NOPARENT,		/* Parent CTF container is not available.  */
+   ECTF_DMODEL,			/* Data model mismatch.  */
+   ECTF_UNUSED2,		/* Unused error.  */
+   ECTF_ZALLOC,			/* Failed to allocate (de)compression buffer.  */
+   ECTF_DECOMPRESS,		/* Failed to decompress CTF data.  */
+   ECTF_STRTAB,			/* String table for this string is missing.  */
+   ECTF_BADNAME,		/* String offset is corrupt w.r.t. strtab.  */
+   ECTF_BADID,			/* Invalid type ID number.  */
+   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,		/* Symtab entry does not refer to a function.  */
+   ECTF_NOFUNCDAT,		/* No func info available for function.  */
+   ECTF_NOTDATA,		/* Symtab entry does not refer to a data obj.  */
+   ECTF_NOTYPEDAT,		/* No type info available for object.  */
+   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 definition present.  */
+   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.  */
+  };
+
+/* The CTF data model is inferred to be the caller's data model or the data
+   model of the given object, unless ctf_setmodel() is explicitly called.  */
+#define	CTF_MODEL_ILP32 1	/* Object data model is ILP32.  */
+#define	CTF_MODEL_LP64  2	/* Object data model is LP64.  */
+#ifdef _LP64
+# define CTF_MODEL_NATIVE CTF_MODEL_LP64
+#else
+# define CTF_MODEL_NATIVE CTF_MODEL_ILP32
+#endif
+
+/* Dynamic CTF containers can be created using ctf_create().  The ctf_add_*
+   routines can be used to add new definitions to the dynamic container.
+   New types are labeled as root or non-root to determine whether they are
+   visible at the top-level program scope when subsequently doing a lookup.  */
+
+#define	CTF_ADD_NONROOT	0	/* Type only visible in nested scope.  */
+#define	CTF_ADD_ROOT	1	/* Type visible at top-level scope.  */
+
+
+#ifdef	__cplusplus
+}
+#endif
+
+#endif				/* _CTF_API_H */
-- 
2.21.0.237.gd0cfaa883d

  parent reply	other threads:[~2019-05-17 22:10 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-17 22:10 [PATCH v2 00/19] libctf, and CTF support for objdump and readelf Nick Alcock
2019-05-17 22:10 ` [PATCH v2 03/19] libctf: lowest-level memory allocation and debug-dumping wrappers Nick Alcock
2019-05-17 22:10 ` [PATCH v2 15/19] libctf: mmappable archives Nick Alcock
2019-05-17 22:10 ` [PATCH v2 19/19] binutils: CTF support for objdump and readelf Nick Alcock
2019-05-17 22:10 ` [PATCH v2 06/19] libctf: hashing Nick Alcock
2019-05-17 22:10 ` [PATCH v2 05/19] libctf: error handling Nick Alcock
2019-05-17 22:10 ` [PATCH v2 12/19] libctf: lookups by name and symbol Nick Alcock
2019-05-17 22:10 ` [PATCH v2 07/19] libctf: implementation definitions related to file creation Nick Alcock
2019-05-17 22:10 ` [PATCH v2 01/19] include: new header ctf.h: file format description Nick Alcock
2019-05-17 22:10 ` [PATCH v2 17/19] libctf: debug dumping Nick Alcock
2019-05-17 22:10 ` [PATCH v2 09/19] libctf: opening Nick Alcock
2019-05-17 22:10 ` Nick Alcock [this message]
2019-05-17 22:10 ` [PATCH v2 10/19] libctf: ELF file opening via BFD Nick Alcock
2019-05-17 22:10 ` [PATCH v2 14/19] libctf: library version enforcement Nick Alcock
2019-05-17 22:10 ` [PATCH v2 08/19] libctf: creation functions Nick Alcock
2019-05-29 14:09   ` Szabolcs Nagy
2019-05-29 14:19     ` Nick Alcock
2019-05-17 22:10 ` [PATCH v2 13/19] libctf: type copying Nick Alcock
2019-05-17 22:10 ` [PATCH v2 04/19] libctf: low-level list manipulation and helper utilities Nick Alcock
2019-05-17 22:11 ` [PATCH v2 18/19] libctf: build system Nick Alcock
2019-05-17 22:12 ` [PATCH v2 16/19] libctf: labels Nick Alcock
2019-05-17 22:12 ` [PATCH v2 11/19] libctf: core type lookup Nick Alcock
2019-05-20 19:27 ` [PATCH v2 00/19] libctf, and CTF support for objdump and readelf Joseph Myers
2019-05-20 20:50   ` Nick Alcock
2019-05-28  8:33 ` Nick Clifton
2019-05-28  9:56   ` Nick Alcock
2019-05-28 16:39   ` Jose E. Marchesi
2019-05-28 19:16     ` Christophe Lyon
2019-05-28 21:36       ` Nix
2019-05-29  3:25         ` Alan Modra
2019-05-29  9:14           ` Jose E. Marchesi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190517221002.408822-3-nick.alcock@oracle.com \
    --to=nick.alcock@oracle.com \
    --cc=binutils@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).