forked from Imagelibrary/binutils-gdb
libctf: add mechanism to prohibit most operations without a strtab
We are about to add machinery that deduplicates a child dict's strtab
against its parent. Obviously if you open such a dict but do not import its
parent, all strtab lookups must fail: so add an LCTF_NO_STR flag that is set
in that window and make most operations fail if it's not set. (Two more
that will be set in future commits are serialization and string lookup
itself.)
Notably, not all symbol lookup is impossible in this window: you can still
look up by symbol index, as long as this dict is not using an indexed
strtypetab (which obviously requires string lookups to get the symbol name).
include/
* ctf-api.h (_CTF_ERRORS) [ECTF_HASPARENT]: New.
[ECTF_WRONGPARENT]: Likewise.
(ECTF_NERR): Update.
Update comments to note the new limitations on ctf_import et al.
libctf/
* ctf-impl.h (LCTF_NO_STR): New.
* ctf-create.c (ctf_rollback): Error out when LCTF_NO_STR.
(ctf_add_generic): Likewise.
(ctf_add_struct_sized): Likewise.
(ctf_add_union_sized): Likewise.
(ctf_add_enum): Likewise.
(ctf_add_forward): Likewise.
(ctf_add_unknown): Likewise.
(ctf_add_enumerator): Likewise.
(ctf_add_member_offset): Likewise.
(ctf_add_variable): Likewise.
(ctf_add_funcobjt_sym_forced): Likewise.
(ctf_add_type): Likewise (on either dict).
* ctf-dump.c (ctf_dump): Likewise.
* ctf-lookup.c (ctf_lookup_by_name): Likewise.
(ctf_lookup_variable): Likewise. Likewise.
(ctf_lookup_enumerator): Likewise.
(ctf_lookup_enumerator_next): Likewise.
(ctf_symbol_next): Likewise.
(ctf_lookup_by_sym_or_name): Likewise, if doing indexed lookups.
* ctf-types.c (ctf_member_next): Likewise.
(ctf_enum_next): Likewise.
(ctf_type_aname): Likewise.
(ctf_type_name_raw): Likewise.
(ctf_type_compat): Likewise, for either dict.
(ctf_member_info): Likewise.
(ctf_enum_name): Likewise.
(ctf_enum_value): Likewise.
(ctf_type_rvisit): Likewise.
(ctf_variable_next): Note that we don't need to test LCTF_NO_STR.
This commit is contained in:
@@ -246,7 +246,9 @@ typedef struct ctf_snapshot_id
|
||||
_CTF_ITEM (ECTF_NONAME, "Type name must not be empty.") \
|
||||
_CTF_ITEM (ECTF_BADFLAG, "Invalid CTF dict flag specified.") \
|
||||
_CTF_ITEM (ECTF_CTFVERS_NO_SERIALIZE, "CTFv1 dicts are too old to serialize.") \
|
||||
_CTF_ITEM (ECTF_UNSTABLE, "Attempt to write unstable file format version: set I_KNOW_LIBCTF_IS_UNSTABLE in the environment.")
|
||||
_CTF_ITEM (ECTF_UNSTABLE, "Attempt to write unstable file format version: set I_KNOW_LIBCTF_IS_UNSTABLE in the environment.") \
|
||||
_CTF_ITEM (ECTF_HASPARENT, "Cannot ctf_import: dict already has a parent.") \
|
||||
_CTF_ITEM (ECTF_WRONGPARENT, "Cannot ctf_import: incorrect parent provided.")
|
||||
|
||||
#define ECTF_BASE 1000 /* Base value for libctf errnos. */
|
||||
|
||||
@@ -259,7 +261,7 @@ _CTF_ERRORS
|
||||
#undef _CTF_FIRST
|
||||
};
|
||||
|
||||
#define ECTF_NERR (ECTF_UNSTABLE - ECTF_BASE + 1) /* Count of CTF errors. */
|
||||
#define ECTF_NERR (ECTF_WRONGPARENT - 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. */
|
||||
@@ -461,7 +463,11 @@ extern void ctf_dict_close (ctf_dict_t *);
|
||||
contain the name of their originating compilation unit and the name of
|
||||
their parent. Dicts opened from CTF archives have this relationship set
|
||||
up already, but if opening via raw low-level calls, you need to figure
|
||||
out which dict is the parent and set it on the child via ctf_import(). */
|
||||
out which dict is the parent and set it on the child via ctf_import().
|
||||
|
||||
Almost all operations other than ctf_import and ctf_close do not work on
|
||||
child dicts that have not yet had ctf_import called on them; in particular,
|
||||
name lookups and type lookup in general are broken, as is type addition. */
|
||||
|
||||
extern const char *ctf_cuname (ctf_dict_t *);
|
||||
extern ctf_dict_t *ctf_parent_dict (ctf_dict_t *);
|
||||
|
||||
Reference in New Issue
Block a user