aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.arch/ppc-fp.exp
blob: 16737775bc7712d22104275c35e2efcdc9550e19 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# Copyright (C) 2008, 2009, 2010 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/>.
#

# Tests for Powerpc floating point register setting and fetching

if $tracelevel then {
    strace $tracelevel
}

if ![istarget "powerpc*"] then {
    verbose "Skipping powerpc floating point register tests."
    return
}

set testfile "ppc-fp"
set binfile ${objdir}/${subdir}/${testfile}
set srcfile ${testfile}.c

if [get_compiler_info $binfile] {
    warning "get_compiler failed"
    return -1
}

if ![test_compiler_info gcc*] {
    # We use GCC's extended asm syntax
    warning "unknown compiler"
    return -1
}

if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {quiet debug}] != "" } {
    verbose "Skipping FPSCR tests."
    return -1
}

# Start with a fresh gdb.

gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}

gdb_breakpoint [gdb_get_line_number "Invalid operation."]
gdb_breakpoint [gdb_get_line_number "Division by zero."]

gdb_run_cmd

# When the prompt comes back we'll be in the invalid operation breakpoint.
gdb_expect { -re ".*$gdb_prompt $" {} }

# First, verify if FPSCR exists and is all zeroes.
gdb_test_multiple "print \$fpscr" "FPSCR exists" {
  -re " = 0\[\r\n\]+$gdb_prompt $" { pass "FPSCR is all zeroes" }

  -re " = void\[\r\n\]+$gdb_prompt $" {
    # There's no FPSCR.  Skip this testcase.
    verbose "Skipping powerpc floating point register tests."
    return
  }
}

# Step over invalid operation.
gdb_test "next" "" ""

# Verify that the following bits are set (See Power ISA for details):
#
# 32 - Floating-Point Exception Summary (FX)
# 34 - Floating-Point Invalid Operation Summary (VX)
# 42 - Floating-Point Invalid Operation Exception (VXZDZ)
# 47 - Floating-Point Result Class Descriptor (C)
# 51 - Floating-Point Unordered or NaN (FU or ?)
gdb_test "print/t \$fpscr" " = 10100000001000010001000000000000" "FPSCR for invalid operation"

gdb_continue_to_breakpoint "go to division by zero"

# Step over division by zero.
gdb_test "next" "" ""

# Verify that the following bits are set (See Power ISA for details):
#
# 32 - Floating-Point Exception Summary (FX)
# 37 - Floating-Point Zero Divide Exception (ZX)
# 49 - Floating-Point Greater Than or Positive (FG or >)
# 51 - Floating-Point Unordered or NaN (FU or ?)
gdb_test "print/t \$fpscr" " = 10000100000000000101000000000000" "FPSCR for division by zero"