Automatic date update in version.in
[deliverable/binutils-gdb.git] / include / ctf-api.h
index f0c00c01a89cf08d72dd94c18172d4b368af72ea..fa8f2cd5b684b7238b65c9a1cf2b9ed289347cfd 100644 (file)
@@ -1,5 +1,5 @@
 /* Public API to libctf.
-   Copyright (C) 2019-2020 Free Software Foundation, Inc.
+   Copyright (C) 2019-2021 Free Software Foundation, Inc.
 
    This file is part of libctf.
 
@@ -51,10 +51,12 @@ struct bfd;
 
 /* If the debugger needs to provide the CTF library with a set of raw buffers
    for use as the CTF data, symbol table, and string table, it can do so by
-   filling in ctf_sect_t structures and passing them to ctf_bufopen().
+   filling in ctf_sect_t structures and passing them to ctf_bufopen.
 
-   The contents of this structure must always be in native endianness (no
-   byteswapping is performed).  */
+   The contents of this structure must always be in native endianness.  At read
+   time, the symbol table endianness is derived from the BFD target (if BFD is
+   in use): if a BFD target is not in use, please call ctf_symsect_endianness or
+   ctf_arc_symsect_endianness.  */
 
 typedef struct ctf_sect
 {
@@ -67,12 +69,12 @@ typedef struct ctf_sect
 /* A minimal symbol extracted from a linker's internal symbol table
    representation.  The symbol name can be given either via st_name or via a
    strtab offset in st_nameidx, which corresponds to one of the string offsets
-   communicated via the ctf_link_add_strtab callback.  */
+   communicated via the ctf_link_add_strtab callback.   */
 
 typedef struct ctf_link_sym
 {
   /* The st_name and st_nameidx will not be accessed outside the call to
-     ctf_link_shuffle_syms().  If you set st_nameidx to offset zero, make sure
+     ctf_link_shuffle_syms.  If you set st_nameidx to offset zero, make sure
      to set st_nameidx_set as well.  */
 
   const char *st_name;
@@ -92,7 +94,8 @@ typedef struct ctf_link_sym
 /* Share only types that are used by multiple inputs.  */
 #define CTF_LINK_SHARE_DUPLICATED 0x1
 
-/* Do a nondeduplicating link.  */
+/* Do a nondeduplicating link, or otherwise deduplicate "less hard", trading off
+   CTF output size for link time.  */
 #define CTF_LINK_NONDEDUP 0x2
 
 /* Create empty outputs for all registered CU mappings even if no types are
@@ -102,6 +105,15 @@ typedef struct ctf_link_sym
 /* Omit the content of the variables section.  */
 #define CTF_LINK_OMIT_VARIABLES_SECTION 0x8
 
+/* If *unset*, filter out entries corresponding to linker-reported symbols
+   from the variable section, and filter out all entries with no linker-reported
+   symbols from the data object and function info sections: if set, do no
+   filtering and leave all entries in place.  (This is a negative-sense flag
+   because it is rare to want symbols the linker has not reported as present to
+   stick around in the symtypetab sections nonetheless: relocatable links are
+   the only likely case.)  */
+#define CTF_LINK_NO_FILTER_REPORTED_SYMS 0x10
+
 /* Symbolic names for CTF sections.  */
 
 typedef enum ctf_sect_names
@@ -118,7 +130,7 @@ typedef enum ctf_sect_names
   } ctf_sect_names_t;
 
 /* Encoding information for integers, floating-point values, and certain other
-   intrinsics can be obtained by calling ctf_type_encoding(), below.  The flags
+   intrinsics can be obtained by calling ctf_type_encoding, below.  The flags
    field will contain values appropriate for the type defined in <ctf.h>.  */
 
 typedef struct ctf_encoding
@@ -162,8 +174,8 @@ typedef struct ctf_snapshot_id
 #define        CTF_FUNC_VARARG 0x1     /* Function arguments end with varargs.  */
 
 /* Functions that return a ctf_id_t use the following value to indicate failure.
-   ctf_errno() can be used to obtain an error code.  Functions that return
-   a straight integral -1 also use ctf_errno().  */
+   ctf_errno can be used to obtain an error code.  Functions that return
+   a straight integral -1 also use ctf_errno.  */
 #define        CTF_ERR ((ctf_id_t) -1L)
 
 /* This macro holds information about all the available ctf errors.
@@ -228,7 +240,9 @@ typedef struct ctf_snapshot_id
   _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.")
+  _CTF_ITEM (ECTF_NEEDSBFD, "This feature needs a libctf with BFD support.") \
+  _CTF_ITEM (ECTF_INCOMPLETE, "Type is not a complete type.") \
+  _CTF_ITEM (ECTF_NONAME, "Type name must not be empty.")
 
 #define        ECTF_BASE       1000    /* Base value for libctf errnos.  */
 
@@ -241,10 +255,10 @@ _CTF_ERRORS
 #undef _CTF_FIRST
   };
 
-#define ECTF_NERR (ECTF_NEEDSBFD - ECTF_BASE + 1) /* Count of CTF errors.  */
+#define ECTF_NERR (ECTF_NONAME - ECTF_BASE + 1) /* Count of CTF errors.  */
 
 /* 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.  */
+   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
@@ -253,7 +267,7 @@ _CTF_ERRORS
 # define CTF_MODEL_NATIVE CTF_MODEL_ILP32
 #endif
 
-/* Dynamic CTF containers can be created using ctf_create().  The ctf_add_*
+/* 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.  */
@@ -261,6 +275,10 @@ _CTF_ERRORS
 #define        CTF_ADD_NONROOT 0       /* Type only visible in nested scope.  */
 #define        CTF_ADD_ROOT    1       /* Type visible at top-level scope.  */
 
+/* Flags for ctf_member_next.  */
+
+#define CTF_MN_RECURSE 0x1     /* Recurse into unnamed members.  */
+
 /* These typedefs are used to define the signature for callback functions that
    can be used with the iteration and visit functions below.  There is also a
    family of iteration functions that do not require callbacks.  */
@@ -283,9 +301,9 @@ typedef char *ctf_dump_decorate_f (ctf_sect_names_t sect,
 
 typedef struct ctf_dump_state ctf_dump_state_t;
 
-/* Iteration state for the _next() functions, and allocators/copiers/freers for
+/* Iteration state for the _next functions, and allocators/copiers/freers for
    it.  (None of these are needed for the simple case of iterating to the end:
-   the _next() function allocate and free the iterators for you.)  */
+   the _next function allocate and free the iterators for you.)  */
 
 typedef struct ctf_next ctf_next_t;
 extern ctf_next_t *ctf_next_create (void);
@@ -295,7 +313,7 @@ extern ctf_next_t *ctf_next_copy (ctf_next_t *);
 /* Opening.  These mostly return an abstraction over both CTF files and CTF
    archives: so they can be used to open both.  CTF files will appear to be an
    archive with one member named '.ctf'.  The low-level functions
-   ctf_simple_open() and ctf_bufopen() return ctf_dict_t's directly, and cannot
+   ctf_simple_open and ctf_bufopen return ctf_dict_t's directly, and cannot
    be used on CTF archives.  */
 
 extern ctf_archive_t *ctf_bfdopen (struct bfd *, int *);
@@ -307,16 +325,23 @@ extern ctf_archive_t *ctf_open (const char *filename,
                                const char *target, int *errp);
 extern void ctf_close (ctf_archive_t *);
 extern ctf_sect_t ctf_getdatasect (const ctf_dict_t *);
+extern ctf_sect_t ctf_getsymsect (const ctf_dict_t *);
+extern ctf_sect_t ctf_getstrsect (const ctf_dict_t *);
+extern void ctf_symsect_endianness (ctf_dict_t *, int little_endian);
 extern ctf_archive_t *ctf_get_arc (const ctf_dict_t *);
 extern ctf_archive_t *ctf_arc_open (const char *, int *);
 extern ctf_archive_t *ctf_arc_bufopen (const ctf_sect_t *,
                                       const ctf_sect_t *,
                                       const ctf_sect_t *,
                                       int *);
+extern void ctf_arc_symsect_endianness (ctf_archive_t *, int little_endian);
 extern void ctf_arc_close (ctf_archive_t *);
 extern ctf_dict_t *ctf_arc_lookup_symbol (ctf_archive_t *,
                                          unsigned long symidx,
                                          ctf_id_t *, int *errp);
+extern ctf_dict_t *ctf_arc_lookup_symbol_name (ctf_archive_t *,
+                                              const char *name,
+                                              ctf_id_t *, int *errp);
 extern void ctf_arc_flush_caches (ctf_archive_t *);
 extern ctf_dict_t *ctf_dict_open (const ctf_archive_t *,
                                  const char *, int *);
@@ -367,6 +392,7 @@ extern int ctf_func_type_args (ctf_dict_t *, ctf_id_t, uint32_t, ctf_id_t *);
 
 extern ctf_id_t ctf_lookup_by_name (ctf_dict_t *, const char *);
 extern ctf_id_t ctf_lookup_by_symbol (ctf_dict_t *, unsigned long);
+extern ctf_id_t ctf_lookup_by_symbol_name (ctf_dict_t *, const char *);
 extern ctf_id_t ctf_symbol_next (ctf_dict_t *, ctf_next_t **,
                                 const char **name, int functions);
 extern ctf_id_t ctf_lookup_variable (ctf_dict_t *, const char *);
@@ -404,7 +430,8 @@ extern int ctf_label_info (ctf_dict_t *, const char *, ctf_lblinfo_t *);
 extern int ctf_member_count (ctf_dict_t *, ctf_id_t);
 extern int ctf_member_iter (ctf_dict_t *, ctf_id_t, ctf_member_f *, void *);
 extern ssize_t ctf_member_next (ctf_dict_t *, ctf_id_t, ctf_next_t **,
-                               const char **name, ctf_id_t *membtype);
+                               const char **name, ctf_id_t *membtype,
+                               int flags);
 extern int ctf_enum_iter (ctf_dict_t *, ctf_id_t, ctf_enum_f *, void *);
 extern const char *ctf_enum_next (ctf_dict_t *, ctf_id_t, ctf_next_t **,
                                  int *);
@@ -464,6 +491,7 @@ extern ctf_id_t ctf_add_struct_sized (ctf_dict_t *, uint32_t, const char *,
                                      size_t);
 extern ctf_id_t ctf_add_union_sized (ctf_dict_t *, uint32_t, const char *,
                                     size_t);
+extern ctf_id_t ctf_add_unknown (ctf_dict_t *, uint32_t, const char *);
 extern ctf_id_t ctf_add_volatile (ctf_dict_t *, uint32_t, ctf_id_t);
 
 extern int ctf_add_enumerator (ctf_dict_t *, ctf_id_t, const char *, int);
This page took 0.026102 seconds and 4 git commands to generate.