From: "Alex Bennée" <alex.bennee@linaro.org>
To: qemu-devel@nongnu.org
Cc: damien.hedde@greensocs.com, luis.machado@linaro.org,
"Philippe Mathieu-Daudé" <philmd@redhat.com>,
richard.henderson@linaro.org, alan.hayward@arm.com,
"Alex Bennée" <alex.bennee@linaro.org>
Subject: [RFC PATCH 01/11] gdbstub: move allocation of GDBState to one place
Date: Fri, 15 Nov 2019 17:29:50 +0000 [thread overview]
Message-ID: <20191115173000.21891-2-alex.bennee@linaro.org> (raw)
In-Reply-To: <20191115173000.21891-1-alex.bennee@linaro.org>
We use g_new0() as it is the preferred form for such allocations. We
can also ensure that gdbserver_state is reset in one place.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
gdbstub.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/gdbstub.c b/gdbstub.c
index 4cf8af365e2..c5b6701825f 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -374,6 +374,13 @@ static int sstep_flags = SSTEP_ENABLE|SSTEP_NOIRQ|SSTEP_NOTIMER;
static GDBState *gdbserver_state;
+static GDBState *gdb_allocate_state(void)
+{
+ g_assert(!gdbserver_state);
+ gdbserver_state = g_new0(GDBState, 1);
+ return gdbserver_state;
+}
+
bool gdb_has_xml;
#ifdef CONFIG_USER_ONLY
@@ -3083,15 +3090,13 @@ static bool gdb_accept(void)
return false;
}
- s = g_malloc0(sizeof(GDBState));
+ s = gdb_allocate_state();
create_default_process(s);
s->processes[0].attached = true;
s->c_cpu = gdb_first_attached_cpu(s);
s->g_cpu = s->c_cpu;
s->fd = fd;
gdb_has_xml = false;
-
- gdbserver_state = s;
return true;
}
@@ -3359,8 +3364,7 @@ int gdbserver_start(const char *device)
s = gdbserver_state;
if (!s) {
- s = g_malloc0(sizeof(GDBState));
- gdbserver_state = s;
+ s = gdb_allocate_state();
qemu_add_vm_change_state_handler(gdb_vm_state_change, NULL);
--
2.20.1
next prev parent reply other threads:[~2019-11-15 17:34 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-15 17:29 [RFC PATCH 00/11] gdbstub re-factor and SVE support Alex Bennée
2019-11-15 17:29 ` Alex Bennée [this message]
2019-11-18 7:37 ` [RFC PATCH 01/11] gdbstub: move allocation of GDBState to one place Richard Henderson
2019-11-18 7:41 ` Richard Henderson
2019-11-18 9:19 ` Damien Hedde
2019-11-18 11:24 ` Richard Henderson
2019-11-18 9:50 ` Damien Hedde
2019-11-15 17:29 ` [RFC PATCH 02/11] gdbstub: stop passing GDBState * around Alex Bennée
2019-11-18 7:47 ` Richard Henderson
2019-11-18 11:52 ` Alex Bennée
2019-11-18 11:57 ` Richard Henderson
2019-11-18 9:40 ` Damien Hedde
2019-11-18 11:59 ` Alex Bennée
2019-11-15 17:29 ` [RFC PATCH 03/11] gdbstub: move str_buf to GDBState and use GString Alex Bennée
2019-11-18 8:06 ` Richard Henderson
2019-11-15 17:29 ` [RFC PATCH 04/11] gdbstub: move mem_buf to GDBState and use GByteArray Alex Bennée
2019-11-18 8:10 ` Richard Henderson
2019-11-15 17:29 ` [RFC PATCH 05/11] gdbstub: add helper for 128 bit registers Alex Bennée
2019-11-18 8:13 ` Richard Henderson
2019-11-15 17:29 ` [RFC PATCH 06/11] target/arm: use gdb_get_reg helpers Alex Bennée
2019-11-18 8:19 ` Richard Henderson
2019-11-15 17:29 ` [RFC PATCH 07/11] target/m68k: " Alex Bennée
2019-11-18 8:21 ` Richard Henderson
2019-11-15 17:29 ` [RFC PATCH 08/11] gdbstub: extend GByteArray to read register helpers Alex Bennée
2019-11-18 8:41 ` Richard Henderson
2019-11-15 17:29 ` [RFC PATCH 09/11] target/arm: prepare for multiple dynamic XMLs Alex Bennée
2019-11-15 17:29 ` [RFC PATCH 10/11] target/arm: explicitly encode regnum in our XML Alex Bennée
2019-11-18 8:43 ` Richard Henderson
2019-11-15 17:30 ` [RFC PATCH 11/11] target/arm: generate xml description of our SVE registers Alex Bennée
2019-11-18 8:46 ` Richard Henderson
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=20191115173000.21891-2-alex.bennee@linaro.org \
--to=alex.bennee@linaro.org \
--cc=alan.hayward@arm.com \
--cc=damien.hedde@greensocs.com \
--cc=luis.machado@linaro.org \
--cc=philmd@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.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;
as well as URLs for NNTP newsgroup(s).