[Lldb-commits] [PATCH] D67022: Enhance SymbolFileDWARF::ParseDeclsForContext performance

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

Thanks for the clarification Greg.

Functionally, this patch seems fine, but I am still wondering if we shouldn't 
make this more efficient. std::set is not the most memory-efficient structure, 
and so creating a std::set entry just to store one bit seems wasteful, 
particularly as there is already a container which uses the context as a key 
(`m_decl_ctx_to_die`). Could just shove this bit into the `m_decl_ctx_to_die` 
map (probably by changing it to something functionally equivalent to 
`map>>`)? Given that the sole "raison 
d´être" of this map is to enable the `ParseDeclsForContext` functionality, I 
don't think that having that flag be stored there should be awkward. Quite the 
opposite, it would remove the awkward back-and-forth between the 
SymbolFileDWARF and the DWARFASTParsers (symbol file calls 
`ForEachDIEInDeclContext`, passing it a callback; then ast parser calls the 
callback; finally the callback immediately re-enters the parser via 
`GetDeclForUIDFromDWARF`) -- instead we could just have the SymbolFileDWARF do 
`ast_parser->PleaseParseAllDiesInThisContextIfTheyHaventBeenParsedAlready(ctx)` 
and have everything happen inside the parser.

So, overall, it seems to me that this way, we could improve the code 
readability while reducing the time, and avoiding a bigger memory increase. In 
fact, since we now will not be using the list of dies after they have been 
parsed once, we could even free up the vector after the parsing is 
complete, and thereby reduce the memory footprint as well.  That would be a 
win-win-win scenario. :)

WDYT?




Comment at: lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp:48
   ASSERT_EQ(2u, die_list.size());
-  ASSERT_EQ(die2, die_list[0]);
-  ASSERT_EQ(die3, die_list[1]);
+  ASSERT_NE(die_list.end(), std::find(die_list.begin(), die_list.end(), die2));
+  ASSERT_NE(die_list.end(), std::find(die_list.begin(), die_list.end(), die3));

guiandrade wrote:
> I think we should not expect any particular order, right?
Probably not. A more succinct way of expressing that would be 
`EXPECT_THAT(die_list, testing::UnorderedElementsAre(die2, die3))`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67022



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


[Lldb-commits] [PATCH] D67083: [dotest] Avoid the need for LEVEL= makefile boilerplate

2019-09-04 Thread Pavel Labath via Phabricator via lldb-commits
labath marked an inline comment as done.
labath added inline comments.



Comment at: packages/Python/lldbsuite/test/lldbinline.py:116
 
-makefile.write("include $(LEVEL)/Makefile.rules\n")
+makefile.write("include Makefile.rules\n")
 makefile.write("\ncleanup:\n\trm -f Makefile *.d\n\n")

aprantl wrote:
> labath wrote:
> > aprantl wrote:
> > > wait.. lldbinline can auto-generate a Makefile? Is that feature used by 
> > > any tests?
> > I would guess "all of them", because otherwise, how would the inline test 
> > executable get built?
> I see. My only exposure to inline test was in the Swift branch and there they 
> all ship their own Makefile, but that is likely because they need to set 
> SWIFT_SOURCES instead of the default CXX_SOURCES.
Aha, interesting. I did some stats, and it seems that (in the lldb repo), most 
(41) inline tests don't come with a Makefile, but there are some (14) that do. 
I am going to separately check if those 14 can be removed too.

It sounds like it might be interesting to make swift inline tests auto generate 
makefiles too, but that's up to you guys...


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

https://reviews.llvm.org/D67083



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


[Lldb-commits] [PATCH] D65677: [VirtualFileSystem] Support encoding working directories in a VFS mapping.

2019-09-04 Thread Sam McCall via Phabricator via lldb-commits
sammccall added a comment.

(I replied by email, it seems phabricator doesn't pick it up.)

In D65677#1649731 , @JDevlieghere 
wrote:

> In D65677#1649329 , @sammccall wrote:
>
> > In D65677#1649291 , @JDevlieghere 
> > wrote:
> >
> > > It's funny you say that, because the code to resolve relative paths is 
> > > almost identical to the thing you added for supporting different working 
> > > directories in different threads. :-)
> >
> >
> > Right! I think the key distinction is that there wasn't any functional 
> > change to the APIs, because the abstraction didn't change.
> >  (There was a second factory function, which basically lets callers choose 
> > between the two implementations that have different sets of bugs)
> >
> > >>>   What do you think? Is there another approach that's worth considering?
> > >> 
> > >> Per my previous comment, what goes wrong if you try to make the working 
> > >> directory a sibling of VFS (within the reproducer container) rather than 
> > >> a child of it (within shared infrastructure)?
> > > 
> > > Oops, seems like I didn't see your question either :-) Please clarify 
> > > what you mean by sibling and child. Do you mean that the working 
> > > directories are part of the mapping or that the redirecting file system 
> > > knows about it? I don't care where we store the entries, I'm happy to 
> > > have a separate YAML mapping that only the LLDB reproducers know about. 
> > > However, I do need the underlying logic to be part of the (redirecting) 
> > > VFS. Just like clang, LLDB is agnostic to the VFS, so this whole thing 
> > > should be transparent. The only reason I didn't keep them separate is 
> > > because then you need a way to tell the redirecting file system about the 
> > > working directories, which means you need to get the concrete VFS, i.e. 
> > > casting the VFS to a RedirectingVFS, which I try to avoid.
> >
> > I mean why can't you just call `setCurrentWorkingDirectory` before 
> > starting? something like this:
> >
> >   struct Reproducer { string FSYaml; string CWD; ... };
> >   void run(Reproducer &R) {
> > auto* FS = RedirectingFileSystem::create(R.FSYaml, ...);
> > FS->setCurrentWorkingDirectory(R.CWD);
> > runLLDBWith(FS, ...);
> >   }
> >  
> >
>
>
> That doesn't work for the reproducer because the working directory likely 
> doesn't exist during replay. The redirecting file system just forwards the 
> `setCurrentWorkingDirectory` call to it's underlying (real) FS, so this 
> becomes a no-op.


Can we fix that instead? The RedirectingVFS already knows about virtual 
directory entries, being able to cd to them makes sense.

This seems mostly like fixing a bug/limitation that wouldn't involve API 
changes.

Is there a part of the problem that needs the new search path concept/multiple 
paths?


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

https://reviews.llvm.org/D65677



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


[Lldb-commits] [PATCH] D67123: [lldb] Early exit in RangeDataVector:FindEntryIndexesThatContain

2019-09-04 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor updated this revision to Diff 218602.
teemperor retitled this revision from "[lldb] Use binary search in 
RangeDataVector:FindEntryIndexesThatContain" to "[lldb] Early exit in 
RangeDataVector:FindEntryIndexesThatContain".
teemperor edited the summary of this revision.
teemperor added a comment.

- Refactor to just stop the search when we find a higher base address.


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

https://reviews.llvm.org/D67123

Files:
  lldb/include/lldb/Utility/RangeMap.h


Index: lldb/include/lldb/Utility/RangeMap.h
===
--- lldb/include/lldb/Utility/RangeMap.h
+++ lldb/include/lldb/Utility/RangeMap.h
@@ -725,11 +725,17 @@
 assert(IsSorted());
 #endif
 
-if (!m_entries.empty()) {
-  for (const auto &entry : m_entries) {
-if (entry.Contains(addr))
-  indexes.push_back(entry.data);
-  }
+if (m_entries.empty())
+  return indexes.size();
+
+// Search the entries until the first entry that has a larger base address
+// than `addr`. As m_entries is sorted by their base address, all following
+// entries can't contain `addr` as their base address is already larger.
+for (const auto &entry : m_entries) {
+  if (entry.Contains(addr))
+indexes.push_back(entry.data);
+  else if (entry.GetRangeBase() > addr)
+break;
 }
 return indexes.size();
   }


Index: lldb/include/lldb/Utility/RangeMap.h
===
--- lldb/include/lldb/Utility/RangeMap.h
+++ lldb/include/lldb/Utility/RangeMap.h
@@ -725,11 +725,17 @@
 assert(IsSorted());
 #endif
 
-if (!m_entries.empty()) {
-  for (const auto &entry : m_entries) {
-if (entry.Contains(addr))
-  indexes.push_back(entry.data);
-  }
+if (m_entries.empty())
+  return indexes.size();
+
+// Search the entries until the first entry that has a larger base address
+// than `addr`. As m_entries is sorted by their base address, all following
+// entries can't contain `addr` as their base address is already larger.
+for (const auto &entry : m_entries) {
+  if (entry.Contains(addr))
+indexes.push_back(entry.data);
+  else if (entry.GetRangeBase() > addr)
+break;
 }
 return indexes.size();
   }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D67123: [lldb] Early exit in RangeDataVector:FindEntryIndexesThatContain

2019-09-04 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor marked 3 inline comments as done.
teemperor added inline comments.



Comment at: lldb/include/lldb/Utility/RangeMap.h:739
+auto end = std::lower_bound(m_entries.begin(), m_entries.end(),
+Entry(addr, 1), BaseLessEqual);
+for (auto I = m_entries.begin(); I != end; ++I) {

labath wrote:
> amccarth wrote:
> > You're trying to find an upper bound, so `std::upper_bound` seems more 
> > natural than `std::lower_bound`.  Understanding how `std::lower_bound` 
> > works with a comparator that implements `<=` requires some mental 
> > gymnastics.  With `std::upper_bound`, you'd just need `<` that compares 
> > only the base addresses.
> > 
> > You could even avoid the custom comparison function by using the maximum 
> > value for the size:
> > 
> > ```
> > auto end = std::upper_bound(m_entries.begin(), m_entries.end(),
> > Entry(addr, 
> > std::numeric_limits::max()));
> > ```
> > 
> Actually, If I understand this correctly, there is no need for either lower 
> or upper bound here. Since you're going to be iterating through the list 
> anyway. It should be sufficient to add a early exit from the loop once you 
> encounter an element whose base address is >= the address you search for.
Oh true, I got confused by all the other lower_bounding we do in the 
surrounding functions :)


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

https://reviews.llvm.org/D67123



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


[Lldb-commits] [PATCH] D67123: [lldb] Early exit in RangeDataVector:FindEntryIndexesThatContain

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

lgtm




Comment at: lldb/include/lldb/Utility/RangeMap.h:728-729
 
-if (!m_entries.empty()) {
-  for (const auto &entry : m_entries) {
-if (entry.Contains(addr))
-  indexes.push_back(entry.data);
-  }
+if (m_entries.empty())
+  return indexes.size();
+

This pattern seems to be common in lldb, but I really don't understand the 
reason behind it -- it just checks the condition that would be checked by the 
for loop anyway. I've personally just started removing checks like these 
whenever I touch some code which uses them...


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

https://reviews.llvm.org/D67123



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


[Lldb-commits] [lldb] r370848 - [lldb][NFC] Add a simple test for thread_local storage.

2019-09-04 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Wed Sep  4 01:02:52 2019
New Revision: 370848

URL: http://llvm.org/viewvc/llvm-project?rev=370848&view=rev
Log:
[lldb][NFC] Add a simple test for thread_local storage.

Seems we fail to read TLS data on Linux, so the test only runs on
macOS for now. We will see how this test runs on the BSD bots.

Added:
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/Makefile

lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/TestThreadLocal.py
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/main.cpp

Added: lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/Makefile?rev=370848&view=auto
==
--- lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/Makefile 
(added)
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/Makefile 
Wed Sep  4 01:02:52 2019
@@ -0,0 +1,3 @@
+LEVEL = ../../../make
+CXX_SOURCES := main.cpp
+include $(LEVEL)/Makefile.rules

Added: 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/TestThreadLocal.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/TestThreadLocal.py?rev=370848&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/TestThreadLocal.py
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/TestThreadLocal.py
 Wed Sep  4 01:02:52 2019
@@ -0,0 +1,5 @@
+from lldbsuite.test import lldbinline
+from lldbsuite.test import decorators
+
+lldbinline.MakeInlineTest(__file__, globals(),
+  lldbinline.expectedFailureAll(oslist=["windows", 
"linux"]))

Added: lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/main.cpp?rev=370848&view=auto
==
--- lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/main.cpp 
(added)
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/main.cpp 
Wed Sep  4 01:02:52 2019
@@ -0,0 +1,17 @@
+int storage = 45;
+thread_local int tl_global_int = 123;
+thread_local int *tl_global_ptr = &storage;
+
+int main(int argc, char **argv) {
+  //% self.expect("expr tl_local_int", error=True, substrs=["couldn't get the 
value of variable tl_local_int"])
+  //% self.expect("expr *tl_local_ptr", error=True, substrs=["couldn't get the 
value of variable tl_local_ptr"])
+  thread_local int tl_local_int = 321;
+  thread_local int *tl_local_ptr = nullptr;
+  tl_local_ptr = &tl_local_int;
+  tl_local_int++;
+  //% self.expect("expr tl_local_int + 1", substrs=["int", "= 323"])
+  //% self.expect("expr *tl_local_ptr + 2", substrs=["int", "= 324"])
+  //% self.expect("expr tl_global_int", substrs=["int", "= 123"])
+  //% self.expect("expr *tl_global_ptr", substrs=["int", "= 45"])
+  return 0;
+}


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


[Lldb-commits] [PATCH] D67067: Breakpad: Basic support for STACK WIN unwinding

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

We always need more tests. I've now added more tests for various boundary 
conditions.




Comment at: source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp:549
+  llvm::Optional record = StackWinRecord::parse(*It);
+  assert(record.hasValue());
+

amccarth wrote:
> Should we log and bail out rather than just assert?  A corrupt symbol file 
> shouldn't kill the debugger, right?
> 
> Also, it's Optional rather than Expected, so it seems even more plausible to 
> hit this.
This is an internal consistency check. An entry will be added to the 
`m_unwind_data->win` map only if it was already parsed successfully down in 
`ParseUnwindData`. This is parsing the same data once more, so it should always 
succeed.

Now the next question is, why parse the same data twice? :)
The first parse is to build an index of the ranges covered by the breakpad 
file. In the second pass we actually parse the undwind data. Theoretically we 
could avoid the second parse if we stored more data in the first one. However, 
here I am operating under the assumption that most record will not be touched, 
so it's worth to save some space for *each* record for the price of having to 
parse twice *some* of them. This seems like a good tradeoff intuitively, but I 
am don't have hard data to back that up.

Also, the case was much stronger for STACK CFI records (which do the same 
thing), as there I only have to put the STACK CFI INIT records into the map 
(and each INIT record is followed by a potentially large number of non-INIT 
records). STACK WIN records don't have an INIT records, so I have to insert all 
of them anyway, which makes the savings smaller, but it still seems worth it.


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

https://reviews.llvm.org/D67067



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


[Lldb-commits] [PATCH] D67067: Breakpad: Basic support for STACK WIN unwinding

2019-09-04 Thread Pavel Labath via Phabricator via lldb-commits
labath updated this revision to Diff 218611.
labath marked 3 inline comments as done.
labath added a comment.

add more tests


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

https://reviews.llvm.org/D67067

Files:
  lit/SymbolFile/Breakpad/Inputs/unwind-via-stack-win.syms
  lit/SymbolFile/Breakpad/Inputs/unwind-via-stack-win.yaml
  lit/SymbolFile/Breakpad/unwind-via-stack-win.test
  source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
  source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h

Index: source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
===
--- source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
+++ source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
@@ -12,6 +12,7 @@
 #include "Plugins/ObjectFile/Breakpad/BreakpadRecords.h"
 #include "lldb/Core/FileSpecList.h"
 #include "lldb/Symbol/LineTable.h"
+#include "lldb/Symbol/PostfixExpression.h"
 #include "lldb/Symbol/SymbolFile.h"
 #include "lldb/Symbol/UnwindPlan.h"
 
@@ -204,9 +205,14 @@
   void ParseCUData();
   void ParseLineTableAndSupportFiles(CompileUnit &cu, CompUnitData &data);
   void ParseUnwindData();
-  bool ParseUnwindRow(llvm::StringRef unwind_rules,
-  const RegisterInfoResolver &resolver,
-  UnwindPlan::Row &row);
+  llvm::ArrayRef SaveAsDWARF(postfix::Node &node);
+  lldb::UnwindPlanSP ParseCFIUnwindPlan(const Bookmark &bookmark,
+const RegisterInfoResolver &resolver);
+  bool ParseCFIUnwindRow(llvm::StringRef unwind_rules,
+ const RegisterInfoResolver &resolver,
+ UnwindPlan::Row &row);
+  lldb::UnwindPlanSP ParseWinUnwindPlan(const Bookmark &bookmark,
+const RegisterInfoResolver &resolver);
 
   using CompUnitMap = RangeDataVector;
 
@@ -214,7 +220,11 @@
   llvm::Optional m_cu_data;
 
   using UnwindMap = RangeDataVector;
-  llvm::Optional m_unwind_data;
+  struct UnwindData {
+UnwindMap cfi;
+UnwindMap win;
+  };
+  llvm::Optional m_unwind_data;
   llvm::BumpPtrAllocator m_allocator;
 };
 
Index: source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
===
--- source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
+++ source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
@@ -15,7 +15,6 @@
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Symbol/CompileUnit.h"
 #include "lldb/Symbol/ObjectFile.h"
-#include "lldb/Symbol/PostfixExpression.h"
 #include "lldb/Symbol/SymbolVendor.h"
 #include "lldb/Symbol/TypeMap.h"
 #include "lldb/Utility/Log.h"
@@ -421,7 +420,17 @@
   return ResolveRegister(resolver, name);
 }
 
-bool SymbolFileBreakpad::ParseUnwindRow(llvm::StringRef unwind_rules,
+llvm::ArrayRef SymbolFileBreakpad::SaveAsDWARF(postfix::Node &node) {
+  ArchSpec arch = m_objfile_sp->GetArchitecture();
+  StreamString dwarf(Stream::eBinary, arch.GetAddressByteSize(),
+ arch.GetByteOrder());
+  ToDWARF(node, dwarf);
+  uint8_t *saved = m_allocator.Allocate(dwarf.GetSize());
+  std::memcpy(saved, dwarf.GetData(), dwarf.GetSize());
+  return {saved, dwarf.GetSize()};
+}
+
+bool SymbolFileBreakpad::ParseCFIUnwindRow(llvm::StringRef unwind_rules,
 const RegisterInfoResolver &resolver,
 UnwindPlan::Row &row) {
   Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_SYMBOLS);
@@ -454,18 +463,12 @@
   return false;
 }
 
-ArchSpec arch = m_objfile_sp->GetArchitecture();
-StreamString dwarf(Stream::eBinary, arch.GetAddressByteSize(),
-   arch.GetByteOrder());
-ToDWARF(*rhs, dwarf);
-uint8_t *saved = m_allocator.Allocate(dwarf.GetSize());
-std::memcpy(saved, dwarf.GetData(), dwarf.GetSize());
-
+llvm::ArrayRef saved = SaveAsDWARF(*rhs);
 if (lhs == ".cfa") {
-  row.GetCFAValue().SetIsDWARFExpression(saved, dwarf.GetSize());
+  row.GetCFAValue().SetIsDWARFExpression(saved.data(), saved.size());
 } else if (const RegisterInfo *info = ResolveRegisterOrRA(resolver, lhs)) {
   UnwindPlan::Row::RegisterLocation loc;
-  loc.SetIsDWARFExpression(saved, dwarf.GetSize());
+  loc.SetIsDWARFExpression(saved.data(), saved.size());
   row.SetRegisterInfo(info->kinds[eRegisterKindLLDB], loc);
 } else
   LLDB_LOG(log, "Invalid register `{0}` in unwind rule.", lhs);
@@ -481,16 +484,23 @@
 SymbolFileBreakpad::GetUnwindPlan(const Address &address,
   const RegisterInfoResolver &resolver) {
   ParseUnwindData();
-  const UnwindMap::Entry *entry =
-  m_unwind_data->FindEntryThatContains(address.GetFileAddress());
-  if (!entry)
-return nullptr;
+  if (auto *entry =
+  m_unwind_data->cfi.FindEntryThatContains(address.GetFileAddress()))
+return ParseCFIUnwindPlan(entry->data, resolver);

[Lldb-commits] [lldb] r370854 - [lldb][NFC] Remove WriteRegister copy-pasta from ObjectFileMachO

2019-09-04 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Wed Sep  4 02:10:28 2019
New Revision: 370854

URL: http://llvm.org/viewvc/llvm-project?rev=370854&view=rev
Log:
[lldb][NFC] Remove WriteRegister copy-pasta from ObjectFileMachO

The function had the same name as one of the member function, so
it was just copied to all classes so that the lookup works. We
could also give the function a more better and unique name
(because it's actually printing the register value and writing
to the stream, not writing to the register).

Also removes the unused return value.

Modified:
lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp

Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=370854&r1=370853&r2=370854&view=diff
==
--- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Wed Sep  4 
02:10:28 2019
@@ -108,6 +108,31 @@ struct lldb_copy_dyld_cache_local_symbol
   uint32_t nlistCount;
 };
 
+static void ReadRegisterValue(RegisterContext *reg_ctx, const char *name,
+  const char *alt_name, size_t reg_byte_size,
+  Stream &data) {
+  const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName(name);
+  if (reg_info == nullptr)
+reg_info = reg_ctx->GetRegisterInfoByName(alt_name);
+  if (reg_info) {
+lldb_private::RegisterValue reg_value;
+if (reg_ctx->ReadRegister(reg_info, reg_value)) {
+  if (reg_info->byte_size >= reg_byte_size)
+data.Write(reg_value.GetBytes(), reg_byte_size);
+  else {
+data.Write(reg_value.GetBytes(), reg_info->byte_size);
+for (size_t i = 0, n = reg_byte_size - reg_info->byte_size; i < n;
+ ++i)
+  data.PutChar(0);
+  }
+  return;
+}
+  }
+  // Just write zeros if all else fails
+  for (size_t i = 0; i < reg_byte_size; ++i)
+data.PutChar(0);
+}
+
 class RegisterContextDarwin_x86_64_Mach : public RegisterContextDarwin_x86_64 {
 public:
   RegisterContextDarwin_x86_64_Mach(lldb_private::Thread &thread,
@@ -169,32 +194,6 @@ public:
 }
   }
 
-  static size_t WriteRegister(RegisterContext *reg_ctx, const char *name,
-  const char *alt_name, size_t reg_byte_size,
-  Stream &data) {
-const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName(name);
-if (reg_info == nullptr)
-  reg_info = reg_ctx->GetRegisterInfoByName(alt_name);
-if (reg_info) {
-  lldb_private::RegisterValue reg_value;
-  if (reg_ctx->ReadRegister(reg_info, reg_value)) {
-if (reg_info->byte_size >= reg_byte_size)
-  data.Write(reg_value.GetBytes(), reg_byte_size);
-else {
-  data.Write(reg_value.GetBytes(), reg_info->byte_size);
-  for (size_t i = 0, n = reg_byte_size - reg_info->byte_size; i < n;
-   ++i)
-data.PutChar(0);
-}
-return reg_byte_size;
-  }
-}
-// Just write zeros if all else fails
-for (size_t i = 0; i < reg_byte_size; ++i)
-  data.PutChar(0);
-return reg_byte_size;
-  }
-
   static bool Create_LC_THREAD(Thread *thread, Stream &data) {
 RegisterContextSP reg_ctx_sp(thread->GetRegisterContext());
 if (reg_ctx_sp) {
@@ -202,27 +201,27 @@ public:
 
   data.PutHex32(GPRRegSet); // Flavor
   data.PutHex32(GPRWordCount);
-  WriteRegister(reg_ctx, "rax", nullptr, 8, data);
-  WriteRegister(reg_ctx, "rbx", nullptr, 8, data);
-  WriteRegister(reg_ctx, "rcx", nullptr, 8, data);
-  WriteRegister(reg_ctx, "rdx", nullptr, 8, data);
-  WriteRegister(reg_ctx, "rdi", nullptr, 8, data);
-  WriteRegister(reg_ctx, "rsi", nullptr, 8, data);
-  WriteRegister(reg_ctx, "rbp", nullptr, 8, data);
-  WriteRegister(reg_ctx, "rsp", nullptr, 8, data);
-  WriteRegister(reg_ctx, "r8", nullptr, 8, data);
-  WriteRegister(reg_ctx, "r9", nullptr, 8, data);
-  WriteRegister(reg_ctx, "r10", nullptr, 8, data);
-  WriteRegister(reg_ctx, "r11", nullptr, 8, data);
-  WriteRegister(reg_ctx, "r12", nullptr, 8, data);
-  WriteRegister(reg_ctx, "r13", nullptr, 8, data);
-  WriteRegister(reg_ctx, "r14", nullptr, 8, data);
-  WriteRegister(reg_ctx, "r15", nullptr, 8, data);
-  WriteRegister(reg_ctx, "rip", nullptr, 8, data);
-  WriteRegister(reg_ctx, "rflags", nullptr, 8, data);
-  WriteRegister(reg_ctx, "cs", nullptr, 8, data);
-  WriteRegister(reg_ctx, "fs", nullptr, 8, data);
-  WriteRegister(reg_ctx, "gs", nullptr, 8, data);
+  ReadRegisterValue(reg_ctx, "rax", nullptr, 8, data);
+  ReadRegisterValue(reg_ctx, "rbx", nullptr, 8, data);
+  ReadRegisterValue(reg_ctx, "rcx", nullptr, 8, data);
+  ReadRegisterValue(reg_ctx, "rdx", nullptr, 8, da

[Lldb-commits] [lldb] r370856 - [lldb][NFC] Rename ReadRegisterValue to PrintRegisterValue

2019-09-04 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Wed Sep  4 02:18:10 2019
New Revision: 370856

URL: http://llvm.org/viewvc/llvm-project?rev=370856&view=rev
Log:
[lldb][NFC] Rename ReadRegisterValue to PrintRegisterValue

That was the actual name I had in mind, but it seems git didn't pick
that change up when committing my previous commit.

Modified:
lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp

Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=370856&r1=370855&r2=370856&view=diff
==
--- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Wed Sep  4 
02:18:10 2019
@@ -108,7 +108,7 @@ struct lldb_copy_dyld_cache_local_symbol
   uint32_t nlistCount;
 };
 
-static void ReadRegisterValue(RegisterContext *reg_ctx, const char *name,
+static void PrintRegisterValue(RegisterContext *reg_ctx, const char *name,
   const char *alt_name, size_t reg_byte_size,
   Stream &data) {
   const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName(name);
@@ -201,27 +201,27 @@ public:
 
   data.PutHex32(GPRRegSet); // Flavor
   data.PutHex32(GPRWordCount);
-  ReadRegisterValue(reg_ctx, "rax", nullptr, 8, data);
-  ReadRegisterValue(reg_ctx, "rbx", nullptr, 8, data);
-  ReadRegisterValue(reg_ctx, "rcx", nullptr, 8, data);
-  ReadRegisterValue(reg_ctx, "rdx", nullptr, 8, data);
-  ReadRegisterValue(reg_ctx, "rdi", nullptr, 8, data);
-  ReadRegisterValue(reg_ctx, "rsi", nullptr, 8, data);
-  ReadRegisterValue(reg_ctx, "rbp", nullptr, 8, data);
-  ReadRegisterValue(reg_ctx, "rsp", nullptr, 8, data);
-  ReadRegisterValue(reg_ctx, "r8", nullptr, 8, data);
-  ReadRegisterValue(reg_ctx, "r9", nullptr, 8, data);
-  ReadRegisterValue(reg_ctx, "r10", nullptr, 8, data);
-  ReadRegisterValue(reg_ctx, "r11", nullptr, 8, data);
-  ReadRegisterValue(reg_ctx, "r12", nullptr, 8, data);
-  ReadRegisterValue(reg_ctx, "r13", nullptr, 8, data);
-  ReadRegisterValue(reg_ctx, "r14", nullptr, 8, data);
-  ReadRegisterValue(reg_ctx, "r15", nullptr, 8, data);
-  ReadRegisterValue(reg_ctx, "rip", nullptr, 8, data);
-  ReadRegisterValue(reg_ctx, "rflags", nullptr, 8, data);
-  ReadRegisterValue(reg_ctx, "cs", nullptr, 8, data);
-  ReadRegisterValue(reg_ctx, "fs", nullptr, 8, data);
-  ReadRegisterValue(reg_ctx, "gs", nullptr, 8, data);
+  PrintRegisterValue(reg_ctx, "rax", nullptr, 8, data);
+  PrintRegisterValue(reg_ctx, "rbx", nullptr, 8, data);
+  PrintRegisterValue(reg_ctx, "rcx", nullptr, 8, data);
+  PrintRegisterValue(reg_ctx, "rdx", nullptr, 8, data);
+  PrintRegisterValue(reg_ctx, "rdi", nullptr, 8, data);
+  PrintRegisterValue(reg_ctx, "rsi", nullptr, 8, data);
+  PrintRegisterValue(reg_ctx, "rbp", nullptr, 8, data);
+  PrintRegisterValue(reg_ctx, "rsp", nullptr, 8, data);
+  PrintRegisterValue(reg_ctx, "r8", nullptr, 8, data);
+  PrintRegisterValue(reg_ctx, "r9", nullptr, 8, data);
+  PrintRegisterValue(reg_ctx, "r10", nullptr, 8, data);
+  PrintRegisterValue(reg_ctx, "r11", nullptr, 8, data);
+  PrintRegisterValue(reg_ctx, "r12", nullptr, 8, data);
+  PrintRegisterValue(reg_ctx, "r13", nullptr, 8, data);
+  PrintRegisterValue(reg_ctx, "r14", nullptr, 8, data);
+  PrintRegisterValue(reg_ctx, "r15", nullptr, 8, data);
+  PrintRegisterValue(reg_ctx, "rip", nullptr, 8, data);
+  PrintRegisterValue(reg_ctx, "rflags", nullptr, 8, data);
+  PrintRegisterValue(reg_ctx, "cs", nullptr, 8, data);
+  PrintRegisterValue(reg_ctx, "fs", nullptr, 8, data);
+  PrintRegisterValue(reg_ctx, "gs", nullptr, 8, data);
 
   //// Write out the FPU registers
   //const size_t fpu_byte_size = sizeof(FPU);
@@ -310,9 +310,9 @@ public:
   // Write out the EXC registers
   data.PutHex32(EXCRegSet);
   data.PutHex32(EXCWordCount);
-  ReadRegisterValue(reg_ctx, "trapno", nullptr, 4, data);
-  ReadRegisterValue(reg_ctx, "err", nullptr, 4, data);
-  ReadRegisterValue(reg_ctx, "faultvaddr", nullptr, 8, data);
+  PrintRegisterValue(reg_ctx, "trapno", nullptr, 4, data);
+  PrintRegisterValue(reg_ctx, "err", nullptr, 4, data);
+  PrintRegisterValue(reg_ctx, "faultvaddr", nullptr, 8, data);
   return true;
 }
 return false;
@@ -406,29 +406,29 @@ public:
 
   data.PutHex32(GPRRegSet); // Flavor
   data.PutHex32(GPRWordCount);
-  ReadRegisterValue(reg_ctx, "eax", nullptr, 4, data);
-  ReadRegisterValue(reg_ctx, "ebx", nullptr, 4, data);
-  ReadRegisterValue(reg_ctx, "ecx", nullptr, 4, data);
-  ReadRegisterValue(reg_ctx, "edx", nullptr, 4, data);
-  ReadRe

[Lldb-commits] [lldb] r370858 - Port TestBatchMode to PExpectTest class

2019-09-04 Thread Pavel Labath via lldb-commits
Author: labath
Date: Wed Sep  4 02:20:08 2019
New Revision: 370858

URL: http://llvm.org/viewvc/llvm-project?rev=370858&view=rev
Log:
Port TestBatchMode to PExpectTest class

Summary:
I'm doing this mainly for consistency, but there are also other cleanups
that will be enabled by this (e.g., the automatic setting of
clang-modules-cache-path setting).

Reviewers: teemperor, JDevlieghere

Subscribers: lldb-commits

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

Modified:
lldb/trunk/packages/Python/lldbsuite/test/driver/batch_mode/TestBatchMode.py
lldb/trunk/packages/Python/lldbsuite/test/lldbpexpect.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/driver/batch_mode/TestBatchMode.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/driver/batch_mode/TestBatchMode.py?rev=370858&r1=370857&r2=370858&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/driver/batch_mode/TestBatchMode.py 
(original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/driver/batch_mode/TestBatchMode.py 
Wed Sep  4 02:20:08 2019
@@ -9,102 +9,78 @@ import lldb
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
+from lldbsuite.test.lldbpexpect import PExpectTest
 
 
-class DriverBatchModeTest (TestBase):
+class DriverBatchModeTest(PExpectTest):
 
 mydir = TestBase.compute_mydir(__file__)
-
-def setUp(self):
-# Call super's setUp().
-TestBase.setUp(self)
-# Our simple source filename.
-self.source = 'main.c'
-self.victim = None
-
-def expect_string(self, string):
-import pexpect
-"""This expects for "string", with timeout & EOF being test fails."""
-try:
-self.child.expect_exact(string)
-except pexpect.EOF:
-self.fail("Got EOF waiting for '%s'" % (string))
-except pexpect.TIMEOUT:
-self.fail("Timed out waiting for '%s'" % (string))
+source = 'main.c'
 
 @skipIfRemote  # test not remote-ready llvm.org/pr24813
 @expectedFlakeyFreeBSD("llvm.org/pr25172 fails rarely on the buildbot")
-@expectedFlakeyLinux("llvm.org/pr25172")
-@expectedFailureAll(
-oslist=["windows"],
-bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
 def test_batch_mode_run_crash(self):
 """Test that the lldb driver's batch mode works correctly."""
 self.build()
-self.setTearDownCleanup()
 
-import pexpect
 exe = self.getBuildArtifact("a.out")
 module_cache = self.getBuildArtifact("module.cache")
-prompt = "(lldb) "
 
 # Pass CRASH so the process will crash and stop in batch mode.
-run_commands = ' -b -o "settings set symbols.clang-modules-cache-path 
%s" -o "break set -n main" -o "run" -o "continue" -k "frame var touch_me_not"' 
% module_cache
-self.child = pexpect.spawn(
-'%s %s %s %s -- CRASH' %
-(lldbtest_config.lldbExec, self.lldbOption, run_commands, exe))
+extra_args = ['-b',
+'-o', "settings set symbols.clang-modules-cache-path 
'%s'"%module_cache,
+'-o', 'break set -n main',
+'-o', 'run',
+'-o', 'continue',
+'-k', 'frame var touch_me_not',
+'--', 'CRASH',
+]
+self.launch(executable=exe, extra_args=extra_args)
 child = self.child
 
 # We should see the "run":
-self.expect_string("run")
+child.expect_exact("run")
 # We should have hit the breakpoint & continued:
-self.expect_string("continue")
+child.expect_exact("continue")
 # The App should have crashed:
-self.expect_string("About to crash")
+child.expect_exact("About to crash")
 # The -k option should have printed the frame variable once:
-self.expect_string('(char *) touch_me_not')
+child.expect_exact('(char *) touch_me_not')
 # Then we should have a live prompt:
-self.expect_string(prompt)
-self.child.sendline("frame variable touch_me_not")
-self.expect_string('(char *) touch_me_not')
-
-self.deletePexpectChild()
+self.expect_prompt()
+self.expect("frame variable touch_me_not", substrs='(char *) 
touch_me_not')
 
 @skipIfRemote  # test not remote-ready llvm.org/pr24813
 @expectedFlakeyFreeBSD("llvm.org/pr25172 fails rarely on the buildbot")
-@expectedFlakeyLinux("llvm.org/pr25172")
-@expectedFailureAll(
-oslist=["windows"],
-bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
 def test_batch_mode_run_exit(self):
 """Test that the lldb driver's batch mode works correctly."""
 self.build()
-self.setTearDownCleanup()
 
-import pexpect
 exe = self.getBuildArtifact("a.out")
 mod

[Lldb-commits] [PATCH] D66791: [lldb][ELF] Read symbols from .gnu_debugdata sect.

2019-09-04 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 218618.
kwk marked an inline comment as done.
kwk added a comment.
Herald added a reviewer: alexshap.

- add lit test for minidebuginfo
- Fixup
- test
- Fiddle with the lit test
- Fix binary in lit test
- Working lit test - still need to only run it when minidebuginfo is available 
(LZMA)
- Make FileCheck less verbose
- Only run minidebuginfo lit test when lzma is available
- fix mylib.so not found problem
- Removed old python based minidebuginfo test
- Remove changes that were only necessary for the old python based test for 
minidebuginfo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66791

Files:
  lldb/CMakeLists.txt
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/include/lldb/Host/Config.h.cmake
  lldb/include/lldb/Host/LZMA.h
  lldb/lit/Breakpoint/Inputs/minidebuginfo-lib.c
  lldb/lit/Breakpoint/Inputs/minidebuginfo-lib.h
  lldb/lit/Breakpoint/Inputs/minidebuginfo-main.c
  lldb/lit/Breakpoint/minidebuginfo.test
  lldb/lit/CMakeLists.txt
  lldb/lit/lit.cfg.py
  lldb/lit/lit.site.cfg.py.in
  lldb/source/Host/CMakeLists.txt
  lldb/source/Host/common/LZMA.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h

Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
@@ -208,6 +208,10 @@
   /// Collection of symbols from the dynamic table.
   DynamicSymbolColl m_dynamic_symbols;
 
+  /// Object file parsed from .gnu_debugdata section (\sa
+  /// GetGnuDebugDataObjectFile())
+  std::shared_ptr m_gnu_debug_data_object_file;
+
   /// List of file specifications corresponding to the modules (shared
   /// libraries) on which this object file depends.
   mutable std::unique_ptr m_filespec_up;
@@ -383,6 +387,14 @@
   lldb_private::UUID &uuid);
 
   bool AnySegmentHasPhysicalAddress();
+  
+  /// Takes the .gnu_debugdata and returns the decompressed object file that is
+  /// stored within that section.
+  ///
+  /// \returns either the decompressed object file stored within the
+  /// .gnu_debugdata section or \c nullptr if an error occured or if there's no
+  /// section with that name.
+  std::shared_ptr GetGnuDebugDataObjectFile();
 };
 
 #endif // liblldb_ObjectFileELF_h_
Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -18,6 +18,7 @@
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Core/Section.h"
 #include "lldb/Host/FileSystem.h"
+#include "lldb/Host/LZMA.h"
 #include "lldb/Symbol/DWARFCallFrameInfo.h"
 #include "lldb/Symbol/SymbolContext.h"
 #include "lldb/Target/SectionLoadList.h"
@@ -1842,6 +1843,72 @@
   // unified section list.
   if (GetType() != eTypeDebugInfo)
 unified_section_list = *m_sections_up;
+  
+  // If there's a .gnu_debugdata section, we'll try to read the .symtab that's
+  // embedded in there and replace the one in the original object file (if any).
+  // If there's none in the orignal object file, we add it to it.
+  SectionList *module_section_list = GetModule()->GetSectionList();
+  if (auto gdd_obj_file = GetGnuDebugDataObjectFile()) {
+if (auto gdd_objfile_section_list = gdd_obj_file->GetSectionList()) {
+  if (SectionSP symtab_section_sp =
+  gdd_objfile_section_list->FindSectionByType(
+  eSectionTypeELFSymbolTable, true)) {
+SectionSP module_section_sp = module_section_list->FindSectionByType(
+eSectionTypeELFSymbolTable, true);
+if (module_section_sp)
+  module_section_list->ReplaceSection(module_section_sp->GetID(),
+  symtab_section_sp);
+else
+  module_section_list->AddSection(symtab_section_sp);
+  }
+}
+  }  
+}
+
+std::shared_ptr ObjectFileELF::GetGnuDebugDataObjectFile() {
+  if (m_gnu_debug_data_object_file != nullptr)
+return m_gnu_debug_data_object_file;
+
+  SectionSP section =
+  GetSectionList()->FindSectionByName(ConstString(".gnu_debugdata"));
+  if (!section)
+return nullptr;
+
+  if (!lldb_private::lzma::isAvailable()) {
+GetModule()->ReportWarning(
+"No LZMA support found for reading .gnu_debugdata section");
+return nullptr;
+  }
+
+  // Uncompress the data
+  DataExtractor data;
+  section->GetSectionData(data);
+  llvm::ArrayRef compressedData(data.GetDataStart(), data.GetByteSize());
+  llvm::SmallVector uncompressedData;
+  auto err = lldb_private::lzma::uncompress(compressedData, uncompressedData);
+  if (err) {
+GetModule()->ReportWarning(
+"An error occured while decompression the section %s: %s",

[Lldb-commits] [PATCH] D67082: Port TestBatchMode to PExpectTest class

2019-09-04 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL370858: Port TestBatchMode to PExpectTest class (authored by 
labath, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67082

Files:
  lldb/trunk/packages/Python/lldbsuite/test/driver/batch_mode/TestBatchMode.py
  lldb/trunk/packages/Python/lldbsuite/test/lldbpexpect.py

Index: lldb/trunk/packages/Python/lldbsuite/test/lldbpexpect.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/lldbpexpect.py
+++ lldb/trunk/packages/Python/lldbsuite/test/lldbpexpect.py
@@ -27,7 +27,7 @@
 def expect_prompt(self):
 self.child.expect_exact(self.PROMPT)
 
-def launch(self, executable=None, timeout=30, dimensions=None):
+def launch(self, executable=None, extra_args=None, timeout=30, dimensions=None):
 logfile = getattr(sys.stdout, 'buffer',
   sys.stdout) if self.TraceOn() else None
 args = ['--no-lldbinit', '--no-use-colors']
@@ -35,6 +35,8 @@
 args += ['-O', cmd]
 if executable is not None:
 args += ['--file', executable]
+if extra_args is not None:
+args.extend(extra_args)
 self.child = pexpect.spawn(
 lldbtest_config.lldbExec, args=args, logfile=logfile,
 timeout=timeout, dimensions=dimensions)
Index: lldb/trunk/packages/Python/lldbsuite/test/driver/batch_mode/TestBatchMode.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/driver/batch_mode/TestBatchMode.py
+++ lldb/trunk/packages/Python/lldbsuite/test/driver/batch_mode/TestBatchMode.py
@@ -9,102 +9,78 @@
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
+from lldbsuite.test.lldbpexpect import PExpectTest
 
 
-class DriverBatchModeTest (TestBase):
+class DriverBatchModeTest(PExpectTest):
 
 mydir = TestBase.compute_mydir(__file__)
-
-def setUp(self):
-# Call super's setUp().
-TestBase.setUp(self)
-# Our simple source filename.
-self.source = 'main.c'
-self.victim = None
-
-def expect_string(self, string):
-import pexpect
-"""This expects for "string", with timeout & EOF being test fails."""
-try:
-self.child.expect_exact(string)
-except pexpect.EOF:
-self.fail("Got EOF waiting for '%s'" % (string))
-except pexpect.TIMEOUT:
-self.fail("Timed out waiting for '%s'" % (string))
+source = 'main.c'
 
 @skipIfRemote  # test not remote-ready llvm.org/pr24813
 @expectedFlakeyFreeBSD("llvm.org/pr25172 fails rarely on the buildbot")
-@expectedFlakeyLinux("llvm.org/pr25172")
-@expectedFailureAll(
-oslist=["windows"],
-bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
 def test_batch_mode_run_crash(self):
 """Test that the lldb driver's batch mode works correctly."""
 self.build()
-self.setTearDownCleanup()
 
-import pexpect
 exe = self.getBuildArtifact("a.out")
 module_cache = self.getBuildArtifact("module.cache")
-prompt = "(lldb) "
 
 # Pass CRASH so the process will crash and stop in batch mode.
-run_commands = ' -b -o "settings set symbols.clang-modules-cache-path %s" -o "break set -n main" -o "run" -o "continue" -k "frame var touch_me_not"' % module_cache
-self.child = pexpect.spawn(
-'%s %s %s %s -- CRASH' %
-(lldbtest_config.lldbExec, self.lldbOption, run_commands, exe))
+extra_args = ['-b',
+'-o', "settings set symbols.clang-modules-cache-path '%s'"%module_cache,
+'-o', 'break set -n main',
+'-o', 'run',
+'-o', 'continue',
+'-k', 'frame var touch_me_not',
+'--', 'CRASH',
+]
+self.launch(executable=exe, extra_args=extra_args)
 child = self.child
 
 # We should see the "run":
-self.expect_string("run")
+child.expect_exact("run")
 # We should have hit the breakpoint & continued:
-self.expect_string("continue")
+child.expect_exact("continue")
 # The App should have crashed:
-self.expect_string("About to crash")
+child.expect_exact("About to crash")
 # The -k option should have printed the frame variable once:
-self.expect_string('(char *) touch_me_not')
+child.expect_exact('(char *) touch_me_not')
 # Then we should have a live prompt:
-self.expect_string(prompt)
-self.child.sendline("frame variable touch_me_not")
-self

[Lldb-commits] [PATCH] D66791: [lldb][ELF] Read symbols from .gnu_debugdata sect.

2019-09-04 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 218621.
kwk added a comment.

- remove not needed  include


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66791

Files:
  lldb/CMakeLists.txt
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/include/lldb/Host/Config.h.cmake
  lldb/include/lldb/Host/LZMA.h
  lldb/lit/Breakpoint/Inputs/minidebuginfo-lib.c
  lldb/lit/Breakpoint/Inputs/minidebuginfo-lib.h
  lldb/lit/Breakpoint/Inputs/minidebuginfo-main.c
  lldb/lit/Breakpoint/minidebuginfo.test
  lldb/lit/CMakeLists.txt
  lldb/lit/lit.cfg.py
  lldb/lit/lit.site.cfg.py.in
  lldb/source/Host/CMakeLists.txt
  lldb/source/Host/common/LZMA.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h

Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
@@ -208,6 +208,10 @@
   /// Collection of symbols from the dynamic table.
   DynamicSymbolColl m_dynamic_symbols;
 
+  /// Object file parsed from .gnu_debugdata section (\sa
+  /// GetGnuDebugDataObjectFile())
+  std::shared_ptr m_gnu_debug_data_object_file;
+
   /// List of file specifications corresponding to the modules (shared
   /// libraries) on which this object file depends.
   mutable std::unique_ptr m_filespec_up;
@@ -383,6 +387,14 @@
   lldb_private::UUID &uuid);
 
   bool AnySegmentHasPhysicalAddress();
+  
+  /// Takes the .gnu_debugdata and returns the decompressed object file that is
+  /// stored within that section.
+  ///
+  /// \returns either the decompressed object file stored within the
+  /// .gnu_debugdata section or \c nullptr if an error occured or if there's no
+  /// section with that name.
+  std::shared_ptr GetGnuDebugDataObjectFile();
 };
 
 #endif // liblldb_ObjectFileELF_h_
Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -18,6 +18,7 @@
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Core/Section.h"
 #include "lldb/Host/FileSystem.h"
+#include "lldb/Host/LZMA.h"
 #include "lldb/Symbol/DWARFCallFrameInfo.h"
 #include "lldb/Symbol/SymbolContext.h"
 #include "lldb/Target/SectionLoadList.h"
@@ -1842,6 +1843,72 @@
   // unified section list.
   if (GetType() != eTypeDebugInfo)
 unified_section_list = *m_sections_up;
+  
+  // If there's a .gnu_debugdata section, we'll try to read the .symtab that's
+  // embedded in there and replace the one in the original object file (if any).
+  // If there's none in the orignal object file, we add it to it.
+  SectionList *module_section_list = GetModule()->GetSectionList();
+  if (auto gdd_obj_file = GetGnuDebugDataObjectFile()) {
+if (auto gdd_objfile_section_list = gdd_obj_file->GetSectionList()) {
+  if (SectionSP symtab_section_sp =
+  gdd_objfile_section_list->FindSectionByType(
+  eSectionTypeELFSymbolTable, true)) {
+SectionSP module_section_sp = module_section_list->FindSectionByType(
+eSectionTypeELFSymbolTable, true);
+if (module_section_sp)
+  module_section_list->ReplaceSection(module_section_sp->GetID(),
+  symtab_section_sp);
+else
+  module_section_list->AddSection(symtab_section_sp);
+  }
+}
+  }  
+}
+
+std::shared_ptr ObjectFileELF::GetGnuDebugDataObjectFile() {
+  if (m_gnu_debug_data_object_file != nullptr)
+return m_gnu_debug_data_object_file;
+
+  SectionSP section =
+  GetSectionList()->FindSectionByName(ConstString(".gnu_debugdata"));
+  if (!section)
+return nullptr;
+
+  if (!lldb_private::lzma::isAvailable()) {
+GetModule()->ReportWarning(
+"No LZMA support found for reading .gnu_debugdata section");
+return nullptr;
+  }
+
+  // Uncompress the data
+  DataExtractor data;
+  section->GetSectionData(data);
+  llvm::ArrayRef compressedData(data.GetDataStart(), data.GetByteSize());
+  llvm::SmallVector uncompressedData;
+  auto err = lldb_private::lzma::uncompress(compressedData, uncompressedData);
+  if (err) {
+GetModule()->ReportWarning(
+"An error occured while decompression the section %s: %s",
+section->GetName().AsCString(), llvm::toString(std::move(err)).c_str());
+return nullptr;
+  }
+
+  // Construct ObjectFileELF object from decompressed buffer
+  DataBufferSP gdd_data_buf(
+  new DataBufferHeap(uncompressedData.data(), uncompressedData.size()));
+  auto fspec = GetFileSpec().CopyByAppendingPathComponent(
+  llvm::StringRef("gnu_debugdata"));
+  m_gnu_debug_data_object_file.reset(new ObjectFileELF(
+  GetModule(), gdd_data_buf, 0, &fspec, 0, 

[Lldb-commits] [PATCH] D66791: [lldb][ELF] Read symbols from .gnu_debugdata sect.

2019-09-04 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 218623.
kwk added a comment.

squashed and rebased on top of master


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66791

Files:
  lldb/CMakeLists.txt
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/include/lldb/Host/Config.h.cmake
  lldb/include/lldb/Host/LZMA.h
  lldb/lit/Breakpoint/Inputs/minidebuginfo-lib.c
  lldb/lit/Breakpoint/Inputs/minidebuginfo-lib.h
  lldb/lit/Breakpoint/Inputs/minidebuginfo-main.c
  lldb/lit/Breakpoint/minidebuginfo.test
  lldb/lit/CMakeLists.txt
  lldb/lit/lit.cfg.py
  lldb/lit/lit.site.cfg.py.in
  lldb/source/Host/CMakeLists.txt
  lldb/source/Host/common/LZMA.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h

Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
@@ -208,6 +208,10 @@
   /// Collection of symbols from the dynamic table.
   DynamicSymbolColl m_dynamic_symbols;
 
+  /// Object file parsed from .gnu_debugdata section (\sa
+  /// GetGnuDebugDataObjectFile())
+  std::shared_ptr m_gnu_debug_data_object_file;
+
   /// List of file specifications corresponding to the modules (shared
   /// libraries) on which this object file depends.
   mutable std::unique_ptr m_filespec_up;
@@ -383,6 +387,14 @@
   lldb_private::UUID &uuid);
 
   bool AnySegmentHasPhysicalAddress();
+  
+  /// Takes the .gnu_debugdata and returns the decompressed object file that is
+  /// stored within that section.
+  ///
+  /// \returns either the decompressed object file stored within the
+  /// .gnu_debugdata section or \c nullptr if an error occured or if there's no
+  /// section with that name.
+  std::shared_ptr GetGnuDebugDataObjectFile();
 };
 
 #endif // liblldb_ObjectFileELF_h_
Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -18,6 +18,7 @@
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Core/Section.h"
 #include "lldb/Host/FileSystem.h"
+#include "lldb/Host/LZMA.h"
 #include "lldb/Symbol/DWARFCallFrameInfo.h"
 #include "lldb/Symbol/SymbolContext.h"
 #include "lldb/Target/SectionLoadList.h"
@@ -1842,6 +1843,72 @@
   // unified section list.
   if (GetType() != eTypeDebugInfo)
 unified_section_list = *m_sections_up;
+  
+  // If there's a .gnu_debugdata section, we'll try to read the .symtab that's
+  // embedded in there and replace the one in the original object file (if any).
+  // If there's none in the orignal object file, we add it to it.
+  SectionList *module_section_list = GetModule()->GetSectionList();
+  if (auto gdd_obj_file = GetGnuDebugDataObjectFile()) {
+if (auto gdd_objfile_section_list = gdd_obj_file->GetSectionList()) {
+  if (SectionSP symtab_section_sp =
+  gdd_objfile_section_list->FindSectionByType(
+  eSectionTypeELFSymbolTable, true)) {
+SectionSP module_section_sp = module_section_list->FindSectionByType(
+eSectionTypeELFSymbolTable, true);
+if (module_section_sp)
+  module_section_list->ReplaceSection(module_section_sp->GetID(),
+  symtab_section_sp);
+else
+  module_section_list->AddSection(symtab_section_sp);
+  }
+}
+  }  
+}
+
+std::shared_ptr ObjectFileELF::GetGnuDebugDataObjectFile() {
+  if (m_gnu_debug_data_object_file != nullptr)
+return m_gnu_debug_data_object_file;
+
+  SectionSP section =
+  GetSectionList()->FindSectionByName(ConstString(".gnu_debugdata"));
+  if (!section)
+return nullptr;
+
+  if (!lldb_private::lzma::isAvailable()) {
+GetModule()->ReportWarning(
+"No LZMA support found for reading .gnu_debugdata section");
+return nullptr;
+  }
+
+  // Uncompress the data
+  DataExtractor data;
+  section->GetSectionData(data);
+  llvm::ArrayRef compressedData(data.GetDataStart(), data.GetByteSize());
+  llvm::SmallVector uncompressedData;
+  auto err = lldb_private::lzma::uncompress(compressedData, uncompressedData);
+  if (err) {
+GetModule()->ReportWarning(
+"An error occured while decompression the section %s: %s",
+section->GetName().AsCString(), llvm::toString(std::move(err)).c_str());
+return nullptr;
+  }
+
+  // Construct ObjectFileELF object from decompressed buffer
+  DataBufferSP gdd_data_buf(
+  new DataBufferHeap(uncompressedData.data(), uncompressedData.size()));
+  auto fspec = GetFileSpec().CopyByAppendingPathComponent(
+  llvm::StringRef("gnu_debugdata"));
+  m_gnu_debug_data_object_file.reset(new ObjectFileELF(
+  GetModule(), gdd_data_buf, 0, &f

[Lldb-commits] [lldb] r370863 - Code cleanup: Change FormattersContainer::KeyType from SP to rvalue

2019-09-04 Thread Jan Kratochvil via lldb-commits
Author: jankratochvil
Date: Wed Sep  4 02:47:18 2019
New Revision: 370863

URL: http://llvm.org/viewvc/llvm-project?rev=370863&view=rev
Log:
Code cleanup: Change FormattersContainer::KeyType from SP to rvalue

There is now std::shared_ptr passed around which is expensive for manycore
CPUs. Most of the times (except for 3 cases) it is now just std::moved with no
CPU locks needed. It also makes it possible to sort the keys (which is now not
needed much after D66398).

Differential revision: https://reviews.llvm.org/D67049

Modified:
lldb/trunk/include/lldb/DataFormatters/FormattersContainer.h
lldb/trunk/include/lldb/DataFormatters/TypeCategory.h
lldb/trunk/include/lldb/Target/Target.h
lldb/trunk/include/lldb/Utility/RegularExpression.h
lldb/trunk/source/API/SBTarget.cpp
lldb/trunk/source/API/SBTypeCategory.cpp
lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp
lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp
lldb/trunk/source/Commands/CommandObjectType.cpp
lldb/trunk/source/DataFormatters/FormatManager.cpp
lldb/trunk/source/DataFormatters/FormattersHelpers.cpp
lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
lldb/trunk/source/Target/Target.cpp

Modified: lldb/trunk/include/lldb/DataFormatters/FormattersContainer.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/FormattersContainer.h?rev=370863&r1=370862&r2=370863&view=diff
==
--- lldb/trunk/include/lldb/DataFormatters/FormattersContainer.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/FormattersContainer.h Wed Sep  4 
02:47:18 2019
@@ -67,7 +67,7 @@ public:
   typedef typename ValueType::SharedPointer ValueSP;
   typedef std::map MapType;
   typedef typename MapType::iterator MapIterator;
-  typedef std::function ForEachCallback;
+  typedef std::function 
ForEachCallback;
 
   FormatMap(IFormatChangeListener *lst)
   : m_map(), m_map_mutex(), listener(lst) {}
@@ -79,7 +79,7 @@ public:
   entry->GetRevision() = 0;
 
 std::lock_guard guard(m_map_mutex);
-m_map[name] = entry;
+m_map[std::move(name)] = entry;
 if (listener)
   listener->Changed();
   }
@@ -116,7 +116,7 @@ public:
   std::lock_guard guard(m_map_mutex);
   MapIterator pos, end = m_map.end();
   for (pos = m_map.begin(); pos != end; pos++) {
-KeyType type = pos->first;
+const KeyType &type = pos->first;
 if (!callback(type, pos->second))
   break;
   }
@@ -138,6 +138,7 @@ public:
 return iter->second;
   }
 
+  // If caller holds the mutex we could return a reference without copy ctor.
   KeyType GetKeyAtIndex(size_t index) {
 std::lock_guard guard(m_map_mutex);
 MapIterator iter = m_map.begin();
@@ -182,8 +183,8 @@ public:
   FormattersContainer(std::string name, IFormatChangeListener *lst)
   : m_format_map(lst), m_name(name) {}
 
-  void Add(const MapKeyType &type, const MapValueType &entry) {
-Add_Impl(type, entry, static_cast(nullptr));
+  void Add(MapKeyType type, const MapValueType &entry) {
+Add_Impl(std::move(type), entry, static_cast(nullptr));
   }
 
   bool Delete(ConstString type) {
@@ -233,9 +234,9 @@ protected:
 
   DISALLOW_COPY_AND_ASSIGN(FormattersContainer);
 
-  void Add_Impl(const MapKeyType &type, const MapValueType &entry,
-lldb::RegularExpressionSP *dummy) {
-m_format_map.Add(type, entry);
+  void Add_Impl(MapKeyType type, const MapValueType &entry,
+RegularExpression *dummy) {
+m_format_map.Add(std::move(type), entry);
   }
 
   void Add_Impl(ConstString type, const MapValueType &entry,
@@ -247,12 +248,12 @@ protected:
 return m_format_map.Delete(type);
   }
 
-  bool Delete_Impl(ConstString type, lldb::RegularExpressionSP *dummy) {
+  bool Delete_Impl(ConstString type, RegularExpression *dummy) {
 std::lock_guard guard(m_format_map.mutex());
 MapIterator pos, end = m_format_map.map().end();
 for (pos = m_format_map.map().begin(); pos != end; pos++) {
-  lldb::RegularExpressionSP regex = pos->first;
-  if (type.GetStringRef() == regex->GetText()) {
+  const RegularExpression ®ex = pos->first;
+  if (type.GetStringRef() == regex.GetText()) {
 m_format_map.map().erase(pos);
 if (m_format_map.listener)
   m_format_map.listener->Changed();
@@ -282,23 +283,22 @@ protected:
   }
 
   lldb::TypeNameSpecifierImplSP
-  GetTypeNameSpecifierAtIndex_Impl(size_t index,
-   lldb::RegularExpressionSP *dummy) {
-lldb::RegularExpressionSP regex = m_format_map.GetKeyAtIndex(index);
-if (regex.get() == nullptr)
+  GetTypeNameSpecifierAtIndex_Impl(size_t index, RegularExpression *dummy) {
+RegularExpression regex = m_format_map.GetKeyAtIndex(index);
+if (regex == RegularExpression())
   return lldb::TypeNameSpecifierImplSP();
 return lldb::TypeNameSpec

[Lldb-commits] [PATCH] D67049: 1/2: Code cleanup: Change FormattersContainer::KeyType from SP to rvalue

2019-09-04 Thread Jan Kratochvil via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL370863: Code cleanup: Change FormattersContainer::KeyType 
from SP to rvalue (authored by jankratochvil, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67049?vs=218263&id=218626#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67049

Files:
  lldb/trunk/include/lldb/DataFormatters/FormattersContainer.h
  lldb/trunk/include/lldb/DataFormatters/TypeCategory.h
  lldb/trunk/include/lldb/Target/Target.h
  lldb/trunk/include/lldb/Utility/RegularExpression.h
  lldb/trunk/source/API/SBTarget.cpp
  lldb/trunk/source/API/SBTypeCategory.cpp
  lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp
  lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp
  lldb/trunk/source/Commands/CommandObjectType.cpp
  lldb/trunk/source/DataFormatters/FormatManager.cpp
  lldb/trunk/source/DataFormatters/FormattersHelpers.cpp
  lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  lldb/trunk/source/Target/Target.cpp

Index: lldb/trunk/include/lldb/Utility/RegularExpression.h
===
--- lldb/trunk/include/lldb/Utility/RegularExpression.h
+++ lldb/trunk/include/lldb/Utility/RegularExpression.h
@@ -78,6 +78,14 @@
   /// otherwise.
   llvm::Error GetError() const;
 
+  bool operator<(const RegularExpression &rhs) const {
+return GetText() < rhs.GetText();
+  }
+
+  bool operator==(const RegularExpression &rhs) const {
+return GetText() == rhs.GetText();
+  }
+
 private:
   /// A copy of the original regular expression text.
   std::string m_regex_text;
Index: lldb/trunk/include/lldb/Target/Target.h
===
--- lldb/trunk/include/lldb/Target/Target.h
+++ lldb/trunk/include/lldb/Target/Target.h
@@ -598,7 +598,7 @@
   const FileSpecList *containingModules,
   const FileSpecList *source_file_list,
   const std::unordered_set &function_names,
-  RegularExpression &source_regex, bool internal, bool request_hardware,
+  RegularExpression source_regex, bool internal, bool request_hardware,
   LazyBool move_to_nearest_code);
 
   // Use this to create a breakpoint from a load address
@@ -621,7 +621,7 @@
   // target setting, else we use the values passed in
   lldb::BreakpointSP CreateFuncRegexBreakpoint(
   const FileSpecList *containingModules,
-  const FileSpecList *containingSourceFiles, RegularExpression &func_regexp,
+  const FileSpecList *containingSourceFiles, RegularExpression func_regexp,
   lldb::LanguageType requested_language, LazyBool skip_prologue,
   bool internal, bool request_hardware);
 
Index: lldb/trunk/include/lldb/DataFormatters/FormattersContainer.h
===
--- lldb/trunk/include/lldb/DataFormatters/FormattersContainer.h
+++ lldb/trunk/include/lldb/DataFormatters/FormattersContainer.h
@@ -67,7 +67,7 @@
   typedef typename ValueType::SharedPointer ValueSP;
   typedef std::map MapType;
   typedef typename MapType::iterator MapIterator;
-  typedef std::function ForEachCallback;
+  typedef std::function ForEachCallback;
 
   FormatMap(IFormatChangeListener *lst)
   : m_map(), m_map_mutex(), listener(lst) {}
@@ -79,7 +79,7 @@
   entry->GetRevision() = 0;
 
 std::lock_guard guard(m_map_mutex);
-m_map[name] = entry;
+m_map[std::move(name)] = entry;
 if (listener)
   listener->Changed();
   }
@@ -116,7 +116,7 @@
   std::lock_guard guard(m_map_mutex);
   MapIterator pos, end = m_map.end();
   for (pos = m_map.begin(); pos != end; pos++) {
-KeyType type = pos->first;
+const KeyType &type = pos->first;
 if (!callback(type, pos->second))
   break;
   }
@@ -138,6 +138,7 @@
 return iter->second;
   }
 
+  // If caller holds the mutex we could return a reference without copy ctor.
   KeyType GetKeyAtIndex(size_t index) {
 std::lock_guard guard(m_map_mutex);
 MapIterator iter = m_map.begin();
@@ -182,8 +183,8 @@
   FormattersContainer(std::string name, IFormatChangeListener *lst)
   : m_format_map(lst), m_name(name) {}
 
-  void Add(const MapKeyType &type, const MapValueType &entry) {
-Add_Impl(type, entry, static_cast(nullptr));
+  void Add(MapKeyType type, const MapValueType &entry) {
+Add_Impl(std::move(type), entry, static_cast(nullptr));
   }
 
   bool Delete(ConstString type) {
@@ -233,9 +234,9 @@
 
   DISALLOW_COPY_AND_ASSIGN(FormattersContainer);
 
-  void Add_Impl(const MapKeyType &type, const MapValueType &entry,
-lldb::RegularExpressionSP *dummy) {
-m_format_map.Add(type, entry);
+  void Add_Impl(MapKeyType type, const MapValueType &entry,
+RegularExpression *dummy) {
+m_format_map.Add(st

[Lldb-commits] [PATCH] D66791: [lldb][ELF] Read symbols from .gnu_debugdata sect.

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

I think we're getting pretty close. I have a couple of extra comments inline, 
but they're all pretty minor, I hope. I'd just like to add some more tests, per 
our discussion on the IRC, and I have some doubts about what exactly is the 
test you've written actually testing, which I'd like to clarify...




Comment at: lldb/CMakeLists.txt:101
 
-  set(LLDB_TEST_DEPS lldb)
+  set(LLDB_TEST_DEPS lldb llvm-nm llvm-strip)
 

It looks like you're already adding these in `lldb/lit/CMakeLists.txt`. Does it 
need to be in both?



Comment at: lldb/include/lldb/Host/LZMA.h:24-25
+
+llvm::Error getUncompressedSize(llvm::ArrayRef InputBuffer,
+uint64_t &uncompressedSize);
+

Now that the vector is auto-resized, do you think it's still useful to expose 
the `getUncompressedSize` function as public api? If yes, then please change it 
to return Expected. (returning Expected would be nice even for a 
private api, but there it's less important...)



Comment at: lldb/lit/Breakpoint/Inputs/minidebuginfo-lib.h:1
+// This function will be embedded within the .dynsym section.
+int multiplyByThree(int num);

Hmm... so, what is the exact scenario you want to test here? This function will 
end up in the dynsym section of the main executable, but it will be an 
*undefined* symbol there. Undefined symbols are ignored in the gnu_debugdata 
logic. The symbol will be *defined* in the dynsym section of the shared 
library, but you're not debugdata-ing that one.

While this scenario might be interesting to test, I am not sure if that's the 
one you actually intended...

PS: If you want to create a file with both dynsym, and non-dynsym defined 
symbols, you don't have to resort to using shared libraries to achieve that. A 
suitable combination of -rdynamic and visibility("hidden") will achieve that 
too. For example the following line:
```
clang -x c - <<<'__attribute__((visibility("hidden"))) int in_symtab() { return 
42; } int in_dynsym() { return 47; } int main() { return 
in_symtab()+in_dynsym(); }' -rdynamic
```
will generate a file where the in_symtab function will only be present in the 
symtab, and in_dynsym will be in the dynsym section (until you apply the 
debug-data magic, it will be in the symtab too)...



Comment at: lldb/lit/Breakpoint/minidebuginfo.test:32
+
+# RUN: llvm-objcopy -S --remove-section .gdb_index --remove-section .comment 
--keep-symbols=keep_symbols %t.debug %t.mini_debuginfo
+

Shouldn't this be `%t.keep_symbols`? Typo ?



Comment at: lldb/lit/lit.cfg.py:102
+
+if config.lldb_enable_lzma == "ON":
+config.available_features.add('lzma')

you should apply `llvm_canonicalize_cmake_booleans` to the value of 
LLDB_ENABLE_LZMA at the cmake level. Otherwise, this will blow up if someone 
types `-DLLDB_ENABLE_LZMA=On`



Comment at: lldb/source/Host/common/LZMA.cpp:72-82
+  auto opts = lzma_stream_flags{};
+  if (InputBuffer.size() < LZMA_STREAM_HEADER_SIZE) {
+return llvm::createStringError(
+llvm::inconvertibleErrorCode(),
+"size of xz-compressed blob (%lu bytes) is smaller than the "
+"LZMA_STREAM_HEADER_SIZE (%lu bytes)",
+InputBuffer.size(), LZMA_STREAM_HEADER_SIZE);

too much auto



Comment at: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:1886
+  section->GetSectionData(data);
+  llvm::ArrayRef compressedData(data.GetDataStart(), 
data.GetByteSize());
+  llvm::SmallVector uncompressedData;

You don't need the temporary ArrayRef. You can just pass `data.GetData()` 
directly..


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66791



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


[Lldb-commits] [PATCH] D66742: Obliterate LLDB_CONFIGURATION_BUILDANDINTEGRATION

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

Any thoughts on this one?


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

https://reviews.llvm.org/D66742



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


[Lldb-commits] [PATCH] D67123: [lldb] Early exit in RangeDataVector:FindEntryIndexesThatContain

2019-09-04 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL370879: [lldb] Early exit in 
RangeDataVector:FindEntryIndexesThatContain (authored by teemperor, committed 
by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67123?vs=218644&id=218645#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67123

Files:
  lldb/trunk/include/lldb/Utility/RangeMap.h


Index: lldb/trunk/include/lldb/Utility/RangeMap.h
===
--- lldb/trunk/include/lldb/Utility/RangeMap.h
+++ lldb/trunk/include/lldb/Utility/RangeMap.h
@@ -724,12 +724,14 @@
 #ifdef ASSERT_RANGEMAP_ARE_SORTED
 assert(IsSorted());
 #endif
-
-if (!m_entries.empty()) {
-  for (const auto &entry : m_entries) {
-if (entry.Contains(addr))
-  indexes.push_back(entry.data);
-  }
+// Search the entries until the first entry that has a larger base address
+// than `addr`. As m_entries is sorted by their base address, all following
+// entries can't contain `addr` as their base address is already larger.
+for (const auto &entry : m_entries) {
+  if (entry.Contains(addr))
+indexes.push_back(entry.data);
+  else if (entry.GetRangeBase() > addr)
+break;
 }
 return indexes.size();
   }


Index: lldb/trunk/include/lldb/Utility/RangeMap.h
===
--- lldb/trunk/include/lldb/Utility/RangeMap.h
+++ lldb/trunk/include/lldb/Utility/RangeMap.h
@@ -724,12 +724,14 @@
 #ifdef ASSERT_RANGEMAP_ARE_SORTED
 assert(IsSorted());
 #endif
-
-if (!m_entries.empty()) {
-  for (const auto &entry : m_entries) {
-if (entry.Contains(addr))
-  indexes.push_back(entry.data);
-  }
+// Search the entries until the first entry that has a larger base address
+// than `addr`. As m_entries is sorted by their base address, all following
+// entries can't contain `addr` as their base address is already larger.
+for (const auto &entry : m_entries) {
+  if (entry.Contains(addr))
+indexes.push_back(entry.data);
+  else if (entry.GetRangeBase() > addr)
+break;
 }
 return indexes.size();
   }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D67123: [lldb] Early exit in RangeDataVector:FindEntryIndexesThatContain

2019-09-04 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor updated this revision to Diff 218644.
teemperor marked an inline comment as done.
teemperor added a comment.

- remove empty check


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

https://reviews.llvm.org/D67123

Files:
  lldb/include/lldb/Utility/RangeMap.h


Index: lldb/include/lldb/Utility/RangeMap.h
===
--- lldb/include/lldb/Utility/RangeMap.h
+++ lldb/include/lldb/Utility/RangeMap.h
@@ -724,12 +724,14 @@
 #ifdef ASSERT_RANGEMAP_ARE_SORTED
 assert(IsSorted());
 #endif
-
-if (!m_entries.empty()) {
-  for (const auto &entry : m_entries) {
-if (entry.Contains(addr))
-  indexes.push_back(entry.data);
-  }
+// Search the entries until the first entry that has a larger base address
+// than `addr`. As m_entries is sorted by their base address, all following
+// entries can't contain `addr` as their base address is already larger.
+for (const auto &entry : m_entries) {
+  if (entry.Contains(addr))
+indexes.push_back(entry.data);
+  else if (entry.GetRangeBase() > addr)
+break;
 }
 return indexes.size();
   }


Index: lldb/include/lldb/Utility/RangeMap.h
===
--- lldb/include/lldb/Utility/RangeMap.h
+++ lldb/include/lldb/Utility/RangeMap.h
@@ -724,12 +724,14 @@
 #ifdef ASSERT_RANGEMAP_ARE_SORTED
 assert(IsSorted());
 #endif
-
-if (!m_entries.empty()) {
-  for (const auto &entry : m_entries) {
-if (entry.Contains(addr))
-  indexes.push_back(entry.data);
-  }
+// Search the entries until the first entry that has a larger base address
+// than `addr`. As m_entries is sorted by their base address, all following
+// entries can't contain `addr` as their base address is already larger.
+for (const auto &entry : m_entries) {
+  if (entry.Contains(addr))
+indexes.push_back(entry.data);
+  else if (entry.GetRangeBase() > addr)
+break;
 }
 return indexes.size();
   }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r370879 - [lldb] Early exit in RangeDataVector:FindEntryIndexesThatContain

2019-09-04 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Wed Sep  4 04:40:29 2019
New Revision: 370879

URL: http://llvm.org/viewvc/llvm-project?rev=370879&view=rev
Log:
[lldb] Early exit in RangeDataVector:FindEntryIndexesThatContain

Summary:
We currently spend a lot of time in this function (around 27% of the 
br-by-regex benchmark in lldb-bench)
by just iterating over all the ranges. We already sorted these ranges by their 
base address, we we can actually
just stop checking ranges as soon as we find one that has a higher base address.

Reviewers: labath

Reviewed By: labath

Subscribers: amccarth, arphaman, JDevlieghere, lldb-commits

Tags: #lldb

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

Modified:
lldb/trunk/include/lldb/Utility/RangeMap.h

Modified: lldb/trunk/include/lldb/Utility/RangeMap.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/RangeMap.h?rev=370879&r1=370878&r2=370879&view=diff
==
--- lldb/trunk/include/lldb/Utility/RangeMap.h (original)
+++ lldb/trunk/include/lldb/Utility/RangeMap.h Wed Sep  4 04:40:29 2019
@@ -724,12 +724,14 @@ public:
 #ifdef ASSERT_RANGEMAP_ARE_SORTED
 assert(IsSorted());
 #endif
-
-if (!m_entries.empty()) {
-  for (const auto &entry : m_entries) {
-if (entry.Contains(addr))
-  indexes.push_back(entry.data);
-  }
+// Search the entries until the first entry that has a larger base address
+// than `addr`. As m_entries is sorted by their base address, all following
+// entries can't contain `addr` as their base address is already larger.
+for (const auto &entry : m_entries) {
+  if (entry.Contains(addr))
+indexes.push_back(entry.data);
+  else if (entry.GetRangeBase() > addr)
+break;
 }
 return indexes.size();
   }


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


[Lldb-commits] [lldb] r370880 - [lldb] Limit the amount of zeroes we use for padding when printing small floats

2019-09-04 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Wed Sep  4 04:41:23 2019
New Revision: 370880

URL: http://llvm.org/viewvc/llvm-project?rev=370880&view=rev
Log:
[lldb] Limit the amount of zeroes we use for padding when printing small floats

Summary:
We got a radar that printing small floats is not very user-friendly in LLDB as 
we print them with up to
100 leading zeroes before starting to use scientific notation. This patch 
changes this by already using
scientific notation when we hit 6 padding zeroes by default and moves this 
value into a target setting
so that users can just set this number back to 100 if they for some reason 
preferred the old behaviour.

This new setting is influencing how we format data, so that's why we have to 
reset the data visualisation
cache when it is changed.

Note that we have always been using scientific notation for large numbers 
because it seems that
the LLVM implementation doesn't support printing out the padding zeroes for 
them. I would have fixed
that if it was trivial, but looking at the LLVM implementation for this it 
seems that this is not as trivial
as it sounds. I would say we look into this if we ever get a bug report about 
someone wanting to have
a large amount of trailing zeroes in their numbers instead of using scientific 
notation.

Fixes rdar://39744137

Reviewers: #lldb, clayborg

Reviewed By: clayborg

Subscribers: JDevlieghere, lldb-commits

Tags: #lldb

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

Added:
lldb/trunk/packages/Python/lldbsuite/test/functionalities/float-display/

lldb/trunk/packages/Python/lldbsuite/test/functionalities/float-display/Makefile

lldb/trunk/packages/Python/lldbsuite/test/functionalities/float-display/TestFloatDisplay.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/float-display/main.c
Modified:
lldb/trunk/include/lldb/Target/Target.h
lldb/trunk/source/Core/Debugger.cpp
lldb/trunk/source/Core/DumpDataExtractor.cpp
lldb/trunk/source/Target/Target.cpp
lldb/trunk/source/Target/TargetProperties.td

Modified: lldb/trunk/include/lldb/Target/Target.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=370880&r1=370879&r2=370880&view=diff
==
--- lldb/trunk/include/lldb/Target/Target.h (original)
+++ lldb/trunk/include/lldb/Target/Target.h Wed Sep  4 04:41:23 2019
@@ -139,6 +139,8 @@ public:
 
   bool GetEnableSyntheticValue() const;
 
+  uint32_t GetMaxZeroPaddingInFloatFormat() const;
+
   uint32_t GetMaximumNumberOfChildrenToDisplay() const;
 
   uint32_t GetMaximumSizeOfStringSummary() const;

Added: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/float-display/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/float-display/Makefile?rev=370880&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/float-display/Makefile
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/float-display/Makefile
 Wed Sep  4 04:41:23 2019
@@ -0,0 +1,3 @@
+LEVEL = ../../make
+C_SOURCES := main.c
+include $(LEVEL)/Makefile.rules

Added: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/float-display/TestFloatDisplay.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/float-display/TestFloatDisplay.py?rev=370880&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/float-display/TestFloatDisplay.py
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/float-display/TestFloatDisplay.py
 Wed Sep  4 04:41:23 2019
@@ -0,0 +1,5 @@
+from lldbsuite.test import lldbinline
+from lldbsuite.test import decorators
+
+lldbinline.MakeInlineTest(
+__file__, globals(), [])

Added: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/float-display/main.c
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/float-display/main.c?rev=370880&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/float-display/main.c 
(added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/float-display/main.c 
Wed Sep  4 04:41:23 2019
@@ -0,0 +1,121 @@
+float f_neg3 = 1.234567 / 1e3;
+float f_neg4 = 1.234567 / 1e4;
+float f_neg5 = 1.234567 / 1e5;
+float f_neg6 = 1.234567 / 1e6;
+float f_neg7 = 1.234567 / 1e7;
+float f_neg8 = 1.234567 / 1e8;
+float f_neg20 = 1.234567 / 1e20;
+float f_neg30 = 1.234567 / 1e30;
+
+float f_3 = 1.234567 * 1e3;
+float f_4 = 1.234567 * 1e4;
+float f_5 = 1.234567 * 1e5;
+float f_6 = 1.234567 * 1e6;
+float f_7 = 1.234567 * 1e7;
+float f_8 = 1.234567 * 1e8;
+float f_20 = 1.234567 * 1e20;
+float f_

[Lldb-commits] [PATCH] D67001: [lldb] Limit the amount of zeroes we use for padding when printing small floats

2019-09-04 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL370880: [lldb] Limit the amount of zeroes we use for padding 
when printing small floats (authored by teemperor, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67001?vs=218072&id=218646#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67001

Files:
  lldb/trunk/include/lldb/Target/Target.h
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/float-display/Makefile
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/float-display/TestFloatDisplay.py
  lldb/trunk/packages/Python/lldbsuite/test/functionalities/float-display/main.c
  lldb/trunk/source/Core/Debugger.cpp
  lldb/trunk/source/Core/DumpDataExtractor.cpp
  lldb/trunk/source/Target/Target.cpp
  lldb/trunk/source/Target/TargetProperties.td

Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/float-display/Makefile
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/float-display/Makefile
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/float-display/Makefile
@@ -0,0 +1,3 @@
+LEVEL = ../../make
+C_SOURCES := main.c
+include $(LEVEL)/Makefile.rules
Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/float-display/main.c
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/float-display/main.c
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/float-display/main.c
@@ -0,0 +1,121 @@
+float f_neg3 = 1.234567 / 1e3;
+float f_neg4 = 1.234567 / 1e4;
+float f_neg5 = 1.234567 / 1e5;
+float f_neg6 = 1.234567 / 1e6;
+float f_neg7 = 1.234567 / 1e7;
+float f_neg8 = 1.234567 / 1e8;
+float f_neg20 = 1.234567 / 1e20;
+float f_neg30 = 1.234567 / 1e30;
+
+float f_3 = 1.234567 * 1e3;
+float f_4 = 1.234567 * 1e4;
+float f_5 = 1.234567 * 1e5;
+float f_6 = 1.234567 * 1e6;
+float f_7 = 1.234567 * 1e7;
+float f_8 = 1.234567 * 1e8;
+float f_20 = 1.234567 * 1e20;
+float f_30 = 1.234567 * 1e30;
+
+double d_neg3 = 1.234567 / 1e3;
+double d_neg4 = 1.234567 / 1e4;
+double d_neg5 = 1.234567 / 1e5;
+double d_neg6 = 1.234567 / 1e6;
+double d_neg7 = 1.234567 / 1e7;
+double d_neg8 = 1.234567 / 1e8;
+double d_neg20 = 1.234567 / 1e20;
+double d_neg30 = 1.234567 / 1e30;
+double d_neg50 = 1.234567 / 1e50;
+double d_neg250 = 1.234567 / 1e250;
+
+double d_3 = 1.234567 * 1e3;
+double d_4 = 1.234567 * 1e4;
+double d_5 = 1.234567 * 1e5;
+double d_6 = 1.234567 * 1e6;
+double d_7 = 1.234567 * 1e7;
+double d_8 = 1.234567 * 1e8;
+double d_20 = 1.234567 * 1e20;
+double d_30 = 1.234567 * 1e30;
+double d_50 = 1.234567 * 1e50;
+double d_250 = 1.234567 * 1e250;
+
+int main (int argc, char const *argv[]) {
+  //% # Default setting should be 6.
+  //% self.expect("frame variable f_neg3", substrs=["0.00123456"])
+  //% self.expect("frame variable f_neg4", substrs=["0.000123456"])
+  //% self.expect("frame variable f_neg5", substrs=["0.123456"])
+  //% self.expect("frame variable f_neg6", substrs=["0.0123456"])
+  //% self.expect("frame variable f_neg7", substrs=["1.234567", "E-7"])
+  //% self.expect("frame variable f_neg8", substrs=["1.23456", "E-8"])
+  //% self.expect("frame variable f_neg20", substrs=["E-20"])
+  //% self.expect("frame variable f_neg30", substrs=["E-30"])
+  //% self.expect("frame variable f_3", substrs=["1234.56"])
+  //% self.expect("frame variable f_4", substrs=["12345.6"])
+  //% self.expect("frame variable f_5", substrs=["123456"])
+  //% self.expect("frame variable f_6", substrs=["123456"])
+  //% self.expect("frame variable f_7", substrs=["123456"])
+  //% self.expect("frame variable f_8", substrs=["123456"])
+  //% self.expect("frame variable f_20", substrs=["E+20"])
+  //% self.expect("frame variable f_30", substrs=["E+30"])
+  //% self.expect("frame variable d_neg3", substrs=["0.00123456"])
+  //% self.expect("frame variable d_neg4", substrs=["0.000123456"])
+  //% self.expect("frame variable d_neg5", substrs=["0.123456"])
+  //% self.expect("frame variable d_neg6", substrs=["0.0123456"])
+  //% self.expect("frame variable d_neg7", substrs=["1.23456", "E-7"])
+  //% self.expect("frame variable d_neg8", substrs=["1.23456", "E-8"])
+  //% self.expect("frame variable d_neg20", substrs=["1.23456", "E-20"])
+  //% self.expect("frame variable d_neg30", substrs=["1.23456", "E-30"])
+  //% self.expect("frame variable d_neg50", substrs=["1.23456", "E-50"])
+  //% self.expect("frame variable d_neg250", substrs=["E-250"])
+  //% self.expect("frame variable d_3", substrs=["1234.56"])
+  //% self.expect("frame variable d_4", substrs=["12345.6"])
+  //% self.expect("frame variable d_5", substrs=["123456"])
+  //% self.expect("frame variable d_6", substrs=["1234567"])
+  //% self.expect("frame variable d_

[Lldb-commits] [lldb] r370887 - [lldb] Fix log statement in Socket::Write

2019-09-04 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Wed Sep  4 05:38:43 2019
New Revision: 370887

URL: http://llvm.org/viewvc/llvm-project?rev=370887&view=rev
Log:
[lldb] Fix log statement in Socket::Write

We change num_bytes in this method, so this doesn't actually
log the parameter that we called the function with. No test
as we don't test logging code.

Modified:
lldb/trunk/source/Host/common/Socket.cpp

Modified: lldb/trunk/source/Host/common/Socket.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Socket.cpp?rev=370887&r1=370886&r2=370887&view=diff
==
--- lldb/trunk/source/Host/common/Socket.cpp (original)
+++ lldb/trunk/source/Host/common/Socket.cpp Wed Sep  4 05:38:43 2019
@@ -353,6 +353,7 @@ Status Socket::Read(void *buf, size_t &n
 }
 
 Status Socket::Write(const void *buf, size_t &num_bytes) {
+  const size_t src_len = num_bytes;
   Status error;
   int bytes_sent = 0;
   do {
@@ -372,7 +373,7 @@ Status Socket::Write(const void *buf, si
   ", src = %p, src_len = %" PRIu64 ", flags = 0) => %" PRIi64
   " (error = %s)",
   static_cast(this), static_cast(m_socket), buf,
-  static_cast(num_bytes),
+  static_cast(src_len),
   static_cast(bytes_sent), error.AsCString());
   }
 


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


[Lldb-commits] [lldb] r370898 - disassemble command: fix error message when disassembly fails

2019-09-04 Thread Pavel Labath via lldb-commits
Author: labath
Date: Wed Sep  4 06:26:41 2019
New Revision: 370898

URL: http://llvm.org/viewvc/llvm-project?rev=370898&view=rev
Log:
disassemble command: fix error message when disassembly fails

We were printing the start_addr field, which is not correct, as in this
branch we are processing the memory described by cur_range. Print that
instead.

Ideally, in particular this case, the error message would also say
something about not being able to disassemble due to not having found
the module from the core file, but that is not easy to do right now, so
I'm leaving that for another time.

Added:
lldb/trunk/lit/Minidump/disassemble-no-module.yaml
lldb/trunk/lit/Minidump/lit.local.cfg
Modified:
lldb/trunk/source/Commands/CommandObjectDisassemble.cpp

Added: lldb/trunk/lit/Minidump/disassemble-no-module.yaml
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Minidump/disassemble-no-module.yaml?rev=370898&view=auto
==
--- lldb/trunk/lit/Minidump/disassemble-no-module.yaml (added)
+++ lldb/trunk/lit/Minidump/disassemble-no-module.yaml Wed Sep  4 06:26:41 2019
@@ -0,0 +1,48 @@
+# RUN: yaml2obj %s > %t
+# RUN: %lldb -c %t -o bt -o disassemble 2>&1 | FileCheck %s
+
+# CHECK-LABEL: (lldb) bt
+# CHECK: frame #0: 0x00400430
+# CHECK-LABEL: (lldb) disassemble
+# CHECK-NEXT: error: error reading data from section .module_image
+# CHECK-NEXT: error: Failed to disassemble memory at 0x00400430.
+
+--- !minidump
+Streams: 
+  - Type:ThreadList
+Threads: 
+  - Thread Id:   0x74F3
+Context: 
0B0010006CAE6B7FC05AC81D415AA2BF9E5A6B7F8850C14BFD7F9850C14BFD7F0100B04AC14BFD7F60812D010800B065E05A6B7F80044000E050C14BFD7F300440007F03801F6B7F0400B84CC14BFD7F304D405A6B7FC84DC14BFD7FC0AA405A6B7F4F033D00B84DC14BFD7FE84DC14BFD7F0070E05A6B7F78629E5A6B7FC81D415A6B7F804F9E5A6B7F0100E6030100E093115A6B7F804EC14BFD7F584EC14BFD7F99ADC05A6B7F0100D77D02000800B065E05A6B7FE6B7C05A6B7F01006B7F884DC14BFD7F106F7C5A6B7F984EC14BFD7F488B7C5A6B7FC4A71CB901000800B065E05A6B7F48B6C05A6B7F702AE25A6B7FD84DC14BFD7F30489E5A6B7FE84EC14BFD7FE05E9E5A6B7F0991F04601000800B065E05A6B7F48B6C05A6B7F0100284EC14BFD7F
+Stack:   
+  Start of Memory Range: 0x7FFD4BC15080
+  Content: 30044000
+  - Type:ModuleList
+Modules: 
+  - Base of Image:   0x0040
+Size of Image:   0x1000
+Module Name: 'nonexisting-module'
+CodeView Record: 4C4570426CCF3F60FFA7CC4B86AE8FF44DB2576A68983611
+  - Type:MemoryList
+Memory Ranges:   
+  - Start of Memory Range: 0x7FFD4BC15080
+Content: 30044000
+  - Type:SystemInfo
+Processor Arch:  AMD64
+Platform ID: Linux
+CPU: 
+  Vendor ID:   GenuineIntel
+  Version Info:0x
+  Feature Info:0x
+  - Type:LinuxProcStatus
+Text: |
+  Name:nonexistin

[Lldb-commits] [PATCH] D67168: [Windows] Add support of watchpoints to `ProcessWindows`

2019-09-04 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov created this revision.
aleksandr.urakov added reviewers: asmith, stella.stamenova, amccarth.
aleksandr.urakov added a project: LLDB.
Herald added subscribers: lldb-commits, JDevlieghere, abidh.
aleksandr.urakov added a subscriber: leonid.mashinskiy.

This patch adds support of watchpoints to the old `ProcessWindows` plugin.

The `ProcessWindows` plugin uses the `RegisterContext` to set and reset 
watchpoints. The `RegisterContext` has some interface to access watchpoints, 
but it is very limited (e.g. it is impossible to retrieve the last triggered 
watchpoint with it), that's why I have implemented a slightly different 
interface in the `RegisterContextWindows`. Moreover, I have made the 
`ProcessWindows` plugin responsible for search of a vacant watchpoint slot, 
because watchpoints exist per-process (not per-thread), then we can place the 
same watchpoint in the same slot in different threads. With this scheme threads 
don't need to have their own watchpoint lists, and it simplifies identifying of 
the last triggered watchpoint.

It looks like it is enough to just implement corresponding methods in the 
`NativeRegisterContextWindows`-based classes to support the feature in the new 
`NativeProcessWindows` plugin. I'll do it in the next review.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D67168

Files:
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/hello_watchlocation/TestWatchLocation.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/hello_watchpoint/TestMyFirstWatchpoint.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/multiple_hits/TestMultipleHits.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/multiple_threads/TestWatchpointMultipleThreads.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/TestWatchpointCommands.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/command/TestWatchpointCommandLLDB.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/command/TestWatchpointCommandPython.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/condition/TestWatchpointConditionCmd.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_disable/TestWatchpointDisable.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_events/TestWatchpointEvents.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_on_vectors/TestValueOfVectorVariable.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_set_command/TestWatchLocationWithWatchSet.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_size/TestWatchpointSizes.py
  lldb/packages/Python/lldbsuite/test/python_api/watchpoint/TestSetWatchpoint.py
  
lldb/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIgnoreCount.py
  
lldb/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIter.py
  
lldb/packages/Python/lldbsuite/test/python_api/watchpoint/condition/TestWatchpointConditionAPI.py
  
lldb/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestSetWatchlocation.py
  
lldb/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py
  lldb/source/Plugins/Process/Windows/Common/IDebugDelegate.h
  lldb/source/Plugins/Process/Windows/Common/LocalDebugDelegate.cpp
  lldb/source/Plugins/Process/Windows/Common/LocalDebugDelegate.h
  lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
  lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.h
  lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp
  lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.h
  lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
  lldb/source/Plugins/Process/Windows/Common/ProcessWindows.h
  lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
  lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.h
  lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
  lldb/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp

Index: lldb/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp
+++ lldb/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp
@@ -267,9 +267,7 @@
   }
 
   // Physically update the registers in the target process.
-  TargetThreadWindows &wthread = static_cast(m_thread);
-  return ::SetThreadContext(
-  wthread.GetHostThread().GetNativeThread().GetSystemHandle(), &m_context);
+  return ApplyAllRegisterValues();
 }
 
 bool RegisterContextWindows_x86::ReadRegisterHelper(
Index: lldb/source/Plugins

[Lldb-commits] [PATCH] D67173: [dotest] Centralize initialization commands even more

2019-09-04 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added reviewers: JDevlieghere, jankratochvil.

In r367234 we introduced a central place to hold the set up commands for
the various ways we have of launching lldb. However, a number of
commands still remained outside of that.

This patch moves the remaining set up commands into this function, which
allows us to remove manual clang module path setting code in
TestBatchMode.

One unfortunate victim of this approach is TestSTTYBeforeAndAfter which,
due to how it launches lldb (pexpect->expect->lldb), fails get the
quoting right. It would be possible to fix the quoting there, it would be a bit
icky, and none of the commands in this list are really relevant for what this
test is doing, so I just remove the commands outright.


https://reviews.llvm.org/D67173

Files:
  packages/Python/lldbsuite/test/driver/batch_mode/TestBatchMode.py
  packages/Python/lldbsuite/test/lldbtest.py
  packages/Python/lldbsuite/test/terminal/TestSTTYBeforeAndAfter.py
  packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py

Index: packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
===
--- packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
+++ packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
@@ -12,7 +12,7 @@
 self.assertTrue(os.path.exists(self.lldbVSCodeExec),
 'lldb-vscode must exist')
 self.vscode = vscode.DebugAdaptor(
-executable=self.lldbVSCodeExec, init_commands=Base.setUpCommands())
+executable=self.lldbVSCodeExec, init_commands=self.setUpCommands())
 
 def build_and_create_debug_adaptor(self):
 self.build()
Index: packages/Python/lldbsuite/test/terminal/TestSTTYBeforeAndAfter.py
===
--- packages/Python/lldbsuite/test/terminal/TestSTTYBeforeAndAfter.py
+++ packages/Python/lldbsuite/test/terminal/TestSTTYBeforeAndAfter.py
@@ -73,7 +73,7 @@
 child.logfile_read = None
 
 # Invoke the lldb command.
-child.sendline('%s %s' % (lldbtest_config.lldbExec, self.lldbOption))
+child.sendline(lldbtest_config.lldbExec)
 child.expect_exact(lldb_prompt)
 
 # Immediately quit.
Index: packages/Python/lldbsuite/test/lldbtest.py
===
--- packages/Python/lldbsuite/test/lldbtest.py
+++ packages/Python/lldbsuite/test/lldbtest.py
@@ -684,16 +684,31 @@
 """Return absolute path to a file in the test's source directory."""
 return os.path.join(self.getSourceDir(), name)
 
-@staticmethod
-def setUpCommands():
-return [
+@classmethod
+def setUpCommands(cls):
+commands = [
 # Disable Spotlight lookup. The testsuite creates
 # different binaries with the same UUID, because they only
 # differ in the debug info, which is not being hashed.
 "settings set symbols.enable-external-lookup false",
 
 # Testsuite runs in parallel and the host can have also other load.
-"settings set plugin.process.gdb-remote.packet-timeout 60"]
+"settings set plugin.process.gdb-remote.packet-timeout 60",
+
+'settings set symbols.clang-modules-cache-path "{}"'.format(
+configuration.module_cache_dir),
+"settings set use-color false",
+]
+# Make sure that a sanitizer LLDB's environment doesn't get passed on.
+if cls.platformContext and cls.platformContext.shlib_environment_var in os.environ:
+commands.append('settings set target.env-vars {}='
+.format(cls.platformContext.shlib_environment_var))
+
+# Set environment variables for the inferior.
+if lldbtest_config.inferior_env:
+commands.append('settings set target.env-vars ' +
+lldbtest_config.inferior_env)
+return commands
 
 def setUp(self):
 """Fixture for unittest test case setup.
@@ -1851,25 +1866,9 @@
 # decorators.
 Base.setUp(self)
 
-# Set the clang modules cache path used by LLDB.
-self.runCmd(
-'settings set symbols.clang-modules-cache-path "{}"'.format(
-configuration.module_cache_dir))
-
 for s in self.setUpCommands():
 self.runCmd(s)
 
-# Disable color.
-self.runCmd("settings set use-color false")
-
-# Make sure that a sanitizer LLDB's environment doesn't get passed on.
-if 'DYLD_LIBRARY_PATH' in os.environ:
-self.runCmd('settings set target.env-vars DYLD_LIBRARY_PATH=')
-
-# Set environment variables for the inferior.
-if lldbtest_config.inferior_env:
-self.runCmd('settings set target.env-vars {}'.format(lldbtest_config.inferior_env))
-
 if "LLDB_

Re: [Lldb-commits] [lldb] r370848 - [lldb][NFC] Add a simple test for thread_local storage.

2019-09-04 Thread Frédéric Riss via lldb-commits


> On Sep 4, 2019, at 1:02 AM, Raphael Isemann via lldb-commits 
>  wrote:
> 
> Author: teemperor
> Date: Wed Sep  4 01:02:52 2019
> New Revision: 370848
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=370848&view=rev
> Log:
> [lldb][NFC] Add a simple test for thread_local storage.
> 
> Seems we fail to read TLS data on Linux, so the test only runs on
> macOS for now. We will see how this test runs on the BSD bots.
> 
> Added:
>lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/
>lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/Makefile
>
> lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/TestThreadLocal.py
>lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/main.cpp
> 
> Added: 
> lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/Makefile
> URL: 
> http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/Makefile?rev=370848&view=auto
> ==
> --- lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/Makefile 
> (added)
> +++ lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/Makefile 
> Wed Sep  4 01:02:52 2019
> @@ -0,0 +1,3 @@
> +LEVEL = ../../../make
> +CXX_SOURCES := main.cpp
> +include $(LEVEL)/Makefile.rules
> 
> Added: 
> lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/TestThreadLocal.py
> URL: 
> http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/TestThreadLocal.py?rev=370848&view=auto
> ==
> --- 
> lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/TestThreadLocal.py
>  (added)
> +++ 
> lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/TestThreadLocal.py
>  Wed Sep  4 01:02:52 2019
> @@ -0,0 +1,5 @@
> +from lldbsuite.test import lldbinline
> +from lldbsuite.test import decorators
> +
> +lldbinline.MakeInlineTest(__file__, globals(),
> +  lldbinline.expectedFailureAll(oslist=["windows", 
> "linux"]))
> 
> Added: 
> lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/main.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/main.cpp?rev=370848&view=auto
> ==
> --- lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/main.cpp 
> (added)
> +++ lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/main.cpp 
> Wed Sep  4 01:02:52 2019
> @@ -0,0 +1,17 @@
> +int storage = 45;
> +thread_local int tl_global_int = 123;
> +thread_local int *tl_global_ptr = &storage;
> +
> +int main(int argc, char **argv) {
> +  //% self.expect("expr tl_local_int", error=True, substrs=["couldn't get 
> the value of variable tl_local_int"])
> +  //% self.expect("expr *tl_local_ptr", error=True, substrs=["couldn't get 
> the value of variable tl_local_ptr"])
> +  thread_local int tl_local_int = 321;
> +  thread_local int *tl_local_ptr = nullptr;
> +  tl_local_ptr = &tl_local_int;
> +  tl_local_int++;
> +  //% self.expect("expr tl_local_int + 1", substrs=["int", "= 323"])
> +  //% self.expect("expr *tl_local_ptr + 2", substrs=["int", "= 324"])
> +  //% self.expect("expr tl_global_int", substrs=["int", "= 123"])
> +  //% self.expect("expr *tl_global_ptr", substrs=["int", "= 45"])
> +  return 0;
> +}

Is frame variable able to get the value of the TLS variables, or do we rely on 
the Clang codeine here? I don’t remember if accessing TLS requires a function 
call on Darwin.

Fred

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

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


[Lldb-commits] [PATCH] D66742: Obliterate LLDB_CONFIGURATION_BUILDANDINTEGRATION

2019-09-04 Thread Frederic Riss via Phabricator via lldb-commits
friss accepted this revision.
friss added a comment.
This revision is now accepted and ready to land.

I don't see reason to keep this around.


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

https://reviews.llvm.org/D66742



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


[Lldb-commits] [PATCH] D67183: [Python] Implement truth testing for lldb.value

2019-09-04 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: friss, LLDB.
Herald added a project: LLDB.

Python 3 calls __bool__() instead of __len__() and lldb.value
only implemented the __len__ method. This adds the __bool__() implementation.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D67183

Files:
  lldb/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py
  lldb/scripts/Python/python-extensions.swig


Index: lldb/scripts/Python/python-extensions.swig
===
--- lldb/scripts/Python/python-extensions.swig
+++ lldb/scripts/Python/python-extensions.swig
@@ -980,6 +980,9 @@
 def __nonzero__(self):
 return self.sbvalue.__nonzero__()
 
+def __bool__(self):
+return self.sbvalue.__bool__()
+
 def __str__(self):
 return self.sbvalue.__str__()
 
Index: lldb/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py
===
--- lldb/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py
+++ lldb/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py
@@ -160,6 +160,10 @@
 val_i.GetType()).AddressOf(),
 VALID_VARIABLE)
 
+# Check that lldb.value implements truth testing.
+self.assertFalse(lldb.value(frame0.FindVariable('bogus')))
+self.assertTrue(lldb.value(frame0.FindVariable('uinthex')))
+
 self.assertTrue(int(lldb.value(frame0.FindVariable('uinthex')))
 == 3768803088, 'uinthex == 3768803088')
 self.assertTrue(int(lldb.value(frame0.FindVariable('sinthex')))


Index: lldb/scripts/Python/python-extensions.swig
===
--- lldb/scripts/Python/python-extensions.swig
+++ lldb/scripts/Python/python-extensions.swig
@@ -980,6 +980,9 @@
 def __nonzero__(self):
 return self.sbvalue.__nonzero__()
 
+def __bool__(self):
+return self.sbvalue.__bool__()
+
 def __str__(self):
 return self.sbvalue.__str__()
 
Index: lldb/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py
===
--- lldb/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py
+++ lldb/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py
@@ -160,6 +160,10 @@
 val_i.GetType()).AddressOf(),
 VALID_VARIABLE)
 
+# Check that lldb.value implements truth testing.
+self.assertFalse(lldb.value(frame0.FindVariable('bogus')))
+self.assertTrue(lldb.value(frame0.FindVariable('uinthex')))
+
 self.assertTrue(int(lldb.value(frame0.FindVariable('uinthex')))
 == 3768803088, 'uinthex == 3768803088')
 self.assertTrue(int(lldb.value(frame0.FindVariable('sinthex')))
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D67184: [Python] Implement __next__ for value_iter

2019-09-04 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: friss, LLDB.
Herald added a project: LLDB.

Python 3 iteration calls the next() method instead of next() and
value_iter only implemented the Python 2 version.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D67184

Files:
  lldb/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py
  lldb/scripts/Python/python-extensions.swig


Index: lldb/scripts/Python/python-extensions.swig
===
--- lldb/scripts/Python/python-extensions.swig
+++ lldb/scripts/Python/python-extensions.swig
@@ -946,13 +946,16 @@
 def __iter__(self):
 return self
 
-def next(self):
+def __next__(self):
 if self.index >= self.length:
 raise StopIteration()
 child_sbvalue = self.sbvalue.GetChildAtIndex(self.index)
 self.index += 1
 return value(child_sbvalue)
 
+def next(self):
+return self.__next__()
+
 def __init__(self,value):
 self.index = 0
 self.sbvalue = value
Index: lldb/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py
===
--- lldb/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py
+++ lldb/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py
@@ -169,6 +169,13 @@
 self.assertTrue(int(lldb.value(frame0.FindVariable('sinthex')))
 == -526164208, 'sinthex == -526164208')
 
+# Check value_iter works correctly.
+for v in [
+lldb.value(frame0.FindVariable('uinthex')),
+lldb.value(frame0.FindVariable('sinthex'))
+]:
+self.assertTrue(v)
+
 self.assertTrue(
 frame0.FindVariable('uinthex').GetValueAsUnsigned() == 3768803088,
 'unsigned uinthex == 3768803088')


Index: lldb/scripts/Python/python-extensions.swig
===
--- lldb/scripts/Python/python-extensions.swig
+++ lldb/scripts/Python/python-extensions.swig
@@ -946,13 +946,16 @@
 def __iter__(self):
 return self
 
-def next(self):
+def __next__(self):
 if self.index >= self.length:
 raise StopIteration()
 child_sbvalue = self.sbvalue.GetChildAtIndex(self.index)
 self.index += 1
 return value(child_sbvalue)
 
+def next(self):
+return self.__next__()
+
 def __init__(self,value):
 self.index = 0
 self.sbvalue = value
Index: lldb/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py
===
--- lldb/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py
+++ lldb/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py
@@ -169,6 +169,13 @@
 self.assertTrue(int(lldb.value(frame0.FindVariable('sinthex')))
 == -526164208, 'sinthex == -526164208')
 
+# Check value_iter works correctly.
+for v in [
+lldb.value(frame0.FindVariable('uinthex')),
+lldb.value(frame0.FindVariable('sinthex'))
+]:
+self.assertTrue(v)
+
 self.assertTrue(
 frame0.FindVariable('uinthex').GetValueAsUnsigned() == 3768803088,
 'unsigned uinthex == 3768803088')
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r370916 - Workaround TestConcurrentMany* flakiness in a more pricipled way

2019-09-04 Thread Frederic Riss via lldb-commits
Author: friss
Date: Wed Sep  4 09:13:12 2019
New Revision: 370916

URL: http://llvm.org/viewvc/llvm-project?rev=370916&view=rev
Log:
Workaround TestConcurrentMany* flakiness in a more pricipled way

The flakiness on our local machines seems to come for a race in the kernel
between task_suspend and the creation of the Mach exceptions for the threads
that hit breakpoints. The debugserver code is written with the assumption
that the kernel will be able to provide us with all the exceptions for a
given task once task_suspend returns. On machines with higher core counts,
this seems not to be the case. The first batch of exceptions we get after
task_suspend does not contain exceptions for all the threads that have hit
a breakpoint, thus they get misreprorted in the first stop packet.

Adding a 1ms timeout to the call that retrieves the batch of exceptions
seems to workaround the issue reliably on our machines, and it shoulnd't
impact standard debugging scenarios too much (a stop will incur an additional
1ms delay). We'll be talking to the kernel team to figure out the right
contract for those APIs.

This patch also reverts part of Jonas' previous workaround for the
issue (r370785).

Modified:
lldb/trunk/packages/Python/lldbsuite/test/make/pseudo_barrier.h
lldb/trunk/tools/debugserver/source/MacOSX/MachTask.mm

Modified: lldb/trunk/packages/Python/lldbsuite/test/make/pseudo_barrier.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/make/pseudo_barrier.h?rev=370916&r1=370915&r2=370916&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/make/pseudo_barrier.h (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/make/pseudo_barrier.h Wed Sep  4 
09:13:12 2019
@@ -7,7 +7,6 @@ static inline void pseudo_barrier_wait(p
   --barrier;
   while (barrier > 0)
 std::this_thread::yield();
-  std::this_thread::sleep_for(std::chrono::milliseconds(100));
 }
 
 static inline void pseudo_barrier_init(pseudo_barrier_t &barrier, int count) {

Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachTask.mm
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachTask.mm?rev=370916&r1=370915&r2=370916&view=diff
==
--- lldb/trunk/tools/debugserver/source/MacOSX/MachTask.mm (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/MachTask.mm Wed Sep  4 09:13:12 
2019
@@ -754,7 +754,7 @@ void *MachTask::ExceptionThread(void *ar
   // to get all currently available exceptions for this task
   err = exception_message.Receive(
   mach_task->ExceptionPort(),
-  MACH_RCV_MSG | MACH_RCV_INTERRUPT | MACH_RCV_TIMEOUT, 0);
+  MACH_RCV_MSG | MACH_RCV_INTERRUPT | MACH_RCV_TIMEOUT, 1);
 } else if (periodic_timeout > 0) {
   // We need to stop periodically in this loop, so try and get a mach
   // message with a valid timeout (ms)


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


[Lldb-commits] [PATCH] D67173: [dotest] Centralize initialization commands even more

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



Comment at: packages/Python/lldbsuite/test/lldbtest.py:709
+if lldbtest_config.inferior_env:
+commands.append('settings set target.env-vars ' +
+lldbtest_config.inferior_env)

I'm curious why you changed this to use `+` instead of `format`? 


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

https://reviews.llvm.org/D67173



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


[Lldb-commits] [PATCH] D67067: Breakpad: Basic support for STACK WIN unwinding

2019-09-04 Thread Adrian McCarthy via Phabricator via lldb-commits
amccarth accepted this revision.
amccarth added a comment.
This revision is now accepted and ready to land.

LGTM.  Please consider adding a comment to the assert that summarizes what you 
explained in the thread.




Comment at: source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp:549
+  llvm::Optional record = StackWinRecord::parse(*It);
+  assert(record.hasValue());
+

labath wrote:
> amccarth wrote:
> > Should we log and bail out rather than just assert?  A corrupt symbol file 
> > shouldn't kill the debugger, right?
> > 
> > Also, it's Optional rather than Expected, so it seems even more plausible 
> > to hit this.
> This is an internal consistency check. An entry will be added to the 
> `m_unwind_data->win` map only if it was already parsed successfully down in 
> `ParseUnwindData`. This is parsing the same data once more, so it should 
> always succeed.
> 
> Now the next question is, why parse the same data twice? :)
> The first parse is to build an index of the ranges covered by the breakpad 
> file. In the second pass we actually parse the undwind data. Theoretically we 
> could avoid the second parse if we stored more data in the first one. 
> However, here I am operating under the assumption that most record will not 
> be touched, so it's worth to save some space for *each* record for the price 
> of having to parse twice *some* of them. This seems like a good tradeoff 
> intuitively, but I am don't have hard data to back that up.
> 
> Also, the case was much stronger for STACK CFI records (which do the same 
> thing), as there I only have to put the STACK CFI INIT records into the map 
> (and each INIT record is followed by a potentially large number of non-INIT 
> records). STACK WIN records don't have an INIT records, so I have to insert 
> all of them anyway, which makes the savings smaller, but it still seems worth 
> it.
Cool.  Could you just add a comment at the assertion that says a short version 
of that.  For example, "We've already parsed it once, so it shouldn't fail this 
time."


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

https://reviews.llvm.org/D67067



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


[Lldb-commits] [PATCH] D67123: [lldb] Early exit in RangeDataVector:FindEntryIndexesThatContain

2019-09-04 Thread Adrian McCarthy via Phabricator via lldb-commits
amccarth added inline comments.



Comment at: lldb/include/lldb/Utility/RangeMap.h:739
+auto end = std::lower_bound(m_entries.begin(), m_entries.end(),
+Entry(addr, 1), BaseLessEqual);
+for (auto I = m_entries.begin(); I != end; ++I) {

teemperor wrote:
> labath wrote:
> > amccarth wrote:
> > > You're trying to find an upper bound, so `std::upper_bound` seems more 
> > > natural than `std::lower_bound`.  Understanding how `std::lower_bound` 
> > > works with a comparator that implements `<=` requires some mental 
> > > gymnastics.  With `std::upper_bound`, you'd just need `<` that compares 
> > > only the base addresses.
> > > 
> > > You could even avoid the custom comparison function by using the maximum 
> > > value for the size:
> > > 
> > > ```
> > > auto end = std::upper_bound(m_entries.begin(), m_entries.end(),
> > > Entry(addr, 
> > > std::numeric_limits::max()));
> > > ```
> > > 
> > Actually, If I understand this correctly, there is no need for either lower 
> > or upper bound here. Since you're going to be iterating through the list 
> > anyway. It should be sufficient to add a early exit from the loop once you 
> > encounter an element whose base address is >= the address you search for.
> Oh true, I got confused by all the other lower_bounding we do in the 
> surrounding functions :)
I still don't see the early exit from the loop.  Have you uploaded the latest 
diff to Phabricator?

(Thanks Pavel for pointing out the obvious that teemperor and I both missed.)


Repository:
  rL LLVM

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

https://reviews.llvm.org/D67123



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


[Lldb-commits] [PATCH] D67123: [lldb] Early exit in RangeDataVector:FindEntryIndexesThatContain

2019-09-04 Thread Adrian McCarthy via Phabricator via lldb-commits
amccarth added a comment.

Disregard my last comment.  Phabricator wasn't showing me that latest, nor that 
the patch had already been submitted, which seems to be happening with 
increasing frequency.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D67123



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


Re: [Lldb-commits] [lldb] r370848 - [lldb][NFC] Add a simple test for thread_local storage.

2019-09-04 Thread Shafik Yaghmour via lldb-commits
It seems like it would also be useful to test that threads actually see their 
own copy as well.

> On Sep 4, 2019, at 1:02 AM, Raphael Isemann via lldb-commits 
>  wrote:
> 
> Author: teemperor
> Date: Wed Sep  4 01:02:52 2019
> New Revision: 370848
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=370848&view=rev
> Log:
> [lldb][NFC] Add a simple test for thread_local storage.
> 
> Seems we fail to read TLS data on Linux, so the test only runs on
> macOS for now. We will see how this test runs on the BSD bots.
> 
> Added:
>lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/
>lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/Makefile
>
> lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/TestThreadLocal.py
>lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/main.cpp
> 
> Added: 
> lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/Makefile
> URL: 
> http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/Makefile?rev=370848&view=auto
> ==
> --- lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/Makefile 
> (added)
> +++ lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/Makefile 
> Wed Sep  4 01:02:52 2019
> @@ -0,0 +1,3 @@
> +LEVEL = ../../../make
> +CXX_SOURCES := main.cpp
> +include $(LEVEL)/Makefile.rules
> 
> Added: 
> lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/TestThreadLocal.py
> URL: 
> http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/TestThreadLocal.py?rev=370848&view=auto
> ==
> --- 
> lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/TestThreadLocal.py
>  (added)
> +++ 
> lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/TestThreadLocal.py
>  Wed Sep  4 01:02:52 2019
> @@ -0,0 +1,5 @@
> +from lldbsuite.test import lldbinline
> +from lldbsuite.test import decorators
> +
> +lldbinline.MakeInlineTest(__file__, globals(),
> +  lldbinline.expectedFailureAll(oslist=["windows", 
> "linux"]))
> 
> Added: 
> lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/main.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/main.cpp?rev=370848&view=auto
> ==
> --- lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/main.cpp 
> (added)
> +++ lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/main.cpp 
> Wed Sep  4 01:02:52 2019
> @@ -0,0 +1,17 @@
> +int storage = 45;
> +thread_local int tl_global_int = 123;
> +thread_local int *tl_global_ptr = &storage;
> +
> +int main(int argc, char **argv) {
> +  //% self.expect("expr tl_local_int", error=True, substrs=["couldn't get 
> the value of variable tl_local_int"])
> +  //% self.expect("expr *tl_local_ptr", error=True, substrs=["couldn't get 
> the value of variable tl_local_ptr"])
> +  thread_local int tl_local_int = 321;
> +  thread_local int *tl_local_ptr = nullptr;
> +  tl_local_ptr = &tl_local_int;
> +  tl_local_int++;
> +  //% self.expect("expr tl_local_int + 1", substrs=["int", "= 323"])
> +  //% self.expect("expr *tl_local_ptr + 2", substrs=["int", "= 324"])
> +  //% self.expect("expr tl_global_int", substrs=["int", "= 123"])
> +  //% self.expect("expr *tl_global_ptr", substrs=["int", "= 45"])
> +  return 0;
> +}
> 
> 
> ___
> lldb-commits mailing list
> lldb-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

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


[Lldb-commits] [lldb] r370931 - Upstream macCatalyst support in debugserver and the macOS dynamic loader

2019-09-04 Thread Adrian Prantl via lldb-commits
Author: adrian
Date: Wed Sep  4 10:23:15 2019
New Revision: 370931

URL: http://llvm.org/viewvc/llvm-project?rev=370931&view=rev
Log:
Upstream macCatalyst support in debugserver and the macOS dynamic loader
plugin.

Unfortunately the test is currently XFAILed because of missing changes
to the clang driver.

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

Added:
lldb/trunk/packages/Python/lldbsuite/test/macosx/macabi/
lldb/trunk/packages/Python/lldbsuite/test/macosx/macabi/Makefile

lldb/trunk/packages/Python/lldbsuite/test/macosx/macabi/TestMacABImacOSFramework.py
lldb/trunk/packages/Python/lldbsuite/test/macosx/macabi/dylib.mk
lldb/trunk/packages/Python/lldbsuite/test/macosx/macabi/foo.c
lldb/trunk/packages/Python/lldbsuite/test/macosx/macabi/foo.h
lldb/trunk/packages/Python/lldbsuite/test/macosx/macabi/main.c
Modified:
lldb/trunk/include/lldb/Core/Module.h
lldb/trunk/include/lldb/Host/macosx/HostInfoMacOSX.h
lldb/trunk/include/lldb/Target/Process.h
lldb/trunk/packages/Python/lldbsuite/test/make/Makefile.rules

lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteHostInfo.py
lldb/trunk/source/Core/Module.cpp
lldb/trunk/source/Host/macosx/objcxx/HostInfoMacOSX.mm
lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h

lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h

lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm

Modified: lldb/trunk/include/lldb/Core/Module.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Module.h?rev=370931&r1=370930&r2=370931&view=diff
==
--- lldb/trunk/include/lldb/Core/Module.h (original)
+++ lldb/trunk/include/lldb/Core/Module.h Wed Sep  4 10:23:15 2019
@@ -895,6 +895,9 @@ public:
   bool RemapSourceFile(llvm::StringRef path, std::string &new_path) const;
   bool RemapSourceFile(const char *, std::string &) const = delete;
 
+  /// Update the ArchSpec to a more specific variant.
+  bool MergeArchitecture(const ArchSpec &arch_spec);
+
   /// \class LookupInfo Module.h "lldb/Core/Module.h"
   /// A class that encapsulates name lookup information.
   ///

Modified: lldb/trunk/include/lldb/Host/macosx/HostInfoMacOSX.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/macosx/HostInfoMacOSX.h?rev=370931&r1=370930&r2=370931&view=diff
==
--- lldb/trunk/include/lldb/Host/macosx/HostInfoMacOSX.h (original)
+++ lldb/trunk/include/lldb/Host/macosx/HostInfoMacOSX.h Wed Sep  4 10:23:15 
2019
@@ -27,6 +27,7 @@ private:
 
 public:
   static llvm::VersionTuple GetOSVersion();
+  static llvm::VersionTuple GetMacCatalystVersion();
   static bool GetOSBuildString(std::string &s);
   static bool GetOSKernelDescription(std::string &s);
   static FileSpec GetProgramFileSpec();

Modified: lldb/trunk/include/lldb/Target/Process.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=370931&r1=370930&r2=370931&view=diff
==
--- lldb/trunk/include/lldb/Target/Process.h (original)
+++ lldb/trunk/include/lldb/Target/Process.h Wed Sep  4 10:23:15 2019
@@ -1196,6 +1196,9 @@ public:
   /// VersionTuple is returner.
   virtual llvm::VersionTuple GetHostOSVersion() { return llvm::VersionTuple(); 
}
 
+  /// \return the macCatalyst version of the host OS.
+  virtual llvm::VersionTuple GetHostMacCatalystVersion() { return {}; }
+
   /// Get the target object pointer for this module.
   ///
   /// \return

Added: lldb/trunk/packages/Python/lldbsuite/test/macosx/macabi/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/macosx/macabi/Makefile?rev=370931&view=auto
==
--- lldb/trunk/packages/Python/lldbsuite/test/macosx/macabi/Makefile (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/macosx/macabi/Makefile Wed Sep  4 
10:23:15 2019
@@ -0,0 +1,18 @@
+LEVEL = ../../make
+
+C_SOURCES := main.c
+LD_EXTRAS := -L. -lfoo
+
+TRIPLE := x86_64-apple-ios13.0-macabi
+CFLAGS_EXTRAS := -target $(TRIPLE)
+
+all: libfoo.dylib a.out
+
+lib%.dylib: %.c
+   $(MAKE) MAKE_DSYM=YES CC=$(CC) \
+   ARCH=$(ARCH) DSYMUTIL=$(DSYMUTIL) \
+   BASENAME=$(shell basename $< .c) \
+   TRIPLE=x86_64-apple-macosx10.15 SDKROOT=$(SDKROOT) \
+   VPATH=$(S

[Lldb-commits] [PATCH] D67022: Enhance SymbolFileDWARF::ParseDeclsForContext performance

2019-09-04 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

In D67022#1656874 , @labath wrote:

> Thanks for the clarification Greg.
>
> Functionally, this patch seems fine, but I am still wondering if we shouldn't 
> make this more efficient. std::set is not the most memory-efficient 
> structure, and so creating a std::set entry just to store one bit seems 
> wasteful, particularly as there is already a container which uses the context 
> as a key (`m_decl_ctx_to_die`). Could just shove this bit into the 
> `m_decl_ctx_to_die` map (probably by changing it to something functionally 
> equivalent to `map>>`)? Given that 
> the sole "raison d´être" of this map is to enable the `ParseDeclsForContext` 
> functionality, I don't think that having that flag be stored there should be 
> awkward. Quite the opposite, it would remove the awkward back-and-forth 
> between the SymbolFileDWARF and the DWARFASTParsers (symbol file calls 
> `ForEachDIEInDeclContext`, passing it a callback; then ast parser calls the 
> callback; finally the callback immediately re-enters the parser via 
> `GetDeclForUIDFromDWARF`) -- instead we could just have the SymbolFileDWARF 
> do 
> `ast_parser->PleaseParseAllDiesInThisContextIfTheyHaventBeenParsedAlready(ctx)`
>  and have everything happen inside the parser.
>
> So, overall, it seems to me that this way, we could improve the code 
> readability while reducing the time, and avoiding a bigger memory increase. 
> In fact, since we now will not be using the list of dies after they have been 
> parsed once, we could even free up the vector after the parsing is 
> complete, and thereby reduce the memory footprint as well.  That would be a 
> win-win-win scenario. :)
>
> WDYT?


Great idea, but this idea gave me the idea  to use "m_decl_ctx_to_die" as is, 
and just remove the entry once we have parse all decls. Then we free the memory 
and don't need a bit. If there is no entry in the m_decl_ctx_to_die map, then 
ForEachDIEInDeclContext will just not iterate at all?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67022



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


[Lldb-commits] [PATCH] D67183: [Python] Implement truth testing for lldb.value

2019-09-04 Thread Davide Italiano via Phabricator via lldb-commits
davide accepted this revision.
davide added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D67183



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


[Lldb-commits] [PATCH] D67184: [Python] Implement __next__ for value_iter

2019-09-04 Thread Davide Italiano via Phabricator via lldb-commits
davide accepted this revision.
davide added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D67184



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


[Lldb-commits] [PATCH] D67022: Enhance SymbolFileDWARF::ParseDeclsForContext performance

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

In D67022#1658057 , @clayborg wrote:

> Great idea, but this idea gave me the idea  to use "m_decl_ctx_to_die" as is, 
> and just remove the entry once we have parse all decls. Then we free the 
> memory and don't need a bit. If there is no entry in the m_decl_ctx_to_die 
> map, then ForEachDIEInDeclContext will just not iterate at all?


Yes, that sounds even better!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67022



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


[Lldb-commits] [lldb] r370953 - [Python] Implement truth testing for lldb.value

2019-09-04 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Wed Sep  4 11:59:10 2019
New Revision: 370953

URL: http://llvm.org/viewvc/llvm-project?rev=370953&view=rev
Log:
[Python] Implement truth testing for lldb.value

Python 3 calls __bool__() instead of __len__() and lldb.value only
implemented the __len__ method. This adds the __bool__() implementation.

Differential revision: https://reviews.llvm.org/D67183

Modified:
lldb/trunk/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py
lldb/trunk/scripts/Python/python-extensions.swig

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py?rev=370953&r1=370952&r2=370953&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py 
(original)
+++ lldb/trunk/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py 
Wed Sep  4 11:59:10 2019
@@ -160,6 +160,10 @@ class ValueAPITestCase(TestBase):
 val_i.GetType()).AddressOf(),
 VALID_VARIABLE)
 
+# Check that lldb.value implements truth testing.
+self.assertFalse(lldb.value(frame0.FindVariable('bogus')))
+self.assertTrue(lldb.value(frame0.FindVariable('uinthex')))
+
 self.assertTrue(int(lldb.value(frame0.FindVariable('uinthex')))
 == 3768803088, 'uinthex == 3768803088')
 self.assertTrue(int(lldb.value(frame0.FindVariable('sinthex')))

Modified: lldb/trunk/scripts/Python/python-extensions.swig
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/python-extensions.swig?rev=370953&r1=370952&r2=370953&view=diff
==
--- lldb/trunk/scripts/Python/python-extensions.swig (original)
+++ lldb/trunk/scripts/Python/python-extensions.swig Wed Sep  4 11:59:10 2019
@@ -980,6 +980,9 @@ class value(object):
 def __nonzero__(self):
 return self.sbvalue.__nonzero__()
 
+def __bool__(self):
+return self.sbvalue.__bool__()
+
 def __str__(self):
 return self.sbvalue.__str__()
 


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


[Lldb-commits] [lldb] r370952 - [Python] Fix whitespace before making changes (NFC)

2019-09-04 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Wed Sep  4 11:59:06 2019
New Revision: 370952

URL: http://llvm.org/viewvc/llvm-project?rev=370952&view=rev
Log:
[Python] Fix whitespace before making changes (NFC)

Modified:
lldb/trunk/scripts/Python/python-extensions.swig

Modified: lldb/trunk/scripts/Python/python-extensions.swig
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/python-extensions.swig?rev=370952&r1=370951&r2=370952&view=diff
==
--- lldb/trunk/scripts/Python/python-extensions.swig (original)
+++ lldb/trunk/scripts/Python/python-extensions.swig Wed Sep  4 11:59:06 2019
@@ -46,18 +46,18 @@
 return lldb_private::PythonString("").release();
 }
 %clearnothreadallow;
-
-%pythoncode %{ 
+
+%pythoncode %{
 def __eq__(self, rhs):
-if not isinstance(rhs, type(self)): 
-return False 
-
+if not isinstance(rhs, type(self)):
+return False
+
 return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs)
-
+
 def __ne__(self, rhs):
-if not isinstance(rhs, type(self)): 
-return True 
-
+if not isinstance(rhs, type(self)):
+return True
+
 return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs)
 %}
 
@@ -97,17 +97,17 @@
 }
 
 %extend lldb::SBBroadcaster {
-%pythoncode %{ 
+%pythoncode %{
 def __eq__(self, rhs):
-if not isinstance(rhs, type(self)): 
-return False 
-
+if not isinstance(rhs, type(self)):
+return False
+
 return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs)
-
+
 def __ne__(self, rhs):
-if not isinstance(rhs, type(self)): 
-return True 
-
+if not isinstance(rhs, type(self)):
+return True
+
 return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs)
 %}
 }
@@ -127,7 +127,7 @@
 return lldb_private::PythonString("").release();
 }
 %clearnothreadallow;
-
+
 /* the write() and flush() calls are not part of the SB API proper, 
and are solely for Python usage
 they are meant to make an SBCommandReturnObject into a file-like 
object so that instructions of the sort
 print >>sb_command_return_object, "something"
@@ -156,17 +156,17 @@
 return lldb_private::PythonString("").release();
 }
 %clearnothreadallow;
-%pythoncode %{ 
+%pythoncode %{
 def __eq__(self, rhs):
-if not isinstance(rhs, type(self)): 
-return False 
-
+if not isinstance(rhs, type(self)):
+return False
+
 return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs)
-
+
 def __ne__(self, rhs):
-if not isinstance(rhs, type(self)): 
-return True 
-
+if not isinstance(rhs, type(self)):
+return True
+
 return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs)
 %}
 }
@@ -217,18 +217,18 @@
 return lldb_private::PythonString("").release();
 }
 %clearnothreadallow;
-
-%pythoncode %{ 
+
+%pythoncode %{
 def __eq__(self, rhs):
-if not isinstance(rhs, type(self)): 
-return False 
-
+if not isinstance(rhs, type(self)):
+return False
+
 return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs)
-
+
 def __ne__(self, rhs):
-if not isinstance(rhs, type(self)): 
-return True 
-
+if not isinstance(rhs, type(self)):
+return True
+
 return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs)
 %}
 
@@ -296,18 +296,18 @@
 return lldb_private::PythonString("").release();
 }
 %clearnothreadallow;
-
-%pythoncode %{ 
+
+%pythoncode %{
 def __eq__(self, rhs):
-if not isinstance(rhs, type(self)): 
-return False 
-
+if not isinstance(rhs, type(self)):
+return False
+
 return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs)
-
+
 def __ne__(self, rhs):
-if not isinstance(rhs, type(self)): 
-return True 
-
+if not isinstance(rhs, type(self)):
+return True
+
 return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs)
 %}
 
@@ -359,18 +359,18 @@
 return lldb_private::PythonString("

[Lldb-commits] [lldb] r370954 - [Python] Implement __next__ for value_iter

2019-09-04 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Wed Sep  4 11:59:13 2019
New Revision: 370954

URL: http://llvm.org/viewvc/llvm-project?rev=370954&view=rev
Log:
[Python] Implement __next__ for value_iter

Python 3 iteration calls the next() method instead of next() and
value_iter only implemented the Python 2 version.

Differential revision: https://reviews.llvm.org/D67184

Modified:
lldb/trunk/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py
lldb/trunk/scripts/Python/python-extensions.swig

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py?rev=370954&r1=370953&r2=370954&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py 
(original)
+++ lldb/trunk/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py 
Wed Sep  4 11:59:13 2019
@@ -169,6 +169,13 @@ class ValueAPITestCase(TestBase):
 self.assertTrue(int(lldb.value(frame0.FindVariable('sinthex')))
 == -526164208, 'sinthex == -526164208')
 
+# Check value_iter works correctly.
+for v in [
+lldb.value(frame0.FindVariable('uinthex')),
+lldb.value(frame0.FindVariable('sinthex'))
+]:
+self.assertTrue(v)
+
 self.assertTrue(
 frame0.FindVariable('uinthex').GetValueAsUnsigned() == 3768803088,
 'unsigned uinthex == 3768803088')

Modified: lldb/trunk/scripts/Python/python-extensions.swig
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/python-extensions.swig?rev=370954&r1=370953&r2=370954&view=diff
==
--- lldb/trunk/scripts/Python/python-extensions.swig (original)
+++ lldb/trunk/scripts/Python/python-extensions.swig Wed Sep  4 11:59:13 2019
@@ -946,13 +946,16 @@ class value_iter(object):
 def __iter__(self):
 return self
 
-def next(self):
+def __next__(self):
 if self.index >= self.length:
 raise StopIteration()
 child_sbvalue = self.sbvalue.GetChildAtIndex(self.index)
 self.index += 1
 return value(child_sbvalue)
 
+def next(self):
+return self.__next__()
+
 def __init__(self,value):
 self.index = 0
 self.sbvalue = value


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


[Lldb-commits] [PATCH] D67183: [Python] Implement truth testing for lldb.value

2019-09-04 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL370953: [Python] Implement truth testing for lldb.value 
(authored by JDevlieghere, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67183?vs=218724&id=218763#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67183

Files:
  lldb/trunk/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py
  lldb/trunk/scripts/Python/python-extensions.swig


Index: lldb/trunk/scripts/Python/python-extensions.swig
===
--- lldb/trunk/scripts/Python/python-extensions.swig
+++ lldb/trunk/scripts/Python/python-extensions.swig
@@ -980,6 +980,9 @@
 def __nonzero__(self):
 return self.sbvalue.__nonzero__()
 
+def __bool__(self):
+return self.sbvalue.__bool__()
+
 def __str__(self):
 return self.sbvalue.__str__()
 
Index: 
lldb/trunk/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py
+++ lldb/trunk/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py
@@ -160,6 +160,10 @@
 val_i.GetType()).AddressOf(),
 VALID_VARIABLE)
 
+# Check that lldb.value implements truth testing.
+self.assertFalse(lldb.value(frame0.FindVariable('bogus')))
+self.assertTrue(lldb.value(frame0.FindVariable('uinthex')))
+
 self.assertTrue(int(lldb.value(frame0.FindVariable('uinthex')))
 == 3768803088, 'uinthex == 3768803088')
 self.assertTrue(int(lldb.value(frame0.FindVariable('sinthex')))


Index: lldb/trunk/scripts/Python/python-extensions.swig
===
--- lldb/trunk/scripts/Python/python-extensions.swig
+++ lldb/trunk/scripts/Python/python-extensions.swig
@@ -980,6 +980,9 @@
 def __nonzero__(self):
 return self.sbvalue.__nonzero__()
 
+def __bool__(self):
+return self.sbvalue.__bool__()
+
 def __str__(self):
 return self.sbvalue.__str__()
 
Index: lldb/trunk/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py
+++ lldb/trunk/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py
@@ -160,6 +160,10 @@
 val_i.GetType()).AddressOf(),
 VALID_VARIABLE)
 
+# Check that lldb.value implements truth testing.
+self.assertFalse(lldb.value(frame0.FindVariable('bogus')))
+self.assertTrue(lldb.value(frame0.FindVariable('uinthex')))
+
 self.assertTrue(int(lldb.value(frame0.FindVariable('uinthex')))
 == 3768803088, 'uinthex == 3768803088')
 self.assertTrue(int(lldb.value(frame0.FindVariable('sinthex')))
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D67184: [Python] Implement __next__ for value_iter

2019-09-04 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL370954: [Python] Implement __next__ for value_iter (authored 
by JDevlieghere, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67184?vs=218726&id=218764#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67184

Files:
  lldb/trunk/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py
  lldb/trunk/scripts/Python/python-extensions.swig


Index: lldb/trunk/scripts/Python/python-extensions.swig
===
--- lldb/trunk/scripts/Python/python-extensions.swig
+++ lldb/trunk/scripts/Python/python-extensions.swig
@@ -946,13 +946,16 @@
 def __iter__(self):
 return self
 
-def next(self):
+def __next__(self):
 if self.index >= self.length:
 raise StopIteration()
 child_sbvalue = self.sbvalue.GetChildAtIndex(self.index)
 self.index += 1
 return value(child_sbvalue)
 
+def next(self):
+return self.__next__()
+
 def __init__(self,value):
 self.index = 0
 self.sbvalue = value
Index: 
lldb/trunk/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py
+++ lldb/trunk/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py
@@ -169,6 +169,13 @@
 self.assertTrue(int(lldb.value(frame0.FindVariable('sinthex')))
 == -526164208, 'sinthex == -526164208')
 
+# Check value_iter works correctly.
+for v in [
+lldb.value(frame0.FindVariable('uinthex')),
+lldb.value(frame0.FindVariable('sinthex'))
+]:
+self.assertTrue(v)
+
 self.assertTrue(
 frame0.FindVariable('uinthex').GetValueAsUnsigned() == 3768803088,
 'unsigned uinthex == 3768803088')


Index: lldb/trunk/scripts/Python/python-extensions.swig
===
--- lldb/trunk/scripts/Python/python-extensions.swig
+++ lldb/trunk/scripts/Python/python-extensions.swig
@@ -946,13 +946,16 @@
 def __iter__(self):
 return self
 
-def next(self):
+def __next__(self):
 if self.index >= self.length:
 raise StopIteration()
 child_sbvalue = self.sbvalue.GetChildAtIndex(self.index)
 self.index += 1
 return value(child_sbvalue)
 
+def next(self):
+return self.__next__()
+
 def __init__(self,value):
 self.index = 0
 self.sbvalue = value
Index: lldb/trunk/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py
+++ lldb/trunk/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py
@@ -169,6 +169,13 @@
 self.assertTrue(int(lldb.value(frame0.FindVariable('sinthex')))
 == -526164208, 'sinthex == -526164208')
 
+# Check value_iter works correctly.
+for v in [
+lldb.value(frame0.FindVariable('uinthex')),
+lldb.value(frame0.FindVariable('sinthex'))
+]:
+self.assertTrue(v)
+
 self.assertTrue(
 frame0.FindVariable('uinthex').GetValueAsUnsigned() == 3768803088,
 'unsigned uinthex == 3768803088')
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D65677: [VirtualFileSystem] Make the RedirectingFileSystem hold on to its own working directory.

2019-09-04 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 218768.
JDevlieghere retitled this revision from "[VirtualFileSystem] Support encoding 
working directories in a VFS mapping." to "[VirtualFileSystem] Make the 
RedirectingFileSystem hold on to its own working directory.".
JDevlieghere edited the summary of this revision.
JDevlieghere added a comment.

Make the RedirectingFileSystem hold on to its own working directory.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D65677

Files:
  llvm/include/llvm/Support/VirtualFileSystem.h
  llvm/lib/Support/VirtualFileSystem.cpp
  llvm/unittests/Support/VirtualFileSystemTest.cpp


Index: llvm/unittests/Support/VirtualFileSystemTest.cpp
===
--- llvm/unittests/Support/VirtualFileSystemTest.cpp
+++ llvm/unittests/Support/VirtualFileSystemTest.cpp
@@ -1994,3 +1994,38 @@
   EXPECT_EQ(FS->getRealPath("/non_existing", RealPath),
 errc::no_such_file_or_directory);
 }
+
+TEST_F(VFSFromYAMLTest, WorkingDirectory) {
+  IntrusiveRefCntPtr Lower(new DummyFileSystem());
+  Lower->addDirectory("//root/");
+  Lower->addDirectory("//root/foo");
+  Lower->addRegularFile("//root/foo/a");
+  Lower->addRegularFile("//root/foo/b");
+  IntrusiveRefCntPtr FS = getFromYAMLString(
+  "{ 'use-external-names': false,\n"
+  "  'roots': [\n"
+  "{\n"
+  "  'type': 'directory',\n"
+  "  'name': '//root/',\n"
+  "  'contents': [ {\n"
+  "  'type': 'file',\n"
+  "  'name': 'bar/a',\n"
+  "  'external-contents': '//root/foo/a'\n"
+  "}\n"
+  "  ]\n"
+  "}\n"
+  "]\n"
+  "}",
+  Lower);
+  ASSERT_TRUE(FS.get() != nullptr);
+  FS->setCurrentWorkingDirectory("//root/bar/");
+
+  llvm::ErrorOr Status = FS->status("./a");
+  ASSERT_FALSE(Status.getError());
+  EXPECT_TRUE(Status->isStatusKnown());
+  EXPECT_FALSE(Status->isDirectory());
+  EXPECT_TRUE(Status->isRegularFile());
+  EXPECT_FALSE(Status->isSymlink());
+  EXPECT_FALSE(Status->isOther());
+  EXPECT_TRUE(Status->exists());
+}
Index: llvm/lib/Support/VirtualFileSystem.cpp
===
--- llvm/lib/Support/VirtualFileSystem.cpp
+++ llvm/lib/Support/VirtualFileSystem.cpp
@@ -1035,12 +1035,13 @@
 
 llvm::ErrorOr
 RedirectingFileSystem::getCurrentWorkingDirectory() const {
-  return ExternalFS->getCurrentWorkingDirectory();
+  return WorkingDirectory;
 }
 
 std::error_code
 RedirectingFileSystem::setCurrentWorkingDirectory(const Twine &Path) {
-  return ExternalFS->setCurrentWorkingDirectory(Path);
+  WorkingDirectory = Path.str();
+  return {};
 }
 
 std::error_code RedirectingFileSystem::isLocal(const Twine &Path,
Index: llvm/include/llvm/Support/VirtualFileSystem.h
===
--- llvm/include/llvm/Support/VirtualFileSystem.h
+++ llvm/include/llvm/Support/VirtualFileSystem.h
@@ -650,6 +650,9 @@
   /// The root(s) of the virtual file system.
   std::vector> Roots;
 
+  /// The current working directory of the file system.
+  std::string WorkingDirectory;
+
   /// The file system to use for external references.
   IntrusiveRefCntPtr ExternalFS;
 


Index: llvm/unittests/Support/VirtualFileSystemTest.cpp
===
--- llvm/unittests/Support/VirtualFileSystemTest.cpp
+++ llvm/unittests/Support/VirtualFileSystemTest.cpp
@@ -1994,3 +1994,38 @@
   EXPECT_EQ(FS->getRealPath("/non_existing", RealPath),
 errc::no_such_file_or_directory);
 }
+
+TEST_F(VFSFromYAMLTest, WorkingDirectory) {
+  IntrusiveRefCntPtr Lower(new DummyFileSystem());
+  Lower->addDirectory("//root/");
+  Lower->addDirectory("//root/foo");
+  Lower->addRegularFile("//root/foo/a");
+  Lower->addRegularFile("//root/foo/b");
+  IntrusiveRefCntPtr FS = getFromYAMLString(
+  "{ 'use-external-names': false,\n"
+  "  'roots': [\n"
+  "{\n"
+  "  'type': 'directory',\n"
+  "  'name': '//root/',\n"
+  "  'contents': [ {\n"
+  "  'type': 'file',\n"
+  "  'name': 'bar/a',\n"
+  "  'external-contents': '//root/foo/a'\n"
+  "}\n"
+  "  ]\n"
+  "}\n"
+  "]\n"
+  "}",
+  Lower);
+  ASSERT_TRUE(FS.get() != nullptr);
+  FS->setCurrentWorkingDirectory("//root/bar/");
+
+  llvm::ErrorOr Status = FS->status("./a");
+  ASSERT_FALSE(Status.getError());
+  EXPECT_TRUE(Status->isStatusKnown());
+  EXPECT_FALSE(Status->isDirectory());
+  EXPECT_TRUE(Status->isRegularFile());
+  EXPECT_FALSE(Status->isSymlink());
+  EXPECT_FALSE(Status->isOther());
+  EXPECT_TRUE(Status->exists());
+}
Index: llvm/lib/Support/VirtualFileSystem.cpp
===
--- llvm/lib/Support/VirtualFileSys

[Lldb-commits] [lldb] r370963 - Revert "[test] Address TestConcurrentMany*.py flakiness on macOS"

2019-09-04 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Wed Sep  4 12:36:29 2019
New Revision: 370963

URL: http://llvm.org/viewvc/llvm-project?rev=370963&view=rev
Log:
Revert "[test] Address TestConcurrentMany*.py flakiness on macOS"

This reverts my change to pseudo_barrier.h which isn't necessary anymore
after Fred's fix to debugserver and caused TestThreadStepOut to fail.

Modified:
lldb/trunk/packages/Python/lldbsuite/test/make/pseudo_barrier.h

Modified: lldb/trunk/packages/Python/lldbsuite/test/make/pseudo_barrier.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/make/pseudo_barrier.h?rev=370963&r1=370962&r2=370963&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/make/pseudo_barrier.h (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/make/pseudo_barrier.h Wed Sep  4 
12:36:29 2019
@@ -1,14 +1,21 @@
 #include 
-#include 
+
+// Note that although hogging the CPU while waiting for a variable to change
+// would be terrible in production code, it's great for testing since it avoids
+// a lot of messy context switching to get multiple threads synchronized.
 
 typedef std::atomic pseudo_barrier_t;
 
-static inline void pseudo_barrier_wait(pseudo_barrier_t &barrier) {
-  --barrier;
-  while (barrier > 0)
-std::this_thread::yield();
-}
+#define pseudo_barrier_wait(barrier)\
+do  \
+{   \
+--(barrier);\
+while ((barrier).load() > 0)\
+;   \
+} while (0)
 
-static inline void pseudo_barrier_init(pseudo_barrier_t &barrier, int count) {
-  barrier = count;
-}
+#define pseudo_barrier_init(barrier, count) \
+do  \
+{   \
+(barrier) = (count);\
+} while (0)


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


[Lldb-commits] [PATCH] D67022: Enhance SymbolFileDWARF::ParseDeclsForContext performance

2019-09-04 Thread Guilherme Andrade via Phabricator via lldb-commits
guiandrade updated this revision to Diff 218779.
guiandrade added a comment.

Migrating to EnsureAllDIEsInDeclContextHaveBeenParsed


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67022

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp

Index: lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
===
--- lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
+++ lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
@@ -24,24 +24,28 @@
 
 // If your implementation needs to dereference the dummy pointers we are
 // defining here, causing this test to fail, feel free to delete it.
-TEST(DWARFASTParserClangTests,
- TestGetDIEForDeclContextReturnsOnlyMatchingEntries) {
-  ClangASTContext ast_ctx;
-  DWARFASTParserClangStub ast_parser(ast_ctx);
-
-  DWARFUnit *unit = nullptr;
-  DWARFDIE die1(unit, (DWARFDebugInfoEntry *)1LL);
-  DWARFDIE die2(unit, (DWARFDebugInfoEntry *)2LL);
-  DWARFDIE die3(unit, (DWARFDebugInfoEntry *)3LL);
-  DWARFDIE die4(unit, (DWARFDebugInfoEntry *)4LL);
-  ast_parser.LinkDeclContextToDIE((clang::DeclContext *)1LL, die1);
-  ast_parser.LinkDeclContextToDIE((clang::DeclContext *)2LL, die2);
-  ast_parser.LinkDeclContextToDIE((clang::DeclContext *)2LL, die3);
-  ast_parser.LinkDeclContextToDIE((clang::DeclContext *)3LL, die4);
-
-  auto die_list = ast_parser.GetDIEForDeclContext(
-  CompilerDeclContext(nullptr, (clang::DeclContext *)2LL));
-  ASSERT_EQ(2u, die_list.size());
-  ASSERT_EQ(die2, die_list[0]);
-  ASSERT_EQ(die3, die_list[1]);
-}
+// TEST(DWARFASTParserClangTests,
+//  TestForEachDIEInDeclContextReturnsOnlyMatchingEntries) {
+//   ClangASTContext ast_ctx;
+//   DWARFASTParserClangStub ast_parser(ast_ctx);
+
+//   DWARFUnit *unit = nullptr;
+//   DWARFDIE die1(unit, (DWARFDebugInfoEntry *)1LL);
+//   DWARFDIE die2(unit, (DWARFDebugInfoEntry *)2LL);
+//   DWARFDIE die3(unit, (DWARFDebugInfoEntry *)3LL);
+//   DWARFDIE die4(unit, (DWARFDebugInfoEntry *)4LL);
+//   ast_parser.LinkDeclContextToDIE((clang::DeclContext *)1LL, die1);
+//   ast_parser.LinkDeclContextToDIE((clang::DeclContext *)2LL, die2);
+//   ast_parser.LinkDeclContextToDIE((clang::DeclContext *)2LL, die3);
+//   ast_parser.LinkDeclContextToDIE((clang::DeclContext *)3LL, die4);
+
+//   std::vector die_list;
+//   ast_parser.ForEachDIEInDeclContext(
+//   CompilerDeclContext(nullptr, (clang::DeclContext *)2LL),
+//   [&die_list](DWARFDIE die) { die_list.push_back(die); });
+
+//   ASSERT_EQ(2u, die_list.size());
+//   ASSERT_NE(die_list.end(), std::find(die_list.begin(), die_list.end(),
+//   die2)); ASSERT_NE(die_list.end(), std::find(die_list.begin(),
+//   die_list.end(), die3));
+// }
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -1204,16 +1204,9 @@
 
 void SymbolFileDWARF::ParseDeclsForContext(CompilerDeclContext decl_ctx) {
   auto *type_system = decl_ctx.GetTypeSystem();
-  if (!type_system)
-return;
-  DWARFASTParser *ast_parser = type_system->GetDWARFParser();
-  std::vector decl_ctx_die_list =
-  ast_parser->GetDIEForDeclContext(decl_ctx);
-
-  for (DWARFDIE decl_ctx_die : decl_ctx_die_list)
-for (DWARFDIE decl = decl_ctx_die.GetFirstChild(); decl;
- decl = decl.GetSibling())
-  ast_parser->GetDeclForUIDFromDWARF(decl);
+  if (type_system != nullptr)
+type_system->GetDWARFParser()->EnsureAllDIEsInDeclContextHaveBeenParsed(
+decl_ctx);
 }
 
 user_id_t SymbolFileDWARF::GetUID(DIERef ref) {
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
@@ -51,8 +51,8 @@
   lldb_private::CompilerDecl
   GetDeclForUIDFromDWARF(const DWARFDIE &die) override;
 
-  std::vector
-  GetDIEForDeclContext(lldb_private::CompilerDeclContext decl_context) override;
+  void EnsureAllDIEsInDeclContextHaveBeenParsed(
+  lldb_private::CompilerDeclContext decl_context) override;
 
   lldb_private::CompilerDeclContext
   GetDeclContextForUIDFromDWARF(const DWARFDIE &die) override;
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -2183

[Lldb-commits] [PATCH] D67022: Enhance SymbolFileDWARF::ParseDeclsForContext performance

2019-09-04 Thread Guilherme Andrade via Phabricator via lldb-commits
guiandrade added a comment.

In D67022#1658057 , @clayborg wrote:

> In D67022#1656874 , @labath wrote:
>
> > Thanks for the clarification Greg.
> >
> > Functionally, this patch seems fine, but I am still wondering if we 
> > shouldn't make this more efficient. std::set is not the most 
> > memory-efficient structure, and so creating a std::set entry just to store 
> > one bit seems wasteful, particularly as there is already a container which 
> > uses the context as a key (`m_decl_ctx_to_die`). Could just shove this bit 
> > into the `m_decl_ctx_to_die` map (probably by changing it to something 
> > functionally equivalent to `map > vector>>`)? Given that the sole "raison d´être" of this map is to 
> > enable the `ParseDeclsForContext` functionality, I don't think that having 
> > that flag be stored there should be awkward. Quite the opposite, it would 
> > remove the awkward back-and-forth between the SymbolFileDWARF and the 
> > DWARFASTParsers (symbol file calls `ForEachDIEInDeclContext`, passing it a 
> > callback; then ast parser calls the callback; finally the callback 
> > immediately re-enters the parser via `GetDeclForUIDFromDWARF`) -- instead 
> > we could just have the SymbolFileDWARF do 
> > `ast_parser->PleaseParseAllDiesInThisContextIfTheyHaventBeenParsedAlready(ctx)`
> >  and have everything happen inside the parser.
> >
> > So, overall, it seems to me that this way, we could improve the code 
> > readability while reducing the time, and avoiding a bigger memory increase. 
> > In fact, since we now will not be using the list of dies after they have 
> > been parsed once, we could even free up the vector after the 
> > parsing is complete, and thereby reduce the memory footprint as well.  That 
> > would be a win-win-win scenario. :)
> >
> > WDYT?
>
>
> Great idea, but this idea gave me the idea  to use "m_decl_ctx_to_die" as is, 
> and just remove the entry once we have parse all decls. Then we free the 
> memory and don't need a bit. If there is no entry in the m_decl_ctx_to_die 
> map, then ForEachDIEInDeclContext will just not iterate at all?


Thanks for the ideas, I think they greatly simplify the code. Let me know what 
you guys think of my implementation. I think the main issue with it is that it 
makes it hard to unit test it...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67022



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


[Lldb-commits] [PATCH] D67022: Enhance SymbolFileDWARF::ParseDeclsForContext performance

2019-09-04 Thread Guilherme Andrade via Phabricator via lldb-commits
guiandrade added inline comments.



Comment at: lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp:27
 // defining here, causing this test to fail, feel free to delete it.
-TEST(DWARFASTParserClangTests,
- TestGetDIEForDeclContextReturnsOnlyMatchingEntries) {
-  ClangASTContext ast_ctx;
-  DWARFASTParserClangStub ast_parser(ast_ctx);
-
-  DWARFUnit *unit = nullptr;
-  DWARFDIE die1(unit, (DWARFDebugInfoEntry *)1LL);
-  DWARFDIE die2(unit, (DWARFDebugInfoEntry *)2LL);
-  DWARFDIE die3(unit, (DWARFDebugInfoEntry *)3LL);
-  DWARFDIE die4(unit, (DWARFDebugInfoEntry *)4LL);
-  ast_parser.LinkDeclContextToDIE((clang::DeclContext *)1LL, die1);
-  ast_parser.LinkDeclContextToDIE((clang::DeclContext *)2LL, die2);
-  ast_parser.LinkDeclContextToDIE((clang::DeclContext *)2LL, die3);
-  ast_parser.LinkDeclContextToDIE((clang::DeclContext *)3LL, die4);
-
-  auto die_list = ast_parser.GetDIEForDeclContext(
-  CompilerDeclContext(nullptr, (clang::DeclContext *)2LL));
-  ASSERT_EQ(2u, die_list.size());
-  ASSERT_EQ(die2, die_list[0]);
-  ASSERT_EQ(die3, die_list[1]);
-}
+// TEST(DWARFASTParserClangTests,
+//  TestForEachDIEInDeclContextReturnsOnlyMatchingEntries) {

Once we agree on how to move forward, the idea is to delete/modify this, not 
leave it commented out


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67022



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


[Lldb-commits] [lldb] r370983 - [test] Escape path to match the literal string

2019-09-04 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Wed Sep  4 14:18:46 2019
New Revision: 370983

URL: http://llvm.org/viewvc/llvm-project?rev=370983&view=rev
Log:
[test] Escape path to match the literal string

This test was failing when you had things like `+` in your build path.

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py?rev=370983&r1=370982&r2=370983&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py
 Wed Sep  4 14:18:46 2019
@@ -280,7 +280,7 @@ class LoadUnloadTestCase(TestBase):
 "process load %s --install=%s" % (localDylibPath, remoteDylibPath),
 "%s loaded correctly" % dylibName,
 patterns=[
-'Loading "%s".*ok' % localDylibPath,
+'Loading "%s".*ok' % re.escape(localDylibPath),
 'Image [0-9]+ loaded'])
 
 # Search for and match the "Image ([0-9]+) loaded" pattern.


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


[Lldb-commits] [PATCH] D67168: [Windows] Add support of watchpoints to `ProcessWindows`

2019-09-04 Thread Adrian McCarthy via Phabricator via lldb-commits
amccarth added inline comments.



Comment at: lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp:397
+if (slot != LLDB_INVALID_INDEX32) {
+  int id = m_watchpoint_slots[slot];
+  LLDB_LOG(log,

The names here are a bit confusing:  `GetTriggeredHardwareBreakpointSlot` 
doesn't return a slot; it returns the index of a slot, so  `slot` also isn't a 
slot, but the index of a slot.  `m_watchpoint_slots` is not a collection of 
slots but IDs, that's indexed by an index called a `slot`.

It may not be possible to completely rationalize this, but doing even a little 
could help future readers understand.  For example, `slot` could be 
`slot_index`, and `m_watchpoint_slots` could be `m_watchpoint_ids` (or even 
just `m_watchpoints`).



Comment at: lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp:525
   for (const auto &thread_info : m_session_data->m_new_threads) {
-ThreadSP thread(new TargetThreadWindows(*this, thread_info.second));
-thread->SetID(thread_info.first);
-new_thread_list.AddThread(thread);
+new_thread_list.AddThread(thread_info.second);
 ++new_size;

This no longer sets the thread ID.  Was that intentional?



Comment at: lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp:743
 
-void ProcessWindows::OnCreateThread(const HostThread &new_thread) {
+void ProcessWindows::OnCreateThread(HostThread &new_thread) {
   llvm::sys::ScopedLock lock(m_mutex);

Can you help me why we needed to get rid of the `const` on the `HostThread &`?

If `native_new_thread` were also a const ref, I don't see any conflicting 
constraint.



Comment at: lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp:832
+  Status error;
+
+  WatchpointInfo info;

Should we check if the watchpoint is already enabled?  I noticed that 
`DisableWatchpoint` has an analogous guard clause.



Comment at: lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp:852
+RegisterContextWindows *reg_ctx = static_cast(
+thread->GetRegisterContext().get());
+if (!reg_ctx->AddHardwareBreakpoint(info.slot, info.address, info.size,

Since you have to explicitly downcast, wouldn't `auto *reg_ctx` on the left be 
sufficient and just as clear?



Comment at: 
lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp:82
 
-bool RegisterContextWindows::ClearHardwareBreakpoint(uint32_t hw_idx) {
-  return false;
-}
+  if (!size || size > 8 || size & (size - 1))
+return false;

Clever!  It took me a minute or two to figure out what the point of that was 
checking.  Perhaps a comment to explain?


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D67168



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


[Lldb-commits] [PATCH] D67111: Adding caching to libc++ std::function formatter for lookups that require scanning symbols

2019-09-04 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik updated this revision to Diff 218797.
shafik marked 2 inline comments as done.
shafik added a comment.

Addressing comments

- Using log timers to verify whether we are using the cache or not
- Switched to llvm::StringMap


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

https://reviews.llvm.org/D67111

Files:
  
packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py
  
packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/main.cpp
  source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
  source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h

Index: source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h
===
--- source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h
+++ source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h
@@ -10,6 +10,9 @@
 #define liblldb_CPPLanguageRuntime_h_
 
 #include 
+
+#include "llvm/ADT/StringMap.h"
+
 #include "lldb/Core/PluginInterface.h"
 #include "lldb/Target/LanguageRuntime.h"
 #include "lldb/lldb-private.h"
@@ -82,6 +85,11 @@
   CPPLanguageRuntime(Process *process);
 
 private:
+  using OperatorStringToCallableInfoMap =
+llvm::StringMap;
+
+  OperatorStringToCallableInfoMap CallableLookupCache;
+
   DISALLOW_COPY_AND_ASSIGN(CPPLanguageRuntime);
 };
 
Index: source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
===
--- source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
+++ source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
@@ -193,13 +193,30 @@
 symbol = sc.symbol;
   }
 
+  // Case 4 or 5
+  // We eliminate these cases early because they don't need the potentially
+  // expensive lookup through the symbol table.
+  if (symbol && !symbol->GetName().GetStringRef().startswith("vtable for") &&
+  !first_template_parameter.contains("$_") &&
+  !first_template_parameter.contains("'lambda'") &&
+  !symbol->GetName().GetStringRef().contains("__invoke")) {
+optional_info.callable_case =
+LibCppStdFunctionCallableCase::FreeOrMemberFunction;
+optional_info.callable_address = function_address_resolved;
+optional_info.callable_symbol = *symbol;
+
+return optional_info;
+  }
+
   auto get_name = [&first_template_parameter, &symbol]() {
 // Given case 1:
 //
 //main::$_0
+//Bar::add_num2(int)::'lambda'(int)
 //
 // we want to append ::operator()()
-if (first_template_parameter.contains("$_"))
+if (first_template_parameter.contains("$_") ||
+first_template_parameter.contains("'lambda'"))
   return llvm::Regex::escape(first_template_parameter.str()) +
  R"(::operator\(\)\(.*\))";
 
@@ -228,6 +245,9 @@
 
   std::string func_to_match = get_name();
 
+  if (CallableLookupCache.count(func_to_match))
+return CallableLookupCache[func_to_match];
+
   SymbolContextList scl;
 
   target.GetImages().FindSymbolsMatchingRegExAndType(
@@ -249,6 +269,7 @@
   addr.CalculateSymbolContextLineEntry(line_entry);
 
   if (first_template_parameter.contains("$_") ||
+  first_template_parameter.contains("'lambda'") ||
   (symbol != nullptr &&
symbol->GetName().GetStringRef().contains("__invoke"))) {
 // Case 1 and 2
@@ -262,19 +283,10 @@
   optional_info.callable_symbol = *symbol;
   optional_info.callable_line_entry = line_entry;
   optional_info.callable_address = addr;
-  return optional_info;
 }
   }
 
-  // Case 4 or 5
-  if (symbol && !symbol->GetName().GetStringRef().startswith("vtable for")) {
-optional_info.callable_case =
-LibCppStdFunctionCallableCase::FreeOrMemberFunction;
-optional_info.callable_address = function_address_resolved;
-optional_info.callable_symbol = *symbol;
-
-return optional_info;
-  }
+  CallableLookupCache[func_to_match] = optional_info;
 
   return optional_info;
 }
Index: packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/main.cpp
===
--- packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/main.cpp
+++ packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/main.cpp
@@ -17,8 +17,25 @@
return 66 ;
}
int add_num(int i) const { return i + 3 ; }
+   int add_num2(int i) {
+ std::function add_num2_f = [](int x) {
+ return x+1;
+  };
+
+  return add_num2_f(i); // Set break point at this line.
+   }
 } ;
 
+int foo2() {
+   auto f = [](int x) {
+   return x+1;
+   };
+
+   std::function foo2_f = f;
+
+   return foo2_f(10); // Set break point at this line.
+}
+
 int main (int argc, char *argv[])
 {
   int acc = 42;
@@ -35,5 +52,8 @@

[Lldb-commits] [lldb] r370994 - [Disassembler] Simplify a few methods (NFC)

2019-09-04 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Wed Sep  4 15:38:20 2019
New Revision: 370994

URL: http://llvm.org/viewvc/llvm-project?rev=370994&view=rev
Log:
[Disassembler] Simplify a few methods (NFC)

Use early returns to highlight preconditions and make the code easier to
follow.

Modified:
lldb/trunk/include/lldb/Symbol/SymbolContext.h
lldb/trunk/source/Core/Disassembler.cpp
lldb/trunk/source/Symbol/SymbolContext.cpp

Modified: lldb/trunk/include/lldb/Symbol/SymbolContext.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/SymbolContext.h?rev=370994&r1=370993&r2=370994&view=diff
==
--- lldb/trunk/include/lldb/Symbol/SymbolContext.h (original)
+++ lldb/trunk/include/lldb/Symbol/SymbolContext.h Wed Sep  4 15:38:20 2019
@@ -470,6 +470,8 @@ public:
   /// Returns the number of symbol context objects in the list.
   uint32_t GetSize() const;
 
+  bool IsEmpty() const;
+
   uint32_t NumLineEntriesWithLine(uint32_t line) const;
 
   void GetDescription(Stream *s, lldb::DescriptionLevel level,

Modified: lldb/trunk/source/Core/Disassembler.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Disassembler.cpp?rev=370994&r1=370993&r2=370994&view=diff
==
--- lldb/trunk/source/Core/Disassembler.cpp (original)
+++ lldb/trunk/source/Core/Disassembler.cpp Wed Sep  4 15:38:20 2019
@@ -158,52 +158,59 @@ size_t Disassembler::Disassemble(Debugge
   return success_count;
 }
 
-bool Disassembler::Disassemble(Debugger &debugger, const ArchSpec &arch,
-   const char *plugin_name, const char *flavor,
-   const ExecutionContext &exe_ctx,
-   ConstString name, Module *module,
-   uint32_t num_instructions,
-   bool mixed_source_and_assembly,
-   uint32_t num_mixed_context_lines,
-   uint32_t options, Stream &strm) {
+bool Disassembler::Disassemble(
+Debugger &debugger, const ArchSpec &arch, const char *plugin_name,
+const char *flavor, const ExecutionContext &exe_ctx, ConstString name,
+Module *module, uint32_t num_instructions, bool mixed_source_and_assembly,
+uint32_t num_mixed_context_lines, uint32_t options, Stream &strm) {
+  // If no name is given there's nothing to disassemble.
+  if (!name)
+return false;
+
+  const bool include_symbols = true;
+  const bool include_inlines = true;
+
+  // Find functions matching the given name.
   SymbolContextList sc_list;
-  if (name) {
-const bool include_symbols = true;
-const bool include_inlines = true;
-if (module) {
-  module->FindFunctions(name, nullptr, eFunctionNameTypeAuto,
-include_symbols, include_inlines, true, sc_list);
-} else if (exe_ctx.GetTargetPtr()) {
-  exe_ctx.GetTargetPtr()->GetImages().FindFunctions(
-  name, eFunctionNameTypeAuto, include_symbols, include_inlines, false,
-  sc_list);
-}
+  if (module) {
+module->FindFunctions(name, nullptr, eFunctionNameTypeAuto, 
include_symbols,
+  include_inlines, true, sc_list);
+  } else if (exe_ctx.GetTargetPtr()) {
+exe_ctx.GetTargetPtr()->GetImages().FindFunctions(
+name, eFunctionNameTypeAuto, include_symbols, include_inlines, false,
+sc_list);
   }
 
-  if (sc_list.GetSize()) {
-return Disassemble(debugger, arch, plugin_name, flavor, exe_ctx, sc_list,
-   num_instructions, mixed_source_and_assembly,
-   num_mixed_context_lines, options, strm);
-  }
-  return false;
+  // If no functions were found there's nothing to disassemble.
+  if (sc_list.IsEmpty())
+return false;
+
+  return Disassemble(debugger, arch, plugin_name, flavor, exe_ctx, sc_list,
+ num_instructions, mixed_source_and_assembly,
+ num_mixed_context_lines, options, strm);
 }
 
 lldb::DisassemblerSP Disassembler::DisassembleRange(
 const ArchSpec &arch, const char *plugin_name, const char *flavor,
 const ExecutionContext &exe_ctx, const AddressRange &range,
 bool prefer_file_cache) {
-  lldb::DisassemblerSP disasm_sp;
-  if (range.GetByteSize() > 0 && range.GetBaseAddress().IsValid()) {
-disasm_sp = Disassembler::FindPluginForTarget(exe_ctx.GetTargetSP(), arch,
-  flavor, plugin_name);
-
-if (disasm_sp) {
-  size_t bytes_disassembled = disasm_sp->ParseInstructions(
-  &exe_ctx, range, nullptr, prefer_file_cache);
-  if (bytes_disassembled == 0)
-disasm_sp.reset();
-}
-  }
+  if (range.GetByteSize() <= 0)
+return {};
+
+  if (!range.GetBaseAddress().IsValid())
+return {};
+
+  lldb::DisassemblerSP disasm_sp = Disassembler::FindPluginForTarget(
+  e

[Lldb-commits] [PATCH] D67111: Adding caching to libc++ std::function formatter for lookups that require scanning symbols

2019-09-04 Thread Frederic Riss via Phabricator via lldb-commits
friss added inline comments.



Comment at: 
packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py:49-59
+self.runCmd("log timers reset")
+self.expect("frame variable foo2_f",
+substrs=['foo2_f =  Lambda in File main.cpp at Line 30'])
+self.expect("log timers dump",
+   
substrs=['lldb_private::Module::FindSymbolsMatchingRegExAndType'])
+
+self.runCmd("log timers reset")

Can you wrap all of the above in a helper function? You repeat this same 
pattern for every variable, the test would be much more readable. It also gives 
you a good spot to expand a little bit on way the testing involves "timers".


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

https://reviews.llvm.org/D67111



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


[Lldb-commits] [PATCH] D67168: [Windows] Add support of watchpoints to `ProcessWindows`

2019-09-04 Thread Zachary Turner via Phabricator via lldb-commits
zturner added inline comments.



Comment at: 
lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp:82
 
-bool RegisterContextWindows::ClearHardwareBreakpoint(uint32_t hw_idx) {
-  return false;
-}
+  if (!size || size > 8 || size & (size - 1))
+return false;

amccarth wrote:
> Clever!  It took me a minute or two to figure out what the point of that was 
> checking.  Perhaps a comment to explain?
Isn't this equivalent to:

```
switch (size)
{
case 1:
case 2:
case 4:
case 8:
break;
default:
return false;
}
```

?  That definitely seems much clearer.

I'm also pretty sure that on x86 you can't add a 64-bit watch, So you'd have to 
do something different depending on the target bitness if you want this to be 
correct for x86.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D67168



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


[Lldb-commits] [lldb] r370998 - [Disassembler] Simplify a few methods (2/2) (NFC)

2019-09-04 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Wed Sep  4 16:05:32 2019
New Revision: 370998

URL: http://llvm.org/viewvc/llvm-project?rev=370998&view=rev
Log:
[Disassembler] Simplify a few methods (2/2) (NFC)

Use early returns to highlight preconditions and make the code easier to
follow.

Modified:
lldb/trunk/source/Core/Disassembler.cpp

Modified: lldb/trunk/source/Core/Disassembler.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Disassembler.cpp?rev=370998&r1=370997&r2=370998&view=diff
==
--- lldb/trunk/source/Core/Disassembler.cpp (original)
+++ lldb/trunk/source/Core/Disassembler.cpp Wed Sep  4 16:05:32 2019
@@ -244,27 +244,28 @@ bool Disassembler::Disassemble(Debugger
bool mixed_source_and_assembly,
uint32_t num_mixed_context_lines,
uint32_t options, Stream &strm) {
-  if (disasm_range.GetByteSize()) {
-lldb::DisassemblerSP disasm_sp(Disassembler::FindPluginForTarget(
-exe_ctx.GetTargetSP(), arch, flavor, plugin_name));
-
-if (disasm_sp) {
-  AddressRange range;
-  ResolveAddress(exe_ctx, disasm_range.GetBaseAddress(),
- range.GetBaseAddress());
-  range.SetByteSize(disasm_range.GetByteSize());
-  const bool prefer_file_cache = false;
-  size_t bytes_disassembled = disasm_sp->ParseInstructions(
-  &exe_ctx, range, &strm, prefer_file_cache);
-  if (bytes_disassembled == 0)
-return false;
-
-  return PrintInstructions(disasm_sp.get(), debugger, arch, exe_ctx,
-   num_instructions, mixed_source_and_assembly,
-   num_mixed_context_lines, options, strm);
-}
-  }
-  return false;
+  if (!disasm_range.GetByteSize())
+return false;
+
+  lldb::DisassemblerSP disasm_sp(Disassembler::FindPluginForTarget(
+  exe_ctx.GetTargetSP(), arch, flavor, plugin_name));
+
+  if (!disasm_sp)
+return false;
+
+  AddressRange range;
+  ResolveAddress(exe_ctx, disasm_range.GetBaseAddress(),
+ range.GetBaseAddress());
+  range.SetByteSize(disasm_range.GetByteSize());
+  const bool prefer_file_cache = false;
+  size_t bytes_disassembled =
+  disasm_sp->ParseInstructions(&exe_ctx, range, &strm, prefer_file_cache);
+  if (bytes_disassembled == 0)
+return false;
+
+  return PrintInstructions(disasm_sp.get(), debugger, arch, exe_ctx,
+   num_instructions, mixed_source_and_assembly,
+   num_mixed_context_lines, options, strm);
 }
 
 bool Disassembler::Disassemble(Debugger &debugger, const ArchSpec &arch,
@@ -275,42 +276,51 @@ bool Disassembler::Disassemble(Debugger
bool mixed_source_and_assembly,
uint32_t num_mixed_context_lines,
uint32_t options, Stream &strm) {
-  if (num_instructions > 0) {
-lldb::DisassemblerSP disasm_sp(Disassembler::FindPluginForTarget(
-exe_ctx.GetTargetSP(), arch, flavor, plugin_name));
-if (disasm_sp) {
-  Address addr;
-  ResolveAddress(exe_ctx, start_address, addr);
-  const bool prefer_file_cache = false;
-  size_t bytes_disassembled = disasm_sp->ParseInstructions(
-  &exe_ctx, addr, num_instructions, prefer_file_cache);
-  if (bytes_disassembled == 0)
-return false;
-  return PrintInstructions(disasm_sp.get(), debugger, arch, exe_ctx,
-   num_instructions, mixed_source_and_assembly,
-   num_mixed_context_lines, options, strm);
-}
-  }
-  return false;
+  if (num_instructions == 0)
+return false;
+
+  lldb::DisassemblerSP disasm_sp(Disassembler::FindPluginForTarget(
+  exe_ctx.GetTargetSP(), arch, flavor, plugin_name));
+  if (!disasm_sp)
+return false;
+
+  Address addr;
+  ResolveAddress(exe_ctx, start_address, addr);
+
+  const bool prefer_file_cache = false;
+  size_t bytes_disassembled = disasm_sp->ParseInstructions(
+  &exe_ctx, addr, num_instructions, prefer_file_cache);
+  if (bytes_disassembled == 0)
+return false;
+
+  return PrintInstructions(disasm_sp.get(), debugger, arch, exe_ctx,
+   num_instructions, mixed_source_and_assembly,
+   num_mixed_context_lines, options, strm);
 }
 
 Disassembler::SourceLine
 Disassembler::GetFunctionDeclLineEntry(const SymbolContext &sc) {
+  if (!sc.function)
+return {};
+
+  if (!sc.line_entry.IsValid())
+return {};
+
+  LineEntry prologue_end_line = sc.line_entry;
+  FileSpec func_decl_file;
+  uint32_t func_decl_line;
+  sc.function->GetStartLineSourceInfo(func_decl_file, func_decl_line);
+
+  if (func_decl_file != prologue_end_line.file &&
+  func_decl_file != prologue_end_line.original_file)
+return {};
+
   SourceLine decl_line;
-  if (sc.function && sc.line_entry.IsVal

[Lldb-commits] [PATCH] D67168: [Windows] Add support of watchpoints to `ProcessWindows`

2019-09-04 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov updated this revision to Diff 218837.
aleksandr.urakov added a comment.

Address the requested changes.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D67168

Files:
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/hello_watchlocation/TestWatchLocation.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/hello_watchpoint/TestMyFirstWatchpoint.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/multiple_hits/TestMultipleHits.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/multiple_threads/TestWatchpointMultipleThreads.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/TestWatchpointCommands.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/command/TestWatchpointCommandLLDB.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/command/TestWatchpointCommandPython.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/condition/TestWatchpointConditionCmd.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_disable/TestWatchpointDisable.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_events/TestWatchpointEvents.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_on_vectors/TestValueOfVectorVariable.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_set_command/TestWatchLocationWithWatchSet.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_size/TestWatchpointSizes.py
  lldb/packages/Python/lldbsuite/test/python_api/watchpoint/TestSetWatchpoint.py
  
lldb/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIgnoreCount.py
  
lldb/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIter.py
  
lldb/packages/Python/lldbsuite/test/python_api/watchpoint/condition/TestWatchpointConditionAPI.py
  
lldb/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestSetWatchlocation.py
  
lldb/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py
  lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.h
  lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
  lldb/source/Plugins/Process/Windows/Common/ProcessWindows.h
  lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
  lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.h
  lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
  lldb/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp

Index: lldb/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp
+++ lldb/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp
@@ -267,9 +267,7 @@
   }
 
   // Physically update the registers in the target process.
-  TargetThreadWindows &wthread = static_cast(m_thread);
-  return ::SetThreadContext(
-  wthread.GetHostThread().GetNativeThread().GetSystemHandle(), &m_context);
+  return ApplyAllRegisterValues();
 }
 
 bool RegisterContextWindows_x86::ReadRegisterHelper(
Index: lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
+++ lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
@@ -532,9 +532,7 @@
   }
 
   // Physically update the registers in the target process.
-  TargetThreadWindows &wthread = static_cast(m_thread);
-  return ::SetThreadContext(
-  wthread.GetHostThread().GetNativeThread().GetSystemHandle(), &m_context);
+  return ApplyAllRegisterValues();
 }
 
 #endif // defined(__x86_64__) || defined(_M_X64)
Index: lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.h
===
--- lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.h
+++ lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.h
@@ -33,28 +33,28 @@
   uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind,
uint32_t num) override;
 
-  // Subclasses can override these functions if desired
-  uint32_t NumSupportedHardwareBreakpoints() override;
-
-  uint32_t SetHardwareBreakpoint(lldb::addr_t addr, size_t size) override;
-
-  bool ClearHardwareBreakpoint(uint32_t hw_idx) override;
-
-  uint32_t NumSupportedHardwareWatchpoints() override;
+  bool HardwareSingleStep(bool enable) override;
 
-  uint32_t SetHardwareWatchpoint(lldb::a

[Lldb-commits] [PATCH] D67168: [Windows] Add support of watchpoints to `ProcessWindows`

2019-09-04 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov updated this revision to Diff 218838.
aleksandr.urakov added a comment.

Address the requested changes.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D67168

Files:
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/hello_watchlocation/TestWatchLocation.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/hello_watchpoint/TestMyFirstWatchpoint.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/multiple_hits/TestMultipleHits.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/multiple_threads/TestWatchpointMultipleThreads.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/TestWatchpointCommands.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/command/TestWatchpointCommandLLDB.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/command/TestWatchpointCommandPython.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/condition/TestWatchpointConditionCmd.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_disable/TestWatchpointDisable.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_events/TestWatchpointEvents.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_on_vectors/TestValueOfVectorVariable.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_set_command/TestWatchLocationWithWatchSet.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_size/TestWatchpointSizes.py
  lldb/packages/Python/lldbsuite/test/python_api/watchpoint/TestSetWatchpoint.py
  
lldb/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIgnoreCount.py
  
lldb/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIter.py
  
lldb/packages/Python/lldbsuite/test/python_api/watchpoint/condition/TestWatchpointConditionAPI.py
  
lldb/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestSetWatchlocation.py
  
lldb/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py
  lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.h
  lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
  lldb/source/Plugins/Process/Windows/Common/ProcessWindows.h
  lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
  lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.h
  lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
  lldb/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp

Index: lldb/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp
+++ lldb/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp
@@ -267,9 +267,7 @@
   }
 
   // Physically update the registers in the target process.
-  TargetThreadWindows &wthread = static_cast(m_thread);
-  return ::SetThreadContext(
-  wthread.GetHostThread().GetNativeThread().GetSystemHandle(), &m_context);
+  return ApplyAllRegisterValues();
 }
 
 bool RegisterContextWindows_x86::ReadRegisterHelper(
Index: lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
+++ lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
@@ -532,9 +532,7 @@
   }
 
   // Physically update the registers in the target process.
-  TargetThreadWindows &wthread = static_cast(m_thread);
-  return ::SetThreadContext(
-  wthread.GetHostThread().GetNativeThread().GetSystemHandle(), &m_context);
+  return ApplyAllRegisterValues();
 }
 
 #endif // defined(__x86_64__) || defined(_M_X64)
Index: lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.h
===
--- lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.h
+++ lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.h
@@ -33,28 +33,28 @@
   uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind,
uint32_t num) override;
 
-  // Subclasses can override these functions if desired
-  uint32_t NumSupportedHardwareBreakpoints() override;
-
-  uint32_t SetHardwareBreakpoint(lldb::addr_t addr, size_t size) override;
-
-  bool ClearHardwareBreakpoint(uint32_t hw_idx) override;
-
-  uint32_t NumSupportedHardwareWatchpoints() override;
+  bool HardwareSingleStep(bool enable) override;
 
-  uint32_t SetHardwareWatchpoint(lldb::a

[Lldb-commits] [PATCH] D67168: [Windows] Add support of watchpoints to `ProcessWindows`

2019-09-04 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov updated this revision to Diff 218840.
aleksandr.urakov marked an inline comment as done.
aleksandr.urakov added a comment.

Check bitness of the target when checking the watchpoint size.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D67168

Files:
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/hello_watchlocation/TestWatchLocation.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/hello_watchpoint/TestMyFirstWatchpoint.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/multiple_hits/TestMultipleHits.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/multiple_threads/TestWatchpointMultipleThreads.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/TestWatchpointCommands.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/command/TestWatchpointCommandLLDB.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/command/TestWatchpointCommandPython.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/condition/TestWatchpointConditionCmd.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_disable/TestWatchpointDisable.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_events/TestWatchpointEvents.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_on_vectors/TestValueOfVectorVariable.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_set_command/TestWatchLocationWithWatchSet.py
  
lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_size/TestWatchpointSizes.py
  lldb/packages/Python/lldbsuite/test/python_api/watchpoint/TestSetWatchpoint.py
  
lldb/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIgnoreCount.py
  
lldb/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIter.py
  
lldb/packages/Python/lldbsuite/test/python_api/watchpoint/condition/TestWatchpointConditionAPI.py
  
lldb/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestSetWatchlocation.py
  
lldb/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py
  lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.h
  lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
  lldb/source/Plugins/Process/Windows/Common/ProcessWindows.h
  lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
  lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.h
  lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
  lldb/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp

Index: lldb/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp
+++ lldb/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp
@@ -267,9 +267,7 @@
   }
 
   // Physically update the registers in the target process.
-  TargetThreadWindows &wthread = static_cast(m_thread);
-  return ::SetThreadContext(
-  wthread.GetHostThread().GetNativeThread().GetSystemHandle(), &m_context);
+  return ApplyAllRegisterValues();
 }
 
 bool RegisterContextWindows_x86::ReadRegisterHelper(
Index: lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
+++ lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
@@ -532,9 +532,7 @@
   }
 
   // Physically update the registers in the target process.
-  TargetThreadWindows &wthread = static_cast(m_thread);
-  return ::SetThreadContext(
-  wthread.GetHostThread().GetNativeThread().GetSystemHandle(), &m_context);
+  return ApplyAllRegisterValues();
 }
 
 #endif // defined(__x86_64__) || defined(_M_X64)
Index: lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.h
===
--- lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.h
+++ lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.h
@@ -33,28 +33,28 @@
   uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind,
uint32_t num) override;
 
-  // Subclasses can override these functions if desired
-  uint32_t NumSupportedHardwareBreakpoints() override;
-
-  uint32_t SetHardwareBreakpoint(lldb::addr_t addr, size_t size) override;
-
-  bool ClearHardwareBreakpoint(uint32_t hw_idx) override;
-
-  uint32_t NumSupportedHardwareWatchpoints() override;
+  bool Ha

[Lldb-commits] [PATCH] D67168: [Windows] Add support of watchpoints to `ProcessWindows`

2019-09-04 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov marked 5 inline comments as done.
aleksandr.urakov added inline comments.



Comment at: lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp:397
+if (slot != LLDB_INVALID_INDEX32) {
+  int id = m_watchpoint_slots[slot];
+  LLDB_LOG(log,

amccarth wrote:
> The names here are a bit confusing:  `GetTriggeredHardwareBreakpointSlot` 
> doesn't return a slot; it returns the index of a slot, so  `slot` also isn't 
> a slot, but the index of a slot.  `m_watchpoint_slots` is not a collection of 
> slots but IDs, that's indexed by an index called a `slot`.
> 
> It may not be possible to completely rationalize this, but doing even a 
> little could help future readers understand.  For example, `slot` could be 
> `slot_index`, and `m_watchpoint_slots` could be `m_watchpoint_ids` (or even 
> just `m_watchpoints`).
The most confusing thing here is that watchpoints have two different IDs: ID in 
LLDB as it is saw by an user, and the number of corresponding debug register in 
CPU (from 0 to 3). That's why I have selected completely different name for the 
last one and have called it `slot`. But you are right, `m_watchpoint_slots` is 
a wrong name, changed it to `m_watchpoint_ids` (because we already have 
`m_watchpoints` - it is map from LLDB IDs to watchpoint information).



Comment at: lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp:525
   for (const auto &thread_info : m_session_data->m_new_threads) {
-ThreadSP thread(new TargetThreadWindows(*this, thread_info.second));
-thread->SetID(thread_info.first);
-new_thread_list.AddThread(thread);
+new_thread_list.AddThread(thread_info.second);
 ++new_size;

amccarth wrote:
> This no longer sets the thread ID.  Was that intentional?
Before this commit `m_new_threads` kept `HostThread`s, not `ThreadSP`s. But a 
`HostThread` have no `RegisterContext`, which we need to set all watchpoints 
when a new thread is created. That's why we create `ThreadSP` on thread 
creation now, so we set the thread ID there (in `OnCreateThread` function).



Comment at: lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp:743
 
-void ProcessWindows::OnCreateThread(const HostThread &new_thread) {
+void ProcessWindows::OnCreateThread(HostThread &new_thread) {
   llvm::sys::ScopedLock lock(m_mutex);

amccarth wrote:
> Can you help me why we needed to get rid of the `const` on the `HostThread &`?
> 
> If `native_new_thread` were also a const ref, I don't see any conflicting 
> constraint.
Oh, I'm sorry, it was left unintentionally after my previous implementation. 
Fixed it, thanks!



Comment at: lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp:852
+RegisterContextWindows *reg_ctx = static_cast(
+thread->GetRegisterContext().get());
+if (!reg_ctx->AddHardwareBreakpoint(info.slot, info.address, info.size,

amccarth wrote:
> Since you have to explicitly downcast, wouldn't `auto *reg_ctx` on the left 
> be sufficient and just as clear?
Actually, I'm a big fan of auto, and some time ago @zturner have told me that 
normally it is not used so much in LLVM code, so I have reduced its usage in my 
patches :) But if it is OK to use auto here, I'll fix it (and in similar places 
too), thanks!



Comment at: 
lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp:82
 
-bool RegisterContextWindows::ClearHardwareBreakpoint(uint32_t hw_idx) {
-  return false;
-}
+  if (!size || size > 8 || size & (size - 1))
+return false;

zturner wrote:
> amccarth wrote:
> > Clever!  It took me a minute or two to figure out what the point of that 
> > was checking.  Perhaps a comment to explain?
> Isn't this equivalent to:
> 
> ```
> switch (size)
> {
> case 1:
> case 2:
> case 4:
> case 8:
> break;
> default:
> return false;
> }
> ```
> 
> ?  That definitely seems much clearer.
> 
> I'm also pretty sure that on x86 you can't add a 64-bit watch, So you'd have 
> to do something different depending on the target bitness if you want this to 
> be correct for x86.
Yes, it is equivalent, I've chosen the previous form due to its less verbosity. 
But you are right, clearance is better (especially after adding the 
architecture check). Fixed it, thanks!


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D67168



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


[Lldb-commits] [PATCH] D67168: [Windows] Add support of watchpoints to `ProcessWindows`

2019-09-04 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp:852
+RegisterContextWindows *reg_ctx = static_cast(
+thread->GetRegisterContext().get());
+if (!reg_ctx->AddHardwareBreakpoint(info.slot, info.address, info.size,

aleksandr.urakov wrote:
> amccarth wrote:
> > Since you have to explicitly downcast, wouldn't `auto *reg_ctx` on the left 
> > be sufficient and just as clear?
> Actually, I'm a big fan of auto, and some time ago @zturner have told me that 
> normally it is not used so much in LLVM code, so I have reduced its usage in 
> my patches :) But if it is OK to use auto here, I'll fix it (and in similar 
> places too), thanks!
Yeah, llvm does not use auto too match, but in this case the type is already 
explicitly present, so there's no ambiguity, and this is fine. (I would still 
use `auto *` instead of plain `auto` though..)



Comment at: 
lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp:82
 
-bool RegisterContextWindows::ClearHardwareBreakpoint(uint32_t hw_idx) {
-  return false;
-}
+  if (!size || size > 8 || size & (size - 1))
+return false;

aleksandr.urakov wrote:
> zturner wrote:
> > amccarth wrote:
> > > Clever!  It took me a minute or two to figure out what the point of that 
> > > was checking.  Perhaps a comment to explain?
> > Isn't this equivalent to:
> > 
> > ```
> > switch (size)
> > {
> > case 1:
> > case 2:
> > case 4:
> > case 8:
> > break;
> > default:
> > return false;
> > }
> > ```
> > 
> > ?  That definitely seems much clearer.
> > 
> > I'm also pretty sure that on x86 you can't add a 64-bit watch, So you'd 
> > have to do something different depending on the target bitness if you want 
> > this to be correct for x86.
> Yes, it is equivalent, I've chosen the previous form due to its less 
> verbosity. But you are right, clearance is better (especially after adding 
> the architecture check). Fixed it, thanks!
 or, you could just use `llvm::isPowerOf2_32` from `MathExtras.h`.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D67168



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


[Lldb-commits] [lldb] r371015 - [dotest] Delete trivial inline test makefiles

2019-09-04 Thread Pavel Labath via lldb-commits
Author: labath
Date: Wed Sep  4 23:55:23 2019
New Revision: 371015

URL: http://llvm.org/viewvc/llvm-project?rev=371015&view=rev
Log:
[dotest] Delete trivial inline test makefiles

inline tests are able to generate these automatically

Removed:

lldb/trunk/packages/Python/lldbsuite/test/commands/expression/completion-crash-incomplete-record/Makefile

lldb/trunk/packages/Python/lldbsuite/test/commands/expression/completion-crash1/Makefile

lldb/trunk/packages/Python/lldbsuite/test/commands/expression/completion-crash2/Makefile

lldb/trunk/packages/Python/lldbsuite/test/commands/expression/dollar-in-variable/Makefile

lldb/trunk/packages/Python/lldbsuite/test/commands/expression/rdar42038760/Makefile

lldb/trunk/packages/Python/lldbsuite/test/commands/expression/rdar44436068/Makefile

lldb/trunk/packages/Python/lldbsuite/test/commands/expression/unicode-in-variable/Makefile
lldb/trunk/packages/Python/lldbsuite/test/commands/frame/var-scope/Makefile
lldb/trunk/packages/Python/lldbsuite/test/commands/source/info/Makefile
lldb/trunk/packages/Python/lldbsuite/test/commands/statistics/basic/Makefile

lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/dump_dynamic/Makefile

lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/setvaluefromcstring/Makefile

lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/stringprinter/Makefile

lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/typedef_array/Makefile
lldb/trunk/packages/Python/lldbsuite/test/issue_verification/Makefile
lldb/trunk/packages/Python/lldbsuite/test/lang/c/offsetof/Makefile
lldb/trunk/packages/Python/lldbsuite/test/lang/c/struct_types/Makefile

lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/class-template-parameter-pack/Makefile
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/const_this/Makefile
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/extern_c/Makefile

lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/function-template-parameter-pack/Makefile
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/function_refs/Makefile

lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/Makefile
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/llvm-style/Makefile

lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace_conflicts/Makefile
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/offsetof/Makefile
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/operators/Makefile
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/symbols/Makefile
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/virtual-overload/Makefile

lldb/trunk/packages/Python/lldbsuite/test/python_api/sbvalue_const_addrof/Makefile

Removed: 
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/completion-crash-incomplete-record/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/commands/expression/completion-crash-incomplete-record/Makefile?rev=371014&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/completion-crash-incomplete-record/Makefile
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/completion-crash-incomplete-record/Makefile
 (removed)
@@ -1,2 +0,0 @@
-CXX_SOURCES := main.cpp
-include Makefile.rules

Removed: 
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/completion-crash1/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/commands/expression/completion-crash1/Makefile?rev=371014&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/completion-crash1/Makefile
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/completion-crash1/Makefile
 (removed)
@@ -1,2 +0,0 @@
-CXX_SOURCES := main.cpp
-include Makefile.rules

Removed: 
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/completion-crash2/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/commands/expression/completion-crash2/Makefile?rev=371014&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/completion-crash2/Makefile
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/completion-crash2/Makefile
 (removed)
@@ -1,2 +0,0 @@
-CXX_SOURCES := main.cpp
-include Makefile.rules

Removed: 
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/dollar-in-variable/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/commands/expression/dollar-in-variable/Makefile?rev=371014&view=auto
==