binutils-gdb/gdb/testsuite/lib
Bernd Edlinger 730f5068f5 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
2024-04-24 16:00:38 +02:00
..
aarch64-scalable.exp
aarch64-test-sme.c
aarch64-test-sve.c
aarch64.exp
ada.exp [gdb/testsuite] Use find_gnatmake instead of gdb_find_gnatmake 2024-04-18 17:02:13 +02:00
append_gdb_boards_dir.exp
attributes.h
build-piece.exp
cache.exp
check-test-names.exp
cl_util.c
cl_util.h
compile-support.exp
compiler.c
compiler.cc
compiler.F90
completion-support.exp
cp-support.exp
d-support.exp
dap-support.exp
data-structures.exp
debuginfod-support.exp
dg-add-core-file-count.sh
dtrace.exp
dwarf.exp Handle two-linetable function in find_epilogue_using_linetable 2024-04-24 16:00:38 +02:00
fortran.exp
future.exp [gdb/testsuite] Use find_gnatmake instead of gdb_find_gnatmake 2024-04-18 17:02:13 +02:00
gdb-guile.exp
gdb-python.exp
gdb-utils.exp
gdb.exp gdb/testsuite: Use default gdb_expect timeout in runto 2024-04-22 13:10:33 -03:00
gdbserver-support.exp
gen-perf-test.exp
gnat_debug_info_test.adb
go.exp
jit-elf-helpers.exp
memory.exp
mi-support.exp
my-syscalls.h
my-syscalls.S
notty-wrap
objc.exp
opencl_hostapp.c
opencl_kernel.cl
opencl.exp
pascal.exp
pdtrace.in
perftest.exp
precise-aligned-alloc.c
prelink-support.exp
prompt.exp
range-stepping-support.exp
read1.c
rocm.exp
rust-support.exp
selftest-support.exp
set_unbuffered_mode.c
sym-info-cmds.exp
ton.tcl
trace-support.exp
tuiterm.exp
unbuffer_output.c
valgrind.exp