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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gdb-7.2/] [gdb/] [testsuite/] [config/] [slite.exp] - Blame information for rev 816

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

Line No. Rev Author Line
1 330 jeremybenn
#   Copyright 1993, 1997, 1998, 2007, 2008, 2009, 2010
2
#   Free Software Foundation, Inc.
3
 
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 3 of the License, or
7
# (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program.  If not, see .
16
 
17
# This file was written by Ian Lance Taylor .
18
 
19
# GDB support routines for a board using the MIPS remote debugging
20
# protocol.  These are actually pretty generic.
21
 
22
# DejaGnu currently assumes that debugging is being done over the main
23
# console port.  It would probably be more convenient for people using
24
# IDT boards to permit the debugging port and the connected port to be
25
# different, since an IDT board has two ports.  This would require
26
# extending some of the tests in a fashion similar to that done for
27
# VxWorks, because the test output would appear on the other port,
28
# rather than being displayed by gdb.
29
 
30
load_lib remote.exp
31
load_lib gdb.exp
32
set gdb_prompt "\\(gdb\\)"
33
 
34
#
35
# gdb_load -- load a file into the GDB.
36
#             Returns a 0 if there was an error,
37
#                       1 if it load successfully.
38
#
39
proc gdb_load { arg } {
40
    global verbose
41
    global loadpath
42
    global loadfile
43
    global gdb_prompt
44
    global GDB
45
    global expect_out
46
 
47
    set loadfile [file tail $arg]
48
    set loadpath [file dirname $arg]
49
 
50
    gdb_file_cmd $arg
51
 
52
    if [target_info exists gdb_protocol] {
53
        set protocol [target_info gdb_protocol];
54
    } else {
55
        set protocol "sparclite"
56
    }
57
 
58
    if [target_info exists serial] {
59
        set targetname [target_info serial];
60
        set command "target $protocol [target_info serial]\n";
61
    } else {
62
        if ![target_info exists netport] {
63
            perror "Need either netport or gdb_serial entry for [target_info name].";
64
            return -1;
65
        }
66
        set targetname [target_info netport];
67
        set command "target $protocol udp [target_info netport]\n";
68
    }
69
    set timeout 60
70
    verbose "Timeout is now $timeout seconds" 2
71
    set try_count 0;
72
    send_gdb $command;
73
    gdb_expect {
74
         -re "Unknown response.*resetting the board.|remote timeout" {
75
            incr try_count;
76
            if { $try_count > 3 } {
77
                set try_count 0;
78
                reboot_target;
79
                sleep 5;
80
            }
81
            sleep 1;
82
            send_gdb $command;
83
            exp_continue;
84
        }
85
         -re "Remote target.*$gdb_prompt $" { }
86
         -re ".*SPARClite appears to be alive.*$gdb_prompt $"   {
87
            if $verbose>1 then {
88
                send_user "Set target to $targetname\n"
89
            }
90
        }
91
         timeout {
92
            perror "Couldn't set SLITE target."
93
            set timeout 10
94
            verbose "Timeout is now $timeout seconds" 2
95
            return -1
96
        }
97
    }
98
 
99
    if [target_info exists gdb_load_offset] {
100
        set offset "[target_info gdb_load_offset]";
101
    } else {
102
        set offset "";
103
    }
104
    if { 1 } {
105
        if [is_remote host] {
106
            set arg [remote_download host $arg];
107
            if { $arg == "" } {
108
                error "download failed"
109
                return -1;
110
            }
111
        }
112
        send_gdb "load $arg $offset\n"
113
        verbose "Loading $arg into $GDB" 2
114
        set timeout 2400
115
        verbose "Timeout is now $timeout seconds" 2
116
        gdb_expect {
117
             -re "Loading.*$gdb_prompt $" {
118
                verbose "Loaded $arg into $GDB" 1
119
                set timeout 30
120
                verbose "Timeout is now $timeout seconds" 2
121
            }
122
             -re "$gdb_prompt $"     {
123
                if $verbose>1 then {
124
                    perror "GDB couldn't load."
125
                }
126
            }
127
             timeout {
128
                if $verbose>1 then {
129
                    perror "Timed out trying to load $arg."
130
                }
131
            }
132
        }
133
    }
134
    # Some SPARClite boards automagically do a run after the program is
135
    # loaded.
136
    if [target_info exists need_monitor_run] {
137
        set timeout 10
138
        verbose "Timeout is now $timeout seconds, doing monitor run" 2
139
        send_gdb "monitor run\n";
140
        sleep 2;
141
        send_gdb "";
142
        gdb_expect {
143
             -re ".*$gdb_prompt $" { verbose "Run command succeded" }
144
             default {
145
                perror "error sending monitor run command";
146
            }
147
        }
148
    } else {
149
        sleep 2;
150
    }
151
 
152
    if [target_info exists gdb_serial] {
153
        set serial [target_info gdb_serial];
154
    } else {
155
        set serial [target_info serial];
156
    }
157
    send_gdb "target remote $serial\n"
158
    set timeout 60
159
    verbose "Timeout is now $timeout seconds" 2
160
    gdb_expect {
161
         -re ".*Kill it?.*y or n.*" {
162
            send_gdb "y\n";
163
            exp_continue
164
        }
165
         -re ".*$gdb_prompt $"  {
166
            verbose "Set remote target to [target_info serial]" 2
167
        }
168
         timeout {
169
            perror "Couldn't set remote target."
170
            set timeout 10
171
            verbose "Timeout is now $timeout seconds" 2
172
            return -1
173
        }
174
    }
175
 
176
    if [info exists expect_out(buffer)] then {
177
        send_log $expect_out(buffer)
178
    }
179
    return 0
180
}

powered by: WebSVN 2.1.0

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