diff options
author | Yao Qi <yao@codesourcery.com> | 2014-08-04 14:57:22 +0800 |
---|---|---|
committer | Yao Qi <yao@codesourcery.com> | 2014-09-19 16:53:27 +0800 |
commit | c3b7b696c231416ac90fd9cb7d5ce735b3683356 (patch) | |
tree | f3d672760699696e0dcda3b62d36a9af6da2a21a /gdb/testsuite | |
parent | 8e635c209bd7dbccd410953334a55ff5fc91e81b (diff) | |
download | gdb-c3b7b696c231416ac90fd9cb7d5ce735b3683356.zip gdb-c3b7b696c231416ac90fd9cb7d5ce735b3683356.tar.gz gdb-c3b7b696c231416ac90fd9cb7d5ce735b3683356.tar.bz2 |
Check function is GC'ed
I see the following fail on arm-none-eabi target,
(gdb) b 24^M
Breakpoint 1 at 0x4: file
../../../../git/gdb/testsuite/gdb.base/break-on-linker-gcd-function.cc,
line 24.^M
(gdb) FAIL: gdb.base/break-on-linker-gcd-function.exp: b 24
Currently, we are using flag has_section_at_zero to determine whether
address zero in debug info means the corresponding code has been
GC'ed, like this:
case DW_LNE_set_address:
address = read_address (abfd, line_ptr, cu, &bytes_read);
if (address == 0 && !dwarf2_per_objfile->has_section_at_zero)
{
/* This line table is for a function which has been
GCd by the linker. Ignore it. PR gdb/12528 */
However, this is incorrect on some bare metal targets, as .text
section is located at 0x0, so dwarf2_per_objfile->has_section_at_zero
is true. If a function is GC'ed by linker, the address is zero. GDB
thinks address zero is a function's address rather than this function
is GC'ed.
In this patch, we choose 'lowpc' got in read_file_scope to check
whether 'lowpc' is greater than zero. If it isn't, address zero really
means the function is GC'ed. In this patch, we pass 'lowpc' in
read_file_scope through handle_DW_AT_stmt_list and dwarf_decode_lines,
and to dwarf_decode_lines_1 finally.
This patch fixes the fail above. This patch also covers the path that
partial symbol isn't used, which is tested by starting gdb with
--readnow option.
It is regression tested on x86-linux with
target_board=dwarf4-gdb-index, and arm-none-eabi. OK to apply?
gdb:
2014-09-19 Yao Qi <yao@codesourcery.com>
* dwarf2read.c (dwarf_decode_lines): Update declaration.
(handle_DW_AT_stmt_list): Add argument 'lowpc'. Update
comments. Callers update.
(dwarf_decode_lines): Likewise.
(dwarf_decode_lines_1): Add argument 'lowpc'. Update
comments. Skip the line table if 'lowpc' is greater than
'address'. Don't check
dwarf2_per_objfile->has_section_at_zero.
gdb/testsuite:
2014-09-19 Yao Qi <yao@codesourcery.com>
* gdb.base/break-on-linker-gcd-function.exp: Move test into new
proc set_breakpoint_on_gcd_function. Invoke
set_breakpoint_on_gcd_function. Restart GDB with --readnow and
invoke set_breakpoint_on_gcd_function again.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/ChangeLog | 7 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/break-on-linker-gcd-function.exp | 24 |
2 files changed, 26 insertions, 5 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index a4b03dc..c421904 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2014-09-19 Yao Qi <yao@codesourcery.com> + + * gdb.base/break-on-linker-gcd-function.exp: Move test into new + proc set_breakpoint_on_gcd_function. Invoke + set_breakpoint_on_gcd_function. Restart GDB with --readnow and + invoke set_breakpoint_on_gcd_function again. + 2014-09-18 Doug Evans <dje@google.com> * gdb.dwarf2/symtab-producer.exp: New file. diff --git a/gdb/testsuite/gdb.base/break-on-linker-gcd-function.exp b/gdb/testsuite/gdb.base/break-on-linker-gcd-function.exp index e593b51..b8de1cd 100644 --- a/gdb/testsuite/gdb.base/break-on-linker-gcd-function.exp +++ b/gdb/testsuite/gdb.base/break-on-linker-gcd-function.exp @@ -41,9 +41,23 @@ if {[build_executable_from_specs $testfile.exp $testfile \ clean_restart $testfile -# Single hex digit -set xd {[0-9a-f]} +proc set_breakpoint_on_gcd_function {} { + # Single hex digit + set xd {[0-9a-f]} + + # This accepts e.g. "Breakpoint 1 at 0x40968a" (fixed GDB) + # but rejects e.g. "Breakpoint 1 at 0x4" (broken GDB). + gdb_test "b [gdb_get_line_number "gdb break here"]" \ + "Breakpoint \[0-9\] at 0x${xd}${xd}+: .*" +} + +set_breakpoint_on_gcd_function -# This accepts e.g. "Breakpoint 1 at 0x40968a" (fixed GDB) -# but rejects e.g. "Breakpoint 1 at 0x4" (broken GDB). -gdb_test "b [gdb_get_line_number "gdb break here"]" "Breakpoint \[0-9\] at 0x${xd}${xd}+: .*" +set saved_gdbflags $GDBFLAGS +set GDBFLAGS "$GDBFLAGS --readnow" +clean_restart ${testfile} +set GDBFLAGS $saved_gdbflags + +with_test_prefix "readnow" { + set_breakpoint_on_gcd_function +} |