public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "vries at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug breakpoints/26096] gdb sets breakpoint at cold clone
Date: Sat, 29 May 2021 10:38:24 +0000	[thread overview]
Message-ID: <bug-26096-4717-6aSkDKyTLO@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-26096-4717@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=26096

--- Comment #3 from Tom de Vries <vries at gcc dot gnu.org> ---
Another thing I noticed with cold clones:
...
$ gdb -q -batch a.out -ex "maint print psymbols" | egrep "foo|bar"
    `bar', function, 0x400455
    `foo', function, 0x400450
...

The psymbol address of the function bar is the address of "bar() [clone
.cold]".

Presumably we'd want the entry address here.

Looking at the corresponding DWARF, we have:
...
 <1><990>: Abbrev Number: 35 (DW_TAG_subprogram)
    <991>   DW_AT_name        : foo
    <995>   DW_AT_decl_file   : 1
    <996>   DW_AT_decl_line   : 8
    <997>   DW_AT_decl_column : 1
    <998>   DW_AT_type        : <0x39b>
    <99c>   DW_AT_ranges      : 0x40
    <9a0>   DW_AT_frame_base  : 1 byte block: 9c        (DW_OP_call_frame_cfa)
    <9a2>   DW_AT_GNU_all_call_sites: 1
    <9a2>   DW_AT_sibling     : <0x9b4>
...

In DWARF 4 standard 2.18 Entry Address we read:
...
If no DW_AT_entry_pc attribute is present, then the entry address is assumed to
be the same as the value of the DW_AT_low_pc attribute, if present; otherwise,
the entry address is unknown.
...

In this case, we have no DW_AT_entry_pc and no DW_AT_low_pc attribute. 
Arguably, this is a gcc bug.

Either way, in absence of a fix in gcc for this, we could adapt a
interpretation that the entry pc is the start address of the first range. At
least, this works for this exec:
...
    00000070 00000000004005b0 00000000004005d7
    00000070 0000000000400455 000000000040045a
    00000070 <End of list>
...

This also seems to be the current interpretation for full symtabs, AFAIU from
the comment for BLOCK_ENTRY_PC in block.h:
...
/* Define the "entry pc" for a block BL to be the lowest (start) address        
   for the block when all addresses within the block are contiguous.  If        
   non-contiguous, then use the start address for the first range in the        
   block.                                                                       
...

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  parent reply	other threads:[~2021-05-29 10:38 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-09 10:57 [Bug breakpoints/26096] New: " vries at gcc dot gnu.org
2020-06-09 13:17 ` [Bug breakpoints/26096] " vries at gcc dot gnu.org
2020-06-09 14:23 ` vries at gcc dot gnu.org
2021-05-29 10:38 ` vries at gcc dot gnu.org [this message]
2021-05-31 14:16 ` vries at gcc dot gnu.org
2021-05-31 14:35 ` vries at gcc dot gnu.org
2021-05-31 17:06 ` bernd.edlinger at hotmail dot de
2021-06-01 13:25 ` cvs-commit at gcc dot gnu.org
2021-06-01 13:33 ` vries at gcc dot gnu.org
2021-06-01 13:33 ` vries at gcc dot gnu.org
2021-06-01 14:14 ` bernd.edlinger at hotmail dot de

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=bug-26096-4717-6aSkDKyTLO@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.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).