aboutsummaryrefslogtreecommitdiff
path: root/gdb/ctfread.c
diff options
context:
space:
mode:
authorWeimin Pan <weimin.pan@oracle.com>2021-03-05 19:17:00 -0500
committerWeimin Pan <weimin.pan@oracle.com>2021-03-05 20:46:39 -0500
commitdd99cf0c580ac7b989a991283fa9f3eab07aec99 (patch)
treefa00af9e843598266fa0bf68a7818e3e3c7b8b54 /gdb/ctfread.c
parent844be3f24027a13630dc0f67e006eee2ee5c6776 (diff)
downloadgdb-dd99cf0c580ac7b989a991283fa9f3eab07aec99.zip
gdb-dd99cf0c580ac7b989a991283fa9f3eab07aec99.tar.gz
gdb-dd99cf0c580ac7b989a991283fa9f3eab07aec99.tar.bz2
CTF: add all members of an enum type to psymtab
With the following change which was made last April: [gdb] Use partial symbol table to find language for main commit d3214198119c1a2f9a6a2b8fcc56d8c324e1a245 The ctf reader was modified to enter all members of an enum type, similar to what the dwarf2 reader did, into the psymtab or gdb won't be able to find them. In addition, the empty name checking needed to be moved down so members of a unnamed enum were not left out. gdb/ChangeLog: * ctfread.c (ctf_psymtab_add_enums): New function. (ctf_psymtab_type_cb): call ctf_psymtab_add_enums.
Diffstat (limited to 'gdb/ctfread.c')
-rw-r--r--gdb/ctfread.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/gdb/ctfread.c b/gdb/ctfread.c
index dfd543a..4ff475f 100644
--- a/gdb/ctfread.c
+++ b/gdb/ctfread.c
@@ -1245,6 +1245,27 @@ ctf_end_symtab (ctf_psymtab *pst,
return result;
}
+/* Add all members of an enum with type TID to partial symbol table. */
+
+static void
+ctf_psymtab_add_enums (struct ctf_context *ccp, ctf_id_t tid)
+{
+ int val;
+ const char *ename;
+ ctf_next_t *i = nullptr;
+
+ while ((ename = ctf_enum_next (ccp->fp, tid, &i, &val)) != nullptr)
+ {
+ ccp->pst->add_psymbol (ename, true,
+ VAR_DOMAIN, LOC_CONST, -1,
+ psymbol_placement::GLOBAL,
+ 0, language_c, ccp->of);
+ }
+ if (ctf_errno (ccp->fp) != ECTF_NEXT_END)
+ complaint (_("ctf_enum_next ctf_psymtab_add_enums failed - %s"),
+ ctf_errmsg (ctf_errno (ccp->fp)));
+}
+
/* Read in full symbols for PST, and anything it depends on. */
void
@@ -1366,17 +1387,17 @@ ctf_psymtab_type_cb (ctf_id_t tid, void *arg)
ccp = (struct ctf_context *) arg;
gdb::unique_xmalloc_ptr<char> name (ctf_type_aname_raw (ccp->fp, tid));
- if (name == nullptr || strlen (name.get ()) == 0)
- return 0;
domain_enum domain = UNDEF_DOMAIN;
enum address_class aclass = LOC_UNDEF;
kind = ctf_type_kind (ccp->fp, tid);
switch (kind)
{
+ case CTF_K_ENUM:
+ ctf_psymtab_add_enums (ccp, tid);
+ /* FALL THROUGH */
case CTF_K_STRUCT:
case CTF_K_UNION:
- case CTF_K_ENUM:
domain = STRUCT_DOMAIN;
aclass = LOC_TYPEDEF;
break;
@@ -1407,6 +1428,9 @@ ctf_psymtab_type_cb (ctf_id_t tid, void *arg)
return 0;
}
+ if (name == nullptr || strlen (name.get ()) == 0)
+ return 0;
+
ccp->pst->add_psymbol (name.get (), true,
domain, aclass, section,
psymbol_placement::GLOBAL,