From: Ladi Prosek <lprosek@redhat.com>
To: Mihail Abakumov <mikhail.abakumov@ispras.ru>
Cc: qemu-devel <qemu-devel@nongnu.org>,
sw@weilnetz.de, Pavel Dovgalyuk <dovgaluk@ispras.ru>,
Roman Kagan <rkagan@virtuozzo.com>,
Paolo Bonzini <pbonzini@redhat.com>,
"Denis V. Lunev" <den@openvz.org>
Subject: Re: [Qemu-devel] [PATCH v3 35/45] windbg: debug exception subscribing
Date: Wed, 6 Dec 2017 10:23:16 +0100 [thread overview]
Message-ID: <CABdb735La9XqoQBgnf+OE-cZqOxv5teTnd6ce7O1nk_U9X4V3Q@mail.gmail.com> (raw)
In-Reply-To: <a4c7740fd7e8cb93d86ea525e6e84999@ispras.ru>
On Wed, Dec 6, 2017 at 8:29 AM, Mihail Abakumov
<mikhail.abakumov@ispras.ru> wrote:
> Ladi Prosek писал 2017-11-29 10:13:
>
>> On Tue, Nov 21, 2017 at 3:10 PM, Mihail Abakumov
>> <mikhail.abakumov@ispras.ru> wrote:
>>>
>>> Added handler registration of gdb debug exception. Its exception also can
>>> be used for windbg.
>>>
>>> Signed-off-by: Mihail Abakumov <mikhail.abakumov@ispras.ru>
>>> Signed-off-by: Pavel Dovgalyuk <dovgaluk@ispras.ru>
>>> Signed-off-by: Dmitriy Koltunov <koltunov@ispras.ru>
>>> ---
>>> cpus.c | 18 +++++++++++++++++-
>>> gdbstub.c | 4 ++++
>>> include/sysemu/sysemu.h | 2 ++
>>> windbgstub.c | 16 ++++++++++++----
>>> 4 files changed, 35 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/cpus.c b/cpus.c
>>> index 9bed61eefc..212553b7e3 100644
>>> --- a/cpus.c
>>> +++ b/cpus.c
>>> @@ -77,6 +77,8 @@ int64_t max_advance;
>>> static QEMUTimer *throttle_timer;
>>> static unsigned int throttle_percentage;
>>>
>>> +static void (*excp_debug_handler)(CPUState *cpu);
>>> +
>>> #define CPU_THROTTLE_PCT_MIN 1
>>> #define CPU_THROTTLE_PCT_MAX 99
>>> #define CPU_THROTTLE_TIMESLICE_NS 10000000
>>> @@ -960,9 +962,23 @@ static bool cpu_can_run(CPUState *cpu)
>>> return true;
>>> }
>>>
>>> +bool register_excp_debug_handler(void (*handler)(CPUState *cpu))
>>> +{
>>> + if (excp_debug_handler == NULL) {
>>> + excp_debug_handler = handler;
>>> + return true;
>>> + } else {
>>> + error_report("ERROR: Something debugger already using");
>>
>>
>> So I take it that -windbg and -gdb cannot be used at the same time.
>> Should it be handled in a more explicit way with a more user-friendly
>> error?
>>
>> Right now I get this error, which is more like an implementation
>> detail (could the debug handler be refactored into a multicast event
>> in the future?) and does not even make sense as a sentence.
>
>
> Yes. I have added a more user-friendly error. "Something debugger is
> already in use. '-gdb' and '-windbg' cannot be used at the same time".
> Or what do you mean under the explicit way? How to do it better?
Yes, "'-gdb' and '-windbg' cannot be used at the same time" would be
nicer. By being more explicit I mean issuing the error from the code
that parses the options.
In other words, I can imagine an implementation of
register_excp_debug_handler() that allows registering multiple
handlers. But running windbg and gdb at the same would probably still
not be a good idea.
Maybe I'm nit-picking and it's ok for the error to stay here.
Wondering what other reviewers think.
>>
>>> + return false;
>>> + }
>>> +}
>>> +
>>> static void cpu_handle_guest_debug(CPUState *cpu)
>>> {
>>> - gdb_set_stop_cpu(cpu);
>>> + if (excp_debug_handler != NULL) {
>>> + excp_debug_handler(cpu);
>>> + }
>>> +
>>> qemu_system_debug_request();
>>> cpu->stopped = true;
>>> }
>>> diff --git a/gdbstub.c b/gdbstub.c
>>> index 2a94030d3b..8c76f54117 100644
>>> --- a/gdbstub.c
>>> +++ b/gdbstub.c
>>> @@ -2006,6 +2006,10 @@ int gdbserver_start(const char *device)
>>> s->mon_chr = mon_chr;
>>> s->current_syscall_cb = NULL;
>>>
>>> + if (!register_excp_debug_handler(gdb_set_stop_cpu)) {
>>> + exit(1);
>>> + }
>>> +
>>> return 0;
>>> }
>>>
>>> diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
>>> index b21369672a..34588c99b4 100644
>>> --- a/include/sysemu/sysemu.h
>>> +++ b/include/sysemu/sysemu.h
>>> @@ -193,6 +193,8 @@ QemuOpts *qemu_get_machine_opts(void);
>>>
>>> bool defaults_enabled(void);
>>>
>>> +bool register_excp_debug_handler(void (*handler)(CPUState *cpu));
>>> +
>>> extern QemuOptsList qemu_legacy_drive_opts;
>>> extern QemuOptsList qemu_common_drive_opts;
>>> extern QemuOptsList qemu_drive_opts;
>>> diff --git a/windbgstub.c b/windbgstub.c
>>> index 489abe6d6c..b33f412659 100755
>>> --- a/windbgstub.c
>>> +++ b/windbgstub.c
>>> @@ -115,16 +115,20 @@ static void windbg_send_control_packet(uint16_t
>>> type)
>>> windbg_state->ctrl_packet_id ^= 1;
>>> }
>>>
>>> -static void windbg_vm_stop(void)
>>> +static void windbg_bp_handler(CPUState *cpu)
>>> {
>>> - CPUState *cpu = qemu_get_cpu(0);
>>> - vm_stop(RUN_STATE_PAUSED);
>>> -
>>> SizedBuf buf = kd_gen_exception_sc(cpu);
>>> windbg_send_data_packet(buf.data, buf.size,
>>> PACKET_TYPE_KD_STATE_CHANGE64);
>>> SBUF_FREE(buf);
>>> }
>>>
>>> +static void windbg_vm_stop(void)
>>> +{
>>> + CPUState *cpu = qemu_get_cpu(0);
>>> + vm_stop(RUN_STATE_PAUSED);
>>> + windbg_bp_handler(cpu);
>>> +}
>>> +
>>> static void windbg_process_manipulate_packet(ParsingContext *ctx)
>>> {
>>> CPUState *cpu;
>>> @@ -432,6 +436,10 @@ int windbg_server_start(const char *device)
>>>
>>> qemu_register_reset(windbg_handle_reset, NULL);
>>>
>>> + if (!register_excp_debug_handler(windbg_bp_handler)) {
>>> + exit(1);
>>> + }
>>> +
>>> atexit(windbg_exit);
>>> return 0;
>>> }
>>>
>
next prev parent reply other threads:[~2017-12-06 9:23 UTC|newest]
Thread overview: 70+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-21 14:07 [Qemu-devel] [PATCH v3 00/45] Windbg supporting Mihail Abakumov
2017-11-21 14:07 ` [Qemu-devel] [PATCH v3 01/45] windbg: added empty windbgstub files Mihail Abakumov
2017-11-28 12:10 ` Ladi Prosek
2017-11-21 14:07 ` [Qemu-devel] [PATCH v3 02/45] windbg: added windbg's KD header file Mihail Abakumov
2017-11-21 14:07 ` [Qemu-devel] [PATCH v3 03/45] windbg: modified windbgkd.h Mihail Abakumov
2017-11-28 12:54 ` Ladi Prosek
2017-11-21 14:07 ` [Qemu-devel] [PATCH v3 04/45] windbg: added '-windbg' option Mihail Abakumov
2017-11-21 14:07 ` [Qemu-devel] [PATCH v3 05/45] windbg: added helper features Mihail Abakumov
2017-11-28 8:18 ` Ladi Prosek
2017-11-28 8:34 ` Peter Maydell
2017-11-28 9:01 ` Paolo Bonzini
2017-11-21 14:07 ` [Qemu-devel] [PATCH v3 06/45] windbg: added WindbgState Mihail Abakumov
2017-11-21 14:07 ` [Qemu-devel] [PATCH v3 07/45] windbg: added chardev Mihail Abakumov
2017-11-21 14:08 ` [Qemu-devel] [PATCH v3 08/45] windbg: hook to wrmsr operation Mihail Abakumov
2017-11-21 14:08 ` [Qemu-devel] [PATCH v3 09/45] windbg: handler of fs/gs register Mihail Abakumov
2017-11-21 14:08 ` [Qemu-devel] [PATCH v3 10/45] windbg: structures for parsing data stream Mihail Abakumov
2017-11-28 13:45 ` Ladi Prosek
2017-11-21 14:08 ` [Qemu-devel] [PATCH v3 11/45] windbg: " Mihail Abakumov
2017-11-21 14:08 ` [Qemu-devel] [PATCH v3 12/45] windbg: send data and control packets Mihail Abakumov
2017-11-21 14:08 ` [Qemu-devel] [PATCH v3 13/45] windbg: handler of parsing context Mihail Abakumov
2017-11-21 14:08 ` [Qemu-devel] [PATCH v3 14/45] windbg: init DBGKD_ANY_WAIT_STATE_CHANGE Mihail Abakumov
2017-11-21 14:08 ` [Qemu-devel] [PATCH v3 15/45] windbg: sized data buffer Mihail Abakumov
2017-11-28 14:07 ` Ladi Prosek
2017-11-21 14:08 ` [Qemu-devel] [PATCH v3 16/45] windbg: generate ExceptionStateChange Mihail Abakumov
2017-11-21 14:08 ` [Qemu-devel] [PATCH v3 17/45] windbg: generate LoadSymbolsStateChange Mihail Abakumov
2017-11-21 14:08 ` [Qemu-devel] [PATCH v3 18/45] windbg: windbg_vm_stop Mihail Abakumov
2017-11-21 14:09 ` [Qemu-devel] [PATCH v3 19/45] windbg: implemented windbg_process_control_packet Mihail Abakumov
2017-11-21 14:09 ` [Qemu-devel] [PATCH v3 20/45] windbg: implemented windbg_process_data_packet Mihail Abakumov
2017-11-21 14:09 ` [Qemu-devel] [PATCH v3 21/45] windbg: implemented windbg_process_manipulate_packet Mihail Abakumov
2017-11-21 14:09 ` [Qemu-devel] [PATCH v3 22/45] windbg: implemented kd_api_read_virtual_memory and kd_api_write_virtual_memory Mihail Abakumov
2017-11-21 14:09 ` [Qemu-devel] [PATCH v3 23/45] windbg: kernel's structures Mihail Abakumov
2017-11-21 14:09 ` [Qemu-devel] [PATCH v3 24/45] windbg: implemented kd_api_get_context and kd_api_set_context Mihail Abakumov
2017-11-21 14:09 ` [Qemu-devel] [PATCH v3 25/45] windbg: implemented kd_api_read_control_space and kd_api_write_control_space Mihail Abakumov
2017-11-21 14:09 ` [Qemu-devel] [PATCH v3 26/45] windbg: implemented windbg_read_context Mihail Abakumov
2017-11-28 14:57 ` Ladi Prosek
2017-11-21 14:09 ` [Qemu-devel] [PATCH v3 27/45] windbg: implemented windbg_write_context Mihail Abakumov
2017-11-21 14:09 ` [Qemu-devel] [PATCH v3 28/45] windbg: implemented windbg_read_ks_regs Mihail Abakumov
2017-11-21 14:09 ` [Qemu-devel] [PATCH v3 29/45] windbg: implemented windbg_write_ks_regs Mihail Abakumov
2017-11-21 14:10 ` [Qemu-devel] [PATCH v3 30/45] windbg: implemented windbg_set_sr Mihail Abakumov
2017-11-21 14:10 ` [Qemu-devel] [PATCH v3 31/45] windbg: implemented windbg_set_dr Mihail Abakumov
2017-11-21 14:10 ` [Qemu-devel] [PATCH v3 32/45] windbg: implemented windbg_set_dr7 Mihail Abakumov
2017-11-21 14:10 ` [Qemu-devel] [PATCH v3 33/45] windbg: implemented windbg_hw_breakpoint_insert and windbg_hw_breakpoint_remove Mihail Abakumov
2017-11-21 14:10 ` [Qemu-devel] [PATCH v3 34/45] windbg: implemented kd_api_write_breakpoint and kd_api_restore_breakpoint Mihail Abakumov
2017-11-21 14:10 ` [Qemu-devel] [PATCH v3 35/45] windbg: debug exception subscribing Mihail Abakumov
2017-11-29 7:13 ` Ladi Prosek
2017-12-06 7:29 ` Mihail Abakumov
2017-12-06 9:23 ` Ladi Prosek [this message]
2017-11-21 14:10 ` [Qemu-devel] [PATCH v3 36/45] windbg: implemented kd_api_continue Mihail Abakumov
2017-11-21 14:10 ` [Qemu-devel] [PATCH v3 37/45] windbg: implemented kd_api_read_io_space and kd_api_write_io_space Mihail Abakumov
2017-11-21 14:10 ` [Qemu-devel] [PATCH v3 38/45] windbg: implemented kd_api_read_physical_memory and kd_api_write_physical_memory Mihail Abakumov
2017-11-21 14:10 ` [Qemu-devel] [PATCH v3 39/45] windbg: implemented kd_api_get_version Mihail Abakumov
2017-11-29 8:14 ` Ladi Prosek
2017-12-06 9:00 ` Mihail Abakumov
2017-12-06 9:37 ` Ladi Prosek
2017-11-21 14:11 ` [Qemu-devel] [PATCH v3 40/45] windbg: implemented kd_api_read_msr and kd_api_write_msr Mihail Abakumov
2017-11-29 7:25 ` Ladi Prosek
2017-11-21 14:11 ` [Qemu-devel] [PATCH v3 41/45] windbg: implemented kd_api_search_memory Mihail Abakumov
2017-11-29 7:55 ` Ladi Prosek
2017-11-21 14:11 ` [Qemu-devel] [PATCH v3 42/45] windbg: implemented kd_api_fill_memory Mihail Abakumov
2017-11-21 14:11 ` [Qemu-devel] [PATCH v3 43/45] windbg: implemented kd_api_query_memory Mihail Abakumov
2017-11-29 8:03 ` Ladi Prosek
2017-11-21 14:11 ` [Qemu-devel] [PATCH v3 44/45] windbg: added new api functions Mihail Abakumov
2017-11-21 14:11 ` [Qemu-devel] [PATCH v3 45/45] windbg: implemented kd_api_get_context_ex and kd_api_set_context_ex Mihail Abakumov
2017-11-28 12:44 ` Ladi Prosek
2017-12-05 11:28 ` Mihail Abakumov
2017-11-21 15:00 ` [Qemu-devel] [PATCH v3 00/45] Windbg supporting no-reply
2017-11-21 15:05 ` no-reply
2017-11-21 16:23 ` no-reply
2017-11-29 8:23 ` Ladi Prosek
2017-12-06 9:14 ` Mihail Abakumov
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=CABdb735La9XqoQBgnf+OE-cZqOxv5teTnd6ce7O1nk_U9X4V3Q@mail.gmail.com \
--to=lprosek@redhat.com \
--cc=den@openvz.org \
--cc=dovgaluk@ispras.ru \
--cc=mikhail.abakumov@ispras.ru \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rkagan@virtuozzo.com \
--cc=sw@weilnetz.de \
/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).