aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/gdb.base/options.exp17
-rw-r--r--gdb/testsuite/gdb.python/py-source-styling.exp107
-rw-r--r--gdb/testsuite/gdb.rocm/precise-memory.cpp12
-rw-r--r--gdb/testsuite/gdb.rocm/precise-memory.exp38
-rw-r--r--gdb/testsuite/gdb.threads/infcall-from-bp-cond-simple.c2
-rw-r--r--gdb/testsuite/gdb.threads/infcall-from-bp-cond-simple.exp4
-rw-r--r--gdb/testsuite/lib/rocm.exp19
7 files changed, 148 insertions, 51 deletions
diff --git a/gdb/testsuite/gdb.base/options.exp b/gdb/testsuite/gdb.base/options.exp
index a1ca39e..8760a91 100644
--- a/gdb/testsuite/gdb.base/options.exp
+++ b/gdb/testsuite/gdb.base/options.exp
@@ -99,21 +99,21 @@ proc make_cmd {variant} {
# operand.
proc expect_none {operand} {
return "-flag 0 -xx1 0 -xx2 0 -bool 0 -enum xxx -uint-unl 0 -pint-unl 0\
- -string '' -filename '' -- $operand"
+ -string '' -filename '' -color magenta -- $operand"
}
# Return a string for the expected result of running "maint
# test-options xxx", with -flag set. OPERAND is the expected operand.
proc expect_flag {operand} {
return "-flag 1 -xx1 0 -xx2 0 -bool 0 -enum xxx -uint-unl 0 -pint-unl 0\
- -string '' -filename '' -- $operand"
+ -string '' -filename '' -color magenta -- $operand"
}
# Return a string for the expected result of running "maint
# test-options xxx", with -bool set. OPERAND is the expected operand.
proc expect_bool {operand} {
return "-flag 0 -xx1 0 -xx2 0 -bool 1 -enum xxx -uint-unl 0 -pint-unl 0\
- -string '' -filename '' -- $operand"
+ -string '' -filename '' -color magenta -- $operand"
}
# Return a string for the expected result of running "maint
@@ -123,10 +123,10 @@ proc expect_bool {operand} {
proc expect_integer {option val operand} {
if {$option == "uinteger-unlimited"} {
return "-flag 0 -xx1 0 -xx2 0 -bool 0 -enum xxx -uint-unl $val\
- -pint-unl 0 -string '' -filename '' -- $operand"
+ -pint-unl 0 -string '' -filename '' -color magenta -- $operand"
} elseif {$option == "pinteger-unlimited"} {
return "-flag 0 -xx1 0 -xx2 0 -bool 0 -enum xxx -uint-unl 0\
- -pint-unl $val -string '' -filename '' -- $operand"
+ -pint-unl $val -string '' -filename '' -color magenta -- $operand"
} else {
error "unsupported option: $option"
}
@@ -144,7 +144,7 @@ proc expect_string {str operand} {
set str [string range $str 1 end-1]
}
return "-flag 0 -xx1 0 -xx2 0 -bool 0 -enum xxx -uint-unl 0 -pint-unl 0\
- -string '$str' -filename '' -- $operand"
+ -string '$str' -filename '' -color magenta -- $operand"
}
# Return a string for the expected result of running "maint
@@ -159,11 +159,12 @@ proc expect_filename {str operand} {
set str [string range $str 1 end-1]
}
return "-flag 0 -xx1 0 -xx2 0 -bool 0 -enum xxx -uint-unl 0 -pint-unl 0\
- -string '' -filename '$str' -- $operand"
+ -string '' -filename '$str' -color magenta -- $operand"
}
set all_options {
"-bool"
+ "-color"
"-enum"
"-filename"
"-flag"
@@ -628,7 +629,7 @@ proc_with_prefix test-flag {variant} {
# Extract twice the same flag, separated by one space.
gdb_test "$cmd -xx1 -xx2 -xx1 -xx2 -xx1 -- non flags args" \
"-flag 0 -xx1 1 -xx2 1 -bool 0 -enum xxx -uint-unl 0 -pint-unl 0\
- -string '' -filename '' -- non flags args"
+ -string '' -filename '' -color magenta -- non flags args"
# Extract 2 known flags in front of unknown flags.
gdb_test "$cmd -xx1 -xx2 -a -b -c -xx1 --" \
diff --git a/gdb/testsuite/gdb.python/py-source-styling.exp b/gdb/testsuite/gdb.python/py-source-styling.exp
index ba7e795..8eed56b 100644
--- a/gdb/testsuite/gdb.python/py-source-styling.exp
+++ b/gdb/testsuite/gdb.python/py-source-styling.exp
@@ -33,12 +33,43 @@ if { [build_executable "failed to build" ${testfile} ${srcfile}] == -1 } {
set line_number [gdb_get_line_number "List this line."]
+# Helper proc. Run CMD, which should produce a source listing, and
+# check if the source code is styled or not. EXPECT_STYLED indicates
+# if we expect the source listing to be styled or not.
+proc check_source_listing_styling { cmd expect_styled { testname "" } } {
+ if { $testname eq "" } {
+ set testname $cmd
+ }
+
+ set seen_style_escape false
+ gdb_test_multiple $cmd $testname {
+ -re -wrap "Python Exception.*" {
+ fail $gdb_test_name
+ return
+ }
+ -re "\033" {
+ set seen_style_escape true
+ exp_continue
+ }
+ -re "$::gdb_prompt $" {
+ gdb_assert { $seen_style_escape == $expect_styled } \
+ $gdb_test_name
+ }
+ }
+}
+
# Check that the Python pygments module can be used for source
# highlighting when GNU source highlight is not available (or is
# disabled, as is done in this test).
proc test_pygments_styling {} {
clean_restart $::binfile
+ # Remote host boards disable styling via GDB's command line. Turn
+ # it back on now.
+ if {[is_remote host]} {
+ gdb_test "set style enabled on"
+ }
+
if { ![gdb_py_module_available "pygments"] } {
unsupported "pygments module not available"
return
@@ -52,19 +83,7 @@ proc test_pygments_styling {} {
gdb_test "maint flush source-cache" "Source cache flushed\\."
- set seen_style_escape false
- gdb_test_multiple "list $::line_number" "" {
- -re "Python Exception.*" {
- fail $gdb_test_name
- }
- -re "\033" {
- set seen_style_escape true
- exp_continue
- }
- -re "$::gdb_prompt $" {
- gdb_assert { $seen_style_escape } $gdb_test_name
- }
- }
+ check_source_listing_styling "list $::line_number" true
}
# Use gdb.execute to list source code containing non-utf-8 character.
@@ -93,6 +112,67 @@ proc test_gdb_execute_non_utf8_source {} {
gdb_test "python print(source)" ".*List this line.*"
}
+# Use gdb.execute() to list source code. Alternate between asking for
+# styled, and unstyled source code. In some cases we ask for the
+# output to be returned via a string, and in other cases we ask for
+# the output to be sent straight to stdout.
+proc_with_prefix test_source_cache_style_tracking {} {
+ clean_restart $::binfile
+
+ # Remote host boards disable styling via GDB's command line. Turn
+ # it back on now.
+ if {[is_remote host]} {
+ gdb_test "set style enabled on"
+ }
+
+ gdb_test_no_output "set host-charset ISO-8859-1"
+
+ # Commands which return styled, and non-styled source code mixed
+ # together. This ensures that the source cache will need to keep
+ # discarding the entry with the wrong styling mode. All of these
+ # gdb.execute calls send their output via a string.
+ check_source_listing_styling \
+ "python print(gdb.execute('list $::line_number', to_string=True), end='')" \
+ false
+ check_source_listing_styling \
+ "python print(gdb.execute('list $::line_number', to_string=True, styling=True), end='')" \
+ true
+ foreach from_tty { True False } {
+ check_source_listing_styling \
+ "python print(gdb.execute('list $::line_number', $from_tty, True), end='')" \
+ false
+ check_source_listing_styling \
+ "python print(gdb.execute('list $::line_number', $from_tty, True, True), end='')" \
+ true
+ check_source_listing_styling \
+ "python print(gdb.execute('list $::line_number', $from_tty, True, False), end='')" \
+ false
+ }
+
+ # The same again, but this time the output is sent directly to
+ # stdout.
+ check_source_listing_styling \
+ "python gdb.execute('list $::line_number')" \
+ true
+ check_source_listing_styling \
+ "python gdb.execute('list $::line_number', to_string=False, styling=False)" \
+ false
+ check_source_listing_styling \
+ "python gdb.execute('list $::line_number', to_string=False, styling=True)" \
+ true
+ foreach from_tty { True False } {
+ check_source_listing_styling \
+ "python gdb.execute('list $::line_number', $from_tty, False, False)" \
+ false
+ check_source_listing_styling \
+ "python gdb.execute('list $::line_number', $from_tty, False, True)" \
+ true
+ check_source_listing_styling \
+ "python gdb.execute('list $::line_number', $from_tty, False)" \
+ true
+ }
+}
+
# We need an ANSI-capable terminal to get the output, additionally we
# need to set LC_ALL so GDB knows the terminal is UTF-8 capable,
# otherwise we'll get a UnicodeEncodeError trying to encode the
@@ -100,4 +180,5 @@ proc test_gdb_execute_non_utf8_source {} {
with_ansi_styling_terminal {
test_pygments_styling
test_gdb_execute_non_utf8_source
+ test_source_cache_style_tracking
}
diff --git a/gdb/testsuite/gdb.rocm/precise-memory.cpp b/gdb/testsuite/gdb.rocm/precise-memory.cpp
index 769b58a..7a8c37e 100644
--- a/gdb/testsuite/gdb.rocm/precise-memory.cpp
+++ b/gdb/testsuite/gdb.rocm/precise-memory.cpp
@@ -31,7 +31,17 @@
__global__ void
kernel ()
{
- __builtin_amdgcn_s_sleep (1);
+
+ /* Simple kernel which loads from address 0 to trigger a pagefault.
+ When precise memory is not enabled, it is expected that the memory fault
+ is reported after the s_nop instruction. With precise-memory, the
+ exception should be reported on the s_nop. */
+ asm volatile ("s_mov_b64 [s10, s11], 0\n"
+ "s_load_dword s12, [s10, s11]\n"
+ "s_nop 0"
+ :
+ :
+ : "s10", "s11", "s12");
}
int
diff --git a/gdb/testsuite/gdb.rocm/precise-memory.exp b/gdb/testsuite/gdb.rocm/precise-memory.exp
index f423a11..8c39f80 100644
--- a/gdb/testsuite/gdb.rocm/precise-memory.exp
+++ b/gdb/testsuite/gdb.rocm/precise-memory.exp
@@ -39,18 +39,40 @@ proc do_test { } {
"AMDGPU precise memory access reporting is off \\(currently disabled\\)." \
"show precise-memory setting in CLI before"
- if {[hip_devices_support_precise_memory]} {
- gdb_test_no_output "set amdgpu precise-memory on"
- set cli_effective_value "enabled"
- } else {
- gdb_test "set amdgpu precise-memory on" \
- "warning: AMDGPU precise memory access reporting could not be enabled."
- set cli_effective_value "disabled"
+ # Assume precise-memory is available, unless GDB reports otherwise.
+ gdb_test_multiple "set amdgpu precise-memory on" "" {
+ -re -wrap "warning: AMDGPU precise memory access reporting could not be enabled\\." {
+ set cli_effective_value "disabled"
+ pass $gdb_test_name
+ }
+ -re -wrap "^" {
+ set cli_effective_value "enabled"
+ pass $gdb_test_name
+ }
}
gdb_test "show amdgpu precise-memory" \
- "AMDGPU precise memory access reporting is on \\(currently ${cli_effective_value}\\)." \
+ "AMDGPU precise memory access reporting is on \\(currently ${cli_effective_value}\\)\\." \
"show precise-memory setting in CLI after"
+
+ if { $cli_effective_value eq "disabled" } {
+ return
+ }
+
+ # Get to the begining of the GPU kernel without precise memory enabled.
+ with_test_prefix "goto gpu code" {
+ gdb_test_no_output "set amdgpu precise-memory off"
+ gdb_breakpoint "kernel" allow-pending
+ gdb_test "continue" "Thread ${::decimal}.* hit Breakpoint .*"
+ gdb_test_no_output "set amdgpu precise-memory on"
+ }
+
+ # If precise-memory is available, run until a SIGSEGV is reported. At
+ # that point, the PC should point to the s_nop instruction (the one
+ # following the one which caused the memory violation).
+ gdb_test "continue" "Thread ${::decimal}\[^\r\n\]* received signal SIGSEGV, Segmentation fault.*"
+
+ gdb_test "x/i \$pc" "=> ${::hex} <_Z6kernelv\\+${::decimal}>:\[ \t\]+s_nop\[ \t\]+0"
}
}
diff --git a/gdb/testsuite/gdb.threads/infcall-from-bp-cond-simple.c b/gdb/testsuite/gdb.threads/infcall-from-bp-cond-simple.c
index 2e23f12..d0707cd 100644
--- a/gdb/testsuite/gdb.threads/infcall-from-bp-cond-simple.c
+++ b/gdb/testsuite/gdb.threads/infcall-from-bp-cond-simple.c
@@ -43,6 +43,7 @@ function_that_segfaults ()
{
int *p = 0;
*p = 1; /* Segfault happens here. */
+ return 0;
}
int
@@ -55,6 +56,7 @@ void *
worker_func (void *arg)
{
int a = 42; /* Breakpoint here. */
+ return NULL;
}
void
diff --git a/gdb/testsuite/gdb.threads/infcall-from-bp-cond-simple.exp b/gdb/testsuite/gdb.threads/infcall-from-bp-cond-simple.exp
index c9508c9..feec37b 100644
--- a/gdb/testsuite/gdb.threads/infcall-from-bp-cond-simple.exp
+++ b/gdb/testsuite/gdb.threads/infcall-from-bp-cond-simple.exp
@@ -79,7 +79,7 @@ proc run_condition_test { message n_expected_hits condition \
gdb_breakpoint \
"${::srcfile}:${::cond_bp_line} if ((++\$n_cond_eval) && (${condition}))"
- # And a breakpoint that we hit when the test is over, this one is
+ # Add a breakpoint that we hit when the test is over, this one is
# not conditional. Only the main thread gets here once all the
# other threads have finished.
gdb_breakpoint "${::srcfile}:${::stop_bp_line}"
@@ -114,7 +114,7 @@ proc run_condition_test { message n_expected_hits condition \
# includes an inferior call), it is still possible to kill the running
# inferior, and then restart the inferior.
#
-# At once point doing this would result in GDB giving an assertion error.
+# At one point doing this would result in GDB giving an assertion error.
proc_with_prefix run_kill_and_restart_test { target_async target_non_stop } {
# This test relies on the 'start' command, which is not possible with
# the plain 'remote' target.
diff --git a/gdb/testsuite/lib/rocm.exp b/gdb/testsuite/lib/rocm.exp
index 3eb51db..5164f1e 100644
--- a/gdb/testsuite/lib/rocm.exp
+++ b/gdb/testsuite/lib/rocm.exp
@@ -176,22 +176,3 @@ proc hip_devices_support_debug_multi_process {} {
}
return 1
}
-
-# Return true if all the devices on the host support precise memory.
-
-proc hip_devices_support_precise_memory {} {
- set unsupported_targets \
- {gfx900 gfx906 gfx908 gfx1010 gfx1011 gfx1012 gfx1030 gfx1031 gfx1032}
-
- set targets [find_amdgpu_devices]
- if { [llength $targets] == 0 } {
- return 0
- }
-
- foreach target $targets {
- if { [lsearch -exact $unsupported_targets $target] != -1 } {
- return 0
- }
- }
- return 1
-}