aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.base
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2023-07-07 16:36:26 +0100
committerAndrew Burgess <aburgess@redhat.com>2023-07-10 10:49:59 +0100
commit3f3ffaca04967511fa14b5cb6ee4cd1ae3802c39 (patch)
tree60388b35e1c37a66f99d291a4265064c693ebbff /gdb/testsuite/gdb.base
parentc432a27df338c6720303c29eab18467cfc981cb8 (diff)
downloadgdb-3f3ffaca04967511fa14b5cb6ee4cd1ae3802c39.zip
gdb-3f3ffaca04967511fa14b5cb6ee4cd1ae3802c39.tar.gz
gdb-3f3ffaca04967511fa14b5cb6ee4cd1ae3802c39.tar.bz2
gdb: include location number in breakpoint error message
This commit improves the output of this previous commit: commit 2dc3457a454a35d0617dc1f9cc1db77468471f95 Date: Fri Oct 14 13:22:55 2022 +0100 gdb: include breakpoint number in testing condition error message The earlier commit extended the error message: Error in testing breakpoint condition: to include the breakpoint number, e.g.: Error in testing breakpoint condition 3: This commit extends takes this further, and includes the location number if the breakpoint has multiple locations, so we might now see: Error in testing breakpoint condition 3.2: Just as with how GDB reports a normal breakpoint stop, if a breakpoint only has a single location then the location number is not included, this keeps things nice and consistent. I've extended one of the tests to cover the new functionality. Approved-By: Pedro Alves <pedro@palves.net>
Diffstat (limited to 'gdb/testsuite/gdb.base')
-rw-r--r--gdb/testsuite/gdb.base/bp-cond-failure.c16
-rw-r--r--gdb/testsuite/gdb.base/bp-cond-failure.exp30
2 files changed, 34 insertions, 12 deletions
diff --git a/gdb/testsuite/gdb.base/bp-cond-failure.c b/gdb/testsuite/gdb.base/bp-cond-failure.c
index 2a9974b..8c226ed 100644
--- a/gdb/testsuite/gdb.base/bp-cond-failure.c
+++ b/gdb/testsuite/gdb.base/bp-cond-failure.c
@@ -15,16 +15,26 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-int
+static inline int __attribute__((__always_inline__))
foo ()
{
- return 0; /* Breakpoint here. */
+ return 0; /* Multi-location breakpoint here. */
+}
+
+static int __attribute__((noinline))
+bar ()
+{
+ int res = foo (); /* Single-location breakpoint here. */
+
+ return res;
}
int
main ()
{
- int res = foo ();
+ int res = bar ();
+
+ res = foo ();
return res;
}
diff --git a/gdb/testsuite/gdb.base/bp-cond-failure.exp b/gdb/testsuite/gdb.base/bp-cond-failure.exp
index cb57220..5fb5b0f 100644
--- a/gdb/testsuite/gdb.base/bp-cond-failure.exp
+++ b/gdb/testsuite/gdb.base/bp-cond-failure.exp
@@ -44,10 +44,7 @@ if { [is_address_zero_readable] } {
return
}
-# Where the breakpoint will be placed.
-set bp_line [gdb_get_line_number "Breakpoint here"]
-
-proc run_test { cond_eval access_type } {
+proc run_test { cond_eval access_type lineno nloc } {
clean_restart ${::binfile}
if { ![runto_main] } {
@@ -59,17 +56,23 @@ proc run_test { cond_eval access_type } {
}
# Setup the conditional breakpoint and record its number.
- gdb_breakpoint "${::srcfile}:${::bp_line} if (*(${access_type} *) 0) == 0"
+ gdb_breakpoint "${::srcfile}:${lineno} if (*(${access_type} *) 0) == 0"
set bp_num [get_integer_valueof "\$bpnum" "*UNKNOWN*"]
+ if { $nloc > 1 } {
+ set bp_num_pattern "${bp_num}.1"
+ } else {
+ set bp_num_pattern "${bp_num}"
+ }
+
gdb_test "continue" \
[multi_line \
"Continuing\\." \
- "Error in testing condition for breakpoint ${bp_num}:" \
+ "Error in testing condition for breakpoint ${bp_num_pattern}:" \
"Cannot access memory at address 0x0" \
"" \
- "Breakpoint ${bp_num}, foo \\(\\) at \[^\r\n\]+:${::bp_line}" \
- "${::decimal}\\s+\[^\r\n\]+Breakpoint here\[^\r\n\]+"]
+ "Breakpoint ${bp_num_pattern}, \(foo\|bar\) \\(\\) at \[^\r\n\]+:${lineno}" \
+ "${::decimal}\\s+\[^\r\n\]+ breakpoint here\\. \[^\r\n\]+"]
}
# If we're using a remote target then conditions could be evaulated
@@ -97,8 +100,17 @@ gdb_test_multiple "show breakpoint condition-evaluation" "" {
}
}
+# Where the breakpoint will be placed.
+set bp_line_multi_loc [gdb_get_line_number "Multi-location breakpoint here"]
+set bp_line_single_loc [gdb_get_line_number "Single-location breakpoint here"]
+
foreach_with_prefix access_type { "char" "short" "int" "long long" } {
foreach_with_prefix cond_eval $cond_eval_modes {
- run_test $cond_eval $access_type
+ with_test_prefix "multi-loc" {
+ run_test $cond_eval $access_type $bp_line_multi_loc 2
+ }
+ with_test_prefix "single-loc" {
+ run_test $cond_eval $access_type $bp_line_single_loc 1
+ }
}
}