Home | History | Annotate | Line # | Download | only in gdb.arch
powerpc-plxv-nonrel.exp revision 1.1
      1  1.1  christos # Copyright 2021-2023 Free Software Foundation, Inc.
      2  1.1  christos 
      3  1.1  christos # This program is free software; you can redistribute it and/or modify
      4  1.1  christos # it under the terms of the GNU General Public License as published by
      5  1.1  christos # the Free Software Foundation; either version 3 of the License, or
      6  1.1  christos # (at your option) any later version.
      7  1.1  christos #
      8  1.1  christos # This program is distributed in the hope that it will be useful,
      9  1.1  christos # but WITHOUT ANY WARRANTY; without even the implied warranty of
     10  1.1  christos # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     11  1.1  christos # GNU General Public License for more details.
     12  1.1  christos #
     13  1.1  christos # You should have received a copy of the GNU General Public License
     14  1.1  christos # along with this program.  If not, see <http://www.gnu.org/licenses/>.
     15  1.1  christos 
     16  1.1  christos # Test to see if gdb is properly single stepping over the
     17  1.1  christos # displaced plxv instruction.
     18  1.1  christos 
     19  1.1  christos if { ![istarget powerpc*-*] || [skip_power_isa_3_1_tests] } {
     20  1.1  christos     verbose "Skipping powerpc ISA 3.1 plxv test."
     21  1.1  christos     return
     22  1.1  christos }
     23  1.1  christos 
     24  1.1  christos set retval 0
     25  1.1  christos 
     26  1.1  christos standard_testfile .s
     27  1.1  christos 
     28  1.1  christos if { [prepare_for_testing "failed to prepare" $testfile "$srcfile" \
     29  1.1  christos       {debug quiet}] } {
     30  1.1  christos     return -1
     31  1.1  christos }
     32  1.1  christos 
     33  1.1  christos gdb_test "set radix 0b10000"
     34  1.1  christos gdb_test "set debug displaced"
     35  1.1  christos 
     36  1.1  christos if {![runto_main]} {
     37  1.1  christos       return
     38  1.1  christos }
     39  1.1  christos 
     40  1.1  christos gdb_test "set debug displaced on"
     41  1.1  christos 
     42  1.1  christos # Proc to extract the uint128 hex value from the output of
     43  1.1  christos # a print vector statement.
     44  1.1  christos proc get_vector_hexadecimal_valueof { exp default {test ""} } {
     45  1.1  christos 	set val "0x0000"
     46  1.1  christos 	global gdb_prompt
     47  1.1  christos 	if {$test == ""} {
     48  1.1  christos 		set test "get vector_hexadecimal valueof \"${exp}\""
     49  1.1  christos 	}
     50  1.1  christos 	gdb_test_multiple "print $${exp}.uint128" $test {
     51  1.1  christos 		-re -wrap "\\$\[0-9\]* = (0x\[0-9a-zA-Z\]+).*" {
     52  1.1  christos 			set val $expect_out(1,string)
     53  1.1  christos 				pass "$test"
     54  1.1  christos 		}
     55  1.1  christos 		-re -wrap ".*Illegal instruction.* $" {
     56  1.1  christos 			fail "Illegal instruction on print."
     57  1.1  christos 			set val 0xffff
     58  1.1  christos 		}
     59  1.1  christos 	}
     60  1.1  christos 	return ${val}
     61  1.1  christos }
     62  1.1  christos 
     63  1.1  christos # Proc to do a single-step, and ensure we gently handle
     64  1.1  christos # an illegal instruction situation.
     65  1.1  christos proc stepi_over_instruction { xyz } {
     66  1.1  christos 	global gdb_prompt
     67  1.1  christos 	gdb_test_multiple "stepi" "${xyz} " {
     68  1.1  christos 		-re -wrap ".*Illegal instruction.*" {
     69  1.1  christos 			fail "Illegal instruction on single step."
     70  1.1  christos 		return
     71  1.1  christos 		}
     72  1.1  christos 		-re -wrap ".*" {
     73  1.1  christos 		 pass "stepi ${xyz}"
     74  1.1  christos 		}
     75  1.1  christos 	}
     76  1.1  christos }
     77  1.1  christos 
     78  1.1  christos set check_pc [get_hexadecimal_valueof "\$pc" "default0"]
     79  1.1  christos 
     80  1.1  christos # set some breakpoints on the instructions below main().
     81  1.1  christos gdb_test "disas /r main"
     82  1.1  christos set bp1 *$check_pc+4
     83  1.1  christos set bp2 *$check_pc+0d12
     84  1.1  christos set bp3 *$check_pc+0d20
     85  1.1  christos set bp4 *$check_pc+0d28
     86  1.1  christos gdb_breakpoint $bp1
     87  1.1  christos gdb_breakpoint $bp2
     88  1.1  christos gdb_breakpoint $bp3
     89  1.1  christos gdb_breakpoint $bp4
     90  1.1  christos 
     91  1.1  christos # single-step through the plxv instructions, and retrieve the
     92  1.1  christos # register values as we proceed.
     93  1.1  christos 
     94  1.1  christos stepi_over_instruction  "stepi over NOP"
     95  1.1  christos stepi_over_instruction  "stepi over lnia"
     96  1.1  christos stepi_over_instruction  "stepi over addi"
     97  1.1  christos 
     98  1.1  christos stepi_over_instruction  "stepi over vs4 assignment"
     99  1.1  christos set check_vs4 [get_vector_hexadecimal_valueof "vs4" "default0"]
    100  1.1  christos 
    101  1.1  christos stepi_over_instruction  "stepi over vs5 assignment"
    102  1.1  christos set check_vs5 [get_vector_hexadecimal_valueof "vs5" "default0"]
    103  1.1  christos 
    104  1.1  christos stepi_over_instruction  "stepi over vs6 assignment"
    105  1.1  christos set check_vs6 [get_vector_hexadecimal_valueof "vs6" "default0"]
    106  1.1  christos 
    107  1.1  christos stepi_over_instruction  "stepi over vs7 assignment"
    108  1.1  christos set check_vs7 [get_vector_hexadecimal_valueof "vs7" "default0"]
    109  1.1  christos 
    110  1.1  christos set vs4_expected 0xa5b5c5d5a4b4c4d4a3b3c3d3a2b2c2d2
    111  1.1  christos set vs5_expected 0xa7b7c7d7a6b6c6d6a5b5c5d5a4b4c4d4
    112  1.1  christos set vs6_expected 0xa9b9c9d9a8b8c8d8a7b7c7d7a6b6c6d6
    113  1.1  christos set vs7_expected 0xabbbcbdbaabacadaa9b9c9d9a8b8c8d8
    114  1.1  christos 
    115  1.1  christos if [expr  $check_vs4 != $vs4_expected] {
    116  1.1  christos     fail "unexpected value vs4;  actual:$check_vs4 expected:$vs4_expected"
    117  1.1  christos }
    118  1.1  christos if [expr $check_vs5 != $vs5_expected ] {
    119  1.1  christos     fail "unexpected value vs5;   actual:$check_vs5 expected:$vs5_expected"
    120  1.1  christos }
    121  1.1  christos if [expr $check_vs6 != $vs6_expected ] {
    122  1.1  christos     fail "unexpected value vs6;   actual:$check_vs6 expected:$vs6_expected"
    123  1.1  christos }
    124  1.1  christos if [expr $check_vs7 != $vs7_expected ] {
    125  1.1  christos     fail "unexpected value vs7;   actual:$check_vs7 expected:$vs7_expected"
    126  1.1  christos }
    127  1.1  christos 
    128  1.1  christos gdb_test "info break"
    129  1.1  christos gdb_test "info register vs4 vs5 vs6 vs7 "
    130  1.1  christos gdb_test "disas main #2"
    131  1.1  christos 
    132