OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-7.1/] [gdb/] [testsuite/] [lib/] [cell.exp] - Blame information for rev 318

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 227 jeremybenn
# Copyright 2009, 2010 Free Software Foundation, Inc.
2
#
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 3 of the License, or
6
# (at your option) any later version.
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
12
#
13
# You should have received a copy of the GNU General Public License
14
# along with this program.  If not, see .
15
#
16
# Contributed by Markus Deuling .
17
#
18
# Support library for testing the combined debugger for Linux
19
# on the Cell Broadband Engine.
20
 
21
# Compile SPU objects.
22
proc gdb_compile_cell_spu {source dest type options} {
23
  global board
24
 
25
  # Save and unset multilib flags; these are not appropriate
26
  # for the SPU compiler.
27
  set board [target_info name]
28
  set save_multilib_flag [board_info $board multilib_flags]
29
  unset_board_info "multilib_flags"
30
 
31
  set options_spu [concat $options [list compiler=spu-gcc]]
32
  set ccout [gdb_compile $source $dest $type $options_spu]
33
 
34
  set_board_info multilib_flags $save_multilib_flag
35
  return $ccout
36
}
37
 
38
# Compile PPU objects.  This is just like gdb_compile_pthreads, except that we
39
# always add the libspe2 library for compiling Cell/B.E. programs.
40
proc gdb_compile_cell_ppu {source dest type options} {
41
    # We do not need to try multiple names for the pthread library
42
    # -lpthread works on all Cell/B.E. systems
43
    set lib "-lspe2 -lpthread"
44
    set options_ppu [concat $options [list libs=$lib]]
45
    return [gdb_compile $source $dest $type $options_ppu]
46
}
47
 
48
# Embed SPU executable into a PPU object.
49
proc gdb_cell_embedspu {source dest options} {
50
    global CC_FOR_TARGET
51
 
52
    if [info exists CC_FOR_TARGET] {
53
        set compiler $CC_FOR_TARGET
54
    } else {
55
        set compiler [board_info [target_info name] compiler]
56
    }
57
 
58
    # We assume the PPU compiler is called gcc or ppu-gcc,
59
    # and find the appropriate embedspu based on that.
60
    regsub gcc "$compiler" embedspu embedspu
61
 
62
    # Determine default embedded symbol name from source filename.
63
    set path [split "$source" /]
64
    set filename [lindex $path [expr [llength $path] - 1]]
65
    regsub -all -- "\[-\.\]" "$filename" "_" symbol
66
 
67
    set options_embed [concat $options [list compiler=$embedspu]]
68
    return [gdb_compile "$symbol $source $dest" "" none $options_embed]
69
}
70
 
71
# Run a test on the target to see if it supports Cell/B.E. hardware.
72
# Return 0 if so, 1 if it does not.
73
proc skip_cell_tests {} {
74
    global skip_cell_tests_saved
75
    global srcdir subdir gdb_prompt
76
 
77
    # Use the cached value, if it exists.
78
    set me "skip_cell_tests"
79
    if [info exists skip_cell_tests_saved] {
80
        verbose "$me:  returning saved $skip_cell_tests_saved" 2
81
        return $skip_cell_tests_saved
82
    }
83
 
84
    # Set up, compile, and execute a combined Cell/B.E. test program.
85
    # Include the current process ID in the file names to prevent conflicts
86
    # with invocations for multiple testsuites.
87
    set src cell[pid].c
88
    set exe cell[pid].x
89
    set src_spu cell[pid]-spu.c
90
    set exe_spu cell[pid]-spu.x
91
 
92
    set f [open $src "w"]
93
    puts $f "#include "
94
    puts $f "extern spe_program_handle_t cell[pid]_spu_x;"
95
    puts $f "int main (void) {"
96
    puts $f "unsigned int entry = SPE_DEFAULT_ENTRY;"
97
    puts $f "spe_context_ptr_t ctx = spe_context_create (0, NULL);"
98
    puts $f "spe_program_load (ctx, &cell[pid]_spu_x);"
99
    puts $f "return spe_context_run (ctx, &entry, 0, NULL, NULL, NULL); }"
100
    close $f
101
 
102
    set f [open $src_spu "w"]
103
    puts $f "int main (void) { return 0; }"
104
    close $f
105
 
106
    verbose "$me:  compiling testfile $src" 2
107
    set compile_flags {debug nowarnings quiet}
108
 
109
    set skip 0
110
    if { [gdb_compile_cell_spu $src_spu $exe_spu executable $compile_flags] != "" } {
111
        verbose "$me:  compiling spu binary failed, returning 1" 2
112
        set skip 1
113
    }
114
    if { ! $skip && [gdb_cell_embedspu $exe_spu $exe_spu-embed.o $compile_flags]  != "" } {
115
        verbose "$me:  embedding spu binary failed, returning 1" 2
116
        set skip 1
117
    }
118
    if { ! $skip && [gdb_compile_cell_ppu [list $src $exe_spu-embed.o] $exe executable $compile_flags] != "" } {
119
        verbose "$me:  compiling ppu binary failed, returning 1" 2
120
        set skip 1
121
    }
122
    file delete $src
123
    file delete $src_spu
124
    file delete $exe_spu
125
    file delete $exe_spu-embed.o
126
 
127
    if { $skip } {
128
        return [set skip_cell_tests_saved 1]
129
    }
130
 
131
    # Compilation succeeded so now run it via gdb.
132
 
133
    gdb_exit
134
    gdb_start
135
    gdb_reinitialize_dir $srcdir/$subdir
136
    gdb_load "$exe"
137
    gdb_run_cmd
138
    gdb_expect {
139
        -re ".*Program exited normally.*${gdb_prompt} $" {
140
            verbose -log "\n$me: Cell/B.E. hardware detected"
141
            set skip_cell_tests_saved 0
142
        }
143
        -re ".*Program exited with code.*${gdb_prompt} $" {
144
            verbose -log "\n$me: Cell/B.E. hardware not detected"
145
            set skip_cell_tests_saved 1
146
        }
147
        default {
148
            verbose -log "\n$me Cell/B.E. hardware not detected (default case)"
149
            set skip_cell_tests_saved 1
150
        }
151
    }
152
    gdb_exit
153
    remote_file build delete $exe
154
 
155
    verbose "$me:  returning $skip_cell_tests_saved" 2
156
    return $skip_cell_tests_saved
157
}
158
 
159
# Delete all breakpoints and stop on the next new SPU thread
160
proc cont_spu_main { } {
161
  delete_breakpoints
162
  gdb_test "set spu stop-on-load on"
163
  gdb_test "continue" \
164
           "Continuing.*Temporary breakpoint .*main .*" \
165
           "continue to SPU main"
166
}
167
 
168
# Continue to MARKER
169
proc c_to { marker srcfile } {
170
  set line [gdb_get_line_number $marker $srcfile]
171
  gdb_test "break $line" \
172
           "Breakpoint.*at.*file.*$srcfile.*line $line.*" \
173
           "break $line"
174
  gdb_test "continue" \
175
           "Continuing.*Breakpoint.*at.*$srcfile.*$line.*" \
176
           "continue to $line"
177
}
178
 
179
# Check if the current thread has SPU architecture
180
proc check_spu_arch { msg } {
181
  if { $msg == "" } {
182
    set msg "spu architecture is spu256K"
183
  }
184
  gdb_test "show architecture" \
185
           "The target architecture is set automatically.*currently spu:256K.*" \
186
           $msg
187
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.