+2020-05-06 Tom de Vries <tdevries@suse.de>
+
+ * lib/gdb.exp (is_stmt_addresses, hex_in_list): New proc, factored out
+ of ...
+ * gdb.base/async.exp: ... here.
+ * gdb.base/consecutive.exp: Handle if 2nd breakpoint is at a
+ "recommended breakpoint location".
+
2020-05-06 Tom de Vries <tdevries@suse.de>
* gdb.compile/compile-ifunc.exp: Use -Wno-attribute-alias.
test_background "step&" "" " foo \\(\\) at .*async.c.*x = 5.*" "step& #2"
-set is_stmt [list]
-gdb_test_multiple "maint info line-table async.c" "" {
- -re "\r\n$decimal\[ \t\]+$decimal\[ \t\]+($hex)\[ \t\]+Y\[^\r\n\]*" {
- lappend is_stmt $expect_out(1,string)
- exp_continue
- }
- -re -wrap "" {
- pass $gdb_test_name
- }
-}
+set is_stmt [is_stmt_addresses $srcfile]
# Get the next instruction address.
set next_insn_addr ""
pass "$test"
}
}
-set next_insn_is_stmt \
- [expr [lsearch -regexp $is_stmt 0x0*$next_insn_addr] != -1]
+set next_insn_is_stmt [hex_in_list $next_insn_addr $is_stmt]
if { $next_insn_is_stmt } {
set prefix ""
continue
}
+set is_stmt [is_stmt_addresses $srcfile]
+
set nl "\[\r\n\]+"
gdb_breakpoint foo
"set bp, 2nd instr"
gdb_test_multiple "step" "stopped at bp, 2nd instr" {
- -re "Breakpoint $decimal, ($hex) in foo.*$gdb_prompt $" {
+ -re -wrap "Breakpoint $decimal, ($hex) in foo.*" {
set stop_addr $expect_out(1,string)
if [eval expr "$bp_addr == $stop_addr"] then {
pass "stopped at bp, 2nd instr"
fail "stopped at bp, 2nd instr (wrong address)"
}
}
+ -re -wrap "Breakpoint $decimal, foo.*" {
+ set stop_addr [get_valueof "/x" "\$pc" "" "value of pc"]
+ set stop_addr_is_stmt [hex_in_list $stop_addr $is_stmt]
+ if { ! $stop_addr_is_stmt } {
+ fail "stopped at bp, 2nd instr (missing hex prefix)"
+ } elseif [eval expr "$bp_addr == $stop_addr"] then {
+ pass "stopped at bp, 2nd instr"
+ } else {
+ fail "stopped at bp, 2nd instr (wrong address)"
+ }
+ }
}
return 0
}
+# Return the addresses in the line table for FILE for which is_stmt is true.
+
+proc is_stmt_addresses { file } {
+ global decimal
+ global hex
+
+ set is_stmt [list]
+
+ gdb_test_multiple "maint info line-table $file" "" {
+ -re "\r\n$decimal\[ \t\]+$decimal\[ \t\]+($hex)\[ \t\]+Y\[^\r\n\]*" {
+ lappend is_stmt $expect_out(1,string)
+ exp_continue
+ }
+ -re -wrap "" {
+ }
+ }
+
+ return $is_stmt
+}
+
+# Return 1 if hex number VAL is an element of HEXLIST.
+
+proc hex_in_list { val hexlist } {
+ # Normalize val by removing 0x prefix, and leading zeros.
+ set val [regsub ^0x $val ""]
+ set val [regsub ^0+ $val "0"]
+
+ set re 0x0*$val
+ set index [lsearch -regexp $hexlist $re]
+ return [expr $index != -1]
+}
+
# Always load compatibility stuff.
load_lib future.exp