diff options
Diffstat (limited to 'gdb/testsuite')
24 files changed, 1369 insertions, 219 deletions
diff --git a/gdb/testsuite/gdb.ada/operator_call.exp b/gdb/testsuite/gdb.ada/operator_call.exp index e96107b..dc7f679 100644 --- a/gdb/testsuite/gdb.ada/operator_call.exp +++ b/gdb/testsuite/gdb.ada/operator_call.exp @@ -71,6 +71,12 @@ proc test_with_menu {command result} { fail $command } } + "Argument to arithmetic operation not a number or boolean." { + fail $command + } + -re "No definition of \".*\" in current context." { + fail $command + } timeout { fail "$command (timeout)" } diff --git a/gdb/testsuite/gdb.arch/amd64-disp-step-self-call-alarm.c b/gdb/testsuite/gdb.arch/amd64-disp-step-self-call-alarm.c index 03b868c..0fb2904 100644 --- a/gdb/testsuite/gdb.arch/amd64-disp-step-self-call-alarm.c +++ b/gdb/testsuite/gdb.arch/amd64-disp-step-self-call-alarm.c @@ -16,9 +16,27 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <unistd.h> +#include <stdlib.h> + +extern void test_call (void); + +void +unreachable (void) +{ + abort (); +} void setup_alarm (void) { alarm (300); } + +int +main () +{ + setup_alarm (); + test_call (); + unreachable (); + return 0; +} diff --git a/gdb/testsuite/gdb.arch/amd64-disp-step-self-call.S b/gdb/testsuite/gdb.arch/amd64-disp-step-self-call.S index 78a6859..20a8eb7 100644 --- a/gdb/testsuite/gdb.arch/amd64-disp-step-self-call.S +++ b/gdb/testsuite/gdb.arch/amd64-disp-step-self-call.S @@ -18,33 +18,12 @@ handling. */ .text - - .global main -main: - nop - - callq setup_alarm - - nop - -/***********************************************/ - -/* test call/ret */ - .global test_call test_call: call test_call - nop + call unreachable .global test_ret_end test_ret_end: nop -/***********************************************/ - -/* all done */ - -done: - mov $0,%rdi - call exit - hlt .section .note.GNU-stack,"",@progbits diff --git a/gdb/testsuite/gdb.arch/i386-disp-step-self-call-alarm.c b/gdb/testsuite/gdb.arch/i386-disp-step-self-call-alarm.c index 03b868c..0fb2904 100644 --- a/gdb/testsuite/gdb.arch/i386-disp-step-self-call-alarm.c +++ b/gdb/testsuite/gdb.arch/i386-disp-step-self-call-alarm.c @@ -16,9 +16,27 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <unistd.h> +#include <stdlib.h> + +extern void test_call (void); + +void +unreachable (void) +{ + abort (); +} void setup_alarm (void) { alarm (300); } + +int +main () +{ + setup_alarm (); + test_call (); + unreachable (); + return 0; +} diff --git a/gdb/testsuite/gdb.arch/i386-disp-step-self-call.S b/gdb/testsuite/gdb.arch/i386-disp-step-self-call.S index 466e50c..20a8eb7 100644 --- a/gdb/testsuite/gdb.arch/i386-disp-step-self-call.S +++ b/gdb/testsuite/gdb.arch/i386-disp-step-self-call.S @@ -18,33 +18,12 @@ handling. */ .text - - .global main -main: - nop - - call setup_alarm - - nop - -/***********************************************/ - -/* test call/ret */ - .global test_call test_call: call test_call - nop + call unreachable .global test_ret_end test_ret_end: nop -/***********************************************/ - -/* all done */ - -done: - pushl $0 - call exit - hlt .section .note.GNU-stack,"",@progbits diff --git a/gdb/testsuite/gdb.base/backtrace-through-cu-nodebug.exp b/gdb/testsuite/gdb.base/backtrace-through-cu-nodebug.exp index 53bf642..fce6d67 100644 --- a/gdb/testsuite/gdb.base/backtrace-through-cu-nodebug.exp +++ b/gdb/testsuite/gdb.base/backtrace-through-cu-nodebug.exp @@ -31,7 +31,7 @@ proc prepare_test {has_cfi} { "${objcallerfile}" \ object [list {additional_flags=-fomit-frame-pointer \ -funwind-tables -fasynchronous-unwind-tables}]] != "" } { - untested "couldn't compile with cfi" + untested "couldn't compile" return false } } else { @@ -41,7 +41,7 @@ proc prepare_test {has_cfi} { object [list {additional_flags=-fomit-frame-pointer \ -fno-unwind-tables \ -fno-asynchronous-unwind-tables}]] != "" } { - untested "couldn't compile without cfi" + untested "couldn't compile" return false } } @@ -54,15 +54,12 @@ proc prepare_test {has_cfi} { clean_restart "$binfile-${extension}" - with_test_prefix "${extension}" { - - if ![runto callback] then { - fail "has_cfi=$has_cfi: Can't run to callback" - return false - } - gdb_test_no_output "maint frame-unwinder disable ARCH" - return true + if ![runto callback] then { + fail "has_cfi=$has_cfi: Can't run to callback" + return false } + gdb_test_no_output "maint frame-unwinder disable ARCH" + return true } if {[gdb_compile "${srcdir}/${subdir}/${srcfile2}" \ @@ -72,15 +69,45 @@ if {[gdb_compile "${srcdir}/${subdir}/${srcfile2}" \ return } -if { [prepare_test false] } { - gdb_test "bt" \ +proc_with_prefix no-cfi {} { + if { ![prepare_test false] } { + return + } + + set re_msg \ + [string_list_to_regexp \ + "Required frame unwinder may have been disabled," \ + " see 'maint info frame-unwinders'"] + set hs {[^\r\n]} + set re_bt_line "#0\\s+[string_to_regexp {callback ()}] $hs+" + set re_bt_no_filters \ [multi_line \ - "\[^\r\n\]+Required frame unwinder may have been disabled, \[^\r\n\]+" \ - "#0\\s+callback \\(\\) \[^\r\n\]+"] \ - "verify unwind fail without CFI" + $re_bt_line \ + $re_msg] + gdb_test "bt -no-filters" \ + $re_bt_no_filters \ + "verify no-filters unwind fail" + + # Flush frame cache to retrigger the message. + gdb_test "maint flush register-cache" \ + [string_to_regexp "Register cache flushed."] + + # This output may occur when we run into the message while applying the + # frame filters. + set re_bt \ + [multi_line \ + $hs+$re_msg \ + $re_bt_line] + gdb_test "bt" \ + "($re_bt|$re_bt_no_filters)" \ + "verify unwind fail" } -if { [prepare_test true] } { +proc_with_prefix cfi {} { + if { ![prepare_test true] } { + return + } + if { [istarget "arm*-*-*"] } { setup_kfail backtrace/31950 *-*-* } @@ -89,6 +116,12 @@ if { [prepare_test true] } { # #1 0x00000000004004e9 in caller () # #2 0x00000000004004cd in main () at ... gdb_test "bt" \ - "#0 +callback $text\r\n#1 $text in caller $text\r\n#2 $text in main $text" \ - "Verify unwinding works based only on CFI information" + [multi_line \ + "#0 +callback $text" \ + "#1 $text in caller $text" \ + "#2 $text in main $text"] \ + "Verify unwinding works" } + +no-cfi +cfi diff --git a/gdb/testsuite/gdb.base/break-dbg.exp b/gdb/testsuite/gdb.base/break-dbg.exp index 3652b8e..a7c7d92 100644 --- a/gdb/testsuite/gdb.base/break-dbg.exp +++ b/gdb/testsuite/gdb.base/break-dbg.exp @@ -46,7 +46,17 @@ gdb_test "catch load" "^Catchpoint $decimal \\(load\\)" gdb_test "catch unload" "^Catchpoint $decimal \\(unload\\)" gdb_test "catch signal" "^Catchpoint $decimal \\(standard signals\\)" -gdb_test "catch syscall" "^Catchpoint $decimal \\(any syscall\\)" + +set re_warning_xml_disabled \ + [string_to_regexp \ + [join \ + [list \ + "warning: Can not parse XML syscalls information;" \ + "XML support was disabled at compile time."]]] +gdb_test "catch syscall" \ + [multi_line \ + "^($re_warning_xml_disabled" \ + ")?Catchpoint $decimal [string_to_regexp {(any syscall)}]"] gdb_test "watch -l global_var" "\[Ww]atchpoint $decimal: -location global_var" diff --git a/gdb/testsuite/gdb.base/command-line-input.exp b/gdb/testsuite/gdb.base/command-line-input.exp index af228dc..9760f1a 100644 --- a/gdb/testsuite/gdb.base/command-line-input.exp +++ b/gdb/testsuite/gdb.base/command-line-input.exp @@ -18,19 +18,59 @@ # Test issuing a command split in multiple lines with continuation # characters. -gdb_exit -gdb_start +clean_restart -set test "print 1\\\\n + 2" -gdb_test_multiple "print 1\\\n + 2" $test { - -re "^print 1\\\\\r\n \\+ 2\r\n\\\$$decimal = 3\r\n$gdb_prompt $" { - pass $test +set bs "\\" +set re_bs [string_to_regexp $bs] +set re_dollar [string_to_regexp $] + +set re \ + [multi_line \ + ^[string_to_regexp "print 1$bs"] \ + [string_to_regexp " + 2"] \ + "$re_dollar$decimal = 3" \ + "$gdb_prompt $"] +gdb_test_multiple "print 1$bs\n + 2" "print 1$bs${bs}n + 2" { + -re $re { + pass $gdb_test_name + } +} + +set re \ + [multi_line \ + ^[string_to_regexp "print 1$bs"] \ + "2" \ + "$re_dollar$decimal = 12" \ + "$gdb_prompt $"] +gdb_test_multiple "print 1$bs\n2" "print 1$bs${bs}n2" { + -re $re { + pass $gdb_test_name } } -set test "print 1\\\\n2" -gdb_test_multiple "print 1\\\n2" $test { - -re "^print 1\\\\\r\n2\r\n\\\$$decimal = 12\r\n$gdb_prompt $" { - pass $test +with_test_prefix "cancel multiline" { + send_gdb "print$bs\n 1" + gdb_test_multiple "" "setup" { + -re "print$re_bs\r\n 1" { + pass $gdb_test_name + } + } + + send_gdb "\003" + gdb_test_multiple "" "cancel" { + -re -wrap "" { + pass $gdb_test_name + } + } + + # Regression test for PR cli/33063. + gdb_test_multiple "print 2" "command after cancel" { + -re -wrap " = 2" { + pass $gdb_test_name + } + -re -wrap "" { + # Avoid undefined command error. + fail $gdb_test_name + } } } diff --git a/gdb/testsuite/gdb.base/style.exp b/gdb/testsuite/gdb.base/style.exp index 503671b..47efb64 100644 --- a/gdb/testsuite/gdb.base/style.exp +++ b/gdb/testsuite/gdb.base/style.exp @@ -859,7 +859,7 @@ proc previous_line_is_ok { str } { # For lines that don't match this pattern, we cannot comment on # where the style reset should occur, so lets just claim the line # is fine. - if { ![regexp "\\s+$::hex - $::hex is \[^\r\n\]+ in " $str] } { + if { ![regexp "\\s+$::hex - $::hex is \[^\r\n\]+ in \033" $str] } { return true } @@ -923,8 +923,14 @@ proc test_pagination_prompt_styling {} { } } + if { $desired_width < [string length $::pagination_prompt_str] + 2 } { + # Avoid readline wrapping after printing the pagination prompt. + return + } + # Now setup the screen width. - gdb_test_no_output "set width $desired_width" + gdb_test_no_output "set width $desired_width" \ + "set width to desired width" # Re-run 'info files'. Check that the content before any # pagination prompt correctly disables styling. diff --git a/gdb/testsuite/gdb.base/wchar.exp b/gdb/testsuite/gdb.base/wchar.exp index 70f738c..f0e4777 100644 --- a/gdb/testsuite/gdb.base/wchar.exp +++ b/gdb/testsuite/gdb.base/wchar.exp @@ -72,3 +72,7 @@ gdb_test "print repeat_p" "= $hex L\"A$cent$cent\"\.\.\." \ # From PR cli/14977, but here because it requires wchar_t. gdb_test "printf \"%ls\\n\", 0" "\\(null\\)" + +# From PR exp/33124 - a bug when converting escapes. +set wbs {L'\\'} +gdb_test "print $wbs" " = $decimal [string_to_regexp $wbs]" diff --git a/gdb/testsuite/gdb.cp/static-print-quit.exp b/gdb/testsuite/gdb.cp/static-print-quit.exp index 8e0b61d..e4bce7f 100644 --- a/gdb/testsuite/gdb.cp/static-print-quit.exp +++ b/gdb/testsuite/gdb.cp/static-print-quit.exp @@ -27,32 +27,17 @@ clean_restart $testfile.o gdb_test_no_output "set width 80" gdb_test_no_output "set height 2" -set test "print c - <return>" -gdb_test_multiple "print c" $test { - -re "\\$\[0-9\]+ = \{loooooooooooooooooooooooooooooooooooooooooooooong = 0, static field = \{\r\n--Type <RET>" { - pass $test +gdb_test_multiple "print c" "" { + -re "\\$\[0-9\]+ = \{loooooooooooooooooooooooooooooooooooooooooooooong = 0, static field = \{\r\n$pagination_prompt$" { + pass $gdb_test_name } - -re "\r\n--Type <RET>" { + -re "\r\n$pagination_prompt$" { # gdb-7.1 did not crash with this testcase but it had the same bug. untested "bug does not reproduce" return 0 } } -set test "print c - q <return>" -gdb_test_multiple "" $test { - -re " for more, q to quit, " { - pass $test - } -} - -set test "print c - remainder" -gdb_test_multiple "" $test { - -re "c to continue without paging--$" { - pass $test - } -} - gdb_test "q" ".*" # Now the obstack is uninitialized. Exercise it. diff --git a/gdb/testsuite/gdb.dwarf2/debug-names-non-ascending-cu.exp b/gdb/testsuite/gdb.dwarf2/debug-names-non-ascending-cu.exp deleted file mode 100644 index d86b5c4..0000000 --- a/gdb/testsuite/gdb.dwarf2/debug-names-non-ascending-cu.exp +++ /dev/null @@ -1,81 +0,0 @@ -# Copyright 2022-2025 Free Software Foundation, Inc. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - -load_lib dwarf.exp - -# This test can only be run on targets which support DWARF-2 and use gas. -require dwarf2_support - -standard_testfile _start.c debug-names.S - -set func_info_vars \ - [get_func_info _start [list debug additional_flags=-nostartfiles]] - -# Create the DWARF. -set asm_file [standard_output_file $srcfile2] -Dwarf::assemble { - filename $asm_file - add_dummy_cus 0 -} { - global func_info_vars - foreach var $func_info_vars { - global $var - } - - cu { label cu_label } { - compile_unit {{language @DW_LANG_C}} { - subprogram { - {DW_AT_name _start} - {DW_AT_low_pc $_start_start DW_FORM_addr} - {DW_AT_high_pc $_start_end DW_FORM_addr} - } - } - } - - cu { label cu_label_2 } { - compile_unit {{language @DW_LANG_C}} { - base_type { - {name int} - {byte_size 4 sdata} - {encoding @DW_ATE_signed} - } - } - } - - debug_names {} { - cu cu_label_2 - cu cu_label - name _start subprogram cu_label 0xEDDB6232 - name int base_type cu_label 0xB888030 - } -} - -if [prepare_for_testing "failed to prepare" $testfile "${asm_file} ${srcfile}" \ - [list additional_flags=-nostartfiles]] { - return -1 -} - -# Check for warning. -set re \ - [list \ - "warning:" \ - "Section .debug_names has incorrect entry in CU table," \ - "ignoring .debug_names."] -set re [join $re] -gdb_assert {[regexp $re $gdb_file_cmd_msg]} "warning" - -# Verify that .debug_names section is ignored. -set index [have_index $binfile] -gdb_assert { [string equal $index ""] } ".debug_names not used" diff --git a/gdb/testsuite/gdb.dwarf2/dw-form-ref-addr-with-type-units.exp b/gdb/testsuite/gdb.dwarf2/dw-form-ref-addr-with-type-units.exp new file mode 100644 index 0000000..6253629 --- /dev/null +++ b/gdb/testsuite/gdb.dwarf2/dw-form-ref-addr-with-type-units.exp @@ -0,0 +1,109 @@ +# Copyright 2025 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# This is a reproducer for PR 29518: +# +# https://sourceware.org/bugzilla/show_bug.cgi?id=29518 +# +# The root cause for the problem was that function +# dwarf2_find_containing_comp_unit was searching the whole "all_units" vector, +# containing both compile units and type units, causing it to sometimes +# erroneously return a type unit. It should have been restricted to searching +# compile units. +# +# To get dwarf2_find_containing_comp_unit to be called and reproduce the +# original bug, we need a value with form DW_FORM_ref_addr pointing to a +# different compile unit. This is produced by `%$int_type` below. + +load_lib dwarf.exp +require dwarf2_support +standard_testfile main.c .S + +set asm_file [standard_output_file $srcfile2] + +Dwarf::assemble $asm_file { + global srcfile + declare_labels int_type + + # The source CU. + cu {version 4} { + compile_unit { + } { + subprogram { + {MACRO_AT_func {main}} + {type %$int_type} + } + } + } + + # Create a bunch of empty / dummy CUs, to make the offset of int_type a bit + # higher. + for {set i 1} {$i < 10} {incr i} { + cu {version 4} { + compile_unit {} {} + } + } + + # The target CU. + cu {version 4} { + compile_unit { + } { + int_type: DW_TAG_base_type { + {DW_AT_byte_size 4 DW_FORM_sdata} + {DW_AT_encoding @DW_ATE_signed} + {DW_AT_name int} + } + } + } + + # Create many TUs. + # + # We need enough type units in the "all_units" vector in order to steer the + # binary search in dwarf2_find_containing_comp_unit towards the type units + # region of the array. + for {set i 1} {$i < 20} {incr i} { + tu {version 4} $i the_type_i { + type_unit {} { + declare_labels dummy_int_type + + the_type_i: structure_type { + {name s} + {byte_size 4 sdata} + } { + member { + {name i} + {type :$dummy_int_type} + } + } + + dummy_int_type: base_type { + {name int} + {encoding @DW_ATE_signed} + {byte_size 4 sdata} + } + } + } + } +} + +if { [prepare_for_testing "failed to prepare" ${testfile} \ + [list $srcfile $asm_file] {nodebug}] } { + return -1 +} + +# Without the corresponding fix, we get an internal error: +# +# gdb/dwarf2/read.c:3940: internal-error: load_full_comp_unit: Assertion `! this_cu->is_debug_types' failed. +gdb_test "p main" " = {int \\(void\\)} $hex <main>" diff --git a/gdb/testsuite/gdb.dwarf2/varval.exp b/gdb/testsuite/gdb.dwarf2/varval.exp index 0693f43..6846ecb 100644 --- a/gdb/testsuite/gdb.dwarf2/varval.exp +++ b/gdb/testsuite/gdb.dwarf2/varval.exp @@ -348,6 +348,6 @@ if ![runto_main] { } gdb_test "print badval" "value has been optimized out" gdb_test "print bad_die_val1" \ - "invalid dwarf2 offset 0xabcdef11" + {DWARF Error: could not find unit containing offset 0xabcdef11 \[in module .*/varval\]} gdb_test "print bad_die_val2" \ "Bad DW_OP_GNU_variable_value DIE\\." diff --git a/gdb/testsuite/gdb.gdb/python-helper.exp b/gdb/testsuite/gdb.gdb/python-helper.exp index 4b9adb0..8126740 100644 --- a/gdb/testsuite/gdb.gdb/python-helper.exp +++ b/gdb/testsuite/gdb.gdb/python-helper.exp @@ -264,10 +264,28 @@ proc test_python_helper {} { gdb_test -prompt $outer_prompt_re "print varobj_table" \ "htab_t with ${::decimal} elements" + set inferior_list_supported 1 + set inferior_list_unsupported_re "type = intrusive_list" + gdb_test_multiple "what inferior_list" "" -prompt $outer_prompt_re { + -re -wrap $inferior_list_unsupported_re { + set inferior_list_supported 0 + pass $gdb_test_name + } + -re -wrap "" { + pass $gdb_test_name + } + } + # Test the intrusive_list pretty-printer. A bug occurred in the # pretty-printer for lists with more than one element. Verify that # we see both elements of the inferior_list list being printed. - gdb_test -prompt $outer_prompt_re "print inferior_list" "intrusive list of inferior = {.*, num = 1,.*, num = 2,.*}" + set test "print inferior_list" + if { $inferior_list_supported } { + gdb_test -prompt $outer_prompt_re $test \ + "intrusive list of inferior = {.*, num = 1,.*, num = 2,.*}" + } else { + unsupported $test + } return 0 } diff --git a/gdb/testsuite/gdb.multi/pending-bp.exp b/gdb/testsuite/gdb.multi/pending-bp.exp index 1cd1cfb..2458cd7 100644 --- a/gdb/testsuite/gdb.multi/pending-bp.exp +++ b/gdb/testsuite/gdb.multi/pending-bp.exp @@ -328,5 +328,7 @@ proc_with_prefix py_test_clear_thread {} { # Run all the tests. test_no_inf_display test_pending_toggle -py_test_toggle_thread -py_test_clear_thread +if { [allow_python_tests] } { + py_test_toggle_thread + py_test_clear_thread +} diff --git a/gdb/testsuite/gdb.python/py-cmd.exp b/gdb/testsuite/gdb.python/py-cmd.exp index 5ac5712..1fa3c73 100644 --- a/gdb/testsuite/gdb.python/py-cmd.exp +++ b/gdb/testsuite/gdb.python/py-cmd.exp @@ -278,13 +278,7 @@ gdb_test_multiline "input multi-line-output command" \ set test "verify pagination from test_multiline" gdb_test_multiple "test_multiline" $test { - -re "--Type <RET>" { - exp_continue - } - -re " for more, q to quit" { - exp_continue - } - -re ", c to continue without paging--$" { + -re "$pagination_prompt$" { pass $test } } diff --git a/gdb/testsuite/gdb.python/python.exp b/gdb/testsuite/gdb.python/python.exp index 6b2f671..96977df 100644 --- a/gdb/testsuite/gdb.python/python.exp +++ b/gdb/testsuite/gdb.python/python.exp @@ -152,13 +152,7 @@ gdb_test_no_output "set height $lines" set test "verify pagination beforehand" gdb_test_multiple "python print (\"\\n\" * $lines)" $test { - -re "--Type <RET>" { - exp_continue - } - -re " for more, q to quit" { - exp_continue - } - -re ", c to continue without paging--$" { + -re "$pagination_prompt$" { pass $test } } @@ -168,13 +162,7 @@ gdb_test "python if gdb.execute('python print (\"\\\\n\" * $lines)', to_string=T set test "verify pagination afterwards" gdb_test_multiple "python print (\"\\n\" * $lines)" $test { - -re "--Type <RET>" { - exp_continue - } - -re " for more, q to quit" { - exp_continue - } - -re ", c to continue without paging--$" { + -re "$pagination_prompt$" { pass $test } } diff --git a/gdb/testsuite/gdb.reverse/i386-avx-reverse.c b/gdb/testsuite/gdb.reverse/i386-avx-reverse.c index a37b65a..bf6cb77 100644 --- a/gdb/testsuite/gdb.reverse/i386-avx-reverse.c +++ b/gdb/testsuite/gdb.reverse/i386-avx-reverse.c @@ -30,6 +30,18 @@ char global_buf1[] = {0, 0, 0, 0, 0, 0, 0, 0, char *dyn_buf0; char *dyn_buf1; + /* Zero memory regions again, so that future tests can update them + without worry. */ +void +reset_buffers () +{ + for (int i = 0; i < 32; i++) + { + global_buf1[i] = 0; + dyn_buf1[i] = 0; + } +} + int vmov_test () { @@ -168,6 +180,22 @@ vmov_test () asm volatile ("vmovapd %%xmm0, %0" : : "m"(*dyn_buf1)); asm volatile ("vmovaps %%ymm15, %0" : : "m"(*dyn_buf1)); + /* Testing vmov[hl|lh]ps and vmov[h|l]pd. */ + asm volatile ("vmovhlps %xmm1, %xmm8, %xmm0"); + asm volatile ("vmovhlps %xmm1, %xmm2, %xmm15"); + asm volatile ("vmovlhps %xmm1, %xmm8, %xmm0"); + asm volatile ("vmovlhps %xmm1, %xmm2, %xmm15"); + + asm volatile ("vmovhps %0, %%xmm1, %%xmm0" : : "m"(buf0)); + asm volatile ("vmovhps %%xmm0, %0" : "=m" (buf1)); + asm volatile ("vmovhpd %0, %%xmm1, %%xmm15" : : "m"(global_buf0)); + asm volatile ("vmovhpd %%xmm15, %0" : "=m" (global_buf1)); + asm volatile ("vmovlpd %0, %%xmm1, %%xmm15" : : "m"(*dyn_buf0)); + asm volatile ("vmovlpd %%xmm15, %0" : "=m" (*dyn_buf1)); + + asm volatile ("vmovddup %xmm1, %xmm15"); + asm volatile ("vmovddup %ymm2, %ymm0"); + /* We have a return statement to deal with epilogue in different compilers. */ return 0; /* end vmov_test */ @@ -245,7 +273,7 @@ vpunpck_test () return 0; /* end vpunpck_test */ } -/* Test if we can record vpbroadcast instructions. */ +/* Test if we can record vpbroadcast and vbroadcast instructions. */ int vpbroadcast_test () { @@ -268,6 +296,14 @@ vpbroadcast_test () asm volatile ("vpbroadcastq %xmm1, %ymm0"); asm volatile ("vpbroadcastq %xmm1, %ymm15"); + asm volatile ("vbroadcastss %xmm1, %xmm0"); + asm volatile ("vbroadcastss %xmm1, %ymm15"); + asm volatile ("vbroadcastss %0, %%ymm0" : : "m" (global_buf0)); + asm volatile ("vbroadcastss %0, %%xmm15": : "m" (*dyn_buf0)); + asm volatile ("vbroadcastsd %xmm1, %ymm0"); + asm volatile ("vbroadcastsd %0, %%ymm15": : "m" (global_buf0)); + asm volatile ("vbroadcastf128 %0, %%ymm0" : : "m" (*dyn_buf0)); + /* We have a return statement to deal with epilogue in different compilers. */ return 0; /* end vpbroadcast_test */ @@ -372,6 +408,7 @@ arith_test () /* Using GDB, load these values onto registers for testing. ymm0.v8_float = {0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5} ymm1.v8_float = {0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5} + ymm2.v2_int128 = {0x0, 0x0} ymm15.v2_int128 = {0x0, 0x0} this way it's easy to confirm we're undoing things correctly. */ asm volatile ("vaddps %xmm0, %xmm1, %xmm15"); @@ -416,9 +453,318 @@ arith_test () asm volatile ("vmaxss %xmm0, %xmm1, %xmm15"); asm volatile ("vmaxsd %xmm0, %xmm1, %xmm15"); + /* Some sanity checks for other arithmetic instructions. */ + asm volatile ("vpaddb %xmm0, %xmm1, %xmm2"); + asm volatile ("vpaddw %xmm0, %xmm1, %xmm15"); + asm volatile ("vpaddd %ymm0, %ymm1, %ymm2"); + asm volatile ("vpaddq %ymm0, %ymm1, %ymm15"); + + asm volatile ("vpmullw %xmm0, %xmm1, %xmm2"); + asm volatile ("vpmulld %xmm0, %xmm1, %xmm15"); + asm volatile ("vpmulhw %ymm0, %ymm1, %ymm2"); + asm volatile ("vpmulhuw %ymm0, %ymm1, %ymm15"); + asm volatile ("vpmuludq %ymm0, %ymm1, %ymm15"); + + asm volatile ("vxorps %xmm0, %xmm1, %xmm2"); + asm volatile ("vxorpd %ymm0, %ymm1, %ymm2"); + asm volatile ("vpand %xmm0, %xmm1, %xmm15"); + asm volatile ("vpandn %ymm0, %ymm1, %ymm15"); + + asm volatile ("vpsadbw %xmm0, %xmm1, %xmm2"); + asm volatile ("vpsadbw %ymm0, %ymm1, %ymm15"); + return 0; /* end arith_test */ } +int +vaddsubpd_test () +{ + /* start vaddsubpd_test */ + /* YMM test. */ + asm volatile ("vaddsubpd %ymm15,%ymm1,%ymm0"); + asm volatile ("vaddsubpd %ymm0,%ymm1,%ymm15"); + asm volatile ("vaddsubpd %ymm2,%ymm3,%ymm4"); + + /* XMM test. */ + asm volatile ("vaddsubpd %xmm15,%xmm1,%xmm2"); + asm volatile ("vaddsubpd %xmm0,%xmm1,%xmm10"); + return 0; /* end vaddsubpd_test */ +} + +int +vaddsubps_test () +{ + /* start vaddsubps_test */ + /* YMM test. */ + asm volatile ("vaddsubps %ymm15,%ymm1,%ymm2"); + asm volatile ("vaddsubps %ymm0,%ymm1,%ymm10"); + asm volatile ("vaddsubps %ymm2,%ymm3,%ymm4"); + + /* XMM test. */ + asm volatile ("vaddsubps %xmm0,%xmm1,%xmm15"); + asm volatile ("vaddsubps %xmm15,%xmm1,%xmm0"); + return 0; /* end vaddsubps_test */ +} + + +/* Test record shifting instructions. */ +int +shift_test () +{ + /* start shift_test. */ + /* Using GDB, load these values onto registers for testing. + ymm0.v2_int128 = {0, 0} + ymm1.v16_int16 = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16} + xmm2.uint128 = 1 + ymm15.v2_int128 = {0x0, 0x0} + this way it's easy to confirm we're undoing things correctly. */ + + asm volatile ("vpsllw $1, %xmm1, %xmm0"); + asm volatile ("vpsllw %xmm2, %ymm1, %ymm0"); + asm volatile ("vpslld $3, %ymm1, %ymm15"); + asm volatile ("vpslld %xmm2, %xmm1, %xmm15"); + asm volatile ("vpsllq $5, %xmm1, %xmm15"); + asm volatile ("vpsllq %xmm2, %ymm1, %ymm15"); + + asm volatile ("vpsraw $1, %xmm1, %xmm0"); + asm volatile ("vpsraw %xmm2, %ymm1, %ymm0"); + asm volatile ("vpsrad $3, %ymm1, %ymm15"); + asm volatile ("vpsrad %xmm2, %xmm1, %xmm15"); + + asm volatile ("vpsrlw $1, %xmm1, %xmm0"); + asm volatile ("vpsrlw %xmm2, %ymm1, %ymm0"); + asm volatile ("vpsrld $3, %ymm1, %ymm15"); + asm volatile ("vpsrld %xmm2, %xmm1, %xmm15"); + asm volatile ("vpsrlq $5, %xmm1, %xmm15"); + asm volatile ("vpsrlq %xmm2, %ymm1, %ymm15"); + + /* The dq version is treated separately in the manual, so + we test it separately just to be sure. */ + asm volatile ("vpslldq $1, %xmm1, %xmm0"); + asm volatile ("vpslldq $2, %ymm1, %ymm0"); + asm volatile ("vpslldq $3, %xmm1, %xmm15"); + asm volatile ("vpslldq $4, %ymm1, %ymm15"); + + asm volatile ("vpsrldq $1, %xmm1, %xmm0"); + asm volatile ("vpsrldq $2, %ymm1, %ymm0"); + asm volatile ("vpsrldq $3, %xmm1, %xmm15"); + asm volatile ("vpsrldq $4, %ymm1, %ymm15"); + + return 0; /* end shift_test */ +} + +int +shuffle_test () +{ + /* start shuffle_test. */ + /* Using GDB, load these values onto registers for testing. + ymm0.v2_int128 = {0, 0} + ymm1.v16_int16 = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16} + ymm2.v16_int15 = {17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32} + ymm15.v2_int128 = {0x0, 0x0} + this way it's easy to confirm we're undoing things correctly. */ + + asm volatile ("vpshufb %xmm1, %xmm2, %xmm0"); + asm volatile ("vpshufb %ymm1, %ymm2, %ymm15"); + asm volatile ("vpshufd $1, %ymm2, %ymm0"); + asm volatile ("vpshufd $2, %xmm2, %xmm15"); + + asm volatile ("vpshufhw $3, %xmm2, %xmm0"); + asm volatile ("vpshufhw $4, %ymm2, %ymm15"); + asm volatile ("vpshuflw $5, %ymm2, %ymm0"); + asm volatile ("vpshuflw $6, %xmm2, %xmm15"); + + asm volatile ("vshufps $1, %xmm1, %xmm2, %xmm0"); + asm volatile ("vshufps $2, %ymm1, %ymm2, %ymm15"); + asm volatile ("vshufpd $4, %ymm1, %ymm2, %ymm0"); + asm volatile ("vshufpd $8, %xmm1, %xmm2, %xmm15"); + + return 0; /* end shuffle_test */ +} + +int +permute_test () +{ + /* start permute_test. */ + /* Using GDB, load these values onto registers for testing. + ymm0.v2_int128 = {0, 0} + ymm1.v16_int16 = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16} + ymm2.v16_int16 = {17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32} + ymm15.v2_int128 = {0x0, 0x0} + eax = 0 + this way it's easy to confirm we're undoing things correctly. */ + asm volatile ("vperm2f128 $1, %ymm1, %ymm2, %ymm0"); + asm volatile ("vperm2f128 $0, %ymm1, %ymm2, %ymm15"); + asm volatile ("vperm2i128 $1, %ymm2, %ymm1, %ymm0"); + asm volatile ("vperm2i128 $0, %ymm2, %ymm1, %ymm15"); + + asm volatile ("vpermd %ymm1, %ymm2, %ymm0"); + asm volatile ("vpermd %ymm1, %ymm2, %ymm15"); + asm volatile ("vpermq $1, %ymm1, %ymm0"); + asm volatile ("vpermq $0, %ymm2, %ymm15"); + + asm volatile ("vpermilpd %ymm1, %ymm2, %ymm0"); + asm volatile ("vpermilpd %xmm1, %xmm2, %xmm15"); + asm volatile ("vpermilpd $1, %ymm2, %ymm15"); + asm volatile ("vpermilpd $0, %xmm2, %xmm0"); + asm volatile ("vpermilps %ymm1, %ymm2, %ymm0"); + asm volatile ("vpermilps %xmm1, %xmm2, %xmm15"); + asm volatile ("vpermilps $1, %ymm2, %ymm15"); + asm volatile ("vpermilps $0, %xmm2, %xmm0"); + + asm volatile ("vpermpd $0, %ymm1, %ymm15"); + asm volatile ("vpermpd $0, %ymm2, %ymm0"); + asm volatile ("vpermps %ymm1, %ymm2, %ymm0"); + asm volatile ("vpermps %ymm1, %ymm2, %ymm15"); + + return 0; /* end permute_test */ +} + +int +extract_insert_test () +{ + /* start extract_insert_test. */ + /* Using GDB, load these values onto registers for testing. + ymm0.v2_int128 = {0, 0} + ymm1.v16_int16 = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16} + xmm2.uint128 = 0xcafe + ymm15.v2_int128 = {0x0, 0x0} + eax = 0 + this way it's easy to confirm we're undoing things correctly. */ + + asm volatile ("vinserti128 $1, %xmm2, %ymm1, %ymm0"); + asm volatile ("vinsertf128 $0, %xmm2, %ymm1, %ymm15"); + asm volatile ("vextracti128 $1, %ymm1, %xmm0"); + asm volatile ("vextractf128 $0, %ymm1, %xmm15"); + asm volatile ("vinsertps $16, %xmm2, %xmm1, %xmm0"); + asm volatile ("vextractps $0, %xmm2, %rax"); + + asm volatile ("vpextrb $5, %xmm1, %rax"); + asm volatile ("vpextrb $4, %%xmm1, %0" : "=m" (global_buf1)); + asm volatile ("vpextrd $3, %xmm1, %eax"); + asm volatile ("vpextrd $2, %%xmm1, %0" : "=m" (global_buf1)); + asm volatile ("vpextrq $1, %xmm1, %rax"); + asm volatile ("vpextrq $0, %%xmm1, %0" : "=m" (global_buf1)); + + asm volatile ("vpinsrb $3, %rax, %xmm2, %xmm0"); + asm volatile ("vpinsrw $2, %eax, %xmm2, %xmm15"); + asm volatile ("vpinsrd $1, %eax, %xmm2, %xmm0"); + asm volatile ("vpinsrq $0, %rax, %xmm2, %xmm15"); + + /* vpextrw has completely different mechanics to other vpextr + instructions, so separate them for ease of testing later. */ + asm volatile ("vpextrw $1, %xmm1, %eax"); + asm volatile ("vpextrw $1, %%xmm1, %0" : "=m" (global_buf1)); + + return 0; /* end extract_insert_test */ +} + +int +blend_test () +{ + /* start blend_test. */ + /* Using GDB, load these values onto registers for testing. + ymm0.v2_int128 = {0, 0} + ymm1.v16_int16 = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16} + ymm2.v16_int16 = {17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32} + ymm15.v2_int128 = {0x0, 0x0} + this way it's easy to confirm we're undoing things correctly. */ + + asm volatile ("vblendps $5, %xmm1, %xmm2, %xmm0"); + asm volatile ("vblendpd $10, %ymm1, %ymm2, %ymm15"); + asm volatile ("vblendvps %ymm15, %ymm1, %ymm2, %ymm0"); + asm volatile ("vblendvpd %xmm0, %xmm1, %xmm2, %xmm15"); + + asm volatile ("vpblendw $94, %ymm1, %ymm2, %ymm15"); + asm volatile ("vpblendw $47, %xmm1, %xmm2, %xmm0"); + asm volatile ("vpblendd $22, %ymm1, %ymm2, %ymm0"); + asm volatile ("vpblendd $11, %xmm1, %xmm2, %xmm15"); + asm volatile ("vpblendvb %xmm0, %xmm1, %xmm2, %xmm15"); + asm volatile ("vpblendvb %ymm0, %ymm1, %ymm2, %ymm0"); + + return 0; /* end blend_test */ +} + +int +compare_test () +{ + /* start compare_test. */ + /* Using GDB, load these values onto registers for testing. + xmm0.v4_float = {0, 1.5, 2, 0} + xmm1.v4_float = {0, 1, 2.5, -1} + xmm15.v4_float = {-1, -2, 10, 100} + eflags = 2 + eflags can't be set to some values, if we set it to 0, it'll + be reset to 2, so set it to that directly to make results less + confusing. + this way it's easy to confirm we're undoing things correctly. */ + + asm volatile ("vcomisd %xmm0, %xmm1"); + asm volatile ("vcomiss %xmm15, %xmm1"); + asm volatile ("vucomiss %xmm1, %xmm15"); + asm volatile ("vucomisd %xmm15, %xmm0"); + + return 0; /* end compare_test */ +} + +int +pack_test () +{ + /* start pack_test. */ + /* Using GDB, load these values onto registers for testing. + xmm0.v4_float = {0, 1.5, 2, 0} + xmm1.v4_float = {0, 1, 2.5, -1} + xmm2.v4_float = {0, 1, 2.5, -1} + xmm15.v4_float = {-1, -2, 10, 100} + this way it's easy to confirm we're undoing things correctly. */ + + asm volatile ("vpacksswb %xmm1, %xmm2, %xmm0"); + asm volatile ("vpacksswb %ymm1, %ymm2, %ymm15"); + asm volatile ("vpackssdw %xmm1, %xmm2, %xmm15"); + asm volatile ("vpackssdw %ymm1, %ymm2, %ymm0"); + asm volatile ("vpackuswb %xmm1, %xmm2, %xmm0"); + asm volatile ("vpackuswb %ymm1, %ymm2, %ymm15"); + asm volatile ("vpackusdw %xmm1, %xmm2, %xmm15"); + asm volatile ("vpackusdw %ymm1, %ymm2, %ymm0"); + + return 0; /* end pack_test */ +} + +int +convert_test () +{ + /* start convert_test. */ + /* Using GDB, load these values onto registers for testing. + xmm0.v2_int128 = {0, 0} + xmm1.v4_float = {0, 1, 2.5, 10} + xmm15.v2_int128 = {0, 0} + ecx = -1 + ebx = 0 + this way it's easy to confirm we're undoing things correctly. */ + + asm volatile ("vcvtdq2ps %xmm1, %xmm0"); + asm volatile ("vcvtdq2pd %xmm1, %xmm15"); + + asm volatile ("vcvtps2dq %xmm1, %xmm15"); + asm volatile ("vcvtps2pd %xmm1, %xmm0"); + asm volatile ("vcvtpd2ps %xmm1, %xmm15"); + asm volatile ("vcvtpd2dq %xmm1, %xmm0"); + + asm volatile ("vcvtsd2si %xmm1, %rbx"); + asm volatile ("vcvtsd2ss %xmm0, %xmm1, %xmm15"); + asm volatile ("vcvtsi2sd %rcx, %xmm1, %xmm0"); + asm volatile ("vcvtsi2ss %rcx, %xmm1, %xmm15"); + asm volatile ("vcvtss2sd %xmm15, %xmm1, %xmm0"); + asm volatile ("vcvtss2si %xmm1, %rbx"); + + asm volatile ("vcvttpd2dq %xmm1, %xmm0"); + asm volatile ("vcvttps2dq %xmm1, %xmm15"); + asm volatile ("vcvttsd2si %xmm0, %rbx"); + asm volatile ("vcvttss2si %xmm1, %ecx"); + + return 0; /* end convert_test */ +} + /* This include is used to allocate the dynamic buffer and have the pointers aligned to a 32-bit boundary, so we can test instructions that require aligned memory. */ @@ -442,6 +788,7 @@ main () asm volatile ("vmovq %0, %%xmm15": : "m" (global_buf1)); vmov_test (); + reset_buffers (); vpunpck_test (); vpbroadcast_test (); vzeroupper_test (); @@ -449,5 +796,15 @@ main () vpcmpeq_test (); vpmovmskb_test (); arith_test (); + vaddsubpd_test (); + vaddsubps_test (); + shift_test (); + shuffle_test (); + permute_test (); + extract_insert_test (); + blend_test (); + compare_test (); + pack_test (); + convert_test (); return 0; /* end of main */ } diff --git a/gdb/testsuite/gdb.reverse/i386-avx-reverse.exp b/gdb/testsuite/gdb.reverse/i386-avx-reverse.exp index 00f58f8..fb04260 100644 --- a/gdb/testsuite/gdb.reverse/i386-avx-reverse.exp +++ b/gdb/testsuite/gdb.reverse/i386-avx-reverse.exp @@ -149,6 +149,33 @@ global decimal if {[record_full_function "vmov"] == true} { # Now execute backwards, checking all instructions. + test_one_register "vmovddup" "ymm0" \ + "0x3736353433323130c004000000000000, 0x0" + test_one_register "vmovddup" "ymm15" \ + "0x2726252423222120, 0x0" + test_one_memory "vmovlpd" "dyn_buf1" \ + "\\\{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x28" \ + true + test_one_register "vmovlpd" "ymm15" \ + "0x1716151413121110c004000000000000, 0x0" + test_one_memory "vmovhpd" "global_buf1" \ + "\\\{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x18" + test_one_register "vmovhpd" "ymm15" \ + "0xc004000000000000c004000000000000, 0x0" + test_one_memory "vmovhps" "buf1" \ + "\\\{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x38" + test_one_register "vmovhps" "ymm0" \ + "0xc004000000000000c004000000000000, 0x0" + + test_one_register "vmovlhps" "ymm15" \ + "0x0, 0x0" + test_one_register "vmovlhps" "ymm0" \ + "0x0, 0x0" + test_one_register "vmovhlps" "ymm15" \ + "0x2f2e2d2c2b2a29280000000000000000, 0x2f2e2d2c2b2a29282726252423222120" + test_one_register "vmovhlps" "ymm0" \ + "0x2f2e2d2c2b2a29282726252423222120, 0x0" + # Explicitly test for the start of the array, since the value repeats. test_one_memory "vmovaps" "dyn_buf1" \ "\\\{0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28" true @@ -365,6 +392,24 @@ gdb_test_no_output "set \$xmm1.v2_int64 = {0x1716151413121110, 0x1f1e1d1c1b1a191 "set xmm1 for vpbroadcast" gdb_test_no_output "set \$ymm15.v2_int128 = {0x0, 0x0}" "set xmm15 for vpbroadcast" if {[record_full_function "vpbroadcast"] == true} { + test_one_register "vbroadcastf128" "ymm0" \ + "0x17161514131211101716151413121110, 0x17161514131211101716151413121110" + test_one_register "vbroadcastsd" "ymm15" \ + "0x23222120232221202322212023222120, 0x0" + test_one_register "vbroadcastsd" "ymm0" \ + "0x13121110131211101312111013121110, 0x13121110131211101312111013121110" + + test_one_register "vbroadcastss" "ymm15" \ + "0x13121110131211101312111013121110, 0x13121110131211101312111013121110" \ + "broadcast from memory" + test_one_register "vbroadcastss" "ymm0" \ + "0x13121110131211101312111013121110, 0x0" \ + "broadcast from memory" + test_one_register "vbroadcastss" "ymm15" \ + "0x17161514131211101716151413121110, 0x17161514131211101716151413121110" + test_one_register "vbroadcastss" "ymm0" \ + "0x17161514131211101716151413121110, 0x17161514131211101716151413121110" + test_one_register "vpbroadcastq" "ymm15" "0x13121110131211101312111013121110, 0x0" test_one_register "vpbroadcastq" "ymm0" "0x13121110131211101312111013121110, 0x0" @@ -527,9 +572,43 @@ gdb_test_no_output \ "set \$ymm0.v8_float = {0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5}" gdb_test_no_output \ "set \$ymm1.v8_float = {0, 1, 2, 3, 4, 5, 6, 7}" +gdb_test_no_output "set \$ymm2.v2_int128 = {0,0}" gdb_test_no_output "set \$ymm15.v2_int128 = {0,0}" if {[record_full_function "arith"] == true} { + test_one_register "vpsadbw" "ymm15" \ + "0x20000000200000004000003f000000, 0x100000001000000010000000100000" + test_one_register "vpsadbw" "ymm2" \ + "0x20000000200000004000003f000000, 0x100000001000000010000000100000" + test_one_register "vpandn" "ymm15" \ + "0x40400000400000003f80000000000000, 0x0" + test_one_register "vpand" "ymm15" \ + "0x10080000000000000000000000000000, 0x10649c00000000001044480000000000" + test_one_register "vxorpd" "ymm2" \ + "0x20000000200000004000003f000000, 0x0" + test_one_register "vxorps" "ymm2" \ + "0x10280000100800000fd0000000000000, 0x10740000106400001054000010440000" + + test_one_register "vpmuludq" "ymm15" \ + "0x10280000100800000fd0000000000000, 0x10740000106400001054000010440000" + test_one_register "vpmulhuw" "ymm15" \ + "0x0, 0x0" + test_one_register "vpmulhw" "ymm2" \ + "0x18000000000000002000000000000000, 0x0" + test_one_register "vpmulld" "ymm15" \ + "0x80a00000802000007f4000003f000000, 0x81d00000819000008150000081100000" + test_one_register "vpmullw" "ymm2" \ + "0x80a00000802000007f4000003f000000, 0x81d00000819000008150000081100000" + + test_one_register "vpaddq" "ymm15" \ + "0x80a00000802000007f4000003f000000, 0x0" + test_one_register "vpaddd" "ymm2" \ + "0x80a00000802000007e4000003f000000, 0x0" + test_one_register "vpaddw" "ymm15" \ + "0x40400000400000003fc000003f000000, 0x0" + test_one_register "vpaddb" "ymm2" \ + "0x0, 0x0" + test_one_register "vmaxsd" "ymm15" \ "0x40400000400000003f8000003f000000, 0x0" "ymm operation: " test_one_register "vmaxss" "ymm15" \ @@ -626,3 +705,493 @@ if {[record_full_function "arith"] == true} { } gdb_test "finish" "Run till exit from.*arith_test.*" \ "leaving arith" + +# Preparation and testing vaddsubpd instructions + +gdb_test_no_output "set \$ymm15.v2_int128 = {0xcafeface, 0xcafeface}" \ + "set ymm15 for vaddsubpd" +gdb_test_no_output "set \$ymm0.v2_int128 = {0xcafeface, 0xcafeface}" \ + "set ymm0 for vaddsubpd" +gdb_test_no_output "set \$xmm2.uint128 = 0xbeef" \ + "set xmm2 for vaddsubpd" +gdb_test_no_output "set \$xmm10.uint128 = 0xbeef" \ + "set xmm10 for vaddsubpd" +gdb_test_no_output "set \$ymm3.v2_int128 = {0xcafeface, 0xcafeface}" \ + "set ymm3 for vaddsubpd" +gdb_test_no_output "set \$ymm4.v2_int128 = {0xcafeface, 0xcafeface}" \ + "set ymm4 for vaddsubpd" + +if {[record_full_function "vaddsubpd"] == true} { + test_one_register "vaddsubpd" "xmm10" \ + "0xbeef" "xmm10:" + test_one_register "vaddsubpd" "xmm2" \ + "0xbeef" "xmm2:" + test_one_register "vaddsubpd" "ymm4" \ + "0xcafeface, 0xcafeface" "ymm4: " + test_one_register "vaddsubpd" "ymm15" \ + "0xcafeface, 0xcafeface" "ymm15: " + test_one_register "vaddsubpd" "ymm0" \ + "0xcafeface, 0xcafeface" "ymm0: " + + gdb_test "record stop" "Process record is stopped.*" \ + "delete history for vaddsubpd_test" +} else { + untested "couldn't run vaddsubpd tests" +} +gdb_test "finish" "Run till exit from.*vaddsubpd_test.*" \ + "leaving vaddsubpd" + +# Preparation and testing vaddsubps instruction + +gdb_test_no_output "set \$ymm10.v2_int128 = {0xcafeface, 0xcafeface}" \ + "set ymm10 for vaddsubps" +gdb_test_no_output "set \$ymm2.v2_int128 = {0xcafeface, 0xcafeface}" \ + "set ymm2 for vaddsubps" +gdb_test_no_output "set \$xmm15.uint128 = 0xbeef" \ + "set xmm15 for vaddsubps" +gdb_test_no_output "set \$xmm0.uint128 = 0xbeef" \ + "set xmm0 for vaddsubps" +gdb_test_no_output "set \$ymm3.v2_int128 = {0xcafeface, 0xcafeface}" \ + "set ymm3 for vaddsubps" +gdb_test_no_output "set \$ymm4.v2_int128 = {0xcafeface, 0xcafeface}" \ + "set ymm4 for vaddsubps" + +if {[record_full_function "vaddsubps"] == true} { + test_one_register "vaddsubps" "xmm0" \ + "0xbeef" "xmm0: " + test_one_register "vaddsubps" "xmm15" \ + "0xbeef" "xmm15: " + test_one_register "vaddsubps" "ymm4" \ + "0xcafeface, 0xcafeface" "ymm4: " + test_one_register "vaddsubps" "ymm10" \ + "0xcafeface, 0xcafeface" "ymm10: " + test_one_register "vaddsubps" "ymm2" \ + "0xcafeface, 0xcafeface" "ymm2: " + + gdb_test "record stop" "Process record is stopped.*" \ + "delete history for vaddsubps_test" +} else { + untested "couldn't run vaddsubps tests" +} +gdb_test "finish" "Run till exit from.*vaddsubps_test.*" \ + "leaving vaddsubps" + +# Preparation and testing shifting instructions. +gdb_test_no_output \ + "set \$ymm0.v2_int128 = {0, 0}" "set ymm0 for shift" +gdb_test_no_output \ + "set \$ymm1.v16_int16 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}" \ + "set ymm1 for shift" +gdb_test_no_output "set \$xmm2.uint128 = 1" "set ymm2 for shift" +gdb_test_no_output "set \$ymm15.v2_int128 = {0,0}" "set ymm15 for shift" + +if {[record_full_function "shift"] == true} { + test_one_register "vpsrldq" "ymm15" \ + "0x80007000600050004000300, 0x0" \ + "High ymm register: " + test_one_register "vpsrldq" "ymm15" \ + "0x60005000400030002000100000000, 0xe000d000c000b000a000900000000" \ + "High xmm register: " + test_one_register "vpsrldq" "ymm0" \ + "0x800070006000500040003000200, 0x0" \ + "Low ymm register: " + test_one_register "vpsrldq" "ymm0" \ + "0x70006000500040003000200010000, 0xf000e000d000c000b000a00090000" \ + "Low xmm register: " + + test_one_register "vpslldq" "ymm15" \ + "0x7000600050004000300020001000000, 0x0" \ + "High ymm register: " + test_one_register "vpslldq" "ymm15" \ + "0x40003800300020002000180010000, 0x80007800700060006000580050004" \ + "High xmm register: " + test_one_register "vpslldq" "ymm0" \ + "0x8000700060005000400030002000100, 0x0" \ + "Low ymm register: " + test_one_register "vpslldq" "ymm0" \ + "0x40003000300020002000100010000, 0x80007000700060006000500050004" \ + "Low xmm register: " + + test_one_register "vpsrlq" "ymm15" \ + "0x4000380030000000200018001000, 0x0" \ + "from register: " + test_one_register "vpsrlq" "ymm15" \ + "0x40003000300020002000100010000, 0x0" \ + "from constant: " + test_one_register "vpsrld" "ymm15" \ + "0x100000000c0000000800000004000, 0x200010001c0010001800100014001" \ + "from register: " + test_one_register "vpsrld" "ymm15" \ + "0x40003000300020002000100010000, 0x0" \ + "from constant: " + test_one_register "vpsrlw" "ymm0" \ + "0x40003000300020002000100010000, 0x0" \ + "from register: " + test_one_register "vpsrlw" "ymm0" \ + "0x40003000300020002000100010000, 0x80007000700060006000500050004" \ + "from constant: " + + test_one_register "vpsrad" "ymm15" \ + "0x100000000c0000000800000004000, 0x200010001c0010001800100014001" \ + "from register: " + test_one_register "vpsrad" "ymm15" \ + "0x10000e000c000a0008000600040002, 0x20001e001c001a0018001600140012" \ + "from constant: " + test_one_register "vpsraw" "ymm0" \ + "0x40003000300020002000100010000, 0x0" \ + "from register: " + test_one_register "vpsraw" "ymm0" \ + "0x10000e000c000a0008000600040002, 0x20001e001c001a0018001600140012" \ + "from constant: " + + test_one_register "vpsllq" "ymm15" \ + "0x10000e000c000a00080006000400020, 0x0" \ + "from register: " + test_one_register "vpsllq" "ymm15" \ + "0x10000e000c000a0008000600040002, 0x0" \ + "from constant: " + test_one_register "vpslld" "ymm15" \ + "0x400038003000280020001800100008, 0x800078007000680060005800500048" \ + "from register: " + test_one_register "vpslld" "ymm15" "0x0, 0x0" "from constant: " + test_one_register "vpsllw" "ymm0" \ + "0x10000e000c000a0008000600040002, 0x0" \ + "from register: " + test_one_register "vpsllw" "ymm0" "0x0, 0x0" "from constant: " + + gdb_test "record stop" "Process record is stopped.*" \ + "delete history for shift_test" +} else { + untested "couldn't run shift tests" +} +gdb_test "finish" "Run till exit from.*shift_test.*" \ + "leaving shift" + +# Preparation and testing shuffling instructions. +gdb_test_no_output \ + "set \$ymm0.v2_int128 = {0, 0}" "set ymm0 for shuffle" +gdb_test_no_output \ + "set \$ymm1.v16_int16 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}" \ + "set ymm1 for shuffle" +gdb_test_no_output "set \$ymm2.v16_int16 = {17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32}" \ + "set ymm2 for shuffle" +gdb_test_no_output "set \$ymm15.v2_int128 = {0,0}" "set ymm15 for shuffle" + +if {[record_full_function "shuffle"] == true} { + test_one_register "vshufpd" "ymm15" \ + "0x20001000200010012001100160015, 0xa0009000a0009001a0019001e001d" \ + "high register: " + test_one_register "vshufpd" "ymm0" \ + "0x20001000200010012001100140013, 0x0" \ + "low register: " + test_one_register "vshufps" "ymm15" \ + "0x180017001600150011001100120013, 0x0" \ + "high register: " + test_one_register "vshufps" "ymm0" \ + "0x180017001600150011001100120012, 0x20001f001e001d00190019001a001a" \ + "low register: " + + test_one_register "vpshuflw" "ymm15" \ + "0x150015001600150014001300120011, 0x1d001d001e001d001c001b001a0019" \ + "high register: " + test_one_register "vpshuflw" "ymm0" \ + "0x150015001500180014001300120011, 0x0" \ + "low register: " + test_one_register "vpshufhw" "ymm15" \ + "0x120011001200110012001100160015, 0x0" \ + "high register: " + test_one_register "vpshufhw" "ymm0" \ + "0x120011001200110012001100140013, 0x1a0019001a0019001a0019001c001b" \ + "low register: " + + test_one_register "vpshufd" "ymm15" \ + "0x11151100111411001113110011121100, 0x1919190019201900191f1900191e1900" \ + "high register: " + test_one_register "vpshufd" "ymm0" \ + "0x11151100111411001113110011121100, 0x0" \ + "low register: " + test_one_register "vpshufb" "ymm15" "0x0, 0x0" "high register: " + test_one_register "vpshufb" "ymm0" "0x0, 0x0" "low register: " + + gdb_test "record stop" "Process record is stopped.*" \ + "delete history for shuffle_test" +} else { + untested "couldn't run shuffle tests" +} +gdb_test "finish" "Run till exit from.*shuffle_test.*" \ + "leaving shuffle" + +# Preparation and testing permute instructions. +gdb_test_no_output \ + "set \$ymm0.v2_int128 = {0, 0}" "set ymm0 for permute" +gdb_test_no_output \ + "set \$ymm1.v16_int16 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}" \ + "set ymm1 for permute" +gdb_test_no_output "set \$ymm2.v16_int16 = {17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32}" \ + "set ymm2 for permute" +gdb_test_no_output "set \$ymm15.v2_int128 = {0,0}" "set ymm15 for permute" + +if {[record_full_function "permute"] == true} { + test_one_register "vpermps" "ymm15" \ + "0x40003000200010004000300020001, 0x40003000200010004000300020001" + test_one_register "vpermps" "ymm0" \ + "0x140013001200110014001300120011, 0x140013001200110014001300120011" + test_one_register "vpermpd" "ymm0" \ + "0x120011001200110012001100120011, 0x0" + test_one_register "vpermpd" "ymm15" \ + "0x120011001200110012001100140013, 0x1a0019001a0019001a0019001c001b" + + test_one_register "vpermilps" "ymm0" \ + "0x180017001400130018001700140013, 0x20001f001c001b0020001f001c001b" \ + "register version" + test_one_register "vpermilps" "ymm15" \ + "0x180017001400130018001700140013, 0x0" \ + "register version" + test_one_register "vpermilps" "ymm15" \ + "0x140013001200110018001700160015, 0x1c001b001a0019001c001b001a0019" \ + "immediate version" + test_one_register "vpermilps" "ymm0" \ + "0x140013001200110014001300120011, 0x0" \ + "immediate version" + + test_one_register "vpermilpd" "ymm0" \ + "0x140013001200110014001300120011, 0x1c001b001a0019001c001b001a0019" \ + "register version" + test_one_register "vpermilpd" "ymm15" \ + "0x140013001200110014001300120011, 0x0" \ + "register version" + test_one_register "vpermilpd" "ymm15" \ + "0x140013001200110014001300120011, 0x140013001200110014001300120011" \ + "immediate version" + test_one_register "vpermilpd" "ymm0" \ + "0x40003000200010008000700060005, 0x40003000200010004000300020001" \ + "immediate version" + + test_one_register "vpermq" "ymm15" \ + "0x10000f000c000b0008000700040003, 0x10000f000c000b0008000700040003" + test_one_register "vpermq" "ymm0" \ + "0x10000f000c000b0008000700040003, 0x10000f000c000b0008000700040003" + test_one_register "vpermd" "ymm15" \ + "0x80007000600050004000300020001, 0x80007000600050004000300020001" + test_one_register "vpermd" "ymm0" \ + "0x10000f000e000d000c000b000a0009, 0x80007000600050004000300020001" + + test_one_register "vperm2i128" "ymm15" \ + "0x180017001600150014001300120011, 0x180017001600150014001300120011" + test_one_register "vperm2i128" "ymm0" \ + "0x20001f001e001d001c001b001a0019, 0x180017001600150014001300120011" + test_one_register "vperm2f128" "ymm15" "0x0, 0x0" + test_one_register "vperm2f128" "ymm0" "0x0, 0x0" + + gdb_test "record stop" "Process record is stopped.*" \ + "delete history for permute_test" +} else { + untested "couldn't run permute tests" +} +gdb_test "finish" "Run till exit from.*permute_test.*" \ + "leaving permute" + +# Preparation and testing extract_insert instructions. +gdb_test_no_output \ + "set \$ymm0.v2_int128 = {0, 0}" "set ymm0 for extract_insert" +gdb_test_no_output \ + "set \$ymm1.v16_int16 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}" \ + "set ymm1 for extract_insert" +gdb_test_no_output "set \$xmm2.uint128 = 0xcafe" \ + "set ymm2 for extract_insert" +gdb_test_no_output "set \$ymm15.v2_int128 = {0,0}" "set ymm15 for extract_insert" +gdb_test_no_output "set \$rax = 0" "set eax for extract_insert" + +if {[record_full_function "extract_insert"] == true} { + test_one_memory "vpextrw" "global_buf1" \ + "\\\{0x1, 0x0, 0x2, 0x0, 0x3, 0x0, 0x4, 0x0 <repeats 25 times>" + test_one_general_register "vpextrw" "rax" "0x8000700060005" + + test_one_register "vpinsrq" "ymm15" \ + "0x50000cafe, 0x0" + test_one_register "vpinsrd" "ymm0" \ + "0x500cafe, 0x0" + test_one_register "vpinsrw" "ymm15" \ + "0x80007000600050004000300020001, 0x0" + test_one_register "vpinsrb" "ymm0" \ + "0x80007000600050000cafe00020001, 0x0" + + test_one_memory "vpextrq" "global_buf1" \ + "\\\{0x5, 0x0, 0x6, 0x0 <repeats 29 times>" + test_one_general_register "vpextrq" "rax" "0x80007" + test_one_memory "vpextrd" "global_buf1" \ + "\\\{0x3, 0x0 <repeats 31 times>" + test_one_general_register "vpextrd" "rax" "0x0" + test_one_memory "vpextrb" "global_buf1" \ + "\\\{0x0 <repeats 32 times>" + test_one_general_register "vpextrb" "rax" "0xcafe" + + test_one_general_register "vextractps" "eax" "0x0" + test_one_register "vinsertps" "ymm0" \ + "0x10000f000e000d000c000b000a0009, 0x0" + test_one_register "vextractf128" "ymm15" \ + "0xcafe, 0x10000f000e000d000c000b000a0009" + test_one_register "vextracti128" "ymm0" \ + "0x80007000600050004000300020001, 0xcafe" + test_one_register "vinsertf128" "ymm15" \ + "0x0, 0x0" + test_one_register "vinserti128" "ymm0" \ + "0x0, 0x0" + + gdb_test "record stop" "Process record is stopped.*" \ + "delete history for extract_insert_test" +} else { + untested "couldn't run extract_insert tests" +} +gdb_test "finish" "Run till exit from.*extract_insert_test.*" \ + "leaving extract_insert" + +# Preparation and testing blend instructions. +gdb_test_no_output \ + "set \$ymm0.v2_int128 = {0, 0}" "set ymm0 for blend" +gdb_test_no_output \ + "set \$ymm1.v16_int16 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}" \ + "set ymm1 for blend" +gdb_test_no_output \ + "set \$ymm2.v16_int16 = {17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32}" \ + "set ymm2 for blend" +gdb_test_no_output "set \$ymm15.v2_int128 = {0,0}" "set ymm15 for blend" + +if {[record_full_function "blend"] == true} { + test_one_register "vpblendvb" "ymm0" \ + "0x180017000600050004000300120011, 0x20001f001e001d001c001b000a0009" + test_one_register "vpblendvb" "ymm15" \ + "0x80007001600150004000300020001, 0x0" + test_one_register "vpblendd" "ymm15" \ + "0x180007001600050004000300020011, 0x20000f001e000d000c000b000a0019" + test_one_register "vpblendd" "ymm0" \ + "0x180017000600150004000300020001, 0x0" + test_one_register "vpblendw" "ymm0" \ + "0x180017001600150014001300120011, 0x20001f001e001d001c001b001a0019" + test_one_register "vpblendw" "ymm15" \ + "0x180017001600150014001300120011, 0x0" + + test_one_register "vblendvpd" "ymm15" \ + "0x80007000600050014001300120011, 0x10000f000e000d001c001b001a0019" + test_one_register "vblendvps" "ymm0" \ + "0x180017000600050014001300020001, 0x0" + test_one_register "vblendpd" "ymm15" "0x0, 0x0" + test_one_register "vblendps" "ymm0" "0x0, 0x0" + + gdb_test "record stop" "Process record is stopped.*" \ + "delete history for blend_test" +} else { + untested "couldn't run blend tests" +} +gdb_test "finish" "Run till exit from.*blend_test.*" \ + "leaving blend" + +# Preparation and testing compare instructions. +gdb_test_no_output \ + "set \$xmm0.v4_float = {0, 1.5, 2, 0}" "set ymm0 for compare" +gdb_test_no_output \ + "set \$xmm1.v4_float = {0, 1, 2.5, -1}" "set ymm1 for compare" +gdb_test_no_output \ + "set \$xmm15.v4_float = {-1, -2, 10, 100}" "set ymm15 for compare" +gdb_test_no_output "set \$eflags = 2" + +if {[record_full_function "compare"] == true} { + test_one_general_register "vucomisd" "eflags" "0x203" + test_one_general_register "vucomiss" "eflags" "0x202" + test_one_general_register "vcomiss" "eflags" "0x203" + test_one_general_register "vcomisd" "eflags" "0x202" + + gdb_test "record stop" "Process record is stopped.*" \ + "delete history for compare_test" +} else { + untested "couldn't run compare tests" +} +gdb_test "finish" "Run till exit from.*compare_test.*" \ + "leaving compare" + +# Preparation and testing pack instructions. +gdb_test_no_output \ + "set \$ymm0.v2_int128 = {0, 0}" "set ymm0 for pack" +gdb_test_no_output \ + "set \$ymm1.v16_int16 = {0x1020, 0x1121, 0x1222, 0x1323, 0x1424, 0x1525, 0x1626, 0x1727, 0x1828, 0x1929, 0x1a2a, 0x1b2b, 0x1c2c, 0x1d2d, 0x1e2e, 0x1f2f}" \ + "set ymm1 for pack" +gdb_test_no_output \ + "set \$ymm2.v16_int16 = {0x3040, 0x3141, 0x3242, 0x3343, 0x3444, 0x3545, 0x3646, 0x3747, 0x3848, 0x3949, 0x3a4a, 0x3b4b, 0x3c4c, 0x3d4d, 0x3e4e, 0x3f4f}" \ + "set ymm2 for pack" +gdb_test_no_output \ + "set \$ymm15.v2_int128 = {0, 0}" "set ymm15 for pack" + +if {[record_full_function "pack"] == true} { + test_one_register "vpackusdw" "ymm0" \ + "0xffffffffffffffffffffffffffffffff, 0x0" + test_one_register "vpackusdw" "ymm15" \ + "0xffffffffffffffffffffffffffffffff, 0xffffffffffffffffffffffffffffffff" + test_one_register "vpackuswb" "ymm15" \ + "0x7fff7fff7fff7fff7fff7fff7fff7fff, 0x0" + test_one_register "vpackuswb" "ymm0" \ + "0x7fff7fff7fff7fff7fff7fff7fff7fff, 0x7fff7fff7fff7fff7fff7fff7fff7fff" + test_one_register "vpackssdw" "ymm0" \ + "0x7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f, 0x0" + test_one_register "vpackssdw" "ymm15" \ + "0x7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f, 0x7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f" + test_one_register "vpacksswb" "ymm15" "0x0, 0x0" + test_one_register "vpacksswb" "ymm0" "0x0, 0x0" + + gdb_test "record stop" "Process record is stopped.*" \ + "delete history for pack_test" +} else { + untested "couldn't run pack tests" +} +gdb_test "finish" "Run till exit from.*pack_test.*" \ + "leaving pack" + +# Preparation and testing converting instructions. +gdb_test_no_output \ + "set \$ymm0.v2_int128 = {0,0}" \ + "set ymm0 for convert test" +gdb_test_no_output \ + "set \$ymm1.v8_float = {0, 1, 2.5, 10, -1, -2.5, 0}" \ + "set ymm1 for convert test" +gdb_test_no_output "set \$ymm15.v2_int128 = {0,0}" \ + "set ymm15 for convert test" +gdb_test_no_output "set \$ecx = -1" "set ecx for convert test" +gdb_test_no_output "set \$ebx = 1" "set ebx for convert test" + +if {[record_full_function "convert"] == true} { + gdb_test "maint print record-instruction" ".*" + test_one_general_register "vcvttss2si" "ecx" "0xffffffff" + test_one_general_register "vcvttsd2si" "ebx" "0x0" + test_one_register "vcvttps2dq" "ymm15" \ + "0x41200000402000003f8000004f800000, 0x0" + test_one_register "vcvttpd2dq" "ymm0" \ + "0x412000004020000041f0000000000000, 0x0" + test_one_general_register "vcvtss2si" "ebx" "0x0" + + test_one_register "vcvtss2sd" "ymm0" \ + "0x412000004020000041efffffffe00000, 0x0" + test_one_register "vcvtsi2ss" "ymm15" \ + "0x41200000402000003f80000000000000, 0x0" + test_one_register "vcvtsi2sd" "ymm0" \ + "0x8000000000000, 0x0" + test_one_register "vcvtsd2ss" "ymm15" \ + "0x490000023c000000, 0x0" + test_one_general_register "vcvtsd2si" "ebx" "0x1" + + test_one_register "vcvtpd2dq" "ymm0" \ + "0x3ff00000000000000000000000000000, 0x0" + test_one_register "vcvtpd2ps" "ymm15" \ + "0xa000000020000000100000000, 0x0" + test_one_register "vcvtps2pd" "ymm0" \ + "0x4e8240004e8040004e7e000000000000, 0x0" + test_one_register "vcvtps2dq" "ymm15" \ + "0x41cfc000000000000000000000000000, 0x0" + test_one_register "vcvtdq2pd" "ymm15" "0x0, 0x0" + test_one_register "vcvtdq2ps" "ymm0" "0x0, 0x0" + + gdb_test "record stop" "Process record is stopped.*" \ + "delete history for convert_test" +} else { + untested "couldn't run convert tests" +} +gdb_test "finish" "Run till exit from.*convert_test.*" \ + "leaving convert" diff --git a/gdb/testsuite/gdb.tui/main-2.exp b/gdb/testsuite/gdb.tui/main-2.exp index 2b0fb6b..71ad03b 100644 --- a/gdb/testsuite/gdb.tui/main-2.exp +++ b/gdb/testsuite/gdb.tui/main-2.exp @@ -41,7 +41,7 @@ if {![Term::enter_tui]} { set line " return 0;" set nr [gdb_get_line_number $line] -set screen_line [Term::get_line_with_attrs 6] +set screen_line [Term::get_string_with_attrs 6 1 79] verbose -log "screen line 6: '$screen_line'" gdb_assert { [regexp "$nr <reverse:1>$line<reverse:0>" $screen_line] } \ "highlighted line in middle of source window" diff --git a/gdb/testsuite/gdb.tui/tuiterm.exp b/gdb/testsuite/gdb.tui/tuiterm.exp index 9dc2402..6cd65f3 100644 --- a/gdb/testsuite/gdb.tui/tuiterm.exp +++ b/gdb/testsuite/gdb.tui/tuiterm.exp @@ -102,7 +102,7 @@ proc test_backspace {} { Term::_move_cursor 1 2 - Term::_ctl_0x08 + Term::_ctl_0x08 0 check "backspace one" { "abcdefgh" "ijklmnop" @@ -111,13 +111,22 @@ proc test_backspace {} { } 0 2 # Cursor should not move if it is already at column 0. - Term::_ctl_0x08 + Term::_ctl_0x08 0 check "backspace 2" { "abcdefgh" "ijklmnop" "qrstuvwx" "yz01234 " } 0 2 + + # Cursor should wrap to previous line. + Term::_ctl_0x08 1 + check "backspace 3" { + "abcdefgh" + "ijklmnop" + "qrstuvwx" + "yz01234 " + } 7 1 } proc test_linefeed { } { @@ -435,6 +444,30 @@ proc test_horizontal_absolute { } { "qrstuvwx" "yz01234 " } 3 2 + + Term::_csi_G 8 + check "cursor horizontal absolute 3" { + "abcdefgh" + "ijklmnop" + "qrstuvwx" + "yz01234 " + } 7 2 + + Term::_csi_G 9 + check "cursor horizontal absolute 4" { + "abcdefgh" + "ijklmnop" + "qrstuvwx" + "yz01234 " + } 7 2 + + Term::_csi_` + check "horizontal position absolute 1" { + "abcdefgh" + "ijklmnop" + "qrstuvwx" + "yz01234 " + } 0 2 } proc test_cursor_position { } { @@ -750,6 +783,15 @@ proc test_attrs {} { set line [Term::get_line_with_attrs 0] gdb_assert { [regexp $re $line] } "attribute: $attr" } + + # Regression test: Check that _csi_m works without arguments. + setup_terminal 4 1 + Term::_csi_m 7 + Term::_insert "a" + Term::_csi_m + Term::_insert "a" + set line [Term::get_line_with_attrs 0] + gdb_assert { [string equal $line "<reverse:1>a<reverse:0>a "] } } # Run proc TEST_PROC_NAME with a "small" terminal. diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 777d64d..8d94d6b 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -287,10 +287,13 @@ if {![info exists gdb_prompt]} { set gdb_prompt "\\(gdb\\)" } -# A regexp that matches the pagination prompt. -set pagination_prompt \ +# The pagination prompt. +set pagination_prompt_str \ "--Type <RET> for more, q to quit, c to continue without paging--" +# A regexp that matches the pagination prompt. +set pagination_prompt [string_to_regexp $pagination_prompt_str] + # The variable fullname_syntax_POSIX is a regexp which matches a POSIX # absolute path ie. /foo/ set fullname_syntax_POSIX {/[^\n]*/} @@ -9990,6 +9993,10 @@ proc gdb_stdin_log_init { } { set logfile [standard_output_file_with_gdb_instance gdb.in] set in_file [open $logfile w] + + verbose -log "" + verbose -log "Starting logfile: $logfile" + verbose -log "" } # Write to the file for logging gdb input. diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp index a0cd199..b83b8af 100644 --- a/gdb/testsuite/lib/tuiterm.exp +++ b/gdb/testsuite/lib/tuiterm.exp @@ -45,9 +45,16 @@ namespace eval Term { set orig_cur_row $_cur_row set orig_cur_col $_cur_col - uplevel $body + set code [catch {uplevel $body} result] _log "$what, cursor: ($orig_cur_row, $orig_cur_col) -> ($_cur_row, $_cur_col)" + + if { $code == 1 } { + global errorInfo errorCode + return -code $code -errorinfo $errorInfo -errorcode $errorCode $result + } else { + return -code $code $result + } } # If ARG is empty, return DEF: otherwise ARG. This is useful for @@ -83,14 +90,40 @@ namespace eval Term { proc _ctl_0x07 {} { } + # Return 1 if tuiterm has the bw/auto_left_margin enabled. + proc _have_bw {} { + return [string equal $Term::_TERM "ansiw"] + } + # Backspace. - proc _ctl_0x08 {} { - _log_cur "Backspace" { + proc _ctl_0x08 { {bw -1} } { + if { $bw == -1 } { + set bw [_have_bw] + } + _log_cur "Backspace, bw == $bw" { variable _cur_col + variable _cur_row + variable _cols - if {$_cur_col > 0} { + if { $_cur_col > 0 } { + # No wrapping needed. incr _cur_col -1 + return + } + + if { ! $bw } { + # Wrapping not enabled. + return } + + if { $_cur_row == 0 } { + # Can't wrap. + return + } + + # Wrap to previous line. + set _cur_col [expr $_cols - 1] + incr _cur_row -1 } } @@ -155,6 +188,14 @@ namespace eval Term { } } + # Horizontal Position Absolute. + # + # https://vt100.net/docs/vt510-rm/HPA.html + proc _csi_` {args} { + # Same as Cursor Horizontal Absolute. + return [Term::_csi_G {*}$args] + } + # Cursor Up. # # https://vt100.net/docs/vt510-rm/CUU.html @@ -251,7 +292,7 @@ namespace eval Term { variable _cur_col variable _cols - set _cur_col [expr {min ($arg - 1, $_cols)}] + set _cur_col [expr {min ($arg, $_cols)} - 1] } } @@ -597,6 +638,11 @@ namespace eval Term { # # https://vt100.net/docs/vt510-rm/SGR.html proc _csi_m {args} { + if { [llength $args] == 0 } { + # Apply default. + set args [list 0] + } + _log_cur "Select Graphic Rendition ([join $args {, }])" { variable _attrs @@ -740,7 +786,7 @@ namespace eval Term { _log "wait_for: unsupported escape" error "unsupported escape" } - -re "^\x1b\\\[(\[0-9;\]*)(\[a-zA-Z@\])" { + -re "^\x1b\\\[(\[0-9;\]*)(\[a-zA-Z@`\])" { set cmd $expect_out(2,string) set params [split $expect_out(1,string) ";"] _log "wait_for: _csi_$cmd <<<$expect_out(1,string)>>>" @@ -844,8 +890,16 @@ namespace eval Term { # BODY. proc with_tuiterm {rows cols body} { global env stty_init + variable _TERM save_vars {env(TERM) env(NO_COLOR) stty_init} { - setenv TERM ansi + if { [ishost *-*-*bsd*] } { + setenv TERM ansiw + } else { + setenv TERM ansi + } + # Save active TERM variable. + set Term::_TERM $env(TERM) + setenv NO_COLOR "" _setup $rows $cols @@ -955,10 +1009,10 @@ namespace eval Term { return $res } - # Return the text of screen line N. Lines are 0-based. If C is given, - # stop before column C. Columns are also zero-based. If ATTRS, annotate - # with attributes. - proc get_line_1 {n c attrs} { + # Return the text of screen line N. Lines are 0-based. Start at column + # X. If C is non-empty, stop before column C. Columns are also + # zero-based. If ATTRS, annotate with attributes. + proc get_string {n x c {attrs 0}} { variable _rows # This can happen during resizing, if the cursor seems to # temporarily be off-screen. @@ -970,7 +1024,6 @@ namespace eval Term { variable _cols variable _chars set c [_default $c $_cols] - set x 0 if { $attrs } { _reset_attrs line_attrs } @@ -990,6 +1043,20 @@ namespace eval Term { return $result } + # Return the text of screen line N. Lines are 0-based. Start at column + # X. If C is non-empty, stop before column C. Columns are also + # zero-based. Annotate with attributes. + proc get_string_with_attrs { n x c } { + return [get_string $n $x $c 1] + } + + # Return the text of screen line N. Lines are 0-based. If C is + # non-empty, stop before column C. Columns are also zero-based. If + # ATTRS, annotate with attributes. + proc get_line_1 {n c attrs} { + return [get_string $n 0 $c $attrs] + } + # Return the text of screen line N, without attributes. Lines are # 0-based. If C is given, stop before column C. Columns are also # zero-based. @@ -1224,7 +1291,7 @@ namespace eval Term { for {set y 0} {$y < $_rows} {incr y} { set fmt [format %5d $y] - verbose -log "$fmt [get_line_1 $y "" $attrs]" + verbose -log "$fmt [get_line_1 $y {} $attrs]" } } |