Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@codesourcery.com>
To: gdb-patches@sourceware.org
Subject: Remove vAttach and vRun unneeded requirement
Date: Tue, 19 Feb 2008 02:04:00 -0000	[thread overview]
Message-ID: <200802190204.18131.pedro@codesourcery.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1087 bytes --]

Hi,

The vAttach packet, which is used to implement the attach command
in the extended-remote target, in it's documentation says that if the
stub is currently controlling a process, it is killed.

`vAttach;pid'
    Attach to a new process with the specified process ID. pid is a 
hexadecimal integer identifying the process. If the stub is currently 
controlling a process, it is killed. The attached process is stopped.

This requirement isn't really needed, since gdb already takes care
of killing the running inferior.

We would like to remove this requirement, since it has no real value,
and limits future extensions for stubs controlling more than one
process at a time.

So, that's what the attached patch does.  It removes that frase,
and removes the implementation for it in the probably only
current implementation of it: gdbserver on HEAD.

I'd like to have this committed before the release, since there's
no release with this packet yet.

Tested with a local gdbserver on x86_64-unknown-linux-gnu, no
regressions, and by looking at the generated html docs.

-- 
Pedro Alves

[-- Attachment #2: dont_kill_on_attach.diff --]
[-- Type: text/x-diff, Size: 2580 bytes --]

doc/
2008-02-19  Pedro Alves  <pedro@codesourcery.com>

	* gdb.texinfo (vAttach): Remove requirement of the stub killing
	the inferior when it is already debugging a process.

gdbserver/
2008-02-19  Pedro Alves  <pedro@codesourcery.com>

	* server.c (handle_v_requests): When handling the vRun and vAttach
	packets, if already debugging a process, don't kill it.  Return an
	error instead.

---
 gdb/doc/gdb.texinfo    |    6 +++---
 gdb/gdbserver/server.c |   10 ++++++----
 2 files changed, 9 insertions(+), 7 deletions(-)

Index: src/gdb/doc/gdb.texinfo
===================================================================
--- src.orig/gdb/doc/gdb.texinfo	2008-02-15 21:46:56.000000000 +0000
+++ src/gdb/doc/gdb.texinfo	2008-02-15 23:35:15.000000000 +0000
@@ -23706,8 +23706,8 @@ up to the first @samp{;} or @samp{?} (or
 @item vAttach;@var{pid}
 @cindex @samp{vAttach} packet
 Attach to a new process with the specified process ID.  @var{pid} is a
-hexadecimal integer identifying the process.  If the stub is currently
-controlling a process, it is killed.  The attached process is stopped.
+hexadecimal integer identifying the process.  The attached process is
+stopped.
 
 This packet is only available in extended mode (@pxref{extended mode}).
 
@@ -23821,7 +23821,7 @@ Run the program @var{filename}, passing 
 command line.  The file and arguments are hex-encoded strings.  If
 @var{filename} is an empty string, the stub may use a default program
 (e.g.@: the last program run).  The program is created in the stopped
-state.  If the stub is currently controlling a process, it is killed.
+state.
 
 This packet is only available in extended mode (@pxref{extended mode}).
 
Index: src/gdb/gdbserver/server.c
===================================================================
--- src.orig/gdb/gdbserver/server.c	2008-02-15 21:23:16.000000000 +0000
+++ src/gdb/gdbserver/server.c	2008-02-15 23:33:56.000000000 +0000
@@ -928,8 +928,9 @@ handle_v_requests (char *own_buf, char *
     {
       if (target_running ())
 	{
-	  fprintf (stderr, "Killing inferior\n");
-	  kill_inferior ();
+	  fprintf (stderr, "Already debugging a process\n");
+	  write_enn (own_buf);
+	  return;
 	}
       handle_v_attach (own_buf, status, signal);
       return;
@@ -939,8 +940,9 @@ handle_v_requests (char *own_buf, char *
     {
       if (target_running ())
 	{
-	  fprintf (stderr, "Killing inferior\n");
-	  kill_inferior ();
+	  fprintf (stderr, "Already debugging a process\n");
+	  write_enn (own_buf);
+	  return;
 	}
       handle_v_run (own_buf, status, signal);
       return;

             reply	other threads:[~2008-02-19  2:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-19  2:04 Pedro Alves [this message]
2008-02-19  4:27 ` Eli Zaretskii
2008-02-19 13:27   ` Daniel Jacobowitz
2008-02-20 12:54     ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200802190204.18131.pedro@codesourcery.com \
    --to=pedro@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox