public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: Aaron Merey <amerey@redhat.com>
Cc: gdb-patches@sourceware.org, Tom Tromey <tom@tromey.com>
Subject: Re: [PATCH 1/2] [gdb/symtab] Add name_of_main and language_of_main to the DWARF index
Date: Tue, 24 Oct 2023 09:43:03 +0200	[thread overview]
Message-ID: <a1abb05b-a98f-4560-9d1a-db7510fca108@suse.de> (raw)
In-Reply-To: <CAJDtP-RFb3-V7mLCQbuz_Hr4KEniVnZY_tvSRrsJQF3u2LZcBQ@mail.gmail.com>

On 10/23/23 18:26, Aaron Merey wrote:
> Hi Tom,
> 
> I tried to generate a v9 .gdb_index for a hello world C program and
> for my local gdb build.  In both cases the name and language of the main
> function are missing.  I looked into this and it seems that main
> information is set in the index only when DW_AT_main_subprogram
> is found or DW_AT_calling_convention == DW_CC_program.
> 
>  From gcc/dwarf2out.cc:add_calling_convention_attribute it looks like
> DW_AT_main_subprogram is only set for Fortran programs.  And as far as
> I can tell DW_AT_calling_convention is not set for C/C++ programs.
> 
> Am I missing something or is the range of cases where a v9 index actually
> contains the name and laguage of main quite limited?  When writing an index
> maybe gdb should try to infer the main name and language from the current
> progspace if this information isn't available in the debuginfo.

Hi,

the current approach is to store information in the dwarf index that is 
available in the dwarf (more concretely, found by the cooked-index's 
get_main).

The benefits are:
- correctness (fixing the case that main_subprogram is ignored when we
   have a .gdb_index, which was my main concern (PR24549))
- speed (in the cases that it covers).

I tried out the C hello world with .gdb_index added, and indeed we end 
up expanding the CU to get the name of main, which can be slow if the CU 
is large (as the author points out in the commit log).  So agreed, we 
can add more cases for speed.

Implementation-wise, that looks non-trivial.

There are two paths to writing a .gdb_index:
- the save gdb-index command
- the index-cache.

In the former case, it's probably fairly easy to infer the main name and 
language from the current progspace, as you suggest, since 
set_initial_language has been executed already.

In the latter case, writing the index-cache is executed asap in the 
background, and it only waits for the cooked-index to become available. 
So it would have to wait for the result of set_initial_language as well.

Also (for both cases) some thought will have to go into how to handle 
the case that the initial language is set by the user.  Is that the 
language we want to write into the .gdb_index?  Or do we skip writing it 
in that case?  Or do we try to get the auto-detected initial language by 
running set_initial_language on the main thread at the point that we 
need it?  Or do we try to get the auto-detected initial language in the 
background on a worker thread?

Thanks,
- Tom


  reply	other threads:[~2023-10-24  7:42 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-06 18:31 [PATCH 0/2] " Tom de Vries
2023-10-06 18:31 ` [PATCH 1/2] [gdb/symtab] " Tom de Vries
2023-10-10 19:19   ` Tom Tromey
2023-10-10 19:22     ` Tom Tromey
2023-10-11 15:37     ` Tom de Vries
2023-10-23 16:26       ` Aaron Merey
2023-10-24  7:43         ` Tom de Vries [this message]
2023-10-24  8:04           ` Tom de Vries
2023-10-24  8:20           ` Tom de Vries
2023-10-24 22:04           ` Aaron Merey
2023-10-06 18:31 ` [PATCH 2/2] [readelf] Handle .gdb_index section version 9 Tom de Vries
2023-10-06 18:33 ` [PATCH 0/2] Add name_of_main and language_of_main to the DWARF index Tom de Vries

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=a1abb05b-a98f-4560-9d1a-db7510fca108@suse.de \
    --to=tdevries@suse.de \
    --cc=amerey@redhat.com \
    --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).