| OLD | NEW |
| 1 # Copyright 1993, 1997-1998, 2007-2012 Free Software Foundation, Inc. | 1 # Copyright 1993-2013 Free Software Foundation, Inc. |
| 2 | 2 |
| 3 # This program is free software; you can redistribute it and/or modify | 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 | 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 | 5 # the Free Software Foundation; either version 3 of the License, or |
| 6 # (at your option) any later version. | 6 # (at your option) any later version. |
| 7 # | 7 # |
| 8 # This program is distributed in the hope that it will be useful, | 8 # This program is distributed in the hope that it will be useful, |
| 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 # GNU General Public License for more details. | 11 # GNU General Public License for more details. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 42 global gdb_prompt | 42 global gdb_prompt |
| 43 global GDB | 43 global GDB |
| 44 global expect_out | 44 global expect_out |
| 45 | 45 |
| 46 set loadfile [file tail $arg] | 46 set loadfile [file tail $arg] |
| 47 set loadpath [file dirname $arg] | 47 set loadpath [file dirname $arg] |
| 48 | 48 |
| 49 gdb_file_cmd $arg | 49 gdb_file_cmd $arg |
| 50 | 50 |
| 51 if [target_info exists gdb_protocol] { | 51 if [target_info exists gdb_protocol] { |
| 52 » set protocol [target_info gdb_protocol]; | 52 » set protocol [target_info gdb_protocol] |
| 53 } else { | 53 } else { |
| 54 set protocol "sparclite" | 54 set protocol "sparclite" |
| 55 } | 55 } |
| 56 | 56 |
| 57 if [target_info exists serial] { | 57 if [target_info exists serial] { |
| 58 » set targetname [target_info serial]; | 58 » set targetname [target_info serial] |
| 59 » set command "target $protocol [target_info serial]\n"; | 59 » set command "target $protocol [target_info serial]\n" |
| 60 } else { | 60 } else { |
| 61 if ![target_info exists netport] { | 61 if ![target_info exists netport] { |
| 62 » perror "Need either netport or gdb_serial entry for [target_info nam
e]."; | 62 » perror "Need either netport or gdb_serial entry for [target_info nam
e]." |
| 63 » return -1; | 63 » return -1 |
| 64 } | 64 } |
| 65 » set targetname [target_info netport]; | 65 » set targetname [target_info netport] |
| 66 » set command "target $protocol udp [target_info netport]\n"; | 66 » set command "target $protocol udp [target_info netport]\n" |
| 67 } | 67 } |
| 68 set timeout 60 | 68 set timeout 60 |
| 69 verbose "Timeout is now $timeout seconds" 2 | 69 verbose "Timeout is now $timeout seconds" 2 |
| 70 set try_count 0; | 70 set try_count 0 |
| 71 send_gdb $command; | 71 send_gdb $command |
| 72 gdb_expect { | 72 gdb_expect { |
| 73 -re "Unknown response.*resetting the board.|remote timeout" { | 73 -re "Unknown response.*resetting the board.|remote timeout" { |
| 74 » incr try_count; | 74 » incr try_count |
| 75 if { $try_count > 3 } { | 75 if { $try_count > 3 } { |
| 76 » » set try_count 0; | 76 » » set try_count 0 |
| 77 » » reboot_target; | 77 » » reboot_target |
| 78 » » sleep 5; | 78 » » sleep 5 |
| 79 } | 79 } |
| 80 » sleep 1; | 80 » sleep 1 |
| 81 » send_gdb $command; | 81 » send_gdb $command |
| 82 » exp_continue; | 82 » exp_continue |
| 83 } | 83 } |
| 84 -re "Remote target.*$gdb_prompt $" { } | 84 -re "Remote target.*$gdb_prompt $" { } |
| 85 -re ".*SPARClite appears to be alive.*$gdb_prompt $" { | 85 -re ".*SPARClite appears to be alive.*$gdb_prompt $" { |
| 86 if $verbose>1 then { | 86 if $verbose>1 then { |
| 87 send_user "Set target to $targetname\n" | 87 send_user "Set target to $targetname\n" |
| 88 } | 88 } |
| 89 } | 89 } |
| 90 timeout { | 90 timeout { |
| 91 perror "Couldn't set SLITE target." | 91 perror "Couldn't set SLITE target." |
| 92 set timeout 10 | 92 set timeout 10 |
| 93 verbose "Timeout is now $timeout seconds" 2 | 93 verbose "Timeout is now $timeout seconds" 2 |
| 94 return -1 | 94 return -1 |
| 95 } | 95 } |
| 96 } | 96 } |
| 97 | 97 |
| 98 if [target_info exists gdb_load_offset] { | 98 if [target_info exists gdb_load_offset] { |
| 99 » set offset "[target_info gdb_load_offset]"; | 99 » set offset "[target_info gdb_load_offset]" |
| 100 } else { | 100 } else { |
| 101 » set offset ""; | 101 » set offset "" |
| 102 } | 102 } |
| 103 if { 1 } { | 103 if { 1 } { |
| 104 if [is_remote host] { | 104 if [is_remote host] { |
| 105 » set arg [remote_download host $arg]; | 105 » set arg [remote_download host $arg] |
| 106 if { $arg == "" } { | 106 if { $arg == "" } { |
| 107 error "download failed" | 107 error "download failed" |
| 108 » » return -1; | 108 » » return -1 |
| 109 } | 109 } |
| 110 } | 110 } |
| 111 send_gdb "load $arg $offset\n" | 111 send_gdb "load $arg $offset\n" |
| 112 verbose "Loading $arg into $GDB" 2 | 112 verbose "Loading $arg into $GDB" 2 |
| 113 set timeout 2400 | 113 set timeout 2400 |
| 114 verbose "Timeout is now $timeout seconds" 2 | 114 verbose "Timeout is now $timeout seconds" 2 |
| 115 gdb_expect { | 115 gdb_expect { |
| 116 -re "Loading.*$gdb_prompt $" { | 116 -re "Loading.*$gdb_prompt $" { |
| 117 verbose "Loaded $arg into $GDB" 1 | 117 verbose "Loaded $arg into $GDB" 1 |
| 118 set timeout 30 | 118 set timeout 30 |
| 119 verbose "Timeout is now $timeout seconds" 2 | 119 verbose "Timeout is now $timeout seconds" 2 |
| 120 } | 120 } |
| 121 -re "$gdb_prompt $" { | 121 -re "$gdb_prompt $" { |
| 122 if $verbose>1 then { | 122 if $verbose>1 then { |
| 123 perror "GDB couldn't load." | 123 perror "GDB couldn't load." |
| 124 } | 124 } |
| 125 } | 125 } |
| 126 timeout { | 126 timeout { |
| 127 if $verbose>1 then { | 127 if $verbose>1 then { |
| 128 perror "Timed out trying to load $arg." | 128 perror "Timed out trying to load $arg." |
| 129 } | 129 } |
| 130 } | 130 } |
| 131 } | 131 } |
| 132 } | 132 } |
| 133 # Some SPARClite boards automagically do a run after the program is | 133 # Some SPARClite boards automagically do a run after the program is |
| 134 # loaded. | 134 # loaded. |
| 135 if [target_info exists need_monitor_run] { | 135 if [target_info exists need_monitor_run] { |
| 136 set timeout 10 | 136 set timeout 10 |
| 137 verbose "Timeout is now $timeout seconds, doing monitor run" 2 | 137 verbose "Timeout is now $timeout seconds, doing monitor run" 2 |
| 138 » send_gdb "monitor run\n"; | 138 » send_gdb "monitor run\n" |
| 139 » sleep 2; | 139 » sleep 2 |
| 140 » send_gdb ""; | 140 » send_gdb "" |
| 141 gdb_expect { | 141 gdb_expect { |
| 142 -re ".*$gdb_prompt $" { verbose "Run command succeded" } | 142 -re ".*$gdb_prompt $" { verbose "Run command succeded" } |
| 143 default { | 143 default { |
| 144 » » perror "error sending monitor run command"; | 144 » » perror "error sending monitor run command" |
| 145 } | 145 } |
| 146 } | 146 } |
| 147 } else { | 147 } else { |
| 148 » sleep 2; | 148 » sleep 2 |
| 149 } | 149 } |
| 150 | 150 |
| 151 if [target_info exists gdb_serial] { | 151 if [target_info exists gdb_serial] { |
| 152 » set serial [target_info gdb_serial]; | 152 » set serial [target_info gdb_serial] |
| 153 } else { | 153 } else { |
| 154 » set serial [target_info serial]; | 154 » set serial [target_info serial] |
| 155 } | 155 } |
| 156 send_gdb "target remote $serial\n" | 156 send_gdb "target remote $serial\n" |
| 157 set timeout 60 | 157 set timeout 60 |
| 158 verbose "Timeout is now $timeout seconds" 2 | 158 verbose "Timeout is now $timeout seconds" 2 |
| 159 gdb_expect { | 159 gdb_expect { |
| 160 -re ".*Kill it?.*y or n.*" { | 160 -re ".*Kill it?.*y or n.*" { |
| 161 » send_gdb "y\n"; | 161 » send_gdb "y\n" |
| 162 exp_continue | 162 exp_continue |
| 163 } | 163 } |
| 164 -re ".*$gdb_prompt $" { | 164 -re ".*$gdb_prompt $" { |
| 165 verbose "Set remote target to [target_info serial]" 2 | 165 verbose "Set remote target to [target_info serial]" 2 |
| 166 } | 166 } |
| 167 timeout { | 167 timeout { |
| 168 perror "Couldn't set remote target." | 168 perror "Couldn't set remote target." |
| 169 set timeout 10 | 169 set timeout 10 |
| 170 verbose "Timeout is now $timeout seconds" 2 | 170 verbose "Timeout is now $timeout seconds" 2 |
| 171 return -1 | 171 return -1 |
| 172 } | 172 } |
| 173 } | 173 } |
| 174 | 174 |
| 175 if [info exists expect_out(buffer)] then { | 175 if [info exists expect_out(buffer)] then { |
| 176 send_log $expect_out(buffer) | 176 send_log $expect_out(buffer) |
| 177 } | 177 } |
| 178 return 0 | 178 return 0 |
| 179 } | 179 } |
| OLD | NEW |