public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: Tom Tromey <tom@tromey.com>,
	Simon Marchi via Gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH v3 3/7] gdb/dwarf: pass compilation directory to line header
Date: Thu, 28 Apr 2022 11:59:55 -0400	[thread overview]
Message-ID: <c8b5829c-711a-5f4f-ff57-2d3cae9f871e@polymtl.ca> (raw)
In-Reply-To: <874k2dmcny.fsf@tromey.com>

On 2022-04-28 11:48, Tom Tromey wrote:
>>>>>> "Simon" == Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:
> 
> Simon> +  /* COMP_DIR is the value of the DW_AT_comp_dir attribute of the compilation
> Simon> +     unit in the context of which we are reading this line header, or nullptr
> Simon> +     if not applicable.  */
> Simon> +  line_header (const char *comp_dir)
> Simon> +    : m_comp_dir (comp_dir != nullptr ? comp_dir : "")
> Simon> +  {}
> 
> I think a single-argument constructor should be 'explicit'.

Fixed.  I should also initialize the bitfield field offset_in_dwz, fixed
that too.

> 
> Simon> +  /* Compilation directory of the compilation unit in the context of which this
> Simon> +     line header is read.  */
> Simon> +  std::string m_comp_dir;
> 
> Is there a need to copy the value here?
> I didn't check in this case, but often in the DWARF reader, a string
> will come directly from some mapped section, and in that case there
> aren't lifetime issues -- and so it's fine to just store the pointer.

I thought there might be lifetime issues.

read_file_scope owns a file_and_directory object, which contains a
possibly computed comp dir.  That object's lifetime is read_file_scope,
but the line_header created there (by calling handle_DW_AT_stmt_list)
lives on, it is stored in dwarf2_cu::line_header.

However, I see that we call fnd.intern_comp_dir prior to that, so the
returned string should actually be one with objfile lifetime, it should
be fine.  I'll change it to a const char*, we'll see if it causes any
test to fail (I build with ASan, so it should point out any
use-after-free).

Thanks,

Simon

  reply	other threads:[~2022-04-28 16:00 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-28  3:35 [PATCH v3 0/7] Fix printing macros Simon Marchi
2022-04-28  3:35 ` [PATCH v3 1/7] gdb: introduce symtab_create_debug_printf Simon Marchi
2022-04-28 15:49   ` Tom Tromey
2022-04-28  3:35 ` [PATCH v3 2/7] gdb: add debug prints in buildsym.c Simon Marchi
2022-04-28 15:50   ` Tom Tromey
2022-04-28  3:35 ` [PATCH v3 3/7] gdb/dwarf: pass compilation directory to line header Simon Marchi
2022-04-28 15:48   ` Tom Tromey
2022-04-28 15:59     ` Simon Marchi [this message]
2022-04-28  3:35 ` [PATCH v3 4/7] gdb/dwarf: pass a file_entry to line_header::file_file_name Simon Marchi
2022-05-03 20:12   ` Bruno Larsen
2022-07-28 16:26     ` Simon Marchi
2022-04-28  3:35 ` [PATCH v3 5/7] gdb: add "id" fields to identify symtabs and subfiles Simon Marchi
2022-04-28 23:53   ` Lancelot SIX
2022-07-28 17:46     ` Simon Marchi
2022-04-28  3:35 ` [PATCH v3 6/7] gdb: remove code to prepend comp dir in buildsym_compunit::start_subfile Simon Marchi
2022-05-12 13:07   ` Bruno Larsen
2022-07-28 17:47     ` Simon Marchi
2022-04-28  3:35 ` [PATCH v3 7/7] gdb/testsuite: add macros test for source files compiled in various ways Simon Marchi
2022-05-12 13:17   ` Bruno Larsen
2022-07-28 17:51     ` Simon Marchi
2022-07-30  0:56 ` [PATCH v3 0/7] Fix printing macros Simon Marchi

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=c8b5829c-711a-5f4f-ff57-2d3cae9f871e@polymtl.ca \
    --to=simon.marchi@polymtl.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).