[Lldb-commits] [lldb] 3da7dcf - [lldb/Reproducers] Serialize empty string for char* methods.

2020-02-05 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-02-05T21:55:36-08:00
New Revision: 3da7dcf38a96b7ba8ba0cb61be40210ace3fd91f

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

LOG: [lldb/Reproducers] Serialize empty string for char* methods.

For the methods taking a char* and a length that have a custom replayer,
ignore the incoming string in the instrumentation macro. This prevents
potentially reading garbage and blowing up the SB API log.

Added: 


Modified: 
lldb/source/API/SBFileSpec.cpp
lldb/source/API/SBProcess.cpp
lldb/source/API/SBStructuredData.cpp
lldb/source/API/SBThread.cpp

Removed: 




diff  --git a/lldb/source/API/SBFileSpec.cpp b/lldb/source/API/SBFileSpec.cpp
index a9b3c0f99f9d..3c3ea32a455d 100644
--- a/lldb/source/API/SBFileSpec.cpp
+++ b/lldb/source/API/SBFileSpec.cpp
@@ -143,8 +143,8 @@ void SBFileSpec::SetDirectory(const char *directory) {
 }
 
 uint32_t SBFileSpec::GetPath(char *dst_path, size_t dst_len) const {
-  LLDB_RECORD_DUMMY(uint32_t, SBFileSpec, GetPath, (char *, size_t),
-   dst_path, dst_len);
+  LLDB_RECORD_METHOD_CONST(uint32_t, SBFileSpec, GetPath, (char *, size_t), "",
+   dst_len);
 
   uint32_t result = m_opaque_up->GetPath(dst_path, dst_len);
 

diff  --git a/lldb/source/API/SBProcess.cpp b/lldb/source/API/SBProcess.cpp
index ffb5a3fa8569..425ebf63ba17 100644
--- a/lldb/source/API/SBProcess.cpp
+++ b/lldb/source/API/SBProcess.cpp
@@ -270,7 +270,7 @@ size_t SBProcess::PutSTDIN(const char *src, size_t src_len) 
{
 }
 
 size_t SBProcess::GetSTDOUT(char *dst, size_t dst_len) const {
-  LLDB_RECORD_METHOD_CONST(size_t, SBProcess, GetSTDOUT, (char *, size_t), dst,
+  LLDB_RECORD_METHOD_CONST(size_t, SBProcess, GetSTDOUT, (char *, size_t), "",
dst_len);
 
   size_t bytes_read = 0;
@@ -284,7 +284,7 @@ size_t SBProcess::GetSTDOUT(char *dst, size_t dst_len) 
const {
 }
 
 size_t SBProcess::GetSTDERR(char *dst, size_t dst_len) const {
-  LLDB_RECORD_METHOD_CONST(size_t, SBProcess, GetSTDERR, (char *, size_t), dst,
+  LLDB_RECORD_METHOD_CONST(size_t, SBProcess, GetSTDERR, (char *, size_t), "",
dst_len);
 
   size_t bytes_read = 0;
@@ -299,7 +299,7 @@ size_t SBProcess::GetSTDERR(char *dst, size_t dst_len) 
const {
 
 size_t SBProcess::GetAsyncProfileData(char *dst, size_t dst_len) const {
   LLDB_RECORD_METHOD_CONST(size_t, SBProcess, GetAsyncProfileData,
-   (char *, size_t), dst, dst_len);
+   (char *, size_t), "", dst_len);
 
   size_t bytes_read = 0;
   ProcessSP process_sp(GetSP());

diff  --git a/lldb/source/API/SBStructuredData.cpp 
b/lldb/source/API/SBStructuredData.cpp
index bc820ba7e2ef..7d1b6bf78504 100644
--- a/lldb/source/API/SBStructuredData.cpp
+++ b/lldb/source/API/SBStructuredData.cpp
@@ -126,10 +126,10 @@ bool SBStructuredData::GetKeys(lldb::SBStringList ) 
const {
 
   if (!m_impl_up)
 return false;
-  
+
   if (GetType() != eStructuredDataTypeDictionary)
 return false;
-  
+
   StructuredData::ObjectSP obj_sp = m_impl_up->GetObjectSP();
   if (!obj_sp)
 return false;
@@ -141,7 +141,7 @@ bool SBStructuredData::GetKeys(lldb::SBStringList ) 
const {
   StructuredData::ObjectSP array_sp = dict->GetKeys();
   StructuredData::Array *key_arr = array_sp->GetAsArray();
   assert(key_arr);
-  
+
   key_arr->ForEach([] (StructuredData::Object *object) -> bool {
 llvm::StringRef key = object->GetStringValue("");
 keys.AppendString(key.str().c_str());
@@ -197,7 +197,7 @@ bool SBStructuredData::GetBooleanValue(bool fail_value) 
const {
 
 size_t SBStructuredData::GetStringValue(char *dst, size_t dst_len) const {
   LLDB_RECORD_METHOD_CONST(size_t, SBStructuredData, GetStringValue,
-   (char *, size_t), dst, dst_len);
+   (char *, size_t), "", dst_len);
 
   return (m_impl_up ? m_impl_up->GetStringValue(dst, dst_len) : 0);
 }

diff  --git a/lldb/source/API/SBThread.cpp b/lldb/source/API/SBThread.cpp
index ff1a428b83cd..69342b972a2c 100644
--- a/lldb/source/API/SBThread.cpp
+++ b/lldb/source/API/SBThread.cpp
@@ -313,8 +313,8 @@ 
SBThread::GetStopReasonExtendedBacktraces(InstrumentationRuntimeType type) {
 }
 
 size_t SBThread::GetStopDescription(char *dst, size_t dst_len) {
-  LLDB_RECORD_METHOD(size_t, SBThread, GetStopDescription, (char *, size_t),
- dst, dst_len);
+  LLDB_RECORD_METHOD(size_t, SBThread, GetStopDescription, (char *, size_t), 
"",
+ dst_len);
 
   std::unique_lock lock;
   ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
@@ -970,23 +970,20 @@ SBError SBThread::StepUsingScriptedThreadPlan(const char 
*script_class_name) {
 SBError 

[Lldb-commits] [PATCH] D73781: [lldb/DWARF] Don't assume that a SymbolFileDWARFDwo contains one compile unit

2020-02-05 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.cpp:29
+: SymbolFileDWARFDwo(dwarf_cu.GetSymbolFileDWARF(), objfile,
+ dwarf_cu.GetID()),
+  m_dwp_symfile(dwp_symfile), m_dwo_id(dwo_id) {}

labath wrote:
> JDevlieghere wrote:
> > Did you forget to clang-format?
> Nope, this is already clang-formatted.
We must be using a different version then :-) 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73781



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


[Lldb-commits] [PATCH] D73781: [lldb/DWARF] Don't assume that a SymbolFileDWARFDwo contains one compile unit

2020-02-05 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
labath marked an inline comment as done.
Closed by commit rGe3aa062ae957: [lldb/DWARF] Dont assume that a 
SymbolFileDWARFDwo contains one compile unit (authored by labath).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73781

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.cpp

Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.cpp
@@ -13,7 +13,7 @@
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Utility/LLDBAssert.h"
 
-#include "DWARFUnit.h"
+#include "DWARFCompileUnit.h"
 #include "DWARFDebugInfo.h"
 
 using namespace lldb;
@@ -25,8 +25,9 @@
  ObjectFileSP objfile,
  DWARFCompileUnit _cu,
  uint64_t dwo_id)
-: SymbolFileDWARFDwo(objfile, dwarf_cu), m_dwp_symfile(dwp_symfile),
-  m_dwo_id(dwo_id) {}
+: SymbolFileDWARFDwo(dwarf_cu.GetSymbolFileDWARF(), objfile,
+ dwarf_cu.GetID()),
+  m_dwp_symfile(dwp_symfile), m_dwo_id(dwo_id) {}
 
 void SymbolFileDWARFDwoDwp::LoadSectionData(lldb::SectionType sect_type,
 DWARFDataExtractor ) {
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
@@ -24,12 +24,11 @@
   static bool classof(const SymbolFile *obj) { return obj->isA(); }
   /// \}
 
-  SymbolFileDWARFDwo(lldb::ObjectFileSP objfile, DWARFCompileUnit _cu);
+  SymbolFileDWARFDwo(SymbolFileDWARF _base_symbol_file,
+ lldb::ObjectFileSP objfile, uint32_t id);
 
   ~SymbolFileDWARFDwo() override = default;
 
-  lldb::CompUnitSP ParseCompileUnit(DWARFCompileUnit _cu) override;
-
   DWARFCompileUnit *GetCompileUnit();
 
   DWARFUnit *
@@ -44,8 +43,6 @@
   DWARFDIE
   GetDIE(const DIERef _ref) override;
 
-  DWARFCompileUnit *GetBaseCompileUnit() override { return _base_dwarf_cu; }
-
   llvm::Optional GetDwoNum() override { return GetID() >> 32; }
 
 protected:
@@ -69,11 +66,11 @@
   const DWARFDIE , lldb_private::ConstString type_name,
   bool must_be_implementation) override;
 
-  SymbolFileDWARF ();
+  SymbolFileDWARF () { return m_base_symbol_file; }
 
   DWARFCompileUnit *ComputeCompileUnit();
 
-  DWARFCompileUnit _base_dwarf_cu;
+  SymbolFileDWARF _base_symbol_file;
   DWARFCompileUnit *m_cu = nullptr;
 };
 
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
@@ -23,12 +23,12 @@
 
 char SymbolFileDWARFDwo::ID;
 
-SymbolFileDWARFDwo::SymbolFileDWARFDwo(ObjectFileSP objfile,
-   DWARFCompileUnit _cu)
+SymbolFileDWARFDwo::SymbolFileDWARFDwo(SymbolFileDWARF _symbol_file,
+   ObjectFileSP objfile, uint32_t id)
 : SymbolFileDWARF(objfile, objfile->GetSectionList(
/*update_module_section_list*/ false)),
-  m_base_dwarf_cu(dwarf_cu) {
-  SetID(((lldb::user_id_t)dwarf_cu.GetID()) << 32);
+  m_base_symbol_file(base_symbol_file) {
+  SetID(user_id_t(id) << 32);
 }
 
 void SymbolFileDWARFDwo::LoadSectionData(lldb::SectionType sect_type,
@@ -49,14 +49,6 @@
   SymbolFileDWARF::LoadSectionData(sect_type, data);
 }
 
-lldb::CompUnitSP
-SymbolFileDWARFDwo::ParseCompileUnit(DWARFCompileUnit _cu) {
-  assert(GetCompileUnit() == _cu &&
- "SymbolFileDWARFDwo::ParseCompileUnit called with incompatible "
- "compile unit");
-  return GetBaseSymbolFile().ParseCompileUnit(m_base_dwarf_cu);
-}
-
 DWARFCompileUnit *SymbolFileDWARFDwo::GetCompileUnit() {
   if (!m_cu)
 m_cu = ComputeCompileUnit();
@@ -133,10 +125,6 @@
   die, type_name, must_be_implementation);
 }
 
-SymbolFileDWARF ::GetBaseSymbolFile() {
-  return m_base_dwarf_cu.GetSymbolFileDWARF();
-}
-
 llvm::Expected
 SymbolFileDWARFDwo::GetTypeSystemForLanguage(LanguageType language) {
   return 

[Lldb-commits] [PATCH] D73781: [lldb/DWARF] Don't assume that a SymbolFileDWARFDwo contains one compile unit

2020-02-05 Thread Pavel Labath via Phabricator via lldb-commits
labath marked 2 inline comments as done.
labath added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.cpp:29
+: SymbolFileDWARFDwo(dwarf_cu.GetSymbolFileDWARF(), objfile,
+ dwarf_cu.GetID()),
+  m_dwp_symfile(dwp_symfile), m_dwo_id(dwo_id) {}

JDevlieghere wrote:
> Did you forget to clang-format?
Nope, this is already clang-formatted.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73781



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


[Lldb-commits] [lldb] e3aa062 - [lldb/DWARF] Don't assume that a SymbolFileDWARFDwo contains one compile unit

2020-02-05 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-02-05T20:37:56-08:00
New Revision: e3aa062ae957f61ee9f9e25f52bdb3c690c79fe3

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

LOG: [lldb/DWARF] Don't assume that a SymbolFileDWARFDwo contains one compile 
unit

Summary:
This is a preparatory patch to re-enable DWP support in lldb (we already
have code claiming to do that, but it has been completely broken for a
while now).

The idea of the new approach is to make the SymbolFileDWARFDwo class
handle both dwo and dwo files, similar to how llvm uses one DWARFContext
to handle the two.

The first step is to remove the assumption that a SymbolFileDWARFDwo
holds just a single compile unit, i.e. the GetBaseCompileUnit method.
This requires changing the way how we reach the skeleton compile unit
(and the lldb_private::CompileUnit) from a dwo unit, which was
previously done via GetSymbolFile()->GetBaseCompileUnit() (and some
virtual dispatch).

The new approach reuses the "user data" mechanism of DWARFUnits, which
was used to link dwarf units (both skeleton and split) to their
lldb_private counterparts. Now, this is done only for non-dwo units, and
instead of that, the dwo units holds a pointer to the relevant skeleton
unit.

Reviewers: JDevlieghere, aprantl, clayborg

Reviewed By: JDevlieghere, clayborg

Subscribers: arphaman, lldb-commits

Tags: #lldb

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

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
index 1c9696843c75..8944078d7fff 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -347,6 +347,7 @@ void DWARFUnit::AddUnitDIE(const DWARFDebugInfoEntry 
_die) {
   DWARFUnit *dwo_cu = dwo_symbol_file->GetCompileUnit();
   if (!dwo_cu)
 return; // Can't fetch the compile unit from the dwo file.
+  dwo_cu->SetUserData(this);
 
   DWARFBaseDIE dwo_cu_die = dwo_cu->GetUnitDIEOnly();
   if (!dwo_cu_die.IsValid())
@@ -563,11 +564,7 @@ uint8_t DWARFUnit::GetDefaultAddressSize() { return 4; }
 
 void *DWARFUnit::GetUserData() const { return m_user_data; }
 
-void DWARFUnit::SetUserData(void *d) {
-  m_user_data = d;
-  if (m_dwo_symbol_file)
-m_dwo_symbol_file->GetCompileUnit()->SetUserData(d);
-}
+void DWARFUnit::SetUserData(void *d) { m_user_data = d; }
 
 bool DWARFUnit::Supports_DW_AT_APPLE_objc_complete_type() {
   return GetProducer() != eProducerLLVMGCC;

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
index 78b1e3bf900f..73edf62e73d4 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -79,6 +79,8 @@ class DWARFUnit : public lldb_private::UserID {
   DIERef::Section section, lldb::offset_t *offset_ptr);
   virtual ~DWARFUnit();
 
+  bool IsDWOUnit() { return m_is_dwo; }
+
   void ExtractUnitDIEIfNeeded();
   void ExtractDIEsIfNeeded();
 

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
index 0d0857ea3811..c86149d2692e 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -89,7 +89,7 @@ void ManualDWARFIndex::Index() {
 
 void ManualDWARFIndex::IndexUnit(DWARFUnit , IndexSet ) {
   assert(
-  !unit.GetSymbolFileDWARF().GetBaseCompileUnit() &&
+  !unit.IsDWOUnit() &&
   "DWARFUnit associated with .dwo or .dwp should not be indexed directly");
 
   Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS);

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 2d7ffde8a54e..02fb37f65da0 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -645,9 +645,7 @@ lldb::CompUnitSP 
SymbolFileDWARF::ParseCompileUnit(DWARFCompileUnit _cu) {
 // We already parsed this compile unit, had out a shared pointer to it
 cu_sp = comp_unit->shared_from_this();
   } else {
-if (_cu.GetSymbolFileDWARF() != this) {
-  return 

[Lldb-commits] [lldb] 2f025bb - [lldb/Reproducers] Implement custom replayers for (char *, size_t)

2020-02-05 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-02-05T19:59:38-08:00
New Revision: 2f025bb87c33a25e3a0d226cdb663f237ccd602e

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

LOG: [lldb/Reproducers] Implement custom replayers for (char *, size_t)

Some SB API methods returns strings through a char* and a length. This
is a problem for the deserializer, which considers a single type at a
time, and therefore cannot know how many bytes to allocate for the
character buffer.

We can solve this problem by implementing a custom replayer, which
ignores the passed-in char* and allocates a buffer of the correct size
itself, before invoking the original API method or function.

This patch adds three new macros to register a custom replayer for
methods that take a char* and a size_t. It supports arbitrary return
values (some functions return a bool while others return a size_t).

Added: 


Modified: 
lldb/include/lldb/Utility/ReproducerInstrumentation.h
lldb/source/API/SBDebugger.cpp
lldb/source/API/SBFileSpec.cpp
lldb/source/API/SBProcess.cpp
lldb/source/API/SBStructuredData.cpp
lldb/source/API/SBThread.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/ReproducerInstrumentation.h 
b/lldb/include/lldb/Utility/ReproducerInstrumentation.h
index bc28999221db..a562511d6012 100644
--- a/lldb/include/lldb/Utility/ReproducerInstrumentation.h
+++ b/lldb/include/lldb/Utility/ReproducerInstrumentation.h
@@ -90,6 +90,32 @@ template  inline std::string 
stringify_args(const Ts &... ts) {
   static_cast(::Method), #Result, #Class,   
\
   #Method, #Signature)
 
+#define LLDB_REGISTER_CHAR_PTR_REDIRECT_STATIC(Result, Class, Method)  
\
+  {
\
+static auto _redirect = [](char *s, size_t l) -> Result {  
\
+  return char_ptr_redirect_static(Class::Method, s, l);
\
+}; 
\
+R.Register(
\
+static_cast(::Method), _redirect);   
\
+  }
+#define LLDB_REGISTER_CHAR_PTR_REDIRECT(Result, Class, Method) 
\
+  {
\
+R.Register(::method<(
\
+   ::Method)>::doit, 
\
+   _ptr_redirect::method<( 
\
+   ::Method)>::doit, 
\
+   #Result, #Class, #Method, "(char*, size_t");
\
+  }
+#define LLDB_REGISTER_CHAR_PTR_REDIRECT_CONST(Result, Class, Method)   
\
+  {
\
+R.Register(
\
+::method_const<(::Method)>::doit,  
\
+_ptr_redirect::method_const<(::Method)>::doit,   
\
+#Result, #Class, #Method, "(char*, size_t");   
\
+  }
+
 #define LLDB_RECORD_CONSTRUCTOR(Class, Signature, ...) 
\
   lldb_private::repro::Recorder _recorder(LLVM_PRETTY_FUNCTION,
\
   stringify_args(__VA_ARGS__));
\
@@ -621,8 +647,6 @@ class Serializer {
 }
   }
 
-  void Serialize(char *t) { Serialize(static_cast(t)); }
-
   void Serialize(const char **t) {
 size_t size = 0;
 if (!t) {
@@ -779,6 +803,33 @@ class Recorder {
   static bool g_global_boundary;
 };
 
+template  struct char_ptr_redirect;
+template 
+struct char_ptr_redirect {
+  template  struct method_const {
+static Result doit(Class *c, char *s, size_t l) {
+  char *buffer = reinterpret_cast(calloc(l, sizeof(char)));
+  return (c->*m)(buffer, l);
+}
+  };
+};
+template 
+struct char_ptr_redirect {
+  template  struct method {
+static Result doit(Class *c, char *s, size_t l) {
+  char *buffer = reinterpret_cast(calloc(l, sizeof(char)));
+  return (c->*m)(buffer, l);
+}
+  };
+};
+
+template 
+Result char_ptr_redirect_static(Result (*f)(char *, size_t), char *s,
+size_t l) {
+  char *buffer = reinterpret_cast(calloc(l, sizeof(char)));
+  return f(buffer, l);
+}
+
 } // namespace repro
 } // namespace lldb_private
 

diff  --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp
index 4a093b1ebb9d..1aeb5e2ca9ff 100644
--- a/lldb/source/API/SBDebugger.cpp
+++ b/lldb/source/API/SBDebugger.cpp
@@ -1627,14 +1627,6 @@ static SBError SetFileRedirect(SBDebugger *, SBFile 
file) { return SBError(); }
 
 static SBError SetFileRedirect(SBDebugger *, FileSP file) { return SBError(); }
 
-static bool 

[Lldb-commits] [lldb] ccf900f - Two more small fixes for debugserver attach failure messaging.

2020-02-05 Thread Jason Molenda via lldb-commits

Author: Jason Molenda
Date: 2020-02-05T19:24:38-08:00
New Revision: ccf900fc932098c1bbaa6e43a94b4423c60bf53e

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

LOG: Two more small fixes for debugserver attach failure messaging.

The developer mode check is now working.

Add another check for user id mismatch, e.g. a regular user
trying to attach to something running as root, and describe
the problem for the user.

Added: 


Modified: 
lldb/tools/debugserver/source/RNBRemote.cpp

Removed: 




diff  --git a/lldb/tools/debugserver/source/RNBRemote.cpp 
b/lldb/tools/debugserver/source/RNBRemote.cpp
index 9d6ca995905c..1f11b2fe8c23 100644
--- a/lldb/tools/debugserver/source/RNBRemote.cpp
+++ b/lldb/tools/debugserver/source/RNBRemote.cpp
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -3684,6 +3685,31 @@ static bool attach_failed_due_to_sip (nub_process_t pid) 
{
   return retval;
 }
 
+// my_uid and process_uid are only initialized if this function
+// returns true -- that there was a uid mismatch -- and those
+// id's may want to be used in the error message.
+static bool attach_failed_due_to_uid_mismatch (nub_process_t pid,
+   uid_t _uid,
+   uid_t _uid) {
+  struct kinfo_proc kinfo;
+  int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_PID, pid};
+  size_t len = sizeof(struct kinfo_proc);
+  if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), , , NULL, 0) != 0) {
+return false; // pid doesn't exist? can't check uid mismatch - it was fine
+  }
+  my_uid = geteuid();
+  if (my_uid == 0)
+return false; // if we're root, attach didn't fail because of uid mismatch
+  process_uid = kinfo.kp_eproc.e_ucred.cr_uid;
+
+  // If my uid != the process' uid, then the attach probably failed because
+  // of that.
+  if (my_uid != process_uid)
+return true;
+  else
+return false;
+}
+
 static bool process_is_already_being_debugged (nub_process_t pid) {
   struct kinfo_proc kinfo;
   int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_PID, pid};
@@ -3714,6 +3740,9 @@ static bool process_is_already_being_debugged 
(nub_process_t pid) {
 // $ security authorizationdb read system.privilege.taskport.debug
 
 static bool developer_mode_enabled () {
+#if !defined (TARGET_OS_OSX)
+  return true;
+#else
  CFDictionaryRef currentRightDict = NULL;
  const char *debug_right = "system.privilege.taskport.debug";
  // caller must free dictionary initialized by the following
@@ -3745,7 +3774,13 @@ static bool developer_mode_enabled () {
  } else {
CFStringRef item = (CFStringRef) CFDictionaryGetValue(currentRightDict, 
CFSTR("class"));
if (item && CFGetTypeID(item) == CFStringGetTypeID()) {
- if (strcmp (CFStringGetCStringPtr (item, ::CFStringGetSystemEncoding()), 
"rule") != 0) {
+ char tmpbuf[128];
+ if (CFStringGetCString (item, tmpbuf, sizeof(tmpbuf), 
CFStringGetSystemEncoding())) {
+   tmpbuf[sizeof (tmpbuf) - 1] = '\0';
+   if (strcmp (tmpbuf, "rule") != 0) {
+ devmode_enabled = false;
+   }
+ } else {
devmode_enabled = false;
  }
} else {
@@ -3773,6 +3808,7 @@ static bool developer_mode_enabled () {
  ::CFRelease(currentRightDict);
 
  return devmode_enabled;
+#endif // TARGET_OS_OSX
 }
 
 /*
@@ -3956,6 +3992,27 @@ rnb_err_t RNBRemote::HandlePacket_v(const char *p) {
"process already being debugged");
   return SendPacket(return_message.c_str());
 }
+uid_t my_uid, process_uid;
+if (attach_failed_due_to_uid_mismatch (pid_attaching_to, 
+   my_uid, process_uid)) {
+  std::string my_username = "uid " + std::to_string (my_uid);
+  std::string process_username = "uid " + std::to_string (process_uid);
+  struct passwd *pw = getpwuid (my_uid);
+  if (pw && pw->pw_name) {
+my_username = pw->pw_name;
+  }
+  pw = getpwuid (process_uid);
+  if (pw && pw->pw_name) {
+process_username = pw->pw_name;
+  }
+  DNBLogError("Tried to attach to process with uid mismatch");
+  std::string return_message = "E96;";
+  std::string msg = "tried to attach to process as user '" 
++ my_username + "' and process is running "
+"as user '" + process_username + "'";
+  return_message += cstring_to_asciihex_string(msg.c_str());
+  return SendPacket(return_message.c_str());
+}
 if (!developer_mode_enabled()) {
   DNBLogError("Developer mode is not enabled");
   std::string return_message = "E96;";




[Lldb-commits] [PATCH] D72751: [LLDB] Add DynamicLoaderWasmDYLD plugin for WebAssembly debugging

2020-02-05 Thread Paolo Severini via Phabricator via lldb-commits
paolosev added a comment.

In D72751#1860950 , @max-kudr wrote:

> There is Windows Build Bot failure 
> http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/13427. Can 
> you please fix or revert it?
>
>   Cannot open include file: 
> 'Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.h': No such file or 
> directory
>


This should have been fixed by 
https://reviews.llvm.org/rGf5f70d1c8fbf12249b4b9598f10a10f12d4db029.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72751



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


[Lldb-commits] [PATCH] D72751: [LLDB] Add DynamicLoaderWasmDYLD plugin for WebAssembly debugging

2020-02-05 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

I am afraid this isn't over yet. :(

The tests with this patch don't seem to be compatible with python3 and are 
failing due to various errors: 
http://lab.llvm.org:8011/builders/lldb-x86_64-debian/builds/4419/steps/test/logs/stdio.
 Even when running the test with python2 I have had one failure due to the 
assert on TestWasm.py:233. I am not sure how this managed to pass for you (I 
guess we must have some host differences leaking in here), but overall, I think 
this is an overly aggressive assertion. You can't assume that lldb will read 
absolutely no memory, even when the module is read from disk. Maybe you could 
just check that none of the reads overlap the debug_info section? (I am 
deliberately not including the text section here, because lldb prefers to read 
code from memory instead of from object file).

Since the situation on master was starting to get a bit out of hand (multiple 
concurrent breakages with frantic fixup attempts), I've tried to back 
everything out so we can start with a clean slate again.

I am also sorry for not looking over the latest round of changes. I'll check 
out the changes you've since I've approved the patch tomorrow.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72751



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


[Lldb-commits] [PATCH] D72751: [LLDB] Add DynamicLoaderWasmDYLD plugin for WebAssembly debugging

2020-02-05 Thread Max Kudryavtsev via Phabricator via lldb-commits
max-kudr added a comment.

There is Windows Build Bot failure 
http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/13427. Can you 
please fix or revert it?

  Cannot open include file: 
'Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.h': No such file or 
directory


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72751



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


[Lldb-commits] [lldb] 40efa65 - Revert "[LLDB] Add DynamicLoaderWasmDYLD plugin for WebAssembly debugging"

2020-02-05 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-02-05T16:22:19-08:00
New Revision: 40efa65de804b42e14356fc8fcfaa79d9dbcdb02

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

LOG: Revert "[LLDB] Add DynamicLoaderWasmDYLD plugin for WebAssembly debugging"

This patch has a couple of outstanding issues. The test is not python3
compatible, and it also seems to fail with python2 (at least under some
circumstances) due to an overambitious assertion.

This reverts the patch as well as subsequent fixup attempts:
014ea9337624fe20aca8892e73b6b3f741d8da9e,
f5f70d1c8fbf12249b4b9598f10a10f12d4db029.
4697e701b8cb40429818609814c7422e49b2ee07.
5c15e8e682e365b3a7fcf35200df79f3fb93b924.
3ec28da6d6430a00b46780555a87acd43fcab790.

Added: 


Modified: 
lldb/source/API/SystemInitializerFull.cpp
lldb/source/Plugins/DynamicLoader/CMakeLists.txt
lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h
lldb/test/Shell/ObjectFile/wasm/basic.yaml
lldb/test/Shell/ObjectFile/wasm/embedded-debug-sections.yaml
lldb/test/Shell/ObjectFile/wasm/stripped-debug-sections.yaml
lldb/test/Shell/ObjectFile/wasm/unified-debug-sections.yaml
lldb/tools/lldb-test/SystemInitializerTest.cpp

Removed: 

lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestWasm.py

lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/test_sym.yaml

lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/test_wasm_embedded_debug_sections.yaml

lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/test_wasm_external_debug_sections.yaml
lldb/source/Plugins/DynamicLoader/wasm-DYLD/CMakeLists.txt
lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.cpp
lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.h



diff  --git 
a/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestWasm.py
 
b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestWasm.py
deleted file mode 100644
index 1d38aa6c66ae..
--- 
a/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestWasm.py
+++ /dev/null
@@ -1,272 +0,0 @@
-import lldb
-import binascii
-import struct
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test.decorators import *
-from gdbclientutils import *
-
-LLDB_INVALID_ADDRESS = 0x
-load_address = 0x4
-
-def format_register_value(val):
-"""
-Encode each byte by two hex digits in little-endian order.
-"""
-return ''.join(x.encode('hex') for x in struct.pack('>= 7
-if val != 0:
-byte |= 0x80  # mark this byte to show that more bytes will follow
-result.append(byte)
-if val == 0:
-break
-return result
-
-
-def encode_wasm_string(s):
-"""
-Encode a string as an array of UTF-8 bytes preceded by its ULEB128 length.
-"""
-char_array = bytearray(x.encode("utf8") for x in s)
-return uleb128_encode(len(char_array)) + char_array
-
-
-def format_bytearray_as_hexstring(byte_array):
-"""
-Encode a n array of bytes as a string of hexadecimal digits.
-"""
-return ''.join(format(x, '02x') for x in byte_array)
-
-
-class MyResponder(MockGDBServerResponder):
-current_pc = load_address + 0x0a
-
-def __init__(self, obj_path):
-self._obj_path = obj_path
-MockGDBServerResponder.__init__(self)
-
-def respond(self, packet):
-if packet == "qProcessInfo":
-return self.qProcessInfo()
-if packet[0:13] == "qRegisterInfo":
-return self.qRegisterInfo(packet[13:])
-return MockGDBServerResponder.respond(self, packet)
-
-def qSupported(self, client_supported):
-return "qXfer:libraries:read+;PacketSize=1000;vContSupported-"
-
-def qHostInfo(self):
-return ""
-
-def QEnableErrorStrings(self):
-return ""
-
-def qfThreadInfo(self):
-return "OK"
-
-def qRegisterInfo(self, index):
-if int(index) == 0:
-return 
"name:pc;alt-name:pc;bitsize:64;offset:0;encoding:uint;format:hex;set:General 
Purpose Registers;gcc:16;dwarf:16;generic:pc;"
-return "E45"
-
-def qProcessInfo(self):
-return 
"pid:1;ppid:1;uid:1;gid:1;euid:1;egid:1;name:%s;triple:%s;ptrsize:4" % 
(hex_encode_bytes("lldb"), hex_encode_bytes("wasm32-unknown-unknown-wasm"))
-
-def haltReason(self):
-return "T05thread-pcs:" + format(self.current_pc, 'x') + ";thread:1;"
-
-def readRegister(self, register):
-return format_register_value(self.current_pc)
-
-def qXferRead(self, obj, annex, offset, length):
-if obj == "libraries":
-xml = '' % ("test_wasm", 

[Lldb-commits] [PATCH] D72751: [LLDB] Add DynamicLoaderWasmDYLD plugin for WebAssembly debugging

2020-02-05 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

In D72751#1860901 , @paolosev wrote:

> Thank you Derek, Jonas; I am sorry for all the trouble...


No worries, thank you both for the quick turnaround time!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72751



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


[Lldb-commits] [PATCH] D73303: [lldb/Target] Add Assert StackFrame Recognizer

2020-02-05 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib reopened this revision.
mib added a comment.
This revision is now accepted and ready to land.

There are still some bugs on Windows and Linux that need to investigated ...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73303



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


[Lldb-commits] [PATCH] D72751: [LLDB] Add DynamicLoaderWasmDYLD plugin for WebAssembly debugging

2020-02-05 Thread Paolo Severini via Phabricator via lldb-commits
paolosev added a comment.

Thank you Derek, Jonas; I am sorry for all the trouble...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72751



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


[Lldb-commits] [PATCH] D74096: [lldb/API] Fix the dangling pointer issue in SBThread::GetStopDescription

2020-02-05 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/source/API/SBThread.cpp:361-363
 stop_desc =
 exe_ctx.GetProcessPtr()->GetUnixSignals()->GetSignalAsCString(
 stop_info_sp->GetValue());

JDevlieghere wrote:
> friss wrote:
> > I don't think this is generally safe. Creating a `std::string` from a 
> > nullptr is undefined (and the previous test makes it look like this pointer 
> > could be null).
> `GetStopDescription` now returns a `std::string`, so it should be fine here?
nvm, I didn't see the variable got assigned again


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74096



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


[Lldb-commits] [PATCH] D74093: [lldb/tests] Correctly configure the lldb dotest arguments

2020-02-05 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM. I tried your patch with the Xcode generator and everything passes. Thanks 
for fixing this!




Comment at: lldb/test/API/lit.site.cfg.py.in:51
+config.test_compiler = config.test_compiler % lit_config.params
+config.dsymutil = config.dsymutil % lit_config.params
+config.filecheck = config.filecheck % lit_config.params

Interesting, I wonder why this works for the Xcode generator.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74093



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


[Lldb-commits] [lldb] 014ea93 - [lldb] Remove "print xml" from TestWasm.py

2020-02-05 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-02-05T16:09:34-08:00
New Revision: 014ea9337624fe20aca8892e73b6b3f741d8da9e

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

LOG: [lldb] Remove "print xml" from TestWasm.py

It's not py3 compatible, and the test should not be printing this to stdout
(unless in --trace mode) anyway.

Added: 


Modified: 

lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestWasm.py

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestWasm.py
 
b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestWasm.py
index 38b34f6d7417..1d38aa6c66ae 100644
--- 
a/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestWasm.py
+++ 
b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestWasm.py
@@ -224,7 +224,6 @@ def __init__(self, obj_path):
 def qXferRead(self, obj, annex, offset, length):
 if obj == "libraries":
 xml = '' % (self._obj_path, load_address)
-print xml
 return xml, False
 else:
 return None, False



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


[Lldb-commits] [lldb] 97edc0d - [lldb/Test] Mark heap-cstr.test as requiring Python

2020-02-05 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-02-05T16:05:54-08:00
New Revision: 97edc0dc9355be8771c3b6ae4efe19b23664d06d

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

LOG: [lldb/Test] Mark heap-cstr.test as requiring Python

Added: 


Modified: 
lldb/test/Shell/Heap/heap-cstr.test

Removed: 




diff  --git a/lldb/test/Shell/Heap/heap-cstr.test 
b/lldb/test/Shell/Heap/heap-cstr.test
index 4515eb56aabb..d2cf16357874 100644
--- a/lldb/test/Shell/Heap/heap-cstr.test
+++ b/lldb/test/Shell/Heap/heap-cstr.test
@@ -1,4 +1,5 @@
 # REQUIRES: system-darwin
+# REQUIRES: python
 # RUN: %clang_host %p/Inputs/cstr.c -g -o %t
 # RUN: %lldb -b -s %s -f %t | FileCheck %s
 



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


[Lldb-commits] [PATCH] D72751: [LLDB] Add DynamicLoaderWasmDYLD plugin for WebAssembly debugging

2020-02-05 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

In D72751#1860871 , @dschuff wrote:

> fixed in rGf5f70d1c8 
> 


Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72751



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


[Lldb-commits] [PATCH] D74096: [lldb/API] Fix the dangling pointer issue in SBThread::GetStopDescription

2020-02-05 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/source/API/SBThread.cpp:357
 stop_desc = wp_desc;
 stop_desc_len = sizeof(wp_desc); // Include the NULL byte for size
   } break;

This looks like some "optimization" to not have to compute the strlen below if 
the string is known. I dont't think we need this anymore with the description 
being a string? 



Comment at: lldb/source/API/SBThread.cpp:394
+  if (!stop_desc.empty()) {
 if (dst)
+  return ::snprintf(dst, dst_len, "%s", stop_desc.c_str()) +

You could simplify this 

```
if (!stop_desc.empty() && dst) {
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74096



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


[Lldb-commits] [PATCH] D74096: [lldb/API] Fix the dangling pointer issue in SBThread::GetStopDescription

2020-02-05 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/source/API/SBThread.cpp:361-363
 stop_desc =
 exe_ctx.GetProcessPtr()->GetUnixSignals()->GetSignalAsCString(
 stop_info_sp->GetValue());

friss wrote:
> I don't think this is generally safe. Creating a `std::string` from a nullptr 
> is undefined (and the previous test makes it look like this pointer could be 
> null).
`GetStopDescription` now returns a `std::string`, so it should be fine here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74096



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


Re: [Lldb-commits] [EXTERNAL] [lldb] 42c906b - [lldb/API] Fix non null-terminated stop-reason in SBThread::GetStopDescription

2020-02-05 Thread Mohamed Ismail Bennani via lldb-commits
Hi,

> On 6 Feb 2020, at 00:32, Pavel Labath  wrote:
> 
> 
> 
> On Wed, 5 Feb 2020 at 15:26, Stella Stamenova via lldb-commits 
> mailto:lldb-commits@lists.llvm.org>> wrote:
> Does this fix the Windows failures that were reported this morning as well?
> 
> 
> I doubt that. In fact, I'm pretty sure it does not even fix the asan failure, 
> but I cannot currently prove that because the build is broken in a couple of 
> other ways too. As Fred pointed out already, you'll need to ensure that the 
> temporary std::string does not get destroyed.
> 
> Also btw, string.c_str() will never be null, so there's no point in checking 
> that.  

I was investigating the failures on Windows and Linux but I’ll need some more 
time.

I think Pavel already reverted my patches.

Sorry for the inconvenience.

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


[Lldb-commits] [lldb] 98b273c - Revert "[lldb/Target] Add Assert StackFrame Recognizer"

2020-02-05 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-02-05T15:51:38-08:00
New Revision: 98b273c893b2c218c56fe5c03cbb6f082cce008c

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

LOG: Revert "[lldb/Target] Add Assert StackFrame Recognizer"

This reverts commit 2b7f32892b76cdfbe075300a5bf4a52e1b674bc7 because of test
failures due to dangling pointers.

Added: 


Modified: 
lldb/docs/use/formatting.rst
lldb/include/lldb/Core/FormatEntity.h
lldb/include/lldb/Target/StackFrameRecognizer.h
lldb/include/lldb/Target/Thread.h

lldb/packages/Python/lldbsuite/test/functionalities/inferior-assert/TestInferiorAssert.py

lldb/packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py
lldb/source/API/SBThread.cpp
lldb/source/Core/FormatEntity.cpp

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
lldb/source/Target/CMakeLists.txt
lldb/source/Target/Process.cpp
lldb/source/Target/StackFrameRecognizer.cpp
lldb/source/Target/Thread.cpp

Removed: 
lldb/include/lldb/Target/AssertFrameRecognizer.h
lldb/source/Target/AssertFrameRecognizer.cpp
lldb/test/Shell/Recognizer/Inputs/assert.c
lldb/test/Shell/Recognizer/assert.test



diff  --git a/lldb/docs/use/formatting.rst b/lldb/docs/use/formatting.rst
index e2644d50217b..939c4e18f749 100644
--- a/lldb/docs/use/formatting.rst
+++ b/lldb/docs/use/formatting.rst
@@ -134,9 +134,7 @@ A complete list of currently supported format string 
variables is listed below:
 
+---+-+
 | ``thread.queue``  | The queue name of the 
thread if the target OS supports dispatch queues


  |
 
+---+-+
-| ``thread.stop-reason``| A textual reason why the 
thread stopped. If the thread have a recognized frame, this displays its 
recognized stop reason. Otherwise, gets the stop info description.  

  |
-+---+-+
-| ``thread.stop-reason-raw``| A textual reason why the 
thread stopped. Always returns stop info description.   


   |
+| ``thread.stop-reason``| A textual reason each 
thread stopped  


  |
 
+---+-+
 | ``thread.return-value``   | The return value of the 
latest step operation (currently only for step-out.)


|
 

[Lldb-commits] [lldb] 5f1e45f - [lldb] pass --lldb-libs-dir argument to lldb-dotest

2020-02-05 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-02-05T15:51:38-08:00
New Revision: 5f1e45fd6764f9e31de1c9d6d7581645eea0c696

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

LOG: [lldb] pass --lldb-libs-dir argument to lldb-dotest

This argument was introduced in dcab9736f, but lldb-dotest was not handled.

Added: 


Modified: 
lldb/utils/lldb-dotest/CMakeLists.txt
lldb/utils/lldb-dotest/lldb-dotest.in

Removed: 




diff  --git a/lldb/utils/lldb-dotest/CMakeLists.txt 
b/lldb/utils/lldb-dotest/CMakeLists.txt
index 4fd16f0f90b3..55ba0ba3c824 100644
--- a/lldb/utils/lldb-dotest/CMakeLists.txt
+++ b/lldb/utils/lldb-dotest/CMakeLists.txt
@@ -4,6 +4,7 @@ add_dependencies(lldb-dotest lldb-test-deps)
 set_target_properties(lldb-dotest PROPERTIES FOLDER "lldb utils")
 
 get_property(LLDB_DOTEST_ARGS GLOBAL PROPERTY LLDB_DOTEST_ARGS_PROPERTY)
+set(LLDB_LIBS_DIR "${LLVM_LIBRARY_OUTPUT_INTDIR}")
 
 # Generate lldb-dotest Python driver script for each build mode.
 if(LLDB_BUILT_STANDALONE)

diff  --git a/lldb/utils/lldb-dotest/lldb-dotest.in 
b/lldb/utils/lldb-dotest/lldb-dotest.in
index bab3f8baa98d..a1d520349523 100755
--- a/lldb/utils/lldb-dotest/lldb-dotest.in
+++ b/lldb/utils/lldb-dotest/lldb-dotest.in
@@ -10,6 +10,8 @@ executable = '@LLDB_TEST_EXECUTABLE@'
 compiler = '@LLDB_TEST_COMPILER@'
 dsymutil = '@LLDB_TEST_DSYMUTIL@'
 filecheck = '@LLDB_TEST_FILECHECK@'
+lldb_libs_dir = "@LLDB_LIBS_DIR@"
+
 
 if __name__ == '__main__':
 wrapper_args = sys.argv[1:]
@@ -23,6 +25,7 @@ if __name__ == '__main__':
 cmd.extend(['--compiler', compiler])
 cmd.extend(['--dsymutil', dsymutil])
 cmd.extend(['--filecheck', filecheck])
+cmd.extend(['--lldb-libs-dir', lldb_libs_dir])
 cmd.extend(wrapper_args)
 # Invoke dotest.py and return exit code.
 print(' '.join(cmd))



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


[Lldb-commits] [PATCH] D74096: [lldb/API] Fix the dangling pointer issue in SBThread::GetStopDescription

2020-02-05 Thread Frederic Riss via Phabricator via lldb-commits
friss added inline comments.



Comment at: lldb/source/API/SBThread.cpp:361-363
 stop_desc =
 exe_ctx.GetProcessPtr()->GetUnixSignals()->GetSignalAsCString(
 stop_info_sp->GetValue());

I don't think this is generally safe. Creating a `std::string` from a nullptr 
is undefined (and the previous test makes it look like this pointer could be 
null).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74096



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


[Lldb-commits] [PATCH] D72751: [LLDB] Add DynamicLoaderWasmDYLD plugin for WebAssembly debugging

2020-02-05 Thread Derek Schuff via Phabricator via lldb-commits
dschuff added a comment.

fixed in rGf5f70d1c8 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72751



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


[Lldb-commits] [lldb] f5f70d1 - Add missing directory from 3ec28da6

2020-02-05 Thread Derek Schuff via lldb-commits

Author: Derek Schuff
Date: 2020-02-05T15:49:48-08:00
New Revision: f5f70d1c8fbf12249b4b9598f10a10f12d4db029

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

LOG: Add missing directory from 3ec28da6

Also revert 4697e701b8, restoring the original patch from
https://reviews.llvm.org/D72751

Added: 
lldb/source/Plugins/DynamicLoader/wasm-DYLD/CMakeLists.txt
lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.cpp
lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.h

Modified: 

lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestWasm.py
lldb/source/API/SystemInitializerFull.cpp
lldb/source/Plugins/DynamicLoader/CMakeLists.txt
lldb/tools/lldb-test/SystemInitializerTest.cpp

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestWasm.py
 
b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestWasm.py
index eb136dce0fab..38b34f6d7417 100644
--- 
a/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestWasm.py
+++ 
b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestWasm.py
@@ -105,6 +105,7 @@ def readMemory(self, addr, length):
 file.close()
 return result
 
+
 class TestWasm(GDBRemoteTestBase):
 
 def setUp(self):
@@ -115,7 +116,6 @@ def tearDown(self):
 lldb.DBG.SetSelectedPlatform(self._initial_platform)
 super(TestWasm, self).tearDown()
 
-@expectedFailureAll
 def test_load_module_with_embedded_symbols_from_remote(self):
 """Test connecting to a WebAssembly engine via GDB-remote and loading 
a Wasm module with embedded DWARF symbols"""
 
@@ -158,7 +158,6 @@ def 
test_load_module_with_embedded_symbols_from_remote(self):
 self.assertEquals(load_address | debug_line_section.GetFileOffset(), 
debug_line_section.GetLoadAddress(target))
 
 
-@expectedFailureAll
 def test_load_module_with_stripped_symbols_from_remote(self):
 """Test connecting to a WebAssembly engine via GDB-remote and loading 
a Wasm module with symbols stripped into a separate Wasm file"""
 
@@ -185,7 +184,7 @@ def 
test_load_module_with_stripped_symbols_from_remote(self):
 target = self.dbg.CreateTarget("")
 process = self.connect(target)
 lldbutil.expect_state_changes(self, self.dbg.GetListener(), process, 
[lldb.eStateStopped])
-
+
 num_modules = target.GetNumModules()
 self.assertEquals(1, num_modules)
 
@@ -214,7 +213,6 @@ def 
test_load_module_with_stripped_symbols_from_remote(self):
 self.assertEquals(LLDB_INVALID_ADDRESS, 
debug_line_section.GetLoadAddress(target))
 
 
-@expectedFailureAll
 def test_load_module_from_file(self):
 """Test connecting to a WebAssembly engine via GDB-remote and loading 
a Wasm module from a file"""
 
@@ -245,7 +243,7 @@ def readMemory(self, addr, length):
 target = self.dbg.CreateTarget("")
 process = self.connect(target)
 lldbutil.expect_state_changes(self, self.dbg.GetListener(), process, 
[lldb.eStateStopped])
-
+
 num_modules = target.GetNumModules()
 self.assertEquals(1, num_modules)
 

diff  --git a/lldb/source/API/SystemInitializerFull.cpp 
b/lldb/source/API/SystemInitializerFull.cpp
index d518c577c7d1..4b7e3337c59e 100644
--- a/lldb/source/API/SystemInitializerFull.cpp
+++ b/lldb/source/API/SystemInitializerFull.cpp
@@ -48,6 +48,7 @@
 #include "Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h"
 #include "Plugins/DynamicLoader/Static/DynamicLoaderStatic.h"
 #include "Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h"
+#include "Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.h"
 #include "Plugins/Instruction/ARM/EmulateInstructionARM.h"
 #include "Plugins/Instruction/ARM64/EmulateInstructionARM64.h"
 #include "Plugins/Instruction/MIPS/EmulateInstructionMIPS.h"
@@ -274,6 +275,7 @@ llvm::Error SystemInitializerFull::Initialize() {
   DynamicLoaderMacOSXDYLD::Initialize();
   DynamicLoaderMacOS::Initialize();
   DynamicLoaderPOSIXDYLD::Initialize();
+  wasm::DynamicLoaderWasmDYLD::Initialize(); // before DynamicLoaderStatic.
   DynamicLoaderStatic::Initialize();
   DynamicLoaderWindowsDYLD::Initialize();
 
@@ -362,6 +364,7 @@ void SystemInitializerFull::Terminate() {
   DynamicLoaderMacOSXDYLD::Terminate();
   DynamicLoaderMacOS::Terminate();
   DynamicLoaderPOSIXDYLD::Terminate();
+  wasm::DynamicLoaderWasmDYLD::Terminate();
   DynamicLoaderStatic::Terminate();
   DynamicLoaderWindowsDYLD::Terminate();
 

diff  --git a/lldb/source/Plugins/DynamicLoader/CMakeLists.txt 
b/lldb/source/Plugins/DynamicLoader/CMakeLists.txt
index 9f3b2ab0e50f..f357fea02efb 100644
--- 

[Lldb-commits] [PATCH] D74096: [lldb/API] Fix the dangling pointer issue in SBThread::GetStopDescription

2020-02-05 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib created this revision.
mib added reviewers: friss, JDevlieghere.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Instead of creating a char pointer to hold the stop reason description,
the reason is stored in a std::string.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74096

Files:
  lldb/source/API/SBThread.cpp


Index: lldb/source/API/SBThread.cpp
===
--- lldb/source/API/SBThread.cpp
+++ lldb/source/API/SBThread.cpp
@@ -325,15 +325,14 @@
 
   StopInfoSP stop_info_sp = exe_ctx.GetThreadPtr()->GetStopInfo();
   if (stop_info_sp) {
-const char *stop_desc =
-exe_ctx.GetThreadPtr()->GetStopDescription().c_str();
-if (stop_desc) {
+std::string stop_desc = exe_ctx.GetThreadPtr()->GetStopDescription();
+if (!stop_desc.empty()) {
   if (dst)
-return ::snprintf(dst, dst_len, "%s", stop_desc);
+return ::snprintf(dst, dst_len, "%s", stop_desc.c_str());
   else {
 // NULL dst passed in, return the length needed to contain the
 // description
-return ::strlen(stop_desc) + 1; // Include the NULL byte for size
+return stop_desc.size() + 1; // Include the NULL byte for size
   }
 } else {
   size_t stop_desc_len = 0;
@@ -362,7 +361,7 @@
 stop_desc =
 exe_ctx.GetProcessPtr()->GetUnixSignals()->GetSignalAsCString(
 stop_info_sp->GetValue());
-if (stop_desc == nullptr || stop_desc[0] == '\0') {
+if (stop_desc.empty()) {
   static char signal_desc[] = "signal";
   stop_desc = signal_desc;
   stop_desc_len =
@@ -391,13 +390,13 @@
 break;
   }
 
-  if (stop_desc && stop_desc[0]) {
+  if (!stop_desc.empty()) {
 if (dst)
-  return ::snprintf(dst, dst_len, "%s", stop_desc) +
+  return ::snprintf(dst, dst_len, "%s", stop_desc.c_str()) +
  1; // Include the NULL byte
 
 if (stop_desc_len == 0)
-  stop_desc_len = ::strlen(stop_desc) + 1; // Include the NULL byte
+  stop_desc_len = stop_desc.size() + 1; // Include the NULL byte
 
 return stop_desc_len;
   }


Index: lldb/source/API/SBThread.cpp
===
--- lldb/source/API/SBThread.cpp
+++ lldb/source/API/SBThread.cpp
@@ -325,15 +325,14 @@
 
   StopInfoSP stop_info_sp = exe_ctx.GetThreadPtr()->GetStopInfo();
   if (stop_info_sp) {
-const char *stop_desc =
-exe_ctx.GetThreadPtr()->GetStopDescription().c_str();
-if (stop_desc) {
+std::string stop_desc = exe_ctx.GetThreadPtr()->GetStopDescription();
+if (!stop_desc.empty()) {
   if (dst)
-return ::snprintf(dst, dst_len, "%s", stop_desc);
+return ::snprintf(dst, dst_len, "%s", stop_desc.c_str());
   else {
 // NULL dst passed in, return the length needed to contain the
 // description
-return ::strlen(stop_desc) + 1; // Include the NULL byte for size
+return stop_desc.size() + 1; // Include the NULL byte for size
   }
 } else {
   size_t stop_desc_len = 0;
@@ -362,7 +361,7 @@
 stop_desc =
 exe_ctx.GetProcessPtr()->GetUnixSignals()->GetSignalAsCString(
 stop_info_sp->GetValue());
-if (stop_desc == nullptr || stop_desc[0] == '\0') {
+if (stop_desc.empty()) {
   static char signal_desc[] = "signal";
   stop_desc = signal_desc;
   stop_desc_len =
@@ -391,13 +390,13 @@
 break;
   }
 
-  if (stop_desc && stop_desc[0]) {
+  if (!stop_desc.empty()) {
 if (dst)
-  return ::snprintf(dst, dst_len, "%s", stop_desc) +
+  return ::snprintf(dst, dst_len, "%s", stop_desc.c_str()) +
  1; // Include the NULL byte
 
 if (stop_desc_len == 0)
-  stop_desc_len = ::strlen(stop_desc) + 1; // Include the NULL byte
+  stop_desc_len = stop_desc.size() + 1; // Include the NULL byte
 
 return stop_desc_len;
   }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D72751: [LLDB] Add DynamicLoaderWasmDYLD plugin for WebAssembly debugging

2020-02-05 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

In D72751#1860780 , @JDevlieghere 
wrote:

> It looks like the wasm-DYLD directory is missing. I removed it again from the 
> CMake file but now it's failing to build. Can you please take a look?


I've partially reverted your change and XFAILed the tests in

  commit 4697e701b8cb40429818609814c7422e49b2ee07 (HEAD -> master, 
origin/master)
  Author: Jonas Devlieghere 
  Date:   Wed Feb 5 15:30:11 2020 -0800
  
  Partially revert "[LLDB] Add DynamicLoaderWasmDYLD plugin for WebAssembly 
debugging"
  
  This temporarily and partially reverts 3ec28da6d643 because it's missing
  a directory.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72751



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


[Lldb-commits] [PATCH] D72751: [LLDB] Add DynamicLoaderWasmDYLD plugin for WebAssembly debugging

2020-02-05 Thread Derek Schuff via Phabricator via lldb-commits
dschuff added a comment.

My bad, sorry about that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72751



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


[Lldb-commits] [lldb] 4697e70 - Partially revert "[LLDB] Add DynamicLoaderWasmDYLD plugin for WebAssembly debugging"

2020-02-05 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-02-05T15:32:54-08:00
New Revision: 4697e701b8cb40429818609814c7422e49b2ee07

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

LOG: Partially revert "[LLDB] Add DynamicLoaderWasmDYLD plugin for WebAssembly 
debugging"

This temporarily and partially reverts 3ec28da6d643 because it's missing
a directory.

Added: 


Modified: 

lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestWasm.py
lldb/source/API/SystemInitializerFull.cpp
lldb/tools/lldb-test/SystemInitializerTest.cpp

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestWasm.py
 
b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestWasm.py
index 38b34f6d7417..eb136dce0fab 100644
--- 
a/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestWasm.py
+++ 
b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestWasm.py
@@ -105,7 +105,6 @@ def readMemory(self, addr, length):
 file.close()
 return result
 
-
 class TestWasm(GDBRemoteTestBase):
 
 def setUp(self):
@@ -116,6 +115,7 @@ def tearDown(self):
 lldb.DBG.SetSelectedPlatform(self._initial_platform)
 super(TestWasm, self).tearDown()
 
+@expectedFailureAll
 def test_load_module_with_embedded_symbols_from_remote(self):
 """Test connecting to a WebAssembly engine via GDB-remote and loading 
a Wasm module with embedded DWARF symbols"""
 
@@ -158,6 +158,7 @@ def 
test_load_module_with_embedded_symbols_from_remote(self):
 self.assertEquals(load_address | debug_line_section.GetFileOffset(), 
debug_line_section.GetLoadAddress(target))
 
 
+@expectedFailureAll
 def test_load_module_with_stripped_symbols_from_remote(self):
 """Test connecting to a WebAssembly engine via GDB-remote and loading 
a Wasm module with symbols stripped into a separate Wasm file"""
 
@@ -184,7 +185,7 @@ def 
test_load_module_with_stripped_symbols_from_remote(self):
 target = self.dbg.CreateTarget("")
 process = self.connect(target)
 lldbutil.expect_state_changes(self, self.dbg.GetListener(), process, 
[lldb.eStateStopped])
-
+
 num_modules = target.GetNumModules()
 self.assertEquals(1, num_modules)
 
@@ -213,6 +214,7 @@ def 
test_load_module_with_stripped_symbols_from_remote(self):
 self.assertEquals(LLDB_INVALID_ADDRESS, 
debug_line_section.GetLoadAddress(target))
 
 
+@expectedFailureAll
 def test_load_module_from_file(self):
 """Test connecting to a WebAssembly engine via GDB-remote and loading 
a Wasm module from a file"""
 
@@ -243,7 +245,7 @@ def readMemory(self, addr, length):
 target = self.dbg.CreateTarget("")
 process = self.connect(target)
 lldbutil.expect_state_changes(self, self.dbg.GetListener(), process, 
[lldb.eStateStopped])
-
+
 num_modules = target.GetNumModules()
 self.assertEquals(1, num_modules)
 

diff  --git a/lldb/source/API/SystemInitializerFull.cpp 
b/lldb/source/API/SystemInitializerFull.cpp
index 4b7e3337c59e..d518c577c7d1 100644
--- a/lldb/source/API/SystemInitializerFull.cpp
+++ b/lldb/source/API/SystemInitializerFull.cpp
@@ -48,7 +48,6 @@
 #include "Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h"
 #include "Plugins/DynamicLoader/Static/DynamicLoaderStatic.h"
 #include "Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h"
-#include "Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.h"
 #include "Plugins/Instruction/ARM/EmulateInstructionARM.h"
 #include "Plugins/Instruction/ARM64/EmulateInstructionARM64.h"
 #include "Plugins/Instruction/MIPS/EmulateInstructionMIPS.h"
@@ -275,7 +274,6 @@ llvm::Error SystemInitializerFull::Initialize() {
   DynamicLoaderMacOSXDYLD::Initialize();
   DynamicLoaderMacOS::Initialize();
   DynamicLoaderPOSIXDYLD::Initialize();
-  wasm::DynamicLoaderWasmDYLD::Initialize(); // before DynamicLoaderStatic.
   DynamicLoaderStatic::Initialize();
   DynamicLoaderWindowsDYLD::Initialize();
 
@@ -364,7 +362,6 @@ void SystemInitializerFull::Terminate() {
   DynamicLoaderMacOSXDYLD::Terminate();
   DynamicLoaderMacOS::Terminate();
   DynamicLoaderPOSIXDYLD::Terminate();
-  wasm::DynamicLoaderWasmDYLD::Terminate();
   DynamicLoaderStatic::Terminate();
   DynamicLoaderWindowsDYLD::Terminate();
 

diff  --git a/lldb/tools/lldb-test/SystemInitializerTest.cpp 
b/lldb/tools/lldb-test/SystemInitializerTest.cpp
index 6d50807ab3dc..5cc998f6031b 100644
--- a/lldb/tools/lldb-test/SystemInitializerTest.cpp
+++ b/lldb/tools/lldb-test/SystemInitializerTest.cpp
@@ -38,7 +38,6 @@
 #include "Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h"
 #include 

Re: [Lldb-commits] [EXTERNAL] [lldb] 42c906b - [lldb/API] Fix non null-terminated stop-reason in SBThread::GetStopDescription

2020-02-05 Thread Pavel Labath via lldb-commits
On Wed, 5 Feb 2020 at 15:26, Stella Stamenova via lldb-commits <
lldb-commits@lists.llvm.org> wrote:

> Does this fix the Windows failures that were reported this morning as well?
>
>
I doubt that. In fact, I'm pretty sure it does not even fix the asan
failure, but I cannot currently prove that because the build is broken in a
couple of other ways too. As Fred pointed out already, you'll need to
ensure that the temporary std::string does not get destroyed.

Also btw, string.c_str() will never be null, so there's no point in
checking that.
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [EXTERNAL] [lldb] 42c906b - [lldb/API] Fix non null-terminated stop-reason in SBThread::GetStopDescription

2020-02-05 Thread Stella Stamenova via lldb-commits
Does this fix the Windows failures that were reported this morning as well?

-Original Message-
From: lldb-commits  On Behalf Of Med 
Ismail Bennani via lldb-commits
Sent: Wednesday, February 5, 2020 3:21 PM
To: lldb-commits@lists.llvm.org
Subject: [EXTERNAL] [Lldb-commits] [lldb] 42c906b - [lldb/API] Fix non 
null-terminated stop-reason in SBThread::GetStopDescription


Author: Med Ismail Bennani
Date: 2020-02-06T00:20:33+01:00
New Revision: 42c906bceffaadeb704f2629d21f33aece831bc6

URL: 
https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fllvm%2Fllvm-project%2Fcommit%2F42c906bceffaadeb704f2629d21f33aece831bc6data=02%7C01%7CSTILIS%40microsoft.com%7Cfe923584da414de18e0208d7aa920b36%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637165416541885593sdata=u7KEb85cya75VP0tnQzix44dmAF%2FFE6SEeZ%2F7y4TT6g%3Dreserved=0
DIFF: 
https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fllvm%2Fllvm-project%2Fcommit%2F42c906bceffaadeb704f2629d21f33aece831bc6.diffdata=02%7C01%7CSTILIS%40microsoft.com%7Cfe923584da414de18e0208d7aa920b36%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637165416541885593sdata=VOQdODtElZsJKjAL56RaH5tZm6JEHqny7vlbxtueukI%3Dreserved=0

LOG: [lldb/API] Fix non null-terminated stop-reason in 
SBThread::GetStopDescription

When trying to get the stop reason description using the SB API, the buffer 
fetched was not null-terminated causing failures on the sanitized bot.

This patch should address those failures.

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/source/API/SBThread.cpp

Removed: 




diff  --git a/lldb/source/API/SBThread.cpp b/lldb/source/API/SBThread.cpp index 
b215cddb4ca8..049a0b285e16 100644
--- a/lldb/source/API/SBThread.cpp
+++ b/lldb/source/API/SBThread.cpp
@@ -326,7 +326,7 @@ size_t SBThread::GetStopDescription(char *dst, size_t 
dst_len) {
   StopInfoSP stop_info_sp = exe_ctx.GetThreadPtr()->GetStopInfo();
   if (stop_info_sp) {
 const char *stop_desc =
-exe_ctx.GetThreadPtr()->GetStopDescription().data();
+exe_ctx.GetThreadPtr()->GetStopDescription().c_str();
 if (stop_desc) {
   if (dst)
 return ::snprintf(dst, dst_len, "%s", stop_desc);



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.llvm.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Flldb-commitsdata=02%7C01%7CSTILIS%40microsoft.com%7Cfe923584da414de18e0208d7aa920b36%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637165416541885593sdata=qZJ4iDBHeRC8xZcWJr4wNMIPLDBIxuWxDPsZoVp1rA0%3Dreserved=0
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D72751: [LLDB] Add DynamicLoaderWasmDYLD plugin for WebAssembly debugging

2020-02-05 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

It looks like the wasm-DYLD directory is missing. I removed it again from the 
CMake file but now it's failing to build. Can you please take a look?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72751



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


[Lldb-commits] [lldb] 42c906b - [lldb/API] Fix non null-terminated stop-reason in SBThread::GetStopDescription

2020-02-05 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2020-02-06T00:20:33+01:00
New Revision: 42c906bceffaadeb704f2629d21f33aece831bc6

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

LOG: [lldb/API] Fix non null-terminated stop-reason in 
SBThread::GetStopDescription

When trying to get the stop reason description using the SB API, the
buffer fetched was not null-terminated causing failures on the sanitized bot.

This patch should address those failures.

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/source/API/SBThread.cpp

Removed: 




diff  --git a/lldb/source/API/SBThread.cpp b/lldb/source/API/SBThread.cpp
index b215cddb4ca8..049a0b285e16 100644
--- a/lldb/source/API/SBThread.cpp
+++ b/lldb/source/API/SBThread.cpp
@@ -326,7 +326,7 @@ size_t SBThread::GetStopDescription(char *dst, size_t 
dst_len) {
   StopInfoSP stop_info_sp = exe_ctx.GetThreadPtr()->GetStopInfo();
   if (stop_info_sp) {
 const char *stop_desc =
-exe_ctx.GetThreadPtr()->GetStopDescription().data();
+exe_ctx.GetThreadPtr()->GetStopDescription().c_str();
 if (stop_desc) {
   if (dst)
 return ::snprintf(dst, dst_len, "%s", stop_desc);



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


[Lldb-commits] [lldb] 5c15e8e - [lldb/CMake] Remove non-existing wasm-DYLD subdir

2020-02-05 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-02-05T15:08:18-08:00
New Revision: 5c15e8e682e365b3a7fcf35200df79f3fb93b924

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

LOG: [lldb/CMake] Remove non-existing wasm-DYLD subdir

Added: 


Modified: 
lldb/source/Plugins/DynamicLoader/CMakeLists.txt

Removed: 




diff  --git a/lldb/source/Plugins/DynamicLoader/CMakeLists.txt 
b/lldb/source/Plugins/DynamicLoader/CMakeLists.txt
index f357fea02efb..9f3b2ab0e50f 100644
--- a/lldb/source/Plugins/DynamicLoader/CMakeLists.txt
+++ b/lldb/source/Plugins/DynamicLoader/CMakeLists.txt
@@ -4,4 +4,3 @@ add_subdirectory(POSIX-DYLD)
 add_subdirectory(Static)
 add_subdirectory(Hexagon-DYLD)
 add_subdirectory(Windows-DYLD)
-add_subdirectory(wasm-DYLD)



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


Re: [Lldb-commits] [lldb] 2b7f328 - [lldb/Target] Add Assert StackFrame Recognizer

2020-02-05 Thread Jason Molenda via lldb-commits
Hi Ismail, I think we started picking up some failures on the greendragon 
lldb-cmake-sanitize bot with this commit,

http://lab.llvm.org:8080/green/view/LLDB/job/lldb-cmake-sanitized/

=
==55503==ERROR: AddressSanitizer: heap-use-after-free on address 0x60400010d150 
at pc 0x00010a4e3f97 bp 0x7ffee573d670 sp 0x7ffee573cdf8
READ of size 2 at 0x60400010d150 thread T0
#0 0x10a4e3f96 in printf_common(void*, char const*, __va_list_tag*)+0x936 
(libclang_rt.asan_osx_dynamic.dylib:x86_64+0x1ef96)
#1 0x10a4e417f in wrap_vsnprintf+0x9f 
(libclang_rt.asan_osx_dynamic.dylib:x86_64+0x1f17f)
#2 0x10a4e4bbd in wrap_snprintf+0x9d 
(libclang_rt.asan_osx_dynamic.dylib:x86_64+0x1fbbd)
#3 0x11068a5fe in lldb::SBThread::GetStopDescription(char*, unsigned long) 
SBThread.cpp:332
#4 0x110b2126a in _wrap_SBThread_GetStopDescription(_object*, _object*) 
LLDBWrapPython.cpp:59175



I'm not sure if you already saw this?  I think Fred already commented on the 
issue, but ASAN caught it too. ;) 



> On Feb 5, 2020, at 8:49 AM, Med Ismail Bennani via lldb-commits 
>  wrote:
> 
> 
> Author: Med Ismail Bennani
> Date: 2020-02-05T17:49:13+01:00
> New Revision: 2b7f32892b76cdfbe075300a5bf4a52e1b674bc7
> 
> URL: 
> https://github.com/llvm/llvm-project/commit/2b7f32892b76cdfbe075300a5bf4a52e1b674bc7
> DIFF: 
> https://github.com/llvm/llvm-project/commit/2b7f32892b76cdfbe075300a5bf4a52e1b674bc7.diff
> 
> LOG: [lldb/Target] Add Assert StackFrame Recognizer
> 
> When a thread stops, this checks depending on the platform if the top frame is
> an abort stack frame. If so, it looks for an assert stack frame in the upper
> frames and set it as the most relavant frame when found.
> 
> To do so, the StackFrameRecognizer class holds a "Most Relevant Frame" and a
> "cooked" stop reason description. When the thread is about to stop, it checks
> if the current frame is recognized, and if so, it fetches the recognized 
> frame's
> attributes and applies them.
> 
> rdar://58528686
> 
> Differential Revision: https://reviews.llvm.org/D73303
> 
> Signed-off-by: Med Ismail Bennani 
> 
> Added: 
>lldb/include/lldb/Target/AssertFrameRecognizer.h
>lldb/source/Target/AssertFrameRecognizer.cpp
>lldb/test/Shell/Recognizer/Inputs/assert.c
>lldb/test/Shell/Recognizer/assert.test
> 
> Modified: 
>lldb/docs/use/formatting.rst
>lldb/include/lldb/Core/FormatEntity.h
>lldb/include/lldb/Target/StackFrameRecognizer.h
>lldb/include/lldb/Target/Thread.h
>
> lldb/packages/Python/lldbsuite/test/functionalities/inferior-assert/TestInferiorAssert.py
>
> lldb/packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py
>lldb/source/API/SBThread.cpp
>lldb/source/Core/FormatEntity.cpp
>
> lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
>lldb/source/Target/CMakeLists.txt
>lldb/source/Target/Process.cpp
>lldb/source/Target/StackFrameRecognizer.cpp
>lldb/source/Target/Thread.cpp
> 
> Removed: 
> 
> 
> 
> 
> diff  --git a/lldb/docs/use/formatting.rst b/lldb/docs/use/formatting.rst
> index 939c4e18f749..e2644d50217b 100644
> --- a/lldb/docs/use/formatting.rst
> +++ b/lldb/docs/use/formatting.rst
> @@ -134,7 +134,9 @@ A complete list of currently supported format string 
> variables is listed below:
> +---+-+
> | ``thread.queue``  | The queue name of the 
> thread if the target OS supports dispatch queues  
>   
>   
> |
> +---+-+
> -| ``thread.stop-reason``| A textual reason each 
> thread stopped
>   
>   
> |
> +| ``thread.stop-reason``| A textual reason why 
> the thread stopped. If the thread have a recognized frame, this 

[Lldb-commits] [PATCH] D72751: [LLDB] Add DynamicLoaderWasmDYLD plugin for WebAssembly debugging

2020-02-05 Thread Derek Schuff via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3ec28da6d643: [LLDB] Add DynamicLoaderWasmDYLD plugin for 
WebAssembly debugging (authored by paolosev, committed by dschuff).

Changed prior to commit:
  https://reviews.llvm.org/D72751?vs=242733=242754#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72751

Files:
  
lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestWasm.py
  
lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/test_sym.yaml
  
lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/test_wasm_embedded_debug_sections.yaml
  
lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/test_wasm_external_debug_sections.yaml
  lldb/source/API/SystemInitializerFull.cpp
  lldb/source/Plugins/DynamicLoader/CMakeLists.txt
  lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
  lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h
  lldb/test/Shell/ObjectFile/wasm/basic.yaml
  lldb/test/Shell/ObjectFile/wasm/embedded-debug-sections.yaml
  lldb/test/Shell/ObjectFile/wasm/stripped-debug-sections.yaml
  lldb/test/Shell/ObjectFile/wasm/unified-debug-sections.yaml
  lldb/tools/lldb-test/SystemInitializerTest.cpp

Index: lldb/tools/lldb-test/SystemInitializerTest.cpp
===
--- lldb/tools/lldb-test/SystemInitializerTest.cpp
+++ lldb/tools/lldb-test/SystemInitializerTest.cpp
@@ -38,6 +38,7 @@
 #include "Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h"
 #include "Plugins/DynamicLoader/Static/DynamicLoaderStatic.h"
 #include "Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h"
+#include "Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.h"
 #include "Plugins/Instruction/ARM/EmulateInstructionARM.h"
 #include "Plugins/Instruction/ARM64/EmulateInstructionARM64.h"
 #include "Plugins/Instruction/MIPS/EmulateInstructionMIPS.h"
@@ -244,6 +245,7 @@
   DynamicLoaderMacOSXDYLD::Initialize();
   DynamicLoaderMacOS::Initialize();
   DynamicLoaderPOSIXDYLD::Initialize();
+  wasm::DynamicLoaderWasmDYLD::Initialize(); // before DynamicLoaderStatic.
   DynamicLoaderStatic::Initialize();
   DynamicLoaderWindowsDYLD::Initialize();
 
@@ -332,6 +334,7 @@
   DynamicLoaderMacOSXDYLD::Terminate();
   DynamicLoaderMacOS::Terminate();
   DynamicLoaderPOSIXDYLD::Terminate();
+  wasm::DynamicLoaderWasmDYLD::Terminate();
   DynamicLoaderStatic::Terminate();
   DynamicLoaderWindowsDYLD::Terminate();
 
Index: lldb/test/Shell/ObjectFile/wasm/unified-debug-sections.yaml
===
--- lldb/test/Shell/ObjectFile/wasm/unified-debug-sections.yaml
+++ lldb/test/Shell/ObjectFile/wasm/unified-debug-sections.yaml
@@ -13,11 +13,11 @@
 # CHECK: Plugin name: wasm
 # CHECK: Architecture: wasm32-unknown-unknown-wasm
 # CHECK: UUID: 
-# CHECK: Executable: true
+# CHECK: Executable: false
 # CHECK: Stripped: true
-# CHECK: Type: executable
+# CHECK: Type: shared library
 # CHECK: Strata: user
-# CHECK: Base VM address: 0xa
+# CHECK: Base VM address: 0x0
 
 # CHECK: Name: code
 # CHECK: Type: code
Index: lldb/test/Shell/ObjectFile/wasm/stripped-debug-sections.yaml
===
--- lldb/test/Shell/ObjectFile/wasm/stripped-debug-sections.yaml
+++ lldb/test/Shell/ObjectFile/wasm/stripped-debug-sections.yaml
@@ -4,9 +4,9 @@
 # CHECK: Plugin name: wasm
 # CHECK: Architecture: wasm32-unknown-unknown-wasm
 # CHECK: UUID: 
-# CHECK: Executable: true
-# CHECK: Stripped: true
-# CHECK: Type: executable
+# CHECK: Executable: false
+# CHECK: Stripped: false
+# CHECK: Type: shared library
 # CHECK: Strata: user
 # CHECK: Base VM address: 0x0
 
Index: lldb/test/Shell/ObjectFile/wasm/embedded-debug-sections.yaml
===
--- lldb/test/Shell/ObjectFile/wasm/embedded-debug-sections.yaml
+++ lldb/test/Shell/ObjectFile/wasm/embedded-debug-sections.yaml
@@ -4,11 +4,11 @@
 # CHECK: Plugin name: wasm
 # CHECK: Architecture: wasm32-unknown-unknown-wasm
 # CHECK: UUID: 
-# CHECK: Executable: true
-# CHECK: Stripped: true
-# CHECK: Type: executable
+# CHECK: Executable: false
+# CHECK: Stripped: false
+# CHECK: Type: shared library
 # CHECK: Strata: user
-# CHECK: Base VM address: 0xa
+# CHECK: Base VM address: 0x0
 
 # CHECK: Name: code
 # CHECK: Type: code
Index: lldb/test/Shell/ObjectFile/wasm/basic.yaml
===
--- lldb/test/Shell/ObjectFile/wasm/basic.yaml
+++ lldb/test/Shell/ObjectFile/wasm/basic.yaml
@@ -4,11 +4,11 @@
 # CHECK: Plugin name: wasm
 # CHECK: Architecture: wasm32-unknown-unknown-wasm
 # CHECK: UUID: 
-# CHECK: Executable: true
-# CHECK: Stripped: true
-# CHECK: Type: executable
+# CHECK: Executable: false
+# CHECK: Stripped: false
+# CHECK: Type: 

[Lldb-commits] [PATCH] D74093: [lldb/tests] Correctly configure the lldb dotest arguments

2020-02-05 Thread Stella Stamenova via Phabricator via lldb-commits
stella.stamenova created this revision.
stella.stamenova added a reviewer: JDevlieghere.
Herald added subscribers: lldb-commits, mgorny.
Herald added a project: LLDB.

When the generator used for CMake is a multi-configuration generator (such as 
VS), the arguments passed to dotest are not currently configured correctly. 
There are a couple of issues:

1. The per-configuration files are all generated for the same configuration 
since the for loop overwrites the properties
2. Not all of the parameters are configured in the lit cfg, so they end up with 
%(build_mode)s as configuration and they point to non-existent paths


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74093

Files:
  lldb/test/API/lit.site.cfg.py.in
  lldb/utils/lldb-dotest/CMakeLists.txt
  lldb/utils/lldb-dotest/lldb-dotest.in

Index: lldb/utils/lldb-dotest/lldb-dotest.in
===
--- lldb/utils/lldb-dotest/lldb-dotest.in
+++ lldb/utils/lldb-dotest/lldb-dotest.in
@@ -2,14 +2,14 @@
 import subprocess
 import sys
 
-dotest_path = '@LLDB_SOURCE_DIR@/test/API/dotest.py'
-build_dir = '@LLDB_TEST_BUILD_DIRECTORY@'
-dotest_args_str = '@LLDB_DOTEST_ARGS@'
+dotest_path = '@LLDB_SOURCE_DIR_CONFIGURED@/test/API/dotest.py'
+build_dir = '@LLDB_TEST_BUILD_DIRECTORY_CONFIGURED@'
+dotest_args_str = '@LLDB_DOTEST_ARGS_CONFIGURED@'
 arch = '@LLDB_TEST_ARCH@'
-executable = '@LLDB_TEST_EXECUTABLE@'
-compiler = '@LLDB_TEST_COMPILER@'
-dsymutil = '@LLDB_TEST_DSYMUTIL@'
-filecheck = '@LLDB_TEST_FILECHECK@'
+executable = '@LLDB_TEST_EXECUTABLE_CONFIGURED@'
+compiler = '@LLDB_TEST_COMPILER_CONFIGURED@'
+dsymutil = '@LLDB_TEST_DSYMUTIL_CONFIGURED@'
+filecheck = '@LLDB_TEST_FILECHECK_CONFIGURED@'
 
 if __name__ == '__main__':
 wrapper_args = sys.argv[1:]
Index: lldb/utils/lldb-dotest/CMakeLists.txt
===
--- lldb/utils/lldb-dotest/CMakeLists.txt
+++ lldb/utils/lldb-dotest/CMakeLists.txt
@@ -14,33 +14,33 @@
   foreach(config_type ${config_types})
 # In paths to our build-tree, replace CMAKE_CFG_INTDIR with our actual configuration names.
 string(REPLACE ${CMAKE_CFG_INTDIR} ${config_type} config_runtime_output_dir ${LLVM_RUNTIME_OUTPUT_INTDIR})
-string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_DOTEST_ARGS "${LLDB_DOTEST_ARGS}")
-string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_SOURCE_DIR "${LLDB_SOURCE_DIR}")
-string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_BUILD_DIRECTORY "${LLDB_TEST_BUILD_DIRECTORY}")
-string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_EXECUTABLE "${LLDB_TEST_EXECUTABLE}")
-string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_COMPILER "${LLDB_TEST_COMPILER}")
-string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_DSYMUTIL "${LLDB_TEST_DSYMUTIL}")
-string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_FILECHECK "${LLDB_TEST_FILECHECK}")
+string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_DOTEST_ARGS_CONFIGURED "${LLDB_DOTEST_ARGS}")
+string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_SOURCE_DIR_CONFIGURED "${LLDB_SOURCE_DIR}")
+string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_BUILD_DIRECTORY_CONFIGURED "${LLDB_TEST_BUILD_DIRECTORY}")
+string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_EXECUTABLE_CONFIGURED "${LLDB_TEST_EXECUTABLE}")
+string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_COMPILER_CONFIGURED "${LLDB_TEST_COMPILER}")
+string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_DSYMUTIL_CONFIGURED "${LLDB_TEST_DSYMUTIL}")
+string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_FILECHECK_CONFIGURED "${LLDB_TEST_FILECHECK}")
 
 # Remaining ones must be paths to the provided LLVM build-tree.
 if(${config_type} IN_LIST LLVM_CONFIGURATION_TYPES)
   # Multi-configuration generator like Xcode (with a matching config).
-  string(REPLACE ${CMAKE_CFG_INTDIR} ${config_type} LLDB_DOTEST_ARGS "${LLDB_DOTEST_ARGS}")
-  string(REPLACE ${CMAKE_CFG_INTDIR} ${config_type} LLDB_SOURCE_DIR "${LLDB_SOURCE_DIR}")
-  string(REPLACE ${CMAKE_CFG_INTDIR} ${config_type} LLDB_TEST_BUILD_DIRECTORY "${LLDB_TEST_BUILD_DIRECTORY}")
-  string(REPLACE ${CMAKE_CFG_INTDIR} ${config_type} LLDB_TEST_EXECUTABLE "${LLDB_TEST_EXECUTABLE}")
-  string(REPLACE ${CMAKE_CFG_INTDIR} ${config_type} LLDB_TEST_COMPILER "${LLDB_TEST_COMPILER}")
-  string(REPLACE ${CMAKE_CFG_INTDIR} ${config_type} LLDB_TEST_DSYMUTIL "${LLDB_TEST_DSYMUTIL}")
-  string(REPLACE ${CMAKE_CFG_INTDIR} ${config_type} LLDB_TEST_FILECHECK 

[Lldb-commits] [lldb] 6dccad7 - [lldb/Reproducers] (De)serialize char* like const char*

2020-02-05 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-02-05T14:52:08-08:00
New Revision: 6dccad7517f83a069d9bfbf761b648b0e50870c2

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

LOG: [lldb/Reproducers] (De)serialize char* like const char*

The current implementation has a discrepancy between how char pointers
are serialized and deserialized. The latter treats it like a const char*
while the former serializes it as a pointer to a basic type.

Both are potentially wrong, as char pointers are mostly used in
combination with a size, and nothing guarantees that the string's length
(its first null byte to be more precise) is greater or equal to its
size. The real solution is to have a custom (de)serializer that uses
both pieces of infromation.

However, the implementation should be consistent between serialization
and deserialization and I believe treating char* as const char* is the
better alternative.

Added: 


Modified: 
lldb/include/lldb/Utility/ReproducerInstrumentation.h

Removed: 




diff  --git a/lldb/include/lldb/Utility/ReproducerInstrumentation.h 
b/lldb/include/lldb/Utility/ReproducerInstrumentation.h
index 9039a7f1d162..bc28999221db 100644
--- a/lldb/include/lldb/Utility/ReproducerInstrumentation.h
+++ b/lldb/include/lldb/Utility/ReproducerInstrumentation.h
@@ -621,6 +621,8 @@ class Serializer {
 }
   }
 
+  void Serialize(char *t) { Serialize(static_cast(t)); }
+
   void Serialize(const char **t) {
 size_t size = 0;
 if (!t) {



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


[Lldb-commits] [lldb] fefff97 - [lldb/debugserver] Link against Security

2020-02-05 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-02-05T14:52:08-08:00
New Revision: fefff970321a4fe0b717f3679e291bd53ee82ef6

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

LOG: [lldb/debugserver] Link against Security

Added: 


Modified: 
lldb/tools/debugserver/source/CMakeLists.txt

Removed: 




diff  --git a/lldb/tools/debugserver/source/CMakeLists.txt 
b/lldb/tools/debugserver/source/CMakeLists.txt
index 5b604126e47d..ef8dcd1f5353 100644
--- a/lldb/tools/debugserver/source/CMakeLists.txt
+++ b/lldb/tools/debugserver/source/CMakeLists.txt
@@ -82,6 +82,8 @@ endif ()
 
 check_library_exists(compression compression_encode_buffer "" 
HAVE_LIBCOMPRESSION)
 
+find_library(SECURITY_LIBRARY Security)
+
 add_subdirectory(MacOSX)
 
 set(LLDB_CODESIGN_IDENTITY "" CACHE STRING
@@ -202,6 +204,8 @@ target_link_libraries(lldbDebugserverCommon
   ${LOCKDOWN_LIBRARY}
   lldbDebugserverArchSupport
   lldbDebugserverDarwin_DarwinLog
+  ${FOUNDATION_LIBRARY}
+  ${SECURITY_LIBRARY}
   ${LIBCOMPRESSION})
 if(HAVE_LIBCOMPRESSION)
   set_property(TARGET lldbDebugserverCommon APPEND PROPERTY
@@ -265,6 +269,7 @@ if(IOS)
   ${FOUNDATION_LIBRARY}
   lldbDebugserverArchSupport
   lldbDebugserverDarwin_DarwinLog
+  ${SECURITY_LIBRARY}
   ${LIBCOMPRESSION})
   if(HAVE_LIBCOMPRESSION)
 set_property(TARGET lldbDebugserverCommon_NonUI APPEND PROPERTY



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


[Lldb-commits] [lldb] 3ec28da - [LLDB] Add DynamicLoaderWasmDYLD plugin for WebAssembly debugging

2020-02-05 Thread Derek Schuff via lldb-commits

Author: Paolo Severini
Date: 2020-02-05T14:49:36-08:00
New Revision: 3ec28da6d6430a00b46780555a87acd43fcab790

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

LOG: [LLDB] Add DynamicLoaderWasmDYLD plugin for WebAssembly debugging

Add a dynamic loader plug-in class for WebAssembly modules.

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

Added: 

lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestWasm.py

lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/test_sym.yaml

lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/test_wasm_embedded_debug_sections.yaml

lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/test_wasm_external_debug_sections.yaml

Modified: 
lldb/source/API/SystemInitializerFull.cpp
lldb/source/Plugins/DynamicLoader/CMakeLists.txt
lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h
lldb/test/Shell/ObjectFile/wasm/basic.yaml
lldb/test/Shell/ObjectFile/wasm/embedded-debug-sections.yaml
lldb/test/Shell/ObjectFile/wasm/stripped-debug-sections.yaml
lldb/test/Shell/ObjectFile/wasm/unified-debug-sections.yaml
lldb/tools/lldb-test/SystemInitializerTest.cpp

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestWasm.py
 
b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestWasm.py
new file mode 100644
index ..38b34f6d7417
--- /dev/null
+++ 
b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestWasm.py
@@ -0,0 +1,273 @@
+import lldb
+import binascii
+import struct
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+from gdbclientutils import *
+
+LLDB_INVALID_ADDRESS = 0x
+load_address = 0x4
+
+def format_register_value(val):
+"""
+Encode each byte by two hex digits in little-endian order.
+"""
+return ''.join(x.encode('hex') for x in struct.pack('>= 7
+if val != 0:
+byte |= 0x80  # mark this byte to show that more bytes will follow
+result.append(byte)
+if val == 0:
+break
+return result
+
+
+def encode_wasm_string(s):
+"""
+Encode a string as an array of UTF-8 bytes preceded by its ULEB128 length.
+"""
+char_array = bytearray(x.encode("utf8") for x in s)
+return uleb128_encode(len(char_array)) + char_array
+
+
+def format_bytearray_as_hexstring(byte_array):
+"""
+Encode a n array of bytes as a string of hexadecimal digits.
+"""
+return ''.join(format(x, '02x') for x in byte_array)
+
+
+class MyResponder(MockGDBServerResponder):
+current_pc = load_address + 0x0a
+
+def __init__(self, obj_path):
+self._obj_path = obj_path
+MockGDBServerResponder.__init__(self)
+
+def respond(self, packet):
+if packet == "qProcessInfo":
+return self.qProcessInfo()
+if packet[0:13] == "qRegisterInfo":
+return self.qRegisterInfo(packet[13:])
+return MockGDBServerResponder.respond(self, packet)
+
+def qSupported(self, client_supported):
+return "qXfer:libraries:read+;PacketSize=1000;vContSupported-"
+
+def qHostInfo(self):
+return ""
+
+def QEnableErrorStrings(self):
+return ""
+
+def qfThreadInfo(self):
+return "OK"
+
+def qRegisterInfo(self, index):
+if int(index) == 0:
+return 
"name:pc;alt-name:pc;bitsize:64;offset:0;encoding:uint;format:hex;set:General 
Purpose Registers;gcc:16;dwarf:16;generic:pc;"
+return "E45"
+
+def qProcessInfo(self):
+return 
"pid:1;ppid:1;uid:1;gid:1;euid:1;egid:1;name:%s;triple:%s;ptrsize:4" % 
(hex_encode_bytes("lldb"), hex_encode_bytes("wasm32-unknown-unknown-wasm"))
+
+def haltReason(self):
+return "T05thread-pcs:" + format(self.current_pc, 'x') + ";thread:1;"
+
+def readRegister(self, register):
+return format_register_value(self.current_pc)
+
+def qXferRead(self, obj, annex, offset, length):
+if obj == "libraries":
+xml = '' % ("test_wasm", load_address)
+return xml, False
+else:
+return None, False
+
+def readMemory(self, addr, length):
+if addr < load_address:
+return "E02"
+result = ""
+with open(self._obj_path, mode='rb') as file:
+file_content = bytearray(file.read())
+addr_from = addr - load_address
+addr_to = addr_from + min(length, len(file_content) - addr_from)
+for i in range(addr_from, addr_to):
+result += format(file_content[i], '02x')
+

[Lldb-commits] [PATCH] D73969: [LLDB] Let DataExtractor deal with two-byte addresses

2020-02-05 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D73969#1860253 , @aykevl wrote:

> > I do have one question though. Will the DataExtractor actually do something 
> > reasonable for non-power-of-2 sizes (5,6,7) ? If yes, then great -- if not, 
> > we should keep the assert as `2 || 4 || 8`.
>
> I checked, and the only places it is actually used is in `GetAddress`, 
> `GetAddress_unchecked`, and `GetPointer`. All those end up at `GetMaxU64` (or 
> the unchecked variant) which seems to take care of odd pointer lengths. I 
> have added a test case to make sure this will keep working.


Awesome, thanks.

> 
> 
>> Since we are doing the same test all over `m_addr_size >= 1 && m_addr_size 
>> <= 8` can we just make it a function and avoid the repetition and potential 
>> erroneous updating later on that does not fix them all?
> 
> Right now there are asserts both when constructing/copying(?) the object (5 
> asserts) and at the place where `m_addr_size` is used (3 asserts). I would 
> propose picking one place, such as where it is used. That would reduce the 
> number of asserts to 3 and keep them close together. What do you think?

I agree only one of those two places should be enough. My idea was to make the 
constructors delegate to one another (if necessary by creating a private 
uber-constructor that everybody can delegate to). Then we could have only one 
assert.

But if that's hard for some reason, your proposal seems fine too.

> Sidenote: `GetAddress` and `GetPointer` are the same function but with a 
> different name. Even the doc comment right before is almost identical. I 
> tried tracing back where they came from and they can both be traced back to 
> the initial LLDB checin from Apple 
> .
>  Maybe this is worth deduplicating eventually.

Indeed, I think I'll do that when I find a bit of time.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73969



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


[Lldb-commits] [PATCH] D73961: [LLDB] Addresses can be two bytes in size

2020-02-05 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D73961#1860270 , @aykevl wrote:

> > How do you normally generate the binaries with these kinds of addresses? 
> > Can they be produced with clang? Can they be produced with llvm-mc? Linked 
> > with lld ?
>
> With `avr-gcc`. I think it's easiest to just generate a minimal binary using 
> `yaml2obj`.
>
> For the rest I'm focusing on D73969  now, 
> this patch should probably be abandoned.


yaml2obj can certainly be useful, the yaml files are not that readable when you 
need to create more complicated inputs (e.g. with DWARF). Writing assembly 
could be more useful there.

But anyway, we can evaluate that on a case-by-case basis.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73961



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


[Lldb-commits] [PATCH] D72513: Don't fail step out if remote server doesn't implement qMemoryRegionInfo

2020-02-05 Thread Jim Ingham via Phabricator via lldb-commits
jingham accepted this revision.
jingham added a comment.
This revision is now accepted and ready to land.

Oops, sorry.  Looks fine.


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

https://reviews.llvm.org/D72513



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


[Lldb-commits] [PATCH] D73303: [lldb/Target] Add Assert StackFrame Recognizer

2020-02-05 Thread Frederic Riss via Phabricator via lldb-commits
friss added inline comments.



Comment at: lldb/source/API/SBThread.cpp:328-329
   if (stop_info_sp) {
-const char *stop_desc = stop_info_sp->GetDescription();
+const char *stop_desc =
+exe_ctx.GetThreadPtr()->GetStopDescription().data();
 if (stop_desc) {

This is wrong. `GetStopDescription()` returns a temporary `std::string`. 
`stop_desc` will be a dangling pointer on the next line. Just make `stop_desc` 
a `std::string` and call `.data()` below. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73303



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


[Lldb-commits] [PATCH] D72751: [LLDB] Add DynamicLoaderWasmDYLD plugin for WebAssembly debugging

2020-02-05 Thread Paolo Severini via Phabricator via lldb-commits
paolosev updated this revision to Diff 242733.
paolosev added a comment.

Fixing ObjectFile/wasm tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72751

Files:
  
lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestWasm.py
  
lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/test_sym.yaml
  
lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/test_wasm_embedded_debug_sections.yaml
  
lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/test_wasm_external_debug_sections.yaml
  lldb/source/API/SystemInitializerFull.cpp
  lldb/source/Plugins/DynamicLoader/CMakeLists.txt
  lldb/source/Plugins/DynamicLoader/wasm-DYLD/CMakeLists.txt
  lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.cpp
  lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.h
  lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
  lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h
  lldb/test/Shell/ObjectFile/wasm/basic.yaml
  lldb/test/Shell/ObjectFile/wasm/embedded-debug-sections.yaml
  lldb/test/Shell/ObjectFile/wasm/stripped-debug-sections.yaml
  lldb/test/Shell/ObjectFile/wasm/unified-debug-sections.yaml
  lldb/tools/lldb-test/SystemInitializerTest.cpp

Index: lldb/tools/lldb-test/SystemInitializerTest.cpp
===
--- lldb/tools/lldb-test/SystemInitializerTest.cpp
+++ lldb/tools/lldb-test/SystemInitializerTest.cpp
@@ -38,6 +38,7 @@
 #include "Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h"
 #include "Plugins/DynamicLoader/Static/DynamicLoaderStatic.h"
 #include "Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h"
+#include "Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.h"
 #include "Plugins/Instruction/ARM/EmulateInstructionARM.h"
 #include "Plugins/Instruction/ARM64/EmulateInstructionARM64.h"
 #include "Plugins/Instruction/MIPS/EmulateInstructionMIPS.h"
@@ -244,6 +245,7 @@
   DynamicLoaderMacOSXDYLD::Initialize();
   DynamicLoaderMacOS::Initialize();
   DynamicLoaderPOSIXDYLD::Initialize();
+  wasm::DynamicLoaderWasmDYLD::Initialize(); // before DynamicLoaderStatic.
   DynamicLoaderStatic::Initialize();
   DynamicLoaderWindowsDYLD::Initialize();
 
@@ -332,6 +334,7 @@
   DynamicLoaderMacOSXDYLD::Terminate();
   DynamicLoaderMacOS::Terminate();
   DynamicLoaderPOSIXDYLD::Terminate();
+  wasm::DynamicLoaderWasmDYLD::Terminate();
   DynamicLoaderStatic::Terminate();
   DynamicLoaderWindowsDYLD::Terminate();
 
Index: lldb/test/Shell/ObjectFile/wasm/unified-debug-sections.yaml
===
--- lldb/test/Shell/ObjectFile/wasm/unified-debug-sections.yaml
+++ lldb/test/Shell/ObjectFile/wasm/unified-debug-sections.yaml
@@ -13,11 +13,11 @@
 # CHECK: Plugin name: wasm
 # CHECK: Architecture: wasm32-unknown-unknown-wasm
 # CHECK: UUID: 
-# CHECK: Executable: true
+# CHECK: Executable: false
 # CHECK: Stripped: true
-# CHECK: Type: executable
+# CHECK: Type: shared library
 # CHECK: Strata: user
-# CHECK: Base VM address: 0xa
+# CHECK: Base VM address: 0x0
 
 # CHECK: Name: code
 # CHECK: Type: code
Index: lldb/test/Shell/ObjectFile/wasm/stripped-debug-sections.yaml
===
--- lldb/test/Shell/ObjectFile/wasm/stripped-debug-sections.yaml
+++ lldb/test/Shell/ObjectFile/wasm/stripped-debug-sections.yaml
@@ -4,9 +4,9 @@
 # CHECK: Plugin name: wasm
 # CHECK: Architecture: wasm32-unknown-unknown-wasm
 # CHECK: UUID: 
-# CHECK: Executable: true
-# CHECK: Stripped: true
-# CHECK: Type: executable
+# CHECK: Executable: false
+# CHECK: Stripped: false
+# CHECK: Type: shared library
 # CHECK: Strata: user
 # CHECK: Base VM address: 0x0
 
Index: lldb/test/Shell/ObjectFile/wasm/embedded-debug-sections.yaml
===
--- lldb/test/Shell/ObjectFile/wasm/embedded-debug-sections.yaml
+++ lldb/test/Shell/ObjectFile/wasm/embedded-debug-sections.yaml
@@ -4,11 +4,11 @@
 # CHECK: Plugin name: wasm
 # CHECK: Architecture: wasm32-unknown-unknown-wasm
 # CHECK: UUID: 
-# CHECK: Executable: true
-# CHECK: Stripped: true
-# CHECK: Type: executable
+# CHECK: Executable: false
+# CHECK: Stripped: false
+# CHECK: Type: shared library
 # CHECK: Strata: user
-# CHECK: Base VM address: 0xa
+# CHECK: Base VM address: 0x0
 
 # CHECK: Name: code
 # CHECK: Type: code
Index: lldb/test/Shell/ObjectFile/wasm/basic.yaml
===
--- lldb/test/Shell/ObjectFile/wasm/basic.yaml
+++ lldb/test/Shell/ObjectFile/wasm/basic.yaml
@@ -4,11 +4,11 @@
 # CHECK: Plugin name: wasm
 # CHECK: Architecture: wasm32-unknown-unknown-wasm
 # CHECK: UUID: 
-# CHECK: Executable: true
-# CHECK: Stripped: true
-# CHECK: Type: executable
+# CHECK: Executable: false
+# CHECK: Stripped: false
+# CHECK: 

[Lldb-commits] [PATCH] D72513: Don't fail step out if remote server doesn't implement qMemoryRegionInfo

2020-02-05 Thread Ted Woodward via Phabricator via lldb-commits
ted added a comment.

@jingham friendly ping


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

https://reviews.llvm.org/D72513



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


[Lldb-commits] [PATCH] D74084: [LLDB] Fix compilation with GCC 5

2020-02-05 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo created this revision.
mstorsjo added reviewers: labath, aprantl.
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74084

Files:
  lldb/source/DataFormatters/FormatCache.cpp
  lldb/source/DataFormatters/LanguageCategory.cpp
  lldb/source/Interpreter/CommandAlias.cpp
  lldb/source/Interpreter/Options.cpp


Index: lldb/source/Interpreter/Options.cpp
===
--- lldb/source/Interpreter/Options.cpp
+++ lldb/source/Interpreter/Options.cpp
@@ -1061,8 +1061,8 @@
 }
 if (!option_arg)
   option_arg = "";
-option_arg_vector->emplace_back(option_str.GetString(), has_arg,
-option_arg);
+option_arg_vector->emplace_back(std::string(option_str.GetString()),
+has_arg, std::string(option_arg));
 
 // Find option in the argument list; also see if it was supposed to take an
 // argument and if one was supplied.  Remove option (and argument, if
Index: lldb/source/Interpreter/CommandAlias.cpp
===
--- lldb/source/Interpreter/CommandAlias.cpp
+++ lldb/source/Interpreter/CommandAlias.cpp
@@ -65,7 +65,8 @@
 else {
   for (auto  : args.entries()) {
 if (!entry.ref().empty())
-  option_arg_vector->emplace_back("", -1, entry.ref());
+  option_arg_vector->emplace_back(std::string(""), -1,
+  std::string(entry.ref()));
   }
 }
   }
Index: lldb/source/DataFormatters/LanguageCategory.cpp
===
--- lldb/source/DataFormatters/LanguageCategory.cpp
+++ lldb/source/DataFormatters/LanguageCategory.cpp
@@ -54,6 +54,8 @@
   return result;
 }
 
+namespace lldb_private {
+
 /// Explicit instantiations for the three types.
 /// \{
 template bool
@@ -82,6 +84,8 @@
   return m_hardcoded_synthetics;
 }
 
+} // namespace lldb_private
+
 template 
 bool LanguageCategory::GetHardcoded(FormatManager _mgr,
 FormattersMatchData _data,
Index: lldb/source/DataFormatters/FormatCache.cpp
===
--- lldb/source/DataFormatters/FormatCache.cpp
+++ lldb/source/DataFormatters/FormatCache.cpp
@@ -68,6 +68,8 @@
   return m_map[type];
 }
 
+namespace lldb_private {
+
 template<> bool FormatCache::Entry::IsCached() {
   return IsFormatCached();
 }
@@ -78,6 +80,8 @@
   return IsSyntheticCached();
 }
 
+} // namespace lldb_private
+
 template 
 bool FormatCache::Get(ConstString type, ImplSP _impl_sp) {
   std::lock_guard guard(m_mutex);


Index: lldb/source/Interpreter/Options.cpp
===
--- lldb/source/Interpreter/Options.cpp
+++ lldb/source/Interpreter/Options.cpp
@@ -1061,8 +1061,8 @@
 }
 if (!option_arg)
   option_arg = "";
-option_arg_vector->emplace_back(option_str.GetString(), has_arg,
-option_arg);
+option_arg_vector->emplace_back(std::string(option_str.GetString()),
+has_arg, std::string(option_arg));
 
 // Find option in the argument list; also see if it was supposed to take an
 // argument and if one was supplied.  Remove option (and argument, if
Index: lldb/source/Interpreter/CommandAlias.cpp
===
--- lldb/source/Interpreter/CommandAlias.cpp
+++ lldb/source/Interpreter/CommandAlias.cpp
@@ -65,7 +65,8 @@
 else {
   for (auto  : args.entries()) {
 if (!entry.ref().empty())
-  option_arg_vector->emplace_back("", -1, entry.ref());
+  option_arg_vector->emplace_back(std::string(""), -1,
+  std::string(entry.ref()));
   }
 }
   }
Index: lldb/source/DataFormatters/LanguageCategory.cpp
===
--- lldb/source/DataFormatters/LanguageCategory.cpp
+++ lldb/source/DataFormatters/LanguageCategory.cpp
@@ -54,6 +54,8 @@
   return result;
 }
 
+namespace lldb_private {
+
 /// Explicit instantiations for the three types.
 /// \{
 template bool
@@ -82,6 +84,8 @@
   return m_hardcoded_synthetics;
 }
 
+} // namespace lldb_private
+
 template 
 bool LanguageCategory::GetHardcoded(FormatManager _mgr,
 FormattersMatchData _data,
Index: lldb/source/DataFormatters/FormatCache.cpp
===
--- lldb/source/DataFormatters/FormatCache.cpp
+++ lldb/source/DataFormatters/FormatCache.cpp
@@ -68,6 +68,8 @@
   return m_map[type];
 }
 
+namespace lldb_private {
+
 template<> bool FormatCache::Entry::IsCached() {
   return IsFormatCached();
 }
@@ -78,6 +80,8 @@
   return IsSyntheticCached();
 }
 
+} // namespace lldb_private
+
 

[Lldb-commits] [PATCH] D73961: [LLDB] Addresses can be two bytes in size

2020-02-05 Thread Ayke via Phabricator via lldb-commits
aykevl added a comment.

> How do you normally generate the binaries with these kinds of addresses? Can 
> they be produced with clang? Can they be produced with llvm-mc? Linked with 
> lld ?

With `avr-gcc`. I think it's easiest to just generate a minimal binary using 
`yaml2obj`.

For the rest I'm focusing on D73969  now, this 
patch should probably be abandoned.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73961



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


[Lldb-commits] [PATCH] D73303: [lldb/Target] Add Assert StackFrame Recognizer

2020-02-05 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

It looks like there is still some memory corruption going on:

  lldb) target create --core 
"../llvm-project/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/fizzbuzz_no_heap.dmp"
  (lldb) bt
  * thread #1, stop reason = Exception 0xc005 encountered at address 
0x164d14
* frame #0: 0x00164d14 fizzbuzz.exe
  frame #1: 0x00167c79 fizzbuzz.exe
 ...
  (lldb) script lldb.thread.GetStopDescription(256)
  '\xf0\xfca\x02'




Comment at: lldb/source/Target/AssertFrameRecognizer.cpp:63-65
+symbol_name = "__GI_raise";
+if (!ModuleHasDebugInfo(target, module_spec, symbol_name))
+  symbol_name = "raise";

This part looks pretty kludgy. Maybe the function should just return a list of 
symbols (and shared libraries) and have this thing be handled at a higher level.

This is going to be needed in order to support other C library implementations 
(e.g. musl) on linux, and it's not inconceivable that the internal glibc symbol 
name will change in the future too...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73303



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


[Lldb-commits] [PATCH] D73969: [LLDB] Let DataExtractor deal with two-byte addresses

2020-02-05 Thread Ayke via Phabricator via lldb-commits
aykevl updated this revision to Diff 242694.
aykevl set the repository for this revision to rG LLVM Github Monorepo.
aykevl added a comment.

> I do have one question though. Will the DataExtractor actually do something 
> reasonable for non-power-of-2 sizes (5,6,7) ? If yes, then great -- if not, 
> we should keep the assert as `2 || 4 || 8`.

I checked, and the only places it is actually used is in `GetAddress`, 
`GetAddress_unchecked`, and `GetPointer`. All those end up at `GetMaxU64` (or 
the unchecked variant) which seems to take care of odd pointer lengths. I have 
added a test case to make sure this will keep working.

> Since we are doing the same test all over `m_addr_size >= 1 && m_addr_size <= 
> 8` can we just make it a function and avoid the repetition and potential 
> erroneous updating later on that does not fix them all?

Right now there are asserts both when constructing/copying(?) the object (5 
asserts) and at the place where `m_addr_size` is used (3 asserts). I would 
propose picking one place, such as where it is used. That would reduce the 
number of asserts to 3 and keep them close together. What do you think?

Sidenote: `GetAddress` and `GetPointer` are the same function but with a 
different name. Even the doc comment right before is almost identical. I tried 
tracing back where they came from and they can both be traced back to the 
initial LLDB checin from Apple 
.
 Maybe this is worth deduplicating eventually.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73969

Files:
  lldb/source/Utility/DataExtractor.cpp
  lldb/unittests/Utility/DataExtractorTest.cpp

Index: lldb/unittests/Utility/DataExtractorTest.cpp
===
--- lldb/unittests/Utility/DataExtractorTest.cpp
+++ lldb/unittests/Utility/DataExtractorTest.cpp
@@ -112,6 +112,39 @@
   EXPECT_EQ(4U, offset);
 }
 
+TEST(DataExtractorTest, UncommonAddressSize) {
+  uint8_t buffer[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
+  DataExtractor E2(buffer, sizeof buffer, lldb::eByteOrderLittle, 2);
+  DataExtractor E5(buffer, sizeof buffer, lldb::eByteOrderLittle, 5);
+  DataExtractor E7(buffer, sizeof buffer, lldb::eByteOrderLittle, 7);
+
+  lldb::offset_t offset;
+
+  // Test 2-byte addresses (for AVR).
+  offset = 0;
+  EXPECT_EQ(0x0201U, E2.GetMaxU64(, 2));
+  EXPECT_EQ(2U, offset);
+  offset = 0;
+  EXPECT_EQ(0x0201U, E2.GetAddress());
+  EXPECT_EQ(2U, offset);
+
+  // Test 5-byte addresses.
+  offset = 0;
+  EXPECT_EQ(0x030201U, E5.GetMaxU64(, 3));
+  EXPECT_EQ(3U, offset);
+  offset = 3;
+  EXPECT_EQ(0x0807060504U, E5.GetAddress());
+  EXPECT_EQ(8U, offset);
+
+  // Test 7-byte addresses.
+  offset = 0;
+  EXPECT_EQ(0x0504030201U, E7.GetMaxU64(, 5));
+  EXPECT_EQ(5U, offset);
+  offset = 0;
+  EXPECT_EQ(0x07060504030201U, E7.GetAddress());
+  EXPECT_EQ(7U, offset);
+}
+
 TEST(DataExtractorTest, GetMaxU64) {
   uint8_t buffer[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
   DataExtractor LE(buffer, sizeof(buffer), lldb::eByteOrderLittle,
Index: lldb/source/Utility/DataExtractor.cpp
===
--- lldb/source/Utility/DataExtractor.cpp
+++ lldb/source/Utility/DataExtractor.cpp
@@ -133,7 +133,7 @@
   m_end(const_cast(static_cast(data)) + length),
   m_byte_order(endian), m_addr_size(addr_size), m_data_sp(),
   m_target_byte_size(target_byte_size) {
-  assert(addr_size == 4 || addr_size == 8);
+  assert(addr_size >= 1 && addr_size <= 8);
 }
 
 // Make a shared pointer reference to the shared data in "data_sp" and set the
@@ -146,7 +146,7 @@
 : m_start(nullptr), m_end(nullptr), m_byte_order(endian),
   m_addr_size(addr_size), m_data_sp(),
   m_target_byte_size(target_byte_size) {
-  assert(addr_size == 4 || addr_size == 8);
+  assert(addr_size >= 1 && addr_size <= 8);
   SetData(data_sp);
 }
 
@@ -160,7 +160,7 @@
 : m_start(nullptr), m_end(nullptr), m_byte_order(data.m_byte_order),
   m_addr_size(data.m_addr_size), m_data_sp(),
   m_target_byte_size(target_byte_size) {
-  assert(m_addr_size == 4 || m_addr_size == 8);
+  assert(m_addr_size >= 1 && m_addr_size <= 8);
   if (data.ValidOffset(offset)) {
 offset_t bytes_available = data.GetByteSize() - offset;
 if (length > bytes_available)
@@ -173,7 +173,7 @@
 : m_start(rhs.m_start), m_end(rhs.m_end), m_byte_order(rhs.m_byte_order),
   m_addr_size(rhs.m_addr_size), m_data_sp(rhs.m_data_sp),
   m_target_byte_size(rhs.m_target_byte_size) {
-  assert(m_addr_size == 4 || m_addr_size == 8);
+  assert(m_addr_size >= 1 && m_addr_size <= 8);
 }
 
 // Assignment operator
@@ -251,7 +251,7 @@
   offset_t data_offset,
   offset_t data_length) {
   m_addr_size = 

[Lldb-commits] [PATCH] D73303: [lldb/Target] Add Assert StackFrame Recognizer

2020-02-05 Thread Max Kudryavtsev via Phabricator via lldb-commits
max-kudr added a comment.

This broke LLDB tests on Windows Build Bot 
http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/13415

Can you please fix it or revert it? Thank you!

  Failing Tests (4):
  lldb-api :: 
commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py
  lldb-api :: functionalities/postmortem/minidump-new/TestMiniDumpNew.py
  lldb-api :: python_api/thread/TestThreadAPI.py
  lldb-shell :: Driver/TestConvenienceVariables.test
  
Expected Passes: 1381
Expected Failures  : 10
Unsupported Tests  : 541
Unexpected Failures: 4


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73303



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


[Lldb-commits] [lldb] 77519b6 - [test] yaml2obj -docnum => --docnum=

2020-02-05 Thread Fangrui Song via lldb-commits

Author: Fangrui Song
Date: 2020-02-05T10:25:04-08:00
New Revision: 77519b60d99233ccea2622ea3e40b30018d2f228

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

LOG: [test] yaml2obj -docnum => --docnum=

Added: 


Modified: 
lld/test/ELF/compressed-input-alignment.test
lld/test/ELF/invalid/bad-reloc-target.test
lld/test/ELF/invalid/common-symbol-alignment.test
lld/test/ELF/invalid/dynamic-section-broken.test
lld/test/ELF/invalid/symtab-sh-info.s
lld/test/ELF/mips-elf-flags-err.test
lld/test/ELF/mips-fp-flags-err.test
lldb/test/Shell/ObjectFile/wasm/unified-debug-sections.yaml

Removed: 




diff  --git a/lld/test/ELF/compressed-input-alignment.test 
b/lld/test/ELF/compressed-input-alignment.test
index fd71bf361e25..57dd677c988b 100644
--- a/lld/test/ELF/compressed-input-alignment.test
+++ b/lld/test/ELF/compressed-input-alignment.test
@@ -1,10 +1,10 @@
 # REQUIRES: zlib, x86
 
-# RUN: yaml2obj -docnum=1 %s -o %t.o
+# RUN: yaml2obj --docnum=1 %s -o %t.o
 # RUN: ld.lld %t.o %t.o -o %t2
 # RUN: llvm-readobj --sections --section-data %t2 | FileCheck %s
 
-# RUN: yaml2obj -docnum=2 %s -o %t.o
+# RUN: yaml2obj --docnum=2 %s -o %t.o
 # RUN: ld.lld %t.o %t.o -o %t2
 # RUN: llvm-readobj --sections --section-data %t2 | FileCheck %s
 

diff  --git a/lld/test/ELF/invalid/bad-reloc-target.test 
b/lld/test/ELF/invalid/bad-reloc-target.test
index 9ab5d9c22580..7fafe5e70773 100644
--- a/lld/test/ELF/invalid/bad-reloc-target.test
+++ b/lld/test/ELF/invalid/bad-reloc-target.test
@@ -1,4 +1,4 @@
-# RUN: yaml2obj -docnum=1 %s -o %t1.o
+# RUN: yaml2obj --docnum=1 %s -o %t1.o
 # RUN: not ld.lld %t1.o -o %t1 2>&1 | FileCheck %s
 # CHECK: error: {{.*}}.o: unsupported relocation reference
 
@@ -24,7 +24,7 @@ Symbols:
   - Name:foo
 Binding: STB_GLOBAL
 
-# RUN: yaml2obj -docnum=2 %s -o %t2.o
+# RUN: yaml2obj --docnum=2 %s -o %t2.o
 # RUN: not ld.lld %t2.o -o %t2 2>&1 | FileCheck %s --check-prefix=ERR2
 # ERR2: error: {{.*}}.o: invalid relocated section index: 99
 
@@ -52,7 +52,7 @@ Symbols:
 
 ## Relocation refers to a symbol with index larger than
 ## symbol table size. Check we report it.
-# RUN: yaml2obj -docnum=3 %s -o %t2.o
+# RUN: yaml2obj --docnum=3 %s -o %t2.o
 # RUN: not ld.lld %t2.o -o %t2 2>&1 | FileCheck %s --check-prefix=ERR3
 # ERR3: error: {{.*}}.o: invalid symbol index
 

diff  --git a/lld/test/ELF/invalid/common-symbol-alignment.test 
b/lld/test/ELF/invalid/common-symbol-alignment.test
index 7b79441aa110..cb8a35a956c2 100644
--- a/lld/test/ELF/invalid/common-symbol-alignment.test
+++ b/lld/test/ELF/invalid/common-symbol-alignment.test
@@ -1,6 +1,6 @@
 ## If an object contains a common symbol with zero alignment,
 ## check we report it.
-# RUN: yaml2obj -docnum=1 %s -o %t1.o
+# RUN: yaml2obj --docnum=1 %s -o %t1.o
 # RUN: not ld.lld %t1.o -o %t 2>&1 | FileCheck %s
 # CHECK: common symbol 'bar' has invalid alignment: 0
 
@@ -18,7 +18,7 @@ Symbols:
 
 ## If an object contains a common symbol with alignment greater
 ## than UINT32_MAX, check we report it.
-# RUN: yaml2obj -docnum=2 %s -o %t2.o
+# RUN: yaml2obj --docnum=2 %s -o %t2.o
 # RUN: not ld.lld %t2.o -o %t 2>&1 | FileCheck %s --check-prefix=BIG
 # BIG: common symbol 'bar' has invalid alignment: 271644049215
 

diff  --git a/lld/test/ELF/invalid/dynamic-section-broken.test 
b/lld/test/ELF/invalid/dynamic-section-broken.test
index ecc7834300ec..31317f632487 100644
--- a/lld/test/ELF/invalid/dynamic-section-broken.test
+++ b/lld/test/ELF/invalid/dynamic-section-broken.test
@@ -1,5 +1,5 @@
 ## .dynamic section has invalid sh_entsize, check we report it.
-# RUN: yaml2obj -docnum=1 %s -o %t.so
+# RUN: yaml2obj --docnum=1 %s -o %t.so
 # RUN: not ld.lld %t.so -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR1
 # ERR1: error: {{.*}}.so: section [index 1] has an invalid sh_entsize: 291
 
@@ -18,7 +18,7 @@ Sections:
 
 ## The  .dynamic section has invalid sh_size, which is too short and
 ## even less than entry size. Check we report it.
-# RUN: yaml2obj -docnum=2 %s -o %t.so
+# RUN: yaml2obj --docnum=2 %s -o %t.so
 # RUN: not ld.lld %t.so -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR2
 # ERR2: error: {{.*}}.so: section [index 1] has an invalid sh_size (1) which 
is not a multiple of its sh_entsize (16)
 

diff  --git a/lld/test/ELF/invalid/symtab-sh-info.s 
b/lld/test/ELF/invalid/symtab-sh-info.s
index 9e694dcc4982..9b9cd4e9964b 100644
--- a/lld/test/ELF/invalid/symtab-sh-info.s
+++ b/lld/test/ELF/invalid/symtab-sh-info.s
@@ -1,7 +1,7 @@
 ## .symtab's sh_info contains zero value. First entry in a .symtab is a
 ## zero entry that must exist in a valid object, so sh_info can't be null.
 ## Check we report a proper error for that case.
-# RUN: yaml2obj -docnum=1 %s -o %t.o
+# RUN: yaml2obj 

[Lldb-commits] [PATCH] D73860: [lldb/StringPrinter] Avoid reading garbage in uninitialized strings

2020-02-05 Thread Vedant Kumar via Phabricator via lldb-commits
vsk added inline comments.



Comment at: lldb/source/DataFormatters/StringPrinter.cpp:144
+return retval;
+  if (!llvm::checkedAdd(reinterpret_cast(buffer),
+static_cast(utf8_encoded_len)))

shafik wrote:
> Wouldn't we want `checkedAddUnsigned`? This would also mean casting to 
> `uintptr_t`.
Not sure about that, as a change in the MSB seems significant to me.

Stepping back a bit though, it seems like this overflow check isn't useful. The 
data formatter must have called `GetPointeeData` to transfer the string payload 
into a host buffer, and we validate the number of bytes read against the size 
of the payload. So, if pointer overflow occurs, the `bytes_read` validation 
would catch it.

I'll just delete this.



Comment at: lldb/source/DataFormatters/StringPrinter.cpp:474
   uint8_t *next_data = nullptr;
   auto printable = escaping_callback(data, data_end, next_data);
   auto printable_bytes = printable.GetBytes();

shafik wrote:
> Not your code but these `auto` seem unnecessary.  Especially `printable` is 
> that just a `bool`?  Same comment in similar code above.
I'll leave this as a follow-up. `printable` is a 
`StringPrinter::StringPrinterBufferPointer`.



Comment at: lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp:530
+
+// When the small-string optimization takes place, the data must fit in the
+// inline string buffer (23 bytes on x86_64/Darwin). If it doesn't, it's

shafik wrote:
> So `short_mode` means SSO? 
Yes.



Comment at: lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp:555
+size = size_vo->GetValueAsUnsigned(LLDB_INVALID_OFFSET);
+const uint64_t cap = cap_vo->GetValueAsUnsigned(LLDB_INVALID_OFFSET);
+if (size == LLDB_INVALID_OFFSET || cap == LLDB_INVALID_OFFSET || cap < 
size)

shafik wrote:
> What does `cap` represent? It is not obvious in this context.
"capacity". I'm using the same jargon as the comment above 
`LibcxxStringLayoutMode` does, but it doesn't hurt to write this out.


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

https://reviews.llvm.org/D73860



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


[Lldb-commits] [PATCH] D73767: [lldb] [test] Pass LLVM_LIBS_DIR from CMake for linking liblldb

2020-02-05 Thread Michał Górny via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdcab9736f01b: [lldb] [test] Pass LLVM_LIBS_DIR from CMake 
for linking liblldb (authored by mgorny).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73767

Files:
  lldb/packages/Python/lldbsuite/test/configuration.py
  lldb/packages/Python/lldbsuite/test/dotest.py
  lldb/packages/Python/lldbsuite/test/dotest_args.py
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/test/API/lit.cfg.py
  lldb/test/API/lit.site.cfg.py.in

Index: lldb/test/API/lit.site.cfg.py.in
===
--- lldb/test/API/lit.site.cfg.py.in
+++ lldb/test/API/lit.site.cfg.py.in
@@ -10,6 +10,7 @@
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.lldb_obj_root = "@LLDB_BINARY_DIR@"
 config.lldb_src_root = "@LLDB_SOURCE_DIR@"
+config.lldb_libs_dir = "@LLDB_LIBS_DIR@"
 config.cmake_cxx_compiler = "@CMAKE_CXX_COMPILER@"
 config.host_os = "@HOST_OS@"
 config.host_triple = "@LLVM_HOST_TRIPLE@"
Index: lldb/test/API/lit.cfg.py
===
--- lldb/test/API/lit.cfg.py
+++ lldb/test/API/lit.cfg.py
@@ -114,6 +114,9 @@
 if config.filecheck:
   dotest_cmd += ['--filecheck', config.filecheck]
 
+if config.lldb_libs_dir:
+  dotest_cmd += ['--lldb-libs-dir', config.lldb_libs_dir]
+
 # We don't want to force users passing arguments to lit to use `;` as a
 # separator. We use Python's simple lexical analyzer to turn the args into a
 # list. Pass there arguments last so they can override anything that was
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1399,7 +1399,7 @@
 stdflag = self.getstdFlag()
 stdlibflag = self.getstdlibFlag()
 
-lib_dir = os.environ["LLDB_LIB_DIR"]
+lib_dir = configuration.lldb_libs_dir
 if self.hasDarwinFramework():
 d = {'CXX_SOURCES': sources,
  'EXE': exe_name,
@@ -1426,7 +1426,7 @@
  os.path.join(
  os.environ["LLDB_SRC"],
  "include")),
-'LD_EXTRAS': "-L%s/../lib -llldb -Wl,-rpath,%s/../lib" % (lib_dir, lib_dir)}
+'LD_EXTRAS': "-L%s -llldb -Wl,-rpath,%s" % (lib_dir, lib_dir)}
 if self.TraceOn():
 print(
 "Building LLDB Driver (%s) from sources %s" %
@@ -1439,7 +1439,7 @@
 
 stdflag = self.getstdFlag()
 
-lib_dir = os.environ["LLDB_LIB_DIR"]
+lib_dir = configuration.lldb_libs_dir
 if self.hasDarwinFramework():
 d = {'DYLIB_CXX_SOURCES': sources,
  'DYLIB_NAME': lib_name,
@@ -1464,7 +1464,7 @@
 os.path.join(
 os.environ["LLDB_SRC"],
 "include")),
-'LD_EXTRAS': "-shared -L%s/../lib -llldb -Wl,-rpath,%s/../lib" % (lib_dir, lib_dir)}
+'LD_EXTRAS': "-shared -L%s -llldb -Wl,-rpath,%s" % (lib_dir, lib_dir)}
 if self.TraceOn():
 print(
 "Building LLDB Library (%s) from sources %s" %
Index: lldb/packages/Python/lldbsuite/test/dotest_args.py
===
--- lldb/packages/Python/lldbsuite/test/dotest_args.py
+++ lldb/packages/Python/lldbsuite/test/dotest_args.py
@@ -172,6 +172,11 @@
 dest='clang_module_cache_dir',
 metavar='The clang module cache directory used by Clang',
 help='The clang module cache directory used in the Make files by Clang while building tests. Defaults to /module-cache-clang.')
+group.add_argument(
+'--lldb-libs-dir',
+dest='lldb_libs_dir',
+metavar='path',
+help='The path to LLDB library directory (containing liblldb)')
 
 # Configuration options
 group = parser.add_argument_group('Remote platform options')
Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -452,6 +452,9 @@
 
 os.environ['CLANG_MODULE_CACHE_DIR'] = configuration.clang_module_cache_dir
 
+if args.lldb_libs_dir:
+configuration.lldb_libs_dir = args.lldb_libs_dir
+
 # Gather all the dirs passed on the command line.
 if len(args.args) > 0:
 configuration.testdirs = [os.path.realpath(os.path.abspath(x)) for x in args.args]
@@ -559,10 +562,7 @@
 # confusingly, 

[Lldb-commits] [PATCH] D73206: Pass `CompileUnit *` along `DWARFDIE` for DWZ

2020-02-05 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Thanks for exploring this.

From a high-level, this approach looks like it could be viable. However, you 
have taken this a lot further than I would have expected. What I was expecting 
to see would be that a bunch of the DWARF internal functions would get an extra 
argument (be it a CompileUnit, DWARFUnit, or whatever), but I did not expect 
that this would also appear on the "generic" interfaces. My idea was that the 
external interface would keep getting just a single user_id_t, but then during 
the process of decoding that integer into a DWARFDie, we would also produce the 
additional CompileUnit object.

Now, that doesn't mean that adding a CompileUnit argument to these functions 
too is a bad idea. Quite the opposite -- _if it actually works_, it would be 
great because it would give us a lot more freedom in encoding the information 
into the user_id_t value. However, I have some doubts about that. For example, 
right now we don't create any CompileUnit objects for types  in DWARF type 
units, and I'm not sure how much we want to change that because of the sheer 
number of type units.  That means we'd still have to have a way to encode a 
precise type location in a user_id_t without a CompileUnit, though maybe we 
would be ablle to assume that a CompileUnit is always available in the DWZ case 
(?).

This duality does make me think that we'd be better off in not adding the 
CompileUnit arguments and encoding everything into a user_id_t. However, I am 
not sure if we really have a choice here -- it may be that this information is 
so complex that it will not be possible to reasonably encode it into 64 bits.

PS. It would be easier to evaluate this if this was based on master instead of 
some patch which is taking the source in the direction we don't want to go it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73206



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


[Lldb-commits] [PATCH] D73860: [lldb/StringPrinter] Avoid reading garbage in uninitialized strings

2020-02-05 Thread Vedant Kumar via Phabricator via lldb-commits
vsk updated this revision to Diff 242661.
vsk marked 4 inline comments as done.
vsk added a comment.

- `s/cap/capacity/`
- Remove the `checkedAdd` pointer overflow check as it's not necessary.


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

https://reviews.llvm.org/D73860

Files:
  
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
  
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp
  lldb/source/DataFormatters/StringPrinter.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp

Index: lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
@@ -8,7 +8,6 @@
 
 #include "LibCxx.h"
 
-#include "llvm/ADT/ScopeExit.h"
 #include "lldb/Core/Debugger.h"
 #include "lldb/Core/FormatEntity.h"
 #include "lldb/Core/ValueObject.h"
@@ -527,6 +526,17 @@
 size = (layout == eLibcxxStringLayoutModeDSC)
? size_mode_value
: ((size_mode_value >> 1) % 256);
+
+// When the small-string optimization takes place, the data must fit in the
+// inline string buffer (23 bytes on x86_64/Darwin). If it doesn't, it's
+// likely that the string isn't initialized and we're reading garbage.
+ExecutionContext exe_ctx(location_sp->GetExecutionContextRef());
+const llvm::Optional max_bytes =
+location_sp->GetCompilerType().GetByteSize(
+exe_ctx.GetBestExecutionContextScope());
+if (!max_bytes || size > *max_bytes)
+  return false;
+
 return (location_sp.get() != nullptr);
   } else {
 ValueObjectSP l(D->GetChildAtIndex(0, true));
@@ -537,9 +547,15 @@
   ? layout_decider
   : l->GetChildAtIndex(2, true);
 ValueObjectSP size_vo(l->GetChildAtIndex(1, true));
-if (!size_vo || !location_sp)
+const unsigned capacity_index =
+(layout == eLibcxxStringLayoutModeDSC) ? 2 : 0;
+ValueObjectSP capacity_vo(l->GetChildAtIndex(capacity_index, true));
+if (!size_vo || !location_sp || !capacity_vo)
+  return false;
+size = size_vo->GetValueAsUnsigned(LLDB_INVALID_OFFSET);
+const uint64_t cap = capacity_vo->GetValueAsUnsigned(LLDB_INVALID_OFFSET);
+if (size == LLDB_INVALID_OFFSET || cap == LLDB_INVALID_OFFSET || cap < size)
   return false;
-size = size_vo->GetValueAsUnsigned(0);
 return true;
   }
 }
@@ -569,7 +585,9 @@
   options.SetIsTruncated(true);
 }
   }
-  location_sp->GetPointeeData(extractor, 0, size);
+  const size_t bytes_read = location_sp->GetPointeeData(extractor, 0, size);
+  if (bytes_read < size)
+return false;
 
   // std::wstring::size() is measured in 'characters', not bytes
   TypeSystemClang *ast_context =
@@ -591,41 +609,33 @@
 
   switch (*wchar_t_size) {
   case 1:
-StringPrinter::ReadBufferAndDumpToStream<
+return StringPrinter::ReadBufferAndDumpToStream<
 lldb_private::formatters::StringPrinter::StringElementType::UTF8>(
 options);
 break;
 
   case 2:
-lldb_private::formatters::StringPrinter::ReadBufferAndDumpToStream<
+return StringPrinter::ReadBufferAndDumpToStream<
 lldb_private::formatters::StringPrinter::StringElementType::UTF16>(
 options);
 break;
 
   case 4:
-lldb_private::formatters::StringPrinter::ReadBufferAndDumpToStream<
+return StringPrinter::ReadBufferAndDumpToStream<
 lldb_private::formatters::StringPrinter::StringElementType::UTF32>(
 options);
-break;
-
-  default:
-stream.Printf("size for wchar_t is not valid");
-return true;
   }
-
-  return true;
+  return false;
 }
 
 template 
 bool LibcxxStringSummaryProvider(ValueObject , Stream ,
  const TypeSummaryOptions _options,
- std::string prefix_token = "") {
+ std::string prefix_token) {
   uint64_t size = 0;
   ValueObjectSP location_sp;
-
   if (!ExtractLibcxxStringInfo(valobj, location_sp, size))
 return false;
-
   if (size == 0) {
 stream.Printf("\"\"");
 return true;
@@ -644,7 +654,9 @@
   options.SetIsTruncated(true);
 }
   }
-  location_sp->GetPointeeData(extractor, 0, size);
+  const size_t bytes_read = location_sp->GetPointeeData(extractor, 0, size);
+  if (bytes_read < size)
+return false;
 
   options.SetData(extractor);
   options.SetStream();
@@ -657,28 +669,40 @@
   options.SetQuote('"');
   options.SetSourceSize(size);
   options.SetBinaryZeroIsTerminator(false);
-  StringPrinter::ReadBufferAndDumpToStream(options);
+  return StringPrinter::ReadBufferAndDumpToStream(options);
+}
 
+template 
+static bool formatStringImpl(ValueObject , Stream ,
+ const TypeSummaryOptions _options,
+

[Lldb-commits] [PATCH] D73952: [lldb] Ignore type sugar in TypeSystemClang::GetPointerType

2020-02-05 Thread Davide Italiano via Phabricator via lldb-commits
davide added a comment.

Good catch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73952



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


[Lldb-commits] [PATCH] D74010: Fix BroadcasterManager::RemoveListener to really remove the listener

2020-02-05 Thread Adrian McCarthy via Phabricator via lldb-commits
amccarth added a comment.

Wow, cool bug.

It's too bad the original code re-used an iterator variable instead of make a 
new name (which would have helped the compiler find the problem).  Note that 
the one they used is shadowed just a couple lines later.

It's too bad the original code feels it's necessary to create iter and end_iter 
up front.  I know raw loops require this trick to avoid re-computing the end 
iterator on each iteration through the loop, but that shouldn't be necessary on 
algorithms like `find_if`.

It's too bad that erase with an end iterator isn't just a safe no-op, so that 
zillions of callers aren't required to check find's return value.  Without the 
visual noise, it would be easier to write exactly what you want.

It's too bad the compiler cannot recognize that `find_if` has no side effects 
and thus ignoring its return value makes the statement a no-op.

It's too bad the `std::erase(std::remove_if(...))` idiom is so cumbersome.  I 
realize that would likely be overkill here, since you apparently want to erase 
just the first one that matches the predicate.  Nonetheless, it would be harder 
to make this kind of bug.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74010



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


[Lldb-commits] [PATCH] D73665: Stop emitting a breakpoint for each location in a breakpoint when responding to breakpoint commands.

2020-02-05 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Sorry about the delay. I think this is better, but the handling 
of`eBreakpointEventTypeLocationsAdded/Removed` it still does not seem 
completely right. Though I don't really understand how VSCode works, if my 
understanding that we are now creating a "vscode" breakpoint for each "lldb 
breakpoint" (instead of breakpoint _location_) is correct, then it seems that 
we should treat the "vscode breakpoint" enabled as long as the lldb breakpoint 
has at least one location.

However, that's not what the code does now, I think. Whenever a single location 
disappears (eBreakpointEventTypeLocationsRemoved), e.g. in response to a shared 
library unloading, we will set the `reason=removed` packet, even if other 
locations remain. I think that we should send the "removed" message only when 
the location count goes down to zero (and send the "new" packet whenever it 
goes non-zero).

Am I misunderstanding something?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73665



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


[Lldb-commits] [PATCH] D73303: [lldb/Target] Add Assert StackFrame Recognizer

2020-02-05 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib added inline comments.



Comment at: lldb/source/Target/StackFrameRecognizer.cpp:95
 const SymbolContext  =
-frame->GetSymbolContext(eSymbolContextModule | eSymbolContextFunction);
+frame->GetSymbolContext(eSymbolContextEverything);
 ConstString function_name = symctx.GetFunctionName();

friss wrote:
> What's the reason of this change?
In line 101, lldb tries to get the symbol from the symbol context. If the 
symbol was not populated in the SymbolContext before calling 
`GetRecognizerForFrame` then it's null and the function returns a 
`StackFrameRecognizerSP`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73303



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


[Lldb-commits] [PATCH] D73303: [lldb/Target] Add Assert StackFrame Recognizer

2020-02-05 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 242634.
mib marked 5 inline comments as done.
mib added a comment.

Fixed the corrupted stop reason description.
Fixed linux support for public symbols.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73303

Files:
  lldb/docs/use/formatting.rst
  lldb/include/lldb/Core/FormatEntity.h
  lldb/include/lldb/Target/AssertFrameRecognizer.h
  lldb/include/lldb/Target/StackFrameRecognizer.h
  lldb/include/lldb/Target/Thread.h
  
lldb/packages/Python/lldbsuite/test/functionalities/inferior-assert/TestInferiorAssert.py
  lldb/packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py
  lldb/source/API/SBThread.cpp
  lldb/source/Core/FormatEntity.cpp
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
  lldb/source/Target/AssertFrameRecognizer.cpp
  lldb/source/Target/CMakeLists.txt
  lldb/source/Target/Process.cpp
  lldb/source/Target/StackFrameRecognizer.cpp
  lldb/source/Target/Thread.cpp
  lldb/test/Shell/Recognizer/Inputs/assert.c
  lldb/test/Shell/Recognizer/assert.test

Index: lldb/test/Shell/Recognizer/assert.test
===
--- /dev/null
+++ lldb/test/Shell/Recognizer/assert.test
@@ -0,0 +1,13 @@
+# UNSUPPORTED: system-windows
+# RUN: %clang_host -g -O0 %S/Inputs/assert.c -o %t.out
+# RUN: %lldb -b -s %s %t.out | FileCheck %s
+run
+# CHECK: thread #{{.*}}stop reason = hit program assert
+frame info
+# CHECK: frame #{{.*}}`main at assert.c
+frame recognizer info 0
+# CHECK: frame 0 is recognized by Assert StackFrame Recognizer
+set set thread-format "{${thread.stop-reason-raw}}\n"
+thread info
+# CHECK: signal SIGABRT
+q
Index: lldb/test/Shell/Recognizer/Inputs/assert.c
===
--- /dev/null
+++ lldb/test/Shell/Recognizer/Inputs/assert.c
@@ -0,0 +1,9 @@
+#include 
+
+int main() {
+  int a = 42;
+  assert(a == 42);
+  a--;
+  assert(a == 42);
+  return 0;
+}
Index: lldb/source/Target/Thread.cpp
===
--- lldb/source/Target/Thread.cpp
+++ lldb/source/Target/Thread.cpp
@@ -573,9 +573,64 @@
   m_state = state;
 }
 
+std::string Thread::GetStopDescription() {
+  StackFrameSP frame_sp = GetStackFrameAtIndex(0);
+
+  if (!frame_sp)
+return GetStopDescriptionRaw();
+
+  auto recognized_frame_sp = frame_sp->GetRecognizedFrame();
+
+  if (!recognized_frame_sp)
+return GetStopDescriptionRaw();
+
+  std::string recognized_stop_description =
+  recognized_frame_sp->GetStopDescription();
+
+  if (!recognized_stop_description.empty())
+return recognized_stop_description;
+
+  return GetStopDescriptionRaw();
+}
+
+std::string Thread::GetStopDescriptionRaw() {
+  StopInfoSP stop_info_sp = GetStopInfo();
+  std::string raw_stop_description;
+  if (stop_info_sp && stop_info_sp->IsValid())
+raw_stop_description = stop_info_sp->GetDescription();
+  return raw_stop_description;
+}
+
+void Thread::SelectMostRelevantFrame() {
+  Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD);
+
+  auto frames_list_sp = GetStackFrameList();
+
+  // Only the top frame should be recognized.
+  auto frame_sp = frames_list_sp->GetFrameAtIndex(0);
+
+  auto recognized_frame_sp = frame_sp->GetRecognizedFrame();
+
+  if (!recognized_frame_sp) {
+LLDB_LOG(log, "Frame #0 not recognized");
+return;
+  }
+
+  if (StackFrameSP most_relevant_frame_sp =
+  recognized_frame_sp->GetMostRelevantFrame()) {
+LLDB_LOG(log, "Found most relevant frame at index {0}",
+ most_relevant_frame_sp->GetFrameIndex());
+SetSelectedFrame(most_relevant_frame_sp.get());
+  } else {
+LLDB_LOG(log, "No relevant frame!");
+  }
+}
+
 void Thread::WillStop() {
   ThreadPlan *current_plan = GetCurrentPlan();
 
+  SelectMostRelevantFrame();
+
   // FIXME: I may decide to disallow threads with no plans.  In which
   // case this should go to an assert.
 
Index: lldb/source/Target/StackFrameRecognizer.cpp
===
--- lldb/source/Target/StackFrameRecognizer.cpp
+++ lldb/source/Target/StackFrameRecognizer.cpp
@@ -92,8 +92,8 @@
   }
 
   StackFrameRecognizerSP GetRecognizerForFrame(StackFrameSP frame) {
-const SymbolContext  =
-frame->GetSymbolContext(eSymbolContextModule | eSymbolContextFunction);
+const SymbolContext  = frame->GetSymbolContext(
+eSymbolContextModule | eSymbolContextFunction | eSymbolContextSymbol);
 ConstString function_name = symctx.GetFunctionName();
 ModuleSP module_sp = symctx.module_sp;
 if (!module_sp) return StackFrameRecognizerSP();
Index: lldb/source/Target/Process.cpp
===
--- lldb/source/Target/Process.cpp
+++ lldb/source/Target/Process.cpp
@@ -38,6 +38,7 @@
 #include 

[Lldb-commits] [PATCH] D73303: [lldb/Target] Add Assert StackFrame Recognizer

2020-02-05 Thread Med Ismail Bennani via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2b7f32892b76: [lldb/Target] Add Assert StackFrame Recognizer 
(authored by mib).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73303

Files:
  lldb/docs/use/formatting.rst
  lldb/include/lldb/Core/FormatEntity.h
  lldb/include/lldb/Target/AssertFrameRecognizer.h
  lldb/include/lldb/Target/StackFrameRecognizer.h
  lldb/include/lldb/Target/Thread.h
  
lldb/packages/Python/lldbsuite/test/functionalities/inferior-assert/TestInferiorAssert.py
  lldb/packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py
  lldb/source/API/SBThread.cpp
  lldb/source/Core/FormatEntity.cpp
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
  lldb/source/Target/AssertFrameRecognizer.cpp
  lldb/source/Target/CMakeLists.txt
  lldb/source/Target/Process.cpp
  lldb/source/Target/StackFrameRecognizer.cpp
  lldb/source/Target/Thread.cpp
  lldb/test/Shell/Recognizer/Inputs/assert.c
  lldb/test/Shell/Recognizer/assert.test

Index: lldb/test/Shell/Recognizer/assert.test
===
--- /dev/null
+++ lldb/test/Shell/Recognizer/assert.test
@@ -0,0 +1,13 @@
+# UNSUPPORTED: system-windows
+# RUN: %clang_host -g -O0 %S/Inputs/assert.c -o %t.out
+# RUN: %lldb -b -s %s %t.out | FileCheck %s
+run
+# CHECK: thread #{{.*}}stop reason = hit program assert
+frame info
+# CHECK: frame #{{.*}}`main at assert.c
+frame recognizer info 0
+# CHECK: frame 0 is recognized by Assert StackFrame Recognizer
+set set thread-format "{${thread.stop-reason-raw}}\n"
+thread info
+# CHECK: signal SIGABRT
+q
Index: lldb/test/Shell/Recognizer/Inputs/assert.c
===
--- /dev/null
+++ lldb/test/Shell/Recognizer/Inputs/assert.c
@@ -0,0 +1,9 @@
+#include 
+
+int main() {
+  int a = 42;
+  assert(a == 42);
+  a--;
+  assert(a == 42);
+  return 0;
+}
Index: lldb/source/Target/Thread.cpp
===
--- lldb/source/Target/Thread.cpp
+++ lldb/source/Target/Thread.cpp
@@ -573,9 +573,64 @@
   m_state = state;
 }
 
+std::string Thread::GetStopDescription() {
+  StackFrameSP frame_sp = GetStackFrameAtIndex(0);
+
+  if (!frame_sp)
+return GetStopDescriptionRaw();
+
+  auto recognized_frame_sp = frame_sp->GetRecognizedFrame();
+
+  if (!recognized_frame_sp)
+return GetStopDescriptionRaw();
+
+  std::string recognized_stop_description =
+  recognized_frame_sp->GetStopDescription();
+
+  if (!recognized_stop_description.empty())
+return recognized_stop_description;
+
+  return GetStopDescriptionRaw();
+}
+
+std::string Thread::GetStopDescriptionRaw() {
+  StopInfoSP stop_info_sp = GetStopInfo();
+  std::string raw_stop_description;
+  if (stop_info_sp && stop_info_sp->IsValid())
+raw_stop_description = stop_info_sp->GetDescription();
+  return raw_stop_description;
+}
+
+void Thread::SelectMostRelevantFrame() {
+  Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD);
+
+  auto frames_list_sp = GetStackFrameList();
+
+  // Only the top frame should be recognized.
+  auto frame_sp = frames_list_sp->GetFrameAtIndex(0);
+
+  auto recognized_frame_sp = frame_sp->GetRecognizedFrame();
+
+  if (!recognized_frame_sp) {
+LLDB_LOG(log, "Frame #0 not recognized");
+return;
+  }
+
+  if (StackFrameSP most_relevant_frame_sp =
+  recognized_frame_sp->GetMostRelevantFrame()) {
+LLDB_LOG(log, "Found most relevant frame at index {0}",
+ most_relevant_frame_sp->GetFrameIndex());
+SetSelectedFrame(most_relevant_frame_sp.get());
+  } else {
+LLDB_LOG(log, "No relevant frame!");
+  }
+}
+
 void Thread::WillStop() {
   ThreadPlan *current_plan = GetCurrentPlan();
 
+  SelectMostRelevantFrame();
+
   // FIXME: I may decide to disallow threads with no plans.  In which
   // case this should go to an assert.
 
Index: lldb/source/Target/StackFrameRecognizer.cpp
===
--- lldb/source/Target/StackFrameRecognizer.cpp
+++ lldb/source/Target/StackFrameRecognizer.cpp
@@ -92,8 +92,8 @@
   }
 
   StackFrameRecognizerSP GetRecognizerForFrame(StackFrameSP frame) {
-const SymbolContext  =
-frame->GetSymbolContext(eSymbolContextModule | eSymbolContextFunction);
+const SymbolContext  = frame->GetSymbolContext(
+eSymbolContextModule | eSymbolContextFunction | eSymbolContextSymbol);
 ConstString function_name = symctx.GetFunctionName();
 ModuleSP module_sp = symctx.module_sp;
 if (!module_sp) return StackFrameRecognizerSP();
Index: lldb/source/Target/Process.cpp
===
--- lldb/source/Target/Process.cpp
+++ lldb/source/Target/Process.cpp
@@ -38,6 +38,7 @@
 #include "lldb/Symbol/Function.h"
 #include 

[Lldb-commits] [PATCH] D73787: [NFC] Refactor `GetDWARFDeclContext` to return `DWARFDeclContext`

2020-02-05 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.

Yes, I agree this is better.

One way to this could be improved further is to change the recursion in 
`GetDWARFDeclContext` into a loop (then you wouldn't need the extra wrapper).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73787



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


[Lldb-commits] [lldb] 2b7f328 - [lldb/Target] Add Assert StackFrame Recognizer

2020-02-05 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2020-02-05T17:49:13+01:00
New Revision: 2b7f32892b76cdfbe075300a5bf4a52e1b674bc7

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

LOG: [lldb/Target] Add Assert StackFrame Recognizer

When a thread stops, this checks depending on the platform if the top frame is
an abort stack frame. If so, it looks for an assert stack frame in the upper
frames and set it as the most relavant frame when found.

To do so, the StackFrameRecognizer class holds a "Most Relevant Frame" and a
"cooked" stop reason description. When the thread is about to stop, it checks
if the current frame is recognized, and if so, it fetches the recognized frame's
attributes and applies them.

rdar://58528686

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

Signed-off-by: Med Ismail Bennani 

Added: 
lldb/include/lldb/Target/AssertFrameRecognizer.h
lldb/source/Target/AssertFrameRecognizer.cpp
lldb/test/Shell/Recognizer/Inputs/assert.c
lldb/test/Shell/Recognizer/assert.test

Modified: 
lldb/docs/use/formatting.rst
lldb/include/lldb/Core/FormatEntity.h
lldb/include/lldb/Target/StackFrameRecognizer.h
lldb/include/lldb/Target/Thread.h

lldb/packages/Python/lldbsuite/test/functionalities/inferior-assert/TestInferiorAssert.py

lldb/packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py
lldb/source/API/SBThread.cpp
lldb/source/Core/FormatEntity.cpp

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
lldb/source/Target/CMakeLists.txt
lldb/source/Target/Process.cpp
lldb/source/Target/StackFrameRecognizer.cpp
lldb/source/Target/Thread.cpp

Removed: 




diff  --git a/lldb/docs/use/formatting.rst b/lldb/docs/use/formatting.rst
index 939c4e18f749..e2644d50217b 100644
--- a/lldb/docs/use/formatting.rst
+++ b/lldb/docs/use/formatting.rst
@@ -134,7 +134,9 @@ A complete list of currently supported format string 
variables is listed below:
 
+---+-+
 | ``thread.queue``  | The queue name of the 
thread if the target OS supports dispatch queues


  |
 
+---+-+
-| ``thread.stop-reason``| A textual reason each 
thread stopped  


  |
+| ``thread.stop-reason``| A textual reason why the 
thread stopped. If the thread have a recognized frame, this displays its 
recognized stop reason. Otherwise, gets the stop info description.  

  |
++---+-+
+| ``thread.stop-reason-raw``| A textual reason why the 
thread stopped. Always returns stop info description.   


   |
 
+---+-+
 | ``thread.return-value``   

[Lldb-commits] [lldb] 706256b - [lldb] Revert some change in data-formatter-objc/main.m that broke TestDataFormatterObjCNSDate.py

2020-02-05 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-02-05T14:08:57+01:00
New Revision: 706256b6d3972dcfa2d3e888d0640e1689c4be95

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

LOG: [lldb] Revert some change in data-formatter-objc/main.m that broke 
TestDataFormatterObjCNSDate.py

Changing the date2 to an timezone independent value broke the test as the data 
formatters
uses the current time zone for the summary (so changing it to a time zone 
independent value
would again break the test in some time zones). We anyway just care about this 
for date2
which will be printed in a timezone-independent summary.

Added: 


Modified: 

lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/main.m

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/main.m
 
b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/main.m
index 81ac2185314a..d0fa27570973 100644
--- 
a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/main.m
+++ 
b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/main.m
@@ -502,7 +502,7 @@ int main (int argc, const char * argv[])
NSURL *nsurl3 = [NSURL URLWithString:@"?whatever" 
relativeToURL:nsurl2];
 
NSDate *date1 = [NSDate 
dateWithTimeIntervalSince1970:133890*60*60]; // 6pm April 10, 1985 GMT
-   NSDate *date2 = [NSDate 
dateWithTimeIntervalSince1970:14975*24*60*60]; // 12am January 1, 2011 GMT
+   NSDate *date2 = [NSDate dateWithNaturalLanguageString:@"12am 
January 1, 2011"];
NSDate *date3 = [NSDate date];
NSDate *date4 = [NSDate dateWithTimeIntervalSince1970:24*60*60];
 NSDate *date5 = [NSDate dateWithTimeIntervalSinceReferenceDate: 
floor([[NSDate date] timeIntervalSinceReferenceDate])];



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


[Lldb-commits] [lldb] 7506ca3 - [lldb][NFC] Remove some unnecessary curly braces

2020-02-05 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-02-05T13:47:09+01:00
New Revision: 7506ca3e8ccb75620a1987749f80d22bc87f246c

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

LOG: [lldb][NFC] Remove some unnecessary curly braces

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index f86460a3adac..0d640819ff28 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -1959,135 +1959,133 @@ bool DWARFASTParserClang::CompleteRecordType(const 
DWARFDIE ,
 
   ClangASTImporter::LayoutInfo layout_info;
 
-  {
-if (die.HasChildren()) {
-  LanguageType class_language = eLanguageTypeUnknown;
-  if (TypeSystemClang::IsObjCObjectOrInterfaceType(clang_type)) {
-class_language = eLanguageTypeObjC;
-// For objective C we don't start the definition when the class is
-// created.
-TypeSystemClang::StartTagDeclarationDefinition(clang_type);
-  }
-
-  int tag_decl_kind = -1;
-  AccessType default_accessibility = eAccessNone;
-  if (tag == DW_TAG_structure_type) {
-tag_decl_kind = clang::TTK_Struct;
-default_accessibility = eAccessPublic;
-  } else if (tag == DW_TAG_union_type) {
-tag_decl_kind = clang::TTK_Union;
-default_accessibility = eAccessPublic;
-  } else if (tag == DW_TAG_class_type) {
-tag_decl_kind = clang::TTK_Class;
-default_accessibility = eAccessPrivate;
-  }
-
-  std::vector> bases;
-  std::vector member_accessibilities;
-  bool is_a_class = false;
-  // Parse members and base classes first
-  std::vector member_function_dies;
-
-  DelayedPropertyList delayed_properties;
-  ParseChildMembers(die, clang_type, class_language, bases,
-member_accessibilities, member_function_dies,
-delayed_properties, default_accessibility, is_a_class,
-layout_info);
-
-  // Now parse any methods if there were any...
-  for (const DWARFDIE  : member_function_dies)
-dwarf->ResolveType(die);
-
-  if (class_language == eLanguageTypeObjC) {
-ConstString class_name(clang_type.GetTypeName());
-if (class_name) {
-  DIEArray method_die_offsets;
-  dwarf->GetObjCMethodDIEOffsets(class_name, method_die_offsets);
-
-  if (!method_die_offsets.empty()) {
-DWARFDebugInfo *debug_info = dwarf->DebugInfo();
-
-const size_t num_matches = method_die_offsets.size();
-for (size_t i = 0; i < num_matches; ++i) {
-  const DIERef _ref = method_die_offsets[i];
-  DWARFDIE method_die = debug_info->GetDIE(die_ref);
-
-  if (method_die)
-method_die.ResolveType();
-}
+  if (die.HasChildren()) {
+LanguageType class_language = eLanguageTypeUnknown;
+if (TypeSystemClang::IsObjCObjectOrInterfaceType(clang_type)) {
+  class_language = eLanguageTypeObjC;
+  // For objective C we don't start the definition when the class is
+  // created.
+  TypeSystemClang::StartTagDeclarationDefinition(clang_type);
+}
+
+int tag_decl_kind = -1;
+AccessType default_accessibility = eAccessNone;
+if (tag == DW_TAG_structure_type) {
+  tag_decl_kind = clang::TTK_Struct;
+  default_accessibility = eAccessPublic;
+} else if (tag == DW_TAG_union_type) {
+  tag_decl_kind = clang::TTK_Union;
+  default_accessibility = eAccessPublic;
+} else if (tag == DW_TAG_class_type) {
+  tag_decl_kind = clang::TTK_Class;
+  default_accessibility = eAccessPrivate;
+}
+
+std::vector> bases;
+std::vector member_accessibilities;
+bool is_a_class = false;
+// Parse members and base classes first
+std::vector member_function_dies;
+
+DelayedPropertyList delayed_properties;
+ParseChildMembers(die, clang_type, class_language, bases,
+  member_accessibilities, member_function_dies,
+  delayed_properties, default_accessibility, is_a_class,
+  layout_info);
+
+// Now parse any methods if there were any...
+for (const DWARFDIE  : member_function_dies)
+  dwarf->ResolveType(die);
+
+if (class_language == eLanguageTypeObjC) {
+  ConstString class_name(clang_type.GetTypeName());
+  if (class_name) {
+DIEArray method_die_offsets;
+dwarf->GetObjCMethodDIEOffsets(class_name, method_die_offsets);
+
+if (!method_die_offsets.empty()) {
+  

[Lldb-commits] [PATCH] D73802: [lldb] Introduce i386 support in NetBSD Process plugin

2020-02-05 Thread Michał Górny via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5cc817be7501: [lldb] Introduce i386 support in NetBSD 
Process plugin (authored by mgorny).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73802

Files:
  lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp
  lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h
  lldb/source/Plugins/Process/Utility/CMakeLists.txt
  lldb/source/Plugins/Process/Utility/RegisterContextNetBSD_i386.cpp
  lldb/source/Plugins/Process/Utility/RegisterContextNetBSD_i386.h
  lldb/source/Plugins/Process/Utility/RegisterInfos_i386.h
  lldb/source/Plugins/Process/Utility/lldb-x86-register-enums.h

Index: lldb/source/Plugins/Process/Utility/lldb-x86-register-enums.h
===
--- lldb/source/Plugins/Process/Utility/lldb-x86-register-enums.h
+++ lldb/source/Plugins/Process/Utility/lldb-x86-register-enums.h
@@ -113,7 +113,8 @@
   lldb_bndstatus_i386,
   k_last_mpxc_i386 = lldb_bndstatus_i386,
 
-  lldb_dr0_i386,
+  k_first_dbr_i386,
+  lldb_dr0_i386 = k_first_dbr_i386,
   lldb_dr1_i386,
   lldb_dr2_i386,
   lldb_dr3_i386,
@@ -121,6 +122,7 @@
   lldb_dr5_i386,
   lldb_dr6_i386,
   lldb_dr7_i386,
+  k_last_dbr_i386 = lldb_dr7_i386,
 
   k_num_registers_i386,
   k_num_gpr_registers_i386 = k_last_gpr_i386 - k_first_gpr_i386 + 1,
@@ -131,6 +133,7 @@
   k_num_fpr_registers_i386 +
   k_num_avx_registers_i386 +
   k_num_mpx_registers_i386,
+  k_num_dbr_registers_i386 = k_last_dbr_i386 - k_first_dbr_i386 + 1,
 };
 
 // Internal codes for all x86_64 registers.
Index: lldb/source/Plugins/Process/Utility/RegisterInfos_i386.h
===
--- lldb/source/Plugins/Process/Utility/RegisterInfos_i386.h
+++ lldb/source/Plugins/Process/Utility/RegisterInfos_i386.h
@@ -145,7 +145,7 @@
 DR_OFFSET(i), eEncodingUint, eFormatHex,   \
   {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,   \
LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,   \
-   LLDB_INVALID_REGNUM },  \
+   lldb_##reg##i##_i386 }, \
nullptr, nullptr, nullptr, 0\
   }
 
Index: lldb/source/Plugins/Process/Utility/RegisterContextNetBSD_i386.h
===
--- /dev/null
+++ lldb/source/Plugins/Process/Utility/RegisterContextNetBSD_i386.h
@@ -0,0 +1,25 @@
+//===-- RegisterContextNetBSD_i386.h *- C++ -*-===//
+//
+// 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
+//
+//===--===//
+
+#ifndef liblldb_RegisterContextNetBSD_i386_H_
+#define liblldb_RegisterContextNetBSD_i386_H_
+
+#include "RegisterInfoInterface.h"
+
+class RegisterContextNetBSD_i386 : public lldb_private::RegisterInfoInterface {
+public:
+  RegisterContextNetBSD_i386(const lldb_private::ArchSpec _arch);
+
+  size_t GetGPRSize() const override;
+
+  const lldb_private::RegisterInfo *GetRegisterInfo() const override;
+
+  uint32_t GetRegisterCount() const override;
+};
+
+#endif
Index: lldb/source/Plugins/Process/Utility/RegisterContextNetBSD_i386.cpp
===
--- /dev/null
+++ lldb/source/Plugins/Process/Utility/RegisterContextNetBSD_i386.cpp
@@ -0,0 +1,96 @@
+//===-- RegisterContextNetBSD_i386.cpp -*- C++ -*-===//
+//
+// 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 "RegisterContextNetBSD_i386.h"
+#include "RegisterContextPOSIX_x86.h"
+
+using namespace lldb_private;
+using namespace lldb;
+
+// this needs to match 'struct reg'
+struct GPR {
+  uint32_t eax;
+  uint32_t ecx;
+  uint32_t edx;
+  uint32_t ebx;
+  uint32_t esp;
+  uint32_t ebp;
+  uint32_t esi;
+  uint32_t edi;
+  uint32_t eip;
+  uint32_t eflags;
+  uint32_t cs;
+  uint32_t ss;
+  uint32_t ds;
+  uint32_t es;
+  uint32_t fs;
+  uint32_t gs;
+};
+
+struct FPR_i386 {
+  uint16_t fctrl; // FPU Control Word (fcw)
+  uint16_t fstat; // FPU Status Word (fsw)
+  uint16_t ftag;  // FPU Tag Word (ftw)
+  uint16_t fop;   // Last Instruction Opcode (fop)
+  

[Lldb-commits] [PATCH] D74038: [lldb] Make TestDataFormatterObjCCF.py pass outside California

2020-02-05 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8d8bd0d6548e: [lldb] Make TestDataFormatterObjCCF.py pass 
outside California (authored by teemperor).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74038

Files:
  
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCCF.py
  
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/main.m


Index: 
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/main.m
===
--- 
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/main.m
+++ 
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/main.m
@@ -501,8 +501,8 @@
NSURL *nsurl2 = [NSURL URLWithString:@"page.html" 
relativeToURL:nsurl];
NSURL *nsurl3 = [NSURL URLWithString:@"?whatever" 
relativeToURL:nsurl2];
 
-   NSDate *date1 = [NSDate dateWithNaturalLanguageString:@"6pm 
April 10, 1985"];
-   NSDate *date2 = [NSDate dateWithNaturalLanguageString:@"12am 
January 1, 2011"];
+   NSDate *date1 = [NSDate 
dateWithTimeIntervalSince1970:133890*60*60]; // 6pm April 10, 1985 GMT
+   NSDate *date2 = [NSDate 
dateWithTimeIntervalSince1970:14975*24*60*60]; // 12am January 1, 2011 GMT
NSDate *date3 = [NSDate date];
NSDate *date4 = [NSDate dateWithTimeIntervalSince1970:24*60*60];
 NSDate *date5 = [NSDate dateWithTimeIntervalSinceReferenceDate: 
floor([[NSDate date] timeIntervalSinceReferenceDate])];
Index: 
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCCF.py
===
--- 
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCCF.py
+++ 
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCCF.py
@@ -31,7 +31,7 @@
 # check formatters for common Objective-C types
 expect_strings = [
 '(CFGregorianUnits) cf_greg_units = 1 years, 3 months, 5 days, 12 
hours, 5 minutes 7 seconds',
-'(CFGregorianDate) cf_greg_date = @"4/11/1985 2:0:0"',
+'(CFGregorianDate) cf_greg_date = @"4/10/1985 18:0:0"',
 '(CFRange) cf_range = location=4 length=4',
 '(NSPoint) ns_point = (x = 4, y = 4)',
 '(NSRange) ns_range = location=4, length=4',


Index: lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/main.m
===
--- lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/main.m
+++ lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/main.m
@@ -501,8 +501,8 @@
 	NSURL *nsurl2 = [NSURL URLWithString:@"page.html" relativeToURL:nsurl];
 	NSURL *nsurl3 = [NSURL URLWithString:@"?whatever" relativeToURL:nsurl2];
 
-		NSDate *date1 = [NSDate dateWithNaturalLanguageString:@"6pm April 10, 1985"];
-		NSDate *date2 = [NSDate dateWithNaturalLanguageString:@"12am January 1, 2011"];
+		NSDate *date1 = [NSDate dateWithTimeIntervalSince1970:133890*60*60]; // 6pm April 10, 1985 GMT
+		NSDate *date2 = [NSDate dateWithTimeIntervalSince1970:14975*24*60*60]; // 12am January 1, 2011 GMT
 		NSDate *date3 = [NSDate date];
 		NSDate *date4 = [NSDate dateWithTimeIntervalSince1970:24*60*60];
 NSDate *date5 = [NSDate dateWithTimeIntervalSinceReferenceDate: floor([[NSDate date] timeIntervalSinceReferenceDate])];
Index: lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCCF.py
===
--- lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCCF.py
+++ lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCCF.py
@@ -31,7 +31,7 @@
 # check formatters for common Objective-C types
 expect_strings = [
 '(CFGregorianUnits) cf_greg_units = 1 years, 3 months, 5 days, 12 hours, 5 minutes 7 seconds',
-'(CFGregorianDate) cf_greg_date = @"4/11/1985 2:0:0"',
+'(CFGregorianDate) cf_greg_date = @"4/10/1985 18:0:0"',
 '(CFRange) cf_range = location=4 length=4',
 '(NSPoint) ns_point = (x = 4, y = 4)',
 '(NSRange) ns_range = location=4, length=4',
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 8d8bd0d - [lldb] Make TestDataFormatterObjCCF.py pass outside California

2020-02-05 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-02-05T13:24:06+01:00
New Revision: 8d8bd0d6548ed9d2482de341c1b0e53449e5c564

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

LOG: [lldb] Make TestDataFormatterObjCCF.py pass outside California

Summary:
This test creates its dates with `NSDate dateWithNaturalLanguageString` which 
is deprecated and uses the current time zone of the machine to
interpret the input string. This causes that the created NSDate has a different 
value depending on the locale of the machine
and we hardcoded the value for California's time zone (PST) but the data 
formatter gives out the GMT value as a string.

This just replaces the use with the timezone-independent 
dateWithTimeIntervalSince1970 (which we also use in the rest of the test)
to make this pass independently of the time zone of the machine running the 
test.

Reviewers: mib

Reviewed By: mib

Subscribers: lldb-commits, JDevlieghere

Tags: #lldb

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

Added: 


Modified: 

lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCCF.py

lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/main.m

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCCF.py
 
b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCCF.py
index 5b82bb6528f3..38e8ae63838b 100644
--- 
a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCCF.py
+++ 
b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCCF.py
@@ -31,7 +31,7 @@ def test_coreframeworks_and_run_command(self):
 # check formatters for common Objective-C types
 expect_strings = [
 '(CFGregorianUnits) cf_greg_units = 1 years, 3 months, 5 days, 12 
hours, 5 minutes 7 seconds',
-'(CFGregorianDate) cf_greg_date = @"4/11/1985 2:0:0"',
+'(CFGregorianDate) cf_greg_date = @"4/10/1985 18:0:0"',
 '(CFRange) cf_range = location=4 length=4',
 '(NSPoint) ns_point = (x = 4, y = 4)',
 '(NSRange) ns_range = location=4, length=4',

diff  --git 
a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/main.m
 
b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/main.m
index aac729c74590..81ac2185314a 100644
--- 
a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/main.m
+++ 
b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/main.m
@@ -501,8 +501,8 @@ int main (int argc, const char * argv[])
NSURL *nsurl2 = [NSURL URLWithString:@"page.html" 
relativeToURL:nsurl];
NSURL *nsurl3 = [NSURL URLWithString:@"?whatever" 
relativeToURL:nsurl2];
 
-   NSDate *date1 = [NSDate dateWithNaturalLanguageString:@"6pm 
April 10, 1985"];
-   NSDate *date2 = [NSDate dateWithNaturalLanguageString:@"12am 
January 1, 2011"];
+   NSDate *date1 = [NSDate 
dateWithTimeIntervalSince1970:133890*60*60]; // 6pm April 10, 1985 GMT
+   NSDate *date2 = [NSDate 
dateWithTimeIntervalSince1970:14975*24*60*60]; // 12am January 1, 2011 GMT
NSDate *date3 = [NSDate date];
NSDate *date4 = [NSDate dateWithTimeIntervalSince1970:24*60*60];
 NSDate *date5 = [NSDate dateWithTimeIntervalSinceReferenceDate: 
floor([[NSDate date] timeIntervalSinceReferenceDate])];



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


[Lldb-commits] [PATCH] D74038: [lldb] Make TestDataFormatterObjCCF.py pass outside California

2020-02-05 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib accepted this revision.
mib added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D74038



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


[Lldb-commits] [PATCH] D74038: [lldb] Make TestDataFormatterObjCCF.py pass outside California

2020-02-05 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
teemperor added a reviewer: mib.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
mib accepted this revision.
mib added a comment.
This revision is now accepted and ready to land.

LGTM!


This test creates its dates with `NSDate dateWithNaturalLanguageString` which 
is deprecated and uses the current time zone of the machine to
interpret the input string. This causes that the created NSDate has a different 
value depending on the locale of the machine
and we hardcoded the value for California's time zone (PST) but the data 
formatter gives out the GMT value as a string.

This just replaces the use with the timezone-independent 
dateWithTimeIntervalSince1970 (which we also use in the rest of the test)
to make this pass independently of the time zone of the machine running the 
test.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D74038

Files:
  
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCCF.py
  
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/main.m


Index: 
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/main.m
===
--- 
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/main.m
+++ 
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/main.m
@@ -501,8 +501,8 @@
NSURL *nsurl2 = [NSURL URLWithString:@"page.html" 
relativeToURL:nsurl];
NSURL *nsurl3 = [NSURL URLWithString:@"?whatever" 
relativeToURL:nsurl2];
 
-   NSDate *date1 = [NSDate dateWithNaturalLanguageString:@"6pm 
April 10, 1985"];
-   NSDate *date2 = [NSDate dateWithNaturalLanguageString:@"12am 
January 1, 2011"];
+   NSDate *date1 = [NSDate 
dateWithTimeIntervalSince1970:133890*60*60]; // 6pm April 10, 1985 GMT
+   NSDate *date2 = [NSDate 
dateWithTimeIntervalSince1970:14975*24*60*60]; // 12am January 1, 2011 GMT
NSDate *date3 = [NSDate date];
NSDate *date4 = [NSDate dateWithTimeIntervalSince1970:24*60*60];
 NSDate *date5 = [NSDate dateWithTimeIntervalSinceReferenceDate: 
floor([[NSDate date] timeIntervalSinceReferenceDate])];
Index: 
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCCF.py
===
--- 
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCCF.py
+++ 
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCCF.py
@@ -31,7 +31,7 @@
 # check formatters for common Objective-C types
 expect_strings = [
 '(CFGregorianUnits) cf_greg_units = 1 years, 3 months, 5 days, 12 
hours, 5 minutes 7 seconds',
-'(CFGregorianDate) cf_greg_date = @"4/11/1985 2:0:0"',
+'(CFGregorianDate) cf_greg_date = @"4/10/1985 18:0:0"',
 '(CFRange) cf_range = location=4 length=4',
 '(NSPoint) ns_point = (x = 4, y = 4)',
 '(NSRange) ns_range = location=4, length=4',


Index: lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/main.m
===
--- lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/main.m
+++ lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/main.m
@@ -501,8 +501,8 @@
 	NSURL *nsurl2 = [NSURL URLWithString:@"page.html" relativeToURL:nsurl];
 	NSURL *nsurl3 = [NSURL URLWithString:@"?whatever" relativeToURL:nsurl2];
 
-		NSDate *date1 = [NSDate dateWithNaturalLanguageString:@"6pm April 10, 1985"];
-		NSDate *date2 = [NSDate dateWithNaturalLanguageString:@"12am January 1, 2011"];
+		NSDate *date1 = [NSDate dateWithTimeIntervalSince1970:133890*60*60]; // 6pm April 10, 1985 GMT
+		NSDate *date2 = [NSDate dateWithTimeIntervalSince1970:14975*24*60*60]; // 12am January 1, 2011 GMT
 		NSDate *date3 = [NSDate date];
 		NSDate *date4 = [NSDate dateWithTimeIntervalSince1970:24*60*60];
 NSDate *date5 = [NSDate dateWithTimeIntervalSinceReferenceDate: floor([[NSDate date] timeIntervalSinceReferenceDate])];
Index: lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCCF.py
===
--- lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCCF.py
+++ lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCCF.py
@@ -31,7 +31,7 @@
 # check formatters for common Objective-C types
 expect_strings = [
 

[Lldb-commits] [PATCH] D73952: [lldb] Ignore type sugar in TypeSystemClang::GetPointerType

2020-02-05 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5ff4f881a777: [lldb] Ignore type sugar in 
TypeSystemClang::GetPointerType (authored by teemperor).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73952

Files:
  
lldb/packages/Python/lldbsuite/test/lang/objc/objc-property/TestObjCProperty.py
  lldb/packages/Python/lldbsuite/test/lang/objc/objc-property/main.m
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp


Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -4259,8 +4259,7 @@
   if (type) {
 clang::QualType qual_type(GetQualType(type));
 
-const clang::Type::TypeClass type_class = qual_type->getTypeClass();
-switch (type_class) {
+switch (qual_type.getDesugaredType(getASTContext())->getTypeClass()) {
 case clang::Type::ObjCObject:
 case clang::Type::ObjCInterface:
   return GetType(getASTContext().getObjCObjectPointerType(qual_type));
Index: lldb/packages/Python/lldbsuite/test/lang/objc/objc-property/main.m
===
--- lldb/packages/Python/lldbsuite/test/lang/objc/objc-property/main.m
+++ lldb/packages/Python/lldbsuite/test/lang/objc/objc-property/main.m
@@ -87,10 +87,13 @@
 }
 @end
 
+typedef BaseClass TypedefBaseClass;
+
 int
 main ()
 {
   BaseClass *mine = [BaseClass baseClassWithBackedInt: 10 andUnbackedInt: 20];
+  TypedefBaseClass *typedefd = mine;
   
   // Set a breakpoint here.
   int nonexistant = mine.nonexistantInt;
Index: 
lldb/packages/Python/lldbsuite/test/lang/objc/objc-property/TestObjCProperty.py
===
--- 
lldb/packages/Python/lldbsuite/test/lang/objc/objc-property/TestObjCProperty.py
+++ 
lldb/packages/Python/lldbsuite/test/lang/objc/objc-property/TestObjCProperty.py
@@ -110,6 +110,11 @@
 self.assertTrue(backed_value.GetValueAsUnsigned(12345)
 == backing_value.GetValueAsUnsigned(23456))
 
+value_from_typedef = frame.EvaluateExpression("typedefd.backedInt", 
False)
+self.assertTrue(value_from_typedef.GetError().Success())
+self.assertEqual(value_from_typedef.GetValueAsUnsigned(12345),
+ backing_value.GetValueAsUnsigned(23456))
+
 unbacked_value = frame.EvaluateExpression("mine.unbackedInt", False)
 unbacked_error = unbacked_value.GetError()
 self.assertTrue(unbacked_error.Success())


Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -4259,8 +4259,7 @@
   if (type) {
 clang::QualType qual_type(GetQualType(type));
 
-const clang::Type::TypeClass type_class = qual_type->getTypeClass();
-switch (type_class) {
+switch (qual_type.getDesugaredType(getASTContext())->getTypeClass()) {
 case clang::Type::ObjCObject:
 case clang::Type::ObjCInterface:
   return GetType(getASTContext().getObjCObjectPointerType(qual_type));
Index: lldb/packages/Python/lldbsuite/test/lang/objc/objc-property/main.m
===
--- lldb/packages/Python/lldbsuite/test/lang/objc/objc-property/main.m
+++ lldb/packages/Python/lldbsuite/test/lang/objc/objc-property/main.m
@@ -87,10 +87,13 @@
 }
 @end
 
+typedef BaseClass TypedefBaseClass;
+
 int
 main ()
 {
   BaseClass *mine = [BaseClass baseClassWithBackedInt: 10 andUnbackedInt: 20];
+  TypedefBaseClass *typedefd = mine;
   
   // Set a breakpoint here.
   int nonexistant = mine.nonexistantInt;
Index: lldb/packages/Python/lldbsuite/test/lang/objc/objc-property/TestObjCProperty.py
===
--- lldb/packages/Python/lldbsuite/test/lang/objc/objc-property/TestObjCProperty.py
+++ lldb/packages/Python/lldbsuite/test/lang/objc/objc-property/TestObjCProperty.py
@@ -110,6 +110,11 @@
 self.assertTrue(backed_value.GetValueAsUnsigned(12345)
 == backing_value.GetValueAsUnsigned(23456))
 
+value_from_typedef = frame.EvaluateExpression("typedefd.backedInt", False)
+self.assertTrue(value_from_typedef.GetError().Success())
+self.assertEqual(value_from_typedef.GetValueAsUnsigned(12345),
+ backing_value.GetValueAsUnsigned(23456))
+
 unbacked_value = frame.EvaluateExpression("mine.unbackedInt", False)
 unbacked_error = unbacked_value.GetError()
 self.assertTrue(unbacked_error.Success())
___
lldb-commits mailing 

[Lldb-commits] [lldb] 5ff4f88 - [lldb] Ignore type sugar in TypeSystemClang::GetPointerType

2020-02-05 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-02-05T11:44:40+01:00
New Revision: 5ff4f881a7774b8ec8d4db40d2a6c95ddd8a5f21

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

LOG: [lldb] Ignore type sugar in TypeSystemClang::GetPointerType

Summary:
Currently having a typedef for ObjC types is breaking member access in LLDB:
```
typedef NSString Str;
NSString *s; s.length; // OK
Str *s; s.length; // Causes: member reference base type 'Str *' (aka 'NSString 
*') is not a structure or union
```

This works for NSString as there the type building from `NSString` -> `NSString 
*` will correctly
build a ObjCObjectPointerType (which is necessary to make member access with a 
dot possible),
but for the typedef the `Str` -> `Str *` conversion will produce an incorrect 
PointerType. The reason
for this is that our check in TypeSystemClang::GetPointerType is not desugaring 
the base type,
which causes that `Str` is not recognised as a type to a `ObjCInterface` as the 
check only sees the
typedef sugar that was put around it. This causes that we fall back to 
constructing a PointerType
instead which does not allow member access with the dot operator.

This patch just changes the check to look at the desugared type instead.

Fixes rdar://17525603

Reviewers: shafik, mib

Reviewed By: mib

Subscribers: mib, JDevlieghere, lldb-commits

Tags: #lldb

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

Added: 


Modified: 

lldb/packages/Python/lldbsuite/test/lang/objc/objc-property/TestObjCProperty.py
lldb/packages/Python/lldbsuite/test/lang/objc/objc-property/main.m
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-property/TestObjCProperty.py
 
b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-property/TestObjCProperty.py
index 3092c3f086a9..4eaef1668ccc 100644
--- 
a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-property/TestObjCProperty.py
+++ 
b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-property/TestObjCProperty.py
@@ -110,6 +110,11 @@ def test_objc_properties(self):
 self.assertTrue(backed_value.GetValueAsUnsigned(12345)
 == backing_value.GetValueAsUnsigned(23456))
 
+value_from_typedef = frame.EvaluateExpression("typedefd.backedInt", 
False)
+self.assertTrue(value_from_typedef.GetError().Success())
+self.assertEqual(value_from_typedef.GetValueAsUnsigned(12345),
+ backing_value.GetValueAsUnsigned(23456))
+
 unbacked_value = frame.EvaluateExpression("mine.unbackedInt", False)
 unbacked_error = unbacked_value.GetError()
 self.assertTrue(unbacked_error.Success())

diff  --git 
a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-property/main.m 
b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-property/main.m
index 8d14759fb384..8c84440adc43 100644
--- a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-property/main.m
+++ b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-property/main.m
@@ -87,10 +87,13 @@ - (int) getAccessCount
 }
 @end
 
+typedef BaseClass TypedefBaseClass;
+
 int
 main ()
 {
   BaseClass *mine = [BaseClass baseClassWithBackedInt: 10 andUnbackedInt: 20];
+  TypedefBaseClass *typedefd = mine;
   
   // Set a breakpoint here.
   int nonexistant = mine.nonexistantInt;

diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 32a52e8100a2..23e9d2172cc9 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -4259,8 +4259,7 @@ 
TypeSystemClang::GetPointerType(lldb::opaque_compiler_type_t type) {
   if (type) {
 clang::QualType qual_type(GetQualType(type));
 
-const clang::Type::TypeClass type_class = qual_type->getTypeClass();
-switch (type_class) {
+switch (qual_type.getDesugaredType(getASTContext())->getTypeClass()) {
 case clang::Type::ObjCObject:
 case clang::Type::ObjCInterface:
   return GetType(getASTContext().getObjCObjectPointerType(qual_type));



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