aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuinevere Larsen <blarsen@redhat.com>2023-07-21 11:10:42 +0200
committerGuinevere Larsen <blarsen@redhat.com>2023-08-24 11:08:35 +0200
commit6e7db5d6bcc383766e10c2ea6f6bf01b629db1b0 (patch)
treea500e987482000bfed75c27618a2f6c9d03fecdb
parent890891f14de5f08a5e5bfa4a6907fb6ec409dd45 (diff)
downloadgdb-6e7db5d6bcc383766e10c2ea6f6bf01b629db1b0.zip
gdb-6e7db5d6bcc383766e10c2ea6f6bf01b629db1b0.tar.gz
gdb-6e7db5d6bcc383766e10c2ea6f6bf01b629db1b0.tar.bz2
gdb/testsuite: fix testing gdb.reverse/step-reverse.exp with clang
When testing using reverse-stepi to fully step through a function, the code checks for an infinite loop by seeing if we land on the line that contains the return statement multiple times. This assumption only works if there is only one instruction associated with that line, which is how GCC handles line information, but other compilers may handle it differently. Clang-15, for instance, associates 6. Because of this, the inferior used to get seriously out of sync with the test expectations, and result in 13 spurious failures. The same issue occurs with gdb.reverse/step-precsave.exp. This commit changes the test so that we check for PC instead of line number. The test still only happens when the same line is detected, to simplify the resulting log. With this change, no new failures are emitted when using clang. Approved-By: Tom Tromey <tom@tromey.com>
-rw-r--r--gdb/testsuite/gdb.reverse/step-precsave.exp10
-rw-r--r--gdb/testsuite/gdb.reverse/step-reverse.exp12
2 files changed, 20 insertions, 2 deletions
diff --git a/gdb/testsuite/gdb.reverse/step-precsave.exp b/gdb/testsuite/gdb.reverse/step-precsave.exp
index 19cd5d9..e297162 100644
--- a/gdb/testsuite/gdb.reverse/step-precsave.exp
+++ b/gdb/testsuite/gdb.reverse/step-precsave.exp
@@ -209,11 +209,19 @@ gdb_test_multiple "stepi" "$test_message" {
# stepi backward out of a function call
+set start_pc [get_hexadecimal_valueof "\$pc" 0 "getting PC at start of stepi backwards"]
+set step_count 0
set stepi_location [gdb_get_line_number "STEPI TEST" "$srcfile"]
set test_message "reverse stepi from a function call"
gdb_test_multiple "stepi" "$test_message" {
-re "ARRIVED IN CALLEE.*$gdb_prompt $" {
- fail "$test_message (start statement)"
+ incr step_count
+ if { [get_hexadecimal_valueof "\$pc" 0 "getting PC after $step_count steps"] == $start_pc } {
+ fail "$test_message (start statement)"
+ } else {
+ send_gdb "stepi\n"
+ exp_continue
+ }
}
-re "ENTER CALLEE.*$gdb_prompt $" {
send_gdb "stepi\n"
diff --git a/gdb/testsuite/gdb.reverse/step-reverse.exp b/gdb/testsuite/gdb.reverse/step-reverse.exp
index 4b78a8f..b7d00fb 100644
--- a/gdb/testsuite/gdb.reverse/step-reverse.exp
+++ b/gdb/testsuite/gdb.reverse/step-reverse.exp
@@ -174,11 +174,21 @@ gdb_test_multiple "stepi" "$test_message" {
# stepi backward out of a function call
+# When testing stepi, we dont want to infinitely step if we're not moving
+# so we store the starting PC, in case we land on the same line as above
+set start_pc [get_hexadecimal_valueof "\$pc" 0 "get PC at start"]
+set get_pc_count 0
set stepi_location [gdb_get_line_number "STEPI TEST" "$srcfile"]
set test_message "reverse stepi from a function call"
gdb_test_multiple "stepi" "$test_message" {
-re "ARRIVED IN CALLEE.*$gdb_prompt $" {
- fail "$test_message (start statement)"
+ incr get_pc_count
+ if { [get_hexadecimal_valueof "\$pc" 0 "get PC again $get_pc_count"] == $start_pc } {
+ fail "$test_message (start statement)"
+ } else {
+ send_gdb "stepi\n"
+ exp_continue
+ }
}
-re "ENTER CALLEE.*$gdb_prompt $" {
send_gdb "stepi\n"