From: Jan Kiszka <jan.kiszka@siemens.com>
To: Fabien Chouteau <chouteau@adacore.com>
Cc: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH 1/2] Add GDB qAttached support
Date: Tue, 12 Mar 2013 15:40:23 +0100 [thread overview]
Message-ID: <513F3E57.40108@siemens.com> (raw)
In-Reply-To: <1363098665-27783-2-git-send-email-chouteau@adacore.com>
On 2013-03-12 15:31, Fabien Chouteau wrote:
> With this patch QEMU handles qAttached request from gdb. When QEMU
> replies 1, GDB sends a "detach" command at the end of a debugging
> session otherwise GDB sends "kill".
>
> The default value for qAttached is 1 on system emulation and 0 on user
> emulation.
>
> We introduce a new command line option. It's a generic option to
> customize the gdb server:
Again, please factor this out into a separate patch so that qAttached
can be merged independently (and we stop warning the gdb users
incorrectly about killing the target on quit).
>
> -gdb-opts [attached=on|off]
This will still trigger additional discussions as it's still a new
top-level command line switch.
I think it is possible to merge chardev-unrelated options into the
parameter that -gdb takes and filter them out before handing the rest
over to the chardev layer.
Jan
>
> The only parameter for now is "attached".
>
> This patch implements the requirement described in Jan Kiszka's patch:
> "gdbstub: Do not kill target in system emulation mode". The patch can
> therefore be reverted.
>
> Signed-off-by: Fabien Chouteau <chouteau@adacore.com>
> ---
> gdbstub.c | 38 +++++++++++++++++++++++++++++++++++++-
> include/exec/gdbstub.h | 2 ++
> qemu-options.hx | 17 +++++++++++++++++
> vl.c | 3 +++
> 4 files changed, 59 insertions(+), 1 deletion(-)
>
> diff --git a/gdbstub.c b/gdbstub.c
> index e414ad9..de95849 100644
> --- a/gdbstub.c
> +++ b/gdbstub.c
> @@ -32,7 +32,6 @@
> #include "monitor/monitor.h"
> #include "char/char.h"
> #include "sysemu/sysemu.h"
> -#include "exec/gdbstub.h"
> #endif
>
> #define MAX_PACKET_LENGTH 4096
> @@ -41,6 +40,13 @@
> #include "qemu/sockets.h"
> #include "sysemu/kvm.h"
> #include "qemu/bitops.h"
> +#include "exec/gdbstub.h"
> +
> +#ifdef CONFIG_USER_ONLY
> +static bool gdb_attached; /* false */
> +#else
> +static bool gdb_attached = true;
> +#endif
>
> #ifndef TARGET_CPU_MEMORY_RW_DEBUG
> static inline int target_memory_rw_debug(CPUArchState *env, target_ulong addr,
> @@ -2491,6 +2497,10 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)
> break;
> }
> #endif
> + if (strncmp(p, "Attached", 8) == 0) {
> + put_packet(s, gdb_attached ? "1" : "0");
> + break;
> + }
> /* Unrecognised 'q' command. */
> goto unknown_command;
>
> @@ -3055,3 +3065,29 @@ int gdbserver_start(const char *device)
> return 0;
> }
> #endif
> +
> +static QemuOptsList qemu_gdb_opts = {
> + .name = "gdb",
> + .head = QTAILQ_HEAD_INITIALIZER(qemu_gdb_opts.head),
> + .desc = {
> + {
> + .name = "attached",
> + .type = QEMU_OPT_BOOL,
> + },
> + { /* end of list */ }
> + },
> +};
> +
> +void gdb_set_opts(const char *opts_str)
> +{
> + QemuOpts *opts;
> +
> + opts = qemu_opts_parse(&qemu_gdb_opts, opts_str, 0);
> + if (!opts) {
> + exit(1);
> + }
> +
> + gdb_attached = qemu_opt_get_bool(opts, "attached", gdb_attached);
> +
> + qemu_opts_del(opts);
> +}
> diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h
> index ba20afa..86fc18b 100644
> --- a/include/exec/gdbstub.h
> +++ b/include/exec/gdbstub.h
> @@ -50,4 +50,6 @@ int gdbserver_start(const char *port);
> /* in gdbstub-xml.c, generated by scripts/feature_to_c.sh */
> extern const char *const xml_builtin[][2];
>
> +void gdb_set_opts(const char *opts_str);
> +
> #endif
> diff --git a/qemu-options.hx b/qemu-options.hx
> index cd76f2a..49a480f 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -2505,6 +2505,23 @@ within gdb and establish the connection via a pipe:
> @end example
> ETEXI
>
> +DEF("gdb-opts", HAS_ARG, QEMU_OPTION_gdb_opts, \
> + "-gdb-opts attached=on|off\n"\
> + " options for the gdb remote server\n", QEMU_ARCH_ALL)
> +STEXI
> +@item -gdb-opts @var{dev}
> +@findex -gdb-opts
> +Set options for the gdb remote server:
> +@table @option
> +@item attached=on|off:
> +
> +When 'on' (default), gdb sends a 'detach' command at the end of debugging
> +session, otherwise gdb sends a 'kill' command.
> +
> +@end table
> +
> +ETEXI
> +
> DEF("s", 0, QEMU_OPTION_s, \
> "-s shorthand for -gdb tcp::" DEFAULT_GDBSTUB_PORT "\n",
> QEMU_ARCH_ALL)
> diff --git a/vl.c b/vl.c
> index 154f7ba..cce96b6 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -3251,6 +3251,9 @@ int main(int argc, char **argv, char **envp)
> case QEMU_OPTION_gdb:
> add_device_config(DEV_GDB, optarg);
> break;
> + case QEMU_OPTION_gdb_opts:
> + gdb_set_opts(optarg);
> + break;
> case QEMU_OPTION_L:
> data_dir = optarg;
> break;
>
--
Siemens AG, Corporate Technology, CT RTC ITP SDP-DE
Corporate Competence Center Embedded Linux
next prev parent reply other threads:[~2013-03-12 14:40 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-12 14:31 [Qemu-devel] [PATCH 0/2] Add GDB qAttached support Fabien Chouteau
2013-03-12 14:31 ` [Qemu-devel] [PATCH 1/2] " Fabien Chouteau
2013-03-12 14:40 ` Jan Kiszka [this message]
2013-03-12 14:31 ` [Qemu-devel] [PATCH 2/2] Revert "gdbstub: Do not kill target in system emulation mode" Fabien Chouteau
-- strict thread matches above, loose matches on Subject: below --
2015-01-31 9:28 [Qemu-devel] [PATCH 1/2] Add GDB qAttached support Jan Kiszka
2015-02-04 13:36 ` Pedro Alves
2015-02-04 14:06 ` Jan Kiszka
2015-02-04 14:30 ` Peter Maydell
2013-03-05 16:03 Fabien Chouteau
2013-03-10 8:06 ` Jan Kiszka
2013-03-11 11:22 ` Fabien Chouteau
2013-03-11 11:36 ` Jan Kiszka
2013-03-11 11:59 ` Fabien Chouteau
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=513F3E57.40108@siemens.com \
--to=jan.kiszka@siemens.com \
--cc=chouteau@adacore.com \
--cc=qemu-devel@nongnu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.