2014-01-01 03:54:24 +00:00
|
|
|
|
# Copyright 2000-2014 Free Software Foundation, Inc.
|
2005-04-08 12:57:00 +00:00
|
|
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
2007-08-23 18:14:19 +00:00
|
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
2005-04-08 12:57:00 +00:00
|
|
|
|
# (at your option) any later version.
|
2007-08-23 18:14:19 +00:00
|
|
|
|
#
|
2005-04-08 12:57:00 +00:00
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
# GNU General Public License for more details.
|
2007-08-23 18:14:19 +00:00
|
|
|
|
#
|
2005-04-08 12:57:00 +00:00
|
|
|
|
# You should have received a copy of the GNU General Public License
|
2007-08-23 18:14:19 +00:00
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2005-04-08 12:57:00 +00:00
|
|
|
|
|
|
|
|
|
# This file is based on config/gdbserver.exp, which was written by
|
|
|
|
|
# Michael Snyder (msnyder@redhat.com).
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# To be addressed or set in your baseboard config file:
|
|
|
|
|
#
|
|
|
|
|
# set_board_info gdb_protocol "remote"
|
|
|
|
|
# Unles you have a gdbserver that uses a different protocol...
|
2011-12-03 20:20:29 +00:00
|
|
|
|
# After GDB starts you should check global $gdbserver_protocol instead as
|
|
|
|
|
# the testfile may force a specific different target protocol itself.
|
2005-04-08 12:57:00 +00:00
|
|
|
|
#
|
|
|
|
|
# set_board_info gdb_server_prog
|
|
|
|
|
# This will be the path to the gdbserver program you want to test.
|
|
|
|
|
# Defaults to "gdbserver".
|
|
|
|
|
#
|
|
|
|
|
# set_board_info sockethost
|
|
|
|
|
# The name of the host computer whose socket is being used.
|
|
|
|
|
# Defaults to "localhost". Note: old gdbserver requires
|
|
|
|
|
# that you define this, but libremote/gdbserver does not.
|
|
|
|
|
#
|
|
|
|
|
# set_board_info gdb,socketport
|
|
|
|
|
# Port id to use for socket connection. If not set explicitly,
|
|
|
|
|
# it will start at "2345" and increment for each use.
|
2011-12-03 20:20:29 +00:00
|
|
|
|
# After GDB starts you should check global $gdbserver_gdbport for the
|
|
|
|
|
# real port used. It is not useful if $gdbserver_reconnect_p was not set.
|
2005-04-08 12:57:00 +00:00
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# gdb_target_cmd
|
|
|
|
|
# Send gdb the "target" command
|
|
|
|
|
#
|
|
|
|
|
proc gdb_target_cmd { targetname serialport } {
|
|
|
|
|
global gdb_prompt
|
|
|
|
|
|
2007-04-25 15:56:15 +00:00
|
|
|
|
set serialport_re [string_to_regexp $serialport]
|
2005-04-08 12:57:00 +00:00
|
|
|
|
for {set i 1} {$i <= 3} {incr i} {
|
|
|
|
|
send_gdb "target $targetname $serialport\n"
|
|
|
|
|
gdb_expect 60 {
|
|
|
|
|
-re "A program is being debugged already.*ill it.*y or n. $" {
|
|
|
|
|
send_gdb "y\n"
|
|
|
|
|
exp_continue
|
|
|
|
|
}
|
2008-01-29 19:36:58 +00:00
|
|
|
|
-re "unknown host.*$gdb_prompt" {
|
|
|
|
|
verbose "Couldn't look up $serialport"
|
|
|
|
|
}
|
2006-10-18 16:49:05 +00:00
|
|
|
|
-re "Couldn't establish connection to remote.*$gdb_prompt $" {
|
2005-04-08 12:57:00 +00:00
|
|
|
|
verbose "Connection failed"
|
|
|
|
|
}
|
|
|
|
|
-re "Remote MIPS debugging.*$gdb_prompt" {
|
|
|
|
|
verbose "Set target to $targetname"
|
|
|
|
|
return 0
|
|
|
|
|
}
|
2007-04-25 15:56:15 +00:00
|
|
|
|
-re "Remote debugging using .*$serialport_re.*$gdb_prompt $" {
|
2005-04-08 12:57:00 +00:00
|
|
|
|
verbose "Set target to $targetname"
|
|
|
|
|
return 0
|
|
|
|
|
}
|
2011-12-16 19:06:38 +00:00
|
|
|
|
-re "Remote debugging using stdio.*$gdb_prompt $" {
|
|
|
|
|
verbose "Set target to $targetname"
|
|
|
|
|
return 0
|
|
|
|
|
}
|
2006-10-18 16:49:05 +00:00
|
|
|
|
-re "Remote target $targetname connected to.*$gdb_prompt $" {
|
2005-04-08 12:57:00 +00:00
|
|
|
|
verbose "Set target to $targetname"
|
|
|
|
|
return 0
|
|
|
|
|
}
|
2006-10-18 16:49:05 +00:00
|
|
|
|
-re "Connected to.*$gdb_prompt $" {
|
2005-04-08 12:57:00 +00:00
|
|
|
|
verbose "Set target to $targetname"
|
|
|
|
|
return 0
|
|
|
|
|
}
|
2006-10-18 16:49:05 +00:00
|
|
|
|
-re "Ending remote.*$gdb_prompt $" { }
|
|
|
|
|
-re "Connection refused.*$gdb_prompt $" {
|
2005-04-08 12:57:00 +00:00
|
|
|
|
verbose "Connection refused by remote target. Pausing, and trying again."
|
|
|
|
|
sleep 30
|
|
|
|
|
continue
|
|
|
|
|
}
|
2006-10-18 16:49:05 +00:00
|
|
|
|
-re "Timeout reading from remote system.*$gdb_prompt $" {
|
2005-04-08 12:57:00 +00:00
|
|
|
|
verbose "Got timeout error from gdb."
|
|
|
|
|
}
|
2007-03-27 17:59:38 +00:00
|
|
|
|
-notransfer -re "Remote debugging using .*\r\n> $" {
|
|
|
|
|
# We got an unexpected prompt while creating the target.
|
|
|
|
|
# Leave it there for the test to diagnose.
|
|
|
|
|
return 1
|
|
|
|
|
}
|
2005-04-08 12:57:00 +00:00
|
|
|
|
timeout {
|
|
|
|
|
send_gdb ""
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
global portnum
|
|
|
|
|
set portnum "2345"
|
|
|
|
|
|
|
|
|
|
# Locate the gdbserver binary. Returns "" if gdbserver could not be found.
|
|
|
|
|
|
|
|
|
|
proc find_gdbserver { } {
|
|
|
|
|
global GDB
|
2008-05-12 17:25:28 +00:00
|
|
|
|
global GDBSERVER
|
|
|
|
|
|
|
|
|
|
if [info exists GDBSERVER] {
|
|
|
|
|
return ${GDBSERVER}
|
|
|
|
|
}
|
2005-04-08 12:57:00 +00:00
|
|
|
|
|
|
|
|
|
if [target_info exists gdb_server_prog] {
|
|
|
|
|
return [target_info gdb_server_prog]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set gdbserver "${GDB}server"
|
|
|
|
|
if { [file isdirectory $gdbserver] } {
|
|
|
|
|
append gdbserver "/gdbserver"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if { [file executable $gdbserver] } {
|
|
|
|
|
return $gdbserver
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ""
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Return non-zero if we should skip gdbserver-specific tests.
|
|
|
|
|
|
|
|
|
|
proc skip_gdbserver_tests { } {
|
|
|
|
|
if { [find_gdbserver] == "" } {
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
* linux-low.c (linux_attach_lwp): Do not _exit after errors.
(linux_kill, linux_detach): Clean up the process list.
* remote-utils.c (remote_open): Improve port number parsing.
(putpkt_binary, input_interrupt): Only send interrupts if the target
is running.
* server.c (extended_protocol): Make static.
(attached): Define earlier.
(exit_requested, response_needed, program_argv): New variables.
(target_running): New.
(start_inferior): Clear attached here.
(attach_inferior): Set attached here.
(require_running): Define.
(handle_query): Use require_running and target_running. Implement
"monitor exit".
(handle_v_attach, handle_v_run): New.
(handle_v_requests): Use require_running. Handle vAttach and vRun.
(gdbserver_usage): Update.
(main): Redo argument parsing. Handle --debug and --multi. Handle
--attach along with other options or after the port. Save
program_argv. Support no initial program. Resynchronize
communication with GDB after an error. Handle "monitor exit".
Use require_running and target_running. Always allow the extended
protocol. Do not error out for Hc0 or Hc-1. Do not automatically
restart in extended mode.
* README: Refer to the GDB manual. Update --attach usage.
* remote.c (struct remote_state): Add cached_wait_status.
(remote_exec_file): New variable.
(PACKET_vAttach, PACKET_vRun): New constants.
(extended_remote_restart): Do not query for status.
(struct start_remote_args): New.
(remote_start_remote): Take it as a second argument. Check
whether the target is running. Issue an error for non-running
non-extended targets. Cache the wait status. Set inferior_ptid
here.
(remote_open_1): Prompt to disconnect non-running targets. Make
sure the target is marked running. Do not set inferior_ptid here.
Update call to remote_start_remote. Do not call remote_check_symbols
if the target is not running.
(remote_detach_1): Rename from remote_detach. Take an EXTENDED
argument. Handle a non-running target.
(remote_detach): Use it.
(extended_remote_detach): New.
(remote_disconnect): Fix typo. Use remoute_mourn_1.
(extended_remote_attach_1, extended_remote_attach)
(extended_async_remote_attach): New.
(remote_vcont_resume): Remove unused variable.
(remote_wait, remote_async_wait): Use any cached wait status.
(putpkt_binary, getpkt): Clear any cached wait status.
(extended_remoute_mourn_1): New.
(extended_remote_mourn): Use it.
(extended_async_remote_mourn, extended_remote_run): New.
(extended_remote_create_inferior_1): New.
(extended_remote_create_inferior): Use it.
(extended_remote_async_create_inferior): Likewise.
(remote_xfer_partial): Skip for non-executing targets.
(init_extended_remote_ops): Set to_detach and to_attach.
(init_extended_async_remote_ops): Likewise. Use
extended_async_remote_mourn.
(_initialize_remote): Register vAttach, vRun, and
set remote exec-file.
* NEWS: Mention vAttach, vRun, and gdbserver extended-remote support.
* gdb.server/ext-attach.c, gdb.server/ext-attach.exp,
gdb.server/ext-run.exp: New files.
* lib/gdbserver-support.exp (gdbserver_download): New.
(gdbserver_start): New. Update gdbserver expected
output.
(gdbserver_spawn): Use them.
(gdbserver_start_extended): New.
* gdb.texinfo (Using the `gdbserver' Program): Add security
warning. Rearrange into subsections and subsubsections. Document
--multi and --debug. Correct --with-sysroot typo. Update --attach
usage. Make load reference clearer. Document monitor exit.
(Remote Configuration): Document set remote exec-file, attach-packet,
and run-packet.
(Packets): Document vAttach and vRun.
2008-01-30 00:51:50 +00:00
|
|
|
|
# Download the currently loaded program to the target if necessary.
|
|
|
|
|
# Return the target system filename.
|
2010-01-12 00:50:26 +00:00
|
|
|
|
# NOTE: This was named "gdbserver_download", but that collides with the
|
|
|
|
|
# dejagnu "download" API function when using load_generic_config "gdbserver".
|
2005-04-08 12:57:00 +00:00
|
|
|
|
|
2010-01-12 00:50:26 +00:00
|
|
|
|
proc gdbserver_download_current_prog { } {
|
2007-03-27 17:59:38 +00:00
|
|
|
|
global gdbserver_host_exec
|
|
|
|
|
global gdbserver_host_mtime
|
|
|
|
|
global gdbserver_server_exec
|
|
|
|
|
global last_loaded_file
|
|
|
|
|
|
|
|
|
|
set host_exec $last_loaded_file
|
|
|
|
|
|
|
|
|
|
# If we already downloaded a file to the target, see if we can reuse it.
|
|
|
|
|
set reuse 0
|
|
|
|
|
if { [info exists gdbserver_server_exec] } {
|
|
|
|
|
set reuse 1
|
|
|
|
|
|
|
|
|
|
# If the file has changed, we can not.
|
|
|
|
|
if { $host_exec != $gdbserver_host_exec } {
|
|
|
|
|
set reuse 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# If the mtime has changed, we can not.
|
|
|
|
|
if { [file mtime $host_exec] != $gdbserver_host_mtime } {
|
|
|
|
|
set reuse 0
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if { $reuse == 0 } {
|
|
|
|
|
set gdbserver_host_exec $host_exec
|
|
|
|
|
set gdbserver_host_mtime [file mtime $host_exec]
|
|
|
|
|
if [is_remote target] {
|
2007-05-16 14:21:47 +00:00
|
|
|
|
set gdbserver_server_exec [gdb_download $host_exec]
|
2007-03-27 17:59:38 +00:00
|
|
|
|
} else {
|
|
|
|
|
set gdbserver_server_exec $host_exec
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-04-08 12:57:00 +00:00
|
|
|
|
|
* linux-low.c (linux_attach_lwp): Do not _exit after errors.
(linux_kill, linux_detach): Clean up the process list.
* remote-utils.c (remote_open): Improve port number parsing.
(putpkt_binary, input_interrupt): Only send interrupts if the target
is running.
* server.c (extended_protocol): Make static.
(attached): Define earlier.
(exit_requested, response_needed, program_argv): New variables.
(target_running): New.
(start_inferior): Clear attached here.
(attach_inferior): Set attached here.
(require_running): Define.
(handle_query): Use require_running and target_running. Implement
"monitor exit".
(handle_v_attach, handle_v_run): New.
(handle_v_requests): Use require_running. Handle vAttach and vRun.
(gdbserver_usage): Update.
(main): Redo argument parsing. Handle --debug and --multi. Handle
--attach along with other options or after the port. Save
program_argv. Support no initial program. Resynchronize
communication with GDB after an error. Handle "monitor exit".
Use require_running and target_running. Always allow the extended
protocol. Do not error out for Hc0 or Hc-1. Do not automatically
restart in extended mode.
* README: Refer to the GDB manual. Update --attach usage.
* remote.c (struct remote_state): Add cached_wait_status.
(remote_exec_file): New variable.
(PACKET_vAttach, PACKET_vRun): New constants.
(extended_remote_restart): Do not query for status.
(struct start_remote_args): New.
(remote_start_remote): Take it as a second argument. Check
whether the target is running. Issue an error for non-running
non-extended targets. Cache the wait status. Set inferior_ptid
here.
(remote_open_1): Prompt to disconnect non-running targets. Make
sure the target is marked running. Do not set inferior_ptid here.
Update call to remote_start_remote. Do not call remote_check_symbols
if the target is not running.
(remote_detach_1): Rename from remote_detach. Take an EXTENDED
argument. Handle a non-running target.
(remote_detach): Use it.
(extended_remote_detach): New.
(remote_disconnect): Fix typo. Use remoute_mourn_1.
(extended_remote_attach_1, extended_remote_attach)
(extended_async_remote_attach): New.
(remote_vcont_resume): Remove unused variable.
(remote_wait, remote_async_wait): Use any cached wait status.
(putpkt_binary, getpkt): Clear any cached wait status.
(extended_remoute_mourn_1): New.
(extended_remote_mourn): Use it.
(extended_async_remote_mourn, extended_remote_run): New.
(extended_remote_create_inferior_1): New.
(extended_remote_create_inferior): Use it.
(extended_remote_async_create_inferior): Likewise.
(remote_xfer_partial): Skip for non-executing targets.
(init_extended_remote_ops): Set to_detach and to_attach.
(init_extended_async_remote_ops): Likewise. Use
extended_async_remote_mourn.
(_initialize_remote): Register vAttach, vRun, and
set remote exec-file.
* NEWS: Mention vAttach, vRun, and gdbserver extended-remote support.
* gdb.server/ext-attach.c, gdb.server/ext-attach.exp,
gdb.server/ext-run.exp: New files.
* lib/gdbserver-support.exp (gdbserver_download): New.
(gdbserver_start): New. Update gdbserver expected
output.
(gdbserver_spawn): Use them.
(gdbserver_start_extended): New.
* gdb.texinfo (Using the `gdbserver' Program): Add security
warning. Rearrange into subsections and subsubsections. Document
--multi and --debug. Correct --with-sysroot typo. Update --attach
usage. Make load reference clearer. Document monitor exit.
(Remote Configuration): Document set remote exec-file, attach-packet,
and run-packet.
(Packets): Document vAttach and vRun.
2008-01-30 00:51:50 +00:00
|
|
|
|
return $gdbserver_server_exec
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-16 19:06:38 +00:00
|
|
|
|
# Default routine to compute the argument to "target remote".
|
|
|
|
|
|
|
|
|
|
proc gdbserver_default_get_remote_address { host port } {
|
2014-04-16 17:40:41 +00:00
|
|
|
|
# Historically HOST included the trailing ":".
|
|
|
|
|
# To avoid breaking any board files out there we leave things alone.
|
2011-12-16 19:06:38 +00:00
|
|
|
|
return "$host$port"
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-16 17:40:41 +00:00
|
|
|
|
# Default routine to compute the "comm" argument for gdbserver.
|
|
|
|
|
|
|
|
|
|
proc gdbserver_default_get_comm_port { port } {
|
|
|
|
|
return ":$port"
|
|
|
|
|
}
|
|
|
|
|
|
* linux-low.c (linux_attach_lwp): Do not _exit after errors.
(linux_kill, linux_detach): Clean up the process list.
* remote-utils.c (remote_open): Improve port number parsing.
(putpkt_binary, input_interrupt): Only send interrupts if the target
is running.
* server.c (extended_protocol): Make static.
(attached): Define earlier.
(exit_requested, response_needed, program_argv): New variables.
(target_running): New.
(start_inferior): Clear attached here.
(attach_inferior): Set attached here.
(require_running): Define.
(handle_query): Use require_running and target_running. Implement
"monitor exit".
(handle_v_attach, handle_v_run): New.
(handle_v_requests): Use require_running. Handle vAttach and vRun.
(gdbserver_usage): Update.
(main): Redo argument parsing. Handle --debug and --multi. Handle
--attach along with other options or after the port. Save
program_argv. Support no initial program. Resynchronize
communication with GDB after an error. Handle "monitor exit".
Use require_running and target_running. Always allow the extended
protocol. Do not error out for Hc0 or Hc-1. Do not automatically
restart in extended mode.
* README: Refer to the GDB manual. Update --attach usage.
* remote.c (struct remote_state): Add cached_wait_status.
(remote_exec_file): New variable.
(PACKET_vAttach, PACKET_vRun): New constants.
(extended_remote_restart): Do not query for status.
(struct start_remote_args): New.
(remote_start_remote): Take it as a second argument. Check
whether the target is running. Issue an error for non-running
non-extended targets. Cache the wait status. Set inferior_ptid
here.
(remote_open_1): Prompt to disconnect non-running targets. Make
sure the target is marked running. Do not set inferior_ptid here.
Update call to remote_start_remote. Do not call remote_check_symbols
if the target is not running.
(remote_detach_1): Rename from remote_detach. Take an EXTENDED
argument. Handle a non-running target.
(remote_detach): Use it.
(extended_remote_detach): New.
(remote_disconnect): Fix typo. Use remoute_mourn_1.
(extended_remote_attach_1, extended_remote_attach)
(extended_async_remote_attach): New.
(remote_vcont_resume): Remove unused variable.
(remote_wait, remote_async_wait): Use any cached wait status.
(putpkt_binary, getpkt): Clear any cached wait status.
(extended_remoute_mourn_1): New.
(extended_remote_mourn): Use it.
(extended_async_remote_mourn, extended_remote_run): New.
(extended_remote_create_inferior_1): New.
(extended_remote_create_inferior): Use it.
(extended_remote_async_create_inferior): Likewise.
(remote_xfer_partial): Skip for non-executing targets.
(init_extended_remote_ops): Set to_detach and to_attach.
(init_extended_async_remote_ops): Likewise. Use
extended_async_remote_mourn.
(_initialize_remote): Register vAttach, vRun, and
set remote exec-file.
* NEWS: Mention vAttach, vRun, and gdbserver extended-remote support.
* gdb.server/ext-attach.c, gdb.server/ext-attach.exp,
gdb.server/ext-run.exp: New files.
* lib/gdbserver-support.exp (gdbserver_download): New.
(gdbserver_start): New. Update gdbserver expected
output.
(gdbserver_spawn): Use them.
(gdbserver_start_extended): New.
* gdb.texinfo (Using the `gdbserver' Program): Add security
warning. Rearrange into subsections and subsubsections. Document
--multi and --debug. Correct --with-sysroot typo. Update --attach
usage. Make load reference clearer. Document monitor exit.
(Remote Configuration): Document set remote exec-file, attach-packet,
and run-packet.
(Packets): Document vAttach and vRun.
2008-01-30 00:51:50 +00:00
|
|
|
|
# Start a gdbserver process with initial OPTIONS and trailing ARGUMENTS.
|
|
|
|
|
# The port will be filled in between them automatically.
|
|
|
|
|
#
|
|
|
|
|
# Returns the target protocol and socket to connect to.
|
|
|
|
|
|
|
|
|
|
proc gdbserver_start { options arguments } {
|
|
|
|
|
global portnum
|
|
|
|
|
|
2005-04-08 12:57:00 +00:00
|
|
|
|
# Port id -- either specified in baseboard file, or managed here.
|
|
|
|
|
if [target_info exists gdb,socketport] {
|
|
|
|
|
set portnum [target_info gdb,socketport]
|
|
|
|
|
} else {
|
|
|
|
|
# Bump the port number to avoid conflicts with hung ports.
|
|
|
|
|
incr portnum
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Extract the local and remote host ids from the target board struct.
|
|
|
|
|
if [target_info exists sockethost] {
|
* linux-low.c (linux_attach_lwp): Do not _exit after errors.
(linux_kill, linux_detach): Clean up the process list.
* remote-utils.c (remote_open): Improve port number parsing.
(putpkt_binary, input_interrupt): Only send interrupts if the target
is running.
* server.c (extended_protocol): Make static.
(attached): Define earlier.
(exit_requested, response_needed, program_argv): New variables.
(target_running): New.
(start_inferior): Clear attached here.
(attach_inferior): Set attached here.
(require_running): Define.
(handle_query): Use require_running and target_running. Implement
"monitor exit".
(handle_v_attach, handle_v_run): New.
(handle_v_requests): Use require_running. Handle vAttach and vRun.
(gdbserver_usage): Update.
(main): Redo argument parsing. Handle --debug and --multi. Handle
--attach along with other options or after the port. Save
program_argv. Support no initial program. Resynchronize
communication with GDB after an error. Handle "monitor exit".
Use require_running and target_running. Always allow the extended
protocol. Do not error out for Hc0 or Hc-1. Do not automatically
restart in extended mode.
* README: Refer to the GDB manual. Update --attach usage.
* remote.c (struct remote_state): Add cached_wait_status.
(remote_exec_file): New variable.
(PACKET_vAttach, PACKET_vRun): New constants.
(extended_remote_restart): Do not query for status.
(struct start_remote_args): New.
(remote_start_remote): Take it as a second argument. Check
whether the target is running. Issue an error for non-running
non-extended targets. Cache the wait status. Set inferior_ptid
here.
(remote_open_1): Prompt to disconnect non-running targets. Make
sure the target is marked running. Do not set inferior_ptid here.
Update call to remote_start_remote. Do not call remote_check_symbols
if the target is not running.
(remote_detach_1): Rename from remote_detach. Take an EXTENDED
argument. Handle a non-running target.
(remote_detach): Use it.
(extended_remote_detach): New.
(remote_disconnect): Fix typo. Use remoute_mourn_1.
(extended_remote_attach_1, extended_remote_attach)
(extended_async_remote_attach): New.
(remote_vcont_resume): Remove unused variable.
(remote_wait, remote_async_wait): Use any cached wait status.
(putpkt_binary, getpkt): Clear any cached wait status.
(extended_remoute_mourn_1): New.
(extended_remote_mourn): Use it.
(extended_async_remote_mourn, extended_remote_run): New.
(extended_remote_create_inferior_1): New.
(extended_remote_create_inferior): Use it.
(extended_remote_async_create_inferior): Likewise.
(remote_xfer_partial): Skip for non-executing targets.
(init_extended_remote_ops): Set to_detach and to_attach.
(init_extended_async_remote_ops): Likewise. Use
extended_async_remote_mourn.
(_initialize_remote): Register vAttach, vRun, and
set remote exec-file.
* NEWS: Mention vAttach, vRun, and gdbserver extended-remote support.
* gdb.server/ext-attach.c, gdb.server/ext-attach.exp,
gdb.server/ext-run.exp: New files.
* lib/gdbserver-support.exp (gdbserver_download): New.
(gdbserver_start): New. Update gdbserver expected
output.
(gdbserver_spawn): Use them.
(gdbserver_start_extended): New.
* gdb.texinfo (Using the `gdbserver' Program): Add security
warning. Rearrange into subsections and subsubsections. Document
--multi and --debug. Correct --with-sysroot typo. Update --attach
usage. Make load reference clearer. Document monitor exit.
(Remote Configuration): Document set remote exec-file, attach-packet,
and run-packet.
(Packets): Document vAttach and vRun.
2008-01-30 00:51:50 +00:00
|
|
|
|
set debughost [target_info sockethost]
|
2005-04-08 12:57:00 +00:00
|
|
|
|
} else {
|
|
|
|
|
set debughost "localhost:"
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-16 19:06:38 +00:00
|
|
|
|
# Some boards use a different value for the port that is passed to
|
|
|
|
|
# gdbserver and the port that is passed to the "target remote" command.
|
|
|
|
|
# One example is the stdio gdbserver support.
|
|
|
|
|
if [target_info exists gdb,get_remote_address] {
|
|
|
|
|
set get_remote_address [target_info gdb,get_remote_address]
|
|
|
|
|
} else {
|
|
|
|
|
set get_remote_address gdbserver_default_get_remote_address
|
|
|
|
|
}
|
2014-04-16 17:40:41 +00:00
|
|
|
|
if [target_info exists gdbserver,get_comm_port] {
|
|
|
|
|
set get_comm_port [target_info gdbserver,get_comm_port]
|
|
|
|
|
} else {
|
|
|
|
|
set get_comm_port gdbserver_default_get_comm_port
|
|
|
|
|
}
|
2011-12-16 19:06:38 +00:00
|
|
|
|
|
2005-04-08 12:57:00 +00:00
|
|
|
|
# Extract the protocol
|
|
|
|
|
if [target_info exists gdb_protocol] {
|
|
|
|
|
set protocol [target_info gdb_protocol]
|
|
|
|
|
} else {
|
|
|
|
|
set protocol "remote"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set gdbserver [find_gdbserver]
|
|
|
|
|
|
2009-07-06 18:51:10 +00:00
|
|
|
|
# Loop till we find a free port.
|
|
|
|
|
while 1 {
|
|
|
|
|
# Fire off the debug agent.
|
|
|
|
|
set gdbserver_command "$gdbserver"
|
2011-04-24 08:02:21 +00:00
|
|
|
|
|
|
|
|
|
# If gdbserver_reconnect will be called $gdbserver_reconnect_p must be
|
|
|
|
|
# set to true already during gdbserver_start.
|
|
|
|
|
global gdbserver_reconnect_p
|
|
|
|
|
if {![info exists gdbserver_reconnect_p] || !$gdbserver_reconnect_p} {
|
|
|
|
|
# GDB client could accidentally connect to a stale server.
|
2011-11-20 23:59:49 +00:00
|
|
|
|
# append gdbserver_command " --debug --once"
|
2011-04-24 08:02:21 +00:00
|
|
|
|
append gdbserver_command " --once"
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-06 18:51:10 +00:00
|
|
|
|
if { $options != "" } {
|
|
|
|
|
append gdbserver_command " $options"
|
|
|
|
|
}
|
2011-12-16 19:06:38 +00:00
|
|
|
|
if { $portnum != "" } {
|
2014-04-16 17:40:41 +00:00
|
|
|
|
append gdbserver_command " [$get_comm_port $portnum]"
|
2011-12-16 19:06:38 +00:00
|
|
|
|
}
|
2009-07-06 18:51:10 +00:00
|
|
|
|
if { $arguments != "" } {
|
|
|
|
|
append gdbserver_command " $arguments"
|
|
|
|
|
}
|
2005-04-08 12:57:00 +00:00
|
|
|
|
|
2009-07-06 18:51:10 +00:00
|
|
|
|
set server_spawn_id [remote_spawn target $gdbserver_command]
|
|
|
|
|
|
|
|
|
|
# Wait for the server to open its TCP socket, so that GDB can connect.
|
|
|
|
|
expect {
|
|
|
|
|
-i $server_spawn_id
|
|
|
|
|
-notransfer
|
|
|
|
|
-re "Listening on" { }
|
|
|
|
|
-re "Can't bind address: Address already in use\\.\r\n" {
|
|
|
|
|
verbose -log "Port $portnum is already in use."
|
|
|
|
|
if ![target_info exists gdb,socketport] {
|
|
|
|
|
# Bump the port number to avoid the conflict.
|
|
|
|
|
wait -i $expect_out(spawn_id)
|
|
|
|
|
incr portnum
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break
|
2005-04-08 12:57:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# We can't just call close, because if gdbserver is local then that means
|
|
|
|
|
# that it will get a SIGHUP. Doing it this way could also allow us to
|
|
|
|
|
# get at the inferior's input or output if necessary, and means that we
|
|
|
|
|
# don't need to redirect output.
|
|
|
|
|
expect_background {
|
|
|
|
|
-i $server_spawn_id
|
2007-05-23 12:41:14 +00:00
|
|
|
|
full_buffer { }
|
2005-04-08 12:57:00 +00:00
|
|
|
|
eof {
|
|
|
|
|
# The spawn ID is already closed now (but not yet waited for).
|
|
|
|
|
wait -i $expect_out(spawn_id)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-16 19:06:38 +00:00
|
|
|
|
return [list $protocol [$get_remote_address $debughost $portnum]]
|
2005-04-08 12:57:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
* linux-low.c (linux_attach_lwp): Do not _exit after errors.
(linux_kill, linux_detach): Clean up the process list.
* remote-utils.c (remote_open): Improve port number parsing.
(putpkt_binary, input_interrupt): Only send interrupts if the target
is running.
* server.c (extended_protocol): Make static.
(attached): Define earlier.
(exit_requested, response_needed, program_argv): New variables.
(target_running): New.
(start_inferior): Clear attached here.
(attach_inferior): Set attached here.
(require_running): Define.
(handle_query): Use require_running and target_running. Implement
"monitor exit".
(handle_v_attach, handle_v_run): New.
(handle_v_requests): Use require_running. Handle vAttach and vRun.
(gdbserver_usage): Update.
(main): Redo argument parsing. Handle --debug and --multi. Handle
--attach along with other options or after the port. Save
program_argv. Support no initial program. Resynchronize
communication with GDB after an error. Handle "monitor exit".
Use require_running and target_running. Always allow the extended
protocol. Do not error out for Hc0 or Hc-1. Do not automatically
restart in extended mode.
* README: Refer to the GDB manual. Update --attach usage.
* remote.c (struct remote_state): Add cached_wait_status.
(remote_exec_file): New variable.
(PACKET_vAttach, PACKET_vRun): New constants.
(extended_remote_restart): Do not query for status.
(struct start_remote_args): New.
(remote_start_remote): Take it as a second argument. Check
whether the target is running. Issue an error for non-running
non-extended targets. Cache the wait status. Set inferior_ptid
here.
(remote_open_1): Prompt to disconnect non-running targets. Make
sure the target is marked running. Do not set inferior_ptid here.
Update call to remote_start_remote. Do not call remote_check_symbols
if the target is not running.
(remote_detach_1): Rename from remote_detach. Take an EXTENDED
argument. Handle a non-running target.
(remote_detach): Use it.
(extended_remote_detach): New.
(remote_disconnect): Fix typo. Use remoute_mourn_1.
(extended_remote_attach_1, extended_remote_attach)
(extended_async_remote_attach): New.
(remote_vcont_resume): Remove unused variable.
(remote_wait, remote_async_wait): Use any cached wait status.
(putpkt_binary, getpkt): Clear any cached wait status.
(extended_remoute_mourn_1): New.
(extended_remote_mourn): Use it.
(extended_async_remote_mourn, extended_remote_run): New.
(extended_remote_create_inferior_1): New.
(extended_remote_create_inferior): Use it.
(extended_remote_async_create_inferior): Likewise.
(remote_xfer_partial): Skip for non-executing targets.
(init_extended_remote_ops): Set to_detach and to_attach.
(init_extended_async_remote_ops): Likewise. Use
extended_async_remote_mourn.
(_initialize_remote): Register vAttach, vRun, and
set remote exec-file.
* NEWS: Mention vAttach, vRun, and gdbserver extended-remote support.
* gdb.server/ext-attach.c, gdb.server/ext-attach.exp,
gdb.server/ext-run.exp: New files.
* lib/gdbserver-support.exp (gdbserver_download): New.
(gdbserver_start): New. Update gdbserver expected
output.
(gdbserver_spawn): Use them.
(gdbserver_start_extended): New.
* gdb.texinfo (Using the `gdbserver' Program): Add security
warning. Rearrange into subsections and subsubsections. Document
--multi and --debug. Correct --with-sysroot typo. Update --attach
usage. Make load reference clearer. Document monitor exit.
(Remote Configuration): Document set remote exec-file, attach-packet,
and run-packet.
(Packets): Document vAttach and vRun.
2008-01-30 00:51:50 +00:00
|
|
|
|
# Start a gdbserver process running SERVER_EXEC, and connect GDB
|
|
|
|
|
# to it. CHILD_ARGS are passed to the inferior.
|
|
|
|
|
#
|
|
|
|
|
# Returns the target protocol and socket to connect to.
|
|
|
|
|
|
|
|
|
|
proc gdbserver_spawn { child_args } {
|
2010-01-12 00:50:26 +00:00
|
|
|
|
set target_exec [gdbserver_download_current_prog]
|
* linux-low.c (linux_attach_lwp): Do not _exit after errors.
(linux_kill, linux_detach): Clean up the process list.
* remote-utils.c (remote_open): Improve port number parsing.
(putpkt_binary, input_interrupt): Only send interrupts if the target
is running.
* server.c (extended_protocol): Make static.
(attached): Define earlier.
(exit_requested, response_needed, program_argv): New variables.
(target_running): New.
(start_inferior): Clear attached here.
(attach_inferior): Set attached here.
(require_running): Define.
(handle_query): Use require_running and target_running. Implement
"monitor exit".
(handle_v_attach, handle_v_run): New.
(handle_v_requests): Use require_running. Handle vAttach and vRun.
(gdbserver_usage): Update.
(main): Redo argument parsing. Handle --debug and --multi. Handle
--attach along with other options or after the port. Save
program_argv. Support no initial program. Resynchronize
communication with GDB after an error. Handle "monitor exit".
Use require_running and target_running. Always allow the extended
protocol. Do not error out for Hc0 or Hc-1. Do not automatically
restart in extended mode.
* README: Refer to the GDB manual. Update --attach usage.
* remote.c (struct remote_state): Add cached_wait_status.
(remote_exec_file): New variable.
(PACKET_vAttach, PACKET_vRun): New constants.
(extended_remote_restart): Do not query for status.
(struct start_remote_args): New.
(remote_start_remote): Take it as a second argument. Check
whether the target is running. Issue an error for non-running
non-extended targets. Cache the wait status. Set inferior_ptid
here.
(remote_open_1): Prompt to disconnect non-running targets. Make
sure the target is marked running. Do not set inferior_ptid here.
Update call to remote_start_remote. Do not call remote_check_symbols
if the target is not running.
(remote_detach_1): Rename from remote_detach. Take an EXTENDED
argument. Handle a non-running target.
(remote_detach): Use it.
(extended_remote_detach): New.
(remote_disconnect): Fix typo. Use remoute_mourn_1.
(extended_remote_attach_1, extended_remote_attach)
(extended_async_remote_attach): New.
(remote_vcont_resume): Remove unused variable.
(remote_wait, remote_async_wait): Use any cached wait status.
(putpkt_binary, getpkt): Clear any cached wait status.
(extended_remoute_mourn_1): New.
(extended_remote_mourn): Use it.
(extended_async_remote_mourn, extended_remote_run): New.
(extended_remote_create_inferior_1): New.
(extended_remote_create_inferior): Use it.
(extended_remote_async_create_inferior): Likewise.
(remote_xfer_partial): Skip for non-executing targets.
(init_extended_remote_ops): Set to_detach and to_attach.
(init_extended_async_remote_ops): Likewise. Use
extended_async_remote_mourn.
(_initialize_remote): Register vAttach, vRun, and
set remote exec-file.
* NEWS: Mention vAttach, vRun, and gdbserver extended-remote support.
* gdb.server/ext-attach.c, gdb.server/ext-attach.exp,
gdb.server/ext-run.exp: New files.
* lib/gdbserver-support.exp (gdbserver_download): New.
(gdbserver_start): New. Update gdbserver expected
output.
(gdbserver_spawn): Use them.
(gdbserver_start_extended): New.
* gdb.texinfo (Using the `gdbserver' Program): Add security
warning. Rearrange into subsections and subsubsections. Document
--multi and --debug. Correct --with-sysroot typo. Update --attach
usage. Make load reference clearer. Document monitor exit.
(Remote Configuration): Document set remote exec-file, attach-packet,
and run-packet.
(Packets): Document vAttach and vRun.
2008-01-30 00:51:50 +00:00
|
|
|
|
|
|
|
|
|
# Fire off the debug agent. This flavour of gdbserver takes as
|
|
|
|
|
# arguments the port information, the name of the executable file to
|
|
|
|
|
# be debugged, and any arguments.
|
|
|
|
|
set arguments "$target_exec"
|
|
|
|
|
if { $child_args != "" } {
|
|
|
|
|
append arguments " $child_args"
|
|
|
|
|
}
|
|
|
|
|
return [gdbserver_start "" $arguments]
|
|
|
|
|
}
|
|
|
|
|
|
2005-04-08 12:57:00 +00:00
|
|
|
|
# Start a gdbserver process running HOST_EXEC and pass CHILD_ARGS
|
|
|
|
|
# to it. Return 0 on success, or non-zero on failure.
|
|
|
|
|
|
2007-03-27 17:59:38 +00:00
|
|
|
|
proc gdbserver_run { child_args } {
|
2007-07-02 21:29:28 +00:00
|
|
|
|
global gdbserver_protocol
|
|
|
|
|
global gdbserver_gdbport
|
|
|
|
|
|
2007-05-23 12:41:14 +00:00
|
|
|
|
# Kill anything running before we try to start gdbserver, in case
|
|
|
|
|
# we are sharing a serial connection.
|
|
|
|
|
global gdb_prompt
|
|
|
|
|
send_gdb "kill\n"
|
|
|
|
|
gdb_expect 120 {
|
|
|
|
|
-re "Kill the program being debugged. .y or n. $" {
|
|
|
|
|
send_gdb "y\n"
|
|
|
|
|
verbose "\t\tKilling previous program being debugged"
|
|
|
|
|
exp_continue
|
|
|
|
|
}
|
|
|
|
|
-re "$gdb_prompt $" {
|
|
|
|
|
# OK.
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-03-27 17:59:38 +00:00
|
|
|
|
set res [gdbserver_spawn $child_args]
|
2007-07-02 21:29:28 +00:00
|
|
|
|
set gdbserver_protocol [lindex $res 0]
|
|
|
|
|
set gdbserver_gdbport [lindex $res 1]
|
|
|
|
|
|
|
|
|
|
return [gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Reconnect to the previous gdbserver session.
|
|
|
|
|
|
|
|
|
|
proc gdbserver_reconnect { } {
|
|
|
|
|
global gdbserver_protocol
|
|
|
|
|
global gdbserver_gdbport
|
2005-04-08 12:57:00 +00:00
|
|
|
|
|
2013-06-07 17:31:09 +00:00
|
|
|
|
global gdbserver_reconnect_p
|
2011-04-24 08:02:21 +00:00
|
|
|
|
if {![info exists gdbserver_reconnect_p] || !$gdbserver_reconnect_p} {
|
|
|
|
|
error "gdbserver_reconnect_p is not set before gdbserver_reconnect"
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
2007-07-02 21:29:28 +00:00
|
|
|
|
return [gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport]
|
2005-04-08 12:57:00 +00:00
|
|
|
|
}
|
* linux-low.c (linux_attach_lwp): Do not _exit after errors.
(linux_kill, linux_detach): Clean up the process list.
* remote-utils.c (remote_open): Improve port number parsing.
(putpkt_binary, input_interrupt): Only send interrupts if the target
is running.
* server.c (extended_protocol): Make static.
(attached): Define earlier.
(exit_requested, response_needed, program_argv): New variables.
(target_running): New.
(start_inferior): Clear attached here.
(attach_inferior): Set attached here.
(require_running): Define.
(handle_query): Use require_running and target_running. Implement
"monitor exit".
(handle_v_attach, handle_v_run): New.
(handle_v_requests): Use require_running. Handle vAttach and vRun.
(gdbserver_usage): Update.
(main): Redo argument parsing. Handle --debug and --multi. Handle
--attach along with other options or after the port. Save
program_argv. Support no initial program. Resynchronize
communication with GDB after an error. Handle "monitor exit".
Use require_running and target_running. Always allow the extended
protocol. Do not error out for Hc0 or Hc-1. Do not automatically
restart in extended mode.
* README: Refer to the GDB manual. Update --attach usage.
* remote.c (struct remote_state): Add cached_wait_status.
(remote_exec_file): New variable.
(PACKET_vAttach, PACKET_vRun): New constants.
(extended_remote_restart): Do not query for status.
(struct start_remote_args): New.
(remote_start_remote): Take it as a second argument. Check
whether the target is running. Issue an error for non-running
non-extended targets. Cache the wait status. Set inferior_ptid
here.
(remote_open_1): Prompt to disconnect non-running targets. Make
sure the target is marked running. Do not set inferior_ptid here.
Update call to remote_start_remote. Do not call remote_check_symbols
if the target is not running.
(remote_detach_1): Rename from remote_detach. Take an EXTENDED
argument. Handle a non-running target.
(remote_detach): Use it.
(extended_remote_detach): New.
(remote_disconnect): Fix typo. Use remoute_mourn_1.
(extended_remote_attach_1, extended_remote_attach)
(extended_async_remote_attach): New.
(remote_vcont_resume): Remove unused variable.
(remote_wait, remote_async_wait): Use any cached wait status.
(putpkt_binary, getpkt): Clear any cached wait status.
(extended_remoute_mourn_1): New.
(extended_remote_mourn): Use it.
(extended_async_remote_mourn, extended_remote_run): New.
(extended_remote_create_inferior_1): New.
(extended_remote_create_inferior): Use it.
(extended_remote_async_create_inferior): Likewise.
(remote_xfer_partial): Skip for non-executing targets.
(init_extended_remote_ops): Set to_detach and to_attach.
(init_extended_async_remote_ops): Likewise. Use
extended_async_remote_mourn.
(_initialize_remote): Register vAttach, vRun, and
set remote exec-file.
* NEWS: Mention vAttach, vRun, and gdbserver extended-remote support.
* gdb.server/ext-attach.c, gdb.server/ext-attach.exp,
gdb.server/ext-run.exp: New files.
* lib/gdbserver-support.exp (gdbserver_download): New.
(gdbserver_start): New. Update gdbserver expected
output.
(gdbserver_spawn): Use them.
(gdbserver_start_extended): New.
* gdb.texinfo (Using the `gdbserver' Program): Add security
warning. Rearrange into subsections and subsubsections. Document
--multi and --debug. Correct --with-sysroot typo. Update --attach
usage. Make load reference clearer. Document monitor exit.
(Remote Configuration): Document set remote exec-file, attach-packet,
and run-packet.
(Packets): Document vAttach and vRun.
2008-01-30 00:51:50 +00:00
|
|
|
|
|
2012-01-27 13:02:22 +00:00
|
|
|
|
# Start and connect to a gdbserver in extended mode. Note this frobs
|
|
|
|
|
# $gdbserver_protocol, so should be used only from a board that
|
|
|
|
|
# usually connects in target remote mode.
|
* linux-low.c (linux_attach_lwp): Do not _exit after errors.
(linux_kill, linux_detach): Clean up the process list.
* remote-utils.c (remote_open): Improve port number parsing.
(putpkt_binary, input_interrupt): Only send interrupts if the target
is running.
* server.c (extended_protocol): Make static.
(attached): Define earlier.
(exit_requested, response_needed, program_argv): New variables.
(target_running): New.
(start_inferior): Clear attached here.
(attach_inferior): Set attached here.
(require_running): Define.
(handle_query): Use require_running and target_running. Implement
"monitor exit".
(handle_v_attach, handle_v_run): New.
(handle_v_requests): Use require_running. Handle vAttach and vRun.
(gdbserver_usage): Update.
(main): Redo argument parsing. Handle --debug and --multi. Handle
--attach along with other options or after the port. Save
program_argv. Support no initial program. Resynchronize
communication with GDB after an error. Handle "monitor exit".
Use require_running and target_running. Always allow the extended
protocol. Do not error out for Hc0 or Hc-1. Do not automatically
restart in extended mode.
* README: Refer to the GDB manual. Update --attach usage.
* remote.c (struct remote_state): Add cached_wait_status.
(remote_exec_file): New variable.
(PACKET_vAttach, PACKET_vRun): New constants.
(extended_remote_restart): Do not query for status.
(struct start_remote_args): New.
(remote_start_remote): Take it as a second argument. Check
whether the target is running. Issue an error for non-running
non-extended targets. Cache the wait status. Set inferior_ptid
here.
(remote_open_1): Prompt to disconnect non-running targets. Make
sure the target is marked running. Do not set inferior_ptid here.
Update call to remote_start_remote. Do not call remote_check_symbols
if the target is not running.
(remote_detach_1): Rename from remote_detach. Take an EXTENDED
argument. Handle a non-running target.
(remote_detach): Use it.
(extended_remote_detach): New.
(remote_disconnect): Fix typo. Use remoute_mourn_1.
(extended_remote_attach_1, extended_remote_attach)
(extended_async_remote_attach): New.
(remote_vcont_resume): Remove unused variable.
(remote_wait, remote_async_wait): Use any cached wait status.
(putpkt_binary, getpkt): Clear any cached wait status.
(extended_remoute_mourn_1): New.
(extended_remote_mourn): Use it.
(extended_async_remote_mourn, extended_remote_run): New.
(extended_remote_create_inferior_1): New.
(extended_remote_create_inferior): Use it.
(extended_remote_async_create_inferior): Likewise.
(remote_xfer_partial): Skip for non-executing targets.
(init_extended_remote_ops): Set to_detach and to_attach.
(init_extended_async_remote_ops): Likewise. Use
extended_async_remote_mourn.
(_initialize_remote): Register vAttach, vRun, and
set remote exec-file.
* NEWS: Mention vAttach, vRun, and gdbserver extended-remote support.
* gdb.server/ext-attach.c, gdb.server/ext-attach.exp,
gdb.server/ext-run.exp: New files.
* lib/gdbserver-support.exp (gdbserver_download): New.
(gdbserver_start): New. Update gdbserver expected
output.
(gdbserver_spawn): Use them.
(gdbserver_start_extended): New.
* gdb.texinfo (Using the `gdbserver' Program): Add security
warning. Rearrange into subsections and subsubsections. Document
--multi and --debug. Correct --with-sysroot typo. Update --attach
usage. Make load reference clearer. Document monitor exit.
(Remote Configuration): Document set remote exec-file, attach-packet,
and run-packet.
(Packets): Document vAttach and vRun.
2008-01-30 00:51:50 +00:00
|
|
|
|
proc gdbserver_start_extended { } {
|
2011-12-03 20:20:29 +00:00
|
|
|
|
global gdbserver_protocol
|
|
|
|
|
global gdbserver_gdbport
|
|
|
|
|
global use_gdb_stub
|
|
|
|
|
|
* linux-low.c (linux_attach_lwp): Do not _exit after errors.
(linux_kill, linux_detach): Clean up the process list.
* remote-utils.c (remote_open): Improve port number parsing.
(putpkt_binary, input_interrupt): Only send interrupts if the target
is running.
* server.c (extended_protocol): Make static.
(attached): Define earlier.
(exit_requested, response_needed, program_argv): New variables.
(target_running): New.
(start_inferior): Clear attached here.
(attach_inferior): Set attached here.
(require_running): Define.
(handle_query): Use require_running and target_running. Implement
"monitor exit".
(handle_v_attach, handle_v_run): New.
(handle_v_requests): Use require_running. Handle vAttach and vRun.
(gdbserver_usage): Update.
(main): Redo argument parsing. Handle --debug and --multi. Handle
--attach along with other options or after the port. Save
program_argv. Support no initial program. Resynchronize
communication with GDB after an error. Handle "monitor exit".
Use require_running and target_running. Always allow the extended
protocol. Do not error out for Hc0 or Hc-1. Do not automatically
restart in extended mode.
* README: Refer to the GDB manual. Update --attach usage.
* remote.c (struct remote_state): Add cached_wait_status.
(remote_exec_file): New variable.
(PACKET_vAttach, PACKET_vRun): New constants.
(extended_remote_restart): Do not query for status.
(struct start_remote_args): New.
(remote_start_remote): Take it as a second argument. Check
whether the target is running. Issue an error for non-running
non-extended targets. Cache the wait status. Set inferior_ptid
here.
(remote_open_1): Prompt to disconnect non-running targets. Make
sure the target is marked running. Do not set inferior_ptid here.
Update call to remote_start_remote. Do not call remote_check_symbols
if the target is not running.
(remote_detach_1): Rename from remote_detach. Take an EXTENDED
argument. Handle a non-running target.
(remote_detach): Use it.
(extended_remote_detach): New.
(remote_disconnect): Fix typo. Use remoute_mourn_1.
(extended_remote_attach_1, extended_remote_attach)
(extended_async_remote_attach): New.
(remote_vcont_resume): Remove unused variable.
(remote_wait, remote_async_wait): Use any cached wait status.
(putpkt_binary, getpkt): Clear any cached wait status.
(extended_remoute_mourn_1): New.
(extended_remote_mourn): Use it.
(extended_async_remote_mourn, extended_remote_run): New.
(extended_remote_create_inferior_1): New.
(extended_remote_create_inferior): Use it.
(extended_remote_async_create_inferior): Likewise.
(remote_xfer_partial): Skip for non-executing targets.
(init_extended_remote_ops): Set to_detach and to_attach.
(init_extended_async_remote_ops): Likewise. Use
extended_async_remote_mourn.
(_initialize_remote): Register vAttach, vRun, and
set remote exec-file.
* NEWS: Mention vAttach, vRun, and gdbserver extended-remote support.
* gdb.server/ext-attach.c, gdb.server/ext-attach.exp,
gdb.server/ext-run.exp: New files.
* lib/gdbserver-support.exp (gdbserver_download): New.
(gdbserver_start): New. Update gdbserver expected
output.
(gdbserver_spawn): Use them.
(gdbserver_start_extended): New.
* gdb.texinfo (Using the `gdbserver' Program): Add security
warning. Rearrange into subsections and subsubsections. Document
--multi and --debug. Correct --with-sysroot typo. Update --attach
usage. Make load reference clearer. Document monitor exit.
(Remote Configuration): Document set remote exec-file, attach-packet,
and run-packet.
(Packets): Document vAttach and vRun.
2008-01-30 00:51:50 +00:00
|
|
|
|
set res [gdbserver_start "--multi" ""]
|
2012-02-15 12:51:17 +00:00
|
|
|
|
set gdbserver_protocol [lindex $res 0]
|
|
|
|
|
if { [string first "extended-" $gdbserver_protocol] != 0} {
|
|
|
|
|
set gdbserver_protocol "extended-$gdbserver_protocol"
|
|
|
|
|
}
|
* linux-low.c (linux_attach_lwp): Do not _exit after errors.
(linux_kill, linux_detach): Clean up the process list.
* remote-utils.c (remote_open): Improve port number parsing.
(putpkt_binary, input_interrupt): Only send interrupts if the target
is running.
* server.c (extended_protocol): Make static.
(attached): Define earlier.
(exit_requested, response_needed, program_argv): New variables.
(target_running): New.
(start_inferior): Clear attached here.
(attach_inferior): Set attached here.
(require_running): Define.
(handle_query): Use require_running and target_running. Implement
"monitor exit".
(handle_v_attach, handle_v_run): New.
(handle_v_requests): Use require_running. Handle vAttach and vRun.
(gdbserver_usage): Update.
(main): Redo argument parsing. Handle --debug and --multi. Handle
--attach along with other options or after the port. Save
program_argv. Support no initial program. Resynchronize
communication with GDB after an error. Handle "monitor exit".
Use require_running and target_running. Always allow the extended
protocol. Do not error out for Hc0 or Hc-1. Do not automatically
restart in extended mode.
* README: Refer to the GDB manual. Update --attach usage.
* remote.c (struct remote_state): Add cached_wait_status.
(remote_exec_file): New variable.
(PACKET_vAttach, PACKET_vRun): New constants.
(extended_remote_restart): Do not query for status.
(struct start_remote_args): New.
(remote_start_remote): Take it as a second argument. Check
whether the target is running. Issue an error for non-running
non-extended targets. Cache the wait status. Set inferior_ptid
here.
(remote_open_1): Prompt to disconnect non-running targets. Make
sure the target is marked running. Do not set inferior_ptid here.
Update call to remote_start_remote. Do not call remote_check_symbols
if the target is not running.
(remote_detach_1): Rename from remote_detach. Take an EXTENDED
argument. Handle a non-running target.
(remote_detach): Use it.
(extended_remote_detach): New.
(remote_disconnect): Fix typo. Use remoute_mourn_1.
(extended_remote_attach_1, extended_remote_attach)
(extended_async_remote_attach): New.
(remote_vcont_resume): Remove unused variable.
(remote_wait, remote_async_wait): Use any cached wait status.
(putpkt_binary, getpkt): Clear any cached wait status.
(extended_remoute_mourn_1): New.
(extended_remote_mourn): Use it.
(extended_async_remote_mourn, extended_remote_run): New.
(extended_remote_create_inferior_1): New.
(extended_remote_create_inferior): Use it.
(extended_remote_async_create_inferior): Likewise.
(remote_xfer_partial): Skip for non-executing targets.
(init_extended_remote_ops): Set to_detach and to_attach.
(init_extended_async_remote_ops): Likewise. Use
extended_async_remote_mourn.
(_initialize_remote): Register vAttach, vRun, and
set remote exec-file.
* NEWS: Mention vAttach, vRun, and gdbserver extended-remote support.
* gdb.server/ext-attach.c, gdb.server/ext-attach.exp,
gdb.server/ext-run.exp: New files.
* lib/gdbserver-support.exp (gdbserver_download): New.
(gdbserver_start): New. Update gdbserver expected
output.
(gdbserver_spawn): Use them.
(gdbserver_start_extended): New.
* gdb.texinfo (Using the `gdbserver' Program): Add security
warning. Rearrange into subsections and subsubsections. Document
--multi and --debug. Correct --with-sysroot typo. Update --attach
usage. Make load reference clearer. Document monitor exit.
(Remote Configuration): Document set remote exec-file, attach-packet,
and run-packet.
(Packets): Document vAttach and vRun.
2008-01-30 00:51:50 +00:00
|
|
|
|
set gdbserver_gdbport [lindex $res 1]
|
|
|
|
|
|
2011-12-03 20:20:29 +00:00
|
|
|
|
# Even if the board file is testing with target remote, our caller
|
|
|
|
|
# wants to test against gdbserver in extended-remote mode. Make sure to
|
|
|
|
|
# disable stub-like techniques.
|
|
|
|
|
set use_gdb_stub 0
|
|
|
|
|
|
* linux-low.c (linux_attach_lwp): Do not _exit after errors.
(linux_kill, linux_detach): Clean up the process list.
* remote-utils.c (remote_open): Improve port number parsing.
(putpkt_binary, input_interrupt): Only send interrupts if the target
is running.
* server.c (extended_protocol): Make static.
(attached): Define earlier.
(exit_requested, response_needed, program_argv): New variables.
(target_running): New.
(start_inferior): Clear attached here.
(attach_inferior): Set attached here.
(require_running): Define.
(handle_query): Use require_running and target_running. Implement
"monitor exit".
(handle_v_attach, handle_v_run): New.
(handle_v_requests): Use require_running. Handle vAttach and vRun.
(gdbserver_usage): Update.
(main): Redo argument parsing. Handle --debug and --multi. Handle
--attach along with other options or after the port. Save
program_argv. Support no initial program. Resynchronize
communication with GDB after an error. Handle "monitor exit".
Use require_running and target_running. Always allow the extended
protocol. Do not error out for Hc0 or Hc-1. Do not automatically
restart in extended mode.
* README: Refer to the GDB manual. Update --attach usage.
* remote.c (struct remote_state): Add cached_wait_status.
(remote_exec_file): New variable.
(PACKET_vAttach, PACKET_vRun): New constants.
(extended_remote_restart): Do not query for status.
(struct start_remote_args): New.
(remote_start_remote): Take it as a second argument. Check
whether the target is running. Issue an error for non-running
non-extended targets. Cache the wait status. Set inferior_ptid
here.
(remote_open_1): Prompt to disconnect non-running targets. Make
sure the target is marked running. Do not set inferior_ptid here.
Update call to remote_start_remote. Do not call remote_check_symbols
if the target is not running.
(remote_detach_1): Rename from remote_detach. Take an EXTENDED
argument. Handle a non-running target.
(remote_detach): Use it.
(extended_remote_detach): New.
(remote_disconnect): Fix typo. Use remoute_mourn_1.
(extended_remote_attach_1, extended_remote_attach)
(extended_async_remote_attach): New.
(remote_vcont_resume): Remove unused variable.
(remote_wait, remote_async_wait): Use any cached wait status.
(putpkt_binary, getpkt): Clear any cached wait status.
(extended_remoute_mourn_1): New.
(extended_remote_mourn): Use it.
(extended_async_remote_mourn, extended_remote_run): New.
(extended_remote_create_inferior_1): New.
(extended_remote_create_inferior): Use it.
(extended_remote_async_create_inferior): Likewise.
(remote_xfer_partial): Skip for non-executing targets.
(init_extended_remote_ops): Set to_detach and to_attach.
(init_extended_async_remote_ops): Likewise. Use
extended_async_remote_mourn.
(_initialize_remote): Register vAttach, vRun, and
set remote exec-file.
* NEWS: Mention vAttach, vRun, and gdbserver extended-remote support.
* gdb.server/ext-attach.c, gdb.server/ext-attach.exp,
gdb.server/ext-run.exp: New files.
* lib/gdbserver-support.exp (gdbserver_download): New.
(gdbserver_start): New. Update gdbserver expected
output.
(gdbserver_spawn): Use them.
(gdbserver_start_extended): New.
* gdb.texinfo (Using the `gdbserver' Program): Add security
warning. Rearrange into subsections and subsubsections. Document
--multi and --debug. Correct --with-sysroot typo. Update --attach
usage. Make load reference clearer. Document monitor exit.
(Remote Configuration): Document set remote exec-file, attach-packet,
and run-packet.
(Packets): Document vAttach and vRun.
2008-01-30 00:51:50 +00:00
|
|
|
|
return [gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport]
|
|
|
|
|
}
|
2012-01-27 13:02:22 +00:00
|
|
|
|
|
|
|
|
|
# Start and connect to a gdbserver in extended/multi mode. Unlike
|
|
|
|
|
# gdbserver_start_extended, this does not frob $gdbserver_protocol.
|
|
|
|
|
|
|
|
|
|
proc gdbserver_start_multi { } {
|
|
|
|
|
global gdbserver_protocol
|
|
|
|
|
global gdbserver_gdbport
|
|
|
|
|
|
|
|
|
|
set res [gdbserver_start "--multi" ""]
|
|
|
|
|
set gdbserver_protocol [lindex $res 0]
|
|
|
|
|
set gdbserver_gdbport [lindex $res 1]
|
|
|
|
|
|
|
|
|
|
return [gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Start a gdbserver process in multi/extended mode, and have GDB
|
|
|
|
|
# connect to it (MI version). Return 0 on success, or non-zero on
|
|
|
|
|
# failure.
|
|
|
|
|
|
|
|
|
|
proc mi_gdbserver_start_multi { } {
|
|
|
|
|
global gdbserver_protocol
|
|
|
|
|
global gdbserver_gdbport
|
|
|
|
|
|
|
|
|
|
set res [gdbserver_start "--multi" ""]
|
|
|
|
|
set gdbserver_protocol [lindex $res 0]
|
|
|
|
|
set gdbserver_gdbport [lindex $res 1]
|
|
|
|
|
|
|
|
|
|
return [mi_gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport]
|
|
|
|
|
}
|