Skip to content

Commit 03cacd3

Browse files
Ensure that cpu state is reset before tests on nSIM GDB board
Non-reseted board can cause issues while running next test and even crash GDB due to inconsistency between old registers state and new debug info. Signed-off-by: Anton Kolesov <[email protected]>
1 parent 14b777e commit 03cacd3

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

dejagnu/nsim-extra.exp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,41 @@ proc arc-nsim_reboot { connhost args } {
111111
return 1
112112
}
113113

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+
}
132+
133+
remote_send host "set \$pc=0\n"
134+
remote_expect host 10 {
135+
-re ".*$gdb_prompt $" {}
136+
}
137+
138+
remote_send host "set \$blink=0\n"
139+
remote_expect host 10 {
140+
-re ".*$gdb_prompt $" {}
141+
}
142+
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
149+
}
150+
114151
# vim: noexpandtab sts=4 ts=8:

0 commit comments

Comments
 (0)