aboutsummaryrefslogtreecommitdiff
path: root/libctf/ctf-impl.h
diff options
context:
space:
mode:
authorNick Alcock <nick.alcock@oracle.com>2019-04-23 21:45:30 +0100
committerNick Alcock <nick.alcock@oracle.com>2019-05-28 17:07:19 +0100
commit94585e7f93c9477bcf2835d8245e967053ce2b41 (patch)
treebe6b9dd49c2463d5a72368ce400f19538f06bc9b /libctf/ctf-impl.h
parent60da9d955964759b1f52690bff587ad32a198507 (diff)
downloadgdb-94585e7f93c9477bcf2835d8245e967053ce2b41.zip
gdb-94585e7f93c9477bcf2835d8245e967053ce2b41.tar.gz
gdb-94585e7f93c9477bcf2835d8245e967053ce2b41.tar.bz2
libctf: low-level list manipulation and helper utilities
These utilities are a bit of a ragbag of small things needed by more than one TU: list manipulation, ELF32->64 translators, routines to look up strings in string tables, dynamically-allocated string appenders, and routines to set the specialized errno values previously committed in <ctf-api.h>. We do still need to dig around in raw ELF symbol tables in places, because libctf allows the caller to pass in the contents of string and symbol sections without telling it where they come from, so we cannot use BFD to get the symbols (BFD reasonably demands the entire file). So extract minimal ELF definitions from glibc into a private header named libctf/elf.h: later, we use those to get symbols. (The start-of- copyright range on elf.h reflects this glibc heritage.) libctf/ * ctf-util.c: New file. * elf.h: Likewise. * ctf-impl.h: Include it, and add declarations.
Diffstat (limited to 'libctf/ctf-impl.h')
-rw-r--r--libctf/ctf-impl.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/libctf/ctf-impl.h b/libctf/ctf-impl.h
index 4356a2a..268b2f3 100644
--- a/libctf/ctf-impl.h
+++ b/libctf/ctf-impl.h
@@ -24,6 +24,13 @@
#include <sys/errno.h>
#include <ctf-api.h>
#include <sys/types.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <limits.h>
+#include <ctype.h>
+#include <elf.h>
#ifdef __cplusplus
extern "C"
@@ -51,6 +58,25 @@ extern "C"
#endif
+typedef struct ctf_list
+{
+ struct ctf_list *l_prev; /* Previous pointer or tail pointer. */
+ struct ctf_list *l_next; /* Next pointer or head pointer. */
+} ctf_list_t;
+
+#define ctf_list_prev(elem) ((void *)(((ctf_list_t *)(elem))->l_prev))
+#define ctf_list_next(elem) ((void *)(((ctf_list_t *)(elem))->l_next))
+
+extern void ctf_list_append (ctf_list_t *, void *);
+extern void ctf_list_prepend (ctf_list_t *, void *);
+extern void ctf_list_delete (ctf_list_t *, void *);
+
+extern const char *ctf_strraw (ctf_file_t *, uint32_t);
+extern const char *ctf_strptr (ctf_file_t *, uint32_t);
+
+extern void *ctf_set_open_errno (int *, int);
+extern long ctf_set_errno (ctf_file_t *, int);
+
_libctf_malloc_
extern void *ctf_data_alloc (size_t);
extern void ctf_data_free (void *, size_t);
@@ -65,10 +91,17 @@ _libctf_malloc_
extern void *ctf_alloc (size_t);
extern void ctf_free (void *);
+_libctf_malloc_
+extern char *ctf_strdup (const char *);
+extern char *ctf_str_append (char *, const char *);
+extern const char *ctf_strerror (int);
+
_libctf_printflike_ (1, 2)
extern void ctf_dprintf (const char *, ...);
extern void libctf_init_debug (void);
+extern Elf64_Sym *ctf_sym_to_elf64 (const Elf32_Sym *src, Elf64_Sym *dst);
+
extern int _libctf_debug; /* debugging messages enabled */
#ifdef __cplusplus