public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug symtab/31622] [gdb/symtab] find_epilogue_using_linetable fails to find entry in function with two linetables
Date: Wed, 24 Apr 2024 14:27:07 +0000	[thread overview]
Message-ID: <bug-31622-4717-xgzLyAwKrK@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-31622-4717@http.sourceware.org/bugzilla/>

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

--- Comment #2 from Sourceware Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Bernd Edlinger <edlinger@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=730f5068f5fb6613e4faa2efc2309cd107562cbd

commit 730f5068f5fb6613e4faa2efc2309cd107562cbd
Author: Bernd Edlinger <bernd.edlinger@hotmail.de>
Date:   Tue Apr 9 09:27:53 2024 +0000

    Handle two-linetable function in find_epilogue_using_linetable

    Consider the following test-case:
    ...
    $ cat hello.c
    int main()
    {
      printf("hello ");
      #include "world.inc"
    $ cat world.inc
      printf("world\n");
      return 0;
    }
    $ gcc -g hello.c
    ...

    The line table for the compilation unit, consisting just of
    function main, is translated into these two gdb line tables, one for
hello.c
    and one for world.inc:
    ...
    compunit_symtab: hello.c
    symtab: hello.c
    INDEX  LINE   REL-ADDRESS UNREL-ADDRESS IS-STMT PROLOGUE-END EPILOGUE-BEGIN
    0      3      0x400557    0x400557      Y
    1      4      0x40055b    0x40055b      Y
    2      END    0x40056a    0x40056a      Y

    compunit_symtab: hello.c
    symtab: world.inc
    INDEX  LINE   REL-ADDRESS UNREL-ADDRESS IS-STMT PROLOGUE-END EPILOGUE-BEGIN
    0      1      0x40056a    0x40056a      Y
    1      2      0x400574    0x400574      Y
    2      3      0x400579    0x400579      Y
    3      END    0x40057b    0x40057b      Y
    ...

    The epilogue of main starts at 0x400579:
    ...
      400579:       5d                      pop    %rbp
      40057a:       c3                      ret
    ...

    Now, say we have an epilogue_begin marker in the line table at 0x400579.

    We won't find it using find_epilogue_using_linetable, because it does:
    ...
      const struct symtab_and_line sal = find_pc_line (start_pc, 0);
    ...
    which gets us the line table for hello.c.

    Fix this by using "find_pc_line (end_pc - 1, 0)" instead.

    Tested on x86_64-linux.

    Co-Authored-By: Tom de Vries <tdevries@suse.de>

    PR symtab/31622
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31622

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

  parent reply	other threads:[~2024-04-24 14:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-09  6:59 [Bug symtab/31622] New: " vries at gcc dot gnu.org
2024-04-09  7:00 ` [Bug symtab/31622] " vries at gcc dot gnu.org
2024-04-10  8:08 ` vries at gcc dot gnu.org
2024-04-24 14:27 ` cvs-commit at gcc dot gnu.org [this message]
2024-04-24 15:20 ` bernd.edlinger at hotmail dot de
2024-04-24 21:13 ` vries at gcc dot gnu.org

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-31622-4717-xgzLyAwKrK@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).