public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: "Maciej W. Rozycki" <macro@embecosm.com>
Cc: gdb-patches@sourceware.org,  Richard Bunt <richard.bunt@linaro.org>
Subject: Re: [PATCH v2 2/3] GDB: Bring back the handling of DW_CC_program
Date: Tue, 28 Mar 2023 13:26:36 -0600	[thread overview]
Message-ID: <878rfgd6dv.fsf@tromey.com> (raw)
In-Reply-To: <alpine.DEB.2.20.2303281941270.15477@tpp.orcam.me.uk> (Maciej W. Rozycki's message of "Tue, 28 Mar 2023 19:48:42 +0100 (BST)")

>>>>> "Maciej" == Maciej W Rozycki <macro@embecosm.com> writes:

Maciej> Original code was removed with commit 6209cde4ddb8 ("Delete DWARF 
Maciej> psymtab code"), and then an update to complement commit 81873cc81eff 
Maciej> ("[gdb/symtab] Support DW_AT_main_subprogram with -readnow.") has also 
Maciej> been included here.

Sorry about that.

Maciej> NB this was discovered with and is covered by the test case included with 
Maciej> 3/3; it has been verified to trigger with GCC 4.4.7 and will likely also 
Maciej> with other configurations.

Maciej> +/* Return TRUE if the given DIE is the program's "main".  */
Maciej> +
Maciej> +static bool
Maciej> +dwarf2_func_is_main_p (struct die_info *die, struct dwarf2_cu *cu)
Maciej> +{
Maciej> +  if (dwarf2_flag_true_p (die, DW_AT_main_subprogram, cu))
Maciej> +    return true;
Maciej> +  struct attribute *attr = dwarf2_attr (die, DW_AT_calling_convention, cu);
Maciej> +  return (attr != nullptr
Maciej> +	  && attr->constant_value (DW_CC_normal) == DW_CC_program);

Should the DW_AT_calling_convention thing only apply to Fortran CUs?  I
have only ever heard of this approach being used by Fortran compilers.

Maciej> +	case DW_AT_calling_convention:
Maciej> +	  if (attr.constant_value (DW_CC_normal) == DW_CC_program)
Maciej> +	    *flags |= IS_MAIN;

Both the spots doing this check could probably use a comment explaining
why.  Maybe someday we'll get to remove this again.

Tom

  reply	other threads:[~2023-03-28 19:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-28 18:45 [PATCH v2 0/3] Fixes and improvements for the starting function Maciej W. Rozycki
2023-03-28 18:48 ` [PATCH v2 1/3] GDB: Favor full symbol main name for backtrace stop Maciej W. Rozycki
2023-03-28 18:48 ` [PATCH v2 2/3] GDB: Bring back the handling of DW_CC_program Maciej W. Rozycki
2023-03-28 19:26   ` Tom Tromey [this message]
2023-03-29 17:54     ` Maciej W. Rozycki
2023-03-28 18:49 ` [PATCH v2 3/3] GDB: Add `info main' command Maciej W. Rozycki
2023-03-28 19:01   ` 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=878rfgd6dv.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    --cc=macro@embecosm.com \
    --cc=richard.bunt@linaro.org \
    /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).