From: David Gibson <david@gibson.dropbear.id.au> To: Suraj Jitindar Singh <sjitindarsingh@gmail.com> Cc: qemu-devel@nongnu.org, dgilbert@redhat.com, armbru@redhat.com, qemu-ppc@nongnu.org Subject: Re: [Qemu-devel] [PATCH 1/2] monitor: Add dump-stack command Date: Thu, 2 May 2019 10:44:20 +1000 [thread overview] Message-ID: <20190502004420.GD13618@umbus.fritz.box> (raw) In-Reply-To: <20190501053522.10967-1-sjitindarsingh@gmail.com> [-- Attachment #1: Type: text/plain, Size: 4324 bytes --] On Wed, May 01, 2019 at 03:35:21PM +1000, Suraj Jitindar Singh wrote: > Add a monitor command "dump-stack" to be used to dump the stack for the > current cpu. So, you can already get guest backtraces by using the gdbstub functionality. I can see some benefit in allowing this more easily through hmp, but whether it's worth the code size, I'm less certain. > > Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com> > --- > hmp-commands.hx | 13 +++++++++++++ > hmp.h | 1 + > include/qom/cpu.h | 10 ++++++++++ > monitor.c | 12 ++++++++++++ > qom/cpu.c | 10 ++++++++++ > 5 files changed, 46 insertions(+) > > diff --git a/hmp-commands.hx b/hmp-commands.hx > index 9b4035965c..965ccdea28 100644 > --- a/hmp-commands.hx > +++ b/hmp-commands.hx > @@ -862,6 +862,19 @@ ETEXI > }, > > STEXI > +@item dump-stack > +@findex dump-stack > +dump stack of the cpu > +ETEXI > + { > + .name = "dump-stack", > + .args_type = "", > + .params = "", > + .help = "dump stack", > + .cmd = hmp_dumpstack, > + }, > + > +STEXI > @item pmemsave @var{addr} @var{size} @var{file} > @findex pmemsave > save to disk physical memory dump starting at @var{addr} of size @var{size}. > diff --git a/hmp.h b/hmp.h > index 43617f2646..e6edf1215c 100644 > --- a/hmp.h > +++ b/hmp.h > @@ -51,6 +51,7 @@ void hmp_announce_self(Monitor *mon, const QDict *qdict); > void hmp_cpu(Monitor *mon, const QDict *qdict); > void hmp_memsave(Monitor *mon, const QDict *qdict); > void hmp_pmemsave(Monitor *mon, const QDict *qdict); > +void hmp_dumpstack(Monitor *mon, const QDict *qdict); > void hmp_ringbuf_write(Monitor *mon, const QDict *qdict); > void hmp_ringbuf_read(Monitor *mon, const QDict *qdict); > void hmp_cont(Monitor *mon, const QDict *qdict); > diff --git a/include/qom/cpu.h b/include/qom/cpu.h > index 08abcbd3fe..f2e83e9918 100644 > --- a/include/qom/cpu.h > +++ b/include/qom/cpu.h > @@ -181,6 +181,7 @@ typedef struct CPUClass { > int (*memory_rw_debug)(CPUState *cpu, vaddr addr, > uint8_t *buf, int len, bool is_write); > void (*dump_state)(CPUState *cpu, FILE *, int flags); > + void (*dump_stack)(CPUState *cpu, FILE *f); > GuestPanicInformation* (*get_crash_info)(CPUState *cpu); > void (*dump_statistics)(CPUState *cpu, int flags); > int64_t (*get_arch_id)(CPUState *cpu); > @@ -568,6 +569,15 @@ enum CPUDumpFlags { > void cpu_dump_state(CPUState *cpu, FILE *f, int flags); > > /** > + * cpu_dump_stack: > + * @cpu: The CPU whose stack is to be dumped. > + * @f: If non-null, dump to this stream, else to current print sink. > + * > + * Dumps CPU stack. > + */ > +void cpu_dump_stack(CPUState *cpu, FILE *f); > + > +/** > * cpu_dump_statistics: > * @cpu: The CPU whose state is to be dumped. > * @flags: Flags what to dump. > diff --git a/monitor.c b/monitor.c > index 9b5f10b475..dbec2e4376 100644 > --- a/monitor.c > +++ b/monitor.c > @@ -1299,6 +1299,18 @@ static void hmp_info_registers(Monitor *mon, const QDict *qdict) > } > } > > +void hmp_dumpstack(Monitor *mon, const QDict *qdict) > +{ > + CPUState *cs = mon_get_cpu(); > + > + if (!cs) { > + monitor_printf(mon, "No CPU available\n"); > + return; > + } > + > + cpu_dump_stack(cs, NULL); > +} > + > #ifdef CONFIG_TCG > static void hmp_info_jit(Monitor *mon, const QDict *qdict) > { > diff --git a/qom/cpu.c b/qom/cpu.c > index 3c5493c96c..0dc10004f4 100644 > --- a/qom/cpu.c > +++ b/qom/cpu.c > @@ -230,6 +230,16 @@ void cpu_dump_state(CPUState *cpu, FILE *f, int flags) > } > } > > +void cpu_dump_stack(CPUState *cpu, FILE *f) > +{ > + CPUClass *cc = CPU_GET_CLASS(cpu); > + > + if (cc->dump_stack) { > + cpu_synchronize_state(cpu); > + cc->dump_stack(cpu, f); > + } > +} > + > void cpu_dump_statistics(CPUState *cpu, int flags) > { > CPUClass *cc = CPU_GET_CLASS(cpu); -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --]
WARNING: multiple messages have this Message-ID (diff)
From: David Gibson <david@gibson.dropbear.id.au> To: Suraj Jitindar Singh <sjitindarsingh@gmail.com> Cc: armbru@redhat.com, qemu-ppc@nongnu.org, qemu-devel@nongnu.org, dgilbert@redhat.com Subject: Re: [Qemu-devel] [PATCH 1/2] monitor: Add dump-stack command Date: Thu, 2 May 2019 10:44:20 +1000 [thread overview] Message-ID: <20190502004420.GD13618@umbus.fritz.box> (raw) Message-ID: <20190502004420.dfldsyFRfFBwctkC-mXEx2GnKKe84dOv0AXiUUfo-5Y@z> (raw) In-Reply-To: <20190501053522.10967-1-sjitindarsingh@gmail.com> [-- Attachment #1: Type: text/plain, Size: 4324 bytes --] On Wed, May 01, 2019 at 03:35:21PM +1000, Suraj Jitindar Singh wrote: > Add a monitor command "dump-stack" to be used to dump the stack for the > current cpu. So, you can already get guest backtraces by using the gdbstub functionality. I can see some benefit in allowing this more easily through hmp, but whether it's worth the code size, I'm less certain. > > Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com> > --- > hmp-commands.hx | 13 +++++++++++++ > hmp.h | 1 + > include/qom/cpu.h | 10 ++++++++++ > monitor.c | 12 ++++++++++++ > qom/cpu.c | 10 ++++++++++ > 5 files changed, 46 insertions(+) > > diff --git a/hmp-commands.hx b/hmp-commands.hx > index 9b4035965c..965ccdea28 100644 > --- a/hmp-commands.hx > +++ b/hmp-commands.hx > @@ -862,6 +862,19 @@ ETEXI > }, > > STEXI > +@item dump-stack > +@findex dump-stack > +dump stack of the cpu > +ETEXI > + { > + .name = "dump-stack", > + .args_type = "", > + .params = "", > + .help = "dump stack", > + .cmd = hmp_dumpstack, > + }, > + > +STEXI > @item pmemsave @var{addr} @var{size} @var{file} > @findex pmemsave > save to disk physical memory dump starting at @var{addr} of size @var{size}. > diff --git a/hmp.h b/hmp.h > index 43617f2646..e6edf1215c 100644 > --- a/hmp.h > +++ b/hmp.h > @@ -51,6 +51,7 @@ void hmp_announce_self(Monitor *mon, const QDict *qdict); > void hmp_cpu(Monitor *mon, const QDict *qdict); > void hmp_memsave(Monitor *mon, const QDict *qdict); > void hmp_pmemsave(Monitor *mon, const QDict *qdict); > +void hmp_dumpstack(Monitor *mon, const QDict *qdict); > void hmp_ringbuf_write(Monitor *mon, const QDict *qdict); > void hmp_ringbuf_read(Monitor *mon, const QDict *qdict); > void hmp_cont(Monitor *mon, const QDict *qdict); > diff --git a/include/qom/cpu.h b/include/qom/cpu.h > index 08abcbd3fe..f2e83e9918 100644 > --- a/include/qom/cpu.h > +++ b/include/qom/cpu.h > @@ -181,6 +181,7 @@ typedef struct CPUClass { > int (*memory_rw_debug)(CPUState *cpu, vaddr addr, > uint8_t *buf, int len, bool is_write); > void (*dump_state)(CPUState *cpu, FILE *, int flags); > + void (*dump_stack)(CPUState *cpu, FILE *f); > GuestPanicInformation* (*get_crash_info)(CPUState *cpu); > void (*dump_statistics)(CPUState *cpu, int flags); > int64_t (*get_arch_id)(CPUState *cpu); > @@ -568,6 +569,15 @@ enum CPUDumpFlags { > void cpu_dump_state(CPUState *cpu, FILE *f, int flags); > > /** > + * cpu_dump_stack: > + * @cpu: The CPU whose stack is to be dumped. > + * @f: If non-null, dump to this stream, else to current print sink. > + * > + * Dumps CPU stack. > + */ > +void cpu_dump_stack(CPUState *cpu, FILE *f); > + > +/** > * cpu_dump_statistics: > * @cpu: The CPU whose state is to be dumped. > * @flags: Flags what to dump. > diff --git a/monitor.c b/monitor.c > index 9b5f10b475..dbec2e4376 100644 > --- a/monitor.c > +++ b/monitor.c > @@ -1299,6 +1299,18 @@ static void hmp_info_registers(Monitor *mon, const QDict *qdict) > } > } > > +void hmp_dumpstack(Monitor *mon, const QDict *qdict) > +{ > + CPUState *cs = mon_get_cpu(); > + > + if (!cs) { > + monitor_printf(mon, "No CPU available\n"); > + return; > + } > + > + cpu_dump_stack(cs, NULL); > +} > + > #ifdef CONFIG_TCG > static void hmp_info_jit(Monitor *mon, const QDict *qdict) > { > diff --git a/qom/cpu.c b/qom/cpu.c > index 3c5493c96c..0dc10004f4 100644 > --- a/qom/cpu.c > +++ b/qom/cpu.c > @@ -230,6 +230,16 @@ void cpu_dump_state(CPUState *cpu, FILE *f, int flags) > } > } > > +void cpu_dump_stack(CPUState *cpu, FILE *f) > +{ > + CPUClass *cc = CPU_GET_CLASS(cpu); > + > + if (cc->dump_stack) { > + cpu_synchronize_state(cpu); > + cc->dump_stack(cpu, f); > + } > +} > + > void cpu_dump_statistics(CPUState *cpu, int flags) > { > CPUClass *cc = CPU_GET_CLASS(cpu); -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2019-05-02 0:44 UTC|newest] Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-05-01 5:35 [Qemu-devel] [PATCH 1/2] monitor: Add dump-stack command Suraj Jitindar Singh 2019-05-01 5:35 ` Suraj Jitindar Singh 2019-05-01 5:35 ` [Qemu-devel] [PATCH 2/2] ppc: Add dump-stack implementation Suraj Jitindar Singh 2019-05-01 5:35 ` Suraj Jitindar Singh 2019-05-01 9:48 ` Alexey Kardashevskiy 2019-05-01 9:48 ` Alexey Kardashevskiy 2019-05-02 0:43 ` David Gibson 2019-05-02 0:43 ` David Gibson 2019-05-02 3:47 ` Alexey Kardashevskiy 2019-05-02 3:47 ` Alexey Kardashevskiy 2019-05-06 3:39 ` David Gibson 2019-05-02 13:59 ` [Qemu-devel] [Qemu-ppc] " Greg Kurz 2019-05-02 13:59 ` Greg Kurz 2019-05-07 11:24 ` [Qemu-devel] " Markus Armbruster 2019-05-01 10:44 ` [Qemu-devel] [PATCH 1/2] monitor: Add dump-stack command Dr. David Alan Gilbert 2019-05-01 10:44 ` Dr. David Alan Gilbert 2019-05-02 0:44 ` David Gibson [this message] 2019-05-02 0:44 ` David Gibson 2019-05-02 2:15 ` [Qemu-devel] [Qemu-ppc] " Alexey Kardashevskiy 2019-05-02 2:15 ` Alexey Kardashevskiy 2019-05-07 11:21 ` Markus Armbruster 2019-05-07 11:09 ` [Qemu-devel] " Markus Armbruster 2019-05-08 10:26 ` Dr. David Alan Gilbert 2019-05-08 13:10 ` Markus Armbruster 2019-05-08 13:15 ` Dr. David Alan Gilbert 2019-06-21 0:51 ` Suraj Jitindar Singh 2019-06-24 8:57 ` Markus Armbruster
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=20190502004420.GD13618@umbus.fritz.box \ --to=david@gibson.dropbear.id.au \ --cc=armbru@redhat.com \ --cc=dgilbert@redhat.com \ --cc=qemu-devel@nongnu.org \ --cc=qemu-ppc@nongnu.org \ --cc=sjitindarsingh@gmail.com \ /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: linkBe 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).