Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi via Gdb-patches <gdb-patches@sourceware.org>
To: Tom Tromey <tom@tromey.com>
Cc: gdb-patches@sourceware.org, Joel Brobecker <brobecker@adacore.com>
Subject: Re: [PATCH 3/3] Cache the result of find_file_and_directory
Date: Sun, 5 Dec 2021 20:54:16 -0500	[thread overview]
Message-ID: <3deee783-bee1-887f-6b8f-ffbe74131151@polymtl.ca> (raw)
In-Reply-To: <874k7mu7q5.fsf@tromey.com>



On 2021-12-05 15:17, Tom Tromey wrote:
>>> Sorry about that.  I'll fix it soon.  Or you can back it out if you
>>> prefer.
> 
> Simon> I'm not personally affected so I do not mind, I can wait for the fix.
> 
> Here is what I am checking in.
> I was able to reproduce the failure with valgrind, and confirmed that
> this patch fixes it.
> 
> Tom

Thanks.  And while looking at that fix, I had this this question:
looking at find_file_and_directory:

    static file_and_directory &
    find_file_and_directory (struct die_info *die, struct dwarf2_cu *cu)
    {
      if (cu->per_cu->fnd != nullptr)
        return *cu->per_cu->fnd;

      /* Find the filename.  Do not use dwarf2_name here, since the filename
         is not a source language identifier.  */
      file_and_directory res (dwarf2_string_attr (die, DW_AT_name, cu),
    			  dwarf2_string_attr (die, DW_AT_comp_dir, cu));

      if (res.get_comp_dir () == nullptr
          && producer_is_gcc_lt_4_3 (cu)
          && res.get_name () != nullptr
          && IS_ABSOLUTE_PATH (res.get_name ()))
        res.set_comp_dir (ldirname (res.get_name ()));

      cu->per_cu->fnd.reset (new file_and_directory (std::move (res)));
      return *cu->per_cu->fnd;
    }

`dwarf2_string_attr (die, DW_AT_name, cu)` is used as the name in
`fnd`, and `fnd` is saved in the dwarf2_per_cu_data structure.  Is
`dwarf2_string_attr (die, DW_AT_name, cu)` value guaranteed to live at
least as long as the dwarf2_per_cu_data structure?  IIUC, the die_info
objects are tied to a dwarf2_cu.  And dwarf2_cus can be deleted
(by free_cached_comp_units).  I might be wrong, but I thought I'd
raise the point just in case.

Simon

  reply	other threads:[~2021-12-06  1:54 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-30  1:33 [PATCH 0/3] Refactor find_file_and_directory Tom Tromey
2021-11-30  1:33 ` [PATCH 1/3] Remove Irix case from find_file_and_directory Tom Tromey
2021-12-04 10:43   ` Joel Brobecker via Gdb-patches
2021-11-30  1:33 ` [PATCH 2/3] Move file_and_directory to new file and C++-ize Tom Tromey
2021-11-30 16:18   ` Lancelot SIX via Gdb-patches
2021-11-30 17:44     ` Tom Tromey
2021-12-04 10:38   ` Joel Brobecker via Gdb-patches
2021-12-04 18:22     ` Tom Tromey
2021-11-30  1:33 ` [PATCH 3/3] Cache the result of find_file_and_directory Tom Tromey
2021-12-04 10:42   ` Joel Brobecker via Gdb-patches
2021-12-04 18:22     ` Tom Tromey
2021-12-05  2:31       ` Simon Marchi via Gdb-patches
2021-12-05  3:46         ` Tom Tromey
2021-12-05  3:47           ` Simon Marchi via Gdb-patches
2021-12-05 20:17             ` Tom Tromey
2021-12-06  1:54               ` Simon Marchi via Gdb-patches [this message]
2021-12-07  4:30                 ` 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=3deee783-bee1-887f-6b8f-ffbe74131151@polymtl.ca \
    --to=gdb-patches@sourceware.org \
    --cc=brobecker@adacore.com \
    --cc=simon.marchi@polymtl.ca \
    --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