[Lldb-commits] [PATCH] D63165: Initial support for native debugging of x86/x64 Windows processes

Hui Huang via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Jun 12 15:02:11 PDT 2019


Hui added a comment.

> In D63165#1539118 <https://reviews.llvm.org/D63165#1539118>, @amccarth wrote:
> 
>> Sorry for the stupid question, but ...
>>
>> What exactly is meant here by "Native"?  How is a NativeProcessWindows different from ProcessWindows?
> 
> 
> The Native*** classes are meant to be used from lldb-server. They look somewhat similar to their non-native counterpart because they still do debugging, but they're a lot dumber, because they only deal with basic process control, and none of the fancy symbolic stuff that you'd need debug info for.

They differ in APIs but most of them have common implementations. The APIs from native process classes are more easy to apply process/thread control.
Hope the native and non-native ones can be merged. The similar thing to the RegisterContext and NativeRegisterContext classes.

The other thing is that using "native" classes can avoid linking a lot of unnecessary lldb libs (LLDB plugins or whatever comes with the plugins) to lldb-server.
The nativeprocesswindows could just be a pass-through to processwindows plugin, but the usage is a sort of strange since the
lldb-server needs to initialize the plugin, create a target, and create a instance just like what lldb does. This means literally
there will be two lldb debuggers, one on host and the other one on remote. It is  doable, but not that applicable.



================
Comment at: source/Plugins/Process/Windows/Common/DebuggerThread.cpp:350
+        (info.ExceptionRecord.ExceptionCode == EXCEPTION_BREAKPOINT ||
+         info.ExceptionRecord.ExceptionCode == 0x4000001FL /* WOW64 STATUS_WX86_BREAKPOINT */)) {
       LLDB_LOG(log, "Breakpoint exception is cue to detach from process {0:x}",
----------------
clayborg wrote:
> Define STATUS_WX86_BREAKPOINT somewhere and don't use a magic number?
The definition is in ntstatus.h which has quite a few macros redefined in winnt.h that is implicitly included in both LLDB. and LLVM.
Could force to include ntstatus.h but need to make a handful of extra patches to replace EXCEPTION_BREAKPOINT macro etc with ntstatus's
in all concerned sources. 





================
Comment at: source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp:529-530
+  ProcessAttachInfo attach_info;
+  attach_info.SetProcessID(pid);
+  attach_info.SetArchitecture(process_info.GetArchitecture());
+
----------------
labath wrote:
> Fetching the architecture this way looks like it could be racy if the pid is recycled before you get a chance to attach to the process (can that happen?). Is there a way to fetch the architecture *after* you perform the attach operation.
This factory attach will return a constructed native process which needs process architecture ahead to construct its native thread with a proper register context. So I think can't do it after the attach operation. At least need to do it before the factory routine returns. Do you mean to put these codes before line 540, i.e. return std::move(process_up)?


Repository:
  rLLDB LLDB

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63165/new/

https://reviews.llvm.org/D63165





More information about the lldb-commits mailing list