[Qemu-devel] [PATCH v3 00/39] Windbg supporting

Mikhail Abakumov posted 39 patches 1 week ago
Test checkpatch failed
Test docker-quick@centos7 passed
Test docker-clang@ubuntu failed
Test docker-mingw@fedora passed
Test asan passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/154409751316.5432.3325938832238028060.stgit@Misha-PC.lan02.inno
MAINTAINERS                      |   12
Makefile.target                  |    3
cpus.c                           |   20 +
default-configs/i386-softmmu.mak |    1
gdbstub.c                        |    6
include/exec/gdbstub.h           |    1
include/exec/windbgkd.h          |  928 ++++++++++++++++++++++++++
include/exec/windbgstub-utils.h  |  104 +++
include/exec/windbgstub.h        |   25 +
include/sysemu/sysemu.h          |    2
qemu-options.hx                  |    8
stubs/Makefile.objs              |    1
stubs/windbgstub.c               |   22 +
target/i386/Makefile.objs        |    1
target/i386/cpu.h                |    5
target/i386/misc_helper.c        |   38 +
target/i386/windbgstub.c         | 1368 ++++++++++++++++++++++++++++++++++++++
vl.c                             |    8
windbgstub-utils.c               |  511 ++++++++++++++
windbgstub.c                     |  545 +++++++++++++++
20 files changed, 3596 insertions(+), 13 deletions(-)
create mode 100644 include/exec/windbgkd.h
create mode 100644 include/exec/windbgstub-utils.h
create mode 100644 include/exec/windbgstub.h
create mode 100644 stubs/windbgstub.c
create mode 100644 target/i386/windbgstub.c
create mode 100644 windbgstub-utils.c
create mode 100644 windbgstub.c

[Qemu-devel] [PATCH v3 00/39] Windbg supporting

Posted by Mikhail Abakumov 1 week ago
An update of:

        v2: https://lists.gnu.org/archive/html/qemu-devel/2018-12/msg00748.html

We made the debugger module WinDbg (like GDB) for QEMU. This is the replacement
of the remote server in Windows kernel. Used for remote Windows kernel debugging
without debugging mode.

WinDbg is a multipurpose debugger for the Microsoft Windows computer operating
system, distributed by Microsoft. Recent versions of WinDbg have been
and are being distributed as part of the free Debugging Tools for Windows suite.

How to start debugging QEMU using WinDbg:
  Run QEMU with next option:
    -windbg pipe:<name>
  QEMU will start and pause for waiting WinDbg connection.
  Run WinDbg with next options:
    -b -k com:pipe,baud=115200,port=\\.\pipe\<name>,resets=0
  Wait for debugger connect to kernel.

Note: You can add Symbol Search Path in WinDbg
such as srv*c:\tmp*http://msdl.microsoft.com/download/symbols.

How it works:
The WinDbg debugger has the possibility of connecting to a remote debug server
(Kdsrv.exe) in the Windows kernel. Therefore, it is possible to connect
to the guest system running in the QEMU emulator. Kernel debugging is possible
only with the enabled debugging mode, may change at the same time.
Our module of WinDbg debugger for QEMU is an alternative of the remote debugging
service in the kernel. Thus, the debugger connects to the debugging module,
not to the kernel of the operating system. The module obtains all the necessary
information answering debugger requests from the QEMU emulator. At the same time
for debugging there is no need to enable debugging mode in the kernel.
This leads to hidden debugging. Our module supports all features of WinDbg
regarding remote debugging, besides interception of events and exceptions.
Supports i386 and x86_64 architectures.

Changed in v3:

 - Make gdb_set_stop_cpu static and remove the gdbstub.h reference
   from cpus.c (Alex Bennée).
 - Fix typo in code.

Changed in v2:

 - Fix errors in crash report (Changbin Du).

Tested-by: Ladi Prosek <lprosek@redhat.com>
---

Mikhail Abakumov (39):
      windbg: add empty windbgstub files
      windbg: add windbg's KD header file
      windbg: add -windbg option
      windbg: add helper features
      windbg: add WindbgState
      windbg: add chardev
      windbg: hook to wrmsr operation
      windbg: implement windbg_on_load
      windbg: implement find_KPCR
      windbg: implement find_kdVersion
      windbg: add windbg_search_vmaddr
      windbg: implement find_kdDebuggerDataBlock
      windbg: parsing data stream
      windbg: send data and control packets
      windbg: handler of parsing context
      windbg: init DBGKD_ANY_WAIT_STATE_CHANGE
      windbg: generate ExceptionStateChange and LoadSymbolsStateChange
      windbg: implement windbg_process_control_packet
      windbg: implement windbg_process_data_packet
      windbg: implement windbg_process_manipulate_packet
      windbg: implement kd_api_read_virtual_memory and kd_api_write_virtual_memory
      windbg: some kernel structures
      windbg: add helper functions
      windbg: [de]serialization cpu context
      windbg: [de]serialization cpu spec registers
      windbg: implement kd_api_get_context and kd_api_set_context
      windbg: implement kd_api_get_context_ex and kd_api_set_context_ex
      windbg: implement kd_api_read_control_space and kd_api_write_control_space
      windbg: implement kd_api_write_breakpoint and kd_api_restore_breakpoint
      windbg: debug exception subscribing
      windbg: implement kd_api_continue
      windbg: implement kd_api_read_io_space and kd_api_write_io_space
      windbg: implement kd_api_read_physical_memory and kd_api_write_physical_memory
      windbg: implement kd_api_get_version
      windbg: implement kd_api_read_msr and kd_api_write_msr
      windbg: implement kd_api_search_memory
      windbg: implement kd_api_fill_memory
      windbg: implement kd_api_query_memory
      windbg: maintainers


 MAINTAINERS                      |   12 
 Makefile.target                  |    3 
 cpus.c                           |   20 +
 default-configs/i386-softmmu.mak |    1 
 gdbstub.c                        |    6 
 include/exec/gdbstub.h           |    1 
 include/exec/windbgkd.h          |  928 ++++++++++++++++++++++++++
 include/exec/windbgstub-utils.h  |  104 +++
 include/exec/windbgstub.h        |   25 +
 include/sysemu/sysemu.h          |    2 
 qemu-options.hx                  |    8 
 stubs/Makefile.objs              |    1 
 stubs/windbgstub.c               |   22 +
 target/i386/Makefile.objs        |    1 
 target/i386/cpu.h                |    5 
 target/i386/misc_helper.c        |   38 +
 target/i386/windbgstub.c         | 1368 ++++++++++++++++++++++++++++++++++++++
 vl.c                             |    8 
 windbgstub-utils.c               |  511 ++++++++++++++
 windbgstub.c                     |  545 +++++++++++++++
 20 files changed, 3596 insertions(+), 13 deletions(-)
 create mode 100644 include/exec/windbgkd.h
 create mode 100644 include/exec/windbgstub-utils.h
 create mode 100644 include/exec/windbgstub.h
 create mode 100644 stubs/windbgstub.c
 create mode 100644 target/i386/windbgstub.c
 create mode 100644 windbgstub-utils.c
 create mode 100644 windbgstub.c

--
Mikhail Abakumov

Re: [Qemu-devel] [PATCH v3 00/39] Windbg supporting

Posted by no-reply@patchew.org 1 week ago
Patchew URL: https://patchew.org/QEMU/154409751316.5432.3325938832238028060.stgit@Misha-PC.lan02.inno/



Hi,

This series seems to have some coding style problems. See output below for
more information:

Type: series
Subject: [Qemu-devel] [PATCH v3 00/39] Windbg supporting
Message-id: 154409751316.5432.3325938832238028060.stgit@Misha-PC.lan02.inno

=== TEST SCRIPT BEGIN ===
#!/bin/bash

BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0

git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram

commits="$(git log --format=%H --reverse $BASE..)"
for c in $commits; do
    echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
    if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
        failed=1
        echo
    fi
    n=$((n+1))
done

exit $failed
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'
fe77421 windbg: maintainers
a54a378 windbg: implement kd_api_query_memory
58798f6 windbg: implement kd_api_fill_memory
6acb09a windbg: implement kd_api_search_memory
ed90032 windbg: implement kd_api_read_msr and kd_api_write_msr
39ab36c windbg: implement kd_api_get_version
1be3261 windbg: implement kd_api_read_physical_memory and kd_api_write_physical_memory
ca747a3 windbg: implement kd_api_read_io_space and kd_api_write_io_space
81e7c01 windbg: implement kd_api_continue
ec7d22c windbg: debug exception subscribing
807cb65 windbg: implement kd_api_write_breakpoint and kd_api_restore_breakpoint
3bc4996 windbg: implement kd_api_read_control_space and kd_api_write_control_space
05a1fa3 windbg: implement kd_api_get_context_ex and kd_api_set_context_ex
41663e4 windbg: implement kd_api_get_context and kd_api_set_context
65acede windbg: [de]serialization cpu spec registers
512481c windbg: [de]serialization cpu context
951620b windbg: add helper functions
5f01ea9 windbg: some kernel structures
2c83a4f windbg: implement kd_api_read_virtual_memory and kd_api_write_virtual_memory
c649e5d windbg: implement windbg_process_manipulate_packet
95cdf1d windbg: implement windbg_process_data_packet
8c24ccd windbg: implement windbg_process_control_packet
c28363e windbg: generate ExceptionStateChange and LoadSymbolsStateChange
a50bfff windbg: init DBGKD_ANY_WAIT_STATE_CHANGE
855d149 windbg: handler of parsing context
1689ce9 windbg: send data and control packets
cb0cdb3 windbg: parsing data stream
7150b2c windbg: implement find_kdDebuggerDataBlock
c4dea1e windbg: add windbg_search_vmaddr
1c2b139 windbg: implement find_kdVersion
5b46019 windbg: implement find_KPCR
4b08bb8 windbg: implement windbg_on_load
a220be1 windbg: hook to wrmsr operation
e1201f5 windbg: add chardev
8454bc6 windbg: add WindbgState
feae06e windbg: add helper features
8e64a7b windbg: add -windbg option
d6cf4bd windbg: add windbg's KD header file
947e704 windbg: add empty windbgstub files

=== OUTPUT BEGIN ===
Checking PATCH 1/39: windbg: add empty windbgstub files...
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#35: 
new file mode 100644

total: 0 errors, 1 warnings, 121 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
Checking PATCH 2/39: windbg: add windbg's KD header file...
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#14: 
new file mode 100644

total: 0 errors, 1 warnings, 934 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
Checking PATCH 3/39: windbg: add -windbg option...
Checking PATCH 4/39: windbg: add helper features...
Checking PATCH 5/39: windbg: add WindbgState...
Checking PATCH 6/39: windbg: add chardev...
Checking PATCH 7/39: windbg: hook to wrmsr operation...
Checking PATCH 8/39: windbg: implement windbg_on_load...
Checking PATCH 9/39: windbg: implement find_KPCR...
Checking PATCH 10/39: windbg: implement find_kdVersion...
Checking PATCH 11/39: windbg: add windbg_search_vmaddr...
Checking PATCH 12/39: windbg: implement find_kdDebuggerDataBlock...
Checking PATCH 13/39: windbg: parsing data stream...
Checking PATCH 14/39: windbg: send data and control packets...
Checking PATCH 15/39: windbg: handler of parsing context...
Checking PATCH 16/39: windbg: init DBGKD_ANY_WAIT_STATE_CHANGE...
Checking PATCH 17/39: windbg: generate ExceptionStateChange and LoadSymbolsStateChange...
Checking PATCH 18/39: windbg: implement windbg_process_control_packet...
Checking PATCH 19/39: windbg: implement windbg_process_data_packet...
Checking PATCH 20/39: windbg: implement windbg_process_manipulate_packet...
Checking PATCH 21/39: windbg: implement kd_api_read_virtual_memory and kd_api_write_virtual_memory...
Checking PATCH 22/39: windbg: some kernel structures...
Checking PATCH 23/39: windbg: add helper functions...
ERROR: Macros with multiple statements should be enclosed in a do - while loop
#126: FILE: target/i386/windbgstub.c:387:
+#define CASE_FIELD(stct, field, field_size, block)                             \
+    case offsetof(stct, field):                                                \
+        field_size = sizeof_field(stct, field);                                \
+        block;                                                                 \
+        break;

total: 1 errors, 0 warnings, 129 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

Checking PATCH 24/39: windbg: [de]serialization cpu context...
Checking PATCH 25/39: windbg: [de]serialization cpu spec registers...
Checking PATCH 26/39: windbg: implement kd_api_get_context and kd_api_set_context...
Checking PATCH 27/39: windbg: implement kd_api_get_context_ex and kd_api_set_context_ex...
Checking PATCH 28/39: windbg: implement kd_api_read_control_space and kd_api_write_control_space...
Checking PATCH 29/39: windbg: implement kd_api_write_breakpoint and kd_api_restore_breakpoint...
Checking PATCH 30/39: windbg: debug exception subscribing...
Checking PATCH 31/39: windbg: implement kd_api_continue...
Checking PATCH 32/39: windbg: implement kd_api_read_io_space and kd_api_write_io_space...
Checking PATCH 33/39: windbg: implement kd_api_read_physical_memory and kd_api_write_physical_memory...
Checking PATCH 34/39: windbg: implement kd_api_get_version...
Checking PATCH 35/39: windbg: implement kd_api_read_msr and kd_api_write_msr...
Checking PATCH 36/39: windbg: implement kd_api_search_memory...
Checking PATCH 37/39: windbg: implement kd_api_fill_memory...
Checking PATCH 38/39: windbg: implement kd_api_query_memory...
Checking PATCH 39/39: windbg: maintainers...
=== OUTPUT END ===

Test command exited with code: 1


The full log is available at
http://patchew.org/logs/154409751316.5432.3325938832238028060.stgit@Misha-PC.lan02.inno/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@redhat.com