Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Simon Marchi <simon.marchi@polymtl.ca>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 1/5] dwarf2read.c: Some C++fycation, use std::vector, std::unique_ptr
Date: Tue, 04 Apr 2017 18:57:00 -0000	[thread overview]
Message-ID: <43dc3793-10e5-4a4b-8983-f5f18b2c6388@redhat.com> (raw)
In-Reply-To: <ef286ec115c7c1986e41dd08ecf14fcf@polymtl.ca>

On 03/29/2017 04:06 PM, Simon Marchi wrote:
>> -/* Add an entry to LH's include directory table.  */
>> -
>> -static void
>> -add_include_dir (struct line_header *lh, const char *include_dir)
>> +void
>> +line_header::add_include_dir (const char *include_dir)
>>  {
>>    if (dwarf_line_debug >= 2)
>>      fprintf_unfiltered (gdb_stdlog, "Adding dir %u: %s\n",
>> -            lh->num_include_dirs + 1, include_dir);
>> +            (unsigned) include_dirs.size () + 1, include_dir);
> 
> Can you use %zu for these?

Hmm, we didn't use to because that would require a C99 runtime.

C++11 is rebased on top of C99, but that doesn't mean that in
practice you're using a C++11 compiler with a fully conforming
C library.

E.g., mingw+msvrt doesn't support it.  However, I think that
gnulib enables __USE_MINGW_ANSI_STDIO, so it should work there.
I don't know about other systems, but it's likely to be safe to
use it nowadays.  In any case, we can always throw more gnulib
at the problem.  There's a printf module that AFAICS supports '%z'.

I'll push with that change.

> 
>> @@ -17952,11 +17890,22 @@ dwarf_decode_line_header (unsigned int
>> offset, struct dwarf2_cu *cu)
>>    if (lh->version >= 5)
>>      {
>>        /* Read directory table.  */
>> -      read_formatted_entries (abfd, &line_ptr, lh, &cu->header,
>> -                  add_include_dir_stub);
>> +      read_formatted_entries (abfd, &line_ptr, lh.get (), &cu->header,
>> +                  [] (struct line_header *lh, const char *name,
>> +                  unsigned int dir_index, unsigned int mod_time,
>> +                  unsigned int length)
>> +    {
>> +      lh->add_include_dir (name);
>> +    });
>>
>>        /* Read file name table.  */
>> -      read_formatted_entries (abfd, &line_ptr, lh, &cu->header,
>> add_file_name);
>> +      read_formatted_entries (abfd, &line_ptr, lh.get (), &cu->header,
>> +                  [] (struct line_header *lh, const char *name,
>> +                  unsigned int dir_index, unsigned int mod_time,
>> +                  unsigned int length)
>> +    {
>> +      lh->add_file_name (name, dir_index, mod_time, length);
>> +    });
> 
> We can do it afterwards to avoid adding noise to this patch, but I
> noticed that if we captured lh in the lambda, we could avoid passing the
> line_header in read_formatted_entries and the callback.

Yeah, that'd require switching to use gdb::function_view though,
because otherwise you can't pass a lambda with a capture.

> I took a quick look, it looks good to me.

Thanks!


  parent reply	other threads:[~2017-04-04 18:57 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-29  2:25 [PATCH 0/5] dwarf2read.c: Some C++fycation Pedro Alves
2017-03-29  2:25 ` [PATCH 3/5] dwarf2read.c: Make dir_index and file_name_index strong typedefs Pedro Alves
2017-03-29 15:36   ` Simon Marchi
2017-04-04 18:54     ` Pedro Alves
2017-04-04 19:06       ` Pedro Alves
2017-03-29  2:25 ` [PATCH 1/5] dwarf2read.c: Some C++fycation, use std::vector, std::unique_ptr Pedro Alves
     [not found]   ` <ef286ec115c7c1986e41dd08ecf14fcf@polymtl.ca>
2017-04-04 18:57     ` Pedro Alves [this message]
2017-03-29  2:25 ` [PATCH 2/5] gdb::optional: Add observers Pedro Alves
2017-03-29  2:25 ` [PATCH 5/5] dwarf2read.c: C++fy lnp_state_machine Pedro Alves
2017-03-29  2:32 ` [PATCH 4/5] Make sect_offset and cu_offset strong typedefs instead of structs Pedro Alves
2017-03-29 15:46   ` Simon Marchi
2017-04-05 15:13     ` Pedro Alves

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=43dc3793-10e5-4a4b-8983-f5f18b2c6388@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@polymtl.ca \
    /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