From: Pedro Alves <palves@redhat.com>
To: Keith Seitz <keiths@redhat.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] Record/output access specifiers for class typedefs
Date: Mon, 26 Jun 2017 10:25:00 -0000 [thread overview]
Message-ID: <984a26ce-e09a-0b11-4d7e-e8c5adf79173@redhat.com> (raw)
In-Reply-To: <1498416734-14498-1-git-send-email-keiths@redhat.com>
On 06/25/2017 07:52 PM, Keith Seitz wrote:
> We do not currently record/output accessibility for typedefs defined
> in a class:
>
> (gdb) list
> 71 struct typedef_struct {
> 72 public:
> 73 typedef int public_int;
> 74 public_int a;
> 75 protected:
> 76 typedef int protected_int;
> 77 protected_int b;
> 78 private:
> 79 typedef int private_int;
> 80 private_int c;
> 81 protected:
> 82 typedef float protected_float;
> 83 protected_float d;
> 84 private:
> 85 typedef float private_float;
> 86 private_float e;
> 87 public:
> 88 typedef float public_float;
> 89 public_float f;
> 90 };
> (gdb) ptype typedef_struct
> type = struct typedef_struct {
> public:
> public_int a;
> protected:
> public_int b;
> private:
> public_int c;
> protected:
> protected_float d;
> private:
> protected_float e;
> public:
> protected_float f;
>
> typedef int public_int;
> typedef int protected_int;
> typedef int private_int;
> typedef float protected_float;
> typedef float private_float;
> typedef float public_float;
> }
>
> This patch modifies the DWARF reader to record accessibility when reading
> in typedef DIEs.
As general principle, please also show in the commit log what
output looks like after the patch.
On 06/25/2017 07:52 PM, Keith Seitz wrote:
> + /* Save accessibility. */
> + struct attribute *attr = dwarf2_attr (die, DW_AT_accessibility, cu);
> + enum dwarf_access_attribute accessibility;
> +
> + if (attr != NULL)
> + accessibility = (enum dwarf_access_attribute) DW_UNSND (attr);
> + else
> + accessibility = dwarf2_default_access_attribute (die, cu);
> + switch (accessibility)
> + {
> + case DW_ACCESS_public:
> + fp->is_public = 1;
> + break;
> + case DW_ACCESS_private:
> + fp->is_private = 1;
> + break;
> + case DW_ACCESS_protected:
> + fp->is_protected = 1;
> + break;
> + default:
> + gdb_assert_not_reached ("unexpected accessibility attribute");
Please don't add assertions that can trigger with
invalid/broken DWARF. Call complaint instead.
> + if (TYPE_TYPEDEF_FIELD_PROTECTED (type, i))
> + {
> + if (section_type != s_protected)
> + {
> + section_type = s_protected;
> + fprintfi_filtered (level + 2, stream,
> + "protected:\n");
> + }
> + }
> + else if (TYPE_TYPEDEF_FIELD_PRIVATE (type, i))
> + {
> + if (section_type != s_private)
> + {
> + section_type = s_private;
> + fprintfi_filtered (level + 2, stream,
> + "private:\n");
> + }
> + }
> + else
> + {
> + gdb_assert (TYPE_TYPEDEF_FIELD_PUBLIC (type, i));
Won't this assertion fail with debug formats other than DWARF?
E.g., stabs?
> + if (section_type != s_public)
> + {
> + section_type = s_public;
> + fprintfi_filtered (level + 2, stream,
> + "public:\n");
> + }
> + }
> +
> --- a/gdb/gdbtypes.h
> +++ b/gdb/gdbtypes.h
> @@ -884,6 +884,18 @@ struct typedef_field
> /* * Type this typedef named NAME represents. */
>
> struct type *type;
> +
> + /* * True if this field was declared public, false otherwise. */
> + unsigned int is_public : 1;
> +
> + /* * True if this field was declared protected, false otherwise. */
> + unsigned int is_protected : 1;
> +
> + /* * True if this field was declared private, false otherwise. */
> + unsigned int is_private : 1;
> +
> + /* * Unused. */
> + unsigned int dummy : 13;
Is this really 13 bits? Looks to me 29 bits on 32-bit archs (and due
to padding, really 61 bits on 64-bit archs)?
> };
For completeness, do you have a sense of whether this is a struct
that might have a significant impact on gdb's memory consumption?
Did you try measuring it with some large program, say, Firefox,
with -readnow ?
Thanks,
Pedro Alves
prev parent reply other threads:[~2017-06-26 10:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-25 18:52 Keith Seitz
2017-06-26 10:25 ` Pedro Alves [this message]
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=984a26ce-e09a-0b11-4d7e-e8c5adf79173@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=keiths@redhat.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