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

Mikhail Abakumov posted 39 patches 5 years, 4 months ago
Test checkpatch failed
Test docker-quick@centos7 failed
Test docker-clang@ubuntu failed
Test docker-mingw@fedora failed
Test asan failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/154401431697.8440.845616703562380651.stgit@Misha-PC.lan02.inno
There is a newer version of this series
MAINTAINERS                      |   12
Makefile.target                  |    3
cpus.c                           |   19 +
default-configs/i386-softmmu.mak |    1
gdbstub.c                        |    4
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 +++++++++++++++
19 files changed, 3595 insertions(+), 10 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 2 00/39] Windbg supporting
Posted by Mikhail Abakumov 5 years, 4 months ago
An update of:

        v1: https://lists.gnu.org/archive/html/qemu-devel/2018-11/msg06222.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 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                           |   19 +
 default-configs/i386-softmmu.mak |    1 
 gdbstub.c                        |    4 
 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 +++++++++++++++
 19 files changed, 3595 insertions(+), 10 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 2 00/39] Windbg supporting
Posted by no-reply@patchew.org 5 years, 4 months ago
Patchew URL: https://patchew.org/QEMU/154401431697.8440.845616703562380651.stgit@Misha-PC.lan02.inno/



Hi,

This series failed the docker-mingw@fedora build test. Please find the testing commands and
their output below. If you have Docker installed, you can probably reproduce it
locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
time make docker-test-mingw@fedora SHOW_ENV=1 J=8
=== TEST SCRIPT END ===

  CC      x86_64-softmmu/windbgstub-utils.o
  CC      x86_64-softmmu/accel/accel.o
/tmp/qemu-test/src/windbgstub-utils.c: In function 'windbg_search_vmaddr':
/tmp/qemu-test/src/windbgstub-utils.c:173:9: error: 'addr' undeclared (first use in this function); did you mean 'vaddr'?
         addr = 0;
         ^~~~
         vaddr
/tmp/qemu-test/src/windbgstub-utils.c:173:9: note: each undeclared identifier is reported only once for each function it appears in
/tmp/qemu-test/src/windbgstub-utils.c:173:17: error: expected '}' before ';' token
         addr = 0;
                 ^
make[1]: *** [/tmp/qemu-test/src/rules.mak:69: windbgstub-utils.o] Error 1


The full log is available at
http://patchew.org/logs/154401431697.8440.845616703562380651.stgit@Misha-PC.lan02.inno/testing.docker-mingw@fedora/?type=message.
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@redhat.com
Re: [Qemu-devel] [PATCH 2 00/39] Windbg supporting
Posted by no-reply@patchew.org 5 years, 4 months ago
Patchew URL: https://patchew.org/QEMU/154401431697.8440.845616703562380651.stgit@Misha-PC.lan02.inno/



Hi,

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

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

=== 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'
3ab8f93 windbg: maintainers
19399ee windbg: implement kd_api_query_memory
fedc3ed windbg: implement kd_api_fill_memory
2327661 windbg: implement kd_api_search_memory
b3ebde4 windbg: implement kd_api_read_msr and kd_api_write_msr
bd560bc windbg: implement kd_api_get_version
0d30b4b windbg: implement kd_api_read_physical_memory and kd_api_write_physical_memory
5f3d2da windbg: implement kd_api_read_io_space and kd_api_write_io_space
a970aa1 windbg: implement kd_api_continue
e7f4432 windbg: debug exception subscribing
92745ee windbg: implement kd_api_write_breakpoint and kd_api_restore_breakpoint
1a275c5 windbg: implement kd_api_read_control_space and kd_api_write_control_space
e72cf62 windbg: implement kd_api_get_context_ex and kd_api_set_context_ex
ee2f444 windbg: implement kd_api_get_context and kd_api_set_context
c12adfa windbg: [de]serialization cpu spec registers
930f2c1 windbg: [de]serialization cpu context
1956044 windbg: add helper functions
e92c5a0 windbg: some kernel structures
e444486 windbg: implement kd_api_read_virtual_memory and kd_api_write_virtual_memory
829a870 windbg: implement windbg_process_manipulate_packet
3f73f31 windbg: implement windbg_process_data_packet
fd43737 windbg: implement windbg_process_control_packet
313477d windbg: generate ExceptionStateChange and LoadSymbolsStateChange
30ccfe5 windbg: init DBGKD_ANY_WAIT_STATE_CHANGE
6298ba5 windbg: handler of parsing context
dfe88bf windbg: send data and control packets
bc8ec4c windbg: parsing data stream
1de1e8f windbg: implement find_kdDebuggerDataBlock
d8cc50a windbg: add windbg_search_vmaddr
31d02b5 windbg: implement find_kdVersion
1d436b8 windbg: implement find_KPCR
b862005 windbg: implement windbg_on_load
ae78964 windbg: hook to wrmsr operation
2e6e5ad windbg: add chardev
6471d15 windbg: add WindbgState
4433b42 windbg: add helper features
5413de4 windbg: add -windbg option
e810415 windbg: add windbg's KD header file
c6b263d 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/154401431697.8440.845616703562380651.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
Re: [Qemu-devel] [PATCH 2 00/39] Windbg supporting
Posted by no-reply@patchew.org 5 years, 4 months ago
Patchew URL: https://patchew.org/QEMU/154401431697.8440.845616703562380651.stgit@Misha-PC.lan02.inno/



Hi,

This series failed the docker-quick@centos7 build test. Please find the testing commands and
their output below. If you have Docker installed, you can probably reproduce it
locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
time make docker-test-quick@centos7 SHOW_ENV=1 J=8
=== TEST SCRIPT END ===

libpmem support   no
libudev           no

WARNING: Use of SDL 1.2 is deprecated and will be removed in
WARNING: future releases. Please switch to using SDL 2.0

NOTE: cross-compilers enabled:  'cc'
  GEN     x86_64-softmmu/config-devices.mak.tmp
---
  CC      x86_64-softmmu/accel/accel.o
  CC      x86_64-softmmu/accel/kvm/kvm-all.o
/tmp/qemu-test/src/windbgstub-utils.c: In function 'windbg_search_vmaddr':
/tmp/qemu-test/src/windbgstub-utils.c:173:9: error: 'addr' undeclared (first use in this function)
         addr = 0;
         ^
/tmp/qemu-test/src/windbgstub-utils.c:173:9: note: each undeclared identifier is reported only once for each function it appears in
/tmp/qemu-test/src/windbgstub-utils.c:173:17: error: expected '}' before ';' token
         addr = 0;
                 ^
make[1]: *** [windbgstub-utils.o] Error 1


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