From: Lancelot SIX via Gdb-patches <gdb-patches@sourceware.org>
To: Weimin Pan <weimin.pan@oracle.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH,V2 2/5] CTF: set up debug info for function arguments
Date: Tue, 2 Mar 2021 12:23:19 +0000 [thread overview]
Message-ID: <YD4uNzvrFR4eL9gq@Plymouth> (raw)
In-Reply-To: <1614650018-9135-3-git-send-email-weimin.pan@oracle.com>
Hi,
I just have style related comments bellow.
Le Mon, Mar 01, 2021 at 08:53:35PM -0500, Weimin Pan via Gdb-patches a écrit :
> Added this support in read_func_kind_type after gcc started generating
> CTF for function arguments.
>
> Expanded gdb.base/ctf-ptype.exp to test function arguments. Also fixed
> some typos.
>
> ---
> gdb/ChangeLog | 4 ++++
> gdb/ctfread.c | 29 ++++++++++++++++++++++++++++-
> gdb/testsuite/ChangeLog | 4 ++++
> gdb/testsuite/gdb.base/ctf-ptype.exp | 19 ++++++++++++++++---
> 4 files changed, 52 insertions(+), 4 deletions(-)
>
> diff --git a/gdb/ChangeLog b/gdb/ChangeLog
> index 88278d1..0a839ba 100644
> --- a/gdb/ChangeLog
> +++ b/gdb/ChangeLog
> @@ -1,5 +1,9 @@
> 2021-02-26 Weimin Pan <weimin.pan@oracle.com>
>
> + * ctfread.c (read_func_kind_type): Set up function arguments.
> +
> +2021-02-26 Weimin Pan <weimin.pan@oracle.com>
> +
> * ctfread.c (new_symbol): Set function address.
> (read_func_kind_type): Remove incorrect type name setting.
>
> diff --git a/gdb/ctfread.c b/gdb/ctfread.c
> index 5a68d9c..75b098c 100644
> --- a/gdb/ctfread.c
> +++ b/gdb/ctfread.c
> @@ -652,8 +652,9 @@ struct ctf_tid_and_type
> {
> struct objfile *of = ccp->of;
> ctf_dict_t *fp = ccp->fp;
> - struct type *type, *rettype;
> + struct type *type, *rettype, *atype;
> ctf_funcinfo_t cfi;
> + uint32_t argc;
>
> type = alloc_type (of);
>
> @@ -663,6 +664,32 @@ struct ctf_tid_and_type
> TYPE_TARGET_TYPE (type) = rettype;
> set_type_align (type, ctf_type_align (fp, tid));
>
> + /* Set up function's arguments. */
> + argc = cfi.ctc_argc;
> + type->set_num_fields (argc);
> + if (cfi.ctc_flags & CTF_FUNC_VARARG)
> + type->set_has_varargs (true);
> +
> + if (argc != 0)
> + {
> + std::vector<ctf_id_t> argv (argc);
> + if (ctf_func_type_args (fp, tid, argc, argv.data ()) == CTF_ERR)
> + return NULL;
Could be nullptr instead of NULL (even if I am not sure the standard
enforces that).
> +
> + type->set_fields
> + ((struct field *) TYPE_ZALLOC (type, argc * sizeof (struct field)));
> + struct type *void_type = objfile_type (of)->builtin_void;
> + /* If failed to find the argument type, fill it with void_type. */
> + for (int iparam = 0; iparam < argc; iparam++)
> + {
> + atype = get_tid_type (of, argv[iparam]);
> + if (atype)
An explicit comparison against nullptr should be done here. See
https://sourceware.org/gdb/wiki/Internals%20GDB-C-Coding-Standards#Comparison_With_NULL_And_Zero
Thanks,
Lancelot.
> + type->field (iparam).set_type (atype);
> + else
> + type->field (iparam).set_type (void_type);
> + }
> + }
> +
> return set_tid_type (of, tid, type);
> }
>
> diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
> index 3d71354..9445362 100644
> --- a/gdb/testsuite/ChangeLog
> +++ b/gdb/testsuite/ChangeLog
> @@ -1,5 +1,9 @@
> 2021-02-26 Weimin Pan <weimin.pan@oracle.com>
>
> + * gdb.base/ctf-ptype.exp: Add function tests and fix typos.
> +
> +2021-02-26 Weimin Pan <weimin.pan@oracle.com>
> +
> * gdb.base/ctf-funcreturn.exp: New file.
>
> 2021-01-29 Tom de Vries <tdevries@suse.de>
> diff --git a/gdb/testsuite/gdb.base/ctf-ptype.exp b/gdb/testsuite/gdb.base/ctf-ptype.exp
> index ffe40f1..056f712 100644
> --- a/gdb/testsuite/gdb.base/ctf-ptype.exp
> +++ b/gdb/testsuite/gdb.base/ctf-ptype.exp
> @@ -63,10 +63,10 @@ gdb_test "ptype struct t_struct" "type = struct t_struct \{.*\[\r\n\] (unsign
>
> # Test the equivalence between '.' and '->' for struct member references.
>
> -if [gdb_test "ptype v_t_struct_p.v_float_member" "type = float"]<0 then {
> +if [gdb_test "ptype v_struct1.v_float_member" "type = float"]<0 then {
> return -1
> }
> -if [gdb_test "ptype v_t_struct_p->v_float_member" "type = float"]<0 then {
> +if [gdb_test "ptype v_struct1->v_float_member" "type = float"]<0 then {
> return -1
> }
> if [gdb_test "ptype v_t_struct_p.v_float_member" "type = float"]<0 then {
> @@ -211,7 +211,7 @@ gdb_test "ptype the_highest" \
>
> gdb_test "ptype the_highest.anonymous_level_1" \
> "type = struct \{.*\[\r\n\] *int b;.*\[\r\n\] *struct \{.*\[\r\n\] *int c;.*\[\r\n\] *\} anonymous_level_2;.*\[\r\n\]}.*" \
> - "ptype the_highest"
> + "ptype the_highest.anonymous_level_1"
>
> # Print the type of the identifier ID, and check the response:
> # - Expect to see PROTOTYPED as the type. PROTOTYPED is not a regular
> @@ -255,8 +255,21 @@ proc ptype_maybe_prototyped { id prototyped plain { overprototyped "NO-MATCH" }
> }
> }
>
> +ptype_maybe_prototyped "func_type" "int (*)(int (*)(int, float), float)" \
> + "int (*)()"
> ptype_maybe_prototyped "old_fptr" "double (*)()" "double (*)()" \
> "double (*)(void)"
> +ptype_maybe_prototyped "new_fptr" "double (*)()" "double (*)()"
> +ptype_maybe_prototyped "fptr" "int (*)(int, float)" "int (*)()"
> +ptype_maybe_prototyped "fptr2" "int *(*)(int (*)(int, float), float)" \
> + "int *(*)()"
> +ptype_maybe_prototyped "xptr" "int (*)(int (*)(), int (*)(), int)" \
> + "int (*)()" \
> + "int (*)(int (*)(void), int (*)(void), int)"
> +ptype_maybe_prototyped "ffptr" "int (*(*)(char))(short int)" \
> + "int (*(*)())()"
> +ptype_maybe_prototyped "fffptr" "int (*(*(*)(char))(short int))(long int)" \
> + "int (*(*(*)())())()"
>
> # Test printing type of string constants and array constants, but
> # requires a running process. These call malloc, and can take a long
> --
> 1.8.3.1
>
--
Lancelot SIX
next prev parent reply other threads:[~2021-03-02 12:23 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 ` [PATCH,V2 4/5] CTF: add all members of an enum type to psymtab Weimin Pan via Gdb-patches
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 ` Lancelot SIX via Gdb-patches [this message]
2021-03-02 18:12 ` [PATCH,V2 2/5] CTF: set up debug info for function arguments 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=YD4uNzvrFR4eL9gq@Plymouth \
--to=gdb-patches@sourceware.org \
--cc=lsix@lancelotsix.com \
--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