[Lldb-commits] [lldb] a659857 - [LLDB] Fix Python GIL-not-held issues

2022-01-17 Thread Pavel Labath via lldb-commits

Author: Ralf Grosse-Kunstleve
Date: 2022-01-17T10:32:19+01:00
New Revision: a6598575f4bc20f9a01c2bced2d0b1ff14d7576f

URL: 
https://github.com/llvm/llvm-project/commit/a6598575f4bc20f9a01c2bced2d0b1ff14d7576f
DIFF: 
https://github.com/llvm/llvm-project/commit/a6598575f4bc20f9a01c2bced2d0b1ff14d7576f.diff

LOG: [LLDB] Fix Python GIL-not-held issues

The GIL must be held when calling any Python C API functions. In multithreaded 
applications that use callbacks this requirement can easily be violated by 
accident. A general tool to ensure GIL health is not available, but patching 
Python Py_INCREF to add an assert provides a basic health check:

```
+int PyGILState_Check(void); /* Include/internal/pystate.h */
+
 #define Py_INCREF(op) ( \
+assert(PyGILState_Check()), \
 _Py_INC_REFTOTAL  _Py_REF_DEBUG_COMMA   \
 ((PyObject *)(op))->ob_refcnt++)

 #define Py_DECREF(op)   \
 do {\
+assert(PyGILState_Check()); \
 PyObject *_py_decref_tmp = (PyObject *)(op);\
 if (_Py_DEC_REFTOTAL  _Py_REF_DEBUG_COMMA   \
 --(_py_decref_tmp)->ob_refcnt != 0) \
```

Adding this assertion causes around 50 test failures in LLDB. Adjusting the 
scope of things guarded by `py_lock` fixes them.

More background: 
https://docs.python.org/3/glossary.html#term-global-interpreter-lock

Patch by Ralf Grosse-Kunstleve

Differential Revision: https://reviews.llvm.org/D114722

Added: 


Modified: 
lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp 
b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
index 7c71c9329e579..d68af672ae83e 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
@@ -257,6 +257,7 @@ PythonObject 
PythonObject::GetAttributeValue(llvm::StringRef attr) const {
 }
 
 StructuredData::ObjectSP PythonObject::CreateStructuredObject() const {
+  assert(PyGILState_Check());
   switch (GetObjectType()) {
   case PyObjectType::Dictionary:
 return PythonDictionary(PyRefType::Borrowed, m_py_obj)

diff  --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h 
b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
index 56bc55d239d12..9d2cdca45a633 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
@@ -88,12 +88,21 @@ class StructuredPythonObject : public 
StructuredData::Generic {
   StructuredPythonObject() : StructuredData::Generic() {}
 
   StructuredPythonObject(void *obj) : StructuredData::Generic(obj) {
+assert(PyGILState_Check());
 Py_XINCREF(GetValue());
   }
 
   ~StructuredPythonObject() override {
-if (Py_IsInitialized())
-  Py_XDECREF(GetValue());
+if (Py_IsInitialized()) {
+  if (_Py_IsFinalizing()) {
+// Leak GetValue() rather than crashing the process.
+// https://docs.python.org/3/c-api/init.html#c.PyGILState_Ensure
+  } else {
+PyGILState_STATE state = PyGILState_Ensure();
+Py_XDECREF(GetValue());
+PyGILState_Release(state);
+  }
+}
 SetValue(nullptr);
   }
 
@@ -264,8 +273,16 @@ class PythonObject {
   ~PythonObject() { Reset(); }
 
   void Reset() {
-if (m_py_obj && Py_IsInitialized())
-  Py_DECREF(m_py_obj);
+if (m_py_obj && Py_IsInitialized()) {
+  if (_Py_IsFinalizing()) {
+// Leak m_py_obj rather than crashing the process.
+// https://docs.python.org/3/c-api/init.html#c.PyGILState_Ensure
+  } else {
+PyGILState_STATE state = PyGILState_Ensure();
+Py_DECREF(m_py_obj);
+PyGILState_Release(state);
+  }
+}
 m_py_obj = nullptr;
   }
 

diff  --git 
a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp 
b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
index ed4ad279f5281..96725afd279ed 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -1438,14 +1438,9 @@ ScriptInterpreterPythonImpl::CreateFrameRecognizer(const 
char *class_name) {
   if (class_name == nullptr || class_name[0] == '\0')
 return StructuredData::GenericSP();
 
-  void *ret_val;
-
-  {
-Locker py_lock(this, Locker::AcquireLock | Locker::NoSTDIN,
-   Locker::FreeLock);
-ret_val = LLDBSWIGPython_CreateFrameRecognizer(class_n

[Lldb-commits] [PATCH] D114722: [LLDB] Fix Python GIL-not-held issues

2022-01-17 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa6598575f4bc: [LLDB] Fix Python GIL-not-held issues 
(authored by rwgk, committed by labath).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114722

Files:
  lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp

Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -1438,14 +1438,9 @@
   if (class_name == nullptr || class_name[0] == '\0')
 return StructuredData::GenericSP();
 
-  void *ret_val;
-
-  {
-Locker py_lock(this, Locker::AcquireLock | Locker::NoSTDIN,
-   Locker::FreeLock);
-ret_val = LLDBSWIGPython_CreateFrameRecognizer(class_name,
-   m_dictionary_name.c_str());
-  }
+  Locker py_lock(this, Locker::AcquireLock | Locker::NoSTDIN, Locker::FreeLock);
+  void *ret_val = LLDBSWIGPython_CreateFrameRecognizer(
+  class_name, m_dictionary_name.c_str());
 
   return StructuredData::GenericSP(new StructuredPythonObject(ret_val));
 }
@@ -1502,14 +1497,9 @@
   if (!process_sp)
 return StructuredData::GenericSP();
 
-  void *ret_val;
-
-  {
-Locker py_lock(this, Locker::AcquireLock | Locker::NoSTDIN,
-   Locker::FreeLock);
-ret_val = LLDBSWIGPythonCreateOSPlugin(
-class_name, m_dictionary_name.c_str(), process_sp);
-  }
+  Locker py_lock(this, Locker::AcquireLock | Locker::NoSTDIN, Locker::FreeLock);
+  void *ret_val = LLDBSWIGPythonCreateOSPlugin(
+  class_name, m_dictionary_name.c_str(), process_sp);
 
   return StructuredData::GenericSP(new StructuredPythonObject(ret_val));
 }
@@ -1757,17 +1747,13 @@
   if (!python_interpreter)
 return {};
 
-  void *ret_val;
-
-  {
-Locker py_lock(this,
-   Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
-ret_val = LLDBSwigPythonCreateScriptedThreadPlan(
-class_name, python_interpreter->m_dictionary_name.c_str(),
-args_data, error_str, thread_plan_sp);
-if (!ret_val)
-  return {};
-  }
+  Locker py_lock(this,
+ Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
+  void *ret_val = LLDBSwigPythonCreateScriptedThreadPlan(
+  class_name, python_interpreter->m_dictionary_name.c_str(), args_data,
+  error_str, thread_plan_sp);
+  if (!ret_val)
+return {};
 
   return StructuredData::ObjectSP(new StructuredPythonObject(ret_val));
 }
@@ -1860,16 +1846,12 @@
   if (!python_interpreter)
 return StructuredData::GenericSP();
 
-  void *ret_val;
-
-  {
-Locker py_lock(this,
-   Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
+  Locker py_lock(this,
+ Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
 
-ret_val = LLDBSwigPythonCreateScriptedBreakpointResolver(
-class_name, python_interpreter->m_dictionary_name.c_str(), args_data,
-bkpt_sp);
-  }
+  void *ret_val = LLDBSwigPythonCreateScriptedBreakpointResolver(
+  class_name, python_interpreter->m_dictionary_name.c_str(), args_data,
+  bkpt_sp);
 
   return StructuredData::GenericSP(new StructuredPythonObject(ret_val));
 }
@@ -1935,16 +1917,12 @@
 return StructuredData::GenericSP();
   }
 
-  void *ret_val;
-
-  {
-Locker py_lock(this,
-   Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
+  Locker py_lock(this,
+ Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
 
-ret_val = LLDBSwigPythonCreateScriptedStopHook(
-target_sp, class_name, python_interpreter->m_dictionary_name.c_str(),
-args_data, error);
-  }
+  void *ret_val = LLDBSwigPythonCreateScriptedStopHook(
+  target_sp, class_name, python_interpreter->m_dictionary_name.c_str(),
+  args_data, error);
 
   return StructuredData::GenericSP(new StructuredPythonObject(ret_val));
 }
@@ -2035,14 +2013,10 @@
   if (!python_interpreter)
 return StructuredData::ObjectSP();
 
-  void *ret_val = nullptr;
-
-  {
-Locker py_lock(this,
-   Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
-ret_val = LLDBSwigPythonCreateSyntheticProvider(
-class_name, python_interpreter->m_dictionary_name.c_str(), valobj);
-  }
+  Locker py_lock(this,
+ Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
+  void *ret_val = LLDBSwigPythonCreateSyntheticProvider(
+  class_name, python_interpreter->m_dictionary_name.c_str(), valobj);
 
   return StructuredDa

[Lldb-commits] [PATCH] D117462: [lldb/python] Use PythonObject in LLDBSwigPython functions

2022-01-17 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added reviewers: JDevlieghere, mib.
labath requested review of this revision.
Herald added a project: LLDB.

Return our PythonObject wrappers instead of raw PyObjects (obfuscated as
void *). This ensures that ownership (reference counts) of python
objects is automatically tracked.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D117462

Files:
  lldb/bindings/python/python-wrapper.swig
  lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
  lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp
  lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp

Index: lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
===
--- lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
+++ lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
@@ -80,23 +80,23 @@
   return false;
 }
 
-void *lldb_private::LLDBSwigPythonCreateSyntheticProvider(
+python::PythonObject lldb_private::LLDBSwigPythonCreateSyntheticProvider(
 const char *python_class_name, const char *session_dictionary_name,
 const lldb::ValueObjectSP &valobj_sp) {
-  return nullptr;
+  return python::PythonObject();
 }
 
-void *lldb_private::LLDBSwigPythonCreateCommandObject(
+python::PythonObject lldb_private::LLDBSwigPythonCreateCommandObject(
 const char *python_class_name, const char *session_dictionary_name,
 lldb::DebuggerSP debugger_sp) {
-  return nullptr;
+  return python::PythonObject();
 }
 
-void *lldb_private::LLDBSwigPythonCreateScriptedThreadPlan(
+python::PythonObject lldb_private::LLDBSwigPythonCreateScriptedThreadPlan(
 const char *python_class_name, const char *session_dictionary_name,
 const StructuredDataImpl &args_data, std::string &error_string,
 const lldb::ThreadPlanSP &thread_plan_sp) {
-  return nullptr;
+  return python::PythonObject();
 }
 
 bool lldb_private::LLDBSWIGPythonCallThreadPlan(void *implementor,
@@ -106,10 +106,11 @@
   return false;
 }
 
-void *lldb_private::LLDBSwigPythonCreateScriptedBreakpointResolver(
+python::PythonObject
+lldb_private::LLDBSwigPythonCreateScriptedBreakpointResolver(
 const char *python_class_name, const char *session_dictionary_name,
 const StructuredDataImpl &args, const lldb::BreakpointSP &bkpt_sp) {
-  return nullptr;
+  return python::PythonObject();
 }
 
 unsigned int lldb_private::LLDBSwigPythonCallBreakpointResolver(
@@ -191,30 +192,30 @@
   return false;
 }
 
-void *
+python::PythonObject
 lldb_private::LLDBSWIGPythonCreateOSPlugin(const char *python_class_name,
const char *session_dictionary_name,
const lldb::ProcessSP &process_sp) {
-  return nullptr;
+  return python::PythonObject();
 }
 
-void *lldb_private::LLDBSwigPythonCreateScriptedProcess(
+python::PythonObject lldb_private::LLDBSwigPythonCreateScriptedProcess(
 const char *python_class_name, const char *session_dictionary_name,
 const lldb::TargetSP &target_sp, const StructuredDataImpl &args_impl,
 std::string &error_string) {
-  return nullptr;
+  return python::PythonObject();
 }
 
-void *lldb_private::LLDBSwigPythonCreateScriptedThread(
+python::PythonObject lldb_private::LLDBSwigPythonCreateScriptedThread(
 const char *python_class_name, const char *session_dictionary_name,
 const lldb::ProcessSP &process_sp, const StructuredDataImpl &args_impl,
 std::string &error_string) {
-  return nullptr;
+  return python::PythonObject();
 }
 
-void *lldb_private::LLDBSWIGPython_CreateFrameRecognizer(
+python::PythonObject lldb_private::LLDBSWIGPython_CreateFrameRecognizer(
 const char *python_class_name, const char *session_dictionary_name) {
-  return nullptr;
+  return python::PythonObject();
 }
 
 PyObject *lldb_private::LLDBSwigPython_GetRecognizedArguments(
@@ -257,11 +258,11 @@
   return nullptr;
 }
 
-void *lldb_private::LLDBSwigPythonCreateScriptedStopHook(
+python::PythonObject lldb_private::LLDBSwigPythonCreateScriptedStopHook(
 lldb::TargetSP target_sp, const char *python_class_name,
 const char *session_dictionary_name, const StructuredDataImpl &args_impl,
 Status &error) {
-  return nullptr;
+  return python::PythonObject();
 }
 
 bool lldb_private::LLDBSwigPythonStopHookCallHandleStop(
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cp

[Lldb-commits] [PATCH] D117462: [lldb/python] Use PythonObject in LLDBSwigPython functions

2022-01-17 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: 
lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp:284
+return StructuredData::ObjectSP(new StructuredPythonObject(
+PythonObject(PyRefType::Borrowed, m_py_obj)));
   }

fixed a leak here



Comment at: 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp:1442
   Locker py_lock(this, Locker::AcquireLock | Locker::NoSTDIN, 
Locker::FreeLock);
-  void *ret_val = LLDBSWIGPython_CreateFrameRecognizer(
+  PythonObject ret_val = LLDBSWIGPython_CreateFrameRecognizer(
   class_name, m_dictionary_name.c_str());

all of these were leaked



Comment at: 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp:2159
Locker::AcquireLock | Locker::InitSession | 
Locker::NoSTDIN);
-callee_wrapper_sp = std::make_shared(new_callee);
+callee_wrapper_sp = std::make_shared(
+PythonObject(PyRefType::Borrowed, static_cast(new_callee)));

I didn't convert this one now because `LLDBSwigPythonCallTypeScript` is doing 
something weird (and most likely incorrect) with reference counts.



Comment at: 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp:2808
 void *module_pyobj = nullptr;
 if (ExecuteOneLineWithReturn(
 command_stream.GetData(),

Refactoring ExecuteOneLineWithReturn into something type-safe would be a bigger 
undertaking than all of the changes in this patch put together.



Comment at: 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp:54
   m_object_instance_sp =
-  StructuredData::GenericSP(new StructuredPythonObject(ret_val));
+  StructuredData::GenericSP(new 
StructuredPythonObject(std::move(ret_val)));
 

btw, all of the `std::move`s are just performance optimizations. They don't 
impact correctness.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117462

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D117071: [lldb/Plugins] Add support of multiple ScriptedThreads in a ScriptedProcess

2022-01-17 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Unifying the two paths by making turning the other reference into an owned one 
is a step in the right direction, but it is not enough, as 
StructuredPythonObject expects a *borrowed* reference. So, instead of fixing 
things, you've made both code paths leak. :)

I've created D117462 , which should make 
reasoning about ownership much easier. StructuredPythonObject and all of the 
LLDBSwigPython functions now tracks ownership automatically, and one only needs 
to be careful when converting to/from a void *. Ideally those would be removed 
too, but that would require a bigger refactor. If you rebase this patch on top 
of that, you should be able to transfer ownership correctly.

While working on the patch I also realized that pretty much all of our 
StructuredPythonObject interfaces were leaking. So, in a way, you were very 
unfortunate to hit a use after free here (like, it it must have taken multiple 
decrefs on borrowed references (one for each thread, I guess) to undo all of 
those leaks). OTOH, we were also fortunate that you've found this, as we can 
now improve the interfaces and fix those leaks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117071

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D117076: [lldb/Plugins] Fix ScriptedThread IndexID reporting

2022-01-17 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

That is a step in the right direction, but ideally we shouldn't by introducing 
new functions with double return values (value in the "real" result + error 
through a by-ref argument, or vice versa). We have llvm::Expected for that, and 
(thread id issue aside) this is actually one of the biggest reasons for using 
the fallible constructor idiom 
 (real 
constructors can't return Expecteds, but static factories can).

In that light, I am very saddened by the existence of the `ErrorWithMessage` 
function as it encourages one to use the incorrect/old/etc. paradigm. Like, I 
get that it makes it handy to work with the functions which still use the old 
interface, but if you really want to have it, then I'd suggest to also create 
one which interoperates nicely with Expected-returning functions, so that 
you're not tempted to create new functions with by-ref error results.

Personally, I'd say this wrapper is unnecessary for the new functions, as one 
of the nice (opinions can vary) things about the llvm error types is that they 
force you to do something with those errors. Usually, when we don't have 
anything better to do with these errors we at least log them. So, I'd probably 
skip logging the errors upon creating, and log them in the caller (as it will 
have to handle them somehow anyway).




Comment at: lldb/source/Plugins/Process/scripted/ScriptedThread.cpp:80
+   ScriptedThreadInterfaceSP interface_sp,
+   Status &error, lldb::tid_t tid,
+   StructuredData::GenericSP script_object_sp)

this is not needed now


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117076

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D117474: [lldb] Make StatsDuration thread-safe

2022-01-17 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added a reviewer: clayborg.
Herald added a subscriber: arphaman.
labath requested review of this revision.
Herald added a project: LLDB.

std::chrono::duration types are not thread-safe, and they cannot be
concurrently updated from multiple threads. Currently, we were doing
such a thing (only) in the DWARF indexing code
(DWARFUnit::ExtractDIEsRWLocked), but I think it can easily happen that
someone else tries to update another statistic like this without
bothering to check for thread safety.

This patch changes the StatsDuration type from a simple typedef into a
class in its own right. The class stores the duration internally as
std::atomic (so it can be updated atomically), but presents it
to its users as the usual chrono type (duration).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D117474

Files:
  lldb/include/lldb/Breakpoint/Breakpoint.h
  lldb/include/lldb/Core/Module.h
  lldb/include/lldb/Symbol/SymbolFile.h
  lldb/include/lldb/Target/Statistics.h
  lldb/source/Breakpoint/Breakpoint.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
  lldb/source/Target/Statistics.cpp

Index: lldb/source/Target/Statistics.cpp
===
--- lldb/source/Target/Statistics.cpp
+++ lldb/source/Target/Statistics.cpp
@@ -34,7 +34,8 @@
 }
 
 static double elapsed(const StatsTimepoint &start, const StatsTimepoint &end) {
-  StatsDuration elapsed = end.time_since_epoch() - start.time_since_epoch();
+  StatsDuration::Duration elapsed =
+  end.time_since_epoch() - start.time_since_epoch();
   return elapsed.count();
 }
 
@@ -86,7 +87,8 @@
 elapsed(*m_launch_or_attach_time, *m_first_public_stop_time);
 target_metrics_json.try_emplace("firstStopTime", elapsed_time);
   }
-  target_metrics_json.try_emplace("targetCreateTime", m_create_time.count());
+  target_metrics_json.try_emplace("targetCreateTime",
+  m_create_time.get().count());
 
   json::Array breakpoints_array;
   double totalBreakpointResolveTime = 0.0;
@@ -177,8 +179,8 @@
 }
 module_stat.uuid = module->GetUUID().GetAsString();
 module_stat.triple = module->GetArchitecture().GetTriple().str();
-module_stat.symtab_parse_time = module->GetSymtabParseTime().count();
-module_stat.symtab_index_time = module->GetSymtabIndexTime().count();
+module_stat.symtab_parse_time = module->GetSymtabParseTime().get().count();
+module_stat.symtab_index_time = module->GetSymtabIndexTime().get().count();
 Symtab *symtab = module->GetSymtab();
 if (symtab) {
   module_stat.symtab_loaded_from_cache = symtab->GetWasLoadedFromCache();
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
@@ -143,8 +143,8 @@
   llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
 
   uint64_t GetDebugInfoSize() override;
-  lldb_private::StatsDuration GetDebugInfoParseTime() override;
-  lldb_private::StatsDuration GetDebugInfoIndexTime() override;
+  lldb_private::StatsDuration::Duration GetDebugInfoParseTime() override;
+  lldb_private::StatsDuration::Duration GetDebugInfoIndexTime() override;
 
 protected:
   enum { kHaveInitializedOSOs = (1 << 0), kNumFlags };
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -1447,8 +1447,8 @@
   return debug_info_size;
 }
 
-StatsDuration SymbolFileDWARFDebugMap::GetDebugInfoParseTime() {
-  StatsDuration elapsed(0.0);
+StatsDuration::Duration SymbolFileDWARFDebugMap::GetDebugInfoParseTime() {
+  StatsDuration::Duration elapsed(0.0);
   ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
 ObjectFile *oso_objfile = oso_dwarf->GetObjectFile();
 if (oso_objfile) {
@@ -1464,8 +1464,8 @@
   return elapsed;
 }
 
-StatsDuration SymbolFileDWARFDebugMap::GetDebugInfoIndexTime() {
-  StatsDuration elapsed(0.0);
+StatsDuration::Duration SymbolFileDWARFDebugMap::GetDebugInfoIndexTime() {
+  StatsDuration::Duration elapsed(0.0);
   ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
 ObjectFile *oso_objfile = oso_dwarf->GetObjectFile();
 if (oso_objfile) {
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+

[Lldb-commits] [PATCH] D117490: [lldb] Log prototype

2022-01-17 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D117490

Files:
  lldb/include/lldb/Interpreter/ScriptedInterface.h
  lldb/include/lldb/Utility/Log.h
  lldb/include/lldb/Utility/Logging.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h
  lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
  lldb/source/Utility/Logging.cpp
  lldb/tools/lldb-server/lldb-gdbserver.cpp

Index: lldb/tools/lldb-server/lldb-gdbserver.cpp
===
--- lldb/tools/lldb-server/lldb-gdbserver.cpp
+++ lldb/tools/lldb-server/lldb-gdbserver.cpp
@@ -27,6 +27,7 @@
 #include "lldb/Host/Socket.h"
 #include "lldb/Host/common/NativeProcessProtocol.h"
 #include "lldb/Target/Process.h"
+#include "lldb/Utility/Logging.h"
 #include "lldb/Utility/Status.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Option/ArgList.h"
Index: lldb/source/Utility/Logging.cpp
===
--- lldb/source/Utility/Logging.cpp
+++ lldb/source/Utility/Logging.cpp
@@ -16,49 +16,98 @@
 using namespace lldb_private;
 
 static constexpr Log::Category g_categories[] = {
-  {{"api"}, {"log API calls and return values"}, LIBLLDB_LOG_API},
-  {{"ast"}, {"log AST"}, LIBLLDB_LOG_AST},
-  {{"break"}, {"log breakpoints"}, LIBLLDB_LOG_BREAKPOINTS},
-  {{"commands"}, {"log command argument parsing"}, LIBLLDB_LOG_COMMANDS},
-  {{"comm"}, {"log communication activities"}, LIBLLDB_LOG_COMMUNICATION},
-  {{"conn"}, {"log connection details"}, LIBLLDB_LOG_CONNECTION},
-  {{"demangle"}, {"log mangled names to catch demangler crashes"}, LIBLLDB_LOG_DEMANGLE},
-  {{"dyld"}, {"log shared library related activities"}, LIBLLDB_LOG_DYNAMIC_LOADER},
-  {{"event"}, {"log broadcaster, listener and event queue activities"}, LIBLLDB_LOG_EVENTS},
-  {{"expr"}, {"log expressions"}, LIBLLDB_LOG_EXPRESSIONS},
-  {{"formatters"}, {"log data formatters related activities"}, LIBLLDB_LOG_DATAFORMATTERS},
-  {{"host"}, {"log host activities"}, LIBLLDB_LOG_HOST},
-  {{"jit"}, {"log JIT events in the target"}, LIBLLDB_LOG_JIT_LOADER},
-  {{"language"}, {"log language runtime events"}, LIBLLDB_LOG_LANGUAGE},
-  {{"mmap"}, {"log mmap related activities"}, LIBLLDB_LOG_MMAP},
-  {{"module"}, {"log module activities such as when modules are created, destroyed, replaced, and more"}, LIBLLDB_LOG_MODULES},
-  {{"object"}, {"log object construction/destruction for important objects"}, LIBLLDB_LOG_OBJECT},
-  {{"os"}, {"log OperatingSystem plugin related activities"}, LIBLLDB_LOG_OS},
-  {{"platform"}, {"log platform events and activities"}, LIBLLDB_LOG_PLATFORM},
-  {{"process"}, {"log process events and activities"}, LIBLLDB_LOG_PROCESS},
-  {{"script"}, {"log events about the script interpreter"}, LIBLLDB_LOG_SCRIPT},
-  {{"state"}, {"log private and public process state changes"}, LIBLLDB_LOG_STATE},
-  {{"step"}, {"log step related activities"}, LIBLLDB_LOG_STEP},
-  {{"symbol"}, {"log symbol related issues and warnings"}, LIBLLDB_LOG_SYMBOLS},
-  {{"system-runtime"}, {"log system runtime events"}, LIBLLDB_LOG_SYSTEM_RUNTIME},
-  {{"target"}, {"log target events and activities"}, LIBLLDB_LOG_TARGET},
-  {{"temp"}, {"log internal temporary debug messages"}, LIBLLDB_LOG_TEMPORARY},
-  {{"thread"}, {"log thread events and activities"}, LIBLLDB_LOG_THREAD},
-  {{"types"}, {"log type system related activities"}, LIBLLDB_LOG_TYPES},
-  {{"unwind"}, {"log stack unwind activities"}, LIBLLDB_LOG_UNWIND},
-  {{"watch"}, {"log watchpoint related activities"}, LIBLLDB_LOG_WATCHPOINTS},
+{{"api"}, {"log API calls and return values"}, uint32_t(LIBLLDB_LOG_API)},
+{{"ast"}, {"log AST"}, uint32_t(LIBLLDB_LOG_AST)},
+{{"break"}, {"log breakpoints"}, uint32_t(LIBLLDB_LOG_BREAKPOINTS)},
+{{"commands"},
+ {"log command argument parsing"},
+ uint32_t(LIBLLDB_LOG_COMMANDS)},
+{{"comm"},
+ {"log communication activities"},
+ uint32_t(LIBLLDB_LOG_COMMUNICATION)},
+{{"conn"}, {"log connection details"}, uint32_t(LIBLLDB_LOG_CONNECTION)},
+{{"demangle"},
+ {"log mangled names to catch demangler crashes"},
+ uint32_t(LIBLLDB_LOG_DEMANGLE)},
+{{"dyld"},
+ {"log shared library related activities"},
+ uint32_t(LIBLLDB_LOG_DYNAMIC_LOADER)},
+{{"event"},
+ {"log broadcaster, listener and event queue activities"},
+ uint32_t(LIBLLDB_LOG_EVENTS)},
+{{"expr"}, {"log expressions"}, uint32_t(LIBLLDB_LOG_EXPRESSIONS)},
+{{"formatters"},
+ {"log data formatters related activities"},
+ uint32_t(LIBLLDB_LOG_DATAFORMATTERS)},
+{{"host"}, {"log host activities"}, uint32_

[Lldb-commits] [PATCH] D116896: [lldb] [gdb-remote] Support client fallback for servers without reg defs

2022-01-17 Thread Michał Górny via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe69a3d18f48b: [lldb] [gdb-remote] Support client fallback 
for servers without reg defs (authored by mgorny).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116896

Files:
  lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterFallback.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterFallback.h
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXML.py

Index: lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXML.py
===
--- /dev/null
+++ lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXML.py
@@ -0,0 +1,346 @@
+from __future__ import print_function
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+from lldbsuite.test.gdbclientutils import *
+from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase
+
+import binascii
+
+
+class TestGDBServerTargetXML(GDBRemoteTestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@staticmethod
+def filecheck_to_blob(fc):
+for l in fc.strip().splitlines():
+val = l.split('0x')[1]
+yield binascii.b2a_hex(bytes(reversed(binascii.a2b_hex(val.decode()
+
+@skipIfRemote
+@skipIfLLVMTargetMissing("X86")
+def test_x86_64_regs(self):
+"""Test grabbing various x86_64 registers from gdbserver."""
+
+GPRS = '''
+CHECK-AMD64-DAG: rax = 0x0807060504030201
+CHECK-AMD64-DAG: rbx = 0x1817161514131211
+CHECK-AMD64-DAG: rcx = 0x2827262524232221
+CHECK-AMD64-DAG: rdx = 0x3837363534333231
+CHECK-AMD64-DAG: rsi = 0x4847464544434241
+CHECK-AMD64-DAG: rdi = 0x5857565554535251
+CHECK-AMD64-DAG: rbp = 0x6867666564636261
+CHECK-AMD64-DAG: rsp = 0x7877767574737271
+CHECK-AMD64-DAG: r8 = 0x8887868584838281
+CHECK-AMD64-DAG: r9 = 0x9897969594939291
+CHECK-AMD64-DAG: r10 = 0xa8a7a6a5a4a3a2a1
+CHECK-AMD64-DAG: r11 = 0xb8b7b6b5b4b3b2b1
+CHECK-AMD64-DAG: r12 = 0xc8c7c6c5c4c3c2c1
+CHECK-AMD64-DAG: r13 = 0xd8d7d6d5d4d3d2d1
+CHECK-AMD64-DAG: r14 = 0xe8e7e6e5e4e3e2e1
+CHECK-AMD64-DAG: r15 = 0xf8f7f6f5f4f3f2f1
+CHECK-AMD64-DAG: rip = 0x100f0e0d0c0b0a09
+CHECK-AMD64-DAG: eflags = 0x1c1b1a19
+CHECK-AMD64-DAG: cs = 0x2c2b2a29
+CHECK-AMD64-DAG: ss = 0x3c3b3a39
+'''
+
+SUPPL = '''
+CHECK-AMD64-DAG: eax = 0x04030201
+CHECK-AMD64-DAG: ebx = 0x14131211
+CHECK-AMD64-DAG: ecx = 0x24232221
+CHECK-AMD64-DAG: edx = 0x34333231
+CHECK-AMD64-DAG: esi = 0x44434241
+CHECK-AMD64-DAG: edi = 0x54535251
+CHECK-AMD64-DAG: ebp = 0x64636261
+CHECK-AMD64-DAG: esp = 0x74737271
+CHECK-AMD64-DAG: r8d = 0x84838281
+CHECK-AMD64-DAG: r9d = 0x94939291
+CHECK-AMD64-DAG: r10d = 0xa4a3a2a1
+CHECK-AMD64-DAG: r11d = 0xb4b3b2b1
+CHECK-AMD64-DAG: r12d = 0xc4c3c2c1
+CHECK-AMD64-DAG: r13d = 0xd4d3d2d1
+CHECK-AMD64-DAG: r14d = 0xe4e3e2e1
+CHECK-AMD64-DAG: r15d = 0xf4f3f2f1
+
+CHECK-AMD64-DAG: ax = 0x0201
+CHECK-AMD64-DAG: bx = 0x1211
+CHECK-AMD64-DAG: cx = 0x2221
+CHECK-AMD64-DAG: dx = 0x3231
+CHECK-AMD64-DAG: si = 0x4241
+CHECK-AMD64-DAG: di = 0x5251
+CHECK-AMD64-DAG: bp = 0x6261
+CHECK-AMD64-DAG: sp = 0x7271
+CHECK-AMD64-DAG: r8w = 0x8281
+CHECK-AMD64-DAG: r9w = 0x9291
+CHECK-AMD64-DAG: r10w = 0xa2a1
+CHECK-AMD64-DAG: r11w = 0xb2b1
+CHECK-AMD64-DAG: r12w = 0xc2c1
+CHECK-AMD64-DAG: r13w = 0xd2d1
+CHECK-AMD64-DAG: r14w = 0xe2e1
+CHECK-AMD64-DAG: r15w = 0xf2f1
+
+CHECK-AMD64-DAG: ah = 0x02
+CHECK-AMD64-DAG: bh = 0x12
+CHECK-AMD64-DAG: ch = 0x22
+CHECK-AMD64-DAG: dh = 0x32
+
+CHECK-AMD64-DAG: al = 0x01
+CHECK-AMD64-DAG: bl = 0x11
+CHECK-AMD64-DAG: cl = 0x21
+CHECK-AMD64-DAG: dl = 0x31
+CHECK-AMD64-DAG: sil = 0x41
+CHECK-AMD64-DAG: dil = 0x51
+CHECK-AMD64-DAG: bpl = 0x61
+CHECK-AMD64-DAG: spl = 0x71
+CHECK-AMD64-DAG: r8l = 0x81
+CHECK-AMD64-DAG: r9l = 0x91
+CHECK-AMD64-DAG: r10l = 0xa1
+CHECK-AMD64-DAG: r11l = 0xb1
+CHECK-AMD64-DAG: r12l = 0xc1
+CHECK-AMD64-DAG: r13l = 0xd1
+CHECK-AMD64-DAG: r14l = 0xe1
+CHECK-AMD64-DAG: r15l = 0xf1
+'''
+
+class MyResponder(MockGDBServerResponder):
+reg_data = ''.join(self.filecheck_to_blob(GPRS))
+
+def readRegister(self, regnum):
+return ""
+
+def readRegisters(self):
+return self.reg_data
+
+def haltReason(self):
+return "T02thread:1ff0d;threads:1ff0d;thread-pcs:00010001bc00;07:0102030405060708;10:1112131415161718;"
+
+self.server.responder = MyResponder()
+
+target = self.createTarget("basic_eh_frame.yaml")
+process = self.connect(target)
+lldbutil.expect_state_changes(self, self.dbg.GetListener(), process,
+  [lldb.eStateStopped])
+
+# test all registe

[Lldb-commits] [lldb] e69a3d1 - [lldb] [gdb-remote] Support client fallback for servers without reg defs

2022-01-17 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2022-01-17T22:31:49+01:00
New Revision: e69a3d18f48bc0d81b5dd12e735a2ec898ce64d4

URL: 
https://github.com/llvm/llvm-project/commit/e69a3d18f48bc0d81b5dd12e735a2ec898ce64d4
DIFF: 
https://github.com/llvm/llvm-project/commit/e69a3d18f48bc0d81b5dd12e735a2ec898ce64d4.diff

LOG: [lldb] [gdb-remote] Support client fallback for servers without reg defs

Provide minimal register definition defaults for working with servers
that implement neither target.xml nor qRegisterInfo packets.  This is
useful e.g. when interacting with FreeBSD's kernel minimal gdbserver
that does not send target.xml but uses the same layout for its supported
register subset as GDB.

The prerequisite for this is the ability to determine the correct
architecture, e.g. from the target executable.

Differential Revision: https://reviews.llvm.org/D116896

Added: 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterFallback.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterFallback.h
lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXML.py

Modified: 
lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt 
b/lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt
index d578033e1c414..3a1a0e435ad25 100644
--- a/lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt
+++ b/lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt
@@ -25,6 +25,7 @@ add_lldb_library(lldbPluginProcessGDBRemote PLUGIN
   GDBRemoteCommunicationServerLLGS.cpp
   GDBRemoteCommunicationServerPlatform.cpp
   GDBRemoteRegisterContext.cpp
+  GDBRemoteRegisterFallback.cpp
   ProcessGDBRemote.cpp
   ProcessGDBRemoteLog.cpp
   ThreadGDBRemote.cpp

diff  --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterFallback.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterFallback.cpp
new file mode 100644
index 0..b391edced695f
--- /dev/null
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterFallback.cpp
@@ -0,0 +1,86 @@
+//===-- GDBRemoteRegisterFallback.cpp 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "GDBRemoteRegisterFallback.h"
+
+namespace lldb_private {
+namespace process_gdb_remote {
+
+#define REG(name, size)
\
+  DynamicRegisterInfo::Register {  
\
+ConstString(#name), empty_alt_name, reg_set, size, LLDB_INVALID_INDEX32,   
\
+lldb::eEncodingUint, lldb::eFormatHex, LLDB_INVALID_REGNUM,
\
+LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, {}, {}  
\
+  }
+#define R64(name) REG(name, 8)
+#define R32(name) REG(name, 4)
+
+static std::vector GetRegisters_aarch64() {
+  ConstString empty_alt_name;
+  ConstString reg_set{"general purpose registers"};
+
+  std::vector registers{
+  R64(x0),  R64(x1),  R64(x2),  R64(x3),  R64(x4),  R64(x5),   R64(x6),
+  R64(x7),  R64(x8),  R64(x9),  R64(x10), R64(x11), R64(x12),  R64(x13),
+  R64(x14), R64(x15), R64(x16), R64(x17), R64(x18), R64(x19),  R64(x20),
+  R64(x21), R64(x22), R64(x23), R64(x24), R64(x25), R64(x26),  R64(x27),
+  R64(x28), R64(x29), R64(x30), R64(sp),  R64(pc),  R32(cpsr),
+  };
+
+  return registers;
+}
+
+static std::vector GetRegisters_x86() {
+  ConstString empty_alt_name;
+  ConstString reg_set{"general purpose registers"};
+
+  std::vector registers{
+  R32(eax), R32(ecx), R32(edx), R32(ebx),R32(esp), R32(ebp),
+  R32(esi), R32(edi), R32(eip), R32(eflags), R32(cs),  R32(ss),
+  R32(ds),  R32(es),  R32(fs),  R32(gs),
+  };
+
+  return registers;
+}
+
+static std::vector GetRegisters_x86_64() {
+  ConstString empty_alt_name;
+  ConstString reg_set{"general purpose registers"};
+
+  std::vector registers{
+  R64(rax), R64(rbx), R64(rcx), R64(rdx), R64(rsi), R64(rdi),
+  R64(rbp), R64(rsp), R64(r8),  R64(r9),  R64(r10), R64(r11),
+  R64(r12), R64(r13), R64(r14), R64(r15), R64(rip), R32(eflags),
+  R32(cs),  R32(ss),  R32(ds),  R32(es),  R32(fs),  R32(gs),
+  };
+
+  return registers;
+}
+
+#undef R32
+#undef R64
+#undef REG
+
+std::vector
+GetFallbackRegisters(const ArchSpec &arch_to_use) {
+  switch (arch_to_use.GetMachine()) {
+  case llvm::Triple::aarch64:
+return GetRegisters_aarch64();
+  case llvm::Triple::x86:
+return GetRegisters_x86();
+  case llvm::Triple::x86_64:
+return GetRegisters_x86_64();
+  default:
+break;
+  }
+
+  return {};
+}
+
+} // namespace process_gd