binutils-gdb/gdb/testsuite/gdb.trace/unavailable-dwarf-piece.exp
Andreas Arnez 194ed4130d Testsuite: Fix ambiguous "break" due to libinproctrace
Some of GDB's trace test cases define a function end() and place a
breakpoint there with "break end".  However, when libinproctrace is linked
to the binary, there are multiple methods named "end", such as
std::string::end() from the C++ library or format_pieces::end() from
common/format.h.  GDB then creates multiple breakpoints instead of just a
single one, and some FAILs result, such as these:

  FAIL: gdb.trace/trace-mt.exp: ftrace on: break end
  FAIL: gdb.trace/trace-mt.exp: ftrace off: break end

Fix this by adding the "-qualified" option to the break commands.  For
consistency, change all occurrences of "break end" (and similar) in all
trace test cases, even if the current behavior does not cause problems.
Also, consequently use the gdb_breakpoint convenience proc.

gdb/testsuite/ChangeLog:

	* gdb.trace/actions-changed.exp: Call gdb_breakpoint with the
	"qualified" option when setting breakpoints.
	* gdb.trace/backtrace.exp: Likewise.
	* gdb.trace/circ.exp: Likewise.
	* gdb.trace/collection.exp: Likewise.
	* gdb.trace/disconnected-tracing.exp: Likewise.
	* gdb.trace/ftrace-lock.exp: Likewise.
	* gdb.trace/ftrace.exp: Likewise.
	* gdb.trace/infotrace.exp: Likewise.
	* gdb.trace/packetlen.exp: Likewise.
	* gdb.trace/passc-dyn.exp: Likewise.
	* gdb.trace/qtro.exp: Likewise.
	* gdb.trace/read-memory.exp: Likewise.
	* gdb.trace/report.exp: Likewise.
	* gdb.trace/signal.exp: Likewise.
	* gdb.trace/status-stop.exp: Likewise.
	* gdb.trace/strace.exp: Likewise.
	* gdb.trace/tfind.exp: Likewise.
	* gdb.trace/trace-break.exp: Likewise.
	* gdb.trace/trace-condition.exp: Likewise.
	* gdb.trace/trace-mt.exp: Likewise.
	* gdb.trace/tstatus.exp: Likewise.
	* gdb.trace/tsv.exp: Likewise.
	* gdb.trace/unavailable-dwarf-piece.exp: Likewise.
	* gdb.trace/unavailable.exp: Likewise.
	* gdb.trace/while-dyn.exp: Likewise.
2018-03-19 13:13:09 +01:00

343 lines
8.1 KiB
Plaintext

# Copyright (C) 2013-2018 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
load_lib "trace-support.exp"
load_lib dwarf.exp
if {![dwarf2_support]} {
return 0
}
standard_testfile .c
set asm_file "${testfile}-dbg.s"
set opts {}
if { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile}1.o \
object {nodebug}] != "" } {
return -1
}
Dwarf::assemble $asm_file {
declare_labels uchar_label struct_s_label foo_label struct_t_label bar_label
cu {} {
compile_unit {{language @DW_LANG_C}} {
uchar_label: DW_TAG_base_type {
{name "unsigned char"}
{byte_size 1 DW_FORM_sdata}
{encoding @DW_ATE_unsigned_char}
}
struct_s_label: DW_TAG_structure_type {
{name s}
{byte_size 3 DW_FORM_sdata}
{decl_file 1 DW_FORM_sdata}
{decl_line 1 DW_FORM_sdata}
} {
DW_TAG_member {
{name a}
{type :$uchar_label}
{data_member_location {
DW_OP_plus_uconst 0
} SPECIAL_expr}
}
DW_TAG_member {
{name b}
{type :$uchar_label}
{data_member_location {
DW_OP_plus_uconst 1
} SPECIAL_expr}
}
DW_TAG_member {
{name c}
{type :$uchar_label}
{data_member_location {
DW_OP_plus_uconst 2
} SPECIAL_expr}
}
}
struct_t_label: DW_TAG_structure_type {
{name t}
{byte_size 3 DW_FORM_sdata}
{decl_file 1 DW_FORM_sdata}
{decl_line 1 DW_FORM_sdata}
} {
DW_TAG_member {
{name a}
{type :$uchar_label}
{data_member_location {
DW_OP_plus_uconst 0
} SPECIAL_expr}
}
DW_TAG_member {
{name b}
{type :$uchar_label}
{byte_size 1 DW_FORM_sdata}
{bit_size 1 DW_FORM_sdata}
{bit_offset 7 DW_FORM_sdata}
{data_member_location {
DW_OP_plus_uconst 1
} SPECIAL_expr}
}
DW_TAG_member {
{name c}
{type :$uchar_label}
{byte_size 1 DW_FORM_sdata}
{bit_size 1 DW_FORM_sdata}
{bit_offset 6 DW_FORM_sdata}
{data_member_location {
DW_OP_plus_uconst 1
} SPECIAL_expr}
}
DW_TAG_member {
{name d}
{type :$uchar_label}
{byte_size 1 DW_FORM_sdata}
{bit_size 1 DW_FORM_sdata}
{bit_offset 5 DW_FORM_sdata}
{data_member_location {
DW_OP_plus_uconst 1
} SPECIAL_expr}
}
DW_TAG_member {
{name e}
{type :$uchar_label}
{byte_size 1 DW_FORM_sdata}
{bit_size 1 DW_FORM_sdata}
{bit_offset 4 DW_FORM_sdata}
{data_member_location {
DW_OP_plus_uconst 1
} SPECIAL_expr}
}
DW_TAG_member {
{name f}
{type :$uchar_label}
{byte_size 1 DW_FORM_sdata}
{bit_size 1 DW_FORM_sdata}
{bit_offset 3 DW_FORM_sdata}
{data_member_location {
DW_OP_plus_uconst 1
} SPECIAL_expr}
}
DW_TAG_member {
{name g}
{type :$uchar_label}
{byte_size 1 DW_FORM_sdata}
{bit_size 1 DW_FORM_sdata}
{bit_offset 2 DW_FORM_sdata}
{data_member_location {
DW_OP_plus_uconst 1
} SPECIAL_expr}
}
DW_TAG_member {
{name h}
{type :$uchar_label}
{byte_size 1 DW_FORM_sdata}
{bit_size 1 DW_FORM_sdata}
{bit_offset 1 DW_FORM_sdata}
{data_member_location {
DW_OP_plus_uconst 1
} SPECIAL_expr}
}
DW_TAG_member {
{name i}
{type :$uchar_label}
{byte_size 1 DW_FORM_sdata}
{bit_size 1 DW_FORM_sdata}
{bit_offset 0 DW_FORM_sdata}
{data_member_location {
DW_OP_plus_uconst 1
} SPECIAL_expr}
}
DW_TAG_member {
{name j}
{type :$uchar_label}
{data_member_location {
DW_OP_plus_uconst 2
} SPECIAL_expr}
}
}
DW_TAG_subprogram {
{name foo}
{decl_file 1 sdata}
{low_pc foo_start_lbl addr}
{high_pc foo_end_lbl addr}
} {
DW_TAG_formal_parameter {
{type :$struct_s_label}
{name x}
{location {
DW_OP_lit0
DW_OP_stack_value
DW_OP_piece 2
DW_OP_reg0
DW_OP_piece 1
} SPECIAL_expr}
}
DW_TAG_formal_parameter {
{type :$struct_s_label}
{name y}
{location {
DW_OP_lit0
DW_OP_stack_value
DW_OP_piece 1
DW_OP_reg0
DW_OP_piece 1
DW_OP_lit0
DW_OP_stack_value
DW_OP_piece 1
} SPECIAL_expr}
}
DW_TAG_formal_parameter {
{type :$struct_s_label}
{name z}
{location {
DW_OP_reg0
DW_OP_piece 1
DW_OP_lit0
DW_OP_stack_value
DW_OP_piece 2
} SPECIAL_expr}
}
}
DW_TAG_subprogram {
{name bar}
{decl_file 1 sdata}
{low_pc bar_start_lbl addr}
{high_pc bar_end_lbl addr}
} {
DW_TAG_formal_parameter {
{type :$struct_t_label}
{name x}
{location {
DW_OP_lit0
DW_OP_stack_value
DW_OP_piece 1
DW_OP_reg0
DW_OP_bit_piece 1 0
DW_OP_lit0
DW_OP_stack_value
DW_OP_bit_piece 7 0
DW_OP_lit0
DW_OP_stack_value
DW_OP_piece 1
} SPECIAL_expr}
}
DW_TAG_formal_parameter {
{type :$struct_t_label}
{name y}
{location {
DW_OP_lit0
DW_OP_stack_value
DW_OP_piece 1
DW_OP_lit0
DW_OP_stack_value
DW_OP_bit_piece 3 0
DW_OP_reg0
DW_OP_bit_piece 1 0
DW_OP_lit0
DW_OP_stack_value
DW_OP_bit_piece 4 0
DW_OP_lit0
DW_OP_stack_value
DW_OP_piece 1
} SPECIAL_expr}
}
DW_TAG_formal_parameter {
{type :$struct_t_label}
{name z}
{location {
DW_OP_lit0
DW_OP_stack_value
DW_OP_piece 1
DW_OP_lit0
DW_OP_stack_value
DW_OP_bit_piece 7 0
DW_OP_reg0
DW_OP_bit_piece 1 0
DW_OP_lit0
DW_OP_stack_value
DW_OP_piece 1
} SPECIAL_expr}
}
}
}
}
}
if { [gdb_compile ${asm_file} ${binfile}2.o object {nodebug}] != "" } {
return -1
}
if { [gdb_compile [list ${binfile}1.o ${binfile}2.o] ${binfile} \
executable {}] != "" } {
return -1
}
clean_restart ${testfile}
if ![runto_main] {
return -1
}
if ![gdb_target_supports_trace] {
unsupported "target does not support trace"
return -1
}
gdb_breakpoint "end" qualified
with_test_prefix "tracing foo" {
gdb_test "trace *foo_start_lbl" ".*"
gdb_test_no_output "tstart"
gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*"
gdb_test_no_output "tstop"
gdb_test "tfind 0" "Found trace frame 0, tracepoint .*"
gdb_test "p/d x" "\\\$${decimal} = {a = 0, b = 0, c = <unavailable>}"
gdb_test "p/d y" "\\\$${decimal} = {a = 0, b = <unavailable>, c = 0}"
gdb_test "p/d z" "\\\$${decimal} = {a = <unavailable>, b = 0, c = 0}"
gdb_test "tfind none" "No longer looking at any trace frame.*"
}
with_test_prefix "tracing bar" {
gdb_test "trace *bar_start_lbl" ".*"
gdb_test_no_output "tstart"
gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*"
gdb_test_no_output "tstop"
set endian [get_endianness]
gdb_test "tfind 0" "Found trace frame 0, tracepoint .*"
if { $endian == "little" } {
gdb_test "p/d x" "\\\$${decimal} = {a = 0, b = <unavailable>, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0}"
gdb_test "p/d y" "\\\$${decimal} = {a = 0, b = 0, c = 0, d = 0, e = <unavailable>, f = 0, g = 0, h = 0, i = 0, j = 0}"
gdb_test "p/d z" "\\\$${decimal} = {a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = <unavailable>, j = 0}"
} else {
gdb_test "p/d x" "\\\$${decimal} = {a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = <unavailable>, j = 0}"
gdb_test "p/d y" "\\\$${decimal} = {a = 0, b = 0, c = 0, d = 0, e = 0, f = <unavailable>, g = 0, h = 0, i = 0, j = 0}"
gdb_test "p/d z" "\\\$${decimal} = {a = 0, b = <unavailable>, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0}"
}
gdb_test "tfind none" "No longer looking at any trace frame.*"
}