OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-6.8/] [gdb/] [testsuite/] [config/] [slite.exp] - Blame information for rev 157

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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