[Lldb-commits] [PATCH] D63052: [Target] Remove Process::GetObjCLanguageRuntime

2019-06-10 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: include/lldb/Target/ObjCLanguageRuntime.h:202
 
+  static ObjCLanguageRuntime *GetObjCLanguageRuntime(Process &process) {
+return llvm::cast_or_null(

compnerd wrote:
> I think it would be nice to just call this `Get` (and we could have 
> equivalents in the other languages).  It makes the uses less verbose and 
> repetitive.
I like that idea.


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

https://reviews.llvm.org/D63052



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


[Lldb-commits] [PATCH] D62943: DWARF: Simplify SymbolFileDWARF::GetDWARFCompileUnit

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

Thanks for reverting this. It seems I did not take into account here the fact 
that SymbolFileDWARFDebugMap creates CompileUnits without setting the the 
UserData to point to the relevant dwarf compile unit.

I'll drop this patch and implement the thing I needed this for in D63005 
 differently.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D62943



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


[Lldb-commits] [PATCH] D62894: DWARF: Share line tables of type units

2019-06-10 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp:309
+  decl.SetFile(
+  die.GetDWARF()->GetSupportFile(*die.GetCU(), form_value.Unsigned()));
   break;

clayborg wrote:
> Maybe make a "FileSpec DWARFDie::GetFile(uint32_t idx);" function? 
I'm trying to avoid diverging llvm and lldb DWARFDies more than they already 
are. As llvm DWARFDie will not be returning a FileSpec, I think going through 
the symbol file makes sense (that's the level at which the sharing happens 
anyway.

But even without that, the api doesn't seem right, as this is not a query that 
can be answered by the DWARFDie class alone.



Comment at: source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp:392-395
+  if (FileSpec spec =
+  unit->GetCompilationDirectory().CopyByAppendingPathComponent(
+  unit->GetUnitDIEOnly().GetName()))
+return spec.GetPath();

clayborg wrote:
> Maybe create a DWARFUnit function?:
> ```
> const lldb_private::FileSpec &DWARFUnit::GetFileSpec();
> ```
> 
Sounds good. This also diverges from llvm DWARFUnit, but OTOH, it fits in 
nicely with the GetCompilationDirectory function we have there already, so 
these two can be resolved later at the same time.



Comment at: source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp:393
+  if (FileSpec spec =
+  unit->GetCompilationDirectory().CopyByAppendingPathComponent(
+  unit->GetUnitDIEOnly().GetName()))

clayborg wrote:
> Does this do the right thing if DW_AT_name is absolute?
Woops. No, it doesn't.



Comment at: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp:286-306
   dw_addr_t addr_base = cu_die.GetAttributeValueAsUnsigned(
   this, DW_AT_addr_base, LLDB_INVALID_ADDRESS);
   if (addr_base != LLDB_INVALID_ADDRESS)
 SetAddrBase(addr_base);
 
   dw_addr_t ranges_base = cu_die.GetAttributeValueAsUnsigned(
   this, DW_AT_rnglists_base, LLDB_INVALID_ADDRESS);

clayborg wrote:
> Many attributes being individually fetched here. This is slow. We should 
> probably iterate over all attributes?
Sounds good.



Comment at: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:812-813
+  if (offset == DW_INVALID_OFFSET ||
+  offset == llvm::DenseMapInfo::getEmptyKey() ||
+  offset == llvm::DenseMapInfo::getTombstoneKey())
+return empty_list;

clayborg wrote:
> why are these checks needed? Remove? Maybe left over from previous approach?
The offset is going to be used as a key in a DenseMap, and DenseMap reserves 
two values of each type for the "empty" and "tombstone" keys. These are 
something like 0xff..ff and 0xff.ffe, so valid DWARF will not contain those 
values, but malformed can (and if it did, this code would crash when trying to 
insert those keys).



Comment at: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:814
+  offset == llvm::DenseMapInfo::getTombstoneKey())
+return empty_list;
+

aprantl wrote:
> `return {};` ?
That wouldn't work, because `{}` is a temporary, and this function is returning 
a reference. Returning by reference saves a copy in the common case where 
DW_AT_stmt_list is valid, but I also need to handle the invalid case somehow. I 
could have this function return a pointer and return a nullptr in the invalid 
case (or something equivalent), but this saves the caller from checking that.


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

https://reviews.llvm.org/D62894



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


[Lldb-commits] [PATCH] D62894: DWARF: Share line tables of type units

2019-06-10 Thread Pavel Labath via Phabricator via lldb-commits
labath updated this revision to Diff 203790.
labath marked 13 inline comments as done.
labath added a comment.

- Implement code review suggestions (except the Die::GetName, and return {})
- Add a test for the error message which is printed when we encounter an 
incomplete class (this is motivated by the bug in the printing of the name of 
the compile unit)


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

https://reviews.llvm.org/D62894

Files:
  lit/SymbolFile/DWARF/debug-types-line-tables.s
  lit/SymbolFile/DWARF/forward-declarations.s
  source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
  source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp
  source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h
  source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
  source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.h
  source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h

Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -49,6 +49,7 @@
 class DWARFDebugRangesBase;
 class DWARFDeclContext;
 class DWARFFormValue;
+class DWARFTypeUnit;
 class SymbolFileDWARFDebugMap;
 class SymbolFileDWARFDwo;
 class SymbolFileDWARFDwp;
@@ -299,6 +300,8 @@
 
   lldb_private::DWARFContext &GetDWARFContext() { return m_context; }
 
+  lldb_private::FileSpec GetFile(DWARFUnit &unit, size_t file_idx);
+
 protected:
   typedef llvm::DenseMap
   DIEToTypePtr;
@@ -438,6 +441,8 @@
 
   SymbolFileDWARFDwp *GetDwpSymbolFile();
 
+  const lldb_private::FileSpecList &GetTypeUnitSupportFiles(DWARFTypeUnit &tu);
+
   lldb::ModuleWP m_debug_map_module_wp;
   SymbolFileDWARFDebugMap *m_debug_map_symfile;
 
@@ -476,6 +481,8 @@
   DIEToVariableSP m_die_to_variable_sp;
   DIEToClangType m_forward_decl_die_to_clang_type;
   ClangTypeToDIE m_forward_decl_clang_type_to_die;
+  llvm::DenseMap
+  m_type_unit_support_files;
 };
 
 #endif // SymbolFileDWARF_SymbolFileDWARF_h_
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -54,6 +54,7 @@
 #include "AppleDWARFIndex.h"
 #include "DWARFASTParser.h"
 #include "DWARFASTParserClang.h"
+#include "DWARFCompileUnit.h"
 #include "DWARFDebugAbbrev.h"
 #include "DWARFDebugAranges.h"
 #include "DWARFDebugInfo.h"
@@ -62,6 +63,7 @@
 #include "DWARFDebugRanges.h"
 #include "DWARFDeclContext.h"
 #include "DWARFFormValue.h"
+#include "DWARFTypeUnit.h"
 #include "DWARFUnit.h"
 #include "DebugNamesDWARFIndex.h"
 #include "LogChannelDWARF.h"
@@ -775,26 +777,55 @@
 bool SymbolFileDWARF::ParseSupportFiles(CompileUnit &comp_unit,
 FileSpecList &support_files) {
   ASSERT_MODULE_LOCK(this);
-  DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit);
-  if (dwarf_cu) {
-const DWARFBaseDIE cu_die = dwarf_cu->GetUnitDIEOnly();
-
-if (cu_die) {
-  const dw_offset_t stmt_list = cu_die.GetAttributeValueAsUnsigned(
-  DW_AT_stmt_list, DW_INVALID_OFFSET);
-  if (stmt_list != DW_INVALID_OFFSET) {
-// All file indexes in DWARF are one based and a file of index zero is
-// supposed to be the compile unit itself.
-support_files.Append(comp_unit);
-return DWARFDebugLine::ParseSupportFiles(
-comp_unit.GetModule(), m_context.getOrLoadLineData(), stmt_list,
-support_files, dwarf_cu);
-  }
+  DWARFUnit *unit = GetDWARFCompileUnit(&comp_unit);
+  if (auto *tu = llvm::dyn_cast_or_null(unit)) {
+support_files = GetTypeUnitSupportFiles(*tu);
+return true;
+  }
+
+  if (unit) {
+const dw_offset_t stmt_list = unit->GetLineTableOffset();
+if (stmt_list != DW_INVALID_OFFSET) {
+  // All file indexes in DWARF are one based and a file of index zero is
+  // supposed to be the compile unit itself.
+  support_files.Append(comp_unit);
+  return DWARFDebugLine::ParseSupportFiles(comp_unit.GetModule(),
+   m_context.getOrLoadLineData(),
+   stmt_list, support_files, unit);
 }
   }
   return false;
 }
 
+FileSpec SymbolFileDWARF::GetFile(DWARFUnit &unit, size_t file_idx) {
+  if (CompileUnit *lldb_cu = GetCompUnitForDWARFCompUnit(&unit))
+return lldb_cu->GetSupportFiles().GetFileSpecAtIndex(file_idx);
+  return FileSpec();
+}
+
+const FileSpecList &
+SymbolFileDWARF::GetTypeUnitSupportFiles(DWARFTypeUnit &tu) {
+  static FileSpecList empty_list;
+
+  dw_offset_t offset = tu.GetLineTableOffset();
+  if (offset == DW_INVALID_OFFSET ||
+  

[Lldb-commits] [PATCH] D63005: DWARF: Don't create lldb CompileUnits for DWARF type units

2019-06-10 Thread Pavel Labath via Phabricator via lldb-commits
labath updated this revision to Diff 203816.
labath added a comment.

- account for the fact that D62943  was a dud. 
Instead, set the correct ID of the compile unit so that the DWARF unit can be 
found via the regular logic.
- add a test for the situation where the dwarf and lldb compile unit indexes do 
not match


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

https://reviews.llvm.org/D63005

Files:
  lit/SymbolFile/DWARF/debug-types-dwarf5.s
  lit/SymbolFile/DWARF/debug-types-line-tables.s
  source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.h

Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.h
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.h
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.h
@@ -24,7 +24,7 @@
   Create(lldb::ModuleSP module_sp, const lldb_private::FileSpec &file_spec);
 
   std::unique_ptr
-  GetSymbolFileForDwoId(DWARFUnit *dwarf_cu, uint64_t dwo_id);
+  GetSymbolFileForDwoId(DWARFCompileUnit &dwarf_cu, uint64_t dwo_id);
 
   bool LoadSectionData(uint64_t dwo_id, lldb::SectionType sect_type,
lldb_private::DWARFDataExtractor &data);
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp
@@ -81,7 +81,7 @@
 {}
 
 std::unique_ptr
-SymbolFileDWARFDwp::GetSymbolFileForDwoId(DWARFUnit *dwarf_cu,
+SymbolFileDWARFDwp::GetSymbolFileForDwoId(DWARFCompileUnit &dwarf_cu,
   uint64_t dwo_id) {
   return std::unique_ptr(
   new SymbolFileDWARFDwoDwp(this, m_obj_file, dwarf_cu, dwo_id));
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.h
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.h
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.h
@@ -15,7 +15,7 @@
 class SymbolFileDWARFDwoDwp : public SymbolFileDWARFDwo {
 public:
   SymbolFileDWARFDwoDwp(SymbolFileDWARFDwp *dwp_symfile,
-lldb::ObjectFileSP objfile, DWARFUnit *dwarf_cu,
+lldb::ObjectFileSP objfile, DWARFCompileUnit &dwarf_cu,
 uint64_t dwo_id);
 
 protected:
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.cpp
@@ -21,7 +21,7 @@
 
 SymbolFileDWARFDwoDwp::SymbolFileDWARFDwoDwp(SymbolFileDWARFDwp *dwp_symfile,
  ObjectFileSP objfile,
- DWARFUnit *dwarf_cu,
+ DWARFCompileUnit &dwarf_cu,
  uint64_t dwo_id)
 : SymbolFileDWARFDwo(objfile, dwarf_cu), m_dwp_symfile(dwp_symfile),
   m_dwo_id(dwo_id) {}
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
@@ -13,11 +13,11 @@
 
 class SymbolFileDWARFDwo : public SymbolFileDWARF {
 public:
-  SymbolFileDWARFDwo(lldb::ObjectFileSP objfile, DWARFUnit *dwarf_cu);
+  SymbolFileDWARFDwo(lldb::ObjectFileSP objfile, DWARFCompileUnit &dwarf_cu);
 
   ~SymbolFileDWARFDwo() override = default;
 
-  lldb::CompUnitSP ParseCompileUnit(DWARFUnit *dwarf_cu) override;
+  lldb::CompUnitSP ParseCompileUnit(DWARFCompileUnit &dwarf_cu) override;
 
   DWARFUnit *GetCompileUnit();
 
@@ -42,7 +42,7 @@
 return nullptr;
   }
 
-  DWARFUnit *GetBaseCompileUnit() override;
+  DWARFCompileUnit *GetBaseCompileUnit() override { return &m_base_dwarf_cu; }
 
 protected:
   void LoadSectionData(lldb::SectionType sect_type,
@@ -68,7 +68,7 @@
   SymbolFileDWARF *GetBaseSymbolFile();
 
   lldb::ObjectFileSP m_obj_file_sp;
-  DWARFUnit *m_base_dwarf_cu;
+  DWARFCompileUnit &m_base_dwarf_cu;
 };
 
 #endif // SymbolFileDWARFDwo_SymbolFileDWARFDwo_h_
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
===

[Lldb-commits] [PATCH] D63005: DWARF: Don't create lldb CompileUnits for DWARF type units

2019-06-10 Thread Pavel Labath via Phabricator via lldb-commits
labath updated this revision to Diff 203820.
labath added a comment.

- Also implement Adrians suggestion.


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

https://reviews.llvm.org/D63005

Files:
  lit/SymbolFile/DWARF/debug-types-dwarf5.s
  lit/SymbolFile/DWARF/debug-types-line-tables.s
  source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.h

Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.h
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.h
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.h
@@ -24,7 +24,7 @@
   Create(lldb::ModuleSP module_sp, const lldb_private::FileSpec &file_spec);
 
   std::unique_ptr
-  GetSymbolFileForDwoId(DWARFUnit *dwarf_cu, uint64_t dwo_id);
+  GetSymbolFileForDwoId(DWARFCompileUnit &dwarf_cu, uint64_t dwo_id);
 
   bool LoadSectionData(uint64_t dwo_id, lldb::SectionType sect_type,
lldb_private::DWARFDataExtractor &data);
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp
@@ -81,7 +81,7 @@
 {}
 
 std::unique_ptr
-SymbolFileDWARFDwp::GetSymbolFileForDwoId(DWARFUnit *dwarf_cu,
+SymbolFileDWARFDwp::GetSymbolFileForDwoId(DWARFCompileUnit &dwarf_cu,
   uint64_t dwo_id) {
   return std::unique_ptr(
   new SymbolFileDWARFDwoDwp(this, m_obj_file, dwarf_cu, dwo_id));
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.h
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.h
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.h
@@ -15,7 +15,7 @@
 class SymbolFileDWARFDwoDwp : public SymbolFileDWARFDwo {
 public:
   SymbolFileDWARFDwoDwp(SymbolFileDWARFDwp *dwp_symfile,
-lldb::ObjectFileSP objfile, DWARFUnit *dwarf_cu,
+lldb::ObjectFileSP objfile, DWARFCompileUnit &dwarf_cu,
 uint64_t dwo_id);
 
 protected:
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.cpp
@@ -21,7 +21,7 @@
 
 SymbolFileDWARFDwoDwp::SymbolFileDWARFDwoDwp(SymbolFileDWARFDwp *dwp_symfile,
  ObjectFileSP objfile,
- DWARFUnit *dwarf_cu,
+ DWARFCompileUnit &dwarf_cu,
  uint64_t dwo_id)
 : SymbolFileDWARFDwo(objfile, dwarf_cu), m_dwp_symfile(dwp_symfile),
   m_dwo_id(dwo_id) {}
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
@@ -13,11 +13,11 @@
 
 class SymbolFileDWARFDwo : public SymbolFileDWARF {
 public:
-  SymbolFileDWARFDwo(lldb::ObjectFileSP objfile, DWARFUnit *dwarf_cu);
+  SymbolFileDWARFDwo(lldb::ObjectFileSP objfile, DWARFCompileUnit &dwarf_cu);
 
   ~SymbolFileDWARFDwo() override = default;
 
-  lldb::CompUnitSP ParseCompileUnit(DWARFUnit *dwarf_cu) override;
+  lldb::CompUnitSP ParseCompileUnit(DWARFCompileUnit &dwarf_cu) override;
 
   DWARFUnit *GetCompileUnit();
 
@@ -42,7 +42,7 @@
 return nullptr;
   }
 
-  DWARFUnit *GetBaseCompileUnit() override;
+  DWARFCompileUnit *GetBaseCompileUnit() override { return &m_base_dwarf_cu; }
 
 protected:
   void LoadSectionData(lldb::SectionType sect_type,
@@ -68,7 +68,7 @@
   SymbolFileDWARF *GetBaseSymbolFile();
 
   lldb::ObjectFileSP m_obj_file_sp;
-  DWARFUnit *m_base_dwarf_cu;
+  DWARFCompileUnit &m_base_dwarf_cu;
 };
 
 #endif // SymbolFileDWARFDwo_SymbolFileDWARFDwo_h_
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
@@ -13,18 +13,19 @@
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Utility/LLDBAssert.h"
 
-#include "DWARFUni

[Lldb-commits] [lldb] r362946 - [lldb] [Process/NetBSD] Fix error handling in register operations

2019-06-10 Thread Michal Gorny via lldb-commits
Author: mgorny
Date: Mon Jun 10 08:03:49 2019
New Revision: 362946

URL: http://llvm.org/viewvc/llvm-project?rev=362946&view=rev
Log:
[lldb] [Process/NetBSD] Fix error handling in register operations

Ensure that errors are passed through correctly when performing
register read/write operations.  Currently, any ptrace() errors are
silently discarded and LLDB behaves as if operation was successful.

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

Modified:

lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp

lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h

Modified: 
lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp?rev=362946&r1=362945&r2=362946&view=diff
==
--- 
lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp 
(original)
+++ 
lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp 
Mon Jun 10 08:03:49 2019
@@ -210,37 +210,28 @@ int NativeRegisterContextNetBSD_x86_64::
 return -1;
 }
 
-int NativeRegisterContextNetBSD_x86_64::ReadRegisterSet(uint32_t set) {
+Status NativeRegisterContextNetBSD_x86_64::ReadRegisterSet(uint32_t set) {
   switch (set) {
   case GPRegSet:
-ReadGPR();
-return 0;
+return ReadGPR();
   case FPRegSet:
-ReadFPR();
-return 0;
+return ReadFPR();
   case DBRegSet:
-ReadDBR();
-return 0;
-  default:
-break;
+return ReadDBR();
   }
-  return -1;
+  llvm_unreachable("NativeRegisterContextNetBSD_x86_64::ReadRegisterSet");
 }
-int NativeRegisterContextNetBSD_x86_64::WriteRegisterSet(uint32_t set) {
+
+Status NativeRegisterContextNetBSD_x86_64::WriteRegisterSet(uint32_t set) {
   switch (set) {
   case GPRegSet:
-WriteGPR();
-return 0;
+return WriteGPR();
   case FPRegSet:
-WriteFPR();
-return 0;
+return WriteFPR();
   case DBRegSet:
-WriteDBR();
-return 0;
-  default:
-break;
+return WriteDBR();
   }
-  return -1;
+  llvm_unreachable("NativeRegisterContextNetBSD_x86_64::WriteRegisterSet");
 }
 
 Status
@@ -272,13 +263,9 @@ NativeRegisterContextNetBSD_x86_64::Read
 return error;
   }
 
-  if (ReadRegisterSet(set) != 0) {
-// This is likely an internal register for lldb use only and should not be
-// directly queried.
-error.SetErrorStringWithFormat(
-"reading register set for register \"%s\" failed", reg_info->name);
+  error = ReadRegisterSet(set);
+  if (error.Fail())
 return error;
-  }
 
   switch (reg) {
   case lldb_rax_x86_64:
@@ -468,13 +455,9 @@ Status NativeRegisterContextNetBSD_x86_6
 return error;
   }
 
-  if (ReadRegisterSet(set) != 0) {
-// This is likely an internal register for lldb use only and should not be
-// directly queried.
-error.SetErrorStringWithFormat(
-"reading register set for register \"%s\" failed", reg_info->name);
+  error = ReadRegisterSet(set);
+  if (error.Fail())
 return error;
-  }
 
   switch (reg) {
   case lldb_rax_x86_64:
@@ -632,10 +615,7 @@ Status NativeRegisterContextNetBSD_x86_6
 break;
   }
 
-  if (WriteRegisterSet(set) != 0)
-error.SetErrorStringWithFormat("failed to write register set");
-
-  return error;
+  return WriteRegisterSet(set);
 }
 
 Status NativeRegisterContextNetBSD_x86_64::ReadAllRegisterValues(

Modified: 
lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h?rev=362946&r1=362945&r2=362946&view=diff
==
--- 
lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h 
(original)
+++ 
lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h 
Mon Jun 10 08:03:49 2019
@@ -82,8 +82,8 @@ private:
 
   int GetSetForNativeRegNum(int reg_num) const;
 
-  int ReadRegisterSet(uint32_t set);
-  int WriteRegisterSet(uint32_t set);
+  Status ReadRegisterSet(uint32_t set);
+  Status WriteRegisterSet(uint32_t set);
 };
 
 } // namespace process_netbsd


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


[Lldb-commits] [PATCH] D63054: [lldb] [Process/NetBSD] Fix error handling in register operations

2019-06-10 Thread Michał Górny via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL362946: [lldb] [Process/NetBSD] Fix error handling in 
register operations (authored by mgorny, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D63054?vs=203717&id=203826#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D63054

Files:
  
lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp
  lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h

Index: lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp
===
--- lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp
+++ lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp
@@ -210,37 +210,28 @@
 return -1;
 }
 
-int NativeRegisterContextNetBSD_x86_64::ReadRegisterSet(uint32_t set) {
+Status NativeRegisterContextNetBSD_x86_64::ReadRegisterSet(uint32_t set) {
   switch (set) {
   case GPRegSet:
-ReadGPR();
-return 0;
+return ReadGPR();
   case FPRegSet:
-ReadFPR();
-return 0;
+return ReadFPR();
   case DBRegSet:
-ReadDBR();
-return 0;
-  default:
-break;
+return ReadDBR();
   }
-  return -1;
+  llvm_unreachable("NativeRegisterContextNetBSD_x86_64::ReadRegisterSet");
 }
-int NativeRegisterContextNetBSD_x86_64::WriteRegisterSet(uint32_t set) {
+
+Status NativeRegisterContextNetBSD_x86_64::WriteRegisterSet(uint32_t set) {
   switch (set) {
   case GPRegSet:
-WriteGPR();
-return 0;
+return WriteGPR();
   case FPRegSet:
-WriteFPR();
-return 0;
+return WriteFPR();
   case DBRegSet:
-WriteDBR();
-return 0;
-  default:
-break;
+return WriteDBR();
   }
-  return -1;
+  llvm_unreachable("NativeRegisterContextNetBSD_x86_64::WriteRegisterSet");
 }
 
 Status
@@ -272,13 +263,9 @@
 return error;
   }
 
-  if (ReadRegisterSet(set) != 0) {
-// This is likely an internal register for lldb use only and should not be
-// directly queried.
-error.SetErrorStringWithFormat(
-"reading register set for register \"%s\" failed", reg_info->name);
+  error = ReadRegisterSet(set);
+  if (error.Fail())
 return error;
-  }
 
   switch (reg) {
   case lldb_rax_x86_64:
@@ -468,13 +455,9 @@
 return error;
   }
 
-  if (ReadRegisterSet(set) != 0) {
-// This is likely an internal register for lldb use only and should not be
-// directly queried.
-error.SetErrorStringWithFormat(
-"reading register set for register \"%s\" failed", reg_info->name);
+  error = ReadRegisterSet(set);
+  if (error.Fail())
 return error;
-  }
 
   switch (reg) {
   case lldb_rax_x86_64:
@@ -632,10 +615,7 @@
 break;
   }
 
-  if (WriteRegisterSet(set) != 0)
-error.SetErrorStringWithFormat("failed to write register set");
-
-  return error;
+  return WriteRegisterSet(set);
 }
 
 Status NativeRegisterContextNetBSD_x86_64::ReadAllRegisterValues(
Index: lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h
===
--- lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h
+++ lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h
@@ -82,8 +82,8 @@
 
   int GetSetForNativeRegNum(int reg_num) const;
 
-  int ReadRegisterSet(uint32_t set);
-  int WriteRegisterSet(uint32_t set);
+  Status ReadRegisterSet(uint32_t set);
+  Status WriteRegisterSet(uint32_t set);
 };
 
 } // namespace process_netbsd
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r362948 - Add "REQUIRES: x86" to DWARF assembly tests

2019-06-10 Thread Pavel Labath via lldb-commits
Author: labath
Date: Mon Jun 10 08:08:00 2019
New Revision: 362948

URL: http://llvm.org/viewvc/llvm-project?rev=362948&view=rev
Log:
Add "REQUIRES: x86" to DWARF assembly tests

These tests don't require an x86 host, but they do require that we build
the x86 llvm target.

Modified:
lldb/trunk/lit/SymbolFile/DWARF/array-sizes.s
lldb/trunk/lit/SymbolFile/DWARF/childless-compile-unit.s
lldb/trunk/lit/SymbolFile/DWARF/debug-line-basic.s
lldb/trunk/lit/SymbolFile/DWARF/debug-types-address-ranges.s
lldb/trunk/lit/SymbolFile/DWARF/debug-types-signature-loop.s
lldb/trunk/lit/SymbolFile/DWARF/debug_aranges-empty-section.s
lldb/trunk/lit/SymbolFile/DWARF/debug_loc.s
lldb/trunk/lit/SymbolFile/DWARF/debug_ranges-missing-section.s
lldb/trunk/lit/SymbolFile/DWARF/debug_ranges.s
lldb/trunk/lit/SymbolFile/DWARF/debug_rnglists.s
lldb/trunk/lit/SymbolFile/DWARF/dir-separator-no-comp-dir-relative-name.s
lldb/trunk/lit/SymbolFile/DWARF/dir-separator-no-comp-dir.s
lldb/trunk/lit/SymbolFile/DWARF/dir-separator-posix.s
lldb/trunk/lit/SymbolFile/DWARF/dir-separator-windows.s
lldb/trunk/lit/SymbolFile/DWARF/dwarf5_locations.s
lldb/trunk/lit/SymbolFile/DWARF/find-inline-method.s
lldb/trunk/lit/SymbolFile/DWARF/parallel-indexing-stress.s

Modified: lldb/trunk/lit/SymbolFile/DWARF/array-sizes.s
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/DWARF/array-sizes.s?rev=362948&r1=362947&r2=362948&view=diff
==
--- lldb/trunk/lit/SymbolFile/DWARF/array-sizes.s (original)
+++ lldb/trunk/lit/SymbolFile/DWARF/array-sizes.s Mon Jun 10 08:08:00 2019
@@ -3,7 +3,7 @@
 # misinterpreted that value as a reference to a DIE specifying the VLA size 
even
 # though the form was a data form (as it should be).
 
-# REQUIRES: lld
+# REQUIRES: lld, x86
 
 # RUN: llvm-mc -triple x86_64-pc-linux %s -filetype=obj > %t.o
 # RUN: ld.lld %t.o -o %t

Modified: lldb/trunk/lit/SymbolFile/DWARF/childless-compile-unit.s
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/DWARF/childless-compile-unit.s?rev=362948&r1=362947&r2=362948&view=diff
==
--- lldb/trunk/lit/SymbolFile/DWARF/childless-compile-unit.s (original)
+++ lldb/trunk/lit/SymbolFile/DWARF/childless-compile-unit.s Mon Jun 10 
08:08:00 2019
@@ -2,6 +2,8 @@
 # unit in this file sets DW_CHILDREN_no, but it still includes an
 # end-of-children marker in its contribution.
 
+# REQUIRES: x86
+
 # RUN: llvm-mc -triple x86_64-pc-linux %s -filetype=obj > %t.o
 # RUN: lldb-test symbols %t.o
 

Modified: lldb/trunk/lit/SymbolFile/DWARF/debug-line-basic.s
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/DWARF/debug-line-basic.s?rev=362948&r1=362947&r2=362948&view=diff
==
--- lldb/trunk/lit/SymbolFile/DWARF/debug-line-basic.s (original)
+++ lldb/trunk/lit/SymbolFile/DWARF/debug-line-basic.s Mon Jun 10 08:08:00 2019
@@ -1,4 +1,4 @@
-# REQUIRES: lld
+# REQUIRES: lld, x86
 
 # RUN: llvm-mc -triple x86_64-pc-linux %s -filetype=obj > %t.o
 # RUN: ld.lld %t.o -o %t

Modified: lldb/trunk/lit/SymbolFile/DWARF/debug-types-address-ranges.s
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/DWARF/debug-types-address-ranges.s?rev=362948&r1=362947&r2=362948&view=diff
==
--- lldb/trunk/lit/SymbolFile/DWARF/debug-types-address-ranges.s (original)
+++ lldb/trunk/lit/SymbolFile/DWARF/debug-types-address-ranges.s Mon Jun 10 
08:08:00 2019
@@ -4,7 +4,7 @@
 # compute address range for the type unit as type units don't describe any
 # addresses. The addresses should always resolve to the relevant compile units.
 
-# REQUIRES: lld
+# REQUIRES: lld, x86
 
 # RUN: llvm-mc -dwarf-version=5 -triple x86_64-pc-linux %s -filetype=obj >%t.o
 # RUN: ld.lld %t.o -o %t -image-base=0x47000

Modified: lldb/trunk/lit/SymbolFile/DWARF/debug-types-signature-loop.s
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/DWARF/debug-types-signature-loop.s?rev=362948&r1=362947&r2=362948&view=diff
==
--- lldb/trunk/lit/SymbolFile/DWARF/debug-types-signature-loop.s (original)
+++ lldb/trunk/lit/SymbolFile/DWARF/debug-types-signature-loop.s Mon Jun 10 
08:08:00 2019
@@ -1,4 +1,4 @@
-# REQUIRES: lld
+# REQUIRES: lld, x86
 
 # RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux -o %t.o %s
 # RUN: ld.lld %t.o -o %t

Modified: lldb/trunk/lit/SymbolFile/DWARF/debug_aranges-empty-section.s
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/DWARF/debug_aranges-empty-section.s?rev=362948&r1=362947&r2=362948&view=diff
==
--- lldb/trunk/lit/SymbolFile/DWARF/deb

[Lldb-commits] [PATCH] D62502: Implement xfer:libraries-svr4:read packet

2019-06-10 Thread Kamil Rytarowski via Phabricator via lldb-commits
krytarowski added a comment.

https://nxr.netbsd.org/xref/src/include/link_elf.h#9

In general this code should be close to functional on NetBSD (if not already 
compatible).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62502



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


[Lldb-commits] [PATCH] D62894: DWARF: Share line tables of type units

2019-06-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: source/Plugins/SymbolFile/DWARF/DWARFUnit.h:148
   dw_addr_t GetStrOffsetsBase() const { return m_str_offsets_base; }
+  dw_offset_t GetLineTableOffset();
   void SetAddrBase(dw_addr_t addr_base);

Nit: move this next to `GetAbbrevOffset`



Comment at: source/Plugins/SymbolFile/DWARF/DWARFUnit.h:200
   const lldb_private::FileSpec &GetCompilationDirectory();
+  const lldb_private::FileSpec &GetFileSpec();
   lldb_private::FileSpec::Style GetPathStyle();

Given the implementation, how about `GetAbsolutePath`? I think the "FileSpec" 
of a DWARF unit is a little weird, but feel free to ignore this. 



Comment at: source/Plugins/SymbolFile/DWARF/DWARFUnit.h:290
   dw_offset_t m_str_offsets_base = 0; // Value of DW_AT_str_offsets_base.
+  dw_offset_t m_line_table_offset =
+  DW_INVALID_OFFSET; // Value of DW_AT_stmt_list.

Let's make this a Doxygen comment with `///<` or even better just `///` on the 
line above it so it doesn't wrap. 



Comment at: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:821
+  if (iter_bool.second) {
+list.Append(FileSpec());
+DWARFDebugLine::ParseSupportFiles(GetObjectFile()->GetModule(),

Not your responsibility but we should really get rid of this thing as it 
doesn't make sense anymore in > DWARF5.



Comment at: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h:303
 
+  lldb_private::FileSpec GetSupportFile(DWARFUnit &unit, size_t file_idx);
+

clayborg wrote:
> Can probably just be named GetFile
Should this return an optional?


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

https://reviews.llvm.org/D62894



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


[Lldb-commits] [PATCH] D62502: Implement xfer:libraries-svr4:read packet

2019-06-10 Thread António Afonso via Phabricator via lldb-commits
aadsm marked an inline comment as done.
aadsm added a comment.

It's the same for freebsd 
https://github.com/freebsd/freebsd/blob/master/sys/kern/link_elf.c#L291 
although behind a GDB flag (which NetBSD doesn't seem to be: 
https://nxr.netbsd.org/xref/src/libexec/ld.elf_so/rtld.c#1040).




Comment at: 
lldb/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/TestGdbRemoteLibrariesSvr4Support.py:21-29
+self.test_sequence.add_log_lines(
+[
+# Start the inferior...
+"read packet: $c#63"
+],
+True,
+)

labath wrote:
> This countinue-and-immediatelly-interrupt sequence seems very dodgy. What's 
> the purpose of that? Given that the inferior forces a break with the null 
> dereference, I would expect you don't need to send any interrupt packets 
> here, just simply wait for the inferior to stop.
ah yeah, it will stop already on the sigsev.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62502



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


[Lldb-commits] [PATCH] D63005: DWARF: Don't create lldb CompileUnits for DWARF type units

2019-06-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.

I saw some weird formatting, but I assume you run clang-format before landing 
anyway. LGTM.


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

https://reviews.llvm.org/D63005



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


[Lldb-commits] [PATCH] D62501: Implement GetSharedLibraryInfoAddress

2019-06-10 Thread António Afonso via Phabricator via lldb-commits
aadsm added a comment.

Initially one at a time but then thought it might be better to do it as a batch 
because I was afraid I was missing some dependency and would brake something 
unexpectedly. But I guess that since I've already landed D62168 
 it's probably fine to land one at a time.




Comment at: lldb/unittests/Process/POSIX/NativeProcessELFTest.cpp:83-117
+  // We're going to set up a fake memory with 2 program headers and 1 entry in
+  // the dynamic section.
+  // For simplicity sake they will be consecutive in memory:
+  // ++
+  // | PT_PHDR|
+  // ++
+  // | PT_DYNAMIC |

labath wrote:
> What if we just defined a struct which described the final memory layout, and 
> then gave that as an argument to the FakeMemory object?
> 
> I'm thinking of something like:
> ```
> struct MemoryContents {
>   Elf32_Phdr phdr_load;
>   Elf32_Phdr phdr_dynamic;
>   Elf32_Dyn dyn_debug;
> } MC;
> MC.phdr_load.p_type = PT_DYNAMIC;
> ...
> FakeMemory M(&MC, sizeof MC, phdr_addr); // This assumes adding a (const void 
> *, size_t) constructor to the class
> ```
Ah nice, why didn't I think about this before :D


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62501



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


[Lldb-commits] [lldb] r362960 - Breakpad: Add support for the arm64e "architecture"

2019-06-10 Thread Pavel Labath via lldb-commits
Author: labath
Date: Mon Jun 10 09:21:26 2019
New Revision: 362960

URL: http://llvm.org/viewvc/llvm-project?rev=362960&view=rev
Log:
Breakpad: Add support for the arm64e "architecture"

Added:
lldb/trunk/lit/Modules/Breakpad/Inputs/identification-macosx-arm64e.syms
Modified:
lldb/trunk/lit/Modules/Breakpad/breakpad-identification.test
lldb/trunk/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp

Added: lldb/trunk/lit/Modules/Breakpad/Inputs/identification-macosx-arm64e.syms
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/Breakpad/Inputs/identification-macosx-arm64e.syms?rev=362960&view=auto
==
--- lldb/trunk/lit/Modules/Breakpad/Inputs/identification-macosx-arm64e.syms 
(added)
+++ lldb/trunk/lit/Modules/Breakpad/Inputs/identification-macosx-arm64e.syms 
Mon Jun 10 09:21:26 2019
@@ -0,0 +1,3 @@
+MODULE mac arm64e 4E11896957B3334EB03456BFCEB573760 mac.out
+PUBLIC 0 0 _mh_execute_header
+PUBLIC f30 0 start

Modified: lldb/trunk/lit/Modules/Breakpad/breakpad-identification.test
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/Breakpad/breakpad-identification.test?rev=362960&r1=362959&r2=362960&view=diff
==
--- lldb/trunk/lit/Modules/Breakpad/breakpad-identification.test (original)
+++ lldb/trunk/lit/Modules/Breakpad/breakpad-identification.test Mon Jun 10 
09:21:26 2019
@@ -1,5 +1,6 @@
 RUN: lldb-test object-file %p/Inputs/identification-linux.syms | FileCheck %s 
--check-prefix=LINUX
 RUN: lldb-test object-file %p/Inputs/identification-macosx.syms | FileCheck %s 
--check-prefix=MAC
+RUN: lldb-test object-file %p/Inputs/identification-macosx-arm64e.syms | 
FileCheck %s --check-prefix=ARM64E
 RUN: lldb-test object-file %p/Inputs/identification-windows.syms | FileCheck 
%s --check-prefix=WINDOWS
 RUN: not lldb-test object-file %p/Inputs/bad-module-id-1.syms 2>&1 | FileCheck 
%s --check-prefix=ERROR
 RUN: not lldb-test object-file %p/Inputs/bad-module-id-2.syms 2>&1 | FileCheck 
%s --check-prefix=ERROR
@@ -21,6 +22,8 @@ MAC: Stripped: false
 MAC: Type: debug info
 MAC: Strata: user
 
+ARM64E: Architecture: aarch64--macosx
+
 WINDOWS: Plugin name: breakpad
 WINDOWS: Architecture: i386--windows
 WINDOWS: UUID: A0C91657-80B5-4909-81A1-925EA62165C0-0001

Modified: lldb/trunk/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp?rev=362960&r1=362959&r2=362960&view=diff
==
--- lldb/trunk/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp Mon Jun 
10 09:21:26 2019
@@ -51,7 +51,7 @@ llvm::Triple::ArchType stringTo(Str)
   .Case("arm", Triple::arm)
-  .Case("arm64", Triple::aarch64)
+  .Cases("arm64", "arm64e", Triple::aarch64)
   .Case("mips", Triple::mips)
   .Case("ppc", Triple::ppc)
   .Case("ppc64", Triple::ppc64)


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


[Lldb-commits] [PATCH] D62894: DWARF: Share line tables of type units

2019-06-10 Thread Pavel Labath via Phabricator via lldb-commits
labath marked 5 inline comments as done.
labath added inline comments.



Comment at: source/Plugins/SymbolFile/DWARF/DWARFUnit.h:200
   const lldb_private::FileSpec &GetCompilationDirectory();
+  const lldb_private::FileSpec &GetFileSpec();
   lldb_private::FileSpec::Style GetPathStyle();

JDevlieghere wrote:
> Given the implementation, how about `GetAbsolutePath`? I think the "FileSpec" 
> of a DWARF unit is a little weird, but feel free to ignore this. 
GetAbsolutePath sounds good.



Comment at: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:821
+  if (iter_bool.second) {
+list.Append(FileSpec());
+DWARFDebugLine::ParseSupportFiles(GetObjectFile()->GetModule(),

JDevlieghere wrote:
> Not your responsibility but we should really get rid of this thing as it 
> doesn't make sense anymore in > DWARF5.
I'm waiting on your llvm debug_lines patch. :)



Comment at: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h:303
 
+  lldb_private::FileSpec GetSupportFile(DWARFUnit &unit, size_t file_idx);
+

JDevlieghere wrote:
> clayborg wrote:
> > Can probably just be named GetFile
> Should this return an optional?
I don't know. On one hand, both the level above this function and the level 
below use an empty FileSpec do denote failure, so I'd have to convert it 
explicitly in both places. OTOH, Optional is the direction we want to move in.

I can change it if you want..


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

https://reviews.llvm.org/D62894



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


[Lldb-commits] [PATCH] D62894: DWARF: Share line tables of type units

2019-06-10 Thread Pavel Labath via Phabricator via lldb-commits
labath updated this revision to Diff 203845.
labath added a comment.

- address code review comments


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

https://reviews.llvm.org/D62894

Files:
  lit/SymbolFile/DWARF/debug-types-line-tables.s
  lit/SymbolFile/DWARF/forward-declarations.s
  source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
  source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp
  source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h
  source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
  source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.h
  source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h

Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -49,6 +49,7 @@
 class DWARFDebugRangesBase;
 class DWARFDeclContext;
 class DWARFFormValue;
+class DWARFTypeUnit;
 class SymbolFileDWARFDebugMap;
 class SymbolFileDWARFDwo;
 class SymbolFileDWARFDwp;
@@ -299,6 +300,8 @@
 
   lldb_private::DWARFContext &GetDWARFContext() { return m_context; }
 
+  lldb_private::FileSpec GetFile(DWARFUnit &unit, size_t file_idx);
+
 protected:
   typedef llvm::DenseMap
   DIEToTypePtr;
@@ -438,6 +441,8 @@
 
   SymbolFileDWARFDwp *GetDwpSymbolFile();
 
+  const lldb_private::FileSpecList &GetTypeUnitSupportFiles(DWARFTypeUnit &tu);
+
   lldb::ModuleWP m_debug_map_module_wp;
   SymbolFileDWARFDebugMap *m_debug_map_symfile;
 
@@ -476,6 +481,8 @@
   DIEToVariableSP m_die_to_variable_sp;
   DIEToClangType m_forward_decl_die_to_clang_type;
   ClangTypeToDIE m_forward_decl_clang_type_to_die;
+  llvm::DenseMap
+  m_type_unit_support_files;
 };
 
 #endif // SymbolFileDWARF_SymbolFileDWARF_h_
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -54,6 +54,7 @@
 #include "AppleDWARFIndex.h"
 #include "DWARFASTParser.h"
 #include "DWARFASTParserClang.h"
+#include "DWARFCompileUnit.h"
 #include "DWARFDebugAbbrev.h"
 #include "DWARFDebugAranges.h"
 #include "DWARFDebugInfo.h"
@@ -62,6 +63,7 @@
 #include "DWARFDebugRanges.h"
 #include "DWARFDeclContext.h"
 #include "DWARFFormValue.h"
+#include "DWARFTypeUnit.h"
 #include "DWARFUnit.h"
 #include "DebugNamesDWARFIndex.h"
 #include "LogChannelDWARF.h"
@@ -775,26 +777,55 @@
 bool SymbolFileDWARF::ParseSupportFiles(CompileUnit &comp_unit,
 FileSpecList &support_files) {
   ASSERT_MODULE_LOCK(this);
-  DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit);
-  if (dwarf_cu) {
-const DWARFBaseDIE cu_die = dwarf_cu->GetUnitDIEOnly();
-
-if (cu_die) {
-  const dw_offset_t stmt_list = cu_die.GetAttributeValueAsUnsigned(
-  DW_AT_stmt_list, DW_INVALID_OFFSET);
-  if (stmt_list != DW_INVALID_OFFSET) {
-// All file indexes in DWARF are one based and a file of index zero is
-// supposed to be the compile unit itself.
-support_files.Append(comp_unit);
-return DWARFDebugLine::ParseSupportFiles(
-comp_unit.GetModule(), m_context.getOrLoadLineData(), stmt_list,
-support_files, dwarf_cu);
-  }
+  DWARFUnit *unit = GetDWARFCompileUnit(&comp_unit);
+  if (auto *tu = llvm::dyn_cast_or_null(unit)) {
+support_files = GetTypeUnitSupportFiles(*tu);
+return true;
+  }
+
+  if (unit) {
+const dw_offset_t stmt_list = unit->GetLineTableOffset();
+if (stmt_list != DW_INVALID_OFFSET) {
+  // All file indexes in DWARF are one based and a file of index zero is
+  // supposed to be the compile unit itself.
+  support_files.Append(comp_unit);
+  return DWARFDebugLine::ParseSupportFiles(comp_unit.GetModule(),
+   m_context.getOrLoadLineData(),
+   stmt_list, support_files, unit);
 }
   }
   return false;
 }
 
+FileSpec SymbolFileDWARF::GetFile(DWARFUnit &unit, size_t file_idx) {
+  if (CompileUnit *lldb_cu = GetCompUnitForDWARFCompUnit(&unit))
+return lldb_cu->GetSupportFiles().GetFileSpecAtIndex(file_idx);
+  return FileSpec();
+}
+
+const FileSpecList &
+SymbolFileDWARF::GetTypeUnitSupportFiles(DWARFTypeUnit &tu) {
+  static FileSpecList empty_list;
+
+  dw_offset_t offset = tu.GetLineTableOffset();
+  if (offset == DW_INVALID_OFFSET ||
+  offset == llvm::DenseMapInfo::getEmptyKey() ||
+  offset == llvm::DenseMapInfo::getTombstoneKey())
+return empty_list;
+
+  // Many type units can share a line table, so parse the support file list
+  // once, and cache it based on the offset field.
+

[Lldb-commits] [lldb] r362961 - ABI: reflow the table text (NFC)

2019-06-10 Thread Saleem Abdulrasool via lldb-commits
Author: compnerd
Date: Mon Jun 10 09:32:33 2019
New Revision: 362961

URL: http://llvm.org/viewvc/llvm-project?rev=362961&view=rev
Log:
ABI: reflow the table text (NFC)

Reflow the text for the table to make the table legible.  This is purely
cosmetic, but makes understanding the contents of the table easier.  NFCI.

Modified:
lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp

Modified: lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp?rev=362961&r1=362960&r2=362961&view=diff
==
--- lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp (original)
+++ lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp Mon Jun 10 
09:32:33 2019
@@ -100,960 +100,90 @@ enum dwarf_regnums {
 };
 
 static RegisterInfo g_register_infos[] = {
-//  NAME  ALT  SZ OFF ENCODING FORMAT  EH_FRAME
-//  DWARF GENERIC PROCESS PLUGIN
-//  LLDB NATIVE
-//    ===  == === ====
-//  === =
-//  === = 
==
-{"rax",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {dwarf_rax, dwarf_rax, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
-  LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
-{"rbx",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {dwarf_rbx, dwarf_rbx, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
-  LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
-{"rcx",
- "arg4",
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {dwarf_rcx, dwarf_rcx, LLDB_REGNUM_GENERIC_ARG4, LLDB_INVALID_REGNUM,
-  LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
-{"rdx",
- "arg3",
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {dwarf_rdx, dwarf_rdx, LLDB_REGNUM_GENERIC_ARG3, LLDB_INVALID_REGNUM,
-  LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
-{"rsi",
- "arg2",
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {dwarf_rsi, dwarf_rsi, LLDB_REGNUM_GENERIC_ARG2, LLDB_INVALID_REGNUM,
-  LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
-{"rdi",
- "arg1",
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {dwarf_rdi, dwarf_rdi, LLDB_REGNUM_GENERIC_ARG1, LLDB_INVALID_REGNUM,
-  LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
-{"rbp",
- "fp",
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {dwarf_rbp, dwarf_rbp, LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM,
-  LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
-{"rsp",
- "sp",
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {dwarf_rsp, dwarf_rsp, LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM,
-  LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
-{"r8",
- "arg5",
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {dwarf_r8, dwarf_r8, LLDB_REGNUM_GENERIC_ARG5, LLDB_INVALID_REGNUM,
-  LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
-{"r9",
- "arg6",
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {dwarf_r9, dwarf_r9, LLDB_REGNUM_GENERIC_ARG6, LLDB_INVALID_REGNUM,
-  LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
-{"r10",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {dwarf_r10, dwarf_r10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
-  LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
-{"r11",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {dwarf_r11, dwarf_r11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
-  LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
-{"r12",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {dwarf_r12, dwarf_r12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
-  LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
-{"r13",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {dwarf_r13, dwarf_r13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
-  LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
-{"r14",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {dwarf_r14, dwarf_r14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
-  LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
-{"r15",
- nullptr,
- 8,
- 0,

[Lldb-commits] [PATCH] D63005: DWARF: Don't create lldb CompileUnits for DWARF type units

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

In D63005#1536367 , @JDevlieghere 
wrote:

> I saw some weird formatting, but I assume you run clang-format before landing 
> anyway. LGTM.


Actually, I usually use it interactively while editing, and then do a final 
pass before creating the diff. However, it looks like I missed it this time. :) 
I have reformatted my local copy now.


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

https://reviews.llvm.org/D63005



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


[Lldb-commits] [PATCH] D62894: DWARF: Share line tables of type units

2019-06-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added inline comments.
This revision is now accepted and ready to land.



Comment at: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h:303
 
+  lldb_private::FileSpec GetSupportFile(DWARFUnit &unit, size_t file_idx);
+

labath wrote:
> JDevlieghere wrote:
> > clayborg wrote:
> > > Can probably just be named GetFile
> > Should this return an optional?
> I don't know. On one hand, both the level above this function and the level 
> below use an empty FileSpec do denote failure, so I'd have to convert it 
> explicitly in both places. OTOH, Optional is the direction we want to move in.
> 
> I can change it if you want..
Yeah it's a bit of a chicken & egg problem. I don't have a strong opinion, so 
I'm fine with keeping it as is. 


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

https://reviews.llvm.org/D62894



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


[Lldb-commits] [PATCH] D62894: DWARF: Share line tables of type units

2019-06-10 Thread Greg Clayton via Phabricator via lldb-commits
clayborg requested changes to this revision.
clayborg added a comment.
This revision now requires changes to proceed.

Still want to resolve getting files from a DWARFUnit a bit better. See inlined 
comment.




Comment at: source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp:309
+  decl.SetFile(
+  die.GetDWARF()->GetFile(*die.GetCU(), form_value.Unsigned()));
   break;

At the very least we should be asking the unit for the file? That is why I 
wanted to be able to ask the DWARFDIE for the file because it contains the 
right unit. If we just put the API on the unit, then we have the chance someone 
will use the wrong unit for the file. Also, as the DWARF gets fancier as time 
goes on (DWO, DWZ, etc), the unit might refer to another unit. But at the very 
least here I would feel better if we ask the DWARFUnit for the file. The 
GetDWARF() will ask the DWARFUnit in the DIE for the is DWARF file, then we 
will call the DWARF file class (SymbolFileDWARF or DWARFContext to get a file 
from the unit by passing a reference? Seems convoluted. Fine not adding the API 
as a FileSpec if we are trying to keep the API the same as LLVM.



Comment at: source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp:2261
+  decl.SetFile(
+  die.GetDWARF()->GetFile(*die.GetCU(), 
form_value.Unsigned()));
   break;

DWARFUnit::GetFile() or what ever solution we come up with from my previous 
long inlined comment.



Comment at: source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp:2418
+decl_up.reset(
+new Declaration(die.GetDWARF()->GetFile(*die.GetCU(), decl_file),
+decl_line, decl_column));

DWARFUnit::GetFile() or what ever solution we come up with from my previous 
long inlined comment.



Comment at: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp:289-326
+  DWARFAttributes attributes;
+  size_t num_attributes = cu_die.GetAttributes(this, attributes);
+  for (size_t i = 0; i < num_attributes; ++i) {
+dw_attr_t attr = attributes.AttributeAtIndex(i);
+DWARFFormValue form_value;
+if (!attributes.ExtractFormValueAtIndex(i, form_value))
+  continue;

much better! 


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

https://reviews.llvm.org/D62894



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


[Lldb-commits] [PATCH] D62502: Implement xfer:libraries-svr4:read packet

2019-06-10 Thread António Afonso via Phabricator via lldb-commits
aadsm marked an inline comment as done.
aadsm added inline comments.



Comment at: lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp:2181
+template 
+Status NativeProcessLinux::ReadSVR4LibraryInfo(lldb::addr_t link_map_addr,
+   SVR4LibraryInfo &info,

labath wrote:
> labath wrote:
> > This too could return an `llvm::Error`. 
> > `Expected>` is a bit of a mouthful, but 
> > I'd consider that instead of by-ref returns too..
> What about that llvm::Error?
oops sorry, missed this one. I do my best to check if I addressed all the 
comments but sometimes I miss some :(.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62502



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


[Lldb-commits] [PATCH] D63052: [Target] Remove Process::GetObjCLanguageRuntime

2019-06-10 Thread Alex Langford via Phabricator via lldb-commits
xiaobai marked an inline comment as done.
xiaobai added inline comments.



Comment at: include/lldb/Target/ObjCLanguageRuntime.h:202
 
+  static ObjCLanguageRuntime *GetObjCLanguageRuntime(Process &process) {
+return llvm::cast_or_null(

labath wrote:
> compnerd wrote:
> > I think it would be nice to just call this `Get` (and we could have 
> > equivalents in the other languages).  It makes the uses less verbose and 
> > repetitive.
> I like that idea.
I also like this idea. Would you mind if I did that in a follow up?


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

https://reviews.llvm.org/D63052



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


[Lldb-commits] [PATCH] D63052: [Target] Remove Process::GetObjCLanguageRuntime

2019-06-10 Thread Alex Langford via Phabricator via lldb-commits
xiaobai updated this revision to Diff 203872.
xiaobai added a comment.

Simplify a change


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

https://reviews.llvm.org/D63052

Files:
  include/lldb/Target/ObjCLanguageRuntime.h
  include/lldb/Target/Process.h
  include/lldb/lldb-forward.h
  source/API/SBTarget.cpp
  source/Core/ValueObject.cpp
  source/Expression/IRDynamicChecks.cpp
  source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
  source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
  source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
  source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
  source/Plugins/Language/ObjC/CF.cpp
  source/Plugins/Language/ObjC/Cocoa.cpp
  source/Plugins/Language/ObjC/NSArray.cpp
  source/Plugins/Language/ObjC/NSDictionary.cpp
  source/Plugins/Language/ObjC/NSError.cpp
  source/Plugins/Language/ObjC/NSException.cpp
  source/Plugins/Language/ObjC/NSIndexPath.cpp
  source/Plugins/Language/ObjC/NSSet.cpp
  source/Plugins/Language/ObjC/NSString.cpp
  source/Plugins/Language/ObjC/ObjCLanguage.cpp
  source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
  
source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
  
source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
  source/Symbol/ClangASTContext.cpp
  source/Target/Process.cpp

Index: source/Target/Process.cpp
===
--- source/Target/Process.cpp
+++ source/Target/Process.cpp
@@ -47,7 +47,6 @@
 #include "lldb/Target/LanguageRuntime.h"
 #include "lldb/Target/MemoryHistory.h"
 #include "lldb/Target/MemoryRegionInfo.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
 #include "lldb/Target/OperatingSystem.h"
 #include "lldb/Target/Platform.h"
 #include "lldb/Target/Process.h"
@@ -1597,13 +1596,6 @@
   return runtime;
 }
 
-ObjCLanguageRuntime *Process::GetObjCLanguageRuntime(bool retry_if_null) {
-  std::lock_guard guard(m_language_runtimes_mutex);
-  LanguageRuntime *runtime =
-  GetLanguageRuntime(eLanguageTypeObjC, retry_if_null);
-  return llvm::cast_or_null(runtime);
-}
-
 bool Process::IsPossibleDynamicValue(ValueObject &in_value) {
   if (m_finalizing)
 return false;
Index: source/Symbol/ClangASTContext.cpp
===
--- source/Symbol/ClangASTContext.cpp
+++ source/Symbol/ClangASTContext.cpp
@@ -5035,7 +5035,8 @@
   ExecutionContext exe_ctx(exe_scope);
   Process *process = exe_ctx.GetProcessPtr();
   if (process) {
-ObjCLanguageRuntime *objc_runtime = process->GetObjCLanguageRuntime();
+ObjCLanguageRuntime *objc_runtime =
+ObjCLanguageRuntime::GetObjCLanguageRuntime(*process);
 if (objc_runtime) {
   uint64_t bit_size = 0;
   if (objc_runtime->GetTypeBitSize(
@@ -6842,7 +6843,7 @@
   process = exe_ctx->GetProcessPtr();
 if (process) {
   ObjCLanguageRuntime *objc_runtime =
-  process->GetObjCLanguageRuntime();
+  ObjCLanguageRuntime::GetObjCLanguageRuntime(*process);
   if (objc_runtime != nullptr) {
 CompilerType parent_ast_type(getASTContext(),
  parent_qual_type);
Index: source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
===
--- source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
+++ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
@@ -171,7 +171,7 @@
   target_addr);
 
 ObjCLanguageRuntime *objc_runtime =
-GetThread().GetProcess()->GetObjCLanguageRuntime();
+ObjCLanguageRuntime::GetObjCLanguageRuntime(*GetThread().GetProcess());
 assert(objc_runtime != nullptr);
 objc_runtime->AddToMethodCache(m_isa_addr, m_sel_addr, target_addr);
 if (log)
Index: source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
===
--- source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
+++ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
@@ -457,8 +457,9 @@
 size_t num_modules = target_modules.GetSize();
 if (!m_objc_module_sp) {
   for (size_t i = 0; i < num_modules; i++) {
-if (process_sp->GetObjCLanguageRuntime()->IsModuleObjCLibrary(
-target_modules.GetModuleAtIndexUnlocked(i))) {
+if (ObjCLanguageRuntime::GetObjCLanguageRuntime(*process_sp)
+->IsModuleObjCLibrary(
+target_modules.GetModuleAtIndexUnlocked(i))) {
   m_objc_module_sp = target_modu

[Lldb-commits] [PATCH] D63052: [Target] Remove Process::GetObjCLanguageRuntime

2019-06-10 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: include/lldb/Target/ObjCLanguageRuntime.h:202
 
+  static ObjCLanguageRuntime *GetObjCLanguageRuntime(Process &process) {
+return llvm::cast_or_null(

xiaobai wrote:
> labath wrote:
> > compnerd wrote:
> > > I think it would be nice to just call this `Get` (and we could have 
> > > equivalents in the other languages).  It makes the uses less verbose and 
> > > repetitive.
> > I like that idea.
> I also like this idea. Would you mind if I did that in a follow up?
You're introducing the function in this patch. What's the point in renaming it 
immediately after that?

I can see how renaming GetCPPLanguageRuntime might be a good thing to do in a 
separate patch, but I don't see a reason to do that with this function


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

https://reviews.llvm.org/D63052



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


[Lldb-commits] [PATCH] D63052: [Target] Remove Process::GetObjCLanguageRuntime

2019-06-10 Thread Alex Langford via Phabricator via lldb-commits
xiaobai marked an inline comment as done.
xiaobai added inline comments.



Comment at: include/lldb/Target/ObjCLanguageRuntime.h:202
 
+  static ObjCLanguageRuntime *GetObjCLanguageRuntime(Process &process) {
+return llvm::cast_or_null(

labath wrote:
> xiaobai wrote:
> > labath wrote:
> > > compnerd wrote:
> > > > I think it would be nice to just call this `Get` (and we could have 
> > > > equivalents in the other languages).  It makes the uses less verbose 
> > > > and repetitive.
> > > I like that idea.
> > I also like this idea. Would you mind if I did that in a follow up?
> You're introducing the function in this patch. What's the point in renaming 
> it immediately after that?
> 
> I can see how renaming GetCPPLanguageRuntime might be a good thing to do in a 
> separate patch, but I don't see a reason to do that with this function
Fair enough. I'll update this patch.


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

https://reviews.llvm.org/D63052



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


[Lldb-commits] [PATCH] D63052: [Target] Remove Process::GetObjCLanguageRuntime

2019-06-10 Thread Alex Langford via Phabricator via lldb-commits
xiaobai updated this revision to Diff 203877.
xiaobai added a comment.

ObjCLanguageRuntime::GetObjCLanguageRuntime -> ObjCLanguageRuntime::Get


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

https://reviews.llvm.org/D63052

Files:
  include/lldb/Target/ObjCLanguageRuntime.h
  include/lldb/Target/Process.h
  include/lldb/lldb-forward.h
  source/API/SBTarget.cpp
  source/Core/ValueObject.cpp
  source/Expression/IRDynamicChecks.cpp
  source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
  source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
  source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
  source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
  source/Plugins/Language/ObjC/CF.cpp
  source/Plugins/Language/ObjC/Cocoa.cpp
  source/Plugins/Language/ObjC/NSArray.cpp
  source/Plugins/Language/ObjC/NSDictionary.cpp
  source/Plugins/Language/ObjC/NSError.cpp
  source/Plugins/Language/ObjC/NSException.cpp
  source/Plugins/Language/ObjC/NSIndexPath.cpp
  source/Plugins/Language/ObjC/NSSet.cpp
  source/Plugins/Language/ObjC/NSString.cpp
  source/Plugins/Language/ObjC/ObjCLanguage.cpp
  source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
  
source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
  
source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
  source/Symbol/ClangASTContext.cpp
  source/Target/Process.cpp

Index: source/Target/Process.cpp
===
--- source/Target/Process.cpp
+++ source/Target/Process.cpp
@@ -47,7 +47,6 @@
 #include "lldb/Target/LanguageRuntime.h"
 #include "lldb/Target/MemoryHistory.h"
 #include "lldb/Target/MemoryRegionInfo.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
 #include "lldb/Target/OperatingSystem.h"
 #include "lldb/Target/Platform.h"
 #include "lldb/Target/Process.h"
@@ -1597,13 +1596,6 @@
   return runtime;
 }
 
-ObjCLanguageRuntime *Process::GetObjCLanguageRuntime(bool retry_if_null) {
-  std::lock_guard guard(m_language_runtimes_mutex);
-  LanguageRuntime *runtime =
-  GetLanguageRuntime(eLanguageTypeObjC, retry_if_null);
-  return llvm::cast_or_null(runtime);
-}
-
 bool Process::IsPossibleDynamicValue(ValueObject &in_value) {
   if (m_finalizing)
 return false;
Index: source/Symbol/ClangASTContext.cpp
===
--- source/Symbol/ClangASTContext.cpp
+++ source/Symbol/ClangASTContext.cpp
@@ -5035,7 +5035,7 @@
   ExecutionContext exe_ctx(exe_scope);
   Process *process = exe_ctx.GetProcessPtr();
   if (process) {
-ObjCLanguageRuntime *objc_runtime = process->GetObjCLanguageRuntime();
+ObjCLanguageRuntime *objc_runtime = ObjCLanguageRuntime::Get(*process);
 if (objc_runtime) {
   uint64_t bit_size = 0;
   if (objc_runtime->GetTypeBitSize(
@@ -6842,7 +6842,7 @@
   process = exe_ctx->GetProcessPtr();
 if (process) {
   ObjCLanguageRuntime *objc_runtime =
-  process->GetObjCLanguageRuntime();
+  ObjCLanguageRuntime::Get(*process);
   if (objc_runtime != nullptr) {
 CompilerType parent_ast_type(getASTContext(),
  parent_qual_type);
Index: source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
===
--- source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
+++ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
@@ -171,7 +171,7 @@
   target_addr);
 
 ObjCLanguageRuntime *objc_runtime =
-GetThread().GetProcess()->GetObjCLanguageRuntime();
+ObjCLanguageRuntime::Get(*GetThread().GetProcess());
 assert(objc_runtime != nullptr);
 objc_runtime->AddToMethodCache(m_isa_addr, m_sel_addr, target_addr);
 if (log)
Index: source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
===
--- source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
+++ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
@@ -457,8 +457,9 @@
 size_t num_modules = target_modules.GetSize();
 if (!m_objc_module_sp) {
   for (size_t i = 0; i < num_modules; i++) {
-if (process_sp->GetObjCLanguageRuntime()->IsModuleObjCLibrary(
-target_modules.GetModuleAtIndexUnlocked(i))) {
+if (ObjCLanguageRuntime::Get(*process_sp)
+->IsModuleObjCLibrary(
+target_modules.GetModuleAtIndexUnlocked(i))) {
   m_objc_module_sp = target_modules.GetModuleAtIndexUnlocked(i);
  

[Lldb-commits] [lldb] r362981 - [Target] Remove Process::GetObjCLanguageRuntime

2019-06-10 Thread Alex Langford via lldb-commits
Author: xiaobai
Date: Mon Jun 10 13:53:23 2019
New Revision: 362981

URL: http://llvm.org/viewvc/llvm-project?rev=362981&view=rev
Log:
[Target] Remove Process::GetObjCLanguageRuntime

Summary:
In an effort to make Process more language agnostic, I removed
GetCPPLanguageRuntime from Process. I'm following up now with an equivalent
change for ObjC.

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

Modified:
lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h
lldb/trunk/include/lldb/Target/Process.h
lldb/trunk/include/lldb/lldb-forward.h
lldb/trunk/source/API/SBTarget.cpp
lldb/trunk/source/Core/ValueObject.cpp
lldb/trunk/source/Expression/IRDynamicChecks.cpp
lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
lldb/trunk/source/Plugins/Language/ObjC/CF.cpp
lldb/trunk/source/Plugins/Language/ObjC/Cocoa.cpp
lldb/trunk/source/Plugins/Language/ObjC/NSArray.cpp
lldb/trunk/source/Plugins/Language/ObjC/NSDictionary.cpp
lldb/trunk/source/Plugins/Language/ObjC/NSError.cpp
lldb/trunk/source/Plugins/Language/ObjC/NSException.cpp
lldb/trunk/source/Plugins/Language/ObjC/NSIndexPath.cpp
lldb/trunk/source/Plugins/Language/ObjC/NSSet.cpp
lldb/trunk/source/Plugins/Language/ObjC/NSString.cpp
lldb/trunk/source/Plugins/Language/ObjC/ObjCLanguage.cpp

lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp

lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp

lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
lldb/trunk/source/Symbol/ClangASTContext.cpp
lldb/trunk/source/Target/Process.cpp

Modified: lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h?rev=362981&r1=362980&r2=362981&view=diff
==
--- lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h (original)
+++ lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h Mon Jun 10 13:53:23 
2019
@@ -199,6 +199,11 @@ public:
 return runtime->isA(&ID);
   }
 
+  static ObjCLanguageRuntime *Get(Process &process) {
+return llvm::cast_or_null(
+process.GetLanguageRuntime(lldb::eLanguageTypeObjC));
+  }
+
   virtual TaggedPointerVendor *GetTaggedPointerVendor() { return nullptr; }
 
   typedef std::shared_ptr EncodingToTypeSP;

Modified: lldb/trunk/include/lldb/Target/Process.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=362981&r1=362980&r2=362981&view=diff
==
--- lldb/trunk/include/lldb/Target/Process.h (original)
+++ lldb/trunk/include/lldb/Target/Process.h Mon Jun 10 13:53:23 2019
@@ -2184,8 +2184,6 @@ public:
   LanguageRuntime *GetLanguageRuntime(lldb::LanguageType language,
   bool retry_if_null = true);
 
-  ObjCLanguageRuntime *GetObjCLanguageRuntime(bool retry_if_null = true);
-
   bool IsPossibleDynamicValue(ValueObject &in_value);
 
   bool IsRunning() const;

Modified: lldb/trunk/include/lldb/lldb-forward.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward.h?rev=362981&r1=362980&r2=362981&view=diff
==
--- lldb/trunk/include/lldb/lldb-forward.h (original)
+++ lldb/trunk/include/lldb/lldb-forward.h Mon Jun 10 13:53:23 2019
@@ -130,7 +130,6 @@ class ModuleList;
 class ModuleSpec;
 class ModuleSpecList;
 struct NameSearchContext;
-class ObjCLanguageRuntime;
 class ObjectContainer;
 class OptionGroup;
 class OptionGroupOptions;

Modified: lldb/trunk/source/API/SBTarget.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=362981&r1=362980&r2=362981&view=diff
==
--- lldb/trunk/source/API/SBTarget.cpp (original)
+++ lldb/trunk/source/API/SBTarget.cpp Mon Jun 10 13:53:23 2019
@@ -1854,7 +1854,7 @@ lldb::SBType SBTarget::FindFirstType(con
 
 if (process_sp) {
   ObjCLanguageRuntime *objc_language_runtime =
-  process_sp->GetObjCLanguageRuntime();
+  ObjCLanguageRuntime::Get(*process_sp);
 
   if (objc_language_runtime) {
 DeclVendor *objc_decl_vendor = objc_language_runtime->GetDeclVendor();
@@ -1924,7 +1924,7 @@ lldb::SBTypeList SBTarget::FindTypes(con
 
 if (process_sp) {
   ObjCLanguageRuntime *objc_language_runtime =
-  process_sp->GetObjCLanguageRuntime();
+  ObjCLanguageRuntime::Get(*process_sp);
 
 

[Lldb-commits] [PATCH] D63052: [Target] Remove Process::GetObjCLanguageRuntime

2019-06-10 Thread Alex Langford via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL362981: [Target] Remove Process::GetObjCLanguageRuntime 
(authored by xiaobai, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D63052

Files:
  lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h
  lldb/trunk/include/lldb/Target/Process.h
  lldb/trunk/include/lldb/lldb-forward.h
  lldb/trunk/source/API/SBTarget.cpp
  lldb/trunk/source/Core/ValueObject.cpp
  lldb/trunk/source/Expression/IRDynamicChecks.cpp
  lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
  lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
  lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
  lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
  lldb/trunk/source/Plugins/Language/ObjC/CF.cpp
  lldb/trunk/source/Plugins/Language/ObjC/Cocoa.cpp
  lldb/trunk/source/Plugins/Language/ObjC/NSArray.cpp
  lldb/trunk/source/Plugins/Language/ObjC/NSDictionary.cpp
  lldb/trunk/source/Plugins/Language/ObjC/NSError.cpp
  lldb/trunk/source/Plugins/Language/ObjC/NSException.cpp
  lldb/trunk/source/Plugins/Language/ObjC/NSIndexPath.cpp
  lldb/trunk/source/Plugins/Language/ObjC/NSSet.cpp
  lldb/trunk/source/Plugins/Language/ObjC/NSString.cpp
  lldb/trunk/source/Plugins/Language/ObjC/ObjCLanguage.cpp
  
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
  
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
  
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
  lldb/trunk/source/Symbol/ClangASTContext.cpp
  lldb/trunk/source/Target/Process.cpp

Index: lldb/trunk/source/API/SBTarget.cpp
===
--- lldb/trunk/source/API/SBTarget.cpp
+++ lldb/trunk/source/API/SBTarget.cpp
@@ -1854,7 +1854,7 @@
 
 if (process_sp) {
   ObjCLanguageRuntime *objc_language_runtime =
-  process_sp->GetObjCLanguageRuntime();
+  ObjCLanguageRuntime::Get(*process_sp);
 
   if (objc_language_runtime) {
 DeclVendor *objc_decl_vendor = objc_language_runtime->GetDeclVendor();
@@ -1924,7 +1924,7 @@
 
 if (process_sp) {
   ObjCLanguageRuntime *objc_language_runtime =
-  process_sp->GetObjCLanguageRuntime();
+  ObjCLanguageRuntime::Get(*process_sp);
 
   if (objc_language_runtime) {
 DeclVendor *objc_decl_vendor = objc_language_runtime->GetDeclVendor();
Index: lldb/trunk/source/Core/ValueObject.cpp
===
--- lldb/trunk/source/Core/ValueObject.cpp
+++ lldb/trunk/source/Core/ValueObject.cpp
@@ -302,7 +302,7 @@
 
   if (process_sp) {
 ObjCLanguageRuntime *objc_language_runtime(
-process_sp->GetObjCLanguageRuntime());
+ObjCLanguageRuntime::Get(*process_sp));
 
 if (objc_language_runtime) {
   TypeSP complete_objc_class_type_sp =
@@ -1699,7 +1699,7 @@
 LanguageRuntime *runtime =
 process->GetLanguageRuntime(GetObjectRuntimeLanguage());
 if (!runtime)
-  runtime = process->GetObjCLanguageRuntime();
+  runtime = ObjCLanguageRuntime::Get(*process);
 if (runtime)
   return runtime->IsRuntimeSupportValue(*this);
 // If there is no language runtime, trust the compiler to mark all
@@ -3399,4 +3399,3 @@
 return m_root_valobj_sp->GetFrameSP();
   return lldb::StackFrameSP();
 }
-
Index: lldb/trunk/source/Target/Process.cpp
===
--- lldb/trunk/source/Target/Process.cpp
+++ lldb/trunk/source/Target/Process.cpp
@@ -47,7 +47,6 @@
 #include "lldb/Target/LanguageRuntime.h"
 #include "lldb/Target/MemoryHistory.h"
 #include "lldb/Target/MemoryRegionInfo.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
 #include "lldb/Target/OperatingSystem.h"
 #include "lldb/Target/Platform.h"
 #include "lldb/Target/Process.h"
@@ -1597,13 +1596,6 @@
   return runtime;
 }
 
-ObjCLanguageRuntime *Process::GetObjCLanguageRuntime(bool retry_if_null) {
-  std::lock_guard guard(m_language_runtimes_mutex);
-  LanguageRuntime *runtime =
-  GetLanguageRuntime(eLanguageTypeObjC, retry_if_null);
-  return llvm::cast_or_null(runtime);
-}
-
 bool Process::IsPossibleDynamicValue(ValueObject &in_value) {
   if (m_finalizing)
 return false;
Index: lldb/trunk/source/Symbol/ClangASTContext.cpp
===
--- lldb/trunk/source/Symbol/ClangASTContext.cpp
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp
@@ -5035,7 +5035,7 @@
   ExecutionContext exe_ctx(exe_scope);
   Process *process = exe_ctx.GetProcessPtr();
   if (process) {
-ObjCLanguageRuntime *objc

[Lldb-commits] [PATCH] D62499: Create a generic handler for Xfer packets

2019-06-10 Thread António Afonso via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL362982: Create a generic handler for Xfer packets (authored 
by aadsm, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D62499?vs=203235&id=203895#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D62499

Files:
  lldb/trunk/include/lldb/Utility/StringExtractorGDBRemote.h
  lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
  lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h
  
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
  
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
  lldb/trunk/source/Utility/StringExtractorGDBRemote.cpp
  lldb/trunk/unittests/Process/gdb-remote/CMakeLists.txt
  lldb/trunk/unittests/Process/gdb-remote/GDBRemoteCommunicationServerTest.cpp
  lldb/trunk/unittests/Process/gdb-remote/GDBRemoteTestUtils.h

Index: lldb/trunk/include/lldb/Utility/StringExtractorGDBRemote.h
===
--- lldb/trunk/include/lldb/Utility/StringExtractorGDBRemote.h
+++ lldb/trunk/include/lldb/Utility/StringExtractorGDBRemote.h
@@ -128,7 +128,7 @@
 eServerPacketType_qVAttachOrWaitSupported,
 eServerPacketType_qWatchpointSupportInfo,
 eServerPacketType_qWatchpointSupportInfoSupported,
-eServerPacketType_qXfer_auxv_read,
+eServerPacketType_qXfer,
 
 eServerPacketType_jSignalsInfo,
 eServerPacketType_jModulesInfo,
Index: lldb/trunk/unittests/Process/gdb-remote/GDBRemoteCommunicationServerTest.cpp
===
--- lldb/trunk/unittests/Process/gdb-remote/GDBRemoteCommunicationServerTest.cpp
+++ lldb/trunk/unittests/Process/gdb-remote/GDBRemoteCommunicationServerTest.cpp
@@ -0,0 +1,73 @@
+//===-- GDBRemoteCommunicationServerTest.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 "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+#include "GDBRemoteTestUtils.h"
+
+#include "Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h"
+#include "lldb/Utility/Connection.h"
+
+namespace lldb_private {
+namespace process_gdb_remote {
+
+TEST(GDBRemoteCommunicationServerTest, SendErrorResponse_ErrorNumber) {
+  MockServerWithMockConnection server;
+  server.SendErrorResponse(0x42);
+
+  EXPECT_THAT(server.GetPackets(), testing::ElementsAre("$E42#ab"));
+}
+
+TEST(GDBRemoteCommunicationServerTest, SendErrorResponse_Status) {
+  MockServerWithMockConnection server;
+  Status status;
+
+  status.SetError(0x42, lldb::eErrorTypeGeneric);
+  status.SetErrorString("Test error message");
+  server.SendErrorResponse(status);
+
+  EXPECT_THAT(
+  server.GetPackets(),
+  testing::ElementsAre("$E42;54657374206572726f72206d657373616765#ad"));
+}
+
+TEST(GDBRemoteCommunicationServerTest, SendErrorResponse_UnimplementedError) {
+  MockServerWithMockConnection server;
+
+  auto error =
+  llvm::make_error("Test unimplemented error");
+  server.SendErrorResponse(std::move(error));
+
+  EXPECT_THAT(server.GetPackets(), testing::ElementsAre("$#00"));
+}
+
+TEST(GDBRemoteCommunicationServerTest, SendErrorResponse_StringError) {
+  MockServerWithMockConnection server;
+
+  auto error = llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "String error test");
+  server.SendErrorResponse(std::move(error));
+
+  EXPECT_THAT(
+  server.GetPackets(),
+  testing::ElementsAre("$Eff;537472696e67206572726f722074657374#b0"));
+}
+
+TEST(GDBRemoteCommunicationServerTest, SendErrorResponse_ErrorList) {
+  MockServerWithMockConnection server;
+
+  auto error = llvm::joinErrors(llvm::make_error(),
+llvm::make_error());
+
+  server.SendErrorResponse(std::move(error));
+  // Make sure only one packet is sent even when there are multiple errors.
+  EXPECT_EQ(server.GetPackets().size(), 1UL);
+}
+
+} // namespace process_gdb_remote
+} // namespace lldb_private
Index: lldb/trunk/unittests/Process/gdb-remote/GDBRemoteTestUtils.h
===
--- lldb/trunk/unittests/Process/gdb-remote/GDBRemoteTestUtils.h
+++ lldb/trunk/unittests/Process/gdb-remote/GDBRemoteTestUtils.h
@@ -8,9 +8,11 @@
 #ifndef lldb_unittests_Process_gdb_remote_GDBRemoteTestUtils_h
 #define lldb_unittests_Process_gdb_remote_GDBRemoteTestUtils_h
 
+#include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
 #include "Plugins/Process/gdb-remote/GDBRemoteCommunicationServe

[Lldb-commits] [lldb] r362984 - [Target][NFC] Rename GetCPPLanguageRuntime to Get

2019-06-10 Thread Alex Langford via lldb-commits
Author: xiaobai
Date: Mon Jun 10 14:04:31 2019
New Revision: 362984

URL: http://llvm.org/viewvc/llvm-project?rev=362984&view=rev
Log:
[Target][NFC] Rename GetCPPLanguageRuntime to Get

This is a followup to rL362981, in which I moved GetObjCLanguageRuntime
from Process to ObjCLanguageRuntime, renaming it to Get along the way.

Modified:
lldb/trunk/include/lldb/Target/CPPLanguageRuntime.h
lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxx.cpp

Modified: lldb/trunk/include/lldb/Target/CPPLanguageRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/CPPLanguageRuntime.h?rev=362984&r1=362983&r2=362984&view=diff
==
--- lldb/trunk/include/lldb/Target/CPPLanguageRuntime.h (original)
+++ lldb/trunk/include/lldb/Target/CPPLanguageRuntime.h Mon Jun 10 14:04:31 2019
@@ -53,7 +53,7 @@ public:
 return lldb::eLanguageTypeC_plus_plus;
   }
 
-  static CPPLanguageRuntime *GetCPPLanguageRuntime(Process &process) {
+  static CPPLanguageRuntime *Get(Process &process) {
 return llvm::cast_or_null(
 process.GetLanguageRuntime(lldb::eLanguageTypeC_plus_plus));
   }

Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxx.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxx.cpp?rev=362984&r1=362983&r2=362984&view=diff
==
--- lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxx.cpp (original)
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxx.cpp Mon Jun 10 14:04:31 
2019
@@ -67,8 +67,7 @@ bool lldb_private::formatters::LibcxxFun
   if (process == nullptr)
 return false;
 
-  CPPLanguageRuntime *cpp_runtime =
-  CPPLanguageRuntime::GetCPPLanguageRuntime(*process);
+  CPPLanguageRuntime *cpp_runtime = CPPLanguageRuntime::Get(*process);
 
   if (!cpp_runtime)
 return false;


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


[Lldb-commits] [lldb] r362985 - [Target] Use llvm::scope_exit to restore m_suppress_stop_hooks value.

2019-06-10 Thread Tatyana Krasnukha via lldb-commits
Author: tkrasnukha
Date: Mon Jun 10 14:13:37 2019
New Revision: 362985

URL: http://llvm.org/viewvc/llvm-project?rev=362985&view=rev
Log:
[Target] Use llvm::scope_exit to restore m_suppress_stop_hooks value.

Modified:
lldb/trunk/source/Target/Target.cpp

Modified: lldb/trunk/source/Target/Target.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=362985&r1=362984&r2=362985&view=diff
==
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Mon Jun 10 14:13:37 2019
@@ -57,6 +57,8 @@
 #include "lldb/Utility/StreamString.h"
 #include "lldb/Utility/Timer.h"
 
+#include "llvm/ADT/ScopeExit.h"
+
 #include 
 #include 
 
@@ -2380,10 +2382,11 @@ ExpressionResults Target::EvaluateExpres
   if (expr.empty())
 return execution_results;
 
-  // We shouldn't run stop hooks in expressions. Be sure to reset this if you
-  // return anywhere within this function.
+  // We shouldn't run stop hooks in expressions.
   bool old_suppress_value = m_suppress_stop_hooks;
   m_suppress_stop_hooks = true;
+  auto on_exit = llvm::make_scope_exit([this, old_suppress_value]() {
+  m_suppress_stop_hooks = old_suppress_value; });
 
   ExecutionContext exe_ctx;
 
@@ -2417,8 +2420,6 @@ ExpressionResults Target::EvaluateExpres
  ctx_obj);
   }
 
-  m_suppress_stop_hooks = old_suppress_value;
-
   return execution_results;
 }
 


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


[Lldb-commits] [PATCH] D63110: Fix a crash in option parsing.

2019-06-10 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl created this revision.
aprantl added a reviewer: JDevlieghere.
Herald added a project: LLDB.

The call to getopt_long didn't handle the case where the *last* option had an 
argument missing.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D63110

Files:
  lldb/lit/Driver/Inputs/process_attach_pid.in
  lldb/lit/Driver/TestProcessAttach.test
  lldb/source/Interpreter/Options.cpp


Index: lldb/source/Interpreter/Options.cpp
===
--- lldb/source/Interpreter/Options.cpp
+++ lldb/source/Interpreter/Options.cpp
@@ -1362,6 +1362,12 @@
 int long_options_index = -1;
 val = OptionParser::Parse(argv.size(), &*argv.begin(), sstr.GetString(),
   long_options, &long_options_index);
+
+if ((size_t)OptionParser::GetOptionIndex() > argv.size()) {
+  error.SetErrorStringWithFormat("option requires an argument");
+  break;
+}
+
 if (val == -1)
   break;
 
Index: lldb/lit/Driver/TestProcessAttach.test
===
--- /dev/null
+++ lldb/lit/Driver/TestProcessAttach.test
@@ -0,0 +1,2 @@
+# RUN: %lldb -x -b -S %S/Inputs/process_attach_pid.in 2>&1 | FileCheck %s
+# CHECK: requires an argument
Index: lldb/lit/Driver/Inputs/process_attach_pid.in
===
--- /dev/null
+++ lldb/lit/Driver/Inputs/process_attach_pid.in
@@ -0,0 +1 @@
+process attach --pid


Index: lldb/source/Interpreter/Options.cpp
===
--- lldb/source/Interpreter/Options.cpp
+++ lldb/source/Interpreter/Options.cpp
@@ -1362,6 +1362,12 @@
 int long_options_index = -1;
 val = OptionParser::Parse(argv.size(), &*argv.begin(), sstr.GetString(),
   long_options, &long_options_index);
+
+if ((size_t)OptionParser::GetOptionIndex() > argv.size()) {
+  error.SetErrorStringWithFormat("option requires an argument");
+  break;
+}
+
 if (val == -1)
   break;
 
Index: lldb/lit/Driver/TestProcessAttach.test
===
--- /dev/null
+++ lldb/lit/Driver/TestProcessAttach.test
@@ -0,0 +1,2 @@
+# RUN: %lldb -x -b -S %S/Inputs/process_attach_pid.in 2>&1 | FileCheck %s
+# CHECK: requires an argument
Index: lldb/lit/Driver/Inputs/process_attach_pid.in
===
--- /dev/null
+++ lldb/lit/Driver/Inputs/process_attach_pid.in
@@ -0,0 +1 @@
+process attach --pid
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D62502: Implement xfer:libraries-svr4:read packet

2019-06-10 Thread António Afonso via Phabricator via lldb-commits
aadsm updated this revision to Diff 203947.
aadsm added a comment.

- Update test to just wait for the process to stop
- Change ReadSVR4LibraryInfo signature to return an Expected to the list of 
libraries and stop taking params by ref.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62502

Files:
  lldb/include/lldb/Host/common/NativeProcessProtocol.h
  lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/Makefile
  
lldb/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/TestGdbRemoteLibrariesSvr4Support.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/main.cpp
  
lldb/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/svr4lib_a.cpp
  
lldb/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/svr4lib_a.mk
  
lldb/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/svr4lib_b_quote.cpp
  
lldb/packages/Python/lldbsuite/test/tools/lldb-server/libraries-svr4/svr4lib_b_quote.mk
  lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
  lldb/source/Plugins/Process/Linux/NativeProcessLinux.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h

Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
@@ -196,6 +196,8 @@
   llvm::Expected>
   ReadXferObject(llvm::StringRef object, llvm::StringRef annex);
 
+  static std::string XMLEncodeAttributeValue(llvm::StringRef value);
+
 private:
   void HandleInferiorState_Exited(NativeProcessProtocol *process);
 
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -2765,6 +2765,24 @@
 return std::move(*buffer_or_error);
   }
 
+  if (object == "libraries-svr4") {
+auto library_list = m_debugged_process_up->GetLoadedSVR4Libraries();
+if (!library_list)
+  return library_list.takeError();
+
+StreamString response;
+response.Printf("");
+for (auto const &library : *library_list) {
+  response.Printf("", library.ld_addr);
+}
+response.Printf("");
+return MemoryBuffer::getMemBufferCopy(response.GetString(), __FUNCTION__);
+  }
+
   return llvm::make_error(
   "Xfer object not supported");
 }
@@ -3283,3 +3301,28 @@
 
   return GDBRemoteCommunicationServerCommon::FindModuleFile(module_path, arch);
 }
+
+std::string GDBRemoteCommunicationServerLLGS::XMLEncodeAttributeValue(
+llvm::StringRef value) {
+  std::string result;
+  for (const char &c : value) {
+switch (c) {
+case '\'':
+  result += "'";
+  break;
+case '"':
+  result += """;
+  break;
+case '<':
+  result += "<";
+  break;
+case '>':
+  result += ">";
+  break;
+default:
+  result += c;
+  break;
+}
+  }
+  return result;
+}
\ No newline at end of file
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
@@ -826,6 +826,9 @@
   response.PutCString(";QPassSignals+");
   response.PutCString(";qXfer:auxv:read+");
 #endif
+#if defined(__linux__)
+  response.PutCString(";qXfer:libraries-svr4:read+");
+#endif
 
   return SendPacketNoLock(response.GetString());
 }
Index: lldb/source/Plugins/Process/Linux/NativeProcessLinux.h
===
--- lldb/source/Plugins/Process/Linux/NativeProcessLinux.h
+++ lldb/source/Plugins/Process/Linux/NativeProcessLinux.h
@@ -76,6 +76,9 @@
 
   Status DeallocateMemory(lldb::addr_t addr) override;
 
+  llvm::Expected>
+  GetLoadedSVR4Libraries() override;
+
   size_t UpdateThreads() override;
 
   const ArchSpec &GetArchitecture() const override { return m_arch; }
@@ -127,6 +130,10 @@
   llvm::Expected>
   GetSoftwareBreakpointTrapOpcode(size_t size_hint) override;
 
+  template 
+  llvm::Expected
+  ReadSVR4LibraryInfo(lldb::addr_t link_map_addr);
+
 private:
   MainLoop::SignalHandleUP m_sigchld_handle;
   ArchSpec m_arch;
Index: lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
=

[Lldb-commits] [PATCH] D62503: Add ReadCStringFromMemory for faster string reads

2019-06-10 Thread António Afonso via Phabricator via lldb-commits
aadsm updated this revision to Diff 203948.
aadsm added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62503

Files:
  lldb/include/lldb/Host/common/NativeProcessProtocol.h
  lldb/source/Host/common/NativeProcessProtocol.cpp
  lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
  lldb/unittests/Host/NativeProcessProtocolTest.cpp

Index: lldb/unittests/Host/NativeProcessProtocolTest.cpp
===
--- lldb/unittests/Host/NativeProcessProtocolTest.cpp
+++ lldb/unittests/Host/NativeProcessProtocolTest.cpp
@@ -96,3 +96,39 @@
   EXPECT_THAT_EXPECTED(Process.ReadMemoryWithoutTrap(4, 2),
llvm::HasValue(std::vector{4, 5}));
 }
+
+TEST(NativeProcessProtocolTest, ReadCStringFromMemory) {
+  NiceMock DummyDelegate;
+  MockProcess Process(DummyDelegate,
+ ArchSpec("aarch64-pc-linux"));
+  FakeMemory M{{'h', 'e', 'l', 'l', 'o', 0, 'w', 'o'}};
+  EXPECT_CALL(Process, ReadMemory(_, _))
+  .WillRepeatedly(Invoke(&M, &FakeMemory::Read));
+
+  char string[1024];
+  size_t bytes_read;
+  EXPECT_THAT_ERROR(
+  Process.ReadCStringFromMemory(0x0, &string[0], sizeof(string), bytes_read)
+  .ToError(),
+  llvm::Succeeded());
+  EXPECT_STREQ(string, "hello");
+  EXPECT_EQ(bytes_read, 6UL);
+}
+
+TEST(NativeProcessProtocolTest, ReadCStringFromMemory_MaxSize) {
+  NiceMock DummyDelegate;
+  MockProcess Process(DummyDelegate,
+ ArchSpec("aarch64-pc-linux"));
+  FakeMemory M{{'h', 'e', 'l', 'l', 'o', 0, 'w', 'o'}};
+  EXPECT_CALL(Process, ReadMemory(_, _))
+  .WillRepeatedly(Invoke(&M, &FakeMemory::Read));
+
+  char string[4];
+  size_t bytes_read;
+  EXPECT_THAT_ERROR(
+  Process.ReadCStringFromMemory(0x0, &string[0], sizeof(string), bytes_read)
+  .ToError(),
+  llvm::Succeeded());
+  EXPECT_STREQ(string, "hel");
+  EXPECT_EQ(bytes_read, 3UL);
+}
Index: lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
===
--- lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
+++ lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
@@ -2089,11 +2089,11 @@
 return error.ToError();
 
   char name_buffer[PATH_MAX];
-  error = ReadMemory(link_map.l_name, &name_buffer, sizeof(name_buffer),
- bytes_read);
+  error = ReadCStringFromMemory(link_map.l_name,
+reinterpret_cast(&name_buffer),
+sizeof(name_buffer), bytes_read);
   if (!error.Success())
 return error.ToError();
-  name_buffer[PATH_MAX - 1] = '\0';
 
   SVR4LibraryInfo info;
   info.name = std::string(name_buffer);
Index: lldb/source/Host/common/NativeProcessProtocol.cpp
===
--- lldb/source/Host/common/NativeProcessProtocol.cpp
+++ lldb/source/Host/common/NativeProcessProtocol.cpp
@@ -16,6 +16,8 @@
 #include "lldb/Utility/State.h"
 #include "lldb/lldb-enumerations.h"
 
+#include "llvm/Support/Process.h"
+
 using namespace lldb;
 using namespace lldb_private;
 
@@ -659,6 +661,52 @@
   return Status();
 }
 
+Status NativeProcessProtocol::ReadCStringFromMemory(lldb::addr_t addr,
+char *buffer,
+size_t max_size,
+size_t &total_bytes_read) {
+  const size_t cache_line_size = llvm::sys::Process::getPageSizeEstimate();
+  size_t bytes_read = 0;
+  size_t bytes_left = max_size;
+  addr_t curr_addr = addr;
+  char *curr_buffer = buffer;
+  total_bytes_read = 0;
+  Status error;
+
+  while (bytes_left > 0 && error.Success()) {
+addr_t cache_line_bytes_left =
+cache_line_size - (curr_addr % cache_line_size);
+addr_t bytes_to_read = std::min(bytes_left, cache_line_bytes_left);
+error = ReadMemory(curr_addr, reinterpret_cast(curr_buffer),
+   bytes_to_read, bytes_read);
+
+if (bytes_read == 0)
+  break;
+
+auto str_end = std::memchr(curr_buffer, '\0', bytes_read);
+if (str_end != NULL) {
+  total_bytes_read =
+  (size_t)(reinterpret_cast(str_end) - buffer + 1);
+  error.Clear();
+  break;
+}
+
+total_bytes_read += bytes_read;
+curr_buffer += bytes_read;
+curr_addr = reinterpret_cast(reinterpret_cast(curr_addr) +
+ bytes_read);
+bytes_left -= bytes_read;
+  }
+
+  // Make sure we return a null terminated string.
+  if (bytes_left == 0 && buffer[max_size - 1] != '\0') {
+buffer[max_size - 1] = '\0';
+total_bytes_read--;
+  }
+
+  return error;
+}
+
 lldb::StateType NativeProcessProtocol::GetState() const {
   std::lock_guard guard(m_state_mutex);
   return m_state;
Index:

[Lldb-commits] [PATCH] D63110: Fix a crash in option parsing.

2019-06-10 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!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63110



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