From: Weimin Pan via Gdb-patches <gdb-patches@sourceware.org>
To: gdb-patches@sourceware.org
Subject: [PATCH,V2 4/5] CTF: add all members of an enum type to psymtab
Date: Mon, 1 Mar 2021 20:53:37 -0500 [thread overview]
Message-ID: <1614650018-9135-5-git-send-email-weimin.pan@oracle.com> (raw)
In-Reply-To: <1614650018-9135-4-git-send-email-weimin.pan@oracle.com>
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 | 5 +++++
gdb/ctfread.c | 30 +++++++++++++++++++++++++++---
2 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index dac61a3..31cac5c 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2021-02-26 Weimin Pan <weimin.pan@oracle.com>
+ * ctfread.c (ctf_psymtab_add_enums): New function.
+ (ctf_psymtab_type_cb): call ctf_psymtab_add_enums.
+
+2021-02-26 Weimin Pan <weimin.pan@oracle.com>
+
* ctfread.c (fetch_tid_type): New function, use throughout file.
(read_forward_type): New function.
(read_type_record): Call read_forward_type.
diff --git a/gdb/ctfread.c b/gdb/ctfread.c
index d3e6ad5..bb73949 100644
--- a/gdb/ctfread.c
+++ b/gdb/ctfread.c
@@ -1294,6 +1294,27 @@ struct ctf_tid_and_type
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 = NULL;
+
+ while ((ename = ctf_enum_next (ccp->fp, tid, &i, &val)) != NULL)
+ {
+ 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
@@ -1415,17 +1436,17 @@ struct ctf_tid_and_type
ccp = (struct ctf_context *) arg;
gdb::unique_xmalloc_ptr<char> name (ctf_type_aname_raw (ccp->fp, tid));
- if (name == NULL || 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;
@@ -1456,6 +1477,9 @@ struct ctf_tid_and_type
return 0;
}
+ if (name == NULL || strlen (name.get ()) == 0)
+ return 0;
+
ccp->pst->add_psymbol (name.get (), true,
domain, aclass, section,
psymbol_placement::GLOBAL,
--
1.8.3.1
next prev parent reply other threads:[~2021-03-02 1:54 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-02 1:53 [PATCH,V2 0/5] CTF: bug fixes and new features Weimin Pan via Gdb-patches
2021-03-02 1:53 ` [PATCH,V2 1/5] CTF: fix incorrect function return type Weimin Pan via Gdb-patches
2021-03-02 1:53 ` [PATCH,V2 2/5] CTF: set up debug info for function arguments Weimin Pan via Gdb-patches
2021-03-02 1:53 ` [PATCH,V2 3/5] CTF: handle forward reference type Weimin Pan via Gdb-patches
2021-03-02 1:53 ` Weimin Pan via Gdb-patches [this message]
2021-03-02 1:53 ` [PATCH,V2 5/5] CTF: multi-CU and archive support Weimin Pan via Gdb-patches
2021-03-02 23:15 ` Lancelot SIX via Gdb-patches
2021-03-03 1:01 ` Wei-min Pan via Gdb-patches
2021-03-03 17:37 ` Lancelot SIX via Gdb-patches
2021-03-03 18:31 ` Weimin Pan via Gdb-patches
2021-03-03 20:46 ` [PATCH,V2 4/5] CTF: add all members of an enum type to psymtab Tom Tromey
2021-03-03 22:27 ` Wei-min Pan via Gdb-patches
2021-03-03 20:49 ` [PATCH,V2 3/5] CTF: handle forward reference type Tom Tromey
2021-03-03 22:01 ` Wei-min Pan via Gdb-patches
2021-03-02 12:23 ` [PATCH,V2 2/5] CTF: set up debug info for function arguments Lancelot SIX via Gdb-patches
2021-03-02 18:12 ` Wei-min Pan via Gdb-patches
2021-03-03 20:38 ` Tom Tromey
2021-03-03 21:58 ` Wei-min Pan via Gdb-patches
2021-03-03 20:41 ` Tom Tromey
2021-03-03 20:37 ` [PATCH,V2 1/5] CTF: fix incorrect function return type Tom Tromey
2021-03-03 21:57 ` Wei-min Pan via Gdb-patches
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=1614650018-9135-5-git-send-email-weimin.pan@oracle.com \
--to=gdb-patches@sourceware.org \
--cc=weimin.pan@oracle.com \
/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