+2020-05-12 Tom de Vries <tdevries@suse.de>
+
+ * gdb.dwarf2/comp-unit-lang.exp: Use with_test_prefix.
+ * gdb.dwarf2/dw2-bad-parameter-type.exp: Same.
+ * gdb.dwarf2/implref-struct.exp: Same.
+ * gdb.dwarf2/varval.exp: Ensure get_sizeof is called once per type.
+ * gdb.dwarf2/data-loc.exp: Same. Remove duplicate test.
+
2020-05-11 Simon Marchi <simon.marchi@polymtl.ca>
* gdb.base/jit-so.exp (one_jit_test): Change test name.
gdb_test "show language" "\"auto; currently $gdb_lang\".*"
}
+proc do_test_with_prefix {cu_lang gdb_lang} {
+ with_test_prefix $gdb_lang {
+ do_test $cu_lang $gdb_lang
+ }
+}
+
# Some paths in the debugger fall back to C. Check C++ as well to
# make sure the test doesn't happen to work because of such a
# fallback.
-do_test DW_LANG_C "c"
-do_test DW_LANG_C_plus_plus "c\\+\\+"
+do_test_with_prefix DW_LANG_C "c"
+do_test_with_prefix DW_LANG_C_plus_plus "c\\+\\+"
} {
declare_labels integer_label array_label array_ptr_label
set int_size [get_sizeof "int" 4]
+ set voidp_size [get_sizeof "void *" 96]
integer_label: DW_TAG_base_type {
{DW_AT_byte_size $int_size DW_FORM_sdata}
{DW_AT_type :$integer_label}
{DW_AT_lower_bound {
DW_OP_push_object_address
- DW_OP_plus_uconst [get_sizeof "void *" 96]
+ DW_OP_plus_uconst $voidp_size
DW_OP_deref
- DW_OP_deref_size [get_sizeof "int" 4]
+ DW_OP_deref_size $int_size
} SPECIAL_expr}
{DW_AT_upper_bound {
DW_OP_push_object_address
- DW_OP_plus_uconst [get_sizeof "void *" 96]
+ DW_OP_plus_uconst $voidp_size
DW_OP_deref
- DW_OP_plus_uconst [get_sizeof "int" 4]
- DW_OP_deref_size [get_sizeof "int" 4]
+ DW_OP_plus_uconst $int_size
+ DW_OP_deref_size $int_size
} SPECIAL_expr}
}
}
gdb_test "ptype foo.five_tdef" \
"type = array \\(2 .. 6\\) of integer"
-gdb_test "ptype foo.array_type" \
- "type = array \\(<>\\) of integer"
-
gdb_test "print foo.five_tdef(2)" \
" = 5"
# The first access (as we do not use -readnow) prints some:
# Dwarf Error: Cannot find DIE at 0x0 referenced from DIE at 0x29 [in module ...]
-gdb_test "ptype f"
-
-gdb_test "ptype f"
+with_test_prefix "first" {
+ gdb_test "ptype f"
+}
+with_test_prefix "second" {
+ gdb_test "ptype f"
+}
gdb_test "p 5" " = 5" "is alive"
# Test assignment through the synthetic reference.
gdb_test_no_output "set (ref = s2)"
-foreach_with_prefix print-object {"off" "on"} {
- gdb_test_no_output "set print object ${print-object}"
+with_test_prefix "after assignment" {
+ foreach_with_prefix print-object {"off" "on"} {
+ gdb_test_no_output "set print object ${print-object}"
- gdb_test "print ref" " = \\(S &\\) @${address}: \\{${s2_members}\\}" "print ref after assignment"
- gdb_test "print s1" " = \\{${s2_members}\\}" "print s1 after assignment"
+ gdb_test "print ref" " = \\(S &\\) @${address}: \\{${s2_members}\\}" "print ref"
+ gdb_test "print s1" " = \\{${s2_members}\\}" "print s1"
+ }
}
if [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] {
return -1
}
+set int_size [get_sizeof "int" -1]
+# gdb always assumes references are implemented as pointers.
+set addr_size [get_sizeof "void *" -1]
proc setup_exec { arg_bad } {
global asm_file executable srcfile bad
# Create the DWARF.
Dwarf::assemble ${asm_file} {
- global srcdir subdir srcfile bad
+ global srcdir subdir srcfile bad int_size addr_size
cu {} {
DW_TAG_compile_unit {
varval2_label varval3_def_label varval3_decl_label \
int_array_label int_array_of_1_label
- set int_size [get_sizeof "int" -1]
-
- # gdb always assumes references are implemented as pointers.
- set addr_size [get_sizeof "void *" -1]
int_label: DW_TAG_base_type {
{DW_AT_byte_size ${int_size} DW_FORM_udata}