Home | History | Annotate | Line # | Download | only in gdb.arch
      1  1.1.1.2  christos # Copyright 2021-2024 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.1.2  christos require {istarget powerpc*-*} allow_power_isa_3_1_tests
     20      1.1  christos 
     21      1.1  christos set retval 0
     22      1.1  christos 
     23      1.1  christos standard_testfile .s
     24      1.1  christos 
     25      1.1  christos if { [prepare_for_testing "failed to prepare" $testfile "$srcfile" \
     26      1.1  christos       {debug quiet}] } {
     27      1.1  christos     return -1
     28      1.1  christos }
     29      1.1  christos 
     30      1.1  christos gdb_test "set radix 0b10000"
     31      1.1  christos gdb_test "set debug displaced"
     32      1.1  christos 
     33      1.1  christos if {![runto_main]} {
     34      1.1  christos       return
     35      1.1  christos }
     36      1.1  christos 
     37      1.1  christos gdb_test "set debug displaced on"
     38      1.1  christos 
     39      1.1  christos # Proc to extract the uint128 hex value from the output of
     40      1.1  christos # a print vector statement.
     41      1.1  christos proc get_vector_hexadecimal_valueof { exp default {test ""} } {
     42      1.1  christos 	set val "0x0000"
     43      1.1  christos 	global gdb_prompt
     44      1.1  christos 	if {$test == ""} {
     45      1.1  christos 		set test "get vector_hexadecimal valueof \"${exp}\""
     46      1.1  christos 	}
     47      1.1  christos 	gdb_test_multiple "print $${exp}.uint128" $test {
     48      1.1  christos 		-re -wrap "\\$\[0-9\]* = (0x\[0-9a-zA-Z\]+).*" {
     49      1.1  christos 			set val $expect_out(1,string)
     50      1.1  christos 				pass "$test"
     51      1.1  christos 		}
     52      1.1  christos 		-re -wrap ".*Illegal instruction.* $" {
     53      1.1  christos 			fail "Illegal instruction on print."
     54      1.1  christos 			set val 0xffff
     55      1.1  christos 		}
     56      1.1  christos 	}
     57      1.1  christos 	return ${val}
     58      1.1  christos }
     59      1.1  christos 
     60      1.1  christos # Proc to do a single-step, and ensure we gently handle
     61      1.1  christos # an illegal instruction situation.
     62      1.1  christos proc stepi_over_instruction { xyz } {
     63      1.1  christos 	global gdb_prompt
     64      1.1  christos 	gdb_test_multiple "stepi" "${xyz} " {
     65      1.1  christos 		-re -wrap ".*Illegal instruction.*" {
     66      1.1  christos 			fail "Illegal instruction on single step."
     67      1.1  christos 		return
     68      1.1  christos 		}
     69      1.1  christos 		-re -wrap ".*" {
     70      1.1  christos 		 pass "stepi ${xyz}"
     71      1.1  christos 		}
     72      1.1  christos 	}
     73      1.1  christos }
     74      1.1  christos 
     75      1.1  christos set check_pc [get_hexadecimal_valueof "\$pc" "default0"]
     76      1.1  christos 
     77      1.1  christos # set some breakpoints on the instructions below main().
     78      1.1  christos gdb_test "disas /r main"
     79      1.1  christos set bp1 *$check_pc+4
     80      1.1  christos set bp2 *$check_pc+0d12
     81      1.1  christos set bp3 *$check_pc+0d20
     82      1.1  christos set bp4 *$check_pc+0d28
     83      1.1  christos gdb_breakpoint $bp1
     84      1.1  christos gdb_breakpoint $bp2
     85      1.1  christos gdb_breakpoint $bp3
     86      1.1  christos gdb_breakpoint $bp4
     87      1.1  christos 
     88      1.1  christos # single-step through the plxv instructions, and retrieve the
     89      1.1  christos # register values as we proceed.
     90      1.1  christos 
     91      1.1  christos stepi_over_instruction  "stepi over NOP"
     92      1.1  christos stepi_over_instruction  "stepi over lnia"
     93      1.1  christos stepi_over_instruction  "stepi over addi"
     94      1.1  christos 
     95      1.1  christos stepi_over_instruction  "stepi over vs4 assignment"
     96      1.1  christos set check_vs4 [get_vector_hexadecimal_valueof "vs4" "default0"]
     97      1.1  christos 
     98      1.1  christos stepi_over_instruction  "stepi over vs5 assignment"
     99      1.1  christos set check_vs5 [get_vector_hexadecimal_valueof "vs5" "default0"]
    100      1.1  christos 
    101      1.1  christos stepi_over_instruction  "stepi over vs6 assignment"
    102      1.1  christos set check_vs6 [get_vector_hexadecimal_valueof "vs6" "default0"]
    103      1.1  christos 
    104      1.1  christos stepi_over_instruction  "stepi over vs7 assignment"
    105      1.1  christos set check_vs7 [get_vector_hexadecimal_valueof "vs7" "default0"]
    106      1.1  christos 
    107      1.1  christos set vs4_expected 0xa5b5c5d5a4b4c4d4a3b3c3d3a2b2c2d2
    108      1.1  christos set vs5_expected 0xa7b7c7d7a6b6c6d6a5b5c5d5a4b4c4d4
    109      1.1  christos set vs6_expected 0xa9b9c9d9a8b8c8d8a7b7c7d7a6b6c6d6
    110      1.1  christos set vs7_expected 0xabbbcbdbaabacadaa9b9c9d9a8b8c8d8
    111      1.1  christos 
    112      1.1  christos if [expr  $check_vs4 != $vs4_expected] {
    113      1.1  christos     fail "unexpected value vs4;  actual:$check_vs4 expected:$vs4_expected"
    114      1.1  christos }
    115      1.1  christos if [expr $check_vs5 != $vs5_expected ] {
    116      1.1  christos     fail "unexpected value vs5;   actual:$check_vs5 expected:$vs5_expected"
    117      1.1  christos }
    118      1.1  christos if [expr $check_vs6 != $vs6_expected ] {
    119      1.1  christos     fail "unexpected value vs6;   actual:$check_vs6 expected:$vs6_expected"
    120      1.1  christos }
    121      1.1  christos if [expr $check_vs7 != $vs7_expected ] {
    122      1.1  christos     fail "unexpected value vs7;   actual:$check_vs7 expected:$vs7_expected"
    123      1.1  christos }
    124      1.1  christos 
    125      1.1  christos gdb_test "info break"
    126      1.1  christos gdb_test "info register vs4 vs5 vs6 vs7 "
    127      1.1  christos gdb_test "disas main #2"
    128      1.1  christos 
    129