This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH v4] Add support for the readnever concept
- From: Pedro Alves <palves at redhat dot com>
- To: Sergio Durigan Junior <sergiodj at redhat dot com>, Tom Tromey <tom at tromey dot com>
- Cc: GDB Patches <gdb-patches at sourceware dot org>, Joel Brobecker <brobecker at adacore dot com>, Yao Qi <qiyaoltc at gmail dot com>, Eli Zaretskii <eliz at gnu dot org>
- Date: Fri, 1 Dec 2017 20:00:23 +0000
- Subject: Re: [PATCH v4] Add support for the readnever concept
- Authentication-results: sourceware.org; auth=none
- References: <1467838463-15786-1-git-send-email-brobecker@adacore.com> <20171130002529.10592-1-sergiodj@redhat.com> <6765d36f-8603-9cd3-0476-801a5bfe0865@redhat.com> <87shcvgj55.fsf@redhat.com> <d912d6af-2500-56bc-5e40-a048c2dbd9e9@redhat.com> <87mv325pz8.fsf@tromey.com> <87h8tafjop.fsf@redhat.com>
On 12/01/2017 05:21 PM, Sergio Durigan Junior wrote:
> On Friday, December 01 2017, Tom Tromey wrote:
>
>>>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
>>
>> Pedro> On 12/01/2017 04:35 AM, Sergio Durigan Junior wrote:
>>>>> If readnever_symbol_files is set, then it'll have been propagated to
>> objfile-> flags before we get here, no?
>>>>
>>>> Hm, I think so, yes. I mean, assuming that objfile != NULL when we call
>>>> the readers, then yes;
>>
>> Pedro> Certainly you can assume that. A reader's job is to read
>> Pedro> in the passed in objfile. The very first line of elf_symfile_read
>> Pedro> would immediately crash otherwise, for example.
>>
>> Perhaps an ATTRIBUTE_NONNULL is in order somewhere.
>
> I thought about a gdb_assert, actually. But yeah, I agree. I'll push
> what Pedro has approved, and if he's OK with it, I'll prepare a patch
> with a gdb_assert.
>
gdb_assert (objfile != NULL) sprinkled around in the readers would be
pointless IMO. It's not like there's any real risk that you'd
be sometimes passing a NULL pointer down to the readers in some
corner cases. That'd be pretty gross mistake. The objfile is kind of
like a "this" pointer here:
static void
read_symbols (struct objfile *objfile, symfile_add_flags add_flags)
{
(*objfile->sf->sym_read) (objfile, add_flags);
...
(obviously the above crashes with a NULL objfile. And up the
call stack, there are many other places that'd crash first
before you even get here.)
Thanks,
Pedro Alves