public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug symtab/31622] New: [gdb/symtab] find_epilogue_using_linetable fails to find entry in function with two linetables
@ 2024-04-09 6:59 vries at gcc dot gnu.org
2024-04-09 7:00 ` [Bug symtab/31622] " vries at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: vries at gcc dot gnu.org @ 2024-04-09 6:59 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=31622
Bug ID: 31622
Summary: [gdb/symtab] find_epilogue_using_linetable fails to
find entry in function with two linetables
Product: gdb
Version: HEAD
Status: NEW
Severity: normal
Priority: P2
Component: symtab
Assignee: unassigned at sourceware dot org
Reporter: vries at gcc dot gnu.org
Target Milestone: ---
Bernd Edlinger reported the following problem and fix in
find_epilogue_using_linetable (
https://sourceware.org/pipermail/gdb-patches/2024-April/207928.html ).
This came up in a discussion for a patch for PR31268, but it's an independent
issue.
Consider the following test-case:
...
$ cat hello.c
#include <stdio.h>
int main()
{
printf("hello ");
#include "world.inc"
/*** End of hello.c ***/
$ cat world.inc
printf("world\n");
return 0;
}
/*** End of world.inc ***/
$ gcc -g -o hello hello.c
...
The corresponding disassembly for main is:
...
0000000000400557 <main>:
400557: 55 push %rbp
400558: 48 89 e5 mov %rsp,%rbp
40055b: bf 24 06 40 00 mov $0x400624,%edi
400560: b8 00 00 00 00 mov $0x0,%eax
400565: e8 f6 fe ff ff call 400460 <printf@plt>
40056a: bf 2b 06 40 00 mov $0x40062b,%edi
40056f: e8 dc fe ff ff call 400450 <puts@plt>
400574: b8 00 00 00 00 mov $0x0,%eax
400579: 5d pop %rbp
40057a: c3 ret
...
And the corresponding line table is:
...
hello.c:
File name Line number Starting address View Stmt
hello.c 3 0x400557 x
hello.c 4 0x40055b x
./world.inc:[++]
world.inc 1 0x40056a x
world.inc 2 0x400574 x
world.inc 3 0x400579 x
world.inc - 0x40057b
...
Now, say we have an epilogue_begin marker at 0x400579 in world.inc.
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.
Proposed patch:
...
- const struct symtab_and_line sal = find_pc_line (start_pc, 0);
+ const struct symtab_and_line sal = find_pc_line (end_pc - 1, 0);
...
which gets us the linetable for world.inc instead.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug symtab/31622] [gdb/symtab] find_epilogue_using_linetable fails to find entry in function with two linetables
2024-04-09 6:59 [Bug symtab/31622] New: [gdb/symtab] find_epilogue_using_linetable fails to find entry in function with two linetables vries at gcc dot gnu.org
@ 2024-04-09 7:00 ` vries at gcc dot gnu.org
2024-04-10 8:08 ` vries at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: vries at gcc dot gnu.org @ 2024-04-09 7:00 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=31622
Tom de Vries <vries at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |bernd.edlinger at hotmail dot de
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug symtab/31622] [gdb/symtab] find_epilogue_using_linetable fails to find entry in function with two linetables
2024-04-09 6:59 [Bug symtab/31622] New: [gdb/symtab] find_epilogue_using_linetable fails to find entry in function with two linetables 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
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: vries at gcc dot gnu.org @ 2024-04-10 8:08 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=31622
--- Comment #1 from Tom de Vries <vries at gcc dot gnu.org> ---
https://sourceware.org/pipermail/gdb-patches/2024-April/207960.html
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug symtab/31622] [gdb/symtab] find_epilogue_using_linetable fails to find entry in function with two linetables
2024-04-09 6:59 [Bug symtab/31622] New: [gdb/symtab] find_epilogue_using_linetable fails to find entry in function with two linetables 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
2024-04-24 15:20 ` bernd.edlinger at hotmail dot de
2024-04-24 21:13 ` vries at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-04-24 14:27 UTC (permalink / raw)
To: gdb-prs
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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug symtab/31622] [gdb/symtab] find_epilogue_using_linetable fails to find entry in function with two linetables
2024-04-09 6:59 [Bug symtab/31622] New: [gdb/symtab] find_epilogue_using_linetable fails to find entry in function with two linetables vries at gcc dot gnu.org
` (2 preceding siblings ...)
2024-04-24 14:27 ` cvs-commit at gcc dot gnu.org
@ 2024-04-24 15:20 ` bernd.edlinger at hotmail dot de
2024-04-24 21:13 ` vries at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: bernd.edlinger at hotmail dot de @ 2024-04-24 15:20 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=31622
--- Comment #3 from Bernd Edlinger <bernd.edlinger at hotmail dot de> ---
fixed on master
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug symtab/31622] [gdb/symtab] find_epilogue_using_linetable fails to find entry in function with two linetables
2024-04-09 6:59 [Bug symtab/31622] New: [gdb/symtab] find_epilogue_using_linetable fails to find entry in function with two linetables vries at gcc dot gnu.org
` (3 preceding siblings ...)
2024-04-24 15:20 ` bernd.edlinger at hotmail dot de
@ 2024-04-24 21:13 ` vries at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: vries at gcc dot gnu.org @ 2024-04-24 21:13 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=31622
Tom de Vries <vries at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
Target Milestone|--- |15.1
--- Comment #4 from Tom de Vries <vries at gcc dot gnu.org> ---
Fixed.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-04-24 21:13 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-09 6:59 [Bug symtab/31622] New: [gdb/symtab] find_epilogue_using_linetable fails to find entry in function with two linetables 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
2024-04-24 15:20 ` bernd.edlinger at hotmail dot de
2024-04-24 21:13 ` vries at gcc dot gnu.org
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).