[Lldb-commits] [PATCH] D46810: 3/3: Fix DWARFUnit::GetUnitDIEPtrOnly stale pointer

2018-09-27 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

@xbolva00 As you gave no reprodudcer it would be good to know how those two 
`DWARFDebugInfoEntry`s differ. Without that I can look at it more only next 
week - travelling.


Repository:
  rL LLVM

https://reviews.llvm.org/D46810



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


[Lldb-commits] [PATCH] D51874: Fix buildbot regression by rL339929: NameError: global name 'test_directory' is not defined

2018-10-03 Thread Jan Kratochvil via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB343726: Fix buildbot regression by rL339929: NameError: 
global name 'test_directory' is… (authored by jankratochvil, 
committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D51874?vs=164709&id=168179#toc

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D51874

Files:
  packages/Python/lldbsuite/test/dosep.py


Index: packages/Python/lldbsuite/test/dosep.py
===
--- packages/Python/lldbsuite/test/dosep.py
+++ packages/Python/lldbsuite/test/dosep.py
@@ -1689,7 +1689,7 @@
 # move core files into session dir
 cores = find('core.*', test_subdir)
 for core in cores:
-dst = core.replace(test_directory, "")[1:]
+dst = core.replace(test_subdir, "")[1:]
 dst = dst.replace(os.path.sep, "-")
 os.rename(core, os.path.join(session_dir, dst))
 


Index: packages/Python/lldbsuite/test/dosep.py
===
--- packages/Python/lldbsuite/test/dosep.py
+++ packages/Python/lldbsuite/test/dosep.py
@@ -1689,7 +1689,7 @@
 # move core files into session dir
 cores = find('core.*', test_subdir)
 for core in cores:
-dst = core.replace(test_directory, "")[1:]
+dst = core.replace(test_subdir, "")[1:]
 dst = dst.replace(os.path.sep, "-")
 os.rename(core, os.path.join(session_dir, dst))
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D53255: Fix: Assertion failed: (!m_first_die || m_first_die == m_die_array.front()), function ExtractDIEsRWLocked

2018-10-14 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil created this revision.
jankratochvil added reviewers: clayborg, labath.
jankratochvil added a project: LLDB.
Herald added subscribers: JDevlieghere, aprantl.

xbolva00 bugreported $subj 
It can happen only from the line:

  m_die_array.back().SetEmptyChildren(true);

In the case `DW_TAG_compile_unit` has `DW_CHILDREN_yes` but there is only 0 
(end of list, no children present). Therefore the assertion can fortunately 
happen only with a hand-crafted DWARF or with DWARF from some suboptimal 
compilers.
I could not find a reproducer with unpatched LLDB code, could you provide what 
LLDB commands could reproduce that? A debuggee binary which can reproduce it 
is: lldb-repro.tar.xz 


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D53255

Files:
  source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp


Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -261,7 +261,11 @@
   }
 
   if (!m_die_array.empty()) {
-lldbassert(!m_first_die || m_first_die == m_die_array.front());
+if (m_first_die) {
+  // Only needed for the assertion.
+  m_first_die.SetEmptyChildren(m_die_array.front().GetEmptyChildren());
+  lldbassert(m_first_die == m_die_array.front());
+}
 m_first_die = m_die_array.front();
   }
 


Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -261,7 +261,11 @@
   }
 
   if (!m_die_array.empty()) {
-lldbassert(!m_first_die || m_first_die == m_die_array.front());
+if (m_first_die) {
+  // Only needed for the assertion.
+  m_first_die.SetEmptyChildren(m_die_array.front().GetEmptyChildren());
+  lldbassert(m_first_die == m_die_array.front());
+}
 m_first_die = m_die_array.front();
   }
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D46810: 3/3: Fix DWARFUnit::GetUnitDIEPtrOnly stale pointer

2018-10-14 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added inline comments.



Comment at: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp:179
+  if (!m_die_array.empty()) {
+lldbassert(!m_first_die || m_first_die == m_die_array.front());
+m_first_die = m_die_array.front();

labath wrote:
> xbolva00 wrote:
> > xbolva00 wrote:
> > > @jankratochvil is this correct assert? Our downstream lldb based on lldb 
> > > 7 with our custom targets hits this assert.  If we remove it, we see no 
> > > obvious breakages.
> > cc @labath 
> I agree with Jan. The two dies should be the same. The fact that they aren't 
> probably means there is a bug somewhere. It would be good to know how the two 
> dies differ and what is the input dwarf they are generated from.
A fix of this assertion is now submitted as: D53255


Repository:
  rL LLVM

https://reviews.llvm.org/D46810



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


[Lldb-commits] [PATCH] D53255: Fix: Assertion failed: (!m_first_die || m_first_die == m_die_array.front()), function ExtractDIEsRWLocked

2018-10-14 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

In https://reviews.llvm.org/D53255#1264782, @xbolva00 wrote:

> reproducer archive - 404 not found


Fixed, sorry.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D53255



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


[Lldb-commits] [PATCH] D53255: Fix: Assertion failed: (!m_first_die || m_first_die == m_die_array.front()), function ExtractDIEsRWLocked

2018-10-16 Thread Jan Kratochvil via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL344605: Fix: Assertion failed: (!m_first_die || m_first_die 
== m_die_array.front())… (authored by jankratochvil, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D53255?vs=169598&id=169808#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D53255

Files:
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp


Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -261,7 +261,11 @@
   }
 
   if (!m_die_array.empty()) {
-lldbassert(!m_first_die || m_first_die == m_die_array.front());
+if (m_first_die) {
+  // Only needed for the assertion.
+  m_first_die.SetEmptyChildren(m_die_array.front().GetEmptyChildren());
+  lldbassert(m_first_die == m_die_array.front());
+}
 m_first_die = m_die_array.front();
   }
 


Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -261,7 +261,11 @@
   }
 
   if (!m_die_array.empty()) {
-lldbassert(!m_first_die || m_first_die == m_die_array.front());
+if (m_first_die) {
+  // Only needed for the assertion.
+  m_first_die.SetEmptyChildren(m_die_array.front().GetEmptyChildren());
+  lldbassert(m_first_die == m_die_array.front());
+}
 m_first_die = m_die_array.front();
   }
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D53321: Code cleanup: Remove DWARFDebugInfoEntry::m_empty_children

2018-10-16 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil created this revision.
jankratochvil added reviewers: aprantl, clayborg.
jankratochvil added a project: LLDB.
Herald added a subscriber: JDevlieghere.

As @aprantl suggested  I have merged 
`DWARFDebugInfoEntry`'s `m_empty_children` into `m_has_children`.
`m_empty_children` was implemented by https://reviews.llvm.org/rL144983. I do 
not see why @clayborg made it a separate flag, from some point of view it is 
sure cleaner but technically I do not see its purpose.
I have checked all calls of `HasChildren()` that it should not matter to them. 
The code even wants to know if there are any children - it does not matter how 
the children presence is coded in the binary.
The only problematic may be `operator==` (and `!=`) although that one is 
currently only used by my `lldbassert()` in my bugfixed 
https://reviews.llvm.org/D53255.
This patch sure has no regressions on Fedora 28 x86_64.
I do not need/request this patch, just that @aprantl asked about it.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D53321

Files:
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
  source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp


Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -223,7 +223,7 @@
   // the list (saves up to 25% in C++ code), we need a way to let the
   // DIE know that it actually doesn't have children.
   if (!m_die_array.empty())
-m_die_array.back().SetEmptyChildren(true);
+m_die_array.back().SetHasChildren(false);
 }
   } else {
 die.SetParentIndex(m_die_array.size() - die_index_stack[depth - 1]);
@@ -263,7 +263,7 @@
   if (!m_die_array.empty()) {
 if (m_first_die) {
   // Only needed for the assertion.
-  m_first_die.SetEmptyChildren(m_die_array.front().GetEmptyChildren());
+  m_first_die.SetHasChildren(m_die_array.front().HasChildren());
   lldbassert(m_first_die == m_die_array.front());
 }
 m_first_die = m_die_array.front();
Index: source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
===
--- source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
+++ source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
@@ -57,8 +57,7 @@
 
   DWARFDebugInfoEntry()
   : m_offset(DW_INVALID_OFFSET), m_parent_idx(0), m_sibling_idx(0),
-m_empty_children(false), m_abbr_idx(0), m_has_children(false),
-m_tag(0) {}
+m_abbr_idx(0), m_has_children(false), m_tag(0) {}
 
   explicit operator bool() const { return m_offset != DW_INVALID_OFFSET; }
   bool operator==(const DWARFDebugInfoEntry &rhs) const;
@@ -227,10 +226,10 @@
   // we don't need to store our child pointer, if we have a child it will
   // be the next entry in the list...
   DWARFDebugInfoEntry *GetFirstChild() {
-return (HasChildren() && !m_empty_children) ? this + 1 : NULL;
+return HasChildren() ? this + 1 : NULL;
   }
   const DWARFDebugInfoEntry *GetFirstChild() const {
-return (HasChildren() && !m_empty_children) ? this + 1 : NULL;
+return HasChildren() ? this + 1 : NULL;
   }
 
   void GetDeclContextDIEs(DWARFUnit *cu,
@@ -271,10 +270,6 @@
 
   void SetParentIndex(uint32_t idx) { m_parent_idx = idx; }
 
-  bool GetEmptyChildren() const { return m_empty_children; }
-
-  void SetEmptyChildren(bool b) { m_empty_children = b; }
-
   static void
   DumpDIECollection(lldb_private::Stream &strm,
 DWARFDebugInfoEntry::collection &die_collection);
@@ -284,11 +279,12 @@
   m_offset; // Offset within the .debug_info of the start of this entry
   uint32_t m_parent_idx; // How many to subtract from "this" to get the parent.
  // If zero this die has no parent
-  uint32_t m_sibling_idx : 31, // How many to add to "this" to get the sibling.
-  m_empty_children : 1;// If a DIE says it had children, yet it just
-   // contained a NULL tag, this will be set.
+  uint32_t m_sibling_idx; // How many to add to "this" to get the sibling.
   uint32_t m_abbr_idx : DIE_ABBR_IDX_BITSIZE,
 m_has_children : 1, // Set to 1 if this DIE has 
children
+// It is zero if a DIE says it had
+// children, yet it just contained
+// a NULL tag.
 m_tag : 16; // A copy of the DW_TAG value so we don't
 // have to go through the compile unit
 // abbrev table
Index: source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
===

[Lldb-commits] [PATCH] D53255: Fix: Assertion failed: (!m_first_die || m_first_die == m_die_array.front()), function ExtractDIEsRWLocked

2018-10-16 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

In https://reviews.llvm.org/D53255#1265520, @aprantl wrote:

> Out of curiosity: why do we allow for both an empty array and an empty 
> children sentinel? Is that distinction useful?


Filed for that new https://reviews.llvm.org/D53321.


Repository:
  rL LLVM

https://reviews.llvm.org/D53255



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


[Lldb-commits] [PATCH] D53321: Code cleanup: Remove DWARFDebugInfoEntry::m_empty_children

2018-10-16 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil marked 2 inline comments as done.
jankratochvil added inline comments.



Comment at: source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h:285-287
+// It is zero if a DIE says it had
+// children, yet it just contained
+// a NULL tag.

clayborg wrote:
> This comment is wrong. The DWARF encodes if a DIE has children in the 
> .debug_info, but we may override this value if the DIE only contains an NULL 
> terminating DIE.
> 
> It should read something like:
> ```
> // If it is zero, then the DIE doesn't have children, or the 
> // DWARF claimed it had children but the DIE only contained 
> // a single NULL terminating child.
> ```
> 
> 
I cannot say it was wrong but I agree your rewording is much better.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D53321



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


[Lldb-commits] [PATCH] D53321: Code cleanup: Remove DWARFDebugInfoEntry::m_empty_children

2018-10-16 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 169850.
jankratochvil marked an inline comment as done.

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D53321

Files:
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
  source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp

Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -223,7 +223,7 @@
   // the list (saves up to 25% in C++ code), we need a way to let the
   // DIE know that it actually doesn't have children.
   if (!m_die_array.empty())
-m_die_array.back().SetEmptyChildren(true);
+m_die_array.back().SetHasChildren(false);
 }
   } else {
 die.SetParentIndex(m_die_array.size() - die_index_stack[depth - 1]);
@@ -263,7 +263,7 @@
   if (!m_die_array.empty()) {
 if (m_first_die) {
   // Only needed for the assertion.
-  m_first_die.SetEmptyChildren(m_die_array.front().GetEmptyChildren());
+  m_first_die.SetHasChildren(m_die_array.front().HasChildren());
   lldbassert(m_first_die == m_die_array.front());
 }
 m_first_die = m_die_array.front();
Index: source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
===
--- source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
+++ source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
@@ -43,7 +43,7 @@
 class DWARFDeclContext;
 
 #define DIE_SIBLING_IDX_BITSIZE 31
-#define DIE_ABBR_IDX_BITSIZE 15
+#define DIE_ABBR_IDX_BITSIZE 16
 
 class DWARFDebugInfoEntry {
 public:
@@ -57,8 +57,7 @@
 
   DWARFDebugInfoEntry()
   : m_offset(DW_INVALID_OFFSET), m_parent_idx(0), m_sibling_idx(0),
-m_empty_children(false), m_abbr_idx(0), m_has_children(false),
-m_tag(0) {}
+m_abbr_idx(0), m_has_children(false), m_tag(0) {}
 
   explicit operator bool() const { return m_offset != DW_INVALID_OFFSET; }
   bool operator==(const DWARFDebugInfoEntry &rhs) const;
@@ -227,10 +226,10 @@
   // we don't need to store our child pointer, if we have a child it will
   // be the next entry in the list...
   DWARFDebugInfoEntry *GetFirstChild() {
-return (HasChildren() && !m_empty_children) ? this + 1 : NULL;
+return HasChildren() ? this + 1 : NULL;
   }
   const DWARFDebugInfoEntry *GetFirstChild() const {
-return (HasChildren() && !m_empty_children) ? this + 1 : NULL;
+return HasChildren() ? this + 1 : NULL;
   }
 
   void GetDeclContextDIEs(DWARFUnit *cu,
@@ -271,10 +270,6 @@
 
   void SetParentIndex(uint32_t idx) { m_parent_idx = idx; }
 
-  bool GetEmptyChildren() const { return m_empty_children; }
-
-  void SetEmptyChildren(bool b) { m_empty_children = b; }
-
   static void
   DumpDIECollection(lldb_private::Stream &strm,
 DWARFDebugInfoEntry::collection &die_collection);
@@ -285,10 +280,11 @@
   uint32_t m_parent_idx; // How many to subtract from "this" to get the parent.
  // If zero this die has no parent
   uint32_t m_sibling_idx : 31, // How many to add to "this" to get the sibling.
-  m_empty_children : 1;// If a DIE says it had children, yet it just
-   // contained a NULL tag, this will be set.
+  // If it is zero, then the DIE doesn't have children, or the
+  // DWARF claimed it had children but the DIE only contained
+  // a single NULL terminating child.
+  m_has_children : 1;
   uint32_t m_abbr_idx : DIE_ABBR_IDX_BITSIZE,
-m_has_children : 1, // Set to 1 if this DIE has children
 m_tag : 16; // A copy of the DW_TAG value so we don't
 // have to go through the compile unit
 // abbrev table
Index: source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -40,7 +40,6 @@
   m_offset = *offset_ptr;
   m_parent_idx = 0;
   m_sibling_idx = 0;
-  m_empty_children = false;
   const uint64_t abbr_idx = debug_info_data.GetULEB128(offset_ptr);
   assert(abbr_idx < (1 << DIE_ABBR_IDX_BITSIZE));
   m_abbr_idx = abbr_idx;
@@ -1836,7 +1835,6 @@
 bool DWARFDebugInfoEntry::operator==(const DWARFDebugInfoEntry &rhs) const {
   return m_offset == rhs.m_offset && m_parent_idx == rhs.m_parent_idx &&
  m_sibling_idx == rhs.m_sibling_idx &&
- m_empty_children == rhs.m_empty_children &&
  m_abbr_idx == rhs.m_abbr_idx && m_has_children == rhs.m_has_children &&
  m_tag == rhs.m_tag;
 }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-

[Lldb-commits] [PATCH] D53321: Code cleanup: Remove DWARFDebugInfoEntry::m_empty_children

2018-10-16 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 169873.
jankratochvil added a comment.

Done the conversion of bitfield to uint16_t.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D53321

Files:
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
  source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp

Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -223,7 +223,7 @@
   // the list (saves up to 25% in C++ code), we need a way to let the
   // DIE know that it actually doesn't have children.
   if (!m_die_array.empty())
-m_die_array.back().SetEmptyChildren(true);
+m_die_array.back().SetHasChildren(false);
 }
   } else {
 die.SetParentIndex(m_die_array.size() - die_index_stack[depth - 1]);
@@ -263,7 +263,7 @@
   if (!m_die_array.empty()) {
 if (m_first_die) {
   // Only needed for the assertion.
-  m_first_die.SetEmptyChildren(m_die_array.front().GetEmptyChildren());
+  m_first_die.SetHasChildren(m_die_array.front().HasChildren());
   lldbassert(m_first_die == m_die_array.front());
 }
 m_first_die = m_die_array.front();
Index: source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
===
--- source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
+++ source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
@@ -43,7 +43,6 @@
 class DWARFDeclContext;
 
 #define DIE_SIBLING_IDX_BITSIZE 31
-#define DIE_ABBR_IDX_BITSIZE 15
 
 class DWARFDebugInfoEntry {
 public:
@@ -57,8 +56,7 @@
 
   DWARFDebugInfoEntry()
   : m_offset(DW_INVALID_OFFSET), m_parent_idx(0), m_sibling_idx(0),
-m_empty_children(false), m_abbr_idx(0), m_has_children(false),
-m_tag(0) {}
+m_has_children(false), m_abbr_idx(0), m_tag(0) {}
 
   explicit operator bool() const { return m_offset != DW_INVALID_OFFSET; }
   bool operator==(const DWARFDebugInfoEntry &rhs) const;
@@ -227,10 +225,10 @@
   // we don't need to store our child pointer, if we have a child it will
   // be the next entry in the list...
   DWARFDebugInfoEntry *GetFirstChild() {
-return (HasChildren() && !m_empty_children) ? this + 1 : NULL;
+return HasChildren() ? this + 1 : NULL;
   }
   const DWARFDebugInfoEntry *GetFirstChild() const {
-return (HasChildren() && !m_empty_children) ? this + 1 : NULL;
+return HasChildren() ? this + 1 : NULL;
   }
 
   void GetDeclContextDIEs(DWARFUnit *cu,
@@ -271,10 +269,6 @@
 
   void SetParentIndex(uint32_t idx) { m_parent_idx = idx; }
 
-  bool GetEmptyChildren() const { return m_empty_children; }
-
-  void SetEmptyChildren(bool b) { m_empty_children = b; }
-
   static void
   DumpDIECollection(lldb_private::Stream &strm,
 DWARFDebugInfoEntry::collection &die_collection);
@@ -285,13 +279,13 @@
   uint32_t m_parent_idx; // How many to subtract from "this" to get the parent.
  // If zero this die has no parent
   uint32_t m_sibling_idx : 31, // How many to add to "this" to get the sibling.
-  m_empty_children : 1;// If a DIE says it had children, yet it just
-   // contained a NULL tag, this will be set.
-  uint32_t m_abbr_idx : DIE_ABBR_IDX_BITSIZE,
-m_has_children : 1, // Set to 1 if this DIE has children
-m_tag : 16; // A copy of the DW_TAG value so we don't
-// have to go through the compile unit
-// abbrev table
+  // If it is zero, then the DIE doesn't have children, or the
+  // DWARF claimed it had children but the DIE only contained
+  // a single NULL terminating child.
+  m_has_children : 1;
+  uint16_t m_abbr_idx;
+  uint16_t m_tag; // A copy of the DW_TAG value so we don't have to go through
+  // the compile unit abbrev table
 };
 
 #endif // SymbolFileDWARF_DWARFDebugInfoEntry_h_
Index: source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -40,9 +40,8 @@
   m_offset = *offset_ptr;
   m_parent_idx = 0;
   m_sibling_idx = 0;
-  m_empty_children = false;
   const uint64_t abbr_idx = debug_info_data.GetULEB128(offset_ptr);
-  assert(abbr_idx < (1 << DIE_ABBR_IDX_BITSIZE));
+  lldbassert(abbr_idx <= UINT16_MAX);
   m_abbr_idx = abbr_idx;
 
   // assert (fixed_form_sizes);  // For best performance this should be
@@ -220,7 +219,7 @@
 m_offset = offset;
 
 const uint64_t abbr_idx = debug_info_data.GetULEB128(&offset);
-assert(abbr_idx < (1 << DIE_ABBR_IDX_BITSIZE));
+lldbassert(abbr_idx <= U

[Lldb-commits] [PATCH] D53321: Code cleanup: Remove DWARFDebugInfoEntry::m_empty_children

2018-10-16 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil marked an inline comment as done.
jankratochvil added a comment.

Also changed `assert()`->`lldbassert()` for `m_abbr_idx` 16-bit overflow as 
that could be a tough bug to catch if it ever happens.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D53321



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


[Lldb-commits] [PATCH] D53321: Code cleanup: Remove DWARFDebugInfoEntry::m_empty_children

2018-10-16 Thread Jan Kratochvil via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB344644: Code cleanup: Remove 
DWARFDebugInfoEntry::m_empty_children (authored by jankratochvil, committed by 
).

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D53321

Files:
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
  source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp

Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -223,7 +223,7 @@
   // the list (saves up to 25% in C++ code), we need a way to let the
   // DIE know that it actually doesn't have children.
   if (!m_die_array.empty())
-m_die_array.back().SetEmptyChildren(true);
+m_die_array.back().SetHasChildren(false);
 }
   } else {
 die.SetParentIndex(m_die_array.size() - die_index_stack[depth - 1]);
@@ -263,7 +263,7 @@
   if (!m_die_array.empty()) {
 if (m_first_die) {
   // Only needed for the assertion.
-  m_first_die.SetEmptyChildren(m_die_array.front().GetEmptyChildren());
+  m_first_die.SetHasChildren(m_die_array.front().HasChildren());
   lldbassert(m_first_die == m_die_array.front());
 }
 m_first_die = m_die_array.front();
Index: source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -40,9 +40,8 @@
   m_offset = *offset_ptr;
   m_parent_idx = 0;
   m_sibling_idx = 0;
-  m_empty_children = false;
   const uint64_t abbr_idx = debug_info_data.GetULEB128(offset_ptr);
-  assert(abbr_idx < (1 << DIE_ABBR_IDX_BITSIZE));
+  lldbassert(abbr_idx <= UINT16_MAX);
   m_abbr_idx = abbr_idx;
 
   // assert (fixed_form_sizes);  // For best performance this should be
@@ -220,7 +219,7 @@
 m_offset = offset;
 
 const uint64_t abbr_idx = debug_info_data.GetULEB128(&offset);
-assert(abbr_idx < (1 << DIE_ABBR_IDX_BITSIZE));
+lldbassert(abbr_idx <= UINT16_MAX);
 m_abbr_idx = abbr_idx;
 if (abbr_idx) {
   const DWARFAbbreviationDeclaration *abbrevDecl =
@@ -1836,7 +1835,6 @@
 bool DWARFDebugInfoEntry::operator==(const DWARFDebugInfoEntry &rhs) const {
   return m_offset == rhs.m_offset && m_parent_idx == rhs.m_parent_idx &&
  m_sibling_idx == rhs.m_sibling_idx &&
- m_empty_children == rhs.m_empty_children &&
  m_abbr_idx == rhs.m_abbr_idx && m_has_children == rhs.m_has_children &&
  m_tag == rhs.m_tag;
 }
Index: source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
===
--- source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
+++ source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
@@ -43,7 +43,6 @@
 class DWARFDeclContext;
 
 #define DIE_SIBLING_IDX_BITSIZE 31
-#define DIE_ABBR_IDX_BITSIZE 15
 
 class DWARFDebugInfoEntry {
 public:
@@ -57,8 +56,7 @@
 
   DWARFDebugInfoEntry()
   : m_offset(DW_INVALID_OFFSET), m_parent_idx(0), m_sibling_idx(0),
-m_empty_children(false), m_abbr_idx(0), m_has_children(false),
-m_tag(0) {}
+m_has_children(false), m_abbr_idx(0), m_tag(0) {}
 
   explicit operator bool() const { return m_offset != DW_INVALID_OFFSET; }
   bool operator==(const DWARFDebugInfoEntry &rhs) const;
@@ -227,10 +225,10 @@
   // we don't need to store our child pointer, if we have a child it will
   // be the next entry in the list...
   DWARFDebugInfoEntry *GetFirstChild() {
-return (HasChildren() && !m_empty_children) ? this + 1 : NULL;
+return HasChildren() ? this + 1 : NULL;
   }
   const DWARFDebugInfoEntry *GetFirstChild() const {
-return (HasChildren() && !m_empty_children) ? this + 1 : NULL;
+return HasChildren() ? this + 1 : NULL;
   }
 
   void GetDeclContextDIEs(DWARFUnit *cu,
@@ -271,10 +269,6 @@
 
   void SetParentIndex(uint32_t idx) { m_parent_idx = idx; }
 
-  bool GetEmptyChildren() const { return m_empty_children; }
-
-  void SetEmptyChildren(bool b) { m_empty_children = b; }
-
   static void
   DumpDIECollection(lldb_private::Stream &strm,
 DWARFDebugInfoEntry::collection &die_collection);
@@ -285,13 +279,13 @@
   uint32_t m_parent_idx; // How many to subtract from "this" to get the parent.
  // If zero this die has no parent
   uint32_t m_sibling_idx : 31, // How many to add to "this" to get the sibling.
-  m_empty_children : 1;// If a DIE says it had children, yet it just
-   // contained a NULL tag, this will be set.
-  uint32_t m_abbr_idx : DIE_ABBR_IDX_BITSIZE,
-m_has_children : 1, // Set to 1 if this DIE has children
-m_tag : 16; /

[Lldb-commits] [PATCH] D53321: Code cleanup: Remove DWARFDebugInfoEntry::m_empty_children

2018-10-16 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

In https://reviews.llvm.org/D53321#1266912, @clayborg wrote:

> Looks good. Nice cleanup.


Thanks for the cleanups and fixes.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D53321



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


[Lldb-commits] [PATCH] D53255: Fix: Assertion failed: (!m_first_die || m_first_die == m_die_array.front()), function ExtractDIEsRWLocked

2018-10-17 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

In https://reviews.llvm.org/D53255#1267850, @labath wrote:

> It looks like it should be easy to write a test for this by hand-crafting  a 
> minimal .s file and feeding it to lldb-test.


Even with such a crafted file (in lldb-repro.tar.xz 
) I haven't found a way 
how to call `DWARFUnit::ExtractUnitDIEIfNeeded()` first.  LLDB will always call 
`DWARFUnit::ExtractDIEsRWLocked()` first which cannot reproduce the bug. 
@xbolva00's file must have something special that `process launch -s` does call 
`DWARFUnit::ExtractUnitDIEIfNeeded()` first, my testcase does not. As I guess 
@xbolva00 cannot provide that file to us I think it would be enough to see a 
backtrace to the first call of `DWARFUnit::ExtractUnitDIEIfNeeded()` to find it 
out.


Repository:
  rL LLVM

https://reviews.llvm.org/D53255



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


[Lldb-commits] [PATCH] D51578: DWARFConcatenatingDataExtractor for D32167

2018-10-21 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 170342.
jankratochvil added a comment.
Herald added a subscriber: arphaman.

Patch `concat` = original posting with `DWARFConcatenatingDataExtractor` used 
only for `.debug_info`(+`.debug_types`) section. download 

Patch `concat2` = used `DWARFDataExtractor` with integrated concatenation for 
all DWARF sections. download 

  master  real=0.996s user=14.744s sys=1.050s
  concat  real=0.994s user=15.524s sys=1.117s
  concat2 real=1.001s user=15.580s sys=1.334s

`concat` vs. `concat2` benchmark difference was mostly a measurement error. It 
is now 5% slowdown compared to trunk - even for former `concat` which I do not 
understand now, I will investigate it more as my original measured slowdown was 
just 1% before.
`concat2` sometimes needs to cast `DWARFDataExtractor` to `DataExtractor` by 
`.AsDataExtractor()` as some functions expected a contiguous block of memory. 
That is a method applicable only for non-`.debug_info` sections (it would 
assert on `.debug_info`). It needs to be called as `DWARFDataExtractor` can no 
longer inherit `DataExtractor`. I did not use `operator DataExtractor &` as it 
could accidentally by applied to `.debug_info` which may be difficult to catch 
when not tested with `-fdebug-types-section`.
`DataExtractorConcat` is a separate class but it is never used separately 
without `DWARFDataExtractor` inheriting it.
Greg, do you mean it somehow way or do I miss something? Personally I may like 
a bit more `concat` but then the patch size is almost the same for both.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D51578

Files:
  source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  source/Plugins/SymbolFile/DWARF/DWARFASTParserGo.cpp
  source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
  source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.h
  source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
  source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp

Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp
@@ -105,9 +105,11 @@
   auto *offsets =
   it->second->getOffset(lldbSectTypeToLlvmSectionKind(sect_type));
   if (offsets) {
-data.SetData(section_data, offsets->Offset, offsets->Length);
+data.AsDataExtractor().SetData(
+section_data.AsDataExtractor(), offsets->Offset, offsets->Length);
   } else {
-data.SetData(section_data, 0, section_data.GetByteSize());
+data.AsDataExtractor().SetData(
+section_data.AsDataExtractor(), 0, section_data.GetByteSize());
   }
   return true;
 }
@@ -131,12 +133,13 @@
 lldb::SectionSP section_sp(
 section_list->FindSectionByType(sect_type, true));
 if (section_sp) {
-  if (m_obj_file->ReadSectionData(section_sp.get(), data) != 0) {
+  if (m_obj_file->ReadSectionData(
+  section_sp.get(), data.AsDataExtractor()) != 0) {
 m_sections[sect_type] = data;
 return true;
   }
 }
   }
-  m_sections[sect_type].Clear();
+  m_sections[sect_type].AsDataExtractor().Clear();
   return false;
 }
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
@@ -36,15 +36,17 @@
 if (section_sp) {
   // See if we memory mapped the DWARF segment?
   if (m_dwarf_data.GetByteSize()) {
-data.SetData(m_dwarf_data, section_sp->GetOffset(),
- section_sp->GetFileSize());
+data.AsDataExtractor().SetData(m_dwarf_data.AsDataExtractor(),
+   section_sp->GetOffset(),
+   section_sp->GetFileSize());
 return;
   }
 
-  if (m_obj_file->ReadSectionData(section_sp.get(), data) != 0)
+  if (m_obj_file->ReadSectionData(
+  section_sp.get(), data.AsDataExtractor()) != 0)
 return;
 
-  data.Clear();
+  data.AsDataExtractor().Clear();
 }
   }
 
Index: source/Plugins/SymbolFile/DWARF/SymbolF

[Lldb-commits] [PATCH] D51578: DWARFConcatenatingDataExtractor for D32167

2018-10-21 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

I got an idea to try making the `.debug_info`+`.debug_types` memory contiguous. 
It cannot be mmapped then but LLDB does not seem to do that now anyway (except 
maybe MachO but despite some comment I haven't found a mmap() even there). 
Besides that there could be even `.debug_info`+gap+`.debug_types` layout.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D51578



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


[Lldb-commits] [PATCH] D54056: Add SetAllowJIT (the SBExpressionOptions equivalent of "expression --allow-jit")

2018-11-03 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

It broke the testsuite for me:

  $ time 
PYTHONPATH=$PWD/lib64/python2.7/site-packages:$PWD/lib64/python2.7/site-packages/lldb
 ../llvm-git/tools/lldb/test/dotest.py --executable $PWD/bin/lldb -C 
$PWD/bin/clang -t ../llvm-git/tools/lldb/packages/Python/lldbsuite/test/ 
  WARNING:root:No valid FileCheck executable; some tests may fail...
  WARNING:root:(Double-check the --filecheck argument to dotest.py)
  LLDB library dir: /home/jkratoch/redhat/llvm-git-build-release-clang/bin
  LLDB import library dir: 
/home/jkratoch/redhat/llvm-git-build-release-clang/bin
  lldb version 8.0.0
clang revision 6974b990e13dfb4190a6dffdcc8bac9edbd1cde5
llvm revision 7fad5fb0d0d32beea4e95e239cc065a850733358
  Libc++ tests will not be run because: Unable to find libc++ installation
  Skipping following debug info categories: ['dsym', 'gmodules']
  Traceback (most recent call last):
File "../llvm-git/tools/lldb/test/dotest.py", line 7, in 
  lldbsuite.test.run_suite()
File 
"/home/jkratoch/redhat/llvm-git/tools/lldb/packages/Python/lldbsuite/test/dotest.py",
 line 1323, in run_suite
  visit('Test', dirpath, filenames)
File 
"/home/jkratoch/redhat/llvm-git/tools/lldb/packages/Python/lldbsuite/test/dotest.py",
 line 965, in visit
  raise Exception("Found multiple tests with the name %s" % name)
  Exception: Found multiple tests with the name TestSampleTest.py

As really there are now:

  $ find -name TestSampleTest.py
  
./packages/Python/lldbsuite/test/expression_command/dont_allow_jit/TestSampleTest.py
  ./packages/Python/lldbsuite/test/sample_test/TestSampleTest.py


Repository:
  rL LLVM

https://reviews.llvm.org/D54056



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


[Lldb-commits] [PATCH] D54056: Add SetAllowJIT (the SBExpressionOptions equivalent of "expression --allow-jit")

2018-11-03 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

In https://reviews.llvm.org/D54056#1286635, @davide wrote:

> I don't think anybody will look at this until Monday, so if you want a quick 
> fix you might consider renaming the test yourself.


Checked in as: https://reviews.llvm.org/rLLDB346089


Repository:
  rL LLVM

https://reviews.llvm.org/D54056



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


[Lldb-commits] [PATCH] D51578: Contiguous .debug_info+.debug_types for D32167

2018-11-05 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 172548.
jankratochvil retitled this revision from "DWARFConcatenatingDataExtractor for 
D32167" to "Contiguous .debug_info+.debug_types for D32167".
jankratochvil edited the summary of this revision.

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D51578

Files:
  include/lldb/lldb-forward.h
  packages/Python/lldbsuite/test/lldbtest.py
  packages/Python/lldbsuite/test/make/Makefile.rules
  packages/Python/lldbsuite/test/plugins/builder_base.py
  packages/Python/lldbsuite/test/test_categories.py
  source/Plugins/SymbolFile/DWARF/CMakeLists.txt
  source/Plugins/SymbolFile/DWARF/DIERef.cpp
  source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
  source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
  source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
  source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.cpp
  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
@@ -242,6 +242,7 @@
   const lldb_private::DWARFDataExtractor &get_debug_aranges_data();
   const lldb_private::DWARFDataExtractor &get_debug_frame_data();
   const lldb_private::DWARFDataExtractor &get_debug_info_data();
+  const lldb_private::DWARFDataExtractor &get_raw_debug_info_data();
   const lldb_private::DWARFDataExtractor &get_debug_line_data();
   const lldb_private::DWARFDataExtractor &get_debug_line_str_data();
   const lldb_private::DWARFDataExtractor &get_debug_macro_data();
@@ -251,7 +252,7 @@
   const lldb_private::DWARFDataExtractor &get_debug_rnglists_data();
   const lldb_private::DWARFDataExtractor &get_debug_str_data();
   const lldb_private::DWARFDataExtractor &get_debug_str_offsets_data();
-  const lldb_private::DWARFDataExtractor &get_debug_types_data();
+  const lldb_private::DWARFDataExtractor &get_raw_debug_types_data();
   const lldb_private::DWARFDataExtractor &get_apple_names_data();
   const lldb_private::DWARFDataExtractor &get_apple_types_data();
   const lldb_private::DWARFDataExtractor &get_apple_namespaces_data();
@@ -329,6 +330,10 @@
 
   void Dump(lldb_private::Stream &s) override;
 
+  uint64_t get_debug_types_offset() const {
+return m_debug_info_concatenated_types_offset;
+  }
+
 protected:
   typedef llvm::DenseMap
   DIEToTypePtr;
@@ -475,7 +480,7 @@
   DWARFDataSegment m_data_debug_addr;
   DWARFDataSegment m_data_debug_aranges;
   DWARFDataSegment m_data_debug_frame;
-  DWARFDataSegment m_data_debug_info;
+  DWARFDataSegment m_data_raw_debug_info;
   DWARFDataSegment m_data_debug_line;
   DWARFDataSegment m_data_debug_line_str;
   DWARFDataSegment m_data_debug_macro;
@@ -485,13 +490,17 @@
   DWARFDataSegment m_data_debug_rnglists;
   DWARFDataSegment m_data_debug_str;
   DWARFDataSegment m_data_debug_str_offsets;
-  DWARFDataSegment m_data_debug_types;
+  DWARFDataSegment m_data_raw_debug_types;
   DWARFDataSegment m_data_apple_names;
   DWARFDataSegment m_data_apple_types;
   DWARFDataSegment m_data_apple_namespaces;
   DWARFDataSegment m_data_apple_objc;
   DWARFDataSegment m_data_gnu_debugaltlink;
 
+  llvm::once_flag m_concatenated_data_once;
+  lldb_private::DWARFDataExtractor m_data_debug_info_concatenated;
+  uint64_t m_debug_info_concatenated_types_offset;
+
   // The unique pointer items below are generated on demand if and when someone
   // accesses
   // them through a non const version of this class.
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -412,7 +412,7 @@
   // when this class parses .o files to
   // contain the .o file index/ID
   m_debug_map_module_wp(), m_debug_map_symfile(NULL), m_data_debug_abbrev(),
-  m_data_debug_aranges(), m_data_debug_frame(), m_data_debug_info(),
+  m_data_debug_aranges(), m_data_debug_frame(), m_data_raw_debug_info(),
   m_data_debug_line(), m_data_debug_macro(), m_data_debug_loc(),
   m_data_debug_ranges(), m_data_debug_rnglists(), m_data_debug_str(),
   m_data_apple_names(), m_data_apple_types(), m_data_apple_namespaces(),
@@ -506,20 +506,6 @@
 if (section_list == NULL)
   return 0;
 
-// On non Apple platforms we might have .debug_types debug info that is
-// created by

[Lldb-commits] [PATCH] D51578: Contiguous .debug_info+.debug_types for D32167

2018-11-05 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 172549.

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D51578

Files:
  include/lldb/lldb-forward.h
  packages/Python/lldbsuite/test/lldbtest.py
  packages/Python/lldbsuite/test/make/Makefile.rules
  packages/Python/lldbsuite/test/plugins/builder_base.py
  packages/Python/lldbsuite/test/test_categories.py
  source/Plugins/SymbolFile/DWARF/CMakeLists.txt
  source/Plugins/SymbolFile/DWARF/DIERef.cpp
  source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
  source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
  source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
  source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.cpp
  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
@@ -242,6 +242,7 @@
   const lldb_private::DWARFDataExtractor &get_debug_aranges_data();
   const lldb_private::DWARFDataExtractor &get_debug_frame_data();
   const lldb_private::DWARFDataExtractor &get_debug_info_data();
+  const lldb_private::DWARFDataExtractor &get_raw_debug_info_data();
   const lldb_private::DWARFDataExtractor &get_debug_line_data();
   const lldb_private::DWARFDataExtractor &get_debug_line_str_data();
   const lldb_private::DWARFDataExtractor &get_debug_macro_data();
@@ -251,7 +252,7 @@
   const lldb_private::DWARFDataExtractor &get_debug_rnglists_data();
   const lldb_private::DWARFDataExtractor &get_debug_str_data();
   const lldb_private::DWARFDataExtractor &get_debug_str_offsets_data();
-  const lldb_private::DWARFDataExtractor &get_debug_types_data();
+  const lldb_private::DWARFDataExtractor &get_raw_debug_types_data();
   const lldb_private::DWARFDataExtractor &get_apple_names_data();
   const lldb_private::DWARFDataExtractor &get_apple_types_data();
   const lldb_private::DWARFDataExtractor &get_apple_namespaces_data();
@@ -329,6 +330,10 @@
 
   void Dump(lldb_private::Stream &s) override;
 
+  uint64_t get_debug_types_offset() const {
+return m_debug_info_concatenated_types_offset;
+  }
+
 protected:
   typedef llvm::DenseMap
   DIEToTypePtr;
@@ -475,7 +480,7 @@
   DWARFDataSegment m_data_debug_addr;
   DWARFDataSegment m_data_debug_aranges;
   DWARFDataSegment m_data_debug_frame;
-  DWARFDataSegment m_data_debug_info;
+  DWARFDataSegment m_data_raw_debug_info;
   DWARFDataSegment m_data_debug_line;
   DWARFDataSegment m_data_debug_line_str;
   DWARFDataSegment m_data_debug_macro;
@@ -485,13 +490,17 @@
   DWARFDataSegment m_data_debug_rnglists;
   DWARFDataSegment m_data_debug_str;
   DWARFDataSegment m_data_debug_str_offsets;
-  DWARFDataSegment m_data_debug_types;
+  DWARFDataSegment m_data_raw_debug_types;
   DWARFDataSegment m_data_apple_names;
   DWARFDataSegment m_data_apple_types;
   DWARFDataSegment m_data_apple_namespaces;
   DWARFDataSegment m_data_apple_objc;
   DWARFDataSegment m_data_gnu_debugaltlink;
 
+  llvm::once_flag m_concatenated_data_once;
+  lldb_private::DWARFDataExtractor m_data_debug_info_concatenated;
+  uint64_t m_debug_info_concatenated_types_offset;
+
   // The unique pointer items below are generated on demand if and when someone
   // accesses
   // them through a non const version of this class.
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -412,7 +412,7 @@
   // when this class parses .o files to
   // contain the .o file index/ID
   m_debug_map_module_wp(), m_debug_map_symfile(NULL), m_data_debug_abbrev(),
-  m_data_debug_aranges(), m_data_debug_frame(), m_data_debug_info(),
+  m_data_debug_aranges(), m_data_debug_frame(), m_data_raw_debug_info(),
   m_data_debug_line(), m_data_debug_macro(), m_data_debug_loc(),
   m_data_debug_ranges(), m_data_debug_rnglists(), m_data_debug_str(),
   m_data_apple_names(), m_data_apple_types(), m_data_apple_namespaces(),
@@ -506,20 +506,6 @@
 if (section_list == NULL)
   return 0;
 
-// On non Apple platforms we might have .debug_types debug info that is
-// created by using "-fdebug-types-section". LLDB currently will try to
-// load this debug info, but it causes crashes during debugging when types
-// are missing since it doesn't know how to pars

[Lldb-commits] [PATCH] D51578: Contiguous .debug_info+.debug_types for D32167

2018-11-10 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 173533.
jankratochvil edited the summary of this revision.

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D51578

Files:
  include/lldb/lldb-forward.h
  packages/Python/lldbsuite/test/lldbtest.py
  packages/Python/lldbsuite/test/make/Makefile.rules
  packages/Python/lldbsuite/test/plugins/builder_base.py
  packages/Python/lldbsuite/test/test_categories.py
  source/Plugins/SymbolFile/DWARF/CMakeLists.txt
  source/Plugins/SymbolFile/DWARF/DIERef.cpp
  source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
  source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
  source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
  source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.cpp
  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
@@ -242,6 +242,7 @@
   const lldb_private::DWARFDataExtractor &get_debug_aranges_data();
   const lldb_private::DWARFDataExtractor &get_debug_frame_data();
   const lldb_private::DWARFDataExtractor &get_debug_info_data();
+  const lldb_private::DWARFDataExtractor &get_raw_debug_info_data();
   const lldb_private::DWARFDataExtractor &get_debug_line_data();
   const lldb_private::DWARFDataExtractor &get_debug_line_str_data();
   const lldb_private::DWARFDataExtractor &get_debug_macro_data();
@@ -251,7 +252,7 @@
   const lldb_private::DWARFDataExtractor &get_debug_rnglists_data();
   const lldb_private::DWARFDataExtractor &get_debug_str_data();
   const lldb_private::DWARFDataExtractor &get_debug_str_offsets_data();
-  const lldb_private::DWARFDataExtractor &get_debug_types_data();
+  const lldb_private::DWARFDataExtractor &get_raw_debug_types_data();
   const lldb_private::DWARFDataExtractor &get_apple_names_data();
   const lldb_private::DWARFDataExtractor &get_apple_types_data();
   const lldb_private::DWARFDataExtractor &get_apple_namespaces_data();
@@ -331,6 +332,10 @@
 
   void DumpClangAST(lldb_private::Stream &s) override;
 
+  uint64_t get_debug_types_offset() const {
+return m_debug_info_concatenated_types_offset;
+  }
+
 protected:
   typedef llvm::DenseMap
   DIEToTypePtr;
@@ -477,7 +482,7 @@
   DWARFDataSegment m_data_debug_addr;
   DWARFDataSegment m_data_debug_aranges;
   DWARFDataSegment m_data_debug_frame;
-  DWARFDataSegment m_data_debug_info;
+  DWARFDataSegment m_data_raw_debug_info;
   DWARFDataSegment m_data_debug_line;
   DWARFDataSegment m_data_debug_line_str;
   DWARFDataSegment m_data_debug_macro;
@@ -487,13 +492,17 @@
   DWARFDataSegment m_data_debug_rnglists;
   DWARFDataSegment m_data_debug_str;
   DWARFDataSegment m_data_debug_str_offsets;
-  DWARFDataSegment m_data_debug_types;
+  DWARFDataSegment m_data_raw_debug_types;
   DWARFDataSegment m_data_apple_names;
   DWARFDataSegment m_data_apple_types;
   DWARFDataSegment m_data_apple_namespaces;
   DWARFDataSegment m_data_apple_objc;
   DWARFDataSegment m_data_gnu_debugaltlink;
 
+  llvm::once_flag m_concatenated_data_once;
+  lldb_private::DWARFDataExtractor m_data_debug_info_concatenated;
+  uint64_t m_debug_info_concatenated_types_offset;
+
   // The unique pointer items below are generated on demand if and when someone
   // accesses
   // them through a non const version of this class.
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -412,7 +412,7 @@
   // when this class parses .o files to
   // contain the .o file index/ID
   m_debug_map_module_wp(), m_debug_map_symfile(NULL), m_data_debug_abbrev(),
-  m_data_debug_aranges(), m_data_debug_frame(), m_data_debug_info(),
+  m_data_debug_aranges(), m_data_debug_frame(), m_data_raw_debug_info(),
   m_data_debug_line(), m_data_debug_macro(), m_data_debug_loc(),
   m_data_debug_ranges(), m_data_debug_rnglists(), m_data_debug_str(),
   m_data_apple_names(), m_data_apple_types(), m_data_apple_namespaces(),
@@ -506,20 +506,6 @@
 if (section_list == NULL)
   return 0;
 
-// On non Apple platforms we might have .debug_types debug info that is
-// created by using "-fdebug-types-section". LLDB currently will try to
-// load this debug info, but it causes crashes during debugging when 

[Lldb-commits] [PATCH] D51578: Contiguous .debug_info+.debug_types for D32167

2018-11-10 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil marked 2 inline comments as done.
jankratochvil added a comment.

There is a `_dwarf` -> `_dwarf_type_units` regression for: `-f 
TestCppTypeLookup.test_namespace_only_dwarf_type_units`

  ./bin/clang -o 1 
../llvm-git/tools/lldb/packages/Python/lldbsuite/test/lang/cpp/type_lookup/main.cpp
 -g -fdebug-types-section;./bin/lldb -o 'settings set 
target.experimental.inject-local-vars false' -o 'target create "./1"' -o 'b 66' 
-o r -o 'p *((in_contains_type *)&i)'

Expected:

  (lldb) p *((in_contains_type *)&i)
  error: use of undeclared identifier 'in_contains_type'
  error: expected expression

Actual:

  (lldb) p *((in_contains_type *)&i)
  (in_contains_type) $0 = (aaa = 123)

I will check it more.




Comment at: source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h:65
   typedef std::vector CompileUnitColl;
+  typedef std::unordered_map TypeSignatureMap;
 

clayborg wrote:
> Use llvm::DenseMap here?
Yes, I agree that is a good idea - changed it (BTW this is your part of the 
patch).



Comment at: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp:797
+DWARFCompileUnit *DWARFUnit::GetAsCompileUnit() {
+  if (GetUnitDIEOnly().Tag() == DW_TAG_compile_unit)
+return static_cast(this);

clayborg wrote:
> Should this just be "if (GetUnitDIEOnly().Tag() != DW_TAG_type_unit)"? 
> Partial units and many others can be top level DIEs.
When you ask then I disagree. Currently `GetAsCompileUnit()` is used only for 
checking `DW_TAG_partial_unit::DW_AT_name` (from D11003) which is never present 
in files by DWZ tool. DWZ tool never puts DIEs referencing any code into 
`DW_TAG_partial_unit` so D11003 should not be needed; although DWZ 
intentionally sometimes uses `DW_TAG_partial_unit::DW_AT_stmt_list` but I 
haven't found when/how it could be useful.
//> many others//
Top level DIEs can be according to DWARF-5 7.5 just `DW_TAG_compile_unit`, 
`DW_TAG_partial_unit` or `DW_TAG_type_unit`.
So personally I would keep `GetAsCompileUnit()` to do what its name exactly 
says.



Repository:
  rLLDB LLDB

https://reviews.llvm.org/D51578



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


[Lldb-commits] [PATCH] D51578: Contiguous .debug_info+.debug_types for D32167

2018-11-10 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 173535.
jankratochvil marked 2 inline comments as done.

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D51578

Files:
  include/lldb/lldb-forward.h
  packages/Python/lldbsuite/test/lldbtest.py
  packages/Python/lldbsuite/test/make/Makefile.rules
  packages/Python/lldbsuite/test/plugins/builder_base.py
  packages/Python/lldbsuite/test/test_categories.py
  source/Plugins/SymbolFile/DWARF/CMakeLists.txt
  source/Plugins/SymbolFile/DWARF/DIERef.cpp
  source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
  source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
  source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
  source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.cpp
  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
@@ -242,6 +242,7 @@
   const lldb_private::DWARFDataExtractor &get_debug_aranges_data();
   const lldb_private::DWARFDataExtractor &get_debug_frame_data();
   const lldb_private::DWARFDataExtractor &get_debug_info_data();
+  const lldb_private::DWARFDataExtractor &get_raw_debug_info_data();
   const lldb_private::DWARFDataExtractor &get_debug_line_data();
   const lldb_private::DWARFDataExtractor &get_debug_line_str_data();
   const lldb_private::DWARFDataExtractor &get_debug_macro_data();
@@ -251,7 +252,7 @@
   const lldb_private::DWARFDataExtractor &get_debug_rnglists_data();
   const lldb_private::DWARFDataExtractor &get_debug_str_data();
   const lldb_private::DWARFDataExtractor &get_debug_str_offsets_data();
-  const lldb_private::DWARFDataExtractor &get_debug_types_data();
+  const lldb_private::DWARFDataExtractor &get_raw_debug_types_data();
   const lldb_private::DWARFDataExtractor &get_apple_names_data();
   const lldb_private::DWARFDataExtractor &get_apple_types_data();
   const lldb_private::DWARFDataExtractor &get_apple_namespaces_data();
@@ -331,6 +332,10 @@
 
   void DumpClangAST(lldb_private::Stream &s) override;
 
+  uint64_t get_debug_types_offset() const {
+return m_debug_info_concatenated_types_offset;
+  }
+
 protected:
   typedef llvm::DenseMap
   DIEToTypePtr;
@@ -477,7 +482,7 @@
   DWARFDataSegment m_data_debug_addr;
   DWARFDataSegment m_data_debug_aranges;
   DWARFDataSegment m_data_debug_frame;
-  DWARFDataSegment m_data_debug_info;
+  DWARFDataSegment m_data_raw_debug_info;
   DWARFDataSegment m_data_debug_line;
   DWARFDataSegment m_data_debug_line_str;
   DWARFDataSegment m_data_debug_macro;
@@ -487,13 +492,17 @@
   DWARFDataSegment m_data_debug_rnglists;
   DWARFDataSegment m_data_debug_str;
   DWARFDataSegment m_data_debug_str_offsets;
-  DWARFDataSegment m_data_debug_types;
+  DWARFDataSegment m_data_raw_debug_types;
   DWARFDataSegment m_data_apple_names;
   DWARFDataSegment m_data_apple_types;
   DWARFDataSegment m_data_apple_namespaces;
   DWARFDataSegment m_data_apple_objc;
   DWARFDataSegment m_data_gnu_debugaltlink;
 
+  llvm::once_flag m_concatenated_data_once;
+  lldb_private::DWARFDataExtractor m_data_debug_info_concatenated;
+  uint64_t m_debug_info_concatenated_types_offset;
+
   // The unique pointer items below are generated on demand if and when someone
   // accesses
   // them through a non const version of this class.
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -412,7 +412,7 @@
   // when this class parses .o files to
   // contain the .o file index/ID
   m_debug_map_module_wp(), m_debug_map_symfile(NULL), m_data_debug_abbrev(),
-  m_data_debug_aranges(), m_data_debug_frame(), m_data_debug_info(),
+  m_data_debug_aranges(), m_data_debug_frame(), m_data_raw_debug_info(),
   m_data_debug_line(), m_data_debug_macro(), m_data_debug_loc(),
   m_data_debug_ranges(), m_data_debug_rnglists(), m_data_debug_str(),
   m_data_apple_names(), m_data_apple_types(), m_data_apple_namespaces(),
@@ -506,20 +506,6 @@
 if (section_list == NULL)
   return 0;
 
-// On non Apple platforms we might have .debug_types debug info that is
-// created by using "-fdebug-types-section". LLDB currently will try to
-// load this debug info, but it causes crashes during debugging when typ

[Lldb-commits] [PATCH] D51578: Contiguous .debug_info+.debug_types for D32167

2018-11-17 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 174518.
jankratochvil edited the summary of this revision.
jankratochvil added a comment.
Herald added subscribers: arichardson, emaste.
Herald added a reviewer: espindola.

I have left here only the sections concatenation.  The .debug_types itself by 
Greg Clayton is now updated on top of this patch in 
https://reviews.llvm.org/D32167.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D51578

Files:
  include/lldb/lldb-enumerations.h
  source/Core/Section.cpp
  source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
  source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFUnit.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/Symbol/ObjectFile.cpp

Index: source/Symbol/ObjectFile.cpp
===
--- source/Symbol/ObjectFile.cpp
+++ source/Symbol/ObjectFile.cpp
@@ -368,6 +368,7 @@
   case eSectionTypeDWARFDebugStrOffsets:
   case eSectionTypeDWARFDebugStrOffsetsDwo:
   case eSectionTypeDWARFDebugTypes:
+  case eSectionTypeDWARFDebugTypesDwo:
   case eSectionTypeDWARFAppleNames:
   case eSectionTypeDWARFAppleTypes:
   case eSectionTypeDWARFAppleNamespaces:
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
@@ -48,9 +48,10 @@
 
   const lldb_private::DWARFDataExtractor &get_debug_abbrev_data() override;
   const lldb_private::DWARFDataExtractor &get_debug_addr_data() override;
-  const lldb_private::DWARFDataExtractor &get_debug_info_data() override;
+  const lldb_private::DWARFDataExtractor &get_raw_debug_info_data() override;
   const lldb_private::DWARFDataExtractor &get_debug_str_data() override;
   const lldb_private::DWARFDataExtractor &get_debug_str_offsets_data() override;
+  const lldb_private::DWARFDataExtractor &get_raw_debug_types_data() override;
 
 protected:
   void LoadSectionData(lldb::SectionType sect_type,
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
@@ -136,8 +136,9 @@
   return m_data_debug_addr.m_data;
 }
 
-const DWARFDataExtractor &SymbolFileDWARFDwo::get_debug_info_data() {
-  return GetCachedSectionData(eSectionTypeDWARFDebugInfoDwo, m_data_debug_info);
+const DWARFDataExtractor &SymbolFileDWARFDwo::get_raw_debug_info_data() {
+  return GetCachedSectionData(eSectionTypeDWARFDebugInfoDwo,
+  m_data_raw_debug_info);
 }
 
 const DWARFDataExtractor &SymbolFileDWARFDwo::get_debug_str_data() {
@@ -149,6 +150,11 @@
   m_data_debug_str_offsets);
 }
 
+const DWARFDataExtractor &SymbolFileDWARFDwo::get_raw_debug_types_data() {
+  return GetCachedSectionData(eSectionTypeDWARFDebugTypesDwo,
+  m_data_raw_debug_types);
+}
+
 SymbolFileDWARF *SymbolFileDWARFDwo::GetBaseSymbolFile() {
   return m_base_dwarf_cu->GetSymbolFileDWARF();
 }
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -237,7 +237,8 @@
   virtual const lldb_private::DWARFDataExtractor &get_debug_addr_data();
   const lldb_private::DWARFDataExtractor &get_debug_aranges_data();
   const lldb_private::DWARFDataExtractor &get_debug_frame_data();
-  virtual const lldb_private::DWARFDataExtractor &get_debug_info_data();
+  const lldb_private::DWARFDataExtractor &get_debug_info_data();
+  virtual const lldb_private::DWARFDataExtractor &get_raw_debug_info_data();
   const lldb_private::DWARFDataExtractor &get_debug_line_data();
   const lldb_private::DWARFDataExtractor &get_debug_line_str_data();
   const lldb_private::DWARFDataExtractor &get_debug_macro_data();
@@ -247,7 +248,7 @@
   const lldb_private::DWARFDataExtractor &get_debug_rnglists_data();
   virtual const lldb_private::DWARFDataExtractor &get_debug_str_data();
   virtual const lldb_private::DWARFDataExtractor &get_debug_str_offsets_data();
-  const lldb_private::DWARFDataExtractor &get_debug_types_data();
+  virtual const lldb_private::DWARFDataExtractor &get_raw_debug_types_data();
   const lldb_private::DWARFDataExtractor &get_apple_names_data();
   const lldb

[Lldb-commits] [PATCH] D54670: Update of D32167 on top of D51578

2018-11-17 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil created this revision.
jankratochvil added a reviewer: clayborg.
jankratochvil added a project: LLDB.
Herald added a subscriber: teemperor.

I cannot update the patch of https://reviews.llvm.org/D32167 so I have created 
this new revision for that.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D54670

Files:
  packages/Python/lldbsuite/test/lldbtest.py
  packages/Python/lldbsuite/test/make/Makefile.rules
  packages/Python/lldbsuite/test/plugins/builder_base.py
  packages/Python/lldbsuite/test/test_categories.py
  source/Plugins/SymbolFile/DWARF/CMakeLists.txt
  source/Plugins/SymbolFile/DWARF/DIERef.cpp
  source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
  source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
  source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
  source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.h
  source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -505,20 +505,6 @@
 if (section_list == NULL)
   return 0;
 
-// On non Apple platforms we might have .debug_types debug info that is
-// created by using "-fdebug-types-section". LLDB currently will try to
-// load this debug info, but it causes crashes during debugging when types
-// are missing since it doesn't know how to parse the info in the
-// .debug_types type units. This causes all complex debug info types to be
-// unresolved. Because this causes LLDB to crash and since it really
-// doesn't provide a solid debuggiung experience, we should disable trying
-// to debug this kind of DWARF until support gets added or deprecated.
-if (section_list->FindSectionByName(ConstString(".debug_types"))) {
-  m_obj_file->GetModule()->ReportWarning(
-"lldb doesn’t support .debug_types debug info");
-  return 0;
-}
-
 uint64_t debug_abbrev_file_size = 0;
 uint64_t debug_info_file_size = 0;
 uint64_t debug_line_file_size = 0;
@@ -900,7 +886,7 @@
 cu_sp.reset(new CompileUnit(
 module_sp, dwarf_cu, cu_file_spec, dwarf_cu->GetID(),
 cu_language, is_optimized ? eLazyBoolYes : eLazyBoolNo));
-if (cu_sp) {
+if (dwarf_cu->GetAsCompileUnit() && cu_sp) {
   // If we just created a compile unit with an invalid file spec,
   // try and get the first entry in the supports files from the
   // line table as that should be the compile unit.
@@ -913,16 +899,16 @@
   cu_sp->GetSupportFiles().Replace(0, cu_file_spec);
 }
   }
+}
 
-  dwarf_cu->SetUserData(cu_sp.get());
+dwarf_cu->SetUserData(cu_sp.get());
 
-  // Figure out the compile unit index if we weren't given one
-  if (cu_idx == UINT32_MAX)
-DebugInfo()->GetCompileUnit(dwarf_cu->GetOffset(), &cu_idx);
+// Figure out the compile unit index if we weren't given one
+if (cu_idx == UINT32_MAX)
+  DebugInfo()->GetCompileUnit(dwarf_cu->GetOffset(), &cu_idx);
 
-  m_obj_file->GetModule()->GetSymbolVendor()->SetCompileUnitAtIndex(
-  cu_idx, cu_sp);
-}
+m_obj_file->GetModule()->GetSymbolVendor()->SetCompileUnitAtIndex(
+cu_idx, cu_sp);
   }
 }
   }
Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.h
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -17,12 +17,15 @@
 #include 
 
 class DWARFUnit;
+class DWARFTypeUnit;
 class DWARFCompileUnit;
 class NameToDIE;
 class SymbolFileDWARF;
 class SymbolFileDWARFDwo;
 
 typedef std::shared_ptr DWARFUnitSP;
+typedef std::shared_ptr DWARFTypeUnitSP;
+typedef std::shared_ptr DWARFCompileUnitSP;
 
 enum DWARFProducer {
   eProducerInvalid = 0,
@@ -39,6 +42,12 @@
 public:
   virtual ~DWARFUnit();
 
+  bool ExtractHeader(SymbolFileDWARF *dwarf,
+ const lldb_private::DWARFDataExtractor &data,
+ lldb::offset_t *offset_ptr);
+
+  DWARFTypeUnit *GetAsTypeUnit();
+  DWARFCompileUnit *GetAsCompileUnit();
   void ExtractUnitDIEIfNeeded();
   void ExtractDIEsIfNeeded();
 
@@ -176,6 +185,10 @@
 return die_iterator_range(m_die_array.begin(), m_die_array.end());
   }
 
+  DWARFDIE FindTypeSignatureDIE(uint64_t ty

[Lldb-commits] [PATCH] D32167: Add support for type units (.debug_types) to LLDB in a way that is compatible with DWARF 5

2018-11-17 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

I could not updates this revision so an updated version of this patch is now: 
https://reviews.llvm.org/D54670


https://reviews.llvm.org/D32167



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


[Lldb-commits] [PATCH] D54670: .debug_types: Update of D32167 on top of D51578 (.debug_types section concatenation)

2018-11-17 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added inline comments.



Comment at: source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp:268
+  if (decl_ctx)
+LinkDeclContextToDIE(decl_ctx, die);
+  return type_sp;

I have added these 4 lines - `decl_ctx` copy - which fixes the 
`-fdebug-types-section` regression [[ https://reviews.llvm.org/D51578#1294416 | 
described before ]] as:

There is a `_dwarf` -> `_dwarf_type_units` regression for: `-f 
TestCppTypeLookup.test_namespace_only_dwarf_type_units`
```
./bin/clang -o 1 
../llvm-git/tools/lldb/packages/Python/lldbsuite/test/lang/cpp/type_lookup/main.cpp
 -g -fdebug-types-section;./bin/lldb -o 'settings set 
target.experimental.inject-local-vars false' -o 'target create "./1"' -o 'b 66' 
-o r -o 'p *((in_contains_type *)&i)'
```
Expected:
```(lldb) p *((in_contains_type *)&i)
error: use of undeclared identifier 'in_contains_type'
error: expected expression
```
Actual:
```(lldb) p *((in_contains_type *)&i)
(in_contains_type) $0 = (aaa = 123)
```

The regression was due to `DWARFASTParserClang::GetClangDeclContextForDIE` 
calling `ResolveType` but then still `GetCachedClangDeclContextForDIE` was 
returning NULL `decl_ctx`.  That was because in this code above the recursive 
`ParseTypeFromDWARF` call properly did set `LinkDeclContextToDIE` but only for 
the referenced DIE, not for the referring DIE.  But then the caller asked for 
DeclContext of the referring DIE which has not been found.

```
  Compilation Unit @ offset 0x84:
   Signature: 0x368b3ff5e79ee8d1
 <0><9b>: Abbrev Number: 1 (DW_TAG_type_unit)
 <1>: Abbrev Number: 2 (DW_TAG_namespace)
   DW_AT_name: (indirect string, offset: 0x149): nsp_a
 <2>: Abbrev Number: 6 (DW_TAG_structure_type)
HERE: Referenced DIE.
   DW_AT_name: (indirect string, offset: 0x169): contains_type
  Compilation Unit @ offset 0xb2:
   Signature: 0xb27591880ea58868
 <0>: Abbrev Number: 1 (DW_TAG_type_unit)
 <1>: Abbrev Number: 2 (DW_TAG_namespace)
   DW_AT_name: (indirect string, offset: 0x149): nsp_a
 <2>: Abbrev Number: 7 (DW_TAG_structure_type)
HERE: Referring DIE.
   DW_AT_declaration : 1
   DW_AT_signature   : signature: 0x368b3ff5e79ee8d1
 <3>: Abbrev Number: 3 (DW_TAG_structure_type)
   DW_AT_name: (indirect string, offset: 0x166): 
in_contains_type
 <4>: Abbrev Number: 4 (DW_TAG_member)
   DW_AT_name: (indirect string, offset: 0x177): aaa
```


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D54670



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


[Lldb-commits] [PATCH] D54751: [LLDB] - Fix setting the breakpoints when -gsplit-dwarf and DWARF 5 were used for building the executable.

2018-11-26 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil accepted this revision.
jankratochvil added a comment.
This revision is now accepted and ready to land.

I do not think my approval is sufficient but I agree with the patch.


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

https://reviews.llvm.org/D54751



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


[Lldb-commits] [PATCH] D54751: [LLDB] - Fix setting the breakpoints when -gsplit-dwarf and DWARF 5 were used for building the executable.

2018-11-26 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added inline comments.



Comment at: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp:351
+  if (!addr_base)
+addr_base =
+   cu_die.GetAttributeValueAsUnsigned(m_dwarf, this, DW_AT_GNU_addr_base, 
0);

Here I would find good also a comment:
``` // pre-DWARF v5 attributes DW_AT_GNU_* applied only to the DWO unit while 
DWARF v5 attributes DW_AT_* apply also to the main unit
```
Based on a [[ https://gcc.gnu.org/wiki/DebugFission | DebugFission ]] comment:
```Note the following difference between the current GCC implementation and the 
DWARF v5 specification: In the current GCC implementation (based on DWARF v4), 
if DW_AT_ranges is present, the offset into the ranges table is not relative to 
the value given by DW_AT_ranges_base (i.e., DW_AT_ranges_base is used only for 
references to the range table from the dwo sections). In DWARF v5, the 
DW_AT_ranges_base attribute is used for all references to the range table -- 
both from dwo sections and from skeleton compile units.
```

I was also thinking to fetch the attributes just once by some `(m_version >= 5 
? DW_AT_addr_base : DW_AT_GNU_addr_base)` but clang-7.0 does produce DWARF-5 
still using `DW_AT_GNU_addr_base`.



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

https://reviews.llvm.org/D54751



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


[Lldb-commits] [PATCH] D54670: .debug_types: Update of D32167 on top of D51578 (.debug_types section concatenation)

2018-12-04 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

@clayborg You have already approved this patchset merged with D51578 
 in D51578 three weeks ago 
. I have split it afterwards to:

| 1of2 | D51578   | the section merge 
which you have approved; but it is not much useful without any code using it.   

 |
| 2of2 | this D54670  | your original 
`.debug_types` patch but with my added few lines of code 
 to fix its regression when using 
`.debug_types`.  These few lines have not been approved yet. |
|

Should I check it in as you wrote it or is it OK with those few lines of code 
added by me?


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D54670



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


[Lldb-commits] [PATCH] D51578: Contiguous .debug_info+.debug_types for D32167

2018-12-15 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 178353.
jankratochvil added a comment.

Updated against trunk due to new `getSectionType` from rL348936 
.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D51578

Files:
  include/lldb/lldb-enumerations.h
  source/Core/Section.cpp
  source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
  source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFUnit.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/Symbol/ObjectFile.cpp

Index: source/Symbol/ObjectFile.cpp
===
--- source/Symbol/ObjectFile.cpp
+++ source/Symbol/ObjectFile.cpp
@@ -368,6 +368,7 @@
   case eSectionTypeDWARFDebugStrOffsets:
   case eSectionTypeDWARFDebugStrOffsetsDwo:
   case eSectionTypeDWARFDebugTypes:
+  case eSectionTypeDWARFDebugTypesDwo:
   case eSectionTypeDWARFAppleNames:
   case eSectionTypeDWARFAppleTypes:
   case eSectionTypeDWARFAppleNamespaces:
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
@@ -48,9 +48,10 @@
 
   const lldb_private::DWARFDataExtractor &get_debug_abbrev_data() override;
   const lldb_private::DWARFDataExtractor &get_debug_addr_data() override;
-  const lldb_private::DWARFDataExtractor &get_debug_info_data() override;
+  const lldb_private::DWARFDataExtractor &get_raw_debug_info_data() override;
   const lldb_private::DWARFDataExtractor &get_debug_str_data() override;
   const lldb_private::DWARFDataExtractor &get_debug_str_offsets_data() override;
+  const lldb_private::DWARFDataExtractor &get_raw_debug_types_data() override;
 
 protected:
   void LoadSectionData(lldb::SectionType sect_type,
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
@@ -136,8 +136,9 @@
   return m_data_debug_addr.m_data;
 }
 
-const DWARFDataExtractor &SymbolFileDWARFDwo::get_debug_info_data() {
-  return GetCachedSectionData(eSectionTypeDWARFDebugInfoDwo, m_data_debug_info);
+const DWARFDataExtractor &SymbolFileDWARFDwo::get_raw_debug_info_data() {
+  return GetCachedSectionData(eSectionTypeDWARFDebugInfoDwo,
+  m_data_raw_debug_info);
 }
 
 const DWARFDataExtractor &SymbolFileDWARFDwo::get_debug_str_data() {
@@ -149,6 +150,11 @@
   m_data_debug_str_offsets);
 }
 
+const DWARFDataExtractor &SymbolFileDWARFDwo::get_raw_debug_types_data() {
+  return GetCachedSectionData(eSectionTypeDWARFDebugTypesDwo,
+  m_data_raw_debug_types);
+}
+
 SymbolFileDWARF *SymbolFileDWARFDwo::GetBaseSymbolFile() {
   return m_base_dwarf_cu->GetSymbolFileDWARF();
 }
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -237,7 +237,8 @@
   virtual const lldb_private::DWARFDataExtractor &get_debug_addr_data();
   const lldb_private::DWARFDataExtractor &get_debug_aranges_data();
   const lldb_private::DWARFDataExtractor &get_debug_frame_data();
-  virtual const lldb_private::DWARFDataExtractor &get_debug_info_data();
+  const lldb_private::DWARFDataExtractor &get_debug_info_data();
+  virtual const lldb_private::DWARFDataExtractor &get_raw_debug_info_data();
   const lldb_private::DWARFDataExtractor &get_debug_line_data();
   const lldb_private::DWARFDataExtractor &get_debug_line_str_data();
   const lldb_private::DWARFDataExtractor &get_debug_macro_data();
@@ -247,7 +248,7 @@
   const lldb_private::DWARFDataExtractor &get_debug_rnglists_data();
   virtual const lldb_private::DWARFDataExtractor &get_debug_str_data();
   virtual const lldb_private::DWARFDataExtractor &get_debug_str_offsets_data();
-  const lldb_private::DWARFDataExtractor &get_debug_types_data();
+  virtual const lldb_private::DWARFDataExtractor &get_raw_debug_types_data();
   const lldb_private::DWARFDataExtractor &get_apple_names_data();
   const lldb_private::DWARFDataExtractor &get_apple_types_data();
   const lldb_private::DWARFDataExtractor &get_apple_namespaces_data();
@@ -3

[Lldb-commits] [PATCH] D55858: noexternal 1/2: refactor testsuite spawnLldbMi args->exe+args

2018-12-18 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil created this revision.
jankratochvil added reviewers: LLDB, labath.
jankratochvil added a project: LLDB.
Herald added subscribers: abidh, ki.stfu.

Currently `spawnLldbMi` accepts both lldb-mi options and executable to debug as 
a single parameter. Split them.
As in the next patch we will need to execute one lldb-mi command before loading 
the exe.  Therefore we can no longer use the exe as lldb-mi command-line 
parameter as then there is no way to execute a command before loading exe 
specified as lldb-mi command-line parameter.
`LocateExecutableSymbolFileDsym` should be static, that is also a little 
refactorization.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D55858

Files:
  packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py
  
packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py
  packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py
  source/Host/common/Symbols.cpp

Index: source/Host/common/Symbols.cpp
===
--- source/Host/common/Symbols.cpp
+++ source/Host/common/Symbols.cpp
@@ -199,7 +199,7 @@
   return false;
 }
 
-FileSpec LocateExecutableSymbolFileDsym(const ModuleSpec &module_spec) {
+static FileSpec LocateExecutableSymbolFileDsym(const ModuleSpec &module_spec) {
   const FileSpec *exec_fspec = module_spec.GetFileSpecPtr();
   const ArchSpec *arch = module_spec.GetArchitecturePtr();
   const UUID *uuid = module_spec.GetUUIDPtr();
Index: packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py
===
--- packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py
+++ packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py
@@ -53,7 +53,7 @@
 os.symlink(self.myexe, complicated_myexe)
 self.addTearDownHook(lambda: os.unlink(complicated_myexe))
 
-self.spawnLldbMi(args="\"%s\"" % complicated_myexe)
+self.spawnLldbMi(exe=complicated_myexe)
 
 # Test that the executable was loaded
 self.expect(
Index: packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py
===
--- packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py
+++ packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py
@@ -22,7 +22,7 @@
 def test_lldbmi_executable_option_file(self):
 """Test that 'lldb-mi --interpreter %s' loads executable file."""
 
-self.spawnLldbMi(args="%s" % self.myexe)
+self.spawnLldbMi(exe=self.myexe)
 
 # Test that the executable is loaded when file was specified
 self.expect("-file-exec-and-symbols \"%s\"" % self.myexe)
@@ -52,7 +52,7 @@
 # Prepare path to executable
 path = "unknown_file"
 
-self.spawnLldbMi(args="%s" % path)
+self.spawnLldbMi(exe=path)
 
 # Test that the executable isn't loaded when unknown file was specified
 self.expect("-file-exec-and-symbols \"%s\"" % path)
@@ -71,7 +71,7 @@
 """Test that 'lldb-mi --interpreter %s' loads executable which is specified via absolute path."""
 
 # Prepare path to executable
-self.spawnLldbMi(args="%s" % self.myexe)
+self.spawnLldbMi(exe=self.myexe)
 
 # Test that the executable is loaded when file was specified using
 # absolute path
@@ -95,7 +95,7 @@
 
 # Prepare path to executable
 path = os.path.relpath(self.myexe, self.getBuildDir())
-self.spawnLldbMi(args="%s" % path)
+self.spawnLldbMi(exe=path)
 
 # Test that the executable is loaded when file was specified using
 # relative path
@@ -119,7 +119,7 @@
 # Prepare path to executable
 path = "unknown_dir" + self.myexe
 
-self.spawnLldbMi(args="%s" % path)
+self.spawnLldbMi(exe=path)
 
 # Test that the executable isn't loaded when file was specified using
 # unknown path
@@ -259,7 +259,7 @@
 """Test that 'lldb-mi --log' creates a log file in the current directory."""
 
 logDirectory = self.getBuildDir()
-self.spawnLldbMi(args="%s --log" % self.myexe)
+self.spawnLldbMi(exe=self.myexe, args="--log")
 
 # Test that the executable is loaded when file was specified
 self.expect("-file-exec-and-symbols \"%s\"" % self.myexe)
@@ -296,9 +296,8 @@
 import tempfile
 logDirectory = tempfile.gettempdir()
 
-self.spawnLldbMi(
-args="%s --log --log-dir=%s" %
-(self.myexe, logDirectory))
+self.spawnLldbMi(exe=self.myexe,
+args="--log --log-dir=%s" % logDirectory)
 
 # Test that the executable is loaded when file was specified
 self.expect("-file-exec-and-symbols \"%s\"" % self.myexe)
Index: packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi

[Lldb-commits] [PATCH] D55859: noexternal 2/2: symbols.enable-external-lookup=false on all hosts (not just OSX)

2018-12-18 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil created this revision.
jankratochvil added reviewers: LLDB, labath.
jankratochvil added a project: LLDB.
Herald added subscribers: abidh, ki.stfu.

There is already in use:

  lit/lit-lldb-init:settings set symbols.enable-external-lookup false
  packages/Python/lldbsuite/test/lldbtest.py:self.runCmd('settings set 
symbols.enable-external-lookup false')

But those are not in effect during MI part of the testsuite.  Another problem 
is that `symbols.enable-external-lookup` (read by `GetEnableExternalLookup`) 
has been currently read only by `LocateMacOSXFilesUsingDebugSymbols` and 
therefore it had no effect on Linux.
On Red Hat platforms (Fedoras, RHEL-7) there is DWZ in use and so 
`MiSyntaxTestCase-test_lldbmi_output_grammar` FAILs due to:

  AssertionError: error: inconsistent pattern ''^.+?\n'' for state 0x5f 
(matched string: warning: (x86_64) /lib64/libstdc++.so.6 unsupported DW_FORM 
values: 0x1f20 0x1f21

It is the only testcase with this error. It happens due to:

  (lldb) target create "/lib64/libstdc++.so.6"
  Current executable set to '/lib64/libstdc++.so.6' (x86_64).
  (lldb) b main
  warning: (x86_64) /lib64/libstdc++.so.6 unsupported DW_FORM values: 0x1f20 
0x1f21
  Breakpoint 1: no locations (pending).
  WARNING:  Unable to resolve breakpoint to any actual locations.

which happens only with `gcc-base-debuginfo` rpm installed (similarly for other 
packages).
It should also speed up the testsuite as it no longer needs to read 
`/usr/lib/debug` symbols which have no effect (and should not have any effect) 
on the testsuite results.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D55859

Files:
  packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py
  
packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py
  
packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/start_script_error
  source/Host/common/Symbols.cpp

Index: source/Host/common/Symbols.cpp
===
--- source/Host/common/Symbols.cpp
+++ source/Host/common/Symbols.cpp
@@ -253,6 +253,9 @@
   FileSystem::Instance().Exists(symbol_file_spec))
 return symbol_file_spec;
 
+  bool external_lookup =
+  ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup();
+
   const char *symbol_filename = symbol_file_spec.GetFilename().AsCString();
   if (symbol_filename && symbol_filename[0]) {
 FileSpecList debug_file_search_paths(
@@ -270,30 +273,32 @@
   debug_file_search_paths.AppendIfUnique(file_spec);
 }
 
-// Add current working directory.
-{
-  FileSpec file_spec(".");
-  FileSystem::Instance().Resolve(file_spec);
-  debug_file_search_paths.AppendIfUnique(file_spec);
-}
+if (external_lookup) {
+  // Add current working directory.
+  {
+FileSpec file_spec(".");
+FileSystem::Instance().Resolve(file_spec);
+debug_file_search_paths.AppendIfUnique(file_spec);
+  }
 
 #ifndef _WIN32
 #if defined(__NetBSD__)
-// Add /usr/libdata/debug directory.
-{
-  FileSpec file_spec("/usr/libdata/debug");
-  FileSystem::Instance().Resolve(file_spec);
-  debug_file_search_paths.AppendIfUnique(file_spec);
-}
+  // Add /usr/libdata/debug directory.
+  {
+FileSpec file_spec("/usr/libdata/debug");
+FileSystem::Instance().Resolve(file_spec);
+debug_file_search_paths.AppendIfUnique(file_spec);
+  }
 #else
-// Add /usr/lib/debug directory.
-{
-  FileSpec file_spec("/usr/lib/debug");
-  FileSystem::Instance().Resolve(file_spec);
-  debug_file_search_paths.AppendIfUnique(file_spec);
-}
+  // Add /usr/lib/debug directory.
+  {
+FileSpec file_spec("/usr/lib/debug");
+FileSystem::Instance().Resolve(file_spec);
+debug_file_search_paths.AppendIfUnique(file_spec);
+  }
 #endif
 #endif // _WIN32
+}
 
 std::string uuid_str;
 const UUID &module_uuid = module_spec.GetUUID();
@@ -357,6 +362,12 @@
 }
   }
 
+  if (!external_lookup) {
+Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+if (log)
+  log->Printf("External lookup for symbol files is disabled.");
+return FileSpec();
+  }
   return LocateExecutableSymbolFileDsym(module_spec);
 }
 
Index: packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/start_script_error
===
--- packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/start_script_error
+++ packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/start_script_error
@@ -1,2 +1,3 @@
+settings set symbols.enable-external-lookup false
 -file-exec-and-symbols a.out
 -break-ins -f main
Index: packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py
===
--- packages/Python/lldbsuite/test/tools/lldb-mi/startup_opt

[Lldb-commits] [PATCH] D55858: noexternal 1/2: refactor testsuite spawnLldbMi args->exe+args

2018-12-19 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil marked 3 inline comments as done.
jankratochvil added a comment.

Thanks for the review!




Comment at: packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py:53
+if exe:
+self.runCmd("-file-exec-and-symbols \"%s\"" % exe)
 

labath wrote:
> Shouldn't you also expect the `^done` response here or something similar?
This would break compatibility with previous behavior of this function, see my 
`test_lldbmi_specialchars` comment below.



Comment at: 
packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py:63
 self.expect("\^done")
 
 # Check that it was loaded correctly

Here you can see just by passing `complicated_myexe` as `spawnLldbMi` parameter 
the code still expects to be able to match the `-file-exec-and-symbols` command.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D55858



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


[Lldb-commits] [PATCH] D55858: noexternal 1/2: refactor testsuite spawnLldbMi args->exe+args

2018-12-19 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 178842.
jankratochvil marked an inline comment as done.
jankratochvil added a comment.

I have put there a comment:

   self.runCmd("-file-exec-and-symbols \"%s\"" % exe)
  +# Testcases expect to be able to match output of this command,
  +# see test_lldbmi_specialchars.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D55858

Files:
  packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py
  
packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py
  packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py
  source/Host/common/Symbols.cpp

Index: source/Host/common/Symbols.cpp
===
--- source/Host/common/Symbols.cpp
+++ source/Host/common/Symbols.cpp
@@ -199,7 +199,7 @@
   return false;
 }
 
-FileSpec LocateExecutableSymbolFileDsym(const ModuleSpec &module_spec) {
+static FileSpec LocateExecutableSymbolFileDsym(const ModuleSpec &module_spec) {
   const FileSpec *exec_fspec = module_spec.GetFileSpecPtr();
   const ArchSpec *arch = module_spec.GetArchitecturePtr();
   const UUID *uuid = module_spec.GetUUIDPtr();
Index: packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py
===
--- packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py
+++ packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py
@@ -53,7 +53,7 @@
 os.symlink(self.myexe, complicated_myexe)
 self.addTearDownHook(lambda: os.unlink(complicated_myexe))
 
-self.spawnLldbMi(args="\"%s\"" % complicated_myexe)
+self.spawnLldbMi(exe=complicated_myexe)
 
 # Test that the executable was loaded
 self.expect(
Index: packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py
===
--- packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py
+++ packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py
@@ -22,7 +22,7 @@
 def test_lldbmi_executable_option_file(self):
 """Test that 'lldb-mi --interpreter %s' loads executable file."""
 
-self.spawnLldbMi(args="%s" % self.myexe)
+self.spawnLldbMi(exe=self.myexe)
 
 # Test that the executable is loaded when file was specified
 self.expect("-file-exec-and-symbols \"%s\"" % self.myexe)
@@ -52,7 +52,7 @@
 # Prepare path to executable
 path = "unknown_file"
 
-self.spawnLldbMi(args="%s" % path)
+self.spawnLldbMi(exe=path)
 
 # Test that the executable isn't loaded when unknown file was specified
 self.expect("-file-exec-and-symbols \"%s\"" % path)
@@ -71,7 +71,7 @@
 """Test that 'lldb-mi --interpreter %s' loads executable which is specified via absolute path."""
 
 # Prepare path to executable
-self.spawnLldbMi(args="%s" % self.myexe)
+self.spawnLldbMi(exe=self.myexe)
 
 # Test that the executable is loaded when file was specified using
 # absolute path
@@ -95,7 +95,7 @@
 
 # Prepare path to executable
 path = os.path.relpath(self.myexe, self.getBuildDir())
-self.spawnLldbMi(args="%s" % path)
+self.spawnLldbMi(exe=path)
 
 # Test that the executable is loaded when file was specified using
 # relative path
@@ -119,7 +119,7 @@
 # Prepare path to executable
 path = "unknown_dir" + self.myexe
 
-self.spawnLldbMi(args="%s" % path)
+self.spawnLldbMi(exe=path)
 
 # Test that the executable isn't loaded when file was specified using
 # unknown path
@@ -259,7 +259,7 @@
 """Test that 'lldb-mi --log' creates a log file in the current directory."""
 
 logDirectory = self.getBuildDir()
-self.spawnLldbMi(args="%s --log" % self.myexe)
+self.spawnLldbMi(exe=self.myexe, args="--log")
 
 # Test that the executable is loaded when file was specified
 self.expect("-file-exec-and-symbols \"%s\"" % self.myexe)
@@ -296,9 +296,8 @@
 import tempfile
 logDirectory = tempfile.gettempdir()
 
-self.spawnLldbMi(
-args="%s --log --log-dir=%s" %
-(self.myexe, logDirectory))
+self.spawnLldbMi(exe=self.myexe,
+args="--log --log-dir=%s" % logDirectory)
 
 # Test that the executable is loaded when file was specified
 self.expect("-file-exec-and-symbols \"%s\"" % self.myexe)
Index: packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py
===
--- packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py
+++ packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py
@@ -40

[Lldb-commits] [PATCH] D55859: noexternal 2/2: symbols.enable-external-lookup=false on all hosts (not just OSX)

2018-12-19 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added inline comments.



Comment at: source/Host/common/Symbols.cpp:365
 
+  if (!external_lookup) {
+Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);

labath wrote:
> This doesn't sound right to me. It looks like this will prevent 
> `LocateDSYMInVincinityOfExecutable`, which (I would expect) is necessary to 
> find dsym bundles for all of our dsym tests.
I have regression tested it only on Fedora 29 x86_64. I see now it may regress 
OSX but I have no idea what really dsym is. I do not have OSX available, is it 
accessible somewhere remotely for LLVM development (such as is [[ 
https://cfarm.tetaneutral.net/ | GCC Compile Farm ]])?


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D55859



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


[Lldb-commits] [PATCH] D55858: noexternal 1/2: refactor testsuite spawnLldbMi args->exe+args

2018-12-19 Thread Jan Kratochvil via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL349607: refactor testsuite spawnLldbMi args->exe+args 
(authored by jankratochvil, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D55858?vs=178842&id=178844#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55858

Files:
  lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py
  
lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py
  lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py
  lldb/trunk/source/Host/common/Symbols.cpp

Index: lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py
+++ lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py
@@ -53,7 +53,7 @@
 os.symlink(self.myexe, complicated_myexe)
 self.addTearDownHook(lambda: os.unlink(complicated_myexe))
 
-self.spawnLldbMi(args="\"%s\"" % complicated_myexe)
+self.spawnLldbMi(exe=complicated_myexe)
 
 # Test that the executable was loaded
 self.expect(
Index: lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py
+++ lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py
@@ -40,7 +40,7 @@
 pass
 Base.tearDown(self)
 
-def spawnLldbMi(self, args=None):
+def spawnLldbMi(self, exe=None, args=None):
 import pexpect
 self.child = pexpect.spawn("%s --interpreter %s" % (
 self.lldbMiExec, args if args else ""), cwd=self.getBuildDir())
@@ -49,6 +49,10 @@
 self.child.logfile_read = open(self.mylog, "w")
 # wait until lldb-mi has started up and is ready to go
 self.expect(self.child_prompt, exactly=True)
+if exe:
+self.runCmd("-file-exec-and-symbols \"%s\"" % exe)
+# Testcases expect to be able to match output of this command,
+# see test_lldbmi_specialchars.
 
 def runCmd(self, cmd):
 self.child.sendline(cmd)
Index: lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py
+++ lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py
@@ -22,7 +22,7 @@
 def test_lldbmi_executable_option_file(self):
 """Test that 'lldb-mi --interpreter %s' loads executable file."""
 
-self.spawnLldbMi(args="%s" % self.myexe)
+self.spawnLldbMi(exe=self.myexe)
 
 # Test that the executable is loaded when file was specified
 self.expect("-file-exec-and-symbols \"%s\"" % self.myexe)
@@ -52,7 +52,7 @@
 # Prepare path to executable
 path = "unknown_file"
 
-self.spawnLldbMi(args="%s" % path)
+self.spawnLldbMi(exe=path)
 
 # Test that the executable isn't loaded when unknown file was specified
 self.expect("-file-exec-and-symbols \"%s\"" % path)
@@ -71,7 +71,7 @@
 """Test that 'lldb-mi --interpreter %s' loads executable which is specified via absolute path."""
 
 # Prepare path to executable
-self.spawnLldbMi(args="%s" % self.myexe)
+self.spawnLldbMi(exe=self.myexe)
 
 # Test that the executable is loaded when file was specified using
 # absolute path
@@ -95,7 +95,7 @@
 
 # Prepare path to executable
 path = os.path.relpath(self.myexe, self.getBuildDir())
-self.spawnLldbMi(args="%s" % path)
+self.spawnLldbMi(exe=path)
 
 # Test that the executable is loaded when file was specified using
 # relative path
@@ -119,7 +119,7 @@
 # Prepare path to executable
 path = "unknown_dir" + self.myexe
 
-self.spawnLldbMi(args="%s" % path)
+self.spawnLldbMi(exe=path)
 
 # Test that the executable isn't loaded when file was specified using
 # unknown path
@@ -259,7 +259,7 @@
 """Test that 'lldb-mi --log' creates a log file in the current directory."""
 
 logDirectory = self.getBuildDir()
-self.spawnLldbMi(args="%s --log" % self.myexe)
+self.spawnLldbMi(exe=self.myexe, args="--log")
 
 # Test that the executable is loaded when file was specified
 self.expect("-file-exec-and-symbols \"%s\"" % self.myexe)
@@ -296,9 +296,8 @@
 import tempfile
 logDirectory = tempfile.gettempdir()
 
-se

[Lldb-commits] [PATCH] D55859: noexternal 2/2: symbols.enable-external-lookup=false on all hosts (not just OSX)

2018-12-19 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil marked 4 inline comments as done.
jankratochvil added a comment.

In D55859#1336351 , @friss wrote:

> Pretty sure this won't work. It might generate a dSYM, but an empty one.


I agree LLDB did not parse such DSYM symbols on Linux.

Is the patch OK for check-in now? Thanks.




Comment at: source/Host/common/Symbols.cpp:365
 
+  if (!external_lookup) {
+Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);

friss wrote:
> jankratochvil wrote:
> > labath wrote:
> > > This doesn't sound right to me. It looks like this will prevent 
> > > `LocateDSYMInVincinityOfExecutable`, which (I would expect) is necessary 
> > > to find dsym bundles for all of our dsym tests.
> > I have regression tested it only on Fedora 29 x86_64. I see now it may 
> > regress OSX but I have no idea what really dsym is. I do not have OSX 
> > available, is it accessible somewhere remotely for LLVM development (such 
> > as is [[ https://cfarm.tetaneutral.net/ | GCC Compile Farm ]])?
> I would just remove that early exit. The rest of the code shouldn't impact 
> the systems you care about.
OK, yes, I have removed it.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D55859



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


[Lldb-commits] [PATCH] D55859: noexternal 2/2: symbols.enable-external-lookup=false on all hosts (not just OSX)

2018-12-19 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 178910.
jankratochvil marked an inline comment as done.

Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D55859

Files:
  packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py
  
packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py
  
packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/start_script_error
  source/Host/common/Symbols.cpp

Index: source/Host/common/Symbols.cpp
===
--- source/Host/common/Symbols.cpp
+++ source/Host/common/Symbols.cpp
@@ -253,6 +253,9 @@
   FileSystem::Instance().Exists(symbol_file_spec))
 return symbol_file_spec;
 
+  bool external_lookup =
+  ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup();
+
   const char *symbol_filename = symbol_file_spec.GetFilename().AsCString();
   if (symbol_filename && symbol_filename[0]) {
 FileSpecList debug_file_search_paths(
@@ -270,30 +273,32 @@
   debug_file_search_paths.AppendIfUnique(file_spec);
 }
 
-// Add current working directory.
-{
-  FileSpec file_spec(".");
-  FileSystem::Instance().Resolve(file_spec);
-  debug_file_search_paths.AppendIfUnique(file_spec);
-}
+if (external_lookup) {
+  // Add current working directory.
+  {
+FileSpec file_spec(".");
+FileSystem::Instance().Resolve(file_spec);
+debug_file_search_paths.AppendIfUnique(file_spec);
+  }
 
 #ifndef _WIN32
 #if defined(__NetBSD__)
-// Add /usr/libdata/debug directory.
-{
-  FileSpec file_spec("/usr/libdata/debug");
-  FileSystem::Instance().Resolve(file_spec);
-  debug_file_search_paths.AppendIfUnique(file_spec);
-}
+  // Add /usr/libdata/debug directory.
+  {
+FileSpec file_spec("/usr/libdata/debug");
+FileSystem::Instance().Resolve(file_spec);
+debug_file_search_paths.AppendIfUnique(file_spec);
+  }
 #else
-// Add /usr/lib/debug directory.
-{
-  FileSpec file_spec("/usr/lib/debug");
-  FileSystem::Instance().Resolve(file_spec);
-  debug_file_search_paths.AppendIfUnique(file_spec);
-}
+  // Add /usr/lib/debug directory.
+  {
+FileSpec file_spec("/usr/lib/debug");
+FileSystem::Instance().Resolve(file_spec);
+debug_file_search_paths.AppendIfUnique(file_spec);
+  }
 #endif
 #endif // _WIN32
+}
 
 std::string uuid_str;
 const UUID &module_uuid = module_spec.GetUUID();
Index: packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/start_script_error
===
--- packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/start_script_error
+++ packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/start_script_error
@@ -1,2 +1,3 @@
+settings set symbols.enable-external-lookup false
 -file-exec-and-symbols a.out
 -break-ins -f main
Index: packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py
===
--- packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py
+++ packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py
@@ -237,7 +237,11 @@
 
 # Prepared source file
 sourceFile = self.copyScript("start_script_error")
-self.spawnLldbMi(args="--source %s" % sourceFile)
+self.spawnLldbMi(args="--source %s" % sourceFile, preconfig=False)
+
+# After 'settings set symbols.enable-external-lookup false'
+self.expect("settings set symbols.enable-external-lookup false")
+self.expect("\^done")
 
 # After '-file-exec-and-symbols a.out'
 self.expect("-file-exec-and-symbols %s" % self.myexe)
Index: packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py
===
--- packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py
+++ packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py
@@ -40,7 +40,7 @@
 pass
 Base.tearDown(self)
 
-def spawnLldbMi(self, exe=None, args=None):
+def spawnLldbMi(self, exe=None, args=None, preconfig=True):
 import pexpect
 self.child = pexpect.spawn("%s --interpreter %s" % (
 self.lldbMiExec, args if args else ""), cwd=self.getBuildDir())
@@ -49,6 +49,10 @@
 self.child.logfile_read = open(self.mylog, "w")
 # wait until lldb-mi has started up and is ready to go
 self.expect(self.child_prompt, exactly=True)
+if preconfig:
+self.runCmd("settings set symbols.enable-external-lookup false")
+self.expect("\^done")
+self.expect(self.child_prompt, exactly=True)
 if exe:
 self.runCmd("-file-exec-and-symbols \"

[Lldb-commits] [PATCH] D55859: noexternal 2/2: symbols.enable-external-lookup=false on all hosts (not just OSX)

2018-12-19 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 178911.

Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D55859

Files:
  packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py
  
packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py
  
packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/start_script_error
  source/Host/common/Symbols.cpp

Index: source/Host/common/Symbols.cpp
===
--- source/Host/common/Symbols.cpp
+++ source/Host/common/Symbols.cpp
@@ -270,30 +270,33 @@
   debug_file_search_paths.AppendIfUnique(file_spec);
 }
 
-// Add current working directory.
-{
-  FileSpec file_spec(".");
-  FileSystem::Instance().Resolve(file_spec);
-  debug_file_search_paths.AppendIfUnique(file_spec);
-}
+if (ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup()) {
+
+  // Add current working directory.
+  {
+FileSpec file_spec(".");
+FileSystem::Instance().Resolve(file_spec);
+debug_file_search_paths.AppendIfUnique(file_spec);
+  }
 
 #ifndef _WIN32
 #if defined(__NetBSD__)
-// Add /usr/libdata/debug directory.
-{
-  FileSpec file_spec("/usr/libdata/debug");
-  FileSystem::Instance().Resolve(file_spec);
-  debug_file_search_paths.AppendIfUnique(file_spec);
-}
+  // Add /usr/libdata/debug directory.
+  {
+FileSpec file_spec("/usr/libdata/debug");
+FileSystem::Instance().Resolve(file_spec);
+debug_file_search_paths.AppendIfUnique(file_spec);
+  }
 #else
-// Add /usr/lib/debug directory.
-{
-  FileSpec file_spec("/usr/lib/debug");
-  FileSystem::Instance().Resolve(file_spec);
-  debug_file_search_paths.AppendIfUnique(file_spec);
-}
+  // Add /usr/lib/debug directory.
+  {
+FileSpec file_spec("/usr/lib/debug");
+FileSystem::Instance().Resolve(file_spec);
+debug_file_search_paths.AppendIfUnique(file_spec);
+  }
 #endif
 #endif // _WIN32
+}
 
 std::string uuid_str;
 const UUID &module_uuid = module_spec.GetUUID();
Index: packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/start_script_error
===
--- packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/start_script_error
+++ packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/start_script_error
@@ -1,2 +1,3 @@
+settings set symbols.enable-external-lookup false
 -file-exec-and-symbols a.out
 -break-ins -f main
Index: packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py
===
--- packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py
+++ packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py
@@ -237,7 +237,11 @@
 
 # Prepared source file
 sourceFile = self.copyScript("start_script_error")
-self.spawnLldbMi(args="--source %s" % sourceFile)
+self.spawnLldbMi(args="--source %s" % sourceFile, preconfig=False)
+
+# After 'settings set symbols.enable-external-lookup false'
+self.expect("settings set symbols.enable-external-lookup false")
+self.expect("\^done")
 
 # After '-file-exec-and-symbols a.out'
 self.expect("-file-exec-and-symbols %s" % self.myexe)
Index: packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py
===
--- packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py
+++ packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py
@@ -40,7 +40,7 @@
 pass
 Base.tearDown(self)
 
-def spawnLldbMi(self, exe=None, args=None):
+def spawnLldbMi(self, exe=None, args=None, preconfig=True):
 import pexpect
 self.child = pexpect.spawn("%s --interpreter %s" % (
 self.lldbMiExec, args if args else ""), cwd=self.getBuildDir())
@@ -49,6 +49,10 @@
 self.child.logfile_read = open(self.mylog, "w")
 # wait until lldb-mi has started up and is ready to go
 self.expect(self.child_prompt, exactly=True)
+if preconfig:
+self.runCmd("settings set symbols.enable-external-lookup false")
+self.expect("\^done")
+self.expect(self.child_prompt, exactly=True)
 if exe:
 self.runCmd("-file-exec-and-symbols \"%s\"" % exe)
 # Testcases expect to be able to match output of this command,
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D55859: noexternal 2/2: symbols.enable-external-lookup=false on all hosts (not just OSX)

2018-12-20 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 179028.
jankratochvil added a comment.
Herald added a subscriber: krytarowski.

Updated symbols.enable-external-lookup description in detail.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D55859

Files:
  packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py
  
packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py
  
packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/start_script_error
  source/Core/ModuleList.cpp
  source/Host/common/Symbols.cpp

Index: source/Host/common/Symbols.cpp
===
--- source/Host/common/Symbols.cpp
+++ source/Host/common/Symbols.cpp
@@ -247,6 +247,8 @@
   return result;
 }
 
+// Keep "symbols.enable-external-lookup" description in sync with this function.
+
 FileSpec Symbols::LocateExecutableSymbolFile(const ModuleSpec &module_spec) {
   FileSpec symbol_file_spec = module_spec.GetSymbolFileSpec();
   if (symbol_file_spec.IsAbsolute() &&
@@ -270,30 +272,33 @@
   debug_file_search_paths.AppendIfUnique(file_spec);
 }
 
-// Add current working directory.
-{
-  FileSpec file_spec(".");
-  FileSystem::Instance().Resolve(file_spec);
-  debug_file_search_paths.AppendIfUnique(file_spec);
-}
+if (ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup()) {
+
+  // Add current working directory.
+  {
+FileSpec file_spec(".");
+FileSystem::Instance().Resolve(file_spec);
+debug_file_search_paths.AppendIfUnique(file_spec);
+  }
 
 #ifndef _WIN32
 #if defined(__NetBSD__)
-// Add /usr/libdata/debug directory.
-{
-  FileSpec file_spec("/usr/libdata/debug");
-  FileSystem::Instance().Resolve(file_spec);
-  debug_file_search_paths.AppendIfUnique(file_spec);
-}
+  // Add /usr/libdata/debug directory.
+  {
+FileSpec file_spec("/usr/libdata/debug");
+FileSystem::Instance().Resolve(file_spec);
+debug_file_search_paths.AppendIfUnique(file_spec);
+  }
 #else
-// Add /usr/lib/debug directory.
-{
-  FileSpec file_spec("/usr/lib/debug");
-  FileSystem::Instance().Resolve(file_spec);
-  debug_file_search_paths.AppendIfUnique(file_spec);
-}
+  // Add /usr/lib/debug directory.
+  {
+FileSpec file_spec("/usr/lib/debug");
+FileSystem::Instance().Resolve(file_spec);
+debug_file_search_paths.AppendIfUnique(file_spec);
+  }
 #endif
 #endif // _WIN32
+}
 
 std::string uuid_str;
 const UUID &module_uuid = module_spec.GetUUID();
Index: source/Core/ModuleList.cpp
===
--- source/Core/ModuleList.cpp
+++ source/Core/ModuleList.cpp
@@ -70,8 +70,22 @@
 {"enable-external-lookup", OptionValue::eTypeBoolean, true, true, nullptr,
  {},
  "Control the use of external tools or libraries to locate symbol files. "
- "On macOS, Spotlight is used to locate a matching .dSYM bundle based on "
- "the UUID of the executable."},
+ "Directories listed in target.debug-file-search-paths and directory of "
+ "the executable are always checked first for separate debug info files. "
+ "Then depending on this setting:"
+#ifdef __APPLE__
+ " On macOS, Spotlight would be also used to locate a matching .dSYM "
+ "bundle based on the UUID of the executable."
+#endif
+#ifndef _WIN32
+#ifdef __NetBSD__
+ " On NetBSD, directory /usr/libdata/debug would be also searched."
+#else // !__NetBSD__
+ " On platforms other than NetBSD directory /usr/lib/debug would be "
+ "also searched."
+#endif // !__NetBSD__
+#endif // _WIN32
+},
 {"clang-modules-cache-path", OptionValue::eTypeFileSpec, true, 0, nullptr,
  {},
  "The path to the clang modules cache directory (-fmodules-cache-path)."}};
Index: packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/start_script_error
===
--- packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/start_script_error
+++ packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/start_script_error
@@ -1,2 +1,3 @@
+settings set symbols.enable-external-lookup false
 -file-exec-and-symbols a.out
 -break-ins -f main
Index: packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py
===
--- packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py
+++ packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py
@@ -237,7 +237,11 @@
 
 # Prepared source file
 sourceFile = self.copyScript("start_script_error")
-self.spawnLldbMi(args="--source %s" % sourceFile)
+self.spawnLldbMi(args="--source %s" % sourceFile, preconfig=Fal

[Lldb-commits] [PATCH] D55859: noexternal 2/2: symbols.enable-external-lookup=false on all hosts (not just OSX)

2018-12-21 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 179349.

Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D55859

Files:
  packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py
  
packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py
  
packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/start_script_error
  source/Core/ModuleList.cpp
  source/Host/common/Symbols.cpp
  source/Target/Target.cpp

Index: source/Target/Target.cpp
===
--- source/Target/Target.cpp
+++ source/Target/Target.cpp
@@ -3232,7 +3232,8 @@
  "whose paths don't match the local file system."},
 {"debug-file-search-paths", OptionValue::eTypeFileSpecList, false, 0,
  nullptr, {},
- "List of directories to be searched when locating debug symbol files."},
+ "List of directories to be searched when locating debug symbol files. "
+ "See also symbols.enable-external-lookup."},
 {"clang-module-search-paths", OptionValue::eTypeFileSpecList, false, 0,
  nullptr, {},
  "List of directories to be searched when locating modules for Clang."},
Index: source/Host/common/Symbols.cpp
===
--- source/Host/common/Symbols.cpp
+++ source/Host/common/Symbols.cpp
@@ -247,6 +247,8 @@
   return result;
 }
 
+// Keep "symbols.enable-external-lookup" description in sync with this function.
+
 FileSpec Symbols::LocateExecutableSymbolFile(const ModuleSpec &module_spec) {
   FileSpec symbol_file_spec = module_spec.GetSymbolFileSpec();
   if (symbol_file_spec.IsAbsolute() &&
@@ -270,30 +272,33 @@
   debug_file_search_paths.AppendIfUnique(file_spec);
 }
 
-// Add current working directory.
-{
-  FileSpec file_spec(".");
-  FileSystem::Instance().Resolve(file_spec);
-  debug_file_search_paths.AppendIfUnique(file_spec);
-}
+if (ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup()) {
+
+  // Add current working directory.
+  {
+FileSpec file_spec(".");
+FileSystem::Instance().Resolve(file_spec);
+debug_file_search_paths.AppendIfUnique(file_spec);
+  }
 
 #ifndef _WIN32
 #if defined(__NetBSD__)
-// Add /usr/libdata/debug directory.
-{
-  FileSpec file_spec("/usr/libdata/debug");
-  FileSystem::Instance().Resolve(file_spec);
-  debug_file_search_paths.AppendIfUnique(file_spec);
-}
+  // Add /usr/libdata/debug directory.
+  {
+FileSpec file_spec("/usr/libdata/debug");
+FileSystem::Instance().Resolve(file_spec);
+debug_file_search_paths.AppendIfUnique(file_spec);
+  }
 #else
-// Add /usr/lib/debug directory.
-{
-  FileSpec file_spec("/usr/lib/debug");
-  FileSystem::Instance().Resolve(file_spec);
-  debug_file_search_paths.AppendIfUnique(file_spec);
-}
+  // Add /usr/lib/debug directory.
+  {
+FileSpec file_spec("/usr/lib/debug");
+FileSystem::Instance().Resolve(file_spec);
+debug_file_search_paths.AppendIfUnique(file_spec);
+  }
 #endif
 #endif // _WIN32
+}
 
 std::string uuid_str;
 const UUID &module_uuid = module_spec.GetUUID();
Index: source/Core/ModuleList.cpp
===
--- source/Core/ModuleList.cpp
+++ source/Core/ModuleList.cpp
@@ -69,9 +69,16 @@
 static constexpr PropertyDefinition g_properties[] = {
 {"enable-external-lookup", OptionValue::eTypeBoolean, true, true, nullptr,
  {},
- "Control the use of external tools or libraries to locate symbol files. "
- "On macOS, Spotlight is used to locate a matching .dSYM bundle based on "
- "the UUID of the executable."},
+ "Control the use of external sources to locate symbol files. "
+ "Directories listed in target.debug-file-search-paths and directory of "
+ "the executable are always checked first for separate debug info files. "
+ "Then depending on this setting: "
+ "On macOS, Spotlight would be also used to locate a matching .dSYM "
+ "bundle based on the UUID of the executable. "
+ "On NetBSD, directory /usr/libdata/debug would be also searched. "
+ "On platforms other than NetBSD directory /usr/lib/debug would be "
+ "also searched."
+},
 {"clang-modules-cache-path", OptionValue::eTypeFileSpec, true, 0, nullptr,
  {},
  "The path to the clang modules cache directory (-fmodules-cache-path)."}};
Index: packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/start_script_error
===
--- packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/start_script_error
+++ packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/start_script_error
@@ -1,2 +1,3 @@
+settings set symbols.enable-external-lookup false
 -file-exec-and-symbols 

[Lldb-commits] [PATCH] D55859: noexternal 2/2: symbols.enable-external-lookup=false on all hosts (not just OSX)

2018-12-21 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil marked 2 inline comments as done.
jankratochvil added inline comments.



Comment at: source/Core/ModuleList.cpp:72
  {},
  "Control the use of external tools or libraries to locate symbol files. "
+ "Directories listed in target.debug-file-search-paths and directory of "

labath wrote:
> My main issue here was with the "tools or libraries" part of this description 
> -- we're not using any special tools or libraries when looking in 
> /usr/lib/debug.
> 
> Maybe just say that this is controls whether we use "external sources" when 
> searching for symbols. The rest of the description is fine (though I would 
> just drop the ifdefs and print everything everywhere).
The Spotlight on OSX was a bit unclear to me what it really does.  Doesn't it 
use some those "tools or libraries" to access the dSYM files downloaded from 
internet? But I have put there the "sources" word now as you wish.
Also rather added `See also symbols.enable-external-lookup.` to 
`target.debug-file-search-paths`.
I will check it in if there are no more replies in some time. Thanks for the 
approval.



Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D55859



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


[Lldb-commits] [PATCH] D55998: ELF: create "container" sections from PT_LOAD segments

2018-12-23 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

> it is in theory possible to create an elf file where only a part of a section 
> would belong to some segment (and another part to a different one).

ELF standard : "//An object file 
segment contains one or more sections.//", "//An object file segment comprises 
one or more sections//"


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

https://reviews.llvm.org/D55998



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


[Lldb-commits] [PATCH] D53530: Fix (and improve) the support for C99 variable length array types

2018-12-24 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added subscribers: dblaikie, jankratochvil.
jankratochvil added a comment.

There is a regression in trunk clang+lldb.  Using either 7.0 clang or 7.0 lldb 
makes the testcases PASS but both trunk clang and trunk lldb makes the testcase 
FAIL.
This commit (rL346165 ) is the regressing 
one for LLDB, commit rL349207  by @dblaikie 
is the regressing one for clang.

TestChar1632T.py

FAIL:

  
Failure-TestChar1632T-Char1632TestCase-test_dwo-x86_64-redhat-llvm-monorepo-clang-bin-clang-8.log
  runCmd: frame variable as16 as32
  output: (char16_t []) as16 = {}
  (char32_t []) as32 = {}

PASS:

  
Success-TestChar1632T-Char1632TestCase-test_dwo-x86_64-redhat-llvm-monorepo-clang-bin-clang-8.log
  runCmd: frame variable as16 as32
  output: (char16_t [64]) as16 = u"ﺸﺵۻ"
  (char32_t [64]) as32 = U"ЕЙРГЖО"

| clang-1 | lldb-1 | PASS |
| clang-1 | lldb   | PASS |
| clang   | lldb-1 | PASS |
| clang   | lldb   | FAIL |
|

monorepo:
clang-1=d162fb426deb61f897038e07ebd2fcaae8e51c01^=b36eb520c704507990b039011cc02c3da181c461
clang  =d162fb426deb61f897038e07ebd2fcaae8e51c01
lldb 
-1=0154738f9a1f73b5fe108671f61554b94eabf3fb^=91e3d2bffe38dbde2976cbb76cecce97a3e94af6
lldb   =0154738f9a1f73b5fe108671f61554b94eabf3fb

git:
clang = b4b260e17979210464c395ee00e6c985f305a16e = 
https://reviews.llvm.org/rL349207
lldb= 8fea0d8957787360d7e5abefc7b6a94991c07f85 = 
https://reviews.llvm.org/rL346165 = https://reviews.llvm.org/D53530

GDB seems to handle the clang output OK:

  gdb -batch -ex 'b 42' -ex r -ex 'p as16' -ex 'p as32' 
./lldb-test-build.noindex/lang/cpp/char1632_t/TestChar1632T.test_dwo/a.out
  ...
  $1 = 
u"色ハ匂ヘト散リヌルヲ\000\000\000\000\000\000y\000\000\000\xde08@\000\000᯿\001\000\000ᰰ\001\000\000ミ\x\x\xѰ\000\000\000ᇁ\000Ҡ\000ᕭ@\000\000ῠ翿\000\000\000\000\000ᔠ@\000\000ၐ@\000"
  $2 = 
U"෴\000РГЖО\000\000\000\000\x6562b026\000\xf7ffea80翿\xf7b89061翿\xf7c55c60翿ɐ\000\xf7c564f8翿\xf7b1d5ad翿\002\000\xf7b198d7翿\000\000\x405000\000ɰ\000\xf000\x\000\000\000\000\000\000\000\000\000\000\xf7c55cc0翿#\000\000\000\xff90\x\xf7c55c60翿ɐ\000\xf7b1a909翿ɀ\000\000"

Using for the test:

  
PYTHONPATH=$PWD/lib64/python2.7/site-packages:$PWD/lib64/python2.7/site-packages/lldb"
 LD_LIBRARY_PATH=$PWD/lib:$PWD/lib64/python2.7/site-packages/lldb" 
../llvm-monorepo/lldb/test/dotest.py --executable /PATH/TO/bin/lldb -C 
$PWD/bin/clang --log-success -t 
../llvm-monorepo/lldb/packages/Python/lldbsuite/test/  -p TestChar1632T.py


Repository:
  rL LLVM

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

https://reviews.llvm.org/D53530



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


[Lldb-commits] [PATCH] D56068: Use reference only for DW_FORM_ref*

2018-12-24 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil created this revision.
jankratochvil added reviewers: clayborg, aprantl.
jankratochvil added a project: LLDB.
Herald added a subscriber: JDevlieghere.

D53530  could interpret `DW_AT_count` in 
`DW_FORM_data1` as a DIE reference as it did not verify its form. Verify that 
reference really uses only `DW_FORM_ref*`  forms as it could otherwise 
accidentally follow a constant number as DIE offset. That fixes a regression as 
described there. 
That `DW_FORM_ref_sig8` comment should be updated by D54670 
 after it gets approved.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D56068

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h


Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
@@ -71,6 +71,7 @@
   bool ExtractValue(const lldb_private::DWARFDataExtractor &data,
 lldb::offset_t *offset_ptr);
   const uint8_t *BlockData() const;
+  bool FormIsReference() const;
   uint64_t Reference() const;
   uint64_t Reference(dw_offset_t offset) const;
   bool Boolean() const { return m_value.value.uval != 0; }
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
@@ -603,6 +603,25 @@
   return symbol_file->get_debug_addr_data().GetMaxU64(&offset, index_size);
 }
 
+bool DWARFFormValue::FormIsReference() const {
+  switch (m_form) {
+  case DW_FORM_ref1:
+  case DW_FORM_ref2:
+  case DW_FORM_ref4:
+  case DW_FORM_ref8:
+  case DW_FORM_ref_udata:
+  case DW_FORM_ref_addr:
+return true;
+break;
+
+  // It cannot be resolved by the Reference() method.
+  case DW_FORM_ref_sig8:
+  default:
+break;
+  }
+  return false;
+}
+
 uint64_t DWARFFormValue::Reference() const {
   uint64_t die_offset = m_value.value.uval;
   switch (m_form) {
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -1001,7 +1001,8 @@
 bool check_specification_or_abstract_origin) const {
   DWARFFormValue form_value;
   if (GetAttributeValue(dwarf2Data, cu, attr, form_value, nullptr,
-check_specification_or_abstract_origin))
+check_specification_or_abstract_origin)
+  && form_value.FormIsReference())
 return form_value.Reference();
   return fail_value;
 }


Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
@@ -71,6 +71,7 @@
   bool ExtractValue(const lldb_private::DWARFDataExtractor &data,
 lldb::offset_t *offset_ptr);
   const uint8_t *BlockData() const;
+  bool FormIsReference() const;
   uint64_t Reference() const;
   uint64_t Reference(dw_offset_t offset) const;
   bool Boolean() const { return m_value.value.uval != 0; }
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
@@ -603,6 +603,25 @@
   return symbol_file->get_debug_addr_data().GetMaxU64(&offset, index_size);
 }
 
+bool DWARFFormValue::FormIsReference() const {
+  switch (m_form) {
+  case DW_FORM_ref1:
+  case DW_FORM_ref2:
+  case DW_FORM_ref4:
+  case DW_FORM_ref8:
+  case DW_FORM_ref_udata:
+  case DW_FORM_ref_addr:
+return true;
+break;
+
+  // It cannot be resolved by the Reference() method.
+  case DW_FORM_ref_sig8:
+  default:
+break;
+  }
+  return false;
+}
+
 uint64_t DWARFFormValue::Reference() const {
   uint64_t die_offset = m_value.value.uval;
   switch (m_form) {
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -1001,7 +1001,8 @@
 bool check_specification_or_abstract_origin) const {
   DWARFFormValue form_value;
   if (GetAttributeValue(dwarf2Data, cu, attr, form_value, nullptr,
-check_specification_or_abstract_origin))
+check_specification_or_abstr

[Lldb-commits] [PATCH] D53530: Fix (and improve) the support for C99 variable length array types

2018-12-24 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added inline comments.



Comment at: 
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp:3476
+  if (DWARFDIE var_die = die.GetReferencedDIE(DW_AT_count)) {
+if (var_die.Tag() == DW_TAG_variable)
+  if (exe_ctx) {

Here it could accidentally follow a number as DIE reference, addressed by: 
D56068



Repository:
  rL LLVM

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

https://reviews.llvm.org/D53530



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


[Lldb-commits] [PATCH] D55991: DWARF: Fix a bug in array size computation

2018-12-25 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added inline comments.



Comment at: source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp:620
+  case DW_FORM_ref_sig8:
+  case DW_FORM_GNU_ref_alt:
+return die_offset;

clayborg wrote:
> Not sure that this is, but if it isn't an absolute .debug_info offset, then 
> we shouldn't return it here
It is DWZ's reference from main debug file into shared DWZ common file - 
implemented by pending D40474.
I agree it needs more complicated handling than this implementation so it 
should not be here.



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

https://reviews.llvm.org/D55991



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


[Lldb-commits] [PATCH] D56068: Use reference only for DW_FORM_ref*

2018-12-25 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil abandoned this revision.
jankratochvil added a comment.

It is a duplicate of D55991 .


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D56068



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


[Lldb-commits] [PATCH] D55859: noexternal 2/2: symbols.enable-external-lookup=false on all hosts (not just OSX)

2019-01-03 Thread Jan Kratochvil via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
jankratochvil marked an inline comment as done.
Closed by commit rLLDB350368: symbols.enable-external-lookup=false on all hosts 
(not just OSX) (authored by jankratochvil, committed by ).
Herald added a reviewer: serge-sans-paille.

Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D55859

Files:
  packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py
  
packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py
  
packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/start_script_error
  source/Core/ModuleList.cpp
  source/Host/common/Symbols.cpp
  source/Target/Target.cpp

Index: packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py
===
--- packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py
+++ packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py
@@ -40,7 +40,7 @@
 pass
 Base.tearDown(self)
 
-def spawnLldbMi(self, exe=None, args=None):
+def spawnLldbMi(self, exe=None, args=None, preconfig=True):
 import pexpect
 self.child = pexpect.spawn("%s --interpreter %s" % (
 self.lldbMiExec, args if args else ""), cwd=self.getBuildDir())
@@ -49,6 +49,10 @@
 self.child.logfile_read = open(self.mylog, "w")
 # wait until lldb-mi has started up and is ready to go
 self.expect(self.child_prompt, exactly=True)
+if preconfig:
+self.runCmd("settings set symbols.enable-external-lookup false")
+self.expect("\^done")
+self.expect(self.child_prompt, exactly=True)
 if exe:
 self.runCmd("-file-exec-and-symbols \"%s\"" % exe)
 # Testcases expect to be able to match output of this command,
Index: packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py
===
--- packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py
+++ packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py
@@ -237,7 +237,11 @@
 
 # Prepared source file
 sourceFile = self.copyScript("start_script_error")
-self.spawnLldbMi(args="--source %s" % sourceFile)
+self.spawnLldbMi(args="--source %s" % sourceFile, preconfig=False)
+
+# After 'settings set symbols.enable-external-lookup false'
+self.expect("settings set symbols.enable-external-lookup false")
+self.expect("\^done")
 
 # After '-file-exec-and-symbols a.out'
 self.expect("-file-exec-and-symbols %s" % self.myexe)
Index: packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/start_script_error
===
--- packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/start_script_error
+++ packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/start_script_error
@@ -1,2 +1,3 @@
+settings set symbols.enable-external-lookup false
 -file-exec-and-symbols a.out
 -break-ins -f main
Index: source/Host/common/Symbols.cpp
===
--- source/Host/common/Symbols.cpp
+++ source/Host/common/Symbols.cpp
@@ -247,6 +247,8 @@
   return result;
 }
 
+// Keep "symbols.enable-external-lookup" description in sync with this function.
+
 FileSpec Symbols::LocateExecutableSymbolFile(const ModuleSpec &module_spec) {
   FileSpec symbol_file_spec = module_spec.GetSymbolFileSpec();
   if (symbol_file_spec.IsAbsolute() &&
@@ -270,30 +272,33 @@
   debug_file_search_paths.AppendIfUnique(file_spec);
 }
 
-// Add current working directory.
-{
-  FileSpec file_spec(".");
-  FileSystem::Instance().Resolve(file_spec);
-  debug_file_search_paths.AppendIfUnique(file_spec);
-}
+if (ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup()) {
+
+  // Add current working directory.
+  {
+FileSpec file_spec(".");
+FileSystem::Instance().Resolve(file_spec);
+debug_file_search_paths.AppendIfUnique(file_spec);
+  }
 
 #ifndef _WIN32
 #if defined(__NetBSD__)
-// Add /usr/libdata/debug directory.
-{
-  FileSpec file_spec("/usr/libdata/debug");
-  FileSystem::Instance().Resolve(file_spec);
-  debug_file_search_paths.AppendIfUnique(file_spec);
-}
+  // Add /usr/libdata/debug directory.
+  {
+FileSpec file_spec("/usr/libdata/debug");
+FileSystem::Instance().Resolve(file_spec);
+debug_file_search_paths.AppendIfUnique(file_spec);
+  }
 #else
-// Add /usr/lib/debug directory.
-{
-  FileSpec file_spec("/usr/lib/debug");
-  FileSystem::Instance().Resolve(file_spec);
-  debug_file_search_paths.AppendIfUnique(file_spec);
-

[Lldb-commits] [PATCH] D55859: noexternal 2/2: symbols.enable-external-lookup=false on all hosts (not just OSX)

2019-01-03 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil marked an inline comment as done.
jankratochvil added inline comments.



Comment at: source/Core/ModuleList.cpp:72
  {},
  "Control the use of external tools or libraries to locate symbol files. "
+ "Directories listed in target.debug-file-search-paths and directory of "

aprantl wrote:
> jankratochvil wrote:
> > labath wrote:
> > > My main issue here was with the "tools or libraries" part of this 
> > > description -- we're not using any special tools or libraries when 
> > > looking in /usr/lib/debug.
> > > 
> > > Maybe just say that this is controls whether we use "external sources" 
> > > when searching for symbols. The rest of the description is fine (though I 
> > > would just drop the ifdefs and print everything everywhere).
> > The Spotlight on OSX was a bit unclear to me what it really does.  Doesn't 
> > it use some those "tools or libraries" to access the dSYM files downloaded 
> > from internet? But I have put there the "sources" word now as you wish.
> > Also rather added `See also symbols.enable-external-lookup.` to 
> > `target.debug-file-search-paths`.
> > I will check it in if there are no more replies in some time. Thanks for 
> > the approval.
> > 
> The original wording is meant for tools that download debug symbols from 
> centralized repositories like the dsym download scripts mentioned on 
> http://lldb.llvm.org/symbols.html + the Spotlight metadata search engine.
> 
> The wording "sources" is problematic because it could be confused with source 
> code. Does "/usr/lib..." count as an external library? Alternatively, what 
> about "tools and repositories"?
GDB calls "**/usr/lib/debug**" as "**debug-file-directory**". I definitely 
would not call it a "**library**". Would be OK for everyone to use "**external 
tools or directories**"?


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D55859



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


[Lldb-commits] [PATCH] D55859: noexternal 2/2: symbols.enable-external-lookup=false on all hosts (not just OSX)

2019-01-05 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil marked an inline comment as done.
jankratochvil added inline comments.



Comment at: source/Core/ModuleList.cpp:72
  {},
  "Control the use of external tools or libraries to locate symbol files. "
+ "Directories listed in target.debug-file-search-paths and directory of "

labath wrote:
> jankratochvil wrote:
> > aprantl wrote:
> > > jankratochvil wrote:
> > > > labath wrote:
> > > > > My main issue here was with the "tools or libraries" part of this 
> > > > > description -- we're not using any special tools or libraries when 
> > > > > looking in /usr/lib/debug.
> > > > > 
> > > > > Maybe just say that this is controls whether we use "external 
> > > > > sources" when searching for symbols. The rest of the description is 
> > > > > fine (though I would just drop the ifdefs and print everything 
> > > > > everywhere).
> > > > The Spotlight on OSX was a bit unclear to me what it really does.  
> > > > Doesn't it use some those "tools or libraries" to access the dSYM files 
> > > > downloaded from internet? But I have put there the "sources" word now 
> > > > as you wish.
> > > > Also rather added `See also symbols.enable-external-lookup.` to 
> > > > `target.debug-file-search-paths`.
> > > > I will check it in if there are no more replies in some time. Thanks 
> > > > for the approval.
> > > > 
> > > The original wording is meant for tools that download debug symbols from 
> > > centralized repositories like the dsym download scripts mentioned on 
> > > http://lldb.llvm.org/symbols.html + the Spotlight metadata search engine.
> > > 
> > > The wording "sources" is problematic because it could be confused with 
> > > source code. Does "/usr/lib..." count as an external library? 
> > > Alternatively, what about "tools and repositories"?
> > GDB calls "**/usr/lib/debug**" as "**debug-file-directory**". I definitely 
> > would not call it a "**library**". Would be OK for everyone to use 
> > "**external tools or directories**"?
> Both "repositories" and "directories" sound fine to me. Another option might 
> be to use something really generic like "facilities"? 
It is now changed to "external tools and repositories" which should satisfy 
everyone by: rL350479


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D55859



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


[Lldb-commits] [PATCH] D40470: DWZ 03/07: Protect DWARFCompileUnit::m_die_array by a new mutex

2018-05-13 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

Revert "Protect DWARFCompileUnit::m_die_array by a new mutex"
Pavel Labath found this patch is incomplete and racy.  I think there needs to 
be some more mutexes even before considering DW_TAG_partial_unit.
This reverts commit 331229 which was: https://reviews.llvm.org/D40470
GIT commit cc242f2a5e10a8e6f8e11a268d376a76324c1d23


Repository:
  rL LLVM

https://reviews.llvm.org/D40470



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


[Lldb-commits] [PATCH] D46810: Fix DWARFUnit::GetUnitDIEPtrOnly stale pointer

2018-05-13 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil created this revision.
jankratochvil added reviewers: clayborg, labath.
Herald added subscribers: JDevlieghere, aprantl.

  +  // GetUnitDIEPtrOnly() needs to return pointer to the first DIE.
  +  // But the first element of m_die_array after ExtractDIEsIfNeeded(true)
  +  // may move in memory after later ExtractDIEsIfNeeded(false).

I haven't tried to reproduce it. `DWARFDebugInfoEntry::collection m_die_array` 
is `std::vector`, its data may move during its expansion.
I would not mind but I have found I cannot make the code thread-safe for 
https://reviews.llvm.org/D40470 when it looks already incorrect to me.


https://reviews.llvm.org/D46810

Files:
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
  source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFUnit.h

Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.h
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -170,6 +170,13 @@
   void *m_user_data = nullptr;
   // The compile unit debug information entry item
   DWARFDebugInfoEntry::collection m_die_array;
+  // GetUnitDIEPtrOnly() needs to return pointer to the first DIE.
+  // But the first element of m_die_array after ExtractDIEsIfNeeded(true)
+  // may move in memory after later ExtractDIEsIfNeeded(false).
+  DWARFDebugInfoEntry m_first_die;
+  // m_die_array_size() is like m_die_array.size() but
+  // it considers also m_die_array.empty() with m_first_die.
+  size_t m_die_array_size() const;
   // A table similar to the .debug_aranges table, but this one points to the
   // exact DW_TAG_subprogram DIEs
   std::unique_ptr m_func_aranges_ap;
@@ -208,9 +215,9 @@
   // if needed.
   const DWARFDebugInfoEntry *GetUnitDIEPtrOnly() {
 ExtractDIEsIfNeeded(true);
-if (m_die_array.empty())
+if (!m_first_die)
   return NULL;
-return &m_die_array[0];
+return &m_first_die;
   }
 
   // Get all DWARF debug informration entries. Parse all DIEs if needed.
Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -41,7 +41,7 @@
 // Parses a compile unit and indexes its DIEs if it hasn't already been done.
 //--
 size_t DWARFUnit::ExtractDIEsIfNeeded(bool cu_die_only) {
-  const size_t initial_die_array_size = m_die_array.size();
+  const size_t initial_die_array_size = m_die_array_size();
   if ((cu_die_only && initial_die_array_size > 0) || initial_die_array_size > 1)
 return 0; // Already parsed
 
@@ -93,6 +93,22 @@
 if (depth == 0) {
   if (initial_die_array_size == 0)
 AddUnitDIE(die);
+
+  if (!cu_die_only) {
+assert(m_die_array.empty() && "Compile unit DIE already added");
+
+// The average bytes per DIE entry has been seen to be around 14-20 so
+// lets pre-reserve half of that since we are now stripping the NULL
+// tags.
+
+// Only reserve the memory if we are adding children of the main
+// compile unit DIE. The compile unit DIE is always the first entry, so
+// if our size is 1, then we are adding the first compile unit child
+// DIE and should reserve the memory.
+m_die_array.reserve(GetDebugInfoSize() / 24);
+m_die_array.push_back(die);
+  }
+
   uint64_t base_addr = die.GetAttributeValueAsAddress(
   m_dwarf, this, DW_AT_low_pc, LLDB_INVALID_ADDRESS);
   if (base_addr == LLDB_INVALID_ADDRESS)
@@ -102,14 +118,17 @@
   if (cu_die_only)
 return 1;
 } else {
+  assert(!cu_die_only);
   if (null_die) {
 if (prev_die_had_children) {
   // This will only happen if a DIE says is has children but all it
   // contains is a NULL tag. Since we are removing the NULL DIEs from
   // the list (saves up to 25% in C++ code), we need a way to let the
   // DIE know that it actually doesn't have children.
-  if (!m_die_array.empty())
+  if (!m_die_array.empty()) {
 m_die_array.back().SetEmptyChildren(true);
+m_first_die.SetEmptyChildren(true);
+  }
 }
   } else {
 die.SetParentIndex(m_die_array.size() - die_index_stack[depth - 1]);
@@ -135,7 +154,7 @@
 
   prev_die_had_children = false;
 } else {
-  die_index_stack.back() = m_die_array.size() - 1;
+  die_index_stack.back() = m_die_array_size() - 1;
   // Normal DIE
   const bool die_has_children = die.HasChildren();
   if (die_has_children) {
@@ -169,36 +188,38 @@
   if (log && log->GetVerbose()) {
 StreamString strm;
 Dump(&strm);
-if (m_die_array.empty())
+if (!m_first_die)
   strm.Printf("er

[Lldb-commits] [PATCH] D40470: Protect DWARFCompileUnit::m_die_array by a new mutex

2018-05-13 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 146523.
jankratochvil retitled this revision from "DWZ 03/07: Protect 
DWARFCompileUnit::m_die_array by a new mutex" to "Protect 
DWARFCompileUnit::m_die_array by a new mutex".
jankratochvil edited the summary of this revision.

https://reviews.llvm.org/D40470

Files:
  source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFUnit.h

Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.h
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -13,6 +13,7 @@
 #include "DWARFDIE.h"
 #include "DWARFDebugInfoEntry.h"
 #include "lldb/lldb-enumerations.h"
+#include "llvm/Support/RWMutex.h"
 
 class DWARFUnit;
 class DWARFCompileUnit;
@@ -196,6 +197,12 @@
   // If this is a dwo compile unit this is the offset of the base compile unit
   // in the main object file
   dw_offset_t m_base_obj_offset = DW_INVALID_OFFSET;
+  mutable llvm::sys::RWMutex m_extractdies_mutex;
+  // It gets increased by ExtractDIEsIfNeeded(false) and decreased by ClearDIEs.
+  // BuildAddressRangeTable and SymbolFileDWARF::Index can populate m_die_array
+  // only temporarily while other functions calling only
+  // ExtractDIEsIfNeeded(false) will keep m_die_array populated forever.
+  uint32_t m_extractdies_count = 0;
 
   static void
   IndexPrivate(DWARFUnit *dwarf_cu, const lldb::LanguageType cu_language,
@@ -215,14 +222,17 @@
   // if needed.
   const DWARFDebugInfoEntry *GetUnitDIEPtrOnly() {
 ExtractDIEsIfNeeded(true);
+// m_extractdies_mutex is not required as m_first_die is never cleared.
 if (!m_first_die)
   return NULL;
 return &m_first_die;
   }
 
   // Get all DWARF debug informration entries. Parse all DIEs if needed.
   const DWARFDebugInfoEntry *DIEPtr() {
 ExtractDIEsIfNeeded(false);
+// m_extractdies_mutex is not required as ExtractDIEsIfNeeded(false) has not
+// been matched by ClearDIEs.
 if (m_die_array.empty())
   return NULL;
 return &m_die_array[0];
Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -41,9 +41,24 @@
 // Parses a compile unit and indexes its DIEs if it hasn't already been done.
 //--
 size_t DWARFUnit::ExtractDIEsIfNeeded(bool cu_die_only) {
-  const size_t initial_die_array_size = m_die_array_size();
-  if ((cu_die_only && initial_die_array_size > 0) || initial_die_array_size > 1)
-return 0; // Already parsed
+  size_t initial_die_array_size;
+  auto already_parsed = [cu_die_only, &initial_die_array_size, this]() -> bool {
+initial_die_array_size = m_die_array_size();
+return (cu_die_only && initial_die_array_size > 0)
+|| initial_die_array_size > 1;
+  };
+  {
+llvm::sys::ScopedReader lock(m_extractdies_mutex);
+if (already_parsed())
+  return 0;
+  }
+  llvm::sys::ScopedWriter lock(m_extractdies_mutex);
+  if (already_parsed())
+return 0;
+  // Protect against use count overflow.
+  if (!cu_die_only && m_extractdies_count
+  < std::numeric_limits::max())
+++m_extractdies_count;
 
   static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
   Timer scoped_timer(
@@ -213,6 +228,7 @@
   return m_first_die ? 1 : 0;
 }
 
+// m_extractdies_mutex must be already held as read/write.
 void DWARFUnit::AddUnitDIE(DWARFDebugInfoEntry &die) {
   assert(m_die_array.empty() && "Compile unit DIE already added");
   assert(!m_first_die);
@@ -265,11 +281,14 @@
 DWARFDIECollection &dies,
 uint32_t depth) const {
   size_t old_size = dies.Size();
-  DWARFDebugInfoEntry::const_iterator pos;
-  DWARFDebugInfoEntry::const_iterator end = m_die_array.end();
-  for (pos = m_die_array.begin(); pos != end; ++pos) {
-if (pos->Tag() == tag)
-  dies.Append(DWARFDIE(this, &(*pos)));
+  {
+llvm::sys::ScopedReader lock(m_extractdies_mutex);
+DWARFDebugInfoEntry::const_iterator pos;
+DWARFDebugInfoEntry::const_iterator end = m_die_array.end();
+for (pos = m_die_array.begin(); pos != end; ++pos) {
+  if (pos->Tag() == tag)
+dies.Append(DWARFDIE(this, &(*pos)));
+}
   }
 
   // Return the number of DIEs added to the collection
@@ -310,9 +329,18 @@
   m_base_obj_offset = base_obj_offset;
 }
 
+// It may be called only after: ExtractDIEsIfNeeded(false) > 1
 void DWARFUnit::ClearDIEs(bool keep_compile_unit_die) {
-  m_die_array.clear();
-  m_die_array.shrink_to_fit();
+  {
+llvm::sys::ScopedWriter lock(m_extractdies_mutex);
+lldbassert(m_die_array.size() > 1);
+lldbassert(m_extractdies_count > 0);
+if (--m_extractdies_count > 0)
+  return;
+
+m_die_array.clear();
+m_die_array.shrink_to_fit();
+  }
 
   if (m_dwo_symbol_file)
 m_dwo_symbol_file->GetCompile

[Lldb-commits] [PATCH] D46810: Fix DWARFUnit::GetUnitDIEPtrOnly stale pointer

2018-05-14 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

In https://reviews.llvm.org/D46810#1097503, @labath wrote:

> - if nothing has been parsed, m_die_array is empty  and m_first_die is empty
> - if the cu die has been parsed, m_die_array us empty and m_first_die is full
> - if everything has been parsed m_first_die and m_die_array are full, **and** 
> the first element of m_die_array contains a copy of m_first_die Is that an 
> accurate description of what you are doing here?


Yes. I will add a comment to the code.

> (If that is true, then I think this is workable, but there are still some 
> details which need to be ironed out; e.g., `m_first_die.GetFirstChild()`)

The current code calling `GetUnitDIEOnly()` (returning `DWARFDIE`) or 
`GetUnitDIEPtrOnly` (returning `DWARFDebugInfoEntry *`) is never dealing with 
child DIEs of what it gets - it also makes sense as there is no guarantee they 
have been read in. Such code would already cause ASAN error accessing memory 
behind `std::vector`. So I find such assertion check orthogonal to this patch 
but I will prepare another patch for that.

Thanks for checking validity of this patch, I was not sure whether LLDB code is 
intended to be thread-safe in the first place.


https://reviews.llvm.org/D46810



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


[Lldb-commits] [PATCH] D46810: Fix DWARFUnit::GetUnitDIEPtrOnly stale pointer

2018-05-14 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

In https://reviews.llvm.org/D46810#1097829, @labath wrote:

> I am not sure it's that simple. I've found at least one case 
> (`SymbolFileDWARF::ParseImportedModuleswhere we call GetFirstChild() on the 
> value returned by `GetUnitDIEOnly`


OK, that is clearly a bug there, thanks for finding it. I see some new 
assertion check would be good (I may try even a compile time check by some new 
class wrapper). `SymbolFileDWARF::ParseImportedModules` should just call 
`DIE()`.

  DWARFDIE GetUnitDIEOnly() -> DWARFDebugInfoEntry *GetUnitDIEPtrOnly() -> 
ExtractDIEsIfNeeded(true ) -> CU DIE only
  DWARFDIEDIE() -> DWARFDebugInfoEntry *   DIEPtr() -> 
ExtractDIEsIfNeeded(false) -> all DIEs



> I was thinking of making this safer by changing the `GetUnitDIEOnly` so that 
> the caller has to explicitly request (either with an argument, or by 
> splitting it into two functions) whether it wants a CU die, which can be used 
> to access other DIEs, or just a bare attribute-only DIE. In second case, we 
> would return &m_first_die, in the first case &m_die_array[0] (after making 
> sure it's properly initialized).

But there is already such function, it is called `DIE()`, we need no new 
parameter. Maybe we should rename those functions, their current names are 
cryptic, what about changing the second line to:

  DWARFDIE GetUnitDIEOnly() -> DWARFDebugInfoEntry *GetUnitDIEPtrOnly() -> 
ExtractDIEsIfNeeded(true ) -> CU DIE only
  DWARFDIE GetUnitAllDIEs() -> DWARFDebugInfoEntry *GetUnitAllDIEsPtr() -> 
ExtractDIEsIfNeeded(false) -> all DIEs



> Then `m_first_die` can have `has_children` property set to false to enforce 
> that noone accesses children that way.

I would prefer an assert (or even a compilation error by some wrapper class) in 
such case but I agree this may be enough.


https://reviews.llvm.org/D46810



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


[Lldb-commits] [PATCH] D47275: 1/3: DWARFDIE split out to DWARFBasicDIE

2018-05-23 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil created this revision.
jankratochvil added reviewers: labath, clayborg.
Herald added subscribers: JDevlieghere, aprantl, mgorny.

As Pavel Labath said in https://reviews.llvm.org/D46810 this is new 
`DWARFBasicDIE` to be used for `DWARFUnit::GetUnitDIEOnly()`. This patch is 
only mechanical split without any use of it.


https://reviews.llvm.org/D47275

Files:
  source/Plugins/SymbolFile/DWARF/CMakeLists.txt
  source/Plugins/SymbolFile/DWARF/DWARFBasicDIE.cpp
  source/Plugins/SymbolFile/DWARF/DWARFBasicDIE.h
  source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDIE.h

Index: source/Plugins/SymbolFile/DWARF/DWARFDIE.h
===
--- source/Plugins/SymbolFile/DWARF/DWARFDIE.h
+++ source/Plugins/SymbolFile/DWARF/DWARFDIE.h
@@ -10,125 +10,23 @@
 #ifndef SymbolFileDWARF_DWARFDIE_h_
 #define SymbolFileDWARF_DWARFDIE_h_
 
-#include "lldb/Core/dwarf.h"
-#include "lldb/lldb-types.h"
-
-struct DIERef;
-class DWARFASTParser;
-class DWARFAttributes;
-class DWARFUnit;
-class DWARFDebugInfoEntry;
-class DWARFDeclContext;
-class DWARFDIECollection;
-class SymbolFileDWARF;
-
-class DWARFDIE {
-public:
-  DWARFDIE() : m_cu(nullptr), m_die(nullptr) {}
-
-  DWARFDIE(DWARFUnit *cu, DWARFDebugInfoEntry *die)
-  : m_cu(cu), m_die(die) {}
-
-  DWARFDIE(const DWARFUnit *cu, DWARFDebugInfoEntry *die)
-  : m_cu(const_cast(cu)), m_die(die) {}
-
-  DWARFDIE(DWARFUnit *cu, const DWARFDebugInfoEntry *die)
-  : m_cu(cu), m_die(const_cast(die)) {}
-
-  DWARFDIE(const DWARFUnit *cu, const DWARFDebugInfoEntry *die)
-  : m_cu(const_cast(cu)),
-m_die(const_cast(die)) {}
-
-  //--
-  // Tests
-  //--
-  explicit operator bool() const { return IsValid(); }
-
-  bool IsValid() const { return m_cu && m_die; }
+#include "DWARFBasicDIE.h"
 
-  bool IsStructOrClass() const;
-
-  bool HasChildren() const;
-
-  bool Supports_DW_AT_APPLE_objc_complete_type() const;
+class DWARFDIE : public DWARFBasicDIE {
+public:
+  using DWARFBasicDIE::DWARFBasicDIE;
 
   //--
   // Accessors
   //--
-  SymbolFileDWARF *GetDWARF() const;
-
-  DWARFUnit *GetCU() const { return m_cu; }
-
-  DWARFDebugInfoEntry *GetDIE() const { return m_die; }
-
-  DIERef GetDIERef() const;
-
-  lldb_private::TypeSystem *GetTypeSystem() const;
-
-  DWARFASTParser *GetDWARFParser() const;
-
-  void Set(DWARFUnit *cu, DWARFDebugInfoEntry *die) {
-if (cu && die) {
-  m_cu = cu;
-  m_die = die;
-} else {
-  Clear();
-}
-  }
-
-  void Clear() {
-m_cu = nullptr;
-m_die = nullptr;
-  }
-
   lldb::ModuleSP GetContainingDWOModule() const;
 
   DWARFDIE
   GetContainingDWOModuleDIE() const;
 
-  //--
-  // Get the data that contains the attribute values for this DIE. Support
-  // for .debug_types means that any DIE can have its data either in the
-  // .debug_info or the .debug_types section; this method will return the
-  // correct section data.
-  //
-  // Clients must validate that this object is valid before calling this.
-  //--
-  const lldb_private::DWARFDataExtractor &GetData() const;
-
   //--
   // Accessing information about a DIE
   //--
-  dw_tag_t Tag() const;
-
-  const char *GetTagAsCString() const;
-
-  dw_offset_t GetOffset() const;
-
-  dw_offset_t GetCompileUnitRelativeOffset() const;
-
-  //--
-  // Get the LLDB user ID for this DIE. This is often just the DIE offset,
-  // but it might have a SymbolFileDWARF::GetID() in the high 32 bits if
-  // we are doing Darwin DWARF in .o file, or DWARF stand alone debug
-  // info.
-  //--
-  lldb::user_id_t GetID() const;
-
-  const char *GetName() const;
-
-  const char *GetMangledName() const;
-
-  const char *GetPubname() const;
-
-  const char *GetQualifiedName(std::string &storage) const;
-
-  lldb::LanguageType GetLanguage() const;
-
-  lldb::ModuleSP GetModule() const;
-
-  lldb_private::CompileUnit *GetLLDBCompileUnit() const;
-
   lldb_private::Type *ResolveType() const;
 
   //--
@@ -159,6 +57,7 @@
   //--
   DWARFDIE
   GetDIE(dw_offset_t die_offset) const;
+  using DWARFBasicDIE::GetDIE;
 
   DWARFDIE
   LookupDeepestBlock(lldb::addr_t file_addr) const;
@@ -182,5

[Lldb-commits] [PATCH] D47276: 2/3: Use DWARFBasicDIE as compile-time protection

2018-05-23 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil created this revision.
jankratochvil added reviewers: labath, clayborg.
Herald added subscribers: JDevlieghere, aprantl.

As suggested by Pavel Labath in https://reviews.llvm.org/D46810 
`DWARFUnit::GetUnitDIEOnly()` returning a pointer to `m_first_die` should not 
permit using methods like `GetFirstChild()`.


https://reviews.llvm.org/D47276

Files:
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -748,7 +748,7 @@
   } else {
 ModuleSP module_sp(m_obj_file->GetModule());
 if (module_sp) {
-  const DWARFDIE cu_die = dwarf_cu->GetUnitDIEOnly();
+  const DWARFDIE cu_die = dwarf_cu->DIE();
   if (cu_die) {
 FileSpec cu_file_spec{cu_die.GetName(), false};
 if (cu_file_spec) {
@@ -883,7 +883,7 @@
   assert(sc.comp_unit);
   DWARFUnit *dwarf_cu = GetDWARFCompileUnit(sc.comp_unit);
   if (dwarf_cu) {
-const DWARFDIE cu_die = dwarf_cu->GetUnitDIEOnly();
+const DWARFBasicDIE cu_die = dwarf_cu->GetUnitDIEOnly();
 
 if (cu_die) {
   FileSpec cu_comp_dir = resolveCompDir(
@@ -922,7 +922,7 @@
   UpdateExternalModuleListIfNeeded();
 
   if (sc.comp_unit) {
-const DWARFDIE die = dwarf_cu->GetUnitDIEOnly();
+const DWARFDIE die = dwarf_cu->DIE();
 
 if (die) {
   for (DWARFDIE child_die = die.GetFirstChild(); child_die;
@@ -997,7 +997,7 @@
 
   DWARFUnit *dwarf_cu = GetDWARFCompileUnit(sc.comp_unit);
   if (dwarf_cu) {
-const DWARFDIE dwarf_cu_die = dwarf_cu->GetUnitDIEOnly();
+const DWARFBasicDIE dwarf_cu_die = dwarf_cu->GetUnitDIEOnly();
 if (dwarf_cu_die) {
   const dw_offset_t cu_line_offset =
   dwarf_cu_die.GetAttributeValueAsUnsigned(DW_AT_stmt_list,
@@ -1082,7 +1082,7 @@
   if (dwarf_cu == nullptr)
 return false;
 
-  const DWARFDIE dwarf_cu_die = dwarf_cu->GetUnitDIEOnly();
+  const DWARFBasicDIE dwarf_cu_die = dwarf_cu->GetUnitDIEOnly();
   if (!dwarf_cu_die)
 return false;
 
@@ -1578,7 +1578,7 @@
   for (uint32_t cu_idx = 0; cu_idx < num_compile_units; ++cu_idx) {
 DWARFUnit *dwarf_cu = debug_info->GetCompileUnitAtIndex(cu_idx);
 
-const DWARFDIE die = dwarf_cu->GetUnitDIEOnly();
+const DWARFBasicDIE die = dwarf_cu->GetUnitDIEOnly();
 if (die && die.HasChildren() == false) {
   const char *name = die.GetAttributeValueAsString(DW_AT_name, nullptr);
 
Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.h
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -110,7 +110,7 @@
 
   void SetBaseAddress(dw_addr_t base_addr);
 
-  DWARFDIE GetUnitDIEOnly() { return DWARFDIE(this, GetUnitDIEPtrOnly()); }
+  DWARFBasicDIE GetUnitDIEOnly() { return DWARFDIE(this, GetUnitDIEPtrOnly()); }
 
   DWARFDIE DIE() { return DWARFDIE(this, DIEPtr()); }
 
Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -209,7 +209,7 @@
   if (!dwo_cu)
 return; // Can't fetch the compile unit from the dwo file.
 
-  DWARFDIE dwo_cu_die = dwo_cu->GetUnitDIEOnly();
+  DWARFBasicDIE dwo_cu_die = dwo_cu->GetUnitDIEOnly();
   if (!dwo_cu_die.IsValid())
 return; // Can't fetch the compile unit DIE from the dwo file.
 
Index: source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -638,7 +638,7 @@
 
 void DWARFDebugInfoEntry::DumpLocation(SymbolFileDWARF *dwarf2Data,
DWARFUnit *cu, Stream &s) const {
-  const DWARFDIE cu_die = cu->GetUnitDIEOnly();
+  const DWARFBasicDIE cu_die = cu->GetUnitDIEOnly();
   const char *cu_name = NULL;
   if (cu_die)
 cu_name = cu_die.GetName();
@@ -912,7 +912,7 @@
   if (!dwo_cu)
 return 0;
 
-  DWARFDIE dwo_cu_die = dwo_cu->GetUnitDIEOnly();
+  DWARFBasicDIE dwo_cu_die = dwo_cu->GetUnitDIEOnly();
   if (!dwo_cu_die.IsValid())
 return 0;
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D47275: 1/3: DWARFDIE split out to DWARFBasicDIE

2018-05-24 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil marked 5 inline comments as done.
jankratochvil added a comment.

In https://reviews.llvm.org/D47275#1110065, @clayborg wrote:

> Marked things that don't belong in DWARFBasicDIE.


OK, sorry, thanks for reviewing it.

> Also DWARFBasicDIE doesn't really explain what it actually is. Maybe we 
> should rename this DWARFUnitDIE? DWARFTopDIE? DWARFRootDIE?

I do not mind any name but if you do not like Pavel's `DWARFBasicDIE` and you 
are not sure with the name yourself I have chosen `DWARFFirstDIE`.


https://reviews.llvm.org/D47275



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


[Lldb-commits] [PATCH] D47275: 1/3: DWARFDIE split out to DWARFBasicDIE

2018-05-24 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 148360.

https://reviews.llvm.org/D47275

Files:
  source/Plugins/SymbolFile/DWARF/CMakeLists.txt
  source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDIE.h
  source/Plugins/SymbolFile/DWARF/DWARFFirstDIE.cpp
  source/Plugins/SymbolFile/DWARF/DWARFFirstDIE.h

Index: source/Plugins/SymbolFile/DWARF/DWARFFirstDIE.h
===
--- /dev/null
+++ source/Plugins/SymbolFile/DWARF/DWARFFirstDIE.h
@@ -0,0 +1,157 @@
+//===-- DWARFFirstDIE.h -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef SymbolFileDWARF_DWARFFirstDIE_h_
+#define SymbolFileDWARF_DWARFFirstDIE_h_
+
+#include "lldb/Core/dwarf.h"
+#include "lldb/lldb-types.h"
+
+struct DIERef;
+class DWARFASTParser;
+class DWARFAttributes;
+class DWARFUnit;
+class DWARFDebugInfoEntry;
+class DWARFDeclContext;
+class DWARFDIECollection;
+class SymbolFileDWARF;
+
+class DWARFFirstDIE {
+public:
+  DWARFFirstDIE() : m_cu(nullptr), m_die(nullptr) {}
+
+  DWARFFirstDIE(DWARFUnit *cu, DWARFDebugInfoEntry *die)
+  : m_cu(cu), m_die(die) {}
+
+  DWARFFirstDIE(const DWARFUnit *cu, DWARFDebugInfoEntry *die)
+  : m_cu(const_cast(cu)), m_die(die) {}
+
+  DWARFFirstDIE(DWARFUnit *cu, const DWARFDebugInfoEntry *die)
+  : m_cu(cu), m_die(const_cast(die)) {}
+
+  DWARFFirstDIE(const DWARFUnit *cu, const DWARFDebugInfoEntry *die)
+  : m_cu(const_cast(cu)),
+m_die(const_cast(die)) {}
+
+  //--
+  // Tests
+  //--
+  explicit operator bool() const { return IsValid(); }
+
+  bool IsValid() const { return m_cu && m_die; }
+
+  bool HasChildren() const;
+
+  bool Supports_DW_AT_APPLE_objc_complete_type() const;
+
+  //--
+  // Accessors
+  //--
+  SymbolFileDWARF *GetDWARF() const;
+
+  DWARFUnit *GetCU() const { return m_cu; }
+
+  DWARFDebugInfoEntry *GetDIE() const { return m_die; }
+
+  DIERef GetDIERef() const;
+
+  lldb_private::TypeSystem *GetTypeSystem() const;
+
+  DWARFASTParser *GetDWARFParser() const;
+
+  void Set(DWARFUnit *cu, DWARFDebugInfoEntry *die) {
+if (cu && die) {
+  m_cu = cu;
+  m_die = die;
+} else {
+  Clear();
+}
+  }
+
+  void Clear() {
+m_cu = nullptr;
+m_die = nullptr;
+  }
+
+  //--
+  // Get the data that contains the attribute values for this DIE. Support
+  // for .debug_types means that any DIE can have its data either in the
+  // .debug_info or the .debug_types section; this method will return the
+  // correct section data.
+  //
+  // Clients must validate that this object is valid before calling this.
+  //--
+  const lldb_private::DWARFDataExtractor &GetData() const;
+
+  //--
+  // Accessing information about a DIE
+  //--
+  dw_tag_t Tag() const;
+
+  const char *GetTagAsCString() const;
+
+  dw_offset_t GetOffset() const;
+
+  dw_offset_t GetCompileUnitRelativeOffset() const;
+
+  //--
+  // Get the LLDB user ID for this DIE. This is often just the DIE offset,
+  // but it might have a SymbolFileDWARF::GetID() in the high 32 bits if
+  // we are doing Darwin DWARF in .o file, or DWARF stand alone debug
+  // info.
+  //--
+  lldb::user_id_t GetID() const;
+
+  const char *GetName() const;
+
+  lldb::LanguageType GetLanguage() const;
+
+  lldb::ModuleSP GetModule() const;
+
+  lldb_private::CompileUnit *GetLLDBCompileUnit() const;
+
+  //--
+  // Getting attribute values from the DIE.
+  //
+  // GetAttributeValueAsXXX() functions should only be used if you are
+  // looking for one or two attributes on a DIE. If you are trying to
+  // parse all attributes, use GetAttributes (...) instead
+  //--
+  const char *GetAttributeValueAsString(const dw_attr_t attr,
+const char *fail_value) const;
+
+  uint64_t GetAttributeValueAsUnsigned(const dw_attr_t attr,
+   uint64_t fail_value) const;
+
+  int64_t GetAttri

[Lldb-commits] [PATCH] D47276: 2/3: Use DWARFBasicDIE as compile-time protection

2018-05-24 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 148362.

https://reviews.llvm.org/D47276

Files:
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -748,7 +748,7 @@
   } else {
 ModuleSP module_sp(m_obj_file->GetModule());
 if (module_sp) {
-  const DWARFDIE cu_die = dwarf_cu->GetUnitDIEOnly();
+  const DWARFDIE cu_die = dwarf_cu->DIE();
   if (cu_die) {
 FileSpec cu_file_spec{cu_die.GetName(), false};
 if (cu_file_spec) {
@@ -883,7 +883,7 @@
   assert(sc.comp_unit);
   DWARFUnit *dwarf_cu = GetDWARFCompileUnit(sc.comp_unit);
   if (dwarf_cu) {
-const DWARFDIE cu_die = dwarf_cu->GetUnitDIEOnly();
+const DWARFFirstDIE cu_die = dwarf_cu->GetUnitDIEOnly();
 
 if (cu_die) {
   FileSpec cu_comp_dir = resolveCompDir(
@@ -922,7 +922,7 @@
   UpdateExternalModuleListIfNeeded();
 
   if (sc.comp_unit) {
-const DWARFDIE die = dwarf_cu->GetUnitDIEOnly();
+const DWARFDIE die = dwarf_cu->DIE();
 
 if (die) {
   for (DWARFDIE child_die = die.GetFirstChild(); child_die;
@@ -997,7 +997,7 @@
 
   DWARFUnit *dwarf_cu = GetDWARFCompileUnit(sc.comp_unit);
   if (dwarf_cu) {
-const DWARFDIE dwarf_cu_die = dwarf_cu->GetUnitDIEOnly();
+const DWARFFirstDIE dwarf_cu_die = dwarf_cu->GetUnitDIEOnly();
 if (dwarf_cu_die) {
   const dw_offset_t cu_line_offset =
   dwarf_cu_die.GetAttributeValueAsUnsigned(DW_AT_stmt_list,
@@ -1082,7 +1082,7 @@
   if (dwarf_cu == nullptr)
 return false;
 
-  const DWARFDIE dwarf_cu_die = dwarf_cu->GetUnitDIEOnly();
+  const DWARFFirstDIE dwarf_cu_die = dwarf_cu->GetUnitDIEOnly();
   if (!dwarf_cu_die)
 return false;
 
@@ -1578,7 +1578,7 @@
   for (uint32_t cu_idx = 0; cu_idx < num_compile_units; ++cu_idx) {
 DWARFUnit *dwarf_cu = debug_info->GetCompileUnitAtIndex(cu_idx);
 
-const DWARFDIE die = dwarf_cu->GetUnitDIEOnly();
+const DWARFFirstDIE die = dwarf_cu->GetUnitDIEOnly();
 if (die && die.HasChildren() == false) {
   const char *name = die.GetAttributeValueAsString(DW_AT_name, nullptr);
 
Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.h
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -110,7 +110,7 @@
 
   void SetBaseAddress(dw_addr_t base_addr);
 
-  DWARFDIE GetUnitDIEOnly() { return DWARFDIE(this, GetUnitDIEPtrOnly()); }
+  DWARFFirstDIE GetUnitDIEOnly() { return DWARFDIE(this, GetUnitDIEPtrOnly()); }
 
   DWARFDIE DIE() { return DWARFDIE(this, DIEPtr()); }
 
Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -209,7 +209,7 @@
   if (!dwo_cu)
 return; // Can't fetch the compile unit from the dwo file.
 
-  DWARFDIE dwo_cu_die = dwo_cu->GetUnitDIEOnly();
+  DWARFFirstDIE dwo_cu_die = dwo_cu->GetUnitDIEOnly();
   if (!dwo_cu_die.IsValid())
 return; // Can't fetch the compile unit DIE from the dwo file.
 
Index: source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -638,7 +638,7 @@
 
 void DWARFDebugInfoEntry::DumpLocation(SymbolFileDWARF *dwarf2Data,
DWARFUnit *cu, Stream &s) const {
-  const DWARFDIE cu_die = cu->GetUnitDIEOnly();
+  const DWARFFirstDIE cu_die = cu->GetUnitDIEOnly();
   const char *cu_name = NULL;
   if (cu_die)
 cu_name = cu_die.GetName();
@@ -912,7 +912,7 @@
   if (!dwo_cu)
 return 0;
 
-  DWARFDIE dwo_cu_die = dwo_cu->GetUnitDIEOnly();
+  DWARFFirstDIE dwo_cu_die = dwo_cu->GetUnitDIEOnly();
   if (!dwo_cu_die.IsValid())
 return 0;
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D47275: 1/3: DWARFDIE split out to DWARFBasicDIE

2018-05-24 Thread Jan Kratochvil via Phabricator via lldb-commits
This revision was not accepted when it landed; it landed in state "Needs 
Revision".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL333222: DWARFDIE split out to DWARFBaseDIE (authored by 
jankratochvil, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D47275?vs=148360&id=148472#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47275

Files:
  lldb/trunk/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.h

Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
@@ -12,43 +12,13 @@
 #include "DWARFASTParser.h"
 #include "DWARFUnit.h"
 #include "DWARFDIECollection.h"
-#include "DWARFDebugAbbrev.h"
-#include "DWARFDebugAranges.h"
 #include "DWARFDebugInfo.h"
-#include "DWARFDebugInfoEntry.h"
-#include "DWARFDebugRanges.h"
 #include "DWARFDeclContext.h"
-#include "DWARFFormValue.h"
-#include "SymbolFileDWARF.h"
 
-#include "lldb/Core/Module.h"
-#include "lldb/Symbol/ObjectFile.h"
-#include "lldb/Symbol/Type.h"
-#include "lldb/Symbol/TypeSystem.h"
+#include "DWARFDebugInfoEntry.h"
 
 using namespace lldb_private;
 
-DIERef DWARFDIE::GetDIERef() const {
-  if (!IsValid())
-return DIERef();
-
-  dw_offset_t cu_offset = m_cu->GetOffset();
-  if (m_cu->GetBaseObjOffset() != DW_INVALID_OFFSET)
-cu_offset = m_cu->GetBaseObjOffset();
-  return DIERef(cu_offset, m_die->GetOffset());
-}
-
-dw_tag_t DWARFDIE::Tag() const {
-  if (m_die)
-return m_die->Tag();
-  else
-return 0;
-}
-
-const char *DWARFDIE::GetTagAsCString() const {
-  return lldb_private::DW_TAG_value_to_name(Tag());
-}
-
 DWARFDIE
 DWARFDIE::GetParent() const {
   if (IsValid())
@@ -91,33 +61,6 @@
 return DWARFDIE();
 }
 
-const char *DWARFDIE::GetAttributeValueAsString(const dw_attr_t attr,
-const char *fail_value) const {
-  if (IsValid())
-return m_die->GetAttributeValueAsString(GetDWARF(), GetCU(), attr,
-fail_value);
-  else
-return fail_value;
-}
-
-uint64_t DWARFDIE::GetAttributeValueAsUnsigned(const dw_attr_t attr,
-   uint64_t fail_value) const {
-  if (IsValid())
-return m_die->GetAttributeValueAsUnsigned(GetDWARF(), GetCU(), attr,
-  fail_value);
-  else
-return fail_value;
-}
-
-int64_t DWARFDIE::GetAttributeValueAsSigned(const dw_attr_t attr,
-int64_t fail_value) const {
-  if (IsValid())
-return m_die->GetAttributeValueAsSigned(GetDWARF(), GetCU(), attr,
-fail_value);
-  else
-return fail_value;
-}
-
 DWARFDIE
 DWARFDIE::GetAttributeValueAsReferenceDIE(const dw_attr_t attr) const {
   if (IsValid()) {
@@ -132,24 +75,6 @@
   return DWARFDIE();
 }
 
-uint64_t DWARFDIE::GetAttributeValueAsReference(const dw_attr_t attr,
-uint64_t fail_value) const {
-  if (IsValid())
-return m_die->GetAttributeValueAsReference(GetDWARF(), GetCU(), attr,
-   fail_value);
-  else
-return fail_value;
-}
-
-uint64_t DWARFDIE::GetAttributeValueAsAddress(const dw_attr_t attr,
-  uint64_t fail_value) const {
-  if (IsValid())
-return m_die->GetAttributeValueAsAddress(GetDWARF(), GetCU(), attr,
- fail_value);
-  else
-return fail_value;
-}
-
 DWARFDIE
 DWARFDIE::LookupDeepestBlock(lldb::addr_t file_addr) const {
   if (IsValid()) {
@@ -171,17 +96,6 @@
   return DWARFDIE();
 }
 
-lldb::user_id_t DWARFDIE::GetID() const {
-  return GetDIERef().GetUID(GetDWARF());
-}
-
-const char *DWARFDIE::GetName() const {
-  if (IsValid())
-return m_die->GetName(GetDWARF(), m_cu);
-  else
-return nullptr;
-}
-
 const char *DWARFDIE::GetMangledName() const {
   if (IsValid())
 return m_die->GetMangledName(GetDWARF(), m_cu);
@@ -203,28 +117,6 @@
 return nullptr;
 }
 
-lldb::LanguageType DWARFDIE::GetLanguage() const {
-  if (IsValid())
-return m_cu->GetLanguageType();
-  else
-return lldb::eLanguageTypeUnknown;
-}
-
-lldb::ModuleSP DWARFDIE::GetModule() const {
-  SymbolFileDWARF *dwarf = GetDWARF();
-  if (dwarf)
-return dwarf->GetObjectFile()->GetModule();
-  else
-return lldb::ModuleSP();
-}
-
-lldb_private::CompileUnit *DWARFDIE::GetLLDBCompileUnit() const {
-  if (IsValid())
-return GetDWARF()->GetCompUnitForDWARFCompUnit

[Lldb-commits] [PATCH] D47276: 2/3: Use DWARFBaseDIE as compile-time protection

2018-05-24 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 148474.
jankratochvil retitled this revision from "2/3: Use DWARFBasicDIE as 
compile-time protection" to "2/3: Use DWARFBaseDIE as compile-time protection".

https://reviews.llvm.org/D47276

Files:
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -748,7 +748,7 @@
   } else {
 ModuleSP module_sp(m_obj_file->GetModule());
 if (module_sp) {
-  const DWARFDIE cu_die = dwarf_cu->GetUnitDIEOnly();
+  const DWARFDIE cu_die = dwarf_cu->DIE();
   if (cu_die) {
 FileSpec cu_file_spec{cu_die.GetName(), false};
 if (cu_file_spec) {
@@ -883,7 +883,7 @@
   assert(sc.comp_unit);
   DWARFUnit *dwarf_cu = GetDWARFCompileUnit(sc.comp_unit);
   if (dwarf_cu) {
-const DWARFDIE cu_die = dwarf_cu->GetUnitDIEOnly();
+const DWARFBaseDIE cu_die = dwarf_cu->GetUnitDIEOnly();
 
 if (cu_die) {
   FileSpec cu_comp_dir = resolveCompDir(
@@ -922,7 +922,7 @@
   UpdateExternalModuleListIfNeeded();
 
   if (sc.comp_unit) {
-const DWARFDIE die = dwarf_cu->GetUnitDIEOnly();
+const DWARFDIE die = dwarf_cu->DIE();
 
 if (die) {
   for (DWARFDIE child_die = die.GetFirstChild(); child_die;
@@ -997,7 +997,7 @@
 
   DWARFUnit *dwarf_cu = GetDWARFCompileUnit(sc.comp_unit);
   if (dwarf_cu) {
-const DWARFDIE dwarf_cu_die = dwarf_cu->GetUnitDIEOnly();
+const DWARFBaseDIE dwarf_cu_die = dwarf_cu->GetUnitDIEOnly();
 if (dwarf_cu_die) {
   const dw_offset_t cu_line_offset =
   dwarf_cu_die.GetAttributeValueAsUnsigned(DW_AT_stmt_list,
@@ -1082,7 +1082,7 @@
   if (dwarf_cu == nullptr)
 return false;
 
-  const DWARFDIE dwarf_cu_die = dwarf_cu->GetUnitDIEOnly();
+  const DWARFBaseDIE dwarf_cu_die = dwarf_cu->GetUnitDIEOnly();
   if (!dwarf_cu_die)
 return false;
 
@@ -1578,7 +1578,7 @@
   for (uint32_t cu_idx = 0; cu_idx < num_compile_units; ++cu_idx) {
 DWARFUnit *dwarf_cu = debug_info->GetCompileUnitAtIndex(cu_idx);
 
-const DWARFDIE die = dwarf_cu->GetUnitDIEOnly();
+const DWARFBaseDIE die = dwarf_cu->GetUnitDIEOnly();
 if (die && die.HasChildren() == false) {
   const char *name = die.GetAttributeValueAsString(DW_AT_name, nullptr);
 
Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.h
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -113,7 +113,7 @@
 
   void SetBaseAddress(dw_addr_t base_addr);
 
-  DWARFDIE GetUnitDIEOnly() { return DWARFDIE(this, GetUnitDIEPtrOnly()); }
+  DWARFBaseDIE GetUnitDIEOnly() { return DWARFDIE(this, GetUnitDIEPtrOnly()); }
 
   DWARFDIE DIE() { return DWARFDIE(this, DIEPtr()); }
 
Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -207,7 +207,7 @@
   if (!dwo_cu)
 return; // Can't fetch the compile unit from the dwo file.
 
-  DWARFDIE dwo_cu_die = dwo_cu->GetUnitDIEOnly();
+  DWARFBaseDIE dwo_cu_die = dwo_cu->GetUnitDIEOnly();
   if (!dwo_cu_die.IsValid())
 return; // Can't fetch the compile unit DIE from the dwo file.
 
Index: source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -638,7 +638,7 @@
 
 void DWARFDebugInfoEntry::DumpLocation(SymbolFileDWARF *dwarf2Data,
DWARFUnit *cu, Stream &s) const {
-  const DWARFDIE cu_die = cu->GetUnitDIEOnly();
+  const DWARFBaseDIE cu_die = cu->GetUnitDIEOnly();
   const char *cu_name = NULL;
   if (cu_die)
 cu_name = cu_die.GetName();
@@ -912,7 +912,7 @@
   if (!dwo_cu)
 return 0;
 
-  DWARFDIE dwo_cu_die = dwo_cu->GetUnitDIEOnly();
+  DWARFBaseDIE dwo_cu_die = dwo_cu->GetUnitDIEOnly();
   if (!dwo_cu_die.IsValid())
 return 0;
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D47276: 2/3: Use DWARFBaseDIE as compile-time protection

2018-05-24 Thread Jan Kratochvil via Phabricator via lldb-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL333224: Use DWARFBaseDIE as a compile-time protection 
(authored by jankratochvil, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D47276?vs=148474&id=148476#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47276

Files:
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -113,7 +113,7 @@
 
   void SetBaseAddress(dw_addr_t base_addr);
 
-  DWARFDIE GetUnitDIEOnly() { return DWARFDIE(this, GetUnitDIEPtrOnly()); }
+  DWARFBaseDIE GetUnitDIEOnly() { return DWARFDIE(this, GetUnitDIEPtrOnly()); }
 
   DWARFDIE DIE() { return DWARFDIE(this, DIEPtr()); }
 
Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -638,7 +638,7 @@
 
 void DWARFDebugInfoEntry::DumpLocation(SymbolFileDWARF *dwarf2Data,
DWARFUnit *cu, Stream &s) const {
-  const DWARFDIE cu_die = cu->GetUnitDIEOnly();
+  const DWARFBaseDIE cu_die = cu->GetUnitDIEOnly();
   const char *cu_name = NULL;
   if (cu_die)
 cu_name = cu_die.GetName();
@@ -912,7 +912,7 @@
   if (!dwo_cu)
 return 0;
 
-  DWARFDIE dwo_cu_die = dwo_cu->GetUnitDIEOnly();
+  DWARFBaseDIE dwo_cu_die = dwo_cu->GetUnitDIEOnly();
   if (!dwo_cu_die.IsValid())
 return 0;
 
Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -207,7 +207,7 @@
   if (!dwo_cu)
 return; // Can't fetch the compile unit from the dwo file.
 
-  DWARFDIE dwo_cu_die = dwo_cu->GetUnitDIEOnly();
+  DWARFBaseDIE dwo_cu_die = dwo_cu->GetUnitDIEOnly();
   if (!dwo_cu_die.IsValid())
 return; // Can't fetch the compile unit DIE from the dwo file.
 
Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -748,7 +748,7 @@
   } else {
 ModuleSP module_sp(m_obj_file->GetModule());
 if (module_sp) {
-  const DWARFDIE cu_die = dwarf_cu->GetUnitDIEOnly();
+  const DWARFDIE cu_die = dwarf_cu->DIE();
   if (cu_die) {
 FileSpec cu_file_spec{cu_die.GetName(), false};
 if (cu_file_spec) {
@@ -883,7 +883,7 @@
   assert(sc.comp_unit);
   DWARFUnit *dwarf_cu = GetDWARFCompileUnit(sc.comp_unit);
   if (dwarf_cu) {
-const DWARFDIE cu_die = dwarf_cu->GetUnitDIEOnly();
+const DWARFBaseDIE cu_die = dwarf_cu->GetUnitDIEOnly();
 
 if (cu_die) {
   FileSpec cu_comp_dir = resolveCompDir(
@@ -922,7 +922,7 @@
   UpdateExternalModuleListIfNeeded();
 
   if (sc.comp_unit) {
-const DWARFDIE die = dwarf_cu->GetUnitDIEOnly();
+const DWARFDIE die = dwarf_cu->DIE();
 
 if (die) {
   for (DWARFDIE child_die = die.GetFirstChild(); child_die;
@@ -997,7 +997,7 @@
 
   DWARFUnit *dwarf_cu = GetDWARFCompileUnit(sc.comp_unit);
   if (dwarf_cu) {
-const DWARFDIE dwarf_cu_die = dwarf_cu->GetUnitDIEOnly();
+const DWARFBaseDIE dwarf_cu_die = dwarf_cu->GetUnitDIEOnly();
 if (dwarf_cu_die) {
   const dw_offset_t cu_line_offset =
   dwarf_cu_die.GetAttributeValueAsUnsigned(DW_AT_stmt_list,
@@ -1082,7 +1082,7 @@
   if (dwarf_cu == nullptr)
 return false;
 
-  const DWARFDIE dwarf_cu_die = dwarf_cu->GetUnitDIEOnly();
+  const DWARFBaseDIE dwarf_cu_die = dwarf_cu->GetUnitDIEOnly();
   if (!dwarf_cu_die)
 return false;
 
@@ -1578,7 +1578,7 @@
   for (uint32_t cu_idx = 0; cu_idx < num_compile_units; ++cu_idx) {
 DWARFUnit *dwarf_cu = debug_info->GetCompileUnitAtIndex(cu_idx);
 
-const DWARFDIE die = dwarf_cu->GetUnitDIEOnly();
+const DWARFBaseDIE die = dwarf_cu->GetUnitDIEOnly();
 if (die && die.HasChildren() == false) {
   const char *name = die.GetAttributeValueAsString(DW_AT_name, nullptr);
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/c

[Lldb-commits] [PATCH] D46810: 3/3: Fix DWARFUnit::GetUnitDIEPtrOnly stale pointer

2018-05-24 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 148480.

https://reviews.llvm.org/D46810

Files:
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
  source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFUnit.h

Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.h
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -173,6 +173,17 @@
   void *m_user_data = nullptr;
   // The compile unit debug information entry item
   DWARFDebugInfoEntry::collection m_die_array;
+  // GetUnitDIEPtrOnly() needs to return pointer to the first DIE.
+  // But the first element of m_die_array after ExtractDIEsIfNeeded(true)
+  // may move in memory after later ExtractDIEsIfNeeded(false).
+  // If nothing has been parsed, m_die_array is empty and m_first_die is empty.
+  // If CU DIE has been parsed, m_die_array is empty and m_first_die is full.
+  // if everything has been parsed m_first_die and m_die_array are full,
+  // and the first element of m_die_array contains a copy of m_first_die.
+  DWARFDebugInfoEntry m_first_die;
+  // m_die_array_size() is like m_die_array.size() but
+  // it considers also m_die_array.empty() with m_first_die.
+  size_t m_die_array_size() const;
   // A table similar to the .debug_aranges table, but this one points to the
   // exact DW_TAG_subprogram DIEs
   std::unique_ptr m_func_aranges_ap;
@@ -203,9 +214,9 @@
   // if needed.
   const DWARFDebugInfoEntry *GetUnitDIEPtrOnly() {
 ExtractDIEsIfNeeded(true);
-if (m_die_array.empty())
+if (!m_first_die)
   return NULL;
-return &m_die_array[0];
+return &m_first_die;
   }
 
   // Get all DWARF debug informration entries. Parse all DIEs if needed.
Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -40,7 +40,7 @@
 // Parses a compile unit and indexes its DIEs if it hasn't already been done.
 //--
 size_t DWARFUnit::ExtractDIEsIfNeeded(bool cu_die_only) {
-  const size_t initial_die_array_size = m_die_array.size();
+  const size_t initial_die_array_size = m_die_array_size();
   if ((cu_die_only && initial_die_array_size > 0) || initial_die_array_size > 1)
 return 0; // Already parsed
 
@@ -92,6 +92,22 @@
 if (depth == 0) {
   if (initial_die_array_size == 0)
 AddUnitDIE(die);
+
+  if (!cu_die_only) {
+assert(m_die_array.empty() && "Compile unit DIE already added");
+
+// The average bytes per DIE entry has been seen to be around 14-20 so
+// lets pre-reserve half of that since we are now stripping the NULL
+// tags.
+
+// Only reserve the memory if we are adding children of the main
+// compile unit DIE. The compile unit DIE is always the first entry, so
+// if our size is 1, then we are adding the first compile unit child
+// DIE and should reserve the memory.
+m_die_array.reserve(GetDebugInfoSize() / 24);
+m_die_array.push_back(die);
+  }
+
   uint64_t base_addr = die.GetAttributeValueAsAddress(
   m_dwarf, this, DW_AT_low_pc, LLDB_INVALID_ADDRESS);
   if (base_addr == LLDB_INVALID_ADDRESS)
@@ -101,14 +117,17 @@
   if (cu_die_only)
 return 1;
 } else {
+  assert(!cu_die_only);
   if (null_die) {
 if (prev_die_had_children) {
   // This will only happen if a DIE says is has children but all it
   // contains is a NULL tag. Since we are removing the NULL DIEs from
   // the list (saves up to 25% in C++ code), we need a way to let the
   // DIE know that it actually doesn't have children.
-  if (!m_die_array.empty())
+  if (!m_die_array.empty()) {
 m_die_array.back().SetEmptyChildren(true);
+m_first_die.SetEmptyChildren(true);
+  }
 }
   } else {
 die.SetParentIndex(m_die_array.size() - die_index_stack[depth - 1]);
@@ -134,7 +153,7 @@
 
   prev_die_had_children = false;
 } else {
-  die_index_stack.back() = m_die_array.size() - 1;
+  die_index_stack.back() = m_die_array_size() - 1;
   // Normal DIE
   const bool die_has_children = die.HasChildren();
   if (die_has_children) {
@@ -168,36 +187,38 @@
   if (log && log->GetVerbose()) {
 StreamString strm;
 Dump(&strm);
-if (m_die_array.empty())
+if (!m_first_die)
   strm.Printf("error: no DIE for compile unit");
 else
-  m_die_array[0].Dump(m_dwarf, this, strm, UINT32_MAX);
+  m_first_die.Dump(m_dwarf, this, strm, UINT32_MAX);
 log->PutString(strm.GetString());
   }
 
+  assert(m_die_array.empty() || !cu_die_only);
+  assert(m_die_arr

[Lldb-commits] [PATCH] D46810: 3/3: Fix DWARFUnit::GetUnitDIEPtrOnly stale pointer

2018-05-24 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

In https://reviews.llvm.org/D46810#1098110, @clayborg wrote:

> So this problem exists both in the LLDB and LLVM DWARF parsers. I am not sure 
> this fix is safe. I would rather fix this by fixing DWARFDIE class to "do the 
> right thing". We should be able to teach the DWARFDIE class to replace its 
> "m_die" with the updated "m_die" if a method ever causes DWARFDIE to need to 
> expand all DIEs in a DWARFUnit. That seems like a much safer fix. Having 
> m_first_die is not safe because it if you call DWARFDIE::GetFirstChild() it 
> will just add 1 to the "m_die" and we will crash. All parent, sibling and 
> child code just do pointer arithmetic to find their counterparts. So since 
> DWARFDIE has the "DWARFUnit *m_cu;" and "DWARFDebugInfoEntry *m_die;" we 
> should use DWARFDIE to abstract this from users. Anyone playing directly with 
> DWARFDebugInfoEntry must know the rules and do the right thing or just use 
> DWARFDIE.


Is this statement still valid now with `DWARFBaseDIE`?


https://reviews.llvm.org/D46810



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


[Lldb-commits] [PATCH] D46810: 3/3: Fix DWARFUnit::GetUnitDIEPtrOnly stale pointer

2018-05-25 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added inline comments.



Comment at: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp:312
 
 void DWARFUnit::ClearDIEs(bool keep_compile_unit_die) {
+  m_die_array.clear();

labath wrote:
> You are ignoring the keep_compile_unit_die argument here. Is that 
> intentional? (I would be fine with not being able to clear the unit die, but 
> if we got that way, then we should remove this argument altogether.)
I did not notice, true. But there is no caller of `ClearDIEs(false)` anyway. 
And with `m_first_die` it has even no longer any benefit to clear even the 
first DIE.


https://reviews.llvm.org/D46810



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


[Lldb-commits] [PATCH] D46810: 3/3: Fix DWARFUnit::GetUnitDIEPtrOnly stale pointer

2018-05-28 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 148801.
jankratochvil added a comment.

Split out `ExtractUnitDIEIfNeeded()` out of `ExtractDIEsIfNeeded()`.


https://reviews.llvm.org/D46810

Files:
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
  source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp

Index: source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
===
--- source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -50,9 +50,9 @@
   auto extract_fn = [&debug_info, &clear_cu_dies](size_t cu_idx) {
 DWARFUnit *dwarf_cu = debug_info.GetCompileUnitAtIndex(cu_idx);
 if (dwarf_cu) {
-  // dwarf_cu->ExtractDIEsIfNeeded(false) will return zero if the DIEs
+  // dwarf_cu->ExtractDIEsIfNeeded() will return false if the DIEs
   // for a compile unit have already been parsed.
-  if (dwarf_cu->ExtractDIEsIfNeeded(false) > 1)
+  if (dwarf_cu->ExtractDIEsIfNeeded())
 clear_cu_dies[cu_idx] = true;
 }
   };
Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.h
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -39,7 +39,8 @@
 public:
   virtual ~DWARFUnit();
 
-  size_t ExtractDIEsIfNeeded(bool cu_die_only);
+  void ExtractUnitDIEIfNeeded();
+  bool ExtractDIEsIfNeeded();
   DWARFDIE LookupAddress(const dw_addr_t address);
   size_t AppendDIEsWithTag(const dw_tag_t tag,
DWARFDIECollection &matching_dies,
@@ -160,7 +161,7 @@
   dw_offset_t GetBaseObjOffset() const;
 
   die_iterator_range dies() {
-ExtractDIEsIfNeeded(false);
+ExtractDIEsIfNeeded();
 return die_iterator_range(m_die_array.begin(), m_die_array.end());
   }
 
@@ -173,6 +174,10 @@
   void *m_user_data = nullptr;
   // The compile unit debug information entry item
   DWARFDebugInfoEntry::collection m_die_array;
+  // GetUnitDIEPtrOnly() needs to return pointer to the first DIE.
+  // But the first element of m_die_array after ExtractUnitDIEIfNeeded()
+  // would possibly move in memory after later ExtractDIEsIfNeeded().
+  DWARFDebugInfoEntry m_first_die;
   // A table similar to the .debug_aranges table, but this one points to the
   // exact DW_TAG_subprogram DIEs
   std::unique_ptr m_func_aranges_ap;
@@ -202,21 +207,22 @@
   // Get the DWARF unit DWARF debug informration entry. Parse the single DIE
   // if needed.
   const DWARFDebugInfoEntry *GetUnitDIEPtrOnly() {
-ExtractDIEsIfNeeded(true);
-if (m_die_array.empty())
+ExtractUnitDIEIfNeeded();
+if (!m_first_die)
   return NULL;
-return &m_die_array[0];
+return &m_first_die;
   }
 
   // Get all DWARF debug informration entries. Parse all DIEs if needed.
   const DWARFDebugInfoEntry *DIEPtr() {
-ExtractDIEsIfNeeded(false);
+ExtractDIEsIfNeeded();
 if (m_die_array.empty())
   return NULL;
 return &m_die_array[0];
   }
 
-  void AddUnitDIE(DWARFDebugInfoEntry &die);
+  void AddUnitDIE(const DWARFDebugInfoEntry &cu_die);
+  void ExtractDIEsEndCheck(lldb::offset_t offset) const;
 
   DISALLOW_COPY_AND_ASSIGN(DWARFUnit);
 };
Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -14,6 +14,7 @@
 #include "lldb/Symbol/CompileUnit.h"
 #include "lldb/Symbol/LineTable.h"
 #include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Utility/LLDBAssert.h"
 #include "lldb/Utility/StreamString.h"
 #include "lldb/Utility/Timer.h"
 
@@ -35,28 +36,54 @@
 DWARFUnit::~DWARFUnit() {}
 
 //--
-// ParseCompileUnitDIEsIfNeeded
-//
+// Parses first DIE of a compile unit.
+//--
+void DWARFUnit::ExtractUnitDIEIfNeeded() {
+  if (m_first_die)
+return; // Already parsed
+
+  static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
+  Timer scoped_timer(
+  func_cat, "%8.8x: DWARFUnit::ExtractUnitDIEIfNeeded()", m_offset);
+
+  // Set the offset to that of the first DIE and calculate the start of the
+  // next compilation unit header.
+  lldb::offset_t offset = GetFirstDIEOffset();
+
+  // We are in our compile unit, parse starting at the offset we were told to
+  // parse
+  const DWARFDataExtractor &data = GetData();
+  DWARFFormValue::FixedFormSizes fixed_form_sizes =
+  DWARFFormValue::GetFixedFormSizesForAddressSize(GetAddressByteSize(),
+  IsDWARF64());
+  if (offset < GetNextCompileUnitOffset() &&
+  m_first_die.FastExtract(data, this, fixed_form_sizes, &off

[Lldb-commits] [PATCH] D46810: 3/3: Fix DWARFUnit::GetUnitDIEPtrOnly stale pointer

2018-05-29 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil marked an inline comment as done.
jankratochvil added inline comments.



Comment at: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp:86
   // Keep a flat array of the DIE for binary lookup by DIE offset
-  if (!cu_die_only) {
+  {
 Log *log(

clayborg wrote:
> Do we need this empty scope? Remove?
There is now enclosed:
```Log *log(LogChannelDWARF::GetLogIfAny(DWARF_LOG_DEBUG_INFO | 
DWARF_LOG_LOOKUPS));
```
While lower (currently moved into `DWARFUnit::ExtractDIEsEndCheck()`) there was:
```Log *log(LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO));
```
So those two did conflict while being a different variable. I am not sure which 
way is right but I have removed the empty scope as it is no longer required. 
Then also I am not sure the log in `DWARFUnit::ExtractDIEsEndCheck()` should 
not also have `| DWARF_LOG_LOOKUPS` but that would be out of the scope of this 
patch topic.



https://reviews.llvm.org/D46810



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


[Lldb-commits] [PATCH] D46810: 3/3: Fix DWARFUnit::GetUnitDIEPtrOnly stale pointer

2018-05-29 Thread Jan Kratochvil via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
jankratochvil marked an inline comment as done.
Closed by commit rL333437: Fix DWARFUnit::GetUnitDIEPtrOnly stale pointer 
(authored by jankratochvil, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D46810?vs=148801&id=148938#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46810

Files:
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  lldb/trunk/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp

Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -39,7 +39,8 @@
 public:
   virtual ~DWARFUnit();
 
-  size_t ExtractDIEsIfNeeded(bool cu_die_only);
+  void ExtractUnitDIEIfNeeded();
+  bool ExtractDIEsIfNeeded();
   DWARFDIE LookupAddress(const dw_addr_t address);
   size_t AppendDIEsWithTag(const dw_tag_t tag,
DWARFDIECollection &matching_dies,
@@ -160,7 +161,7 @@
   dw_offset_t GetBaseObjOffset() const;
 
   die_iterator_range dies() {
-ExtractDIEsIfNeeded(false);
+ExtractDIEsIfNeeded();
 return die_iterator_range(m_die_array.begin(), m_die_array.end());
   }
 
@@ -173,6 +174,10 @@
   void *m_user_data = nullptr;
   // The compile unit debug information entry item
   DWARFDebugInfoEntry::collection m_die_array;
+  // GetUnitDIEPtrOnly() needs to return pointer to the first DIE.
+  // But the first element of m_die_array after ExtractUnitDIEIfNeeded()
+  // would possibly move in memory after later ExtractDIEsIfNeeded().
+  DWARFDebugInfoEntry m_first_die;
   // A table similar to the .debug_aranges table, but this one points to the
   // exact DW_TAG_subprogram DIEs
   std::unique_ptr m_func_aranges_ap;
@@ -202,21 +207,22 @@
   // Get the DWARF unit DWARF debug informration entry. Parse the single DIE
   // if needed.
   const DWARFDebugInfoEntry *GetUnitDIEPtrOnly() {
-ExtractDIEsIfNeeded(true);
-if (m_die_array.empty())
+ExtractUnitDIEIfNeeded();
+if (!m_first_die)
   return NULL;
-return &m_die_array[0];
+return &m_first_die;
   }
 
   // Get all DWARF debug informration entries. Parse all DIEs if needed.
   const DWARFDebugInfoEntry *DIEPtr() {
-ExtractDIEsIfNeeded(false);
+ExtractDIEsIfNeeded();
 if (m_die_array.empty())
   return NULL;
 return &m_die_array[0];
   }
 
-  void AddUnitDIE(DWARFDebugInfoEntry &die);
+  void AddUnitDIE(const DWARFDebugInfoEntry &cu_die);
+  void ExtractDIEsEndCheck(lldb::offset_t offset) const;
 
   DISALLOW_COPY_AND_ASSIGN(DWARFUnit);
 };
Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -1825,3 +1825,15 @@
 die_ref.HasChildren() ? " *" : "");
   }
 }
+
+bool DWARFDebugInfoEntry::operator==(const DWARFDebugInfoEntry &rhs) const {
+  return m_offset == rhs.m_offset && m_parent_idx == rhs.m_parent_idx &&
+ m_sibling_idx == rhs.m_sibling_idx &&
+ m_empty_children == rhs.m_empty_children &&
+ m_abbr_idx == rhs.m_abbr_idx && m_has_children == rhs.m_has_children &&
+ m_tag == rhs.m_tag;
+}
+
+bool DWARFDebugInfoEntry::operator!=(const DWARFDebugInfoEntry &rhs) const {
+  return !(*this == rhs);
+}
Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
@@ -60,6 +60,10 @@
 m_empty_children(false), m_abbr_idx(0), m_has_children(false),
 m_tag(0) {}
 
+  explicit operator bool() const { return m_offset != DW_INVALID_OFFSET; }
+  bool operator==(const DWARFDebugInfoEntry &rhs) const;
+  bool operator!=(const DWARFDebugInfoEntry &rhs) const;
+
   void BuildAddressRangeTable(SymbolFileDWARF *dwarf2Data,
   const DWARFUnit *cu,
   DWARFDebugAranges *debug_aranges) const;
Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -14,6 +14,7 @@
 #include "lldb/Symbol/CompileUnit.h"
 #include "lldb/Symbol/LineTable.h"
 #include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Utility/LLDBAssert.h"
 #include 

[Lldb-commits] [PATCH] D46810: 3/3: Fix DWARFUnit::GetUnitDIEPtrOnly stale pointer

2018-05-29 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil marked an inline comment as done.
jankratochvil added inline comments.



Comment at: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp:208
+void DWARFUnit::ExtractDIEsEndCheck(lldb::offset_t offset) const {
+  lldb::offset_t next_cu_offset = GetNextCompileUnitOffset();
+

xiaobai wrote:
> This function introduces a warning because `next_cu_offset` is never used 
> within this function. Did you intend to use it in the if conditional below? 
> It looks like you call `GetNextCompileUnitOffset` there instead of using 
> `next_cu_offset`.
Fixed now in rL333449, sorry. Yes, you are right, it remained there from 
refactorizations.

GDB is using `-Werror` so I was not used to watch for compiler warnings.



Repository:
  rL LLVM

https://reviews.llvm.org/D46810



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


[Lldb-commits] [PATCH] D47492: DWARFUnit::m_die_array swap()->shrink_to_fit()

2018-05-29 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil created this revision.
jankratochvil added a reviewer: clayborg.
Herald added a subscriber: JDevlieghere.

https://reviews.llvm.org/rL145086 introduced `m_die_array.shrink_to_fit()` 
implemented by `exact_size_die_array.swap`, it was before LLVM became written 
in C++11.

That is fine to use `shrink_to_fit()` now, right? Although I see no real 
performance gain by a simple `time` test.


https://reviews.llvm.org/D47492

Files:
  source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp


Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -180,15 +180,7 @@
 m_first_die = m_die_array.front();
   }
 
-  // Since std::vector objects will double their size, we really need to make a
-  // new array with the perfect size so we don't end up wasting space. So here
-  // we copy and swap to make sure we don't have any extra memory taken up.
-
-  if (m_die_array.size() < m_die_array.capacity()) {
-DWARFDebugInfoEntry::collection exact_size_die_array(m_die_array.begin(),
- m_die_array.end());
-exact_size_die_array.swap(m_die_array);
-  }
+  m_die_array.shrink_to_fit();
 
   ExtractDIEsEndCheck(offset);
 


Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -180,15 +180,7 @@
 m_first_die = m_die_array.front();
   }
 
-  // Since std::vector objects will double their size, we really need to make a
-  // new array with the perfect size so we don't end up wasting space. So here
-  // we copy and swap to make sure we don't have any extra memory taken up.
-
-  if (m_die_array.size() < m_die_array.capacity()) {
-DWARFDebugInfoEntry::collection exact_size_die_array(m_die_array.begin(),
- m_die_array.end());
-exact_size_die_array.swap(m_die_array);
-  }
+  m_die_array.shrink_to_fit();
 
   ExtractDIEsEndCheck(offset);
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D40470: Protect DWARFCompileUnit::m_die_array by a new mutex

2018-05-29 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 149037.
jankratochvil edited the summary of this revision.

https://reviews.llvm.org/D40470

Files:
  source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFUnit.h

Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.h
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -13,6 +13,7 @@
 #include "DWARFDIE.h"
 #include "DWARFDebugInfoEntry.h"
 #include "lldb/lldb-enumerations.h"
+#include "llvm/Support/RWMutex.h"
 
 class DWARFUnit;
 class DWARFCompileUnit;
@@ -172,10 +173,17 @@
   void *m_user_data = nullptr;
   // The compile unit debug information entry item
   DWARFDebugInfoEntry::collection m_die_array;
+  mutable llvm::sys::RWMutex m_die_array_mutex;
+  // It gets increased by ExtractDIEsIfNeeded() and decreased by ClearDIEs().
+  // BuildAddressRangeTable and SymbolFileDWARF::Index can populate m_die_array
+  // only temporarily while other functions calling only
+  // ExtractDIEsIfNeeded() will keep m_die_array populated forever.
+  uint32_t m_die_array_usecount = 0;
   // GetUnitDIEPtrOnly() needs to return pointer to the first DIE.
   // But the first element of m_die_array after ExtractUnitDIEIfNeeded()
   // would possibly move in memory after later ExtractDIEsIfNeeded().
   DWARFDebugInfoEntry m_first_die;
+  llvm::sys::RWMutex m_first_die_mutex;
   // A table similar to the .debug_aranges table, but this one points to the
   // exact DW_TAG_subprogram DIEs
   std::unique_ptr m_func_aranges_ap;
@@ -206,14 +214,17 @@
   // if needed.
   const DWARFDebugInfoEntry *GetUnitDIEPtrOnly() {
 ExtractUnitDIEIfNeeded();
+// m_first_die_mutex is not required as m_first_die is never cleared.
 if (!m_first_die)
   return NULL;
 return &m_first_die;
   }
 
   // Get all DWARF debug informration entries. Parse all DIEs if needed.
   const DWARFDebugInfoEntry *DIEPtr() {
 ExtractDIEsIfNeeded();
+// m_die_array_mutex is not required as ExtractDIEsIfNeeded() has not
+// been matched by ClearDIEs().
 if (m_die_array.empty())
   return NULL;
 return &m_die_array[0];
Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -39,6 +39,12 @@
 // Parses first DIE of a compile unit.
 //--
 void DWARFUnit::ExtractUnitDIEIfNeeded() {
+  {
+llvm::sys::ScopedReader lock(m_first_die_mutex);
+if (m_first_die)
+  return; // Already parsed
+  }
+  llvm::sys::ScopedWriter lock(m_first_die_mutex);
   if (m_first_die)
 return; // Already parsed
 
@@ -69,8 +75,19 @@
 // Parses a compile unit and indexes its DIEs if it hasn't already been done.
 //--
 bool DWARFUnit::ExtractDIEsIfNeeded() {
+  {
+llvm::sys::ScopedReader lock(m_die_array_mutex);
+if (!m_die_array.empty())
+  return 0; // Already parsed
+  }
+  llvm::sys::ScopedWriter lock(m_die_array_mutex);
   if (!m_die_array.empty())
 return 0; // Already parsed
+  // Protect against use count overflow.
+  if (m_die_array_usecount
+  < std::numeric_limits::max())
+++m_die_array_usecount;
+  llvm::sys::ScopedWriter first_die_lock(m_first_die_mutex);
 
   static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
   Timer scoped_timer(
@@ -227,6 +244,7 @@
   }
 }
 
+// m_die_array_mutex must be already held as read/write.
 void DWARFUnit::AddUnitDIE(const DWARFDebugInfoEntry &cu_die) {
   uint64_t base_addr = cu_die.GetAttributeValueAsAddress(
   m_dwarf, this, DW_AT_low_pc, LLDB_INVALID_ADDRESS);
@@ -280,11 +298,14 @@
 DWARFDIECollection &dies,
 uint32_t depth) const {
   size_t old_size = dies.Size();
-  DWARFDebugInfoEntry::const_iterator pos;
-  DWARFDebugInfoEntry::const_iterator end = m_die_array.end();
-  for (pos = m_die_array.begin(); pos != end; ++pos) {
-if (pos->Tag() == tag)
-  dies.Append(DWARFDIE(this, &(*pos)));
+  {
+llvm::sys::ScopedReader lock(m_die_array_mutex);
+DWARFDebugInfoEntry::const_iterator pos;
+DWARFDebugInfoEntry::const_iterator end = m_die_array.end();
+for (pos = m_die_array.begin(); pos != end; ++pos) {
+  if (pos->Tag() == tag)
+dies.Append(DWARFDIE(this, &(*pos)));
+}
   }
 
   // Return the number of DIEs added to the collection
@@ -325,9 +346,18 @@
   m_base_obj_offset = base_obj_offset;
 }
 
+// It may be called only after: ExtractDIEsIfNeeded() == true
 void DWARFUnit::ClearDIEs() {
-  m_die_array.clear();
-  m_die_array.shrink_to_fit();
+  {
+llvm::sys::ScopedWriter lock(m_die_array_mutex);
+lldbassert(!m_die_array.empty());
+lldbassert(m_die_array_usecount > 0);
+if (--m_die_array_usecount > 0)
+  return;

[Lldb-commits] [PATCH] D46810: 3/3: Fix DWARFUnit::GetUnitDIEPtrOnly stale pointer

2018-05-30 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil marked an inline comment as done.
jankratochvil added a comment.

FYI I also checked in a regression (just looking at the source code) 
https://reviews.llvm.org/rL333517.


Repository:
  rL LLVM

https://reviews.llvm.org/D46810



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


[Lldb-commits] [PATCH] D47492: DWARFUnit::m_die_array swap()->shrink_to_fit()

2018-05-31 Thread Jan Kratochvil via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL333636: Simplify DWARFUnit::m_die_array swap() to use 
shrink_to_fit() (authored by jankratochvil, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D47492?vs=148964&id=149250#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47492

Files:
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp


Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -180,15 +180,7 @@
 m_first_die = m_die_array.front();
   }
 
-  // Since std::vector objects will double their size, we really need to make a
-  // new array with the perfect size so we don't end up wasting space. So here
-  // we copy and swap to make sure we don't have any extra memory taken up.
-
-  if (m_die_array.size() < m_die_array.capacity()) {
-DWARFDebugInfoEntry::collection exact_size_die_array(m_die_array.begin(),
- m_die_array.end());
-exact_size_die_array.swap(m_die_array);
-  }
+  m_die_array.shrink_to_fit();
 
   ExtractDIEsEndCheck(offset);
 


Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -180,15 +180,7 @@
 m_first_die = m_die_array.front();
   }
 
-  // Since std::vector objects will double their size, we really need to make a
-  // new array with the perfect size so we don't end up wasting space. So here
-  // we copy and swap to make sure we don't have any extra memory taken up.
-
-  if (m_die_array.size() < m_die_array.capacity()) {
-DWARFDebugInfoEntry::collection exact_size_die_array(m_die_array.begin(),
- m_die_array.end());
-exact_size_die_array.swap(m_die_array);
-  }
+  m_die_array.shrink_to_fit();
 
   ExtractDIEsEndCheck(offset);
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D47492: DWARFUnit::m_die_array swap()->shrink_to_fit()

2018-05-31 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

In https://reviews.llvm.org/D47492#1117350, @labath wrote:

> it is implemented (in libstdc++ at least) using the swap trick too.


Thanks for the heads up, I expected it does `realloc()`: implementation 
absolutely cannot rely on realloc ... because realloc, if it cannot shrink 
in-place, will either leave the memory alone (no-op case) or make a bitwise 
copy (and miss the opportunity for readjusting pointers, etc. that the proper 
C++ copying/moving constructors would give) 



Repository:
  rL LLVM

https://reviews.llvm.org/D47492



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


[Lldb-commits] [PATCH] D47492: DWARFUnit::m_die_array swap()->shrink_to_fit()

2018-05-31 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

If it is trivially copyable then IMO libstdc++ could use even that realloc() 
(that is for a shrink without any copy).


Repository:
  rL LLVM

https://reviews.llvm.org/D47492



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


[Lldb-commits] [PATCH] D40470: Protect DWARFCompileUnit::m_die_array by a new mutex

2018-05-31 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil marked an inline comment as done.
jankratochvil added inline comments.



Comment at: source/Plugins/SymbolFile/DWARF/DWARFUnit.h:181
+  // ExtractDIEsIfNeeded() will keep m_die_array populated forever.
+  uint32_t m_die_array_usecount = 0;
   // GetUnitDIEPtrOnly() needs to return pointer to the first DIE.

clayborg wrote:
> Why don't we expose the llvm::sys::RWMutex for BuildAddressRangeTable and 
> SymbolFileDWARF::Index? Then they can just grab the read lock?
Wouldn't you prefer an RAII lock (`DWARFUnit::ScopedExtractDIEs`) instead of 
the mutex exposure?

There are two mutexes (`m_die_array_mutex` and `m_die_array_scoped_mutex`), I 
tried it using a single mutex (as you IMO suggest) but then one needs to 
downgrade exclusive->shared lock there which requires a `retry` label there so 
I did not like the single lock ([[ 
https://people.redhat.com/jkratoch/mutex2.patch | mutex2.patch ]]).



https://reviews.llvm.org/D40470



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


[Lldb-commits] [PATCH] D40470: Protect DWARFCompileUnit::m_die_array by a new mutex

2018-05-31 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 149255.
jankratochvil marked an inline comment as done.
jankratochvil added a comment.

RAII lock `DWARFUnit::ScopedExtractDIEs` with mutexes `m_die_array_mutex`, 
`m_die_array_scoped_mutex` and `m_first_die_mutex`.


https://reviews.llvm.org/D40470

Files:
  source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp

Index: source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
===
--- source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -38,23 +38,22 @@
 
   std::vector sets(num_compile_units);
 
-  // std::vector might be implemented using bit test-and-set, so use
-  // uint8_t instead.
-  std::vector clear_cu_dies(num_compile_units, false);
+  //--
+  // Keep memory down by clearing DIEs for any compile units if indexing
+  // caused us to load the compile unit's DIEs.
+  //--
+  std::vector>
+  clear_cu_dies(num_compile_units);
   auto parser_fn = [&](size_t cu_idx) {
 DWARFUnit *dwarf_cu = debug_info.GetCompileUnitAtIndex(cu_idx);
 if (dwarf_cu)
   IndexUnit(*dwarf_cu, sets[cu_idx]);
   };
 
   auto extract_fn = [&debug_info, &clear_cu_dies](size_t cu_idx) {
 DWARFUnit *dwarf_cu = debug_info.GetCompileUnitAtIndex(cu_idx);
-if (dwarf_cu) {
-  // dwarf_cu->ExtractDIEsIfNeeded() will return false if the DIEs
-  // for a compile unit have already been parsed.
-  if (dwarf_cu->ExtractDIEsIfNeeded())
-clear_cu_dies[cu_idx] = true;
-}
+if (dwarf_cu)
+  clear_cu_dies[cu_idx] = dwarf_cu->ExtractDIEsScoped();
   };
 
   // Create a task runner that extracts dies for each DWARF compile unit in a
@@ -89,15 +88,6 @@
  [&]() { finalize_fn(&IndexSet::globals); },
  [&]() { finalize_fn(&IndexSet::types); },
  [&]() { finalize_fn(&IndexSet::namespaces); });
-
-  //--
-  // Keep memory down by clearing DIEs for any compile units if indexing
-  // caused us to load the compile unit's DIEs.
-  //--
-  for (uint32_t cu_idx = 0; cu_idx < num_compile_units; ++cu_idx) {
-if (clear_cu_dies[cu_idx])
-  debug_info.GetCompileUnitAtIndex(cu_idx)->ClearDIEs();
-  }
 }
 
 void ManualDWARFIndex::IndexUnit(DWARFUnit &unit, IndexSet &set) {
Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.h
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -13,6 +13,7 @@
 #include "DWARFDIE.h"
 #include "DWARFDebugInfoEntry.h"
 #include "lldb/lldb-enumerations.h"
+#include "llvm/Support/RWMutex.h"
 
 class DWARFUnit;
 class DWARFCompileUnit;
@@ -40,7 +41,20 @@
   virtual ~DWARFUnit();
 
   void ExtractUnitDIEIfNeeded();
-  bool ExtractDIEsIfNeeded();
+  void ExtractDIEsIfNeeded();
+
+  class ScopedExtractDIEs {
+DWARFUnit *m_cu;
+  public:
+bool m_clear_dies = false;
+ScopedExtractDIEs(DWARFUnit *cu);
+~ScopedExtractDIEs();
+DISALLOW_COPY_AND_ASSIGN(ScopedExtractDIEs);
+ScopedExtractDIEs(ScopedExtractDIEs &&rhs);
+ScopedExtractDIEs &operator=(ScopedExtractDIEs &&rhs);
+  };
+  ScopedExtractDIEs ExtractDIEsScoped();
+
   DWARFDIE LookupAddress(const dw_addr_t address);
   size_t AppendDIEsWithTag(const dw_tag_t tag,
DWARFDIECollection &matching_dies,
@@ -100,7 +114,6 @@
   dw_addr_t GetRangesBase() const { return m_ranges_base; }
   void SetAddrBase(dw_addr_t addr_base, dw_addr_t ranges_base,
dw_offset_t base_obj_offset);
-  void ClearDIEs();
   void BuildAddressRangeTable(SymbolFileDWARF *dwarf,
   DWARFDebugAranges *debug_aranges);
 
@@ -172,10 +185,17 @@
   void *m_user_data = nullptr;
   // The compile unit debug information entry item
   DWARFDebugInfoEntry::collection m_die_array;
+  mutable llvm::sys::RWMutex m_die_array_mutex;
+  // It is used for tracking of ScopedExtractDIEs instances.
+  mutable llvm::sys::RWMutex m_die_array_scoped_mutex;
+  // ScopedExtractDIEs instances should not call ClearDIEsRWLocked()
+  // as someone called ExtractDIEsIfNeeded().
+  std::atomic m_cancel_scopes;
   // GetUnitDIEPtrOnly() needs to return pointer to the first DIE.
   // But the first element of m_die_array after ExtractUnitDIEIfNeeded()
   // would possibly move in memory after later ExtractDIEsIfNeeded().
   DWARFDebugInfoEntry m_first_die;
+  llvm::sys::RWMutex m_first_die_mutex;
   // A table similar to the .debug_aranges table, but this one points to the
   // exact DW_TAG_subprogram DIEs
   st

[Lldb-commits] [PATCH] D47625: [cmake] Detect presence of wide-char libedit at build time

2018-06-01 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil accepted this revision.
jankratochvil added a comment.
This revision is now accepted and ready to land.

No regressions on Fedora 28 x86_64.  It does set there now 
`LLDB_EDITLINE_USE_WCHAR` although one still cannot enter unicode characters to 
`(lldb)` line.


https://reviews.llvm.org/D47625



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


[Lldb-commits] [PATCH] D40470: Protect DWARFCompileUnit::m_die_array by a new mutex

2018-06-02 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 149609.
jankratochvil added a comment.

Provided variants with a new RAII lock guard vs. unchanged caller `bool 
clear_dies` variable. And also 1 vs. 2 mutexes for `m_die_array`. Please choose 
one, I do not mind any.

- mutexes2raii.patch  - 
RAII lock guard, 2 mutexes - preferred by me, posted here
- mutexes2var.patch  - 
caller variable, 2 mutexes
- mutexes1raii.patch  - 
RAII lock guard, 1 mutex (lock retrying)
- mutexes1var.patch  - 
caller variable, 1 mutex (lock retrying)  - IMO this was suggested by you


https://reviews.llvm.org/D40470

Files:
  source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp

Index: source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
===
--- source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -38,23 +38,22 @@
 
   std::vector sets(num_compile_units);
 
-  // std::vector might be implemented using bit test-and-set, so use
-  // uint8_t instead.
-  std::vector clear_cu_dies(num_compile_units, false);
+  //--
+  // Keep memory down by clearing DIEs for any compile units if indexing
+  // caused us to load the compile unit's DIEs.
+  //--
+  std::vector>
+  clear_cu_dies(num_compile_units);
   auto parser_fn = [&](size_t cu_idx) {
 DWARFUnit *dwarf_cu = debug_info.GetCompileUnitAtIndex(cu_idx);
 if (dwarf_cu)
   IndexUnit(*dwarf_cu, sets[cu_idx]);
   };
 
   auto extract_fn = [&debug_info, &clear_cu_dies](size_t cu_idx) {
 DWARFUnit *dwarf_cu = debug_info.GetCompileUnitAtIndex(cu_idx);
-if (dwarf_cu) {
-  // dwarf_cu->ExtractDIEsIfNeeded() will return false if the DIEs
-  // for a compile unit have already been parsed.
-  if (dwarf_cu->ExtractDIEsIfNeeded())
-clear_cu_dies[cu_idx] = true;
-}
+if (dwarf_cu)
+  clear_cu_dies[cu_idx] = dwarf_cu->ExtractDIEsScoped();
   };
 
   // Create a task runner that extracts dies for each DWARF compile unit in a
@@ -89,15 +88,6 @@
  [&]() { finalize_fn(&IndexSet::globals); },
  [&]() { finalize_fn(&IndexSet::types); },
  [&]() { finalize_fn(&IndexSet::namespaces); });
-
-  //--
-  // Keep memory down by clearing DIEs for any compile units if indexing
-  // caused us to load the compile unit's DIEs.
-  //--
-  for (uint32_t cu_idx = 0; cu_idx < num_compile_units; ++cu_idx) {
-if (clear_cu_dies[cu_idx])
-  debug_info.GetCompileUnitAtIndex(cu_idx)->ClearDIEs();
-  }
 }
 
 void ManualDWARFIndex::IndexUnit(DWARFUnit &unit, IndexSet &set) {
Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.h
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -13,6 +13,7 @@
 #include "DWARFDIE.h"
 #include "DWARFDebugInfoEntry.h"
 #include "lldb/lldb-enumerations.h"
+#include "llvm/Support/RWMutex.h"
 
 class DWARFUnit;
 class DWARFCompileUnit;
@@ -40,7 +41,20 @@
   virtual ~DWARFUnit();
 
   void ExtractUnitDIEIfNeeded();
-  bool ExtractDIEsIfNeeded();
+  void ExtractDIEsIfNeeded();
+
+  class ScopedExtractDIEs {
+DWARFUnit *m_cu;
+  public:
+bool m_clear_dies = false;
+ScopedExtractDIEs(DWARFUnit *cu);
+~ScopedExtractDIEs();
+DISALLOW_COPY_AND_ASSIGN(ScopedExtractDIEs);
+ScopedExtractDIEs(ScopedExtractDIEs &&rhs);
+ScopedExtractDIEs &operator=(ScopedExtractDIEs &&rhs);
+  };
+  ScopedExtractDIEs ExtractDIEsScoped();
+
   DWARFDIE LookupAddress(const dw_addr_t address);
   size_t AppendDIEsWithTag(const dw_tag_t tag,
DWARFDIECollection &matching_dies,
@@ -100,7 +114,6 @@
   dw_addr_t GetRangesBase() const { return m_ranges_base; }
   void SetAddrBase(dw_addr_t addr_base, dw_addr_t ranges_base,
dw_offset_t base_obj_offset);
-  void ClearDIEs();
   void BuildAddressRangeTable(SymbolFileDWARF *dwarf,
   DWARFDebugAranges *debug_aranges);
 
@@ -172,10 +185,17 @@
   void *m_user_data = nullptr;
   // The compile unit debug information entry item
   DWARFDebugInfoEntry::collection m_die_array;
+  mutable llvm::sys::RWMutex m_die_array_mutex;
+  // It is used for tracking of ScopedExtractDIEs instances.
+  mutable llvm::sys::RWMutex m_die_array_scoped_mutex;
+  // ScopedExtractDIEs instances shou

[Lldb-commits] [PATCH] D47492: DWARFUnit::m_die_array swap()->shrink_to_fit()

2018-06-04 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

FYI I have filed it for libstdc++ but I did not really understand their 
reaction: Bug 86013 - std::vector::shrink_to_fit() could sometimes use 
realloc() 


Repository:
  rL LLVM

https://reviews.llvm.org/D47492



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


[Lldb-commits] [PATCH] D47492: DWARFUnit::m_die_array swap()->shrink_to_fit()

2018-06-05 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

In https://reviews.llvm.org/D47492#1121543, @dblaikie wrote:

> Happy to help explain it - which part(s) are you having a bit of trouble with?


What's wrong on this implementation 
?

> It seems like the main one is that the implementation can't be sure that 
> malloc was used to allocate the memory - since the global allocation function 
> can be replaced & there's no convenient way to detect that.

The example above does verify whether the vector uses default libstdc++ 
std::allocator which uses libstdc++ ::operator new which uses malloc().


Repository:
  rL LLVM

https://reviews.llvm.org/D47492



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


[Lldb-commits] [PATCH] D40470: Protect DWARFCompileUnit::m_die_array by a new mutex

2018-06-05 Thread Jan Kratochvil via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL333987: Protect DWARFCompileUnit::m_die_array by new mutexes 
(authored by jankratochvil, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D40470?vs=149609&id=149917#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D40470

Files:
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  lldb/trunk/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp

Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -13,6 +13,7 @@
 #include "DWARFDIE.h"
 #include "DWARFDebugInfoEntry.h"
 #include "lldb/lldb-enumerations.h"
+#include "llvm/Support/RWMutex.h"
 
 class DWARFUnit;
 class DWARFCompileUnit;
@@ -40,7 +41,20 @@
   virtual ~DWARFUnit();
 
   void ExtractUnitDIEIfNeeded();
-  bool ExtractDIEsIfNeeded();
+  void ExtractDIEsIfNeeded();
+
+  class ScopedExtractDIEs {
+DWARFUnit *m_cu;
+  public:
+bool m_clear_dies = false;
+ScopedExtractDIEs(DWARFUnit *cu);
+~ScopedExtractDIEs();
+DISALLOW_COPY_AND_ASSIGN(ScopedExtractDIEs);
+ScopedExtractDIEs(ScopedExtractDIEs &&rhs);
+ScopedExtractDIEs &operator=(ScopedExtractDIEs &&rhs);
+  };
+  ScopedExtractDIEs ExtractDIEsScoped();
+
   DWARFDIE LookupAddress(const dw_addr_t address);
   size_t AppendDIEsWithTag(const dw_tag_t tag,
DWARFDIECollection &matching_dies,
@@ -100,7 +114,6 @@
   dw_addr_t GetRangesBase() const { return m_ranges_base; }
   void SetAddrBase(dw_addr_t addr_base, dw_addr_t ranges_base,
dw_offset_t base_obj_offset);
-  void ClearDIEs();
   void BuildAddressRangeTable(SymbolFileDWARF *dwarf,
   DWARFDebugAranges *debug_aranges);
 
@@ -172,10 +185,17 @@
   void *m_user_data = nullptr;
   // The compile unit debug information entry item
   DWARFDebugInfoEntry::collection m_die_array;
+  mutable llvm::sys::RWMutex m_die_array_mutex;
+  // It is used for tracking of ScopedExtractDIEs instances.
+  mutable llvm::sys::RWMutex m_die_array_scoped_mutex;
+  // ScopedExtractDIEs instances should not call ClearDIEsRWLocked()
+  // as someone called ExtractDIEsIfNeeded().
+  std::atomic m_cancel_scopes;
   // GetUnitDIEPtrOnly() needs to return pointer to the first DIE.
   // But the first element of m_die_array after ExtractUnitDIEIfNeeded()
   // would possibly move in memory after later ExtractDIEsIfNeeded().
   DWARFDebugInfoEntry m_first_die;
+  llvm::sys::RWMutex m_first_die_mutex;
   // A table similar to the .debug_aranges table, but this one points to the
   // exact DW_TAG_subprogram DIEs
   std::unique_ptr m_func_aranges_ap;
@@ -201,11 +221,14 @@
 
 private:
   void ParseProducerInfo();
+  void ExtractDIEsRWLocked();
+  void ClearDIEsRWLocked();
 
   // Get the DWARF unit DWARF debug informration entry. Parse the single DIE
   // if needed.
   const DWARFDebugInfoEntry *GetUnitDIEPtrOnly() {
 ExtractUnitDIEIfNeeded();
+// m_first_die_mutex is not required as m_first_die is never cleared.
 if (!m_first_die)
   return NULL;
 return &m_first_die;
Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -31,14 +31,21 @@
 
 extern int g_verbose;
 
-DWARFUnit::DWARFUnit(SymbolFileDWARF *dwarf) : m_dwarf(dwarf) {}
+DWARFUnit::DWARFUnit(SymbolFileDWARF *dwarf)
+: m_dwarf(dwarf), m_cancel_scopes(false) {}
 
 DWARFUnit::~DWARFUnit() {}
 
 //--
 // Parses first DIE of a compile unit.
 //--
 void DWARFUnit::ExtractUnitDIEIfNeeded() {
+  {
+llvm::sys::ScopedReader lock(m_first_die_mutex);
+if (m_first_die)
+  return; // Already parsed
+  }
+  llvm::sys::ScopedWriter lock(m_first_die_mutex);
   if (m_first_die)
 return; // Already parsed
 
@@ -67,10 +74,88 @@
 
 //--
 // Parses a compile unit and indexes its DIEs if it hasn't already been done.
+// It will leave this compile unit extracted forever.
 //--
-bool DWARFUnit::ExtractDIEsIfNeeded() {
+void DWARFUnit::ExtractDIEsIfNeeded() {
+  m_cancel_scopes = true;
+
+  {
+llvm::sys::ScopedReader lock(m_die_array_mutex);
+if (!m_die_array.empty())
+  return; // Already parsed
+  }
+  llvm::sys::ScopedWriter lock(m_die_array_mutex);
   if (!m_die_array.empty())
-return 0; // Already parsed
+return; // Already parsed
+
+  ExtractDIEsRW

[Lldb-commits] [PATCH] D40470: Protect DWARFCompileUnit::m_die_array by a new mutex

2018-06-05 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

FYI I have reordered `m_cu->m_die_array_scoped_mutex.unlock_shared();` in 
`DWARFUnit::ScopedExtractDIEs::~ScopedExtractDIEs()` during commit (it was 
written this new way in some other of the 4 offered variants).


Repository:
  rL LLVM

https://reviews.llvm.org/D40470



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


[Lldb-commits] [PATCH] D47492: DWARFUnit::m_die_array swap()->shrink_to_fit()

2018-06-05 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

In https://reviews.llvm.org/D47492#1122080, @labath wrote:

> It doesn't look like your code verifies that the user hasn't replaced the 
> global `operator new` by defining a custom version. 
> http://en.cppreference.com/w/cpp/memory/new/operator_new:


I asked about it in the code, I see I could find it is permitted:

  // Is permitted a symbol interposition of ::operator new to verify even that?



> if libstdc++ exposed a non-weak alias to its `operator new` and then 
> `shrink_to_fit` did a runtime check like `if(&__standard_operator_new == 
> &::operator new)`.

Yes, that is what I planned to write if the symbol interpoisiton is really 
permitted.

> That seems like a huge hack.

Yes but possible.


Repository:
  rL LLVM

https://reviews.llvm.org/D47492



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


[Lldb-commits] [PATCH] D40470: Protect DWARFCompileUnit::m_die_array by a new mutex

2018-06-05 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

Thanks for https://reviews.llvm.org/rL333996 fixups.


Repository:
  rL LLVM

https://reviews.llvm.org/D40470



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


[Lldb-commits] [PATCH] D40475: DWZ 06/07: DWZ test mode

2018-07-03 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 153941.

https://reviews.llvm.org/D40475

Files:
  packages/Python/lldbsuite/test/dotest.py
  packages/Python/lldbsuite/test/lldbinline.py
  packages/Python/lldbsuite/test/lldbtest.py
  packages/Python/lldbsuite/test/make/Makefile.rules
  packages/Python/lldbsuite/test/plugins/builder_base.py
  packages/Python/lldbsuite/test/test_categories.py
  unittests/SymbolFile/CMakeLists.txt
  unittests/SymbolFile/DWZ/CMakeLists.txt
  unittests/SymbolFile/DWZ/Inputs/dwztest.c
  unittests/SymbolFile/DWZ/Inputs/dwztest.debug
  unittests/SymbolFile/DWZ/Inputs/dwztest.debug.dwz
  unittests/SymbolFile/DWZ/Inputs/dwztest.out
  unittests/SymbolFile/DWZ/SymbolFileDWZTests.cpp

Index: unittests/SymbolFile/DWZ/SymbolFileDWZTests.cpp
===
--- /dev/null
+++ unittests/SymbolFile/DWZ/SymbolFileDWZTests.cpp
@@ -0,0 +1,89 @@
+//===-- SymbolFileDWZTests.cpp --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "gtest/gtest.h"
+
+#include "TestingSupport/TestUtilities.h"
+
+#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h"
+#include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
+#include "Plugins/SymbolVendor/ELF/SymbolVendorELF.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Symbol/SymbolVendor.h"
+#include "lldb/Utility/ArchSpec.h"
+#include "lldb/Utility/FileSpec.h"
+
+#if defined(_MSC_VER)
+#include "lldb/Host/windows/windows.h"
+#include 
+#endif
+
+#include 
+
+using namespace lldb_private;
+
+class SymbolFileDWZTests : public testing::Test {
+public:
+  void SetUp() override {
+// Initialize and TearDown the plugin every time, so we get a brand new
+// AST every time so that modifications to the AST from each test don't
+// leak into the next test.
+#if defined(_MSC_VER)
+::CoInitializeEx(nullptr, COINIT_MULTITHREADED);
+#endif
+
+HostInfo::Initialize();
+SymbolFileDWARF::Initialize();
+ClangASTContext::Initialize();
+ObjectFileELF::Initialize();
+SymbolVendorELF::Initialize();
+
+m_dwztest_out = GetInputFilePath("dwztest.out");
+  }
+
+  void TearDown() override {
+SymbolVendorELF::Terminate();
+ObjectFileELF::Terminate();
+ClangASTContext::Terminate();
+SymbolFileDWARF::Terminate();
+HostInfo::Terminate();
+
+#if defined(_MSC_VER)
+::CoUninitialize();
+#endif
+  }
+
+protected:
+  std::string m_dwztest_out;
+};
+
+TEST_F(SymbolFileDWZTests, TestSimpleClassTypes) {
+  FileSpec fspec(m_dwztest_out.c_str(), false);
+  ArchSpec aspec("x86_64-pc-linux");
+  lldb::ModuleSP module = std::make_shared(fspec, aspec);
+
+  SymbolVendor *plugin = module->GetSymbolVendor();
+  EXPECT_NE(nullptr, plugin);
+  SymbolFile *symfile = plugin->GetSymbolFile();
+  EXPECT_NE(nullptr, symfile);
+  EXPECT_EQ(symfile->GetPluginName(), SymbolFileDWARF::GetPluginNameStatic());
+  SymbolContext sc;
+  llvm::DenseSet searched_files;
+  TypeMap results;
+  EXPECT_EQ(1u,
+  symfile->FindTypes(sc, ConstString("StructMovedToDWZCommonFile"), nullptr,
+  false, 0, searched_files, results));
+  EXPECT_EQ(1u, results.GetSize());
+  lldb::TypeSP udt_type = results.GetTypeAtIndex(0);
+  EXPECT_EQ(ConstString("StructMovedToDWZCommonFile"), udt_type->GetName());
+  CompilerType compiler_type = udt_type->GetForwardCompilerType();
+  EXPECT_TRUE(ClangASTContext::IsClassType(compiler_type.GetOpaqueQualType()));
+}
Index: unittests/SymbolFile/DWZ/Inputs/dwztest.c
===
--- /dev/null
+++ unittests/SymbolFile/DWZ/Inputs/dwztest.c
@@ -0,0 +1,9 @@
+// gcc -Wall -g -o dwztest.out dwztest.c; eu-strip --remove-comment -f dwztest.debug dwztest.out; cp -p dwztest.debug dwztest.debug.dup; dwz -m dwztest.debug.dwz dwztest.debug dwztest.debug.dup;rm dwztest.debug.dup; /usr/lib/rpm/sepdebugcrcfix . dwztest.out 
+
+struct StructMovedToDWZCommonFile {
+  int i1, i2, i3, i4, i5, i6, i7, i8, i9;
+} VarWithStructMovedToDWZCommonFile;
+static const int sizeof_StructMovedToDWZCommonFile = sizeof(struct StructMovedToDWZCommonFile);
+int main() {
+  return sizeof_StructMovedToDWZCommonFile;
+}
Index: unittests/SymbolFile/DWZ/CMakeLists.txt
===
--- /dev/null
+++ unittests/SymbolFile/DWZ/CMakeLists.txt
@@ -0,0 +1,21 @@
+add_lldb_unittest(SymbolFileDWZTests
+  SymbolFileDWZTests.cpp
+
+  LINK_LIBS
+lldbCore
+lldbHost
+lldbSymbol
+lldbPluginSymbolFileDWARF
+lldbUtilityHelpers
+lldbPluginObjectFileELF
+lldbPluginSymbolVendorELF
+  LINK_COMPONENTS
+Support
+  )
+
+set(test_inputs
+   dwztest.out
+   dwztest.debug
+   dwztest.debug

[Lldb-commits] [PATCH] D40475: DWZ 06/07: DWZ test mode

2018-07-03 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 153942.

https://reviews.llvm.org/D40475

Files:
  packages/Python/lldbsuite/test/dotest.py
  packages/Python/lldbsuite/test/lldbinline.py
  packages/Python/lldbsuite/test/lldbtest.py
  packages/Python/lldbsuite/test/make/Makefile.rules
  packages/Python/lldbsuite/test/plugins/builder_base.py
  packages/Python/lldbsuite/test/test_categories.py
  unittests/SymbolFile/CMakeLists.txt
  unittests/SymbolFile/DWZ/CMakeLists.txt
  unittests/SymbolFile/DWZ/Inputs/dwztest.c
  unittests/SymbolFile/DWZ/Inputs/dwztest.debug
  unittests/SymbolFile/DWZ/Inputs/dwztest.debug.dwz
  unittests/SymbolFile/DWZ/Inputs/dwztest.out
  unittests/SymbolFile/DWZ/SymbolFileDWZTests.cpp

Index: unittests/SymbolFile/DWZ/SymbolFileDWZTests.cpp
===
--- /dev/null
+++ unittests/SymbolFile/DWZ/SymbolFileDWZTests.cpp
@@ -0,0 +1,89 @@
+//===-- SymbolFileDWZTests.cpp --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "gtest/gtest.h"
+
+#include "TestingSupport/TestUtilities.h"
+
+#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h"
+#include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
+#include "Plugins/SymbolVendor/ELF/SymbolVendorELF.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Symbol/SymbolVendor.h"
+#include "lldb/Utility/ArchSpec.h"
+#include "lldb/Utility/FileSpec.h"
+
+#if defined(_MSC_VER)
+#include "lldb/Host/windows/windows.h"
+#include 
+#endif
+
+#include 
+
+using namespace lldb_private;
+
+class SymbolFileDWZTests : public testing::Test {
+public:
+  void SetUp() override {
+// Initialize and TearDown the plugin every time, so we get a brand new
+// AST every time so that modifications to the AST from each test don't
+// leak into the next test.
+#if defined(_MSC_VER)
+::CoInitializeEx(nullptr, COINIT_MULTITHREADED);
+#endif
+
+HostInfo::Initialize();
+SymbolFileDWARF::Initialize();
+ClangASTContext::Initialize();
+ObjectFileELF::Initialize();
+SymbolVendorELF::Initialize();
+
+m_dwztest_out = GetInputFilePath("dwztest.out");
+  }
+
+  void TearDown() override {
+SymbolVendorELF::Terminate();
+ObjectFileELF::Terminate();
+ClangASTContext::Terminate();
+SymbolFileDWARF::Terminate();
+HostInfo::Terminate();
+
+#if defined(_MSC_VER)
+::CoUninitialize();
+#endif
+  }
+
+protected:
+  std::string m_dwztest_out;
+};
+
+TEST_F(SymbolFileDWZTests, TestSimpleClassTypes) {
+  FileSpec fspec(m_dwztest_out.c_str(), false);
+  ArchSpec aspec("x86_64-pc-linux");
+  lldb::ModuleSP module = std::make_shared(fspec, aspec);
+
+  SymbolVendor *plugin = module->GetSymbolVendor();
+  EXPECT_NE(nullptr, plugin);
+  SymbolFile *symfile = plugin->GetSymbolFile();
+  EXPECT_NE(nullptr, symfile);
+  EXPECT_EQ(symfile->GetPluginName(), SymbolFileDWARF::GetPluginNameStatic());
+  SymbolContext sc;
+  llvm::DenseSet searched_files;
+  TypeMap results;
+  EXPECT_EQ(1u,
+  symfile->FindTypes(sc, ConstString("StructMovedToDWZCommonFile"), nullptr,
+  false, 0, searched_files, results));
+  EXPECT_EQ(1u, results.GetSize());
+  lldb::TypeSP udt_type = results.GetTypeAtIndex(0);
+  EXPECT_EQ(ConstString("StructMovedToDWZCommonFile"), udt_type->GetName());
+  CompilerType compiler_type = udt_type->GetForwardCompilerType();
+  EXPECT_TRUE(ClangASTContext::IsClassType(compiler_type.GetOpaqueQualType()));
+}
Index: unittests/SymbolFile/DWZ/Inputs/dwztest.c
===
--- /dev/null
+++ unittests/SymbolFile/DWZ/Inputs/dwztest.c
@@ -0,0 +1,9 @@
+// gcc -Wall -g -o dwztest.out dwztest.c; eu-strip --remove-comment -f dwztest.debug dwztest.out; cp -p dwztest.debug dwztest.debug.dup; dwz -m dwztest.debug.dwz dwztest.debug dwztest.debug.dup;rm dwztest.debug.dup; /usr/lib/rpm/sepdebugcrcfix . dwztest.out 
+
+struct StructMovedToDWZCommonFile {
+  int i1, i2, i3, i4, i5, i6, i7, i8, i9;
+} VarWithStructMovedToDWZCommonFile;
+static const int sizeof_StructMovedToDWZCommonFile = sizeof(struct StructMovedToDWZCommonFile);
+int main() {
+  return sizeof_StructMovedToDWZCommonFile;
+}
Index: unittests/SymbolFile/DWZ/CMakeLists.txt
===
--- /dev/null
+++ unittests/SymbolFile/DWZ/CMakeLists.txt
@@ -0,0 +1,21 @@
+add_lldb_unittest(SymbolFileDWZTests
+  SymbolFileDWZTests.cpp
+
+  LINK_LIBS
+lldbCore
+lldbHost
+lldbSymbol
+lldbPluginSymbolFileDWARF
+lldbUtilityHelpers
+lldbPluginObjectFileELF
+lldbPluginSymbolVendorELF
+  LINK_COMPONENTS
+Support
+  )
+
+set(test_inputs
+   dwztest.out
+   dwztest.debug
+   dwztest.debug

[Lldb-commits] [PATCH] D48782: LLDB Test Suite: Provide an Option to run all tests with Dwarf Package Format (DWP).

2018-07-03 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

The DWZ-testmode Makefile.rules part. 

The DWZ-mode is written as another test matrix dimension.  Compared to this 
DWP-mode it autodetects if all the tools are available on the host for that 
testsuite mode.
I agree that some `EXPENSIVE_CHECKS` would be appropriate for both DWZ and DWP 
as general LLVM/LLDB development should not break only specifically these modes.
I do not think it matters whether there is an external wrapper script or 
whether the commands are specified as a Makefile rule/macro, sure I will adapt 
it if anyone requests an external command.


https://reviews.llvm.org/D48782



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


[Lldb-commits] [PATCH] D48782: LLDB Test Suite: Provide an Option to run all tests with Dwarf Package Format (DWP).

2018-07-03 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added inline comments.



Comment at: packages/Python/lldbsuite/test/make/Makefile.rules:520
 $(EXE) : $(OBJECTS) $(ARCHIVE_NAME) $(DYLIB_FILENAME)
$(LD) $(OBJECTS) $(ARCHIVE_NAME) -L. -l$(DYLIB_NAME) $(LDFLAGS) -o 
"$(EXE)"
 else

Shouldn't be $(LLVM_DWP) even here? DWZ mode has its command even here.



Comment at: packages/Python/lldbsuite/test/make/Makefile.rules:546
$(OBJCOPY) --strip-debug --add-gnu-debuglink="$(DSYM)" "$(EXE)" "$(EXE)"
 endif
 endif

Shouldn't be $(LLVM_DWP) even here? DWZ mode has its command even here.


https://reviews.llvm.org/D48782



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


[Lldb-commits] [PATCH] D48782: LLDB Test Suite: Provide an Option to run all tests with Dwarf Package Format (DWP).

2018-07-18 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil requested changes to this revision.
jankratochvil added inline comments.
This revision now requires changes to proceed.



Comment at: packages/Python/lldbsuite/test/make/Makefile.rules:238
 
+ifneq (,$(wildcard $(DWP)))
+  MAKE_DWP=YES

I was thinking DWP should be specifiable by user but `make check-lldb 
DWP=/usr/bin/dwp` has no effect. And `DWP` is not set by any `build*(` 
functions in `packages/Python/lldbsuite/test/plugins/builder_base.py`, sorry 
but I do not find that obvious.



Comment at: packages/Python/lldbsuite/test/make/Makefile.rules:528
+ifeq "$(MAKE_DWP)" "YES"
+   $(DWP) -e "$(EXE)" -o "$(EXE).dwp"
+   rm -f $(OBJECTS:.o=.dwo)

The patch as exported by `Download Raw Diff` says:
```../../../make/Makefile.rules:529: *** missing separator.  Stop.
```
(after forcing it by `DWP=/usr/bin/dwp` in that `Makefile.rules` file)


https://reviews.llvm.org/D48782



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


[Lldb-commits] [PATCH] D40473: DWZ 04/07: Adjust existing code for the DWZ support.

2018-07-29 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 157897.
jankratochvil edited the summary of this revision.

https://reviews.llvm.org/D40473

Files:
  source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp
  source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h
  source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -740,6 +740,8 @@
 
 DWARFUnit *dwarf_cu =
 info->GetCompileUnit((dw_offset_t)comp_unit->GetID());
+if (dwarf_cu)
+  dwarf_cu = dwarf_cu->GetMainCU();
 if (dwarf_cu && dwarf_cu->GetUserData() == NULL)
   dwarf_cu->SetUserData(comp_unit);
 return dwarf_cu;
@@ -769,6 +771,7 @@
uint32_t cu_idx) {
   CompUnitSP cu_sp;
   if (dwarf_cu) {
+dwarf_cu = dwarf_cu->GetMainCU();
 CompileUnit *comp_unit = (CompileUnit *)dwarf_cu->GetUserData();
 if (comp_unit) {
   // We already parsed this compile unit, had out a shared pointer to it
@@ -1370,6 +1373,9 @@
 
 Type *SymbolFileDWARF::ResolveTypeUID(const DWARFDIE &die,
   bool assert_not_being_parsed) {
+  // this can be neither die.GetDWARF() nor die.GetMainDWARF().
+  if (die.GetMainDWARF() != this)
+return die.GetMainDWARF()->ResolveTypeUID(die, assert_not_being_parsed);
   if (die) {
 Log *log(LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO));
 if (log)
@@ -1480,6 +1486,10 @@
 Type *SymbolFileDWARF::ResolveType(const DWARFDIE &die,
bool assert_not_being_parsed,
bool resolve_function_context) {
+  // this can be neither die.GetDWARF() nor die.GetMainDWARF().
+  if (die.GetMainDWARF() != this)
+return die.GetMainDWARF()->ResolveType(
+die, assert_not_being_parsed, resolve_function_context);
   if (die) {
 Type *type = GetTypeForDIE(die, resolve_function_context).get();
 
@@ -1500,6 +1510,7 @@
 CompileUnit *
 SymbolFileDWARF::GetCompUnitForDWARFCompUnit(DWARFUnit *dwarf_cu,
  uint32_t cu_idx) {
+  dwarf_cu = dwarf_cu->GetMainCU();
   // Check if the symbol vendor already knows about this compile unit?
   if (dwarf_cu->GetUserData() == NULL) {
 // The symbol vendor doesn't know about this compile unit, we need to parse
@@ -3164,8 +3175,8 @@
 VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext &sc,
  const DWARFDIE &die,
  const lldb::addr_t func_low_pc) {
-  if (die.GetDWARF() != this)
-return die.GetDWARF()->ParseVariableDIE(sc, die, func_low_pc);
+  if (die.GetMainDWARF() != this)
+return die.GetMainDWARF()->ParseVariableDIE(sc, die, func_low_pc);
 
   VariableSP var_sp;
   if (!die)
Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.h
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -175,6 +175,11 @@
 return die_iterator_range(m_die_array.begin(), m_die_array.end());
   }
 
+  // DW_TAG_compile_unit with DW_TAG_imported_unit for this DW_TAG_partial_unit.
+  DWARFUnit *GetMainCU() const {
+return const_cast(this);
+  }
+
 protected:
   DWARFUnit(SymbolFileDWARF *dwarf);
 
Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -510,6 +510,9 @@
 }
 
 TypeSystem *DWARFUnit::GetTypeSystem() {
+  if (GetMainCU() != this)
+return GetMainCU()->GetTypeSystem();
+
   if (m_dwarf)
 return m_dwarf->GetTypeSystemForLanguage(GetLanguageType());
   else
@@ -557,7 +560,7 @@
   // Don't specify the compile unit offset as we don't know it because the
   // DIE belongs to
   // a different compile unit in the same symbol file.
-  return m_dwarf->DebugInfo()->GetDIEForDIEOffset(die_offset);
+  return GetMainCU()->m_dwarf->DebugInfo()->GetDIEForDIEOffset(die_offset);
 }
   }
   m_dwarf->GetObjectFile()->GetModule()->ReportError(
@@ -695,6 +698,9 @@
 }
 
 LanguageType DWARFUnit::GetLanguageType() {
+  if (GetMainCU() != this)
+return GetMainCU()->GetLanguageType();
+
   if (m_language_type != eLanguageTypeUnknown)
 return m_language_type;
 
Index: source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp

[Lldb-commits] [PATCH] D49968: DWZ 02/06: Refactor DWARFUnit::ExtractDIEsScoped

2018-07-29 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil created this revision.
jankratochvil added a reviewer: clayborg.
Herald added subscribers: JDevlieghere, aprantl.

Change the method of construction from:

  DWARFUnit::ScopedExtractDIEs DWARFUnit::ExtractDIEsScoped()

to:

  DWARFUnit::ScopedExtractDIEs::ScopedExtractDIEs(DWARFUnit *cu)

So that a later patch can implement:

  std::unordered_map
  .emplace(DWARFUnit *,DWARFUnit *)

so that if the map element already exists `DWARFUnit::ScopedExtractDIEs` is not 
temporarily constructed. If the caller called `DWARFUnit::ExtractDIEsScoped()` 
as an `emplace` parameter it would get constructed already in the caller.
Patch also contains what I considered as a general cleanup.


https://reviews.llvm.org/D49968

Files:
  source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp

Index: source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
===
--- source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -55,7 +55,8 @@
   };
 
   auto extract_fn = [&units_to_index, &clear_cu_dies](size_t cu_idx) {
-clear_cu_dies[cu_idx] = units_to_index[cu_idx]->ExtractDIEsScoped();
+clear_cu_dies[cu_idx] =
+DWARFUnit::ScopedExtractDIEs(units_to_index[cu_idx]);
   };
 
   // Create a task runner that extracts dies for each DWARF compile unit in a
Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.h
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -43,16 +43,20 @@
   void ExtractDIEsIfNeeded();
 
   class ScopedExtractDIEs {
-DWARFUnit *m_cu;
   public:
-bool m_clear_dies = false;
 ScopedExtractDIEs(DWARFUnit *cu);
+void ClearDIEs() { assert(!m_clear_dies); m_clear_dies = true; }
+// Do not touch m_cu anymore.
+void Disable() { m_unlock = false; m_clear_dies = false; }
 ~ScopedExtractDIEs();
-DISALLOW_COPY_AND_ASSIGN(ScopedExtractDIEs);
 ScopedExtractDIEs(ScopedExtractDIEs &&rhs);
 ScopedExtractDIEs &operator=(ScopedExtractDIEs &&rhs);
+  private:
+DWARFUnit *m_cu;
+bool m_clear_dies = false;
+bool m_unlock;
+DISALLOW_COPY_AND_ASSIGN(ScopedExtractDIEs);
   };
-  ScopedExtractDIEs ExtractDIEsScoped();
 
   DWARFDIE LookupAddress(const dw_addr_t address);
   size_t AppendDIEsWithTag(const dw_tag_t tag,
@@ -227,6 +231,7 @@
   void ParseProducerInfo();
   void ExtractDIEsRWLocked();
   void ClearDIEsRWLocked();
+  void ExtractDIEsScoped(ScopedExtractDIEs &scoped);
 
   // Get the DWARF unit DWARF debug informration entry. Parse the single DIE
   // if needed.
Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -98,35 +98,30 @@
 // and no ExtractDIEsIfNeeded() has been executed during this ScopedExtractDIEs
 // lifetime.
 //--
-DWARFUnit::ScopedExtractDIEs DWARFUnit::ExtractDIEsScoped() {
-  ScopedExtractDIEs scoped(this);
-
+void DWARFUnit::ExtractDIEsScoped(ScopedExtractDIEs &scoped) {
   {
 llvm::sys::ScopedReader lock(m_die_array_mutex);
 if (!m_die_array.empty())
-  return scoped; // Already parsed
+  return; // Already parsed
   }
   llvm::sys::ScopedWriter lock(m_die_array_mutex);
   if (!m_die_array.empty())
-return scoped; // Already parsed
-
-  // Otherwise m_die_array would be already populated.
-  lldbassert(!m_cancel_scopes);
+return; // Already parsed
 
   ExtractDIEsRWLocked();
-  scoped.m_clear_dies = true;
-  return scoped;
+  scoped.ClearDIEs();
 }
 
 DWARFUnit::ScopedExtractDIEs::ScopedExtractDIEs(DWARFUnit *cu) : m_cu(cu) {
   lldbassert(m_cu);
   m_cu->m_die_array_scoped_mutex.lock_shared();
+  m_unlock = true;
+  m_cu->ExtractDIEsScoped(*this);
 }
 
 DWARFUnit::ScopedExtractDIEs::~ScopedExtractDIEs() {
-  if (!m_cu)
-return;
-  m_cu->m_die_array_scoped_mutex.unlock_shared();
+  if (m_unlock)
+m_cu->m_die_array_scoped_mutex.unlock_shared();
   if (!m_clear_dies || m_cu->m_cancel_scopes)
 return;
   // Be sure no other ScopedExtractDIEs is running anymore.
@@ -139,14 +134,14 @@
 
 DWARFUnit::ScopedExtractDIEs::ScopedExtractDIEs(ScopedExtractDIEs &&rhs)
 : m_cu(rhs.m_cu), m_clear_dies(rhs.m_clear_dies) {
-  rhs.m_cu = nullptr;
+  Disable();
 }
 
 DWARFUnit::ScopedExtractDIEs &DWARFUnit::ScopedExtractDIEs::operator=(
 DWARFUnit::ScopedExtractDIEs &&rhs) {
   m_cu = rhs.m_cu;
-  rhs.m_cu = nullptr;
   m_clear_dies = rhs.m_clear_dies;
+  rhs.Disable();
   return *this;
 }
 
@@ -447,7 +442,7 @@
   // If the DIEs weren't parsed, then we don't want all dies for all compile
   // units to stay loaded when they weren't needed. So we can end 

[Lldb-commits] [PATCH] D40474: DWZ 03/06: Main functionality

2018-07-29 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 157900.
jankratochvil retitled this revision from "DWZ 05/07: Main functionality" to 
"DWZ 03/06: Main functionality".
Herald added a subscriber: jfb.

https://reviews.llvm.org/D40474

Files:
  include/lldb/Utility/ConstString.h
  include/lldb/Utility/FileSpec.h
  source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h
  source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
  source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
  source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  source/Utility/DataEncoder.cpp
  source/Utility/DataExtractor.cpp

Index: source/Utility/DataExtractor.cpp
===
--- source/Utility/DataExtractor.cpp
+++ source/Utility/DataExtractor.cpp
@@ -230,7 +230,8 @@
 if (data != nullptr) {
   const uint8_t *data_bytes = data->GetBytes();
   if (data_bytes != nullptr) {
-assert(m_start >= data_bytes);
+// For DWARFDataExtractor::OffsetData we need to return negative value.
+// assert(m_start >= data_bytes);
 return m_start - data_bytes;
   }
 }
Index: source/Utility/DataEncoder.cpp
===
--- source/Utility/DataEncoder.cpp
+++ source/Utility/DataEncoder.cpp
@@ -79,7 +79,8 @@
 if (data != nullptr) {
   const uint8_t *data_bytes = data->GetBytes();
   if (data_bytes != nullptr) {
-assert(m_start >= data_bytes);
+// For DWARFDataExtractor::OffsetData we need to return negative value.
+// assert(m_start >= data_bytes);
 return m_start - data_bytes;
   }
 }
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -18,10 +18,12 @@
 #include 
 #include 
 #include 
+#include 
 
 // Other libraries and framework includes
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/Support/Threading.h"
+#include "llvm/Support/RWMutex.h"
 
 #include "lldb/Utility/Flags.h"
 
@@ -318,6 +320,13 @@
 
   void Dump(lldb_private::Stream &s) override;
 
+  SymbolFileDWARF *GetDWZSymbolFile() const {
+if (!m_dwz_common_file)
+  return nullptr;
+return m_dwz_common_file->SymbolFile();
+  }
+  bool GetIsDWZ() const { return m_is_dwz; }
+
 protected:
   typedef llvm::DenseMap
   DIEToTypePtr;
@@ -452,6 +461,45 @@
 
   SymbolFileDWARFDwp *GetDwpSymbolFile();
 
+  void InitializeDWZ();
+
+  class DWZCommonFile {
+  public:
+// C++14: Use heterogenous lookup.
+DWZCommonFile(const lldb_private::FileSpec &filespec_ref);
+DWZCommonFile(std::unique_ptr symbol_file,
+lldb::ObjectFileSP obj_file, lldb::ModuleSP module);
+SymbolFileDWARF *SymbolFile() const { return m_symbol_file.get(); }
+
+bool operator==(const DWZCommonFile &rhs) const {
+  return m_filespec_ref == rhs.m_filespec_ref;
+}
+bool operator!=(const DWZCommonFile &rhs) const { return !(*this == rhs); }
+class Hasher {
+public:
+  size_t operator()(const DWZCommonFile &key) const {
+return lldb_private::FileSpec::Hasher()(key.m_filespec_ref);
+  }
+};
+
+size_t m_use_count = 0;
+
+  private:
+std::unique_ptr m_symbol_file;
+lldb::ObjectFileSP m_obj_file;
+lldb::ModuleSP m_module;
+const lldb_private::FileSpec &m_filespec_ref;
+
+DISALLOW_COPY_AND_ASSIGN(DWZCommonFile);
+  };
+  DWZCommonFile *m_dwz_common_file = nullptr;
+  void DWZCommonFileSet(DWZCommonFile *dwz_common_file);
+  void DWZCommonFileClear();
+  static std::unordered_set
+  m_filespec_to_dwzcommonfile;
+  static llvm::sys::RWMutex m_filespec_to_dwzcommonfile_mutex;
+  bool m_is_dwz = false;
+
   lldb::ModuleWP m_debug_map_module_wp;
   SymbolFileDWARFDebugMap *m_debug_map_symfile;
 
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -419,7 +419,9 @@
   m_supports_DW_AT_APPLE_objc_complete_type(eLazyBoolCalculate), m_ranges(),
   m_unique_ast_type_map() {}
 
-SymbolFileDWARF::~SymbolFileDWARF() {}
+SymbolFileDWARF::~SymbolFileDWARF() {
+  DWZCommonFileClear();
+}
 
 static const ConstString &GetDWARFMachOSegmentName() {
   static ConstString g_dwarf_section_name("__DWARF");
@@ -435,6 +437,7 @@
 }
 
 Type

[Lldb-commits] [PATCH] D49969: DWZ 04/06: ManualDWARFIndex::GetGlobalVariables for DIEs in PUs

2018-07-29 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil created this revision.
jankratochvil added reviewers: labath, clayborg.
Herald added a subscriber: JDevlieghere.

Rarely (`GlobalVariablesTestCase-test_c_global_variables`) a DIE can be only in 
PU (PartialUnit), that is if a DIE is a static constant variable 
(`g_file_static_int`) so that it has no location address.

Patch has been optimized for minimal code added despite the performance is 
suboptimal for DWZ files. It also should not affect non-DWZ files performance.

All DWZ patches are also applied in: git clone -b dwz 
git://git.jankratochvil.net/lldb


https://reviews.llvm.org/D49969

Files:
  source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
  source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
  source/Plugins/SymbolFile/DWARF/NameToDIE.cpp
  source/Plugins/SymbolFile/DWARF/NameToDIE.h

Index: source/Plugins/SymbolFile/DWARF/NameToDIE.h
===
--- source/Plugins/SymbolFile/DWARF/NameToDIE.h
+++ source/Plugins/SymbolFile/DWARF/NameToDIE.h
@@ -11,6 +11,7 @@
 #define SymbolFileDWARF_NameToDIE_h_
 
 #include 
+#include 
 
 #include "DIERef.h"
 #include "lldb/Core/UniqueCStringMap.h"
@@ -39,9 +40,16 @@
   size_t Find(const lldb_private::RegularExpression ®ex,
   DIEArray &info_array) const;
 
+  size_t FindAllEntriesForCompileUnit(
+  std::function compare, DIEArray &info_array) const;
+
   size_t FindAllEntriesForCompileUnit(dw_offset_t cu_offset,
   DIEArray &info_array) const;
 
+  size_t FindAllEntriesForCompileUnit(
+  const std::unordered_set &cu_offsets,
+  DIEArray &info_array) const;
+
   void
   ForEach(std::function const
Index: source/Plugins/SymbolFile/DWARF/NameToDIE.cpp
===
--- source/Plugins/SymbolFile/DWARF/NameToDIE.cpp
+++ source/Plugins/SymbolFile/DWARF/NameToDIE.cpp
@@ -39,18 +39,33 @@
   return m_map.GetValues(regex, info_array);
 }
 
-size_t NameToDIE::FindAllEntriesForCompileUnit(dw_offset_t cu_offset,
-   DIEArray &info_array) const {
+size_t NameToDIE::FindAllEntriesForCompileUnit(
+std::function compare, DIEArray &info_array) const {
   const size_t initial_size = info_array.size();
   const uint32_t size = m_map.GetSize();
   for (uint32_t i = 0; i < size; ++i) {
 const DIERef &die_ref = m_map.GetValueAtIndexUnchecked(i);
-if (cu_offset == die_ref.cu_offset)
+if (compare(die_ref.cu_offset))
   info_array.push_back(die_ref);
   }
   return info_array.size() - initial_size;
 }
 
+size_t NameToDIE::FindAllEntriesForCompileUnit(dw_offset_t cu_offset,
+   DIEArray &info_array) const {
+  return FindAllEntriesForCompileUnit([cu_offset](dw_offset_t offset) {
+return offset == cu_offset;
+  }, info_array);
+}
+
+size_t NameToDIE::FindAllEntriesForCompileUnit(
+const std::unordered_set &cu_offsets,
+DIEArray &info_array) const {
+  return FindAllEntriesForCompileUnit([&cu_offsets](dw_offset_t offset) {
+return cu_offsets.count(offset) != 0;
+  }, info_array);
+}
+
 void NameToDIE::Dump(Stream *s) {
   const uint32_t size = m_map.GetSize();
   for (uint32_t i = 0; i < size; ++i) {
Index: source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
===
--- source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
+++ source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
@@ -11,8 +11,12 @@
 #define LLDB_MANUALDWARFINDEX_H
 
 #include "Plugins/SymbolFile/DWARF/DWARFIndex.h"
+#include "Plugins/SymbolFile/DWARF/DWARFUnit.h"
 #include "Plugins/SymbolFile/DWARF/NameToDIE.h"
 #include "llvm/ADT/DenseSet.h"
+#include "llvm/Support/RWMutex.h"
+
+#include 
 
 namespace lldb_private {
 class ManualDWARFIndex : public DWARFIndex {
@@ -22,6 +26,8 @@
   : DWARFIndex(module), m_debug_info(debug_info),
 m_units_to_avoid(std::move(units_to_avoid)) {}
 
+  ~ManualDWARFIndex() override;
+
   void Preload() override { Index(); }
 
   void GetGlobalVariables(ConstString basename, DIEArray &offsets) override;
@@ -68,7 +74,19 @@
   /// Which dwarf units should we skip while building the index.
   llvm::DenseSet m_units_to_avoid;
 
+  void AddExtractedPU(DWARFUnit &importer, DWARFUnit &importee);
+
   IndexSet m_set;
+
+  // All DW_TAG_partial_unit's extracted for Index-ing this DW_TAG_compile_unit.
+  struct ExtractedForUnit {
+// FIXME: The pointer is already contained in the value; but we wound need
+// a combination of DenseSet::insert_as and DenseSet::try_emplace.
+std::unordered_map m_map;
+llvm::sys::RWMutex m_mutex;
+  };
+  std::unordered_map m_extracted_pu;
+  llvm::sys::RWMutex m_extracted_pu_mutex;
 };
 } // namespace lldb_private
 
Index: source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
===
--- source/Plugins/SymbolFile/DWARF/ManualDWARFInd

[Lldb-commits] [PATCH] D43512: DWZ 06/06: Fix for symlinked .build-id/**.debug files

2018-07-29 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 157903.
jankratochvil retitled this revision from "DWZ 07/07: Fix for symlinked 
.build-id/**.debug files" to "DWZ 06/06: Fix for symlinked .build-id/**.debug 
files".

https://reviews.llvm.org/D43512

Files:
  packages/Python/lldbsuite/test/decorators.py
  packages/Python/lldbsuite/test/linux/buildidsymlink/Makefile
  
packages/Python/lldbsuite/test/linux/buildidsymlink/TestTargetSymbolsBuildidSymlink.py
  packages/Python/lldbsuite/test/linux/buildidsymlink/main.c
  source/Host/common/Symbols.cpp

Index: source/Host/common/Symbols.cpp
===
--- source/Host/common/Symbols.cpp
+++ source/Host/common/Symbols.cpp
@@ -284,6 +284,8 @@
 if (llvm::sys::fs::equivalent(file_spec.GetPath(),
   module_file_spec.GetPath()))
   continue;
+if (FileSystem::ResolveSymbolicLink(file_spec, file_spec).Fail())
+  continue;
 
 if (file_spec.Exists()) {
   lldb_private::ModuleSpecList specs;
Index: packages/Python/lldbsuite/test/linux/buildidsymlink/main.c
===
--- /dev/null
+++ packages/Python/lldbsuite/test/linux/buildidsymlink/main.c
@@ -0,0 +1,6 @@
+struct s {
+  int i1, i2, i3, i4, i5, i6, i7, i8, i9;
+} v;
+int main() {
+  return 0;
+}
Index: packages/Python/lldbsuite/test/linux/buildidsymlink/TestTargetSymbolsBuildidSymlink.py
===
--- /dev/null
+++ packages/Python/lldbsuite/test/linux/buildidsymlink/TestTargetSymbolsBuildidSymlink.py
@@ -0,0 +1,24 @@
+""" Testing separate debug info loading for base binary with a symlink. """
+import os
+import time
+import lldb
+import sys
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestTargetSymbolsBuildidSymlink(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@no_debug_info_test  # Prevent the genaration of the dwarf version of this test
+@skipUnlessPlatform(['linux'])
+@skipIf(hostoslist=["windows"])
+@skipIfRemote # llvm.org/pr36237
+@skipUnlessDWZInstalled
+def test_target_symbols_buildid_symlink(self):
+self.build()
+exe = self.getBuildArtifact("stripped.out")
+
+lldbutil.run_to_name_breakpoint(self, "main", exe_name = exe)
Index: packages/Python/lldbsuite/test/linux/buildidsymlink/Makefile
===
--- /dev/null
+++ packages/Python/lldbsuite/test/linux/buildidsymlink/Makefile
@@ -0,0 +1,24 @@
+LEVEL = ../../make
+C_SOURCES := main.c
+LD_EXTRAS += -Wl,--build-id=sha1
+
+all: .build-id
+
+.PHONY: .build-id
+stripped.out stripped.debug stripped.debug.dwz: a.out
+	eu-strip --remove-comment -f stripped.debug -F stripped.debugx -o stripped.out $<
+	cp -p stripped.debug stripped.debug.dup
+	dwz -m stripped.debug.dwz stripped.debug stripped.debug.dup
+
+.build-id: stripped.debug
+	$(OBJCOPY) -j .note.gnu.build-id -O binary $< tmp
+	rm -rf .build-id
+	fn=`od -An -tx1 ___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D40475: DWZ 05/06: DWZ test mode

2018-07-29 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 157902.
jankratochvil retitled this revision from "DWZ 06/07: DWZ test mode" to "DWZ 
05/06: DWZ test mode".
jankratochvil edited the summary of this revision.

https://reviews.llvm.org/D40475

Files:
  packages/Python/lldbsuite/test/dotest.py
  packages/Python/lldbsuite/test/lldbinline.py
  packages/Python/lldbsuite/test/lldbtest.py
  packages/Python/lldbsuite/test/make/Makefile.rules
  packages/Python/lldbsuite/test/plugins/builder_base.py
  packages/Python/lldbsuite/test/test_categories.py
  unittests/SymbolFile/CMakeLists.txt
  unittests/SymbolFile/DWZ/CMakeLists.txt
  unittests/SymbolFile/DWZ/Inputs/dwztest.c
  unittests/SymbolFile/DWZ/Inputs/dwztest.debug
  unittests/SymbolFile/DWZ/Inputs/dwztest.debug.dwz
  unittests/SymbolFile/DWZ/Inputs/dwztest.out
  unittests/SymbolFile/DWZ/SymbolFileDWZTests.cpp

Index: unittests/SymbolFile/DWZ/SymbolFileDWZTests.cpp
===
--- /dev/null
+++ unittests/SymbolFile/DWZ/SymbolFileDWZTests.cpp
@@ -0,0 +1,89 @@
+//===-- SymbolFileDWZTests.cpp --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "gtest/gtest.h"
+
+#include "TestingSupport/TestUtilities.h"
+
+#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h"
+#include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
+#include "Plugins/SymbolVendor/ELF/SymbolVendorELF.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Symbol/SymbolVendor.h"
+#include "lldb/Utility/ArchSpec.h"
+#include "lldb/Utility/FileSpec.h"
+
+#if defined(_MSC_VER)
+#include "lldb/Host/windows/windows.h"
+#include 
+#endif
+
+#include 
+
+using namespace lldb_private;
+
+class SymbolFileDWZTests : public testing::Test {
+public:
+  void SetUp() override {
+// Initialize and TearDown the plugin every time, so we get a brand new
+// AST every time so that modifications to the AST from each test don't
+// leak into the next test.
+#if defined(_MSC_VER)
+::CoInitializeEx(nullptr, COINIT_MULTITHREADED);
+#endif
+
+HostInfo::Initialize();
+SymbolFileDWARF::Initialize();
+ClangASTContext::Initialize();
+ObjectFileELF::Initialize();
+SymbolVendorELF::Initialize();
+
+m_dwztest_out = GetInputFilePath("dwztest.out");
+  }
+
+  void TearDown() override {
+SymbolVendorELF::Terminate();
+ObjectFileELF::Terminate();
+ClangASTContext::Terminate();
+SymbolFileDWARF::Terminate();
+HostInfo::Terminate();
+
+#if defined(_MSC_VER)
+::CoUninitialize();
+#endif
+  }
+
+protected:
+  std::string m_dwztest_out;
+};
+
+TEST_F(SymbolFileDWZTests, TestSimpleClassTypes) {
+  FileSpec fspec(m_dwztest_out.c_str(), false);
+  ArchSpec aspec("x86_64-pc-linux");
+  lldb::ModuleSP module = std::make_shared(fspec, aspec);
+
+  SymbolVendor *plugin = module->GetSymbolVendor();
+  EXPECT_NE(nullptr, plugin);
+  SymbolFile *symfile = plugin->GetSymbolFile();
+  EXPECT_NE(nullptr, symfile);
+  EXPECT_EQ(symfile->GetPluginName(), SymbolFileDWARF::GetPluginNameStatic());
+  SymbolContext sc;
+  llvm::DenseSet searched_files;
+  TypeMap results;
+  EXPECT_EQ(1u,
+  symfile->FindTypes(sc, ConstString("StructMovedToDWZCommonFile"), nullptr,
+  false, 0, searched_files, results));
+  EXPECT_EQ(1u, results.GetSize());
+  lldb::TypeSP udt_type = results.GetTypeAtIndex(0);
+  EXPECT_EQ(ConstString("StructMovedToDWZCommonFile"), udt_type->GetName());
+  CompilerType compiler_type = udt_type->GetForwardCompilerType();
+  EXPECT_TRUE(ClangASTContext::IsClassType(compiler_type.GetOpaqueQualType()));
+}
Index: unittests/SymbolFile/DWZ/Inputs/dwztest.c
===
--- /dev/null
+++ unittests/SymbolFile/DWZ/Inputs/dwztest.c
@@ -0,0 +1,9 @@
+// gcc -Wall -g -o dwztest.out dwztest.c; eu-strip --remove-comment -f dwztest.debug dwztest.out; cp -p dwztest.debug dwztest.debug.dup; dwz -m dwztest.debug.dwz dwztest.debug dwztest.debug.dup;rm dwztest.debug.dup; /usr/lib/rpm/sepdebugcrcfix . dwztest.out 
+
+struct StructMovedToDWZCommonFile {
+  int i1, i2, i3, i4, i5, i6, i7, i8, i9;
+} VarWithStructMovedToDWZCommonFile;
+static const int sizeof_StructMovedToDWZCommonFile = sizeof(struct StructMovedToDWZCommonFile);
+int main() {
+  return sizeof_StructMovedToDWZCommonFile;
+}
Index: unittests/SymbolFile/DWZ/CMakeLists.txt
===
--- /dev/null
+++ unittests/SymbolFile/DWZ/CMakeLists.txt
@@ -0,0 +1,21 @@
+add_lldb_unittest(SymbolFileDWZTests
+  SymbolFileDWZTests.cpp
+
+  LINK_LIBS
+lldbCore
+lldbHost
+lldbSymbol
+lldbPluginSymbolFileDWARF
+lldbUtilityHelpers
+lldbPlugin

  1   2   3   4   5   6   7   8   9   >