Skip to content

Commit 880aefa

Browse files
Restart nSIM and GDB each time for GCC tests
There seem to be issues with scenarios where GDB uses `file` command to load new application - for some reason debug symbols loaded seem to be off the previous application, thus breakpoint at `exit()` is installed improperly. To workaround that issues this patch modifued "gdb-comm.exp" board to quit GDB and nSIM each time where possible. Signed-off-by: Anton Kolesov <[email protected]>
1 parent 92accaa commit 880aefa

File tree

2 files changed

+22
-32
lines changed

2 files changed

+22
-32
lines changed

dejagnu/baseboards/arc-nsim.exp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ set_board_info ldscript ""
6969
# Call to nsim_open will set the netport (used by gdb-comm) as well as setting
7070
# up nSim specific data.
7171
set port [exec [file dirname $env(DEJAGNU)]/get-random-port.sh]
72-
nsim_open $port
72+
set_board_info nsim_port $port
7373

7474
# GDB protocol to be used
7575
set_board_info gdb_protocol "remote"

dejagnu/nsim-extra.exp

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -111,41 +111,31 @@ 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-
}
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+
}
137128

138-
remote_send host "set \$blink=0\n"
139-
remote_expect host 10 {
140-
-re ".*$gdb_prompt $" {}
141-
}
129+
proc gdb_comm_start { dest } {
130+
global board board_info
142131

143-
remote_send host "set \$lp_count=0\n"
144-
remote_expect host 10 {
145-
-re ".*$gdb_prompt $" {}
132+
if { ![info exists board] } {
133+
set board $dest
146134
}
147135

148-
arc_saved_gdb_comm_go_idle
136+
verbose "ARC specific gdb_comm_start"
137+
nsim_open [target_info nsim_port]
138+
arc_saved_gdb_comm_start $dest
149139
}
150140

151141
# vim: noexpandtab sts=4 ts=8:

0 commit comments

Comments
 (0)