+2020-05-25 Simon Marchi <simon.marchi@efficios.com>
+
+ * lib/gdb.exp (gdb_run_cmd): Change argument from args to
+ inferior_args. Pass it to gdb_reload.
+ (gdb_start_cmd, gdb_starti_cmd): Change argument from args to
+ inferior_args.
+ (gdb_reload): Add inferior_args argument.
+ * config/gdbserver.exp (gdb_reload): Add inferior_args argument,
+ pass it to gdbserver_run.
+ * boards/native-gdbserver.exp: Do not set noargs.
+ * boards/native-extended-gdbserver.exp (gdb_reload): Add
+ inferior_args argument.
+ * boards/stdio-gdbserver-base.exp (gdb_reload): Likewise.
+ * gdb.base/a2-run.exp: Check for use_gdb_stub.
+ * gdb.base/args.exp: Likewise.
+
2020-05-25 Tom de Vries <tdevries@suse.de>
* lib/gdb.exp (exec_is_pie): Add comment.
# Unles you have a gdbserver that can handle multiple sessions.
#
# set_board_info noargs 1
-# At present there is no provision in the remote protocol
-# for passing arguments. This test framework does not
-# address the issue, so it's best to set this variable
-# in your baseboard configuration file.
-# FIXME: there's no reason why the test harness couldn't
-# pass commandline args when it spawns gdbserver.
+# Set this if the board does not support passing arguments to the
+# inferior process.
#
# set_board_info gdb,noinferiorio 1
# Neither the traditional gdbserver nor the one in libremote
return [gdbserver_spawn ""]
}
-proc gdb_reload { } {
- return [gdbserver_run ""]
+proc gdb_reload { {inferior_args {}} } {
+ return [gdbserver_run $inferior_args]
}
proc gdb_reconnect { } {
# Using ``.*$'' could swallow up output that we attempt to match
# elsewhere.
#
+# INFERIOR_ARGS is passed as arguments to the start command, so may contain
+# inferior arguments.
+#
# N.B. This function does not wait for gdb to return to the prompt,
# that is the caller's responsibility.
-proc gdb_run_cmd {args} {
+proc gdb_run_cmd { {inferior_args {}} } {
global gdb_prompt use_gdb_stub
foreach command [gdb_init_commands] {
if $use_gdb_stub {
if [target_info exists gdb,do_reload_on_run] {
- if { [gdb_reload] != 0 } {
+ if { [gdb_reload $inferior_args] != 0 } {
return
}
send_gdb "continue\n"
send_gdb "y\n" answer
}
-re "The program is not being run.*$gdb_prompt $" {
- if { [gdb_reload] != 0 } {
+ if { [gdb_reload $inferior_args] != 0 } {
return
}
send_gdb "jump *$start\n"
}
if [target_info exists gdb,do_reload_on_run] {
- if { [gdb_reload] != 0 } {
+ if { [gdb_reload $inferior_args] != 0 } {
return
}
}
- send_gdb "run $args\n"
+ send_gdb "run $inferior_args\n"
# This doesn't work quite right yet.
# Use -notransfer here so that test cases (like chng-sym.exp)
# may test for additional start-up messages.
# Generic start command. Return 0 if we could start the program, -1
# if we could not.
#
+# INFERIOR_ARGS is passed as arguments to the start command, so may contain
+# inferior arguments.
+#
# N.B. This function does not wait for gdb to return to the prompt,
# that is the caller's responsibility.
-proc gdb_start_cmd {args} {
+proc gdb_start_cmd { {inferior_args {}} } {
global gdb_prompt use_gdb_stub
foreach command [gdb_init_commands] {
return -1
}
- send_gdb "start $args\n"
+ send_gdb "start $inferior_args\n"
# Use -notransfer here so that test cases (like chng-sym.exp)
# may test for additional start-up messages.
gdb_expect 60 {
# Generic starti command. Return 0 if we could start the program, -1
# if we could not.
#
+# INFERIOR_ARGS is passed as arguments to the starti command, so may contain
+# inferior arguments.
+#
# N.B. This function does not wait for gdb to return to the prompt,
# that is the caller's responsibility.
-proc gdb_starti_cmd {args} {
+proc gdb_starti_cmd { {inferior_args {}} } {
global gdb_prompt use_gdb_stub
foreach command [gdb_init_commands] {
return -1
}
- send_gdb "starti $args\n"
+ send_gdb "starti $inferior_args\n"
gdb_expect 60 {
-re "The program .* has been started already.*y or n. $" {
send_gdb "y\n" answer
# either the first time or after already starting the program once,
# for remote targets. Most files that override gdb_load should now
# override this instead.
+#
+# INFERIOR_ARGS contains the arguments to pass to the inferiors, as a
+# single string to get interpreted by a shell. If the target board
+# overriding gdb_reload is a "stub", then it should arrange things such
+# these arguments make their way to the inferior process.
-proc gdb_reload { } {
+proc gdb_reload { {inferior_args {}} } {
# For the benefit of existing configurations, default to gdb_load.
# Specifying no file defaults to the executable currently being
# debugged.