[Lldb-commits] [PATCH] D68299: [JSON] Use LLVM's library for encoding JSON in GDBRemoteCommunicationServerLLGS

2019-10-04 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

TBE, this happens when lldb is not able to find the python package files (which 
should normally be in `$BUILD/libXY/pythonA.B/site-packages`).


Repository:
  rL LLVM

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

https://reviews.llvm.org/D68299



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


[Lldb-commits] [PATCH] D68299: [JSON] Use LLVM's library for encoding JSON in GDBRemoteCommunicationServerLLGS

2019-10-04 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Yeah, that's definitely python-related, but it's hard to say how exactly 
without knowing more details. Also note that there have been some changes in 
how the python stuff is used/built in the last couple of weeks so it's possible 
this was not caused by a change on your side...


Repository:
  rL LLVM

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

https://reviews.llvm.org/D68299



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


[Lldb-commits] [PATCH] D68299: [JSON] Use LLVM's library for encoding JSON in GDBRemoteCommunicationServerLLGS

2019-10-03 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht added a comment.

In D68299#1692503 , @labath wrote:

> > FYI, we've root caused some internal lldb asan failures to this patch. I 
> > don't have a repro yet (my lldb tests seem to be failing locally for 
> > unrelated reasons)
>
> This should be fixed with r373572.


Thanks!

> BTW, are you sure those reasons were unrelated? If you have had nearly every 
> test failing then it was very likely due to this. (The reason only a couple 
> of tests failed for you in asan mode is because our CI does not run a large 
> chunk of the lldb tests... :/ )

Yes, tests are still failing locally for me, e.g. 
`Driver/TestConvenienceVariables.test` in `ninja check-lldb-driver` fails:

  Command Output (stderr):
  --
  Traceback (most recent call last):
File "", line 1, in 
  ImportError: No module named lldb.embedded_interpreter
  Traceback (most recent call last):
File "", line 1, in 
  NameError: name 'run_one_line' is not defined
  Traceback (most recent call last):
File "", line 1, in 
  NameError: name 'run_one_line' is not defined
  Traceback (most recent call last):
File "", line 1, in 
  NameError: name 'run_one_line' is not defined
  Traceback (most recent call last):
File "", line 1, in 
  NameError: name 'run_one_line' is not defined
  Traceback (most recent call last):
File "", line 1, in 
  NameError: name 'run_one_line' is not defined
  Traceback (most recent call last):
File "", line 1, in 
  NameError: name 'run_one_line' is not defined
  error: python failed attempting to evaluate 'print(lldb.debugger)'

I think it's a python-related misconfiguration somewhere about not finding the 
lldb module, but I'm not sure when it started -- these tests used to pass, but 
I nuked my cmake tree and apparently didn't reconfigure it correctly.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D68299



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


[Lldb-commits] [PATCH] D68299: [JSON] Use LLVM's library for encoding JSON in GDBRemoteCommunicationServerLLGS

2019-10-03 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

> FYI, we've root caused some internal lldb asan failures to this patch. I 
> don't have a repro yet (my lldb tests seem to be failing locally for 
> unrelated reasons)

This should be fixed with r373572.

BTW, are you sure those reasons were unrelated? If you have had nearly every 
test failing then it was very likely due to this. (The reason only a couple of 
tests failed for you in asan mode is because our CI does not run a large chunk 
of the lldb tests... :/ )


Repository:
  rL LLVM

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

https://reviews.llvm.org/D68299



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


[Lldb-commits] [PATCH] D68299: [JSON] Use LLVM's library for encoding JSON in GDBRemoteCommunicationServerLLGS

2019-10-02 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht added a comment.

FYI, we've root caused some internal lldb asan failures to this patch. I don't 
have a repro yet (my lldb tests seem to be failing locally for unrelated 
reasons), but e.g. `Register/x86-64-read.test` is failing to read all the 
non-general purpose registers:

  (lldb) register read --all
  General Purpose Registers:
 rax = 0x7fffd660
 ... etc. ...
  
  Floating Point Registers:
  42 registers were unavailable.
  
  Advanced Vector Extensions:
  16 registers were unavailable.
  
  Memory Protection Extensions:
  6 registers were unavailable.
  
  (lldb) process continue
  error: Failed to resume process: Resume timed out..

These tests are passing in all other modes, including other sanitizer modes


Repository:
  rL LLVM

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

https://reviews.llvm.org/D68299



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


[Lldb-commits] [PATCH] D68299: [JSON] Use LLVM's library for encoding JSON in GDBRemoteCommunicationServerLLGS

2019-10-02 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL373497: [JSON] Use LLVMs library for encoding JSON in 
GDBRemoteCommunicationServerLLGS (authored by JDevlieghere, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D68299?vs=222706=222876#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D68299

Files:
  
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp

Index: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
===
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -32,7 +32,6 @@
 #include "lldb/Utility/Args.h"
 #include "lldb/Utility/DataBuffer.h"
 #include "lldb/Utility/Endian.h"
-#include "lldb/Utility/JSON.h"
 #include "lldb/Utility/LLDBAssert.h"
 #include "lldb/Utility/Log.h"
 #include "lldb/Utility/RegisterValue.h"
@@ -40,6 +39,7 @@
 #include "lldb/Utility/StreamString.h"
 #include "lldb/Utility/UriParser.h"
 #include "llvm/ADT/Triple.h"
+#include "llvm/Support/JSON.h"
 #include "llvm/Support/ScopedPrinter.h"
 
 #include "ProcessGDBRemote.h"
@@ -402,19 +402,21 @@
   }
 }
 
-static JSONObject::SP GetRegistersAsJSON(NativeThreadProtocol ) {
+static llvm::Expected
+GetRegistersAsJSON(NativeThreadProtocol ) {
   Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_THREAD));
 
   NativeRegisterContext& reg_ctx = thread.GetRegisterContext();
 
-  JSONObject::SP register_object_sp = std::make_shared();
+  json::Object register_object;
 
 #ifdef LLDB_JTHREADSINFO_FULL_REGISTER_SET
   // Expedite all registers in the first register set (i.e. should be GPRs)
   // that are not contained in other registers.
   const RegisterSet *reg_set_p = reg_ctx_sp->GetRegisterSet(0);
   if (!reg_set_p)
-return nullptr;
+return llvm::make_error("failed to get registers",
+   llvm::inconvertibleErrorCode());
   for (const uint32_t *reg_num_p = reg_set_p->registers;
*reg_num_p != LLDB_INVALID_REGNUM; ++reg_num_p) {
 uint32_t reg_num = *reg_num_p;
@@ -460,12 +462,10 @@
 WriteRegisterValueInHexFixedWidth(stream, reg_ctx, *reg_info_p,
   _value, lldb::eByteOrderBig);
 
-register_object_sp->SetObject(
-llvm::to_string(reg_num),
-std::make_shared(stream.GetString()));
+register_object.try_emplace(llvm::to_string(reg_num), stream.GetString());
   }
 
-  return register_object_sp;
+  return register_object;
 }
 
 static const char *GetStopReasonString(StopReason stop_reason) {
@@ -492,11 +492,11 @@
   return nullptr;
 }
 
-static JSONArray::SP GetJSONThreadsInfo(NativeProcessProtocol ,
-bool abridged) {
+static llvm::Expected
+GetJSONThreadsInfo(NativeProcessProtocol , bool abridged) {
   Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_THREAD));
 
-  JSONArray::SP threads_array_sp = std::make_shared();
+  json::Array threads_array;
 
   // Ensure we can get info on the given thread.
   uint32_t thread_idx = 0;
@@ -510,7 +510,8 @@
 struct ThreadStopInfo tid_stop_info;
 std::string description;
 if (!thread->GetStopReason(tid_stop_info, description))
-  return nullptr;
+  return llvm::make_error(
+  "failed to get stop reason", llvm::inconvertibleErrorCode());
 
 const int signum = tid_stop_info.details.signal.signo;
 if (log) {
@@ -522,50 +523,49 @@
 tid_stop_info.reason, tid_stop_info.details.exception.type);
 }
 
-JSONObject::SP thread_obj_sp = std::make_shared();
-threads_array_sp->AppendObject(thread_obj_sp);
+json::Object thread_obj;
 
 if (!abridged) {
-  if (JSONObject::SP registers_sp = GetRegistersAsJSON(*thread))
-thread_obj_sp->SetObject("registers", registers_sp);
+  if (llvm::Expected registers =
+  GetRegistersAsJSON(*thread)) {
+thread_obj.try_emplace("registers", std::move(*registers));
+  } else {
+return registers.takeError();
+  }
 }
 
-thread_obj_sp->SetObject("tid", std::make_shared(tid));
+thread_obj.try_emplace("tid", static_cast(tid));
+
 if (signum != 0)
-  thread_obj_sp->SetObject("signal", std::make_shared(signum));
+  thread_obj.try_emplace("signal", signum);
 
 const std::string thread_name = thread->GetName();
 if (!thread_name.empty())
-  thread_obj_sp->SetObject("name",
-   std::make_shared(thread_name));
+  thread_obj.try_emplace("name", thread_name);
 
-if (const char *stop_reason_str = GetStopReasonString(tid_stop_info.reason))
-  thread_obj_sp->SetObject("reason",
-   

[Lldb-commits] [PATCH] D68299: [JSON] Use LLVM's library for encoding JSON in GDBRemoteCommunicationServerLLGS

2019-10-02 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.
This revision is now accepted and ready to land.

Cool. Thanks for doing this.


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

https://reviews.llvm.org/D68299



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


[Lldb-commits] [PATCH] D68299: [JSON] Use LLVM's library for encoding JSON in GDBRemoteCommunicationServerLLGS

2019-10-01 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: labath, mgorbach, vsk.

This patch replaces the LLDB's JSON implementation with the one from
LLVM in GDBRemoteCommunicationServerLLGS.


https://reviews.llvm.org/D68299

Files:
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp

Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -32,7 +32,6 @@
 #include "lldb/Utility/Args.h"
 #include "lldb/Utility/DataBuffer.h"
 #include "lldb/Utility/Endian.h"
-#include "lldb/Utility/JSON.h"
 #include "lldb/Utility/LLDBAssert.h"
 #include "lldb/Utility/Log.h"
 #include "lldb/Utility/RegisterValue.h"
@@ -40,6 +39,7 @@
 #include "lldb/Utility/StreamString.h"
 #include "lldb/Utility/UriParser.h"
 #include "llvm/ADT/Triple.h"
+#include "llvm/Support/JSON.h"
 #include "llvm/Support/ScopedPrinter.h"
 
 #include "ProcessGDBRemote.h"
@@ -402,19 +402,21 @@
   }
 }
 
-static JSONObject::SP GetRegistersAsJSON(NativeThreadProtocol ) {
+static llvm::Expected
+GetRegistersAsJSON(NativeThreadProtocol ) {
   Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_THREAD));
 
   NativeRegisterContext& reg_ctx = thread.GetRegisterContext();
 
-  JSONObject::SP register_object_sp = std::make_shared();
+  json::Object register_object;
 
 #ifdef LLDB_JTHREADSINFO_FULL_REGISTER_SET
   // Expedite all registers in the first register set (i.e. should be GPRs)
   // that are not contained in other registers.
   const RegisterSet *reg_set_p = reg_ctx_sp->GetRegisterSet(0);
   if (!reg_set_p)
-return nullptr;
+return llvm::make_error("failed to get registers",
+   llvm::inconvertibleErrorCode());
   for (const uint32_t *reg_num_p = reg_set_p->registers;
*reg_num_p != LLDB_INVALID_REGNUM; ++reg_num_p) {
 uint32_t reg_num = *reg_num_p;
@@ -460,12 +462,10 @@
 WriteRegisterValueInHexFixedWidth(stream, reg_ctx, *reg_info_p,
   _value, lldb::eByteOrderBig);
 
-register_object_sp->SetObject(
-llvm::to_string(reg_num),
-std::make_shared(stream.GetString()));
+register_object.try_emplace(llvm::to_string(reg_num), stream.GetString());
   }
 
-  return register_object_sp;
+  return register_object;
 }
 
 static const char *GetStopReasonString(StopReason stop_reason) {
@@ -492,11 +492,11 @@
   return nullptr;
 }
 
-static JSONArray::SP GetJSONThreadsInfo(NativeProcessProtocol ,
-bool abridged) {
+static llvm::Expected
+GetJSONThreadsInfo(NativeProcessProtocol , bool abridged) {
   Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_THREAD));
 
-  JSONArray::SP threads_array_sp = std::make_shared();
+  json::Array threads_array;
 
   // Ensure we can get info on the given thread.
   uint32_t thread_idx = 0;
@@ -510,7 +510,8 @@
 struct ThreadStopInfo tid_stop_info;
 std::string description;
 if (!thread->GetStopReason(tid_stop_info, description))
-  return nullptr;
+  return llvm::make_error(
+  "failed to get stop reason", llvm::inconvertibleErrorCode());
 
 const int signum = tid_stop_info.details.signal.signo;
 if (log) {
@@ -522,50 +523,49 @@
 tid_stop_info.reason, tid_stop_info.details.exception.type);
 }
 
-JSONObject::SP thread_obj_sp = std::make_shared();
-threads_array_sp->AppendObject(thread_obj_sp);
+json::Object thread_obj;
 
 if (!abridged) {
-  if (JSONObject::SP registers_sp = GetRegistersAsJSON(*thread))
-thread_obj_sp->SetObject("registers", registers_sp);
+  if (llvm::Expected registers =
+  GetRegistersAsJSON(*thread)) {
+thread_obj.try_emplace("registers", std::move(*registers));
+  } else {
+return registers.takeError();
+  }
 }
 
-thread_obj_sp->SetObject("tid", std::make_shared(tid));
+thread_obj.try_emplace("tid", static_cast(tid));
+
 if (signum != 0)
-  thread_obj_sp->SetObject("signal", std::make_shared(signum));
+  thread_obj.try_emplace("signal", signum);
 
 const std::string thread_name = thread->GetName();
 if (!thread_name.empty())
-  thread_obj_sp->SetObject("name",
-   std::make_shared(thread_name));
+  thread_obj.try_emplace("name", thread_name);
 
-if (const char *stop_reason_str = GetStopReasonString(tid_stop_info.reason))
-  thread_obj_sp->SetObject("reason",
-   std::make_shared(stop_reason_str));
+const char *stop_reason = GetStopReasonString(tid_stop_info.reason);
+if (stop_reason)
+  thread_obj.try_emplace("reason", stop_reason);
 
 if (!description.empty())
-  thread_obj_sp->SetObject("description",
-