public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Sergio Durigan Junior <sergiodj@redhat.com>
Cc: Yao Qi <qiyaoltc@gmail.com>,
	Joel Brobecker <brobecker@adacore.com>,
	"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [PATCH v2] Add support for the --readnever command-line option (DWARF only)
Date: Fri, 24 Nov 2017 13:18:00 -0000	[thread overview]
Message-ID: <a70f1f41-6ac1-699a-7d2c-bf0c5095809b@redhat.com> (raw)
In-Reply-To: <87a7zc9syx.fsf@redhat.com>


On 11/24/2017 04:54 AM, Sergio Durigan Junior wrote:
> On Thursday, November 23 2017, Pedro Alves wrote:
> 
>> On 11/23/2017 05:21 PM, Sergio Durigan Junior wrote:
>>
>>>>> +This option is currently limited to debug information in DWARF format.
>>>>> +For all other format, this option has no effect.
>>>>
>>>> How hard would it be to just make it work?  There's only stabs and mdebug
>>>> left, I think?  There should be a single a function somewhere that we can
>>>> add an early return.  And then we don't need to document this limitation...
>>>>
>>>> For example, in elf_symfile_read, we could just skip the elf_locate_sections
>>>> call.  In coffread.c we could skip reading stabs right after 
>>>>   bfd_map_over_sections (abfd, coff_locate_sections....);
>>>>
>>>> Looking for:
>>>>
>>>>  $ grep -h "^[a-z]*_build_psymtabs" gdb/
>>>>  coffstab_build_psymtabs (struct objfile *objfile,
>>>>  elfstab_build_psymtabs (struct objfile *objfile, asection *stabsect,
>>>>  stabsect_build_psymtabs (struct objfile *objfile, char *stab_name,
>>>>  mdebug_build_psymtabs (minimal_symbol_reader &reader,
>>>>  elfmdebug_build_psymtabs (struct objfile *objfile,
>>>>
>>>> finds all the relevant places.
>>>>
>>>> Maybe it wouldn't be that hard to make this be an objfile flag
>>>> afterall (like OBJF_READNOW is).  That'd make it possible
>>>> to add the location "-readnever" counterpart switch to add-symbol-file
>>>> too, BTW:
>>
>> I meant "logical" instead of "location".  I was staring at
>> gdb/location.c at that time.  :-P
>>
>>>>
>>>>  symfile.c:        if (strcmp (arg, "-readnow") == 0)
>>>>  symfile.c:        else if (strcmp (arg, "-readnow") == 0)
>>>
>>> Hm, I'll look into this.  Just to make it clear: the idea is to have
>>> both a --readnever global option and also a OBJF_READNEVER specific to
>>> each objfile?
>>
>> Sure, the idea is to do something similar to what's done for --readnow.
> 
> Sorry, but I guess I need a few more details on this.
> 
> The way I understand the code at elf_symfile_read, the very first thing
> to do would be to check if OBJF_READNEVER is set and return early if it
> is.  But it seems that you're proposing something a bit different when
> you say that we should "... just skip the elf_locate_sections call."  It
> doesn't seem to me that is worth continuing on that function if
> OBJF_READNEVER is present.

No, you can't return early the very first thing, because
 --readnever is supposed to skip _debug_ info, not ELF/minimal symbols...
So the "return early" would have to be _after_ the
elf_read_minimal_symbols call:

 static void
 elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
 {
   bfd *abfd = objfile->obfd;
   struct elfinfo ei;

   memset ((char *) &ei, 0, sizeof (ei));
   bfd_map_over_sections (abfd, elf_locate_sections, (void *) & ei);
 
   elf_read_minimal_symbols (objfile, symfile_flags, &ei);

I don't know whether we can reorder that.  Maybe we can.

When I looked at this quickly yesterday, I saw that elf_location_sections
is what finds the stabs and mdebug sections:

static void
elf_locate_sections (bfd *ignore_abfd, asection *sectp, void *eip)
{
  struct elfinfo *ei;

  ei = (struct elfinfo *) eip;
  if (strcmp (sectp->name, ".stab") == 0)
    {
      ei->stabsect = sectp;
    }
  else if (strcmp (sectp->name, ".mdebug") == 0)
    {
      ei->mdebugsect = sectp;
    }
}

and it seemed to be that skipping the section location would make
the parts of  elf_symfile_read that actually read the symbols
be no-ops, because the stabsect/mdebusect pointers would be NULL.

But if returning early or something else works, that's fine.

> 
> As for the *_build_psymtabs functions, I am doing exactly that: if
> objfile->flags contains OBJF_READNEVER, then just return and do nothing.

Sure, that should work too.  It's just the difference between
skipping checking whether debug info is available (skipping before
calling into those), vs letting gdb do the work to figure out whether
debug info is available, but then ignore it.
The grep for "*_build_psymtabs" was intended as a pointer to find
what the relevant code is, including to look at the code that
is calling those functions, see if there's something to be done there.

> 
> The patch is almost ready for resubmission (well, I still need to figure
> out how to test the --readnow && --readnever scenario), but I want to
> make sure I got this part right.
> 

Thanks,
Pedro Alves

  reply	other threads:[~2017-11-24 13:18 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-06 20:54 [RFC/RFA] " Joel Brobecker
2016-07-12 14:27 ` Yao Qi
2016-10-04 18:07   ` Pedro Alves
2017-11-23  0:54     ` [PATCH v2] " Sergio Durigan Junior
2017-11-23 12:09       ` Pedro Alves
2017-11-23 17:21         ` Sergio Durigan Junior
2017-11-23 17:29           ` Pedro Alves
2017-11-24  4:54             ` Sergio Durigan Junior
2017-11-24 13:18               ` Pedro Alves [this message]
2017-11-24 20:27                 ` Sergio Durigan Junior
2017-11-27 19:13                   ` Pedro Alves
2017-11-29  0:59                     ` Sergio Durigan Junior
2017-11-29 12:23                       ` Pedro Alves
2017-11-23 15:59       ` Eli Zaretskii
2017-11-23 19:36         ` Sergio Durigan Junior
2016-10-04 18:06 ` [RFC/RFA] " Pedro Alves
2017-11-24 23:01 ` [PATCH v2] Add support for the --readnever command-line option Sergio Durigan Junior
2017-11-25  7:33   ` Eli Zaretskii
2017-11-25 16:41     ` Sergio Durigan Junior
2017-11-25 17:16       ` Eli Zaretskii
2017-11-29  1:21 ` [PATCH v3] Add support for the readnever concept Sergio Durigan Junior
2017-11-29  3:39   ` Eli Zaretskii
2017-11-29 12:25   ` Pedro Alves
2017-11-29 18:43     ` Sergio Durigan Junior
2017-11-29 21:45     ` [PATCH] Make 'symbol-file' not care about the position of command line arguments Sergio Durigan Junior
2017-11-29 22:26       ` Pedro Alves
2017-11-29 22:42         ` Sergio Durigan Junior
2017-11-29 23:15           ` Pedro Alves
2017-11-30  0:08             ` Sergio Durigan Junior
2017-11-30  0:34               ` Pedro Alves
2017-11-30  4:07                 ` Sergio Durigan Junior
2017-11-30  4:25       ` [PATCH v2] Make '{add-,}symbol-file' " Sergio Durigan Junior
2017-11-30 10:57         ` Pedro Alves
2017-11-30 12:38           ` Sergio Durigan Junior
2017-11-30 12:49             ` Pedro Alves
2017-11-30 13:06               ` Sergio Durigan Junior
2017-11-30 13:33       ` [PATCH v3] " Sergio Durigan Junior
2017-11-30 15:01         ` Pedro Alves
2017-11-30 17:26           ` Sergio Durigan Junior
2017-11-30 17:37             ` Pedro Alves
2017-11-30 17:43               ` Sergio Durigan Junior
2017-11-30 17:50                 ` Pedro Alves
2017-11-30 20:00       ` [PATCH v4] " Sergio Durigan Junior
2017-12-01 12:11         ` Pedro Alves
2017-12-01 17:41           ` Sergio Durigan Junior
2017-12-01 21:45             ` Pedro Alves
2017-12-01 22:02               ` Sergio Durigan Junior
2017-11-30  0:25 ` [PATCH v4] Add support for the readnever concept Sergio Durigan Junior
2017-11-30 11:53   ` Pedro Alves
2017-12-01  4:35     ` Sergio Durigan Junior
2017-12-01 12:43       ` Pedro Alves
2017-12-01 17:19         ` Tom Tromey
2017-12-01 17:21           ` Sergio Durigan Junior
2017-12-01 20:00             ` Pedro Alves
2017-12-01 22:16 ` [PATCH v5] " Sergio Durigan Junior
2017-12-01 23:19   ` Pedro Alves
2017-12-02  2:31     ` Sergio Durigan Junior
2017-12-02  8:21   ` Eli Zaretskii

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=a70f1f41-6ac1-699a-7d2c-bf0c5095809b@redhat.com \
    --to=palves@redhat.com \
    --cc=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=qiyaoltc@gmail.com \
    --cc=sergiodj@redhat.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).