@@ -111,31 +111,41 @@ proc arc-nsim_reboot { connhost args } {
111111 return 1
112112}
113113
114- # There are problems with GDB loading new application with `file` command, at
115- # least when new file has same filename as the old one. That problem is
116- # not-deterministic and I wasn't able to trace down the source, however I see
117- # that this happened between 7.5 and 7.6. To avoid troubles - restart GDB
118- # completely. Restarting nSIM is not really required if it's registers are
119- # reset, however for a good measure it is better to restart it, at the price of
120- # performance penalty for restarting, of course.
121- rename gdb_comm_start arc_saved_gdb_comm_start
122-
123- proc gdb_comm_leave { } {
124- verbose " ARC specific gdb_comm_leave"
125- nsim_close
126- quit_gdb
127- }
114+ # By default between tests GDB will do `target exec`, then will reconnect to
115+ # target with `target remote`. As a result target will be left at the state of
116+ # end of previous test, likely in `exit()`. When GDB will reconnect with new
117+ # application, it will automatically try to unwind trace using old register
118+ # values, that will happen immediately after `target remote` before `load` that
119+ # will overwrite PC register. Consequently old-register values will be used and
120+ # in some unfortunate cases that might cause a failed assert in GDB. To avoid
121+ # possible issues this board should redefine gdb_comm_go_idle, so before
122+ # disconnecting from target GDB will reset crucial registers to 0.
123+ rename gdb_comm_go_idle arc_saved_gdb_comm_go_idle
124+
125+ proc gdb_comm_go_idle {} {
126+ global gdb_prompt
127+
128+ # Original gdb_comm_go_idle does the same, so it is save to not call it.
129+ if {! [board_info host exists fileid]} {
130+ return -1
131+ }
128132
129- proc gdb_comm_start { dest } {
130- global board board_info
133+ remote_send host " set \$ pc=0\n"
134+ remote_expect host 10 {
135+ -re " .*$gdb_prompt $" {}
136+ }
131137
132- if { ! [info exists board] } {
133- set board $dest
138+ remote_send host " set \$ blink=0\n"
139+ remote_expect host 10 {
140+ -re " .*$gdb_prompt $" {}
134141 }
135142
136- verbose " ARC specific gdb_comm_start"
137- nsim_open [target_info nsim_port]
138- arc_saved_gdb_comm_start $dest
143+ remote_send host " set \$ lp_count=0\n"
144+ remote_expect host 10 {
145+ -re " .*$gdb_prompt $" {}
146+ }
147+
148+ arc_saved_gdb_comm_go_idle
139149}
140150
141151# vim: noexpandtab sts=4 ts=8:
0 commit comments