From: Simon Marchi <simark@simark.ca>
To: Tom Tromey <tom@tromey.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 3/8] Change fde table to a vector
Date: Wed, 12 Feb 2020 03:28:00 -0000 [thread overview]
Message-ID: <a8628675-5902-8923-d9c8-e294c6a317c1@simark.ca> (raw)
In-Reply-To: <20200208152758.29385-4-tom@tromey.com>
On 2020-02-08 10:27 a.m., Tom Tromey wrote:
> diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c
> index db8e5cd25f3..6d87e598345 100644
> --- a/gdb/dwarf2/frame.c
> +++ b/gdb/dwarf2/frame.c
> @@ -129,11 +129,7 @@ struct dwarf2_fde
> unsigned char eh_frame_p;
> };
>
> -struct dwarf2_fde_table
> -{
> - int num_entries;
> - struct dwarf2_fde **entries;
> -};
> +typedef std::vector<dwarf2_fde *> dwarf2_fde_table;
As a further change, I think we could consider make this a vector of objects, rather
than a vector of pointers.
> /* A minimal decoding of DWARF2 compilation units. We only decode
> what's needed to get to the call frame information. */
> @@ -1471,9 +1467,7 @@ dwarf2_frame_cfa (struct frame_info *this_frame)
> return get_frame_base (this_frame);
> }
> \f
> -const struct objfile_key<dwarf2_fde_table,
> - gdb::noop_deleter<dwarf2_fde_table>>
> - dwarf2_frame_objfile_data;
> +const struct objfile_key<dwarf2_fde_table> dwarf2_frame_objfile_data;
Can you make this static, while at it?
> @@ -2215,42 +2198,20 @@ dwarf2_build_frame_info (struct objfile *objfile)
> warning (_("skipping .debug_frame info of %s: %s"),
> objfile_name (objfile), e.what ());
>
> - if (fde_table.num_entries != 0)
> - {
> - fde_table.num_entries = num_old_fde_entries;
> - if (num_old_fde_entries == 0)
> - {
> - xfree (fde_table.entries);
> - fde_table.entries = NULL;
> - }
> - else
> - {
> - fde_table.entries
> - = XRESIZEVEC (struct dwarf2_fde *, fde_table.entries,
> - fde_table.num_entries);
> - }
> - }
> - fde_table.num_entries = num_old_fde_entries;
> + fde_table.resize (num_old_fde_entries);
> }
> }
>
> /* Copy fde_table to obstack: it is needed at runtime. */
I think that comment is stale.
> - fde_table2 = XOBNEW (&objfile->objfile_obstack, struct dwarf2_fde_table);
> + fde_table2 = new dwarf2_fde_table;
>
> - if (fde_table.num_entries == 0)
> - {
> - fde_table2->entries = NULL;
> - fde_table2->num_entries = 0;
> - }
> - else
> + if (!fde_table.empty ())
If you want to simplify the code even further, you could get rid of this check, since the
code below should cope well with an empty vector.
> @@ -2293,16 +2249,10 @@ dwarf2_build_frame_info (struct objfile *objfile)
> && fde_prev->initial_location == fde->initial_location)
> continue;
>
> - obstack_grow (&objfile->objfile_obstack, &fde_table.entries[i],
> - sizeof (fde_table.entries[0]));
> - ++fde_table2->num_entries;
> + fde_table2->push_back (fde);
> fde_prev = fde;
> }
> - fde_table2->entries
> - = (struct dwarf2_fde **) obstack_finish (&objfile->objfile_obstack);
> -
> - /* Discard the original fde_table. */
> - xfree (fde_table.entries);
> + fde_table2->shrink_to_fit ();
That shrink_to_fit appears to be pointless, as fde_table2 is created empty and we only
push_back. Maybe you meant to create it with an initial size?
Simon
next prev parent reply other threads:[~2020-02-12 3:28 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-08 15:28 [PATCH 0/8] Share DWARF frame information across inferiors Tom Tromey
2020-02-08 15:28 ` [PATCH 1/8] Don't forward-declare struct objfile in frame.h Tom Tromey
2020-02-12 0:51 ` Simon Marchi
2020-02-12 1:59 ` Tom Tromey
2020-02-08 15:28 ` [PATCH 2/8] Dont' allow copying of auto_obstack Tom Tromey
2020-02-09 23:56 ` Christian Biesinger via gdb-patches
2020-02-12 0:16 ` Tom Tromey
2020-02-12 0:53 ` Simon Marchi
2020-02-12 1:01 ` Tom Tromey
2020-02-08 15:28 ` [PATCH 5/8] Add per-unit obstack Tom Tromey
2020-02-11 10:34 ` Luis Machado
2020-02-12 3:53 ` Simon Marchi
2020-02-12 22:41 ` Tom Tromey
2020-02-12 22:48 ` Simon Marchi
2020-02-12 22:51 ` Tom Tromey
2020-02-08 15:28 ` [PATCH 6/8] Remove a use of the comp_unit backlink Tom Tromey
2020-02-08 15:28 ` [PATCH 7/8] Remove the objfile backlink from comp_unit Tom Tromey
2020-02-09 23:56 ` Christian Biesinger via gdb-patches
2020-02-12 0:26 ` Tom Tromey
2020-02-11 10:40 ` Luis Machado
2020-02-08 15:28 ` [PATCH 3/8] Change fde table to a vector Tom Tromey
[not found] ` <5a373a74-9283-5d82-a22d-7a2606a4d3f5@linaro.org>
2020-02-12 0:29 ` Tom Tromey
2020-02-12 3:28 ` Simon Marchi [this message]
2020-02-12 3:33 ` Simon Marchi
2020-02-12 22:36 ` Tom Tromey
2020-02-12 22:47 ` Simon Marchi
2020-02-08 15:28 ` [PATCH 4/8] Store the comp_unit instead of the FDE table Tom Tromey
2020-02-09 23:56 ` Christian Biesinger via gdb-patches
2020-02-12 0:19 ` Tom Tromey
2020-02-11 10:32 ` Luis Machado
2020-02-12 0:20 ` Tom Tromey
2020-02-12 3:36 ` Simon Marchi
2020-02-12 22:20 ` Tom Tromey
2020-02-08 15:28 ` [PATCH 8/8] Move the frame data to the BFD when possible Tom Tromey
2020-02-11 10:45 ` Luis Machado
2020-02-12 0:31 ` Tom Tromey
2020-11-14 3:31 ` Simon Marchi
2020-02-08 15:29 ` [PATCH 0/8] Share DWARF frame information across inferiors Tom Tromey
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=a8628675-5902-8923-d9c8-e294c6a317c1@simark.ca \
--to=simark@simark.ca \
--cc=gdb-patches@sourceware.org \
--cc=tom@tromey.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