[Lldb-commits] [PATCH] D56322: [Reproducers] SBReproducer framework

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

I think we're very close. This batch of comments is just about small 
improvements to the tests. It looks like the `Validate` thingy wasn't such a 
clever idea, since the fact that the framework creates extra copies means that 
there are some unvalidated copies floating around. Still, I think it's worth it 
overall, because it tests the bahavior we want more closely than if we just 
went through global variables (however, do see my comments on the global 
variables to make sure that validation did indeed take place).




Comment at: include/lldb/Utility/ReproducerInstrumentation.h:594-595
+
+  /// The serializer is set from the reproducer framework. If the serializer is
+  /// not set, we're not in recording mode.
+  Serializer &m_serializer;

I guess this comment is no longer true. We should only ever create this object 
if we are recording.



Comment at: source/API/SBReproducerPrivate.h:23
+
+#define LLDB_GET_INSTRUMENTATION_DATA  
\
+  lldb_private::repro::GetInstrumentationData()

If it's all the same to you, i'd prefer to have this be a function-like macro 
(so just add `()` after the macro name here, and also add `()` to all macro 
"invocations").



Comment at: source/API/SBReproducerPrivate.h:61
+
+InstrumentationData GetInstrumentationData() {
+  if (auto *g = lldb_private::repro::Reproducer::Instance().GetGenerator()) {

`inline` (or move to .cpp)



Comment at: unittests/Utility/ReproducerInstrumentationTest.cpp:50-52
+template  bool Equals(T LHS, T RHS) {
+  return std::fabs(RHS - LHS) < std::numeric_limits::epsilon();
+}

I guess this is no longer used?



Comment at: unittests/Utility/ReproducerInstrumentationTest.cpp:62
+public:
+  ~InstrumentedFoo() { EXPECT_TRUE(m_validated); }
+

I think it's still important to independently check that `Validate` was called, 
IIUC, the framework never deletes the objects it creates, so this wouldn't 
actually check anything during the replay. Even if it did, this opens up the 
possibility that the `Replay` method decides to do absolutely nothing for some 
reason, in which case the test would still succeed. The idea for stashing the 
`this` pointer from the other comment could be reused for this purpose too.



Comment at: unittests/Utility/ReproducerInstrumentationTest.cpp:443
+
+  InstrumentedFoo *foo2 = new (foo) InstrumentedFoo();
+  foo2->A(100);

destroy the old object before creating a new one in its place 
(`foo->~InstrumentedFoo()`).



Comment at: unittests/Utility/ReproducerInstrumentationTest.cpp:455
+  registry.Replay(os.str());
+}
+

A good thing to check here would be to make sure that the framework created 
actually created two instances of this object. As it stands now, if the 
framework just decided to keep calling methods on the original object, the test 
would probably still succeed. One way to achieve that would be to enhance the 
Validate method to stash the `this` pointer into an array somewhere. Then you 
could check that the array contains two elements (and that they are different).



Comment at: unittests/Utility/ReproducerInstrumentationTest.cpp:479-480
+
+bar.SetInstrumentedFoo(foo);
+bar.SetInstrumentedFoo(&foo);
+bar.Validate();

Add a check that these two methods are called with the same object during 
replay. The methods could store the object pointer instead of just a plain 
flag, and then Validate could verify their equality.


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

https://reviews.llvm.org/D56322



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


[Lldb-commits] [PATCH] D57781: Fix strlen() of unbound array undefined behavior

2019-02-06 Thread Jan Kratochvil via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL353280: Fix strlen() of unbound array undefined behavior 
(authored by jankratochvil, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D57781?vs=185373&id=185498#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D57781

Files:
  lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  lldb/trunk/source/Utility/ConstString.cpp


Index: lldb/trunk/source/Utility/ConstString.cpp
===
--- lldb/trunk/source/Utility/ConstString.cpp
+++ lldb/trunk/source/Utility/ConstString.cpp
@@ -143,7 +143,7 @@
   const char *GetConstTrimmedCStringWithLength(const char *cstr,
size_t cstr_len) {
 if (cstr != nullptr) {
-  const size_t trimmed_len = std::min(strlen(cstr), cstr_len);
+  const size_t trimmed_len = strnlen(cstr, cstr_len);
   return GetConstCStringWithLength(cstr, trimmed_len);
 }
 return nullptr;
Index: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
===
--- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -1609,8 +1609,7 @@
   bool add_section = true;
   bool add_to_unified = true;
   ConstString const_segname(
-  load_cmd.segname,
-  std::min(strlen(load_cmd.segname), sizeof(load_cmd.segname)));
+  load_cmd.segname, strnlen(load_cmd.segname, sizeof(load_cmd.segname)));
 
   SectionSP unified_section_sp(
   context.UnifiedList.FindSectionByName(const_segname));
@@ -1729,8 +1728,7 @@
 
 if (add_section) {
   ConstString section_name(
-  sect64.sectname,
-  std::min(strlen(sect64.sectname), sizeof(sect64.sectname)));
+  sect64.sectname, strnlen(sect64.sectname, sizeof(sect64.sectname)));
   if (!const_segname) {
 // We have a segment with no name so we need to conjure up segments
 // that correspond to the section's segname if there isn't already such


Index: lldb/trunk/source/Utility/ConstString.cpp
===
--- lldb/trunk/source/Utility/ConstString.cpp
+++ lldb/trunk/source/Utility/ConstString.cpp
@@ -143,7 +143,7 @@
   const char *GetConstTrimmedCStringWithLength(const char *cstr,
size_t cstr_len) {
 if (cstr != nullptr) {
-  const size_t trimmed_len = std::min(strlen(cstr), cstr_len);
+  const size_t trimmed_len = strnlen(cstr, cstr_len);
   return GetConstCStringWithLength(cstr, trimmed_len);
 }
 return nullptr;
Index: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
===
--- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -1609,8 +1609,7 @@
   bool add_section = true;
   bool add_to_unified = true;
   ConstString const_segname(
-  load_cmd.segname,
-  std::min(strlen(load_cmd.segname), sizeof(load_cmd.segname)));
+  load_cmd.segname, strnlen(load_cmd.segname, sizeof(load_cmd.segname)));
 
   SectionSP unified_section_sp(
   context.UnifiedList.FindSectionByName(const_segname));
@@ -1729,8 +1728,7 @@
 
 if (add_section) {
   ConstString section_name(
-  sect64.sectname,
-  std::min(strlen(sect64.sectname), sizeof(sect64.sectname)));
+  sect64.sectname, strnlen(sect64.sectname, sizeof(sect64.sectname)));
   if (!const_segname) {
 // We have a segment with no name so we need to conjure up segments
 // that correspond to the section's segname if there isn't already such
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r353280 - Fix strlen() of unbound array undefined behavior

2019-02-06 Thread Jan Kratochvil via lldb-commits
Author: jankratochvil
Date: Wed Feb  6 00:44:13 2019
New Revision: 353280

URL: http://llvm.org/viewvc/llvm-project?rev=353280&view=rev
Log:
Fix strlen() of unbound array undefined behavior

LLDB testsuite fails when built by GCC8 on:
  LLDB :: SymbolFile/DWARF/find-basic-namespace.cpp

This is because this code in LLDB codebase has undefined behavior:

  #include 
  #include 
  // lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp:1731
  static struct section_64 {
char sectname[16];
char segname[16];
  } sect64 = { 
{'_','_','a','p','p','l','e','_','n','a','m','e','s','p','a','c'}, "__DWARF" };
  int main() {
return std::min(strlen(sect64.sectname), sizeof(sect64.sectname));
  }

It has been discussed as a (false) bugreport to GCC:
  wrong-code: LLDB testcase fails: SymbolFile/DWARF/find-basic-namespace.cpp
  https://bugzilla.redhat.com/show_bug.cgi?id=1672436

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

Modified:
lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/trunk/source/Utility/ConstString.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=353280&r1=353279&r2=353280&view=diff
==
--- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Wed Feb  6 
00:44:13 2019
@@ -1609,8 +1609,7 @@ void ObjectFileMachO::ProcessSegmentComm
   bool add_section = true;
   bool add_to_unified = true;
   ConstString const_segname(
-  load_cmd.segname,
-  std::min(strlen(load_cmd.segname), sizeof(load_cmd.segname)));
+  load_cmd.segname, strnlen(load_cmd.segname, sizeof(load_cmd.segname)));
 
   SectionSP unified_section_sp(
   context.UnifiedList.FindSectionByName(const_segname));
@@ -1729,8 +1728,7 @@ void ObjectFileMachO::ProcessSegmentComm
 
 if (add_section) {
   ConstString section_name(
-  sect64.sectname,
-  std::min(strlen(sect64.sectname), sizeof(sect64.sectname)));
+  sect64.sectname, strnlen(sect64.sectname, sizeof(sect64.sectname)));
   if (!const_segname) {
 // We have a segment with no name so we need to conjure up segments
 // that correspond to the section's segname if there isn't already such

Modified: lldb/trunk/source/Utility/ConstString.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/ConstString.cpp?rev=353280&r1=353279&r2=353280&view=diff
==
--- lldb/trunk/source/Utility/ConstString.cpp (original)
+++ lldb/trunk/source/Utility/ConstString.cpp Wed Feb  6 00:44:13 2019
@@ -143,7 +143,7 @@ public:
   const char *GetConstTrimmedCStringWithLength(const char *cstr,
size_t cstr_len) {
 if (cstr != nullptr) {
-  const size_t trimmed_len = std::min(strlen(cstr), cstr_len);
+  const size_t trimmed_len = strnlen(cstr, cstr_len);
   return GetConstCStringWithLength(cstr, trimmed_len);
 }
 return nullptr;


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


[Lldb-commits] [PATCH] D57745: [x64] Process the B field of the REX prefix correctly for the PUSH and POP instructions

2019-02-06 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov updated this revision to Diff 185497.
aleksandr.urakov added a comment.

Yes, sure, sorry about this, I occasionally have forgot to update the 
prefixes...


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D57745

Files:
  source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
  unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp


Index: unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp
===
--- unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp
+++ unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp
@@ -1415,6 +1415,34 @@
   EXPECT_EQ(-8, regloc.GetOffset());
 }
 
+TEST_F(Testx86AssemblyInspectionEngine, TestPushRBPWithREX) {
+  UnwindPlan::Row::RegisterLocation regloc;
+  UnwindPlan::RowSP row_sp;
+
+  uint8_t data[] = {
+  0x40, 0x55, // pushq %rbp
+  0x90  // nop
+  };
+
+  AddressRange sample_range(0x1000, sizeof(data));
+  UnwindPlan unwind_plan(eRegisterKindLLDB);
+
+  std::unique_ptr engine64 = Getx86_64Inspector();
+  EXPECT_TRUE(engine64->GetNonCallSiteUnwindPlanFromAssembly(
+  data, sizeof(data), sample_range, unwind_plan));
+
+  row_sp = unwind_plan.GetRowForFunctionOffset(2);
+
+  EXPECT_EQ(2ull, row_sp->GetOffset());
+  EXPECT_TRUE(row_sp->GetCFAValue().GetRegisterNumber() == k_rsp);
+  EXPECT_TRUE(row_sp->GetCFAValue().IsRegisterPlusOffset() == true);
+  EXPECT_EQ(16, row_sp->GetCFAValue().GetOffset());
+
+  EXPECT_TRUE(row_sp->GetRegisterInfo(k_rbp, regloc));
+  EXPECT_TRUE(regloc.IsAtCFAPlusOffset());
+  EXPECT_EQ(-16, regloc.GetOffset());
+}
+
 TEST_F(Testx86AssemblyInspectionEngine, TestPushESI) {
   UnwindPlan::Row::RegisterLocation regloc;
   UnwindPlan::RowSP row_sp;
@@ -1913,6 +1941,32 @@
   EXPECT_FALSE(row_sp->GetRegisterInfo(k_ebp, regloc));
 }
 
+TEST_F(Testx86AssemblyInspectionEngine, TestPopRBPWithREX) {
+  UnwindPlan::Row::RegisterLocation regloc;
+  UnwindPlan::RowSP row_sp;
+  AddressRange sample_range;
+  UnwindPlan unwind_plan(eRegisterKindLLDB);
+  std::unique_ptr engine = Getx86_64Inspector();
+
+  uint8_t data[] = {
+  0x40, 0x55, // pushq %rbp
+  0x40, 0x5d, // popq %rbp
+  0x90// nop
+  };
+
+  sample_range = AddressRange(0x1000, sizeof(data));
+
+  EXPECT_TRUE(engine->GetNonCallSiteUnwindPlanFromAssembly(
+  data, sizeof(data), sample_range, unwind_plan));
+
+  row_sp = unwind_plan.GetRowForFunctionOffset(4);
+  EXPECT_EQ(4ull, row_sp->GetOffset());
+  EXPECT_TRUE(row_sp->GetCFAValue().GetRegisterNumber() == k_rsp);
+  EXPECT_TRUE(row_sp->GetCFAValue().IsRegisterPlusOffset() == true);
+  EXPECT_EQ(8, row_sp->GetCFAValue().GetOffset());
+  EXPECT_FALSE(row_sp->GetRegisterInfo(k_rbp, regloc));
+}
+
 TEST_F(Testx86AssemblyInspectionEngine, TestPopESI) {
   UnwindPlan::Row::RegisterLocation regloc;
   UnwindPlan::RowSP row_sp;
Index: source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
===
--- source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
+++ source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
@@ -364,8 +364,8 @@
   uint8_t *p = m_cur_insn;
   int regno_prefix_bit = 0;
   // If we have a rex prefix byte, check to see if a B bit is set
-  if (m_wordsize == 8 && *p == 0x41) {
-regno_prefix_bit = 1 << 3;
+  if (m_wordsize == 8 && (*p & 0xfe) == 0x40) {
+regno_prefix_bit = (*p & 1) << 3;
 p++;
   }
   if (*p >= 0x50 && *p <= 0x57) {
@@ -562,8 +562,8 @@
   uint8_t *p = m_cur_insn;
   int regno_prefix_bit = 0;
   // If we have a rex prefix byte, check to see if a B bit is set
-  if (m_wordsize == 8 && *p == 0x41) {
-regno_prefix_bit = 1 << 3;
+  if (m_wordsize == 8 && (*p & 0xfe) == 0x40) {
+regno_prefix_bit = (*p & 1) << 3;
 p++;
   }
   if (*p >= 0x58 && *p <= 0x5f) {


Index: unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp
===
--- unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp
+++ unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp
@@ -1415,6 +1415,34 @@
   EXPECT_EQ(-8, regloc.GetOffset());
 }
 
+TEST_F(Testx86AssemblyInspectionEngine, TestPushRBPWithREX) {
+  UnwindPlan::Row::RegisterLocation regloc;
+  UnwindPlan::RowSP row_sp;
+
+  uint8_t data[] = {
+  0x40, 0x55, // pushq %rbp
+  0x90  // nop
+  };
+
+  AddressRange sample_range(0x1000, sizeof(data));
+  UnwindPlan unwind_plan(eRegisterKindLLDB);
+
+  std::unique_ptr engine64 = Getx86_64Inspector();
+  EXPECT_TRUE(engine64->GetNonCallSiteUnwindPlanFromAssembly(
+  data, sizeof(data), sample_range, unwind_plan));
+
+  row_sp = unwind_plan.GetRowForFunctionOffset(2);
+
+  EXPECT_EQ(2ull, row_sp->GetOffset());
+  EXPECT_TRUE(row_sp->GetCFAValue().GetRegisterNumber() == k_rsp);
+  EXPECT_TRUE(row_sp->GetCFAValue().IsReg

[Lldb-commits] [PATCH] D57745: [x64] Process the B field of the REX prefix correctly for the PUSH and POP instructions

2019-02-06 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov marked an inline comment as done.
aleksandr.urakov added a comment.

Thanks all for the review!


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D57745



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


[Lldb-commits] [lldb] r353281 - [x64] Process the B field of the REX prefix correctly for the PUSH and POP

2019-02-06 Thread Aleksandr Urakov via lldb-commits
Author: aleksandr.urakov
Date: Wed Feb  6 00:48:30 2019
New Revision: 353281

URL: http://llvm.org/viewvc/llvm-project?rev=353281&view=rev
Log:
[x64] Process the B field of the REX prefix correctly for the PUSH and POP
instructions

Summary: This patch makes `x86AssemblyInspectionEngine` to process zero value of
the `B` field of the `REX` prefix in a correct way for `PUSH` and `POP`
instructions. MSVC sometimes emits `pushq %rbp` instruction as `0x40 0x55`, and
it was not parsed correctly before.

Reviewers: jasonmolenda, labath

Reviewed By: jasonmolenda, labath

Subscribers: abidh, lldb-commits

Tags: #lldb

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

Modified:
lldb/trunk/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
lldb/trunk/unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp

Modified: 
lldb/trunk/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp?rev=353281&r1=353280&r2=353281&view=diff
==
--- 
lldb/trunk/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp 
(original)
+++ 
lldb/trunk/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp 
Wed Feb  6 00:48:30 2019
@@ -364,8 +364,8 @@ bool x86AssemblyInspectionEngine::push_r
   uint8_t *p = m_cur_insn;
   int regno_prefix_bit = 0;
   // If we have a rex prefix byte, check to see if a B bit is set
-  if (m_wordsize == 8 && *p == 0x41) {
-regno_prefix_bit = 1 << 3;
+  if (m_wordsize == 8 && (*p & 0xfe) == 0x40) {
+regno_prefix_bit = (*p & 1) << 3;
 p++;
   }
   if (*p >= 0x50 && *p <= 0x57) {
@@ -562,8 +562,8 @@ bool x86AssemblyInspectionEngine::pop_re
   uint8_t *p = m_cur_insn;
   int regno_prefix_bit = 0;
   // If we have a rex prefix byte, check to see if a B bit is set
-  if (m_wordsize == 8 && *p == 0x41) {
-regno_prefix_bit = 1 << 3;
+  if (m_wordsize == 8 && (*p & 0xfe) == 0x40) {
+regno_prefix_bit = (*p & 1) << 3;
 p++;
   }
   if (*p >= 0x58 && *p <= 0x5f) {

Modified: 
lldb/trunk/unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp?rev=353281&r1=353280&r2=353281&view=diff
==
--- lldb/trunk/unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp 
(original)
+++ lldb/trunk/unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp 
Wed Feb  6 00:48:30 2019
@@ -1415,6 +1415,34 @@ TEST_F(Testx86AssemblyInspectionEngine,
   EXPECT_EQ(-8, regloc.GetOffset());
 }
 
+TEST_F(Testx86AssemblyInspectionEngine, TestPushRBPWithREX) {
+  UnwindPlan::Row::RegisterLocation regloc;
+  UnwindPlan::RowSP row_sp;
+
+  uint8_t data[] = {
+  0x40, 0x55, // pushq %rbp
+  0x90  // nop
+  };
+
+  AddressRange sample_range(0x1000, sizeof(data));
+  UnwindPlan unwind_plan(eRegisterKindLLDB);
+
+  std::unique_ptr engine64 = Getx86_64Inspector();
+  EXPECT_TRUE(engine64->GetNonCallSiteUnwindPlanFromAssembly(
+  data, sizeof(data), sample_range, unwind_plan));
+
+  row_sp = unwind_plan.GetRowForFunctionOffset(2);
+
+  EXPECT_EQ(2ull, row_sp->GetOffset());
+  EXPECT_TRUE(row_sp->GetCFAValue().GetRegisterNumber() == k_rsp);
+  EXPECT_TRUE(row_sp->GetCFAValue().IsRegisterPlusOffset() == true);
+  EXPECT_EQ(16, row_sp->GetCFAValue().GetOffset());
+
+  EXPECT_TRUE(row_sp->GetRegisterInfo(k_rbp, regloc));
+  EXPECT_TRUE(regloc.IsAtCFAPlusOffset());
+  EXPECT_EQ(-16, regloc.GetOffset());
+}
+
 TEST_F(Testx86AssemblyInspectionEngine, TestPushESI) {
   UnwindPlan::Row::RegisterLocation regloc;
   UnwindPlan::RowSP row_sp;
@@ -1913,6 +1941,32 @@ TEST_F(Testx86AssemblyInspectionEngine,
   EXPECT_FALSE(row_sp->GetRegisterInfo(k_ebp, regloc));
 }
 
+TEST_F(Testx86AssemblyInspectionEngine, TestPopRBPWithREX) {
+  UnwindPlan::Row::RegisterLocation regloc;
+  UnwindPlan::RowSP row_sp;
+  AddressRange sample_range;
+  UnwindPlan unwind_plan(eRegisterKindLLDB);
+  std::unique_ptr engine = Getx86_64Inspector();
+
+  uint8_t data[] = {
+  0x40, 0x55, // pushq %rbp
+  0x40, 0x5d, // popq %rbp
+  0x90// nop
+  };
+
+  sample_range = AddressRange(0x1000, sizeof(data));
+
+  EXPECT_TRUE(engine->GetNonCallSiteUnwindPlanFromAssembly(
+  data, sizeof(data), sample_range, unwind_plan));
+
+  row_sp = unwind_plan.GetRowForFunctionOffset(4);
+  EXPECT_EQ(4ull, row_sp->GetOffset());
+  EXPECT_TRUE(row_sp->GetCFAValue().GetRegisterNumber() == k_rsp);
+  EXPECT_TRUE(row_sp->GetCFAValue().IsRegisterPlusOffset() == true);
+  EXPECT_EQ(8, row_sp->GetCFAValue().GetOffset());
+  EXPECT_FALSE(row_sp->GetRegisterInfo(k_rbp, regloc));
+}
+
 TEST_F(Testx86AssemblyInspectionEngine, TestPopESI) {
   UnwindPlan::Row::RegisterLocation regloc;
   UnwindPlan::Ro

[Lldb-commits] [PATCH] D57780: Don't include UnixSignals.h from Host

2019-02-06 Thread Pavel Labath via Phabricator via lldb-commits
labath added reviewers: jingham, davide.
labath accepted this revision.
labath added a comment.
This revision is now accepted and ready to land.

The rationale you give for this class being in Target is sound from the POV of 
lldb client. (the CreateForHost function is slightly fishy, but not too much.) 
However, it starts to break down when you start to consider lldb-server, whose 
large chunk of responsibility revolves around signals, but it doesn't need 
anything else in the Target module. For that, I think the ultimate place of 
UnixSignals should be somewhere else (I was planning to try to move it to 
Utility, which would mean that GetHostSignals could stay where it is).

However, we still have a long way to go before we can make lldb-server more 
independent, and the changes you make here are fairly small and easy to back 
out if needed. Since they solve the immediate problems with the Host module, I 
think it's fine to do this change now, and then revisit the placement of this 
class later.




Comment at: 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp:401
 
-  const auto &signals = Host::GetUnixSignals();
+  lldb::UnixSignalsSP signals = UnixSignals::CreateForHost();
   for (auto signo = signals->GetFirstSignalNumber();

Despite being burried in `Plugins/Process/gdb-remote`, this code is actually 
part of lldb-server (and only lldb-server).


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

https://reviews.llvm.org/D57780



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


[Lldb-commits] [PATCH] D57745: [x64] Process the B field of the REX prefix correctly for the PUSH and POP instructions

2019-02-06 Thread Aleksandr Urakov via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB353281: [x64] Process the B field of the REX prefix 
correctly for the PUSH and POP (authored by aleksandr.urakov, committed by ).

Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D57745

Files:
  source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
  unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp


Index: unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp
===
--- unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp
+++ unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp
@@ -1415,6 +1415,34 @@
   EXPECT_EQ(-8, regloc.GetOffset());
 }
 
+TEST_F(Testx86AssemblyInspectionEngine, TestPushRBPWithREX) {
+  UnwindPlan::Row::RegisterLocation regloc;
+  UnwindPlan::RowSP row_sp;
+
+  uint8_t data[] = {
+  0x40, 0x55, // pushq %rbp
+  0x90  // nop
+  };
+
+  AddressRange sample_range(0x1000, sizeof(data));
+  UnwindPlan unwind_plan(eRegisterKindLLDB);
+
+  std::unique_ptr engine64 = Getx86_64Inspector();
+  EXPECT_TRUE(engine64->GetNonCallSiteUnwindPlanFromAssembly(
+  data, sizeof(data), sample_range, unwind_plan));
+
+  row_sp = unwind_plan.GetRowForFunctionOffset(2);
+
+  EXPECT_EQ(2ull, row_sp->GetOffset());
+  EXPECT_TRUE(row_sp->GetCFAValue().GetRegisterNumber() == k_rsp);
+  EXPECT_TRUE(row_sp->GetCFAValue().IsRegisterPlusOffset() == true);
+  EXPECT_EQ(16, row_sp->GetCFAValue().GetOffset());
+
+  EXPECT_TRUE(row_sp->GetRegisterInfo(k_rbp, regloc));
+  EXPECT_TRUE(regloc.IsAtCFAPlusOffset());
+  EXPECT_EQ(-16, regloc.GetOffset());
+}
+
 TEST_F(Testx86AssemblyInspectionEngine, TestPushESI) {
   UnwindPlan::Row::RegisterLocation regloc;
   UnwindPlan::RowSP row_sp;
@@ -1913,6 +1941,32 @@
   EXPECT_FALSE(row_sp->GetRegisterInfo(k_ebp, regloc));
 }
 
+TEST_F(Testx86AssemblyInspectionEngine, TestPopRBPWithREX) {
+  UnwindPlan::Row::RegisterLocation regloc;
+  UnwindPlan::RowSP row_sp;
+  AddressRange sample_range;
+  UnwindPlan unwind_plan(eRegisterKindLLDB);
+  std::unique_ptr engine = Getx86_64Inspector();
+
+  uint8_t data[] = {
+  0x40, 0x55, // pushq %rbp
+  0x40, 0x5d, // popq %rbp
+  0x90// nop
+  };
+
+  sample_range = AddressRange(0x1000, sizeof(data));
+
+  EXPECT_TRUE(engine->GetNonCallSiteUnwindPlanFromAssembly(
+  data, sizeof(data), sample_range, unwind_plan));
+
+  row_sp = unwind_plan.GetRowForFunctionOffset(4);
+  EXPECT_EQ(4ull, row_sp->GetOffset());
+  EXPECT_TRUE(row_sp->GetCFAValue().GetRegisterNumber() == k_rsp);
+  EXPECT_TRUE(row_sp->GetCFAValue().IsRegisterPlusOffset() == true);
+  EXPECT_EQ(8, row_sp->GetCFAValue().GetOffset());
+  EXPECT_FALSE(row_sp->GetRegisterInfo(k_rbp, regloc));
+}
+
 TEST_F(Testx86AssemblyInspectionEngine, TestPopESI) {
   UnwindPlan::Row::RegisterLocation regloc;
   UnwindPlan::RowSP row_sp;
Index: source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
===
--- source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
+++ source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
@@ -364,8 +364,8 @@
   uint8_t *p = m_cur_insn;
   int regno_prefix_bit = 0;
   // If we have a rex prefix byte, check to see if a B bit is set
-  if (m_wordsize == 8 && *p == 0x41) {
-regno_prefix_bit = 1 << 3;
+  if (m_wordsize == 8 && (*p & 0xfe) == 0x40) {
+regno_prefix_bit = (*p & 1) << 3;
 p++;
   }
   if (*p >= 0x50 && *p <= 0x57) {
@@ -562,8 +562,8 @@
   uint8_t *p = m_cur_insn;
   int regno_prefix_bit = 0;
   // If we have a rex prefix byte, check to see if a B bit is set
-  if (m_wordsize == 8 && *p == 0x41) {
-regno_prefix_bit = 1 << 3;
+  if (m_wordsize == 8 && (*p & 0xfe) == 0x40) {
+regno_prefix_bit = (*p & 1) << 3;
 p++;
   }
   if (*p >= 0x58 && *p <= 0x5f) {


Index: unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp
===
--- unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp
+++ unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp
@@ -1415,6 +1415,34 @@
   EXPECT_EQ(-8, regloc.GetOffset());
 }
 
+TEST_F(Testx86AssemblyInspectionEngine, TestPushRBPWithREX) {
+  UnwindPlan::Row::RegisterLocation regloc;
+  UnwindPlan::RowSP row_sp;
+
+  uint8_t data[] = {
+  0x40, 0x55, // pushq %rbp
+  0x90  // nop
+  };
+
+  AddressRange sample_range(0x1000, sizeof(data));
+  UnwindPlan unwind_plan(eRegisterKindLLDB);
+
+  std::unique_ptr engine64 = Getx86_64Inspector();
+  EXPECT_TRUE(engine64->GetNonCallSiteUnwindPlanFromAssembly(
+  data, sizeof(data), sample_range, unwind_plan));
+
+  row_sp = unwind_plan.GetRowForFunctionOffset(2);
+
+  EXPECT_EQ(2ull, row_sp->GetOffset());
+  EXPECT_TRUE(row_sp->GetCFAValue().GetRegisterNumber() 

[Lldb-commits] [PATCH] D57809: [build.py] Add `VCINSTALLDIR` to default variables

2019-02-06 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov created this revision.
aleksandr.urakov added reviewers: zturner, labath, stella.stamenova.
aleksandr.urakov added a project: LLDB.
Herald added a reviewer: serge-sans-paille.
Herald added a subscriber: lldb-commits.

On my system, `clang-cl` can't compile tests containing `char16_t` and 
`char32_t` types without this environment variable defined. This fix makes the 
tests to pass, but I'm not sure about the such solution. What do you think 
about it?


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D57809

Files:
  lit/helper/build.py


Index: lit/helper/build.py
===
--- lit/helper/build.py
+++ lit/helper/build.py
@@ -512,7 +512,7 @@
 defaultenv = {}
 if sys.platform == 'win32':
 defaultenv = { x : os.environ[x] for x in
-  ['SystemDrive', 'SystemRoot', 'TMP', 'TEMP'] }
+  ['SystemDrive', 'SystemRoot', 'TMP', 'TEMP', 
'VCINSTALLDIR'] }
 # The directory to mspdbcore.dll needs to be in PATH, but this is
 # always in the native toolchain path, not the cross-toolchain
 # path.  So, for example, if we're using HostX64\x86 then we need


Index: lit/helper/build.py
===
--- lit/helper/build.py
+++ lit/helper/build.py
@@ -512,7 +512,7 @@
 defaultenv = {}
 if sys.platform == 'win32':
 defaultenv = { x : os.environ[x] for x in
-  ['SystemDrive', 'SystemRoot', 'TMP', 'TEMP'] }
+  ['SystemDrive', 'SystemRoot', 'TMP', 'TEMP', 'VCINSTALLDIR'] }
 # The directory to mspdbcore.dll needs to be in PATH, but this is
 # always in the native toolchain path, not the cross-toolchain
 # path.  So, for example, if we're using HostX64\x86 then we need
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D56904: [NativePDB] Process virtual bases in the correct order

2019-02-06 Thread Aleksandr Urakov via lldb-commits
Yes, sure, here it is: https://reviews.llvm.org/D56904

On Tue, Feb 5, 2019 at 7:39 PM Zachary Turner  wrote:

> Yes, clang tries to find the visual studio installation, because that is
> how it can find headers and libs.  Can you make a separate patch with the
> changes to build.py and upload that?
>
> On Tue, Feb 5, 2019 at 2:34 AM Aleksandr Urakov via Phabricator <
> revi...@reviews.llvm.org> wrote:
>
>> aleksandr.urakov added a comment.
>>
>> Thanks for the reply! It seems that after your hint I've figured it out.
>> It's the environment variable `VCINSTALLDIR`. I've added it to the
>> `defaultenv` list of the `_get_visual_studio_environment` function and the
>> test passes now. What do you think about this solution?
>>
>> And do I understand right, it means, that clang-cl needs MSVC
>> installation to work with these types?
>>
>>
>> Repository:
>>   rLLDB LLDB
>>
>> CHANGES SINCE LAST ACTION
>>   https://reviews.llvm.org/D56904/new/
>>
>> https://reviews.llvm.org/D56904
>>
>>
>>
>>

-- 
Aleksandr Urakov
Software Developer
JetBrains
http://www.jetbrains.com
The Drive to Develop
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D57809: [build.py] Add `VCINSTALLDIR` to default variables

2019-02-06 Thread Pavel Labath via Phabricator via lldb-commits
labath requested changes to this revision.
labath added a comment.
This revision now requires changes to proceed.

I don't think this should be necessary. Based on my experiments, the fact 
whether clang-cl defines `char32_t` depends on the version of visual studio it 
is emulating (`-fms-compatibility-version`). For instance I can do this:

  $ cat /tmp/a.cc 
  char32_t XX;
  $ bin/clang-cl /tmp/a.cc /GS- /GR- /c -fms-compatibility-version=18
  /tmp/a.cc(1,1) :  error: unknown type name 'char32_t'
  char32_t XX;
  ^
  1 error generated.
  $ bin/clang-cl /tmp/a.cc /GS- /GR- /c -fms-compatibility-version=19
  $ bin/clang-cl /tmp/a.cc /GS- /GR- /c

So, what I suspect is happening is that clang uses %VCINSTALLDIR% to detect the 
MSVC version, and then sets the compatibility based on that. If the detected 
version is high enough, `char32_t` will be automatically defined. The 
interesting part is that, for me, the default version seems to be high enough 
that even without any special setting `char32_t` "just works". However, I'm on 
linux, so the differences could be due to that.

So I think this is good news. I hope all that's needed here is to get 
`build.py` to add the -fms-compatibility thingy and things should work. Until 
we actually need to vary this version, I think we can just unconditionally add 
that flag to all clang-cl invocations in build.py.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D57809



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


[Lldb-commits] [PATCH] D57402: build: remove custom variables

2019-02-06 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz added a comment.

In D57402#1385718 , @xiaobai wrote:

> > - For us it's a good match for our downstream code 
> > https://github.com/apple/swift-lldb/blob/upstream-with-swift/cmake/modules/LLDBStandalone.cmake
>
> I don't think it's too difficult to change how it works downstream in 
> lldb-swift. I actually already have an open PR trying to make swift-lldb 
> closer to upstream in this particular file: 
> https://github.com/apple/swift-lldb/pull/1252
>  This change would be a cherry-pick on top of that, I think.


Ok didn't see this PR earlier either. Will have a look.

> The consequence of this is that you would be required to specify Clang_DIR 
> unless a clang install is in your `CMAKE_MODULE_PATH`. I assume @compnerd 
> specified Clang_DIR when he tested this patch.

@compnerd can you please confirm/clarify? By default we shouldn't need to 
specify Clang_DIR explicitly. Otherwise LGTM.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D57402



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


[Lldb-commits] [PATCH] D57751: minidump: Add ability to attach (breakpad) symbol files to placeholder modules

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

- remove std::move
- avoid using the word "update" in CreateModuleFromObjectFile
- implement the Dump method and cover it with a test


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

https://reviews.llvm.org/D57751

Files:
  include/lldb/Core/Module.h
  lit/Minidump/Inputs/linux-x86_64.dmp
  lit/Minidump/Inputs/linux-x86_64.syms
  lit/Minidump/breakpad-symbols.test
  source/Plugins/Process/minidump/ProcessMinidump.cpp

Index: source/Plugins/Process/minidump/ProcessMinidump.cpp
===
--- source/Plugins/Process/minidump/ProcessMinidump.cpp
+++ source/Plugins/Process/minidump/ProcessMinidump.cpp
@@ -41,51 +41,84 @@
 using namespace lldb_private;
 using namespace minidump;
 
-//--
-/// A placeholder module used for minidumps, where the original
-/// object files may not be available (so we can't parse the object
-/// files to extract the set of sections/segments)
-///
-/// This placeholder module has a single synthetic section (.module_image)
-/// which represents the module memory range covering the whole module.
-//--
-class PlaceholderModule : public Module {
+namespace {
+
+/// A minimal ObjectFile implementation providing a dummy object file for the
+/// cases when the real module binary is not available. This allows the module
+/// to show up in "image list" and symbols to be added to it.
+class PlaceholderObjectFile : public ObjectFile {
 public:
-  PlaceholderModule(const ModuleSpec &module_spec) :
-Module(module_spec.GetFileSpec(), module_spec.GetArchitecture()) {
-if (module_spec.GetUUID().IsValid())
-  SetUUID(module_spec.GetUUID());
-  }
-
-  // Creates a synthetic module section covering the whole module image (and
-  // sets the section load address as well)
-  void CreateImageSection(const MinidumpModule *module, Target& target) {
-const ConstString section_name(".module_image");
-lldb::SectionSP section_sp(new Section(
-shared_from_this(), // Module to which this section belongs.
-nullptr,// ObjectFile
-0,  // Section ID.
-section_name,   // Section name.
-eSectionTypeContainer,  // Section type.
-module->base_of_image,  // VM address.
-module->size_of_image,  // VM size in bytes of this section.
-0,  // Offset of this section in the file.
-module->size_of_image,  // Size of the section as found in the file.
-12, // Alignment of the section (log2)
-0,  // Flags for this section.
-1));// Number of host bytes per target byte
-section_sp->SetPermissions(ePermissionsExecutable | ePermissionsReadable);
-GetSectionList()->AddSection(section_sp);
-target.GetSectionLoadList().SetSectionLoadAddress(
-section_sp, module->base_of_image);
+  PlaceholderObjectFile(const lldb::ModuleSP &module_sp,
+const ModuleSpec &module_spec, lldb::offset_t base,
+lldb::offset_t size)
+  : ObjectFile(module_sp, &module_spec.GetFileSpec(), /*file_offset*/ 0,
+   /*length*/ 0, /*data_sp*/ nullptr, /*data_offset*/ 0),
+m_arch(module_spec.GetArchitecture()), m_uuid(module_spec.GetUUID()),
+m_base(base), m_size(size) {
+m_symtab_ap = llvm::make_unique(this);
+  }
+
+  ConstString GetPluginName() override { return ConstString("placeholder"); }
+  uint32_t GetPluginVersion() override { return 1; }
+  bool ParseHeader() override { return true; }
+  Type CalculateType() override { return eTypeUnknown; }
+  Strata CalculateStrata() override { return eStrataUnknown; }
+  uint32_t GetDependentModules(FileSpecList &file_list) override { return 0; }
+  bool IsExecutable() const override { return false; }
+  ArchSpec GetArchitecture() override { return m_arch; }
+  Symtab *GetSymtab() override { return m_symtab_ap.get(); }
+  bool IsStripped() override { return true; }
+  ByteOrder GetByteOrder() const override { return m_arch.GetByteOrder(); }
+
+  uint32_t GetAddressByteSize() const override {
+return m_arch.GetAddressByteSize();
+  }
+
+  bool GetUUID(UUID *uuid) override {
+*uuid = m_uuid;
+return true;
+  }
+
+  Address GetBaseAddress() override {
+return Address(m_sections_ap->GetSectionAtIndex(0), 0);
   }
 
-ObjectFile *GetObjectFile() override { return nullptr; }
+  void CreateSections(SectionList &unified_section_list) override {
+m_sections_ap = llvm::make_unique();
+auto section_sp = std::make_shared(
+GetModule(), this, /*sect_id*/ 0, ConstString(".module_image"),
+eSectionTypeOther, m_base, m_size, /*file_offset*/ 0, /*file_

[Lldb-commits] [PATCH] D57751: minidump: Add ability to attach (breakpad) symbol files to placeholder modules

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



Comment at: include/lldb/Core/Module.h:176-177
+
+// Also update the module FileSpec.
+module_sp->m_file = module_sp->m_objfile_sp->GetFileSpec();
+return std::move(module_sp);

clayborg wrote:
> Why do we need to update the m_file? m_platform_file is the path of the 
> module as it is known the the remote system, so if m_file differs from the 
> object file's file spec, we might want to shuffle, m_file into 
> m_platform_file first and then overwrite it?
I used the word "update", because the previous comment did, but this isn't 
really "updating" anything. It is just "setting" the FileSpec because it was 
previously empty (the module we're setting this on is created a couple of lines 
back (line 163) as an empty module. The entire reason for existence of this 
function is to perform the articulate dance of creating the objects in the 
right order (because ObjectFile stores a shared_ptr to the module, it needs to 
be created after the ModuleSP is fully constructed).

So, there isn't to shuffle here. We just set m_file, to whatever the ObjectFile 
tells us is the file it was created from. 



Comment at: include/lldb/Core/Module.h:178
+module_sp->m_file = module_sp->m_objfile_sp->GetFileSpec();
+return std::move(module_sp);
   }

lemo wrote:
> nit: return std::move(x) is almost never a good idea. It's not needed, 
> verbose and most importantly it actually inhibits NRVO so it's likely less 
> efficient. 
Yep, I should have known that. I'll remove it.



Comment at: source/Plugins/Process/minidump/ProcessMinidump.cpp:51
 public:
-  PlaceholderModule(const ModuleSpec &module_spec) :
-Module(module_spec.GetFileSpec(), module_spec.GetArchitecture()) {
-if (module_spec.GetUUID().IsValid())
-  SetUUID(module_spec.GetUUID());
-  }
-
-  // Creates a synthetic module section covering the whole module image (and
-  // sets the section load address as well)
-  void CreateImageSection(const MinidumpModule *module, Target& target) {
-const ConstString section_name(".module_image");
-lldb::SectionSP section_sp(new Section(
-shared_from_this(), // Module to which this section belongs.
-nullptr,// ObjectFile
-0,  // Section ID.
-section_name,   // Section name.
-eSectionTypeContainer,  // Section type.
-module->base_of_image,  // VM address.
-module->size_of_image,  // VM size in bytes of this section.
-0,  // Offset of this section in the file.
-module->size_of_image,  // Size of the section as found in the file.
-12, // Alignment of the section (log2)
-0,  // Flags for this section.
-1));// Number of host bytes per target byte
-section_sp->SetPermissions(ePermissionsExecutable | ePermissionsReadable);
-GetSectionList()->AddSection(section_sp);
-target.GetSectionLoadList().SetSectionLoadAddress(
-section_sp, module->base_of_image);
+  PlaceholderObjectFile(const lldb::ModuleSP &module_sp,
+const ModuleSpec &module_spec, lldb::offset_t base,

lemo wrote:
> Can we avoid passing both the module_sp and module_spec? I try to avoid 
> interfaces which allow for inconsistent states, ex: what if module_sp and 
> module_spec describe completely different modules?
> 
> At very least I'd add a few asserts, but if we can change the interface to 
> avoid it, even better.
Yeah, I agree this interface is weird, but this is kind of necessary to make 
the `CreateModuleFromObjectFile` flow work. The idea there is to create an 
empty module, then place an ObjectFile inside of it, and then use the data from 
the ObjectFile to initialize the module.

So, at the point when this function is called, the module_sp object will be 
empty (so there isn't anything to assert). It's only present here to satisfy 
the ObjectFile contract and set up the weak_ptr backlink. The module_spec 
contains the actual data, which is used to initialize the PlaceholderObjectFile 
(and which will then in turn initialize the Module object).



Comment at: source/Plugins/Process/minidump/ProcessMinidump.cpp:52
-//--
-class PlaceholderModule : public Module {
 public:

lemo wrote:
> Nice - so we can do without this in all scenarios? What about PDBs?
I haven't tried anything special besides running existing tests, but I don't 
think this should hamper anything. The modules I create here will be fairly 
realistic, they will have UUIDs, ObjectFiles and everything. So if the PDBs 
were able to attach to the PlaceholderModules, they should certainly be able to 
do the same with regular modules + PlaceholderObjectFiles.



Comment at: sou

[Lldb-commits] [PATCH] D57809: [build.py] Add `VCINSTALLDIR` to default variables

2019-02-06 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov updated this revision to Diff 185526.
aleksandr.urakov added a comment.

I've checked your solution, and it's worked for me too! I think that your 
solution is better because it is more straight-forward. Here is the updated 
patch.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D57809

Files:
  lit/helper/build.py


Index: lit/helper/build.py
===
--- lit/helper/build.py
+++ lit/helper/build.py
@@ -566,6 +566,7 @@
 if self.toolchain_type == 'clang-cl':
 args.append('-Xclang')
 args.append('-fkeep-static-consts')
+args.append('-fms-compatibility-version=19')
 args.append('/c')
 
 args.append('/Fo' + obj)


Index: lit/helper/build.py
===
--- lit/helper/build.py
+++ lit/helper/build.py
@@ -566,6 +566,7 @@
 if self.toolchain_type == 'clang-cl':
 args.append('-Xclang')
 args.append('-fkeep-static-consts')
+args.append('-fms-compatibility-version=19')
 args.append('/c')
 
 args.append('/Fo' + obj)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D57809: [build.py] Add `VCINSTALLDIR` to default variables

2019-02-06 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.

This looks good to me, but let's wait for zachary too.

In D57809#1386883 , @aleksandr.urakov 
wrote:

> I've checked your solution, and it's worked for me too! I think that your 
> solution is better because it is more straight-forward. Here is the updated 
> patch.


It also has a higher chance of behaving identically on different systems.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D57809



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


[Lldb-commits] [PATCH] D56595: SymbolFileBreakpad: Add line table support

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

Tried to make parsing as lazy as possible. GetNumSections() will count the
number of FUNC records, but will not create CompileUnit objects. FILE records
will be parsed when we create the first compile unit. The support files and line
tables will be parsed when the first of them is requested for a given CU.

I've removed the CU shared pointer from the CompUnitData structure. Instead, I 
go through the symbol vendor to fetch the CU SP.

Added the move constructor for FileSpecList.

Please take another look.


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

https://reviews.llvm.org/D56595

Files:
  include/lldb/Core/FileSpecList.h
  include/lldb/Core/RangeMap.h
  lit/SymbolFile/Breakpad/Inputs/line-table-discontinuous-file-ids.syms
  lit/SymbolFile/Breakpad/Inputs/line-table-edgecases.syms
  lit/SymbolFile/Breakpad/Inputs/line-table-missing-file.syms
  lit/SymbolFile/Breakpad/Inputs/line-table.syms
  lit/SymbolFile/Breakpad/line-table-discontinuous-file-ids.test
  lit/SymbolFile/Breakpad/line-table-edgecases.test
  lit/SymbolFile/Breakpad/line-table-missing-file.test
  lit/SymbolFile/Breakpad/line-table.test
  source/Core/FileSpecList.cpp
  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
@@ -9,6 +9,9 @@
 #ifndef LLDB_PLUGINS_SYMBOLFILE_BREAKPAD_SYMBOLFILEBREAKPAD_H
 #define LLDB_PLUGINS_SYMBOLFILE_BREAKPAD_SYMBOLFILEBREAKPAD_H
 
+#include "Plugins/ObjectFile/Breakpad/BreakpadRecords.h"
+#include "lldb/Core/FileSpecList.h"
+#include "lldb/Symbol/LineTable.h"
 #include "lldb/Symbol/SymbolFile.h"
 
 namespace lldb_private {
@@ -63,9 +66,7 @@
   bool ParseDebugMacros(CompileUnit &comp_unit) override { return false; }
 
   bool ParseSupportFiles(CompileUnit &comp_unit,
- FileSpecList &support_files) override {
-return false;
-  }
+ FileSpecList &support_files) override;
   size_t ParseTypes(CompileUnit &cu) override { return 0; }
 
   bool
@@ -98,6 +99,11 @@
 lldb::SymbolContextItem resolve_scope,
 SymbolContext &sc) override;
 
+  uint32_t ResolveSymbolContext(const FileSpec &file_spec, uint32_t line,
+bool check_inlines,
+lldb::SymbolContextItem resolve_scope,
+SymbolContextList &sc_list) override;
+
   size_t GetTypes(SymbolContextScope *sc_scope, lldb::TypeClass type_mask,
   TypeList &type_list) override {
 return 0;
@@ -137,6 +143,66 @@
   uint32_t GetPluginVersion() override { return 1; }
 
 private:
+  // A class representing a position in the breakpad file. Useful for
+  // remembering the position so we can go back to it later and parse more data.
+  // Can be converted to/from a LineIterator, but it has a much smaller memory
+  // footprint.
+  struct Bookmark {
+uint32_t section;
+size_t offset;
+  };
+
+  // At iterator class for simplifying algorithms reading data from the breakpad
+  // file. It iterates over all records (lines) in the sections of a given type.
+  // It also supports saving a specific position (via the GetBookmark() method)
+  // and then resuming from it afterwards.
+  class LineIterator;
+
+  // Return an iterator range for all records in the given object file of the
+  // given type.
+  llvm::iterator_range lines(Record::Kind section_type);
+
+  // Breakpad files do not contain sufficient information to correctly
+  // reconstruct compile units. The approach chosen here is to treat each
+  // function as a compile unit. The compile unit name is the name if the first
+  // line entry belonging to this function.
+  // This class is our internal representation of a compile unit. It stores the
+  // CompileUnit object and a bookmark pointing to the FUNC record of the
+  // compile unit function. It also lazily construct the list of support files
+  // and line table entries for the compile unit, when these are needed.
+  class CompUnitData {
+  public:
+CompUnitData(Bookmark bookmark) : bookmark(bookmark) {}
+
+CompUnitData() = default;
+CompUnitData(const CompUnitData &rhs) : bookmark(rhs.bookmark) {}
+CompUnitData &operator=(const CompUnitData &rhs) {
+  bookmark = rhs.bookmark;
+  support_files.reset();
+  line_table_up.reset();
+  return *this;
+}
+friend bool operator<(const CompUnitData &lhs, const CompUnitData &rhs) {
+  return std::tie(lhs.bookmark.section, lhs.bookmark.offset) <
+ std::tie(rhs.bookmark.section, rhs.bookmark.offset);
+}
+
+ 

[Lldb-commits] [PATCH] D57817: Add PythonBoolean type to PythonDataObjects

2019-02-06 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha created this revision.
tatyana-krasnukha added reviewers: zturner, labath.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

When reading some settings from a Python script, getting a boolean option via 
`StructuredData::Object::GetAsBoolean` fails unexpectedly: `PyBool_Type` values 
fall to `PythonInteger` (and `StructuredData::Integer` as well). This patch 
adds `PythonBoolean` type to make `GetAsBoolean` working for Python.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D57817

Files:
  source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
  source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
  unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp

Index: unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp
===
--- unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp
+++ unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp
@@ -195,6 +195,31 @@
   EXPECT_EQ(7, constructed_int.GetInteger());
 }
 
+TEST_F(PythonDataObjectsTest, TestPythonBoolean) {
+  // Test PythonBoolean constructed from Py_True
+  EXPECT_TRUE(PythonBoolean::Check(Py_True));
+  PythonBoolean python_true(PyRefType::Owned, Py_True);
+  EXPECT_EQ(PyObjectType::Boolean, python_true.GetObjectType());
+
+  // Test PythonBoolean constructed from Py_False
+  EXPECT_TRUE(PythonBoolean::Check(Py_False));
+  PythonBoolean python_false(PyRefType::Owned, Py_False);
+  EXPECT_EQ(PyObjectType::Boolean, python_false.GetObjectType());
+
+  auto test_from_long = [](long value) {
+PyObject *py_bool = PyBool_FromLong(value);
+EXPECT_TRUE(PythonBoolean::Check(py_bool));
+PythonBoolean python_boolean(PyRefType::Owned, py_bool);
+EXPECT_EQ(PyObjectType::Boolean, python_boolean.GetObjectType());
+EXPECT_EQ(bool(value), python_boolean.GetValue());
+  };
+
+  // Test PythonBoolean constructed from long integer values.
+  test_from_long(0); // Test 'false' value.
+  test_from_long(1); // Test 'true' value.
+  test_from_long(~0); // Any value != 0 is 'true'.
+}
+
 TEST_F(PythonDataObjectsTest, TestPythonBytes) {
   static const char *test_bytes = "PythonDataObjectsTest::TestPythonBytes";
   PyObject *py_bytes = PyBytes_FromString(test_bytes);
Index: source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
===
--- source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
+++ source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
@@ -57,6 +57,7 @@
 enum class PyObjectType {
   Unknown,
   None,
+  Boolean,
   Integer,
   Dictionary,
   List,
@@ -297,6 +298,29 @@
   StructuredData::IntegerSP CreateStructuredInteger() const;
 };
 
+class PythonBoolean : public PythonObject {
+public:
+  PythonBoolean() = default;
+  explicit PythonBoolean(bool value);
+  PythonBoolean(PyRefType type, PyObject *o);
+  PythonBoolean(const PythonBoolean &object);
+
+  ~PythonBoolean() override = default;
+
+  static bool Check(PyObject *py_obj);
+
+  // Bring in the no-argument base class version
+  using PythonObject::Reset;
+
+  void Reset(PyRefType type, PyObject *py_obj) override;
+
+  bool GetValue() const;
+
+  void SetValue(bool value);
+
+  StructuredData::BooleanSP CreateStructuredBoolean() const;
+};
+
 class PythonList : public PythonObject {
 public:
   PythonList() {}
Index: source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
===
--- source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
+++ source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
@@ -77,6 +77,8 @@
 #endif
   if (PythonByteArray::Check(m_py_obj))
 return PyObjectType::ByteArray;
+  if (PythonBoolean::Check(m_py_obj))
+return PyObjectType::Boolean;
   if (PythonInteger::Check(m_py_obj))
 return PyObjectType::Integer;
   if (PythonFile::Check(m_py_obj))
@@ -178,6 +180,9 @@
   case PyObjectType::Dictionary:
 return PythonDictionary(PyRefType::Borrowed, m_py_obj)
 .CreateStructuredDictionary();
+  case PyObjectType::Boolean:
+return PythonBoolean(PyRefType::Borrowed, m_py_obj)
+.CreateStructuredBoolean();
   case PyObjectType::Integer:
 return PythonInteger(PyRefType::Borrowed, m_py_obj)
 .CreateStructuredInteger();
@@ -526,6 +531,55 @@
 }
 
 //--
+// PythonBoolean
+//--
+
+PythonBoolean::PythonBoolean(PyRefType type, PyObject *py_obj)
+: PythonObject() {
+  Reset(type, py_obj); // Use "Reset()" to ensure that py_obj is a boolean type
+}
+
+PythonBoolean::PythonBoolean(const PythonBoolean &object)
+: PythonObject(object) {}
+
+PythonBoolean::PythonBoolean(bool value) {
+  SetValue(value);
+}
+
+bool PythonBoolean::Check(PyObject *py_obj) {
+  return py_obj ? PyBool_Check(py_obj) : false;
+}

[Lldb-commits] [PATCH] D51387: Allow Template argument accessors to automatically unwrap parameter packs

2019-02-06 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

Do we have any callers that call GetNumTemplateArguments with false? If not, 
remove the argument?


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

https://reviews.llvm.org/D51387



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


[Lldb-commits] [PATCH] D56595: SymbolFileBreakpad: Add line table support

2019-02-06 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

Just bounds check "index" in parse compile unit and this is good to go




Comment at: source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp:196
+
+  CompUnitData &data = m_cu_data->GetEntryRef(index).data;
+

Validate "index" first? We will crash if someone iterates over too many CUs?


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

https://reviews.llvm.org/D56595



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


[Lldb-commits] [PATCH] D56595: SymbolFileBreakpad: Add line table support

2019-02-06 Thread Pavel Labath via Phabricator via lldb-commits
labath updated this revision to Diff 185557.
labath edited the summary of this revision.
labath added a comment.

Add a bounds check to the GetCompileUnitAtIndex method


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

https://reviews.llvm.org/D56595

Files:
  include/lldb/Core/FileSpecList.h
  include/lldb/Core/RangeMap.h
  lit/SymbolFile/Breakpad/Inputs/line-table-discontinuous-file-ids.syms
  lit/SymbolFile/Breakpad/Inputs/line-table-edgecases.syms
  lit/SymbolFile/Breakpad/Inputs/line-table-missing-file.syms
  lit/SymbolFile/Breakpad/Inputs/line-table.syms
  lit/SymbolFile/Breakpad/line-table-discontinuous-file-ids.test
  lit/SymbolFile/Breakpad/line-table-edgecases.test
  lit/SymbolFile/Breakpad/line-table-missing-file.test
  lit/SymbolFile/Breakpad/line-table.test
  source/Core/FileSpecList.cpp
  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
@@ -9,6 +9,9 @@
 #ifndef LLDB_PLUGINS_SYMBOLFILE_BREAKPAD_SYMBOLFILEBREAKPAD_H
 #define LLDB_PLUGINS_SYMBOLFILE_BREAKPAD_SYMBOLFILEBREAKPAD_H
 
+#include "Plugins/ObjectFile/Breakpad/BreakpadRecords.h"
+#include "lldb/Core/FileSpecList.h"
+#include "lldb/Symbol/LineTable.h"
 #include "lldb/Symbol/SymbolFile.h"
 
 namespace lldb_private {
@@ -63,9 +66,7 @@
   bool ParseDebugMacros(CompileUnit &comp_unit) override { return false; }
 
   bool ParseSupportFiles(CompileUnit &comp_unit,
- FileSpecList &support_files) override {
-return false;
-  }
+ FileSpecList &support_files) override;
   size_t ParseTypes(CompileUnit &cu) override { return 0; }
 
   bool
@@ -98,6 +99,11 @@
 lldb::SymbolContextItem resolve_scope,
 SymbolContext &sc) override;
 
+  uint32_t ResolveSymbolContext(const FileSpec &file_spec, uint32_t line,
+bool check_inlines,
+lldb::SymbolContextItem resolve_scope,
+SymbolContextList &sc_list) override;
+
   size_t GetTypes(SymbolContextScope *sc_scope, lldb::TypeClass type_mask,
   TypeList &type_list) override {
 return 0;
@@ -137,6 +143,66 @@
   uint32_t GetPluginVersion() override { return 1; }
 
 private:
+  // A class representing a position in the breakpad file. Useful for
+  // remembering the position so we can go back to it later and parse more data.
+  // Can be converted to/from a LineIterator, but it has a much smaller memory
+  // footprint.
+  struct Bookmark {
+uint32_t section;
+size_t offset;
+  };
+
+  // At iterator class for simplifying algorithms reading data from the breakpad
+  // file. It iterates over all records (lines) in the sections of a given type.
+  // It also supports saving a specific position (via the GetBookmark() method)
+  // and then resuming from it afterwards.
+  class LineIterator;
+
+  // Return an iterator range for all records in the given object file of the
+  // given type.
+  llvm::iterator_range lines(Record::Kind section_type);
+
+  // Breakpad files do not contain sufficient information to correctly
+  // reconstruct compile units. The approach chosen here is to treat each
+  // function as a compile unit. The compile unit name is the name if the first
+  // line entry belonging to this function.
+  // This class is our internal representation of a compile unit. It stores the
+  // CompileUnit object and a bookmark pointing to the FUNC record of the
+  // compile unit function. It also lazily construct the list of support files
+  // and line table entries for the compile unit, when these are needed.
+  class CompUnitData {
+  public:
+CompUnitData(Bookmark bookmark) : bookmark(bookmark) {}
+
+CompUnitData() = default;
+CompUnitData(const CompUnitData &rhs) : bookmark(rhs.bookmark) {}
+CompUnitData &operator=(const CompUnitData &rhs) {
+  bookmark = rhs.bookmark;
+  support_files.reset();
+  line_table_up.reset();
+  return *this;
+}
+friend bool operator<(const CompUnitData &lhs, const CompUnitData &rhs) {
+  return std::tie(lhs.bookmark.section, lhs.bookmark.offset) <
+ std::tie(rhs.bookmark.section, rhs.bookmark.offset);
+}
+
+Bookmark bookmark;
+llvm::Optional support_files;
+std::unique_ptr line_table_up;
+
+  };
+
+  SymbolVendor &GetSymbolVendor();
+  lldb::addr_t GetBaseFileAddress();
+  void ParseFileRecords();
+  void ParseCUData();
+  void ParseLineTableAndSupportFiles(CompileUnit &cu, CompUnitData &data);
+
+  using CompUnitMap = RangeDataVector;
+
+  llvm::Optional> m_files;
+  llvm::Optional m_cu_data;
 };
 
 } // namespace breakpad
Index: source/Plu

[Lldb-commits] [PATCH] D56322: [Reproducers] SBReproducer framework

2019-02-06 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 185585.
JDevlieghere marked 7 inline comments as done.
JDevlieghere added a comment.

Feedback Pavel.


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

https://reviews.llvm.org/D56322

Files:
  lldb/include/lldb/API/SBReproducer.h
  lldb/include/lldb/Utility/ReproducerInstrumentation.h
  lldb/source/API/CMakeLists.txt
  lldb/source/API/SBReproducer.cpp
  lldb/source/API/SBReproducerPrivate.h
  lldb/source/Utility/ReproducerInstrumentation.cpp
  lldb/tools/driver/Driver.cpp
  lldb/unittests/Utility/ReproducerInstrumentationTest.cpp

Index: lldb/unittests/Utility/ReproducerInstrumentationTest.cpp
===
--- lldb/unittests/Utility/ReproducerInstrumentationTest.cpp
+++ lldb/unittests/Utility/ReproducerInstrumentationTest.cpp
@@ -9,12 +9,14 @@
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
+#include 
+#include 
+
 #include "lldb/Utility/ReproducerInstrumentation.h"
 
 using namespace lldb_private;
 using namespace lldb_private::repro;
 
-namespace {
 struct Foo {
   int m = 1;
 };
@@ -40,7 +42,205 @@
   unsigned long l = 8;
   unsigned short m = 9;
 };
-} // namespace
+
+class TestingRegistry : public Registry {
+public:
+  TestingRegistry();
+};
+
+static llvm::Optional g_serializer;
+static llvm::Optional g_registry;
+
+#define LLDB_GET_INSTRUMENTATION_DATA()\
+  InstrumentationData(*g_serializer, *g_registry)
+
+class InstrumentedFoo {
+public:
+  InstrumentedFoo() = default;
+  /// Instrumented methods.
+  /// {
+  InstrumentedFoo(int i);
+  InstrumentedFoo(const InstrumentedFoo &foo);
+  InstrumentedFoo &operator=(const InstrumentedFoo &foo);
+  void A(int a);
+  void B(int &b) const;
+  int C(float *c);
+  int D(const char *d) const;
+  static void E(double e);
+  static int F();
+  void Validate();
+   }
+
+private:
+  int m_a = 0;
+  mutable int m_b = 0;
+  float m_c = 0;
+  mutable std::string m_d = {};
+  static double g_e;
+  static bool g_f;
+  mutable int m_called = 0;
+};
+
+class InstrumentedBar {
+public:
+  /// Instrumented methods.
+  /// {
+  InstrumentedBar();
+  InstrumentedFoo GetInstrumentedFoo();
+  void SetInstrumentedFoo(InstrumentedFoo *foo);
+  void SetInstrumentedFoo(InstrumentedFoo &foo);
+  void Validate();
+  /// }
+
+private:
+  bool m_get_instrumend_foo_called = false;
+  InstrumentedFoo *m_foo_set_by_ptr = nullptr;
+  InstrumentedFoo *m_foo_set_by_ref = nullptr;
+};
+
+double InstrumentedFoo::g_e = 0;
+bool InstrumentedFoo::g_f = false;
+
+static std::vector g_foos;
+static std::vector g_bars;
+
+void ClearObjects() {
+  g_foos.clear();
+  g_bars.clear();
+}
+
+void ValidateObjects(size_t expected_foos, size_t expected_bars) {
+  EXPECT_EQ(expected_foos, g_foos.size());
+  EXPECT_EQ(expected_bars, g_bars.size());
+
+  for (auto *foo : g_foos) {
+foo->Validate();
+  }
+
+  for (auto *bar : g_bars) {
+bar->Validate();
+  }
+}
+
+InstrumentedFoo::InstrumentedFoo(int i) {
+  LLDB_RECORD_CONSTRUCTOR(InstrumentedFoo, (int), i);
+  g_foos.push_back(this);
+}
+
+InstrumentedFoo::InstrumentedFoo(const InstrumentedFoo &foo) {
+  LLDB_RECORD_CONSTRUCTOR(InstrumentedFoo, (const InstrumentedFoo &), foo);
+  g_foos.erase(std::remove(g_foos.begin(), g_foos.end(), &foo));
+  g_foos.push_back(this);
+}
+
+InstrumentedFoo &InstrumentedFoo::operator=(const InstrumentedFoo &foo) {
+  LLDB_RECORD_METHOD(InstrumentedFoo &,
+ InstrumentedFoo, operator=,(const InstrumentedFoo &), foo);
+  g_foos.erase(std::remove(g_foos.begin(), g_foos.end(), &foo));
+  g_foos.push_back(this);
+  return *this;
+}
+
+void InstrumentedFoo::A(int a) {
+  LLDB_RECORD_METHOD(void, InstrumentedFoo, A, (int), a);
+  B(a);
+  m_a = a;
+}
+
+void InstrumentedFoo::B(int &b) const {
+  LLDB_RECORD_METHOD_CONST(void, InstrumentedFoo, B, (int &), b);
+  m_called++;
+  m_b = b;
+}
+
+int InstrumentedFoo::C(float *c) {
+  LLDB_RECORD_METHOD(int, InstrumentedFoo, C, (float *), c);
+  m_c = *c;
+  return 1;
+}
+
+int InstrumentedFoo::D(const char *d) const {
+  LLDB_RECORD_METHOD_CONST(int, InstrumentedFoo, D, (const char *), d);
+  m_d = std::string(d);
+  return 2;
+}
+
+void InstrumentedFoo::E(double e) {
+  LLDB_RECORD_STATIC_METHOD(void, InstrumentedFoo, E, (double), e);
+  g_e = e;
+}
+
+int InstrumentedFoo::F() {
+  LLDB_RECORD_STATIC_METHOD_NO_ARGS(int, InstrumentedFoo, F);
+  g_f = true;
+  return 3;
+}
+
+void InstrumentedFoo::Validate() {
+  LLDB_RECORD_METHOD_NO_ARGS(void, InstrumentedFoo, Validate);
+  EXPECT_EQ(m_a, 100);
+  EXPECT_EQ(m_b, 200);
+  EXPECT_NEAR(m_c, 300.3, 0.01);
+  EXPECT_EQ(m_d, "bar");
+  EXPECT_NEAR(g_e, 400.4, 0.01);
+  EXPECT_EQ(g_f, true);
+  EXPECT_EQ(2, m_called);
+}
+
+InstrumentedBar::InstrumentedBar() {
+  LLDB_RECORD_CONSTRUCTOR_NO_ARGS(InstrumentedBar);
+  g_bars.push_back(this);
+}
+
+InstrumentedFoo InstrumentedBar::GetInstrumentedFoo() {
+  LLDB_RECORD_METHOD_NO_ARGS(InstrumentedFoo, Instru

[Lldb-commits] [PATCH] D56322: [Reproducers] SBReproducer framework

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

This looks good to me. Thank you for your patience.




Comment at: lldb/source/Utility/ReproducerInstrumentation.cpp:91
+Recorder::~Recorder() {
+  assert(m_result_recorded && "Did you forget SB_RECORD_RESULT?");
+  UpdateBoundary();

old macro name in assert message


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

https://reviews.llvm.org/D56322



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


[Lldb-commits] [lldb] r353324 - [Reproducers] SBReproducer framework: Capture & Replay

2019-02-06 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Wed Feb  6 10:57:42 2019
New Revision: 353324

URL: http://llvm.org/viewvc/llvm-project?rev=353324&view=rev
Log:
[Reproducers] SBReproducer framework: Capture & Replay

This is part two of the reproducer instrumentation framework. It
contains the code to capture and replay function calls. The main user of
this framework will be the SB API layer.

For all the details refer to the RFC on the mailing list:
http://lists.llvm.org/pipermail/lldb-dev/2019-January/014530.html

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

Added:
lldb/trunk/include/lldb/API/SBReproducer.h
lldb/trunk/source/API/SBReproducer.cpp
lldb/trunk/source/API/SBReproducerPrivate.h
Modified:
lldb/trunk/include/lldb/Utility/ReproducerInstrumentation.h
lldb/trunk/source/API/CMakeLists.txt
lldb/trunk/source/Utility/ReproducerInstrumentation.cpp
lldb/trunk/tools/driver/Driver.cpp
lldb/trunk/unittests/Utility/ReproducerInstrumentationTest.cpp

Added: lldb/trunk/include/lldb/API/SBReproducer.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBReproducer.h?rev=353324&view=auto
==
--- lldb/trunk/include/lldb/API/SBReproducer.h (added)
+++ lldb/trunk/include/lldb/API/SBReproducer.h Wed Feb  6 10:57:42 2019
@@ -0,0 +1,23 @@
+//===-- SBReproducer.h --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_API_SBREPRODUCER_H
+#define LLDB_API_SBREPRODUCER_H
+
+#include "lldb/lldb-defines.h"
+
+namespace lldb {
+
+class LLDB_API SBReproducer {
+public:
+  static bool Replay();
+};
+
+} // namespace lldb
+
+#endif

Modified: lldb/trunk/include/lldb/Utility/ReproducerInstrumentation.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/ReproducerInstrumentation.h?rev=353324&r1=353323&r2=353324&view=diff
==
--- lldb/trunk/include/lldb/Utility/ReproducerInstrumentation.h (original)
+++ lldb/trunk/include/lldb/Utility/ReproducerInstrumentation.h Wed Feb  6 
10:57:42 2019
@@ -1,5 +1,4 @@
 //===-- ReproducerInstrumentation.h -*- C++ 
-*-===//
-//
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
@@ -18,7 +17,104 @@
 #include "llvm/Support/ErrorHandling.h"
 
 #include 
-#include 
+
+#define LLDB_REGISTER_CONSTRUCTOR(Class, Signature)
\
+  Register(&construct::doit)
+#define LLDB_REGISTER_METHOD(Result, Class, Method, Signature) 
\
+  Register(&invoke::method<&Class::Method>::doit)
+#define LLDB_REGISTER_METHOD_CONST(Result, Class, Method, Signature)   
\
+  Register(&invoke::method_const<&Class::Method>::doit)
+#define LLDB_REGISTER_STATIC_METHOD(Result, Class, Method, Signature)  
\
+  Register(static_cast(&Class::Method))
+
+#define LLDB_RECORD_CONSTRUCTOR(Class, Signature, ...) 
\
+  if (lldb_private::repro::InstrumentationData data =  
\
+  LLDB_GET_INSTRUMENTATION_DATA()) {   
\
+lldb_private::repro::Recorder sb_recorder( 
\
+data.GetSerializer(), data.GetRegistry(), LLVM_PRETTY_FUNCTION);   
\
+sb_recorder.Record(&lldb_private::repro::construct::doit, 
\
+   __VA_ARGS__);   
\
+sb_recorder.RecordResult(this);
\
+  }
+
+#define LLDB_RECORD_CONSTRUCTOR_NO_ARGS(Class) 
\
+  if (lldb_private::repro::InstrumentationData data =  
\
+  LLDB_GET_INSTRUMENTATION_DATA()) {   
\
+lldb_private::repro::Recorder sb_recorder( 
\
+data.GetSerializer(), data.GetRegistry(), LLVM_PRETTY_FUNCTION);   
\
+sb_recorder.Record(&lldb_private::repro::construct::doit);
\
+sb_recorder.RecordResult(this);
\
+  }
+
+#define LLDB_RECORD_METHOD(Result, Class, Method, Signature, ...)  
\
+  llvm::Optional sb_recorder;   
\
+  if (lldb_private::repro::InstrumentationData data =  
\
+  LLDB_GET_INSTRUMENTATION_DATA()) {   
\
+sb_recorder.emplace(data.GetSerializer(), data.GetRegistry(),  
\
+LLVM_PRETTY_FUNCTION);  

[Lldb-commits] [PATCH] D56322: [Reproducers] SBReproducer framework

2019-02-06 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

In D56322#1387357 , @labath wrote:

> This looks good to me. Thank you for your patience.


My pleasure, thank you for the thorough review!


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

https://reviews.llvm.org/D56322



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


[Lldb-commits] [PATCH] D56322: [Reproducers] SBReproducer framework

2019-02-06 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL353324: [Reproducers] SBReproducer framework: Capture & 
Replay (authored by JDevlieghere, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D56322?vs=185585&id=185592#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D56322

Files:
  lldb/trunk/include/lldb/API/SBReproducer.h
  lldb/trunk/include/lldb/Utility/ReproducerInstrumentation.h
  lldb/trunk/source/API/CMakeLists.txt
  lldb/trunk/source/API/SBReproducer.cpp
  lldb/trunk/source/API/SBReproducerPrivate.h
  lldb/trunk/source/Utility/ReproducerInstrumentation.cpp
  lldb/trunk/tools/driver/Driver.cpp
  lldb/trunk/unittests/Utility/ReproducerInstrumentationTest.cpp

Index: lldb/trunk/unittests/Utility/ReproducerInstrumentationTest.cpp
===
--- lldb/trunk/unittests/Utility/ReproducerInstrumentationTest.cpp
+++ lldb/trunk/unittests/Utility/ReproducerInstrumentationTest.cpp
@@ -9,12 +9,14 @@
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
+#include 
+#include 
+
 #include "lldb/Utility/ReproducerInstrumentation.h"
 
 using namespace lldb_private;
 using namespace lldb_private::repro;
 
-namespace {
 struct Foo {
   int m = 1;
 };
@@ -40,7 +42,205 @@
   unsigned long l = 8;
   unsigned short m = 9;
 };
-} // namespace
+
+class TestingRegistry : public Registry {
+public:
+  TestingRegistry();
+};
+
+static llvm::Optional g_serializer;
+static llvm::Optional g_registry;
+
+#define LLDB_GET_INSTRUMENTATION_DATA()\
+  InstrumentationData(*g_serializer, *g_registry)
+
+class InstrumentedFoo {
+public:
+  InstrumentedFoo() = default;
+  /// Instrumented methods.
+  /// {
+  InstrumentedFoo(int i);
+  InstrumentedFoo(const InstrumentedFoo &foo);
+  InstrumentedFoo &operator=(const InstrumentedFoo &foo);
+  void A(int a);
+  void B(int &b) const;
+  int C(float *c);
+  int D(const char *d) const;
+  static void E(double e);
+  static int F();
+  void Validate();
+   }
+
+private:
+  int m_a = 0;
+  mutable int m_b = 0;
+  float m_c = 0;
+  mutable std::string m_d = {};
+  static double g_e;
+  static bool g_f;
+  mutable int m_called = 0;
+};
+
+class InstrumentedBar {
+public:
+  /// Instrumented methods.
+  /// {
+  InstrumentedBar();
+  InstrumentedFoo GetInstrumentedFoo();
+  void SetInstrumentedFoo(InstrumentedFoo *foo);
+  void SetInstrumentedFoo(InstrumentedFoo &foo);
+  void Validate();
+  /// }
+
+private:
+  bool m_get_instrumend_foo_called = false;
+  InstrumentedFoo *m_foo_set_by_ptr = nullptr;
+  InstrumentedFoo *m_foo_set_by_ref = nullptr;
+};
+
+double InstrumentedFoo::g_e = 0;
+bool InstrumentedFoo::g_f = false;
+
+static std::vector g_foos;
+static std::vector g_bars;
+
+void ClearObjects() {
+  g_foos.clear();
+  g_bars.clear();
+}
+
+void ValidateObjects(size_t expected_foos, size_t expected_bars) {
+  EXPECT_EQ(expected_foos, g_foos.size());
+  EXPECT_EQ(expected_bars, g_bars.size());
+
+  for (auto *foo : g_foos) {
+foo->Validate();
+  }
+
+  for (auto *bar : g_bars) {
+bar->Validate();
+  }
+}
+
+InstrumentedFoo::InstrumentedFoo(int i) {
+  LLDB_RECORD_CONSTRUCTOR(InstrumentedFoo, (int), i);
+  g_foos.push_back(this);
+}
+
+InstrumentedFoo::InstrumentedFoo(const InstrumentedFoo &foo) {
+  LLDB_RECORD_CONSTRUCTOR(InstrumentedFoo, (const InstrumentedFoo &), foo);
+  g_foos.erase(std::remove(g_foos.begin(), g_foos.end(), &foo));
+  g_foos.push_back(this);
+}
+
+InstrumentedFoo &InstrumentedFoo::operator=(const InstrumentedFoo &foo) {
+  LLDB_RECORD_METHOD(InstrumentedFoo &,
+ InstrumentedFoo, operator=,(const InstrumentedFoo &), foo);
+  g_foos.erase(std::remove(g_foos.begin(), g_foos.end(), &foo));
+  g_foos.push_back(this);
+  return *this;
+}
+
+void InstrumentedFoo::A(int a) {
+  LLDB_RECORD_METHOD(void, InstrumentedFoo, A, (int), a);
+  B(a);
+  m_a = a;
+}
+
+void InstrumentedFoo::B(int &b) const {
+  LLDB_RECORD_METHOD_CONST(void, InstrumentedFoo, B, (int &), b);
+  m_called++;
+  m_b = b;
+}
+
+int InstrumentedFoo::C(float *c) {
+  LLDB_RECORD_METHOD(int, InstrumentedFoo, C, (float *), c);
+  m_c = *c;
+  return 1;
+}
+
+int InstrumentedFoo::D(const char *d) const {
+  LLDB_RECORD_METHOD_CONST(int, InstrumentedFoo, D, (const char *), d);
+  m_d = std::string(d);
+  return 2;
+}
+
+void InstrumentedFoo::E(double e) {
+  LLDB_RECORD_STATIC_METHOD(void, InstrumentedFoo, E, (double), e);
+  g_e = e;
+}
+
+int InstrumentedFoo::F() {
+  LLDB_RECORD_STATIC_METHOD_NO_ARGS(int, InstrumentedFoo, F);
+  g_f = true;
+  return 3;
+}
+
+void InstrumentedFoo::Validate() {
+  LLDB_RECORD_METHOD_NO_ARGS(void, InstrumentedFoo, Validate);
+  EXPECT_EQ(m_a, 100);
+  EXPECT_EQ(m_b, 200);
+  

[Lldb-commits] [lldb] r353326 - Add SBReproducer to Xcode project

2019-02-06 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Wed Feb  6 11:05:43 2019
New Revision: 353326

URL: http://llvm.org/viewvc/llvm-project?rev=353326&view=rev
Log:
Add SBReproducer to Xcode project

Modified:
lldb/trunk/lldb.xcodeproj/project.pbxproj

Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=353326&r1=353325&r2=353326&view=diff
==
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Wed Feb  6 11:05:43 2019
@@ -824,6 +824,7 @@
AF0EBBEC185941360059E52F /* SBQueue.h in Headers */ = {isa = 
PBXBuildFile; fileRef = AF0EBBEA185941360059E52F /* SBQueue.h */; settings = 
{ATTRIBUTES = (Public, ); }; };
AF0EBBE9185940FB0059E52F /* SBQueueItem.cpp in Sources */ = 
{isa = PBXBuildFile; fileRef = AF0EBBE7185940FB0059E52F /* SBQueueItem.cpp */; 
};
AF0EBBED185941360059E52F /* SBQueueItem.h in Headers */ = {isa 
= PBXBuildFile; fileRef = AF0EBBEB185941360059E52F /* SBQueueItem.h */; 
settings = {ATTRIBUTES = (Public, ); }; };
+   DD1E0ACA220B660100B815F8 /* SBReproducer.cpp in Sources */ = 
{isa = PBXBuildFile; fileRef = DD1E0AC9220B660100B815F8 /* SBReproducer.cpp */; 
};
26B82840142D020F002DBC64 /* SBSection.cpp in Sources */ = {isa 
= PBXBuildFile; fileRef = 26B8283F142D020F002DBC64 /* SBSection.cpp */; };
26B8283D142D01E9002DBC64 /* SBSection.h in Headers */ = {isa = 
PBXBuildFile; fileRef = 26B8283C142D01E9002DBC64 /* SBSection.h */; settings = 
{ATTRIBUTES = (Public, ); }; };
26680327116005DC008E1FE4 /* SBSourceManager.cpp in Sources */ = 
{isa = PBXBuildFile; fileRef = 9A9831051125FC5800A56CB0 /* SBSourceManager.cpp 
*/; };
@@ -2846,6 +2847,8 @@
AF0EBBE7185940FB0059E52F /* SBQueueItem.cpp */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; 
name = SBQueueItem.cpp; path = source/API/SBQueueItem.cpp; sourceTree = 
""; };
AF0EBBEB185941360059E52F /* SBQueueItem.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = 
SBQueueItem.h; path = include/lldb/API/SBQueueItem.h; sourceTree = ""; };
AF0EBBEF1859419F0059E52F /* SBQueueItem.i */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = 
sourcecode.c.c.preprocessed; path = SBQueueItem.i; sourceTree = ""; };
+   DD1E0AC9220B660100B815F8 /* SBReproducer.cpp */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; 
name = SBReproducer.cpp; path = source/API/SBReproducer.cpp; sourceTree = 
""; };
+   DD1E0ACB220B660E00B815F8 /* SBReproducerPrivate.h */ = {isa = 
PBXFileReference; lastKnownFileType = sourcecode.c.h; name = 
SBReproducerPrivate.h; path = source/API/SBReproducerPrivate.h; sourceTree = 
""; };
26B8283F142D020F002DBC64 /* SBSection.cpp */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; 
name = SBSection.cpp; path = source/API/SBSection.cpp; sourceTree = ""; 
};
26B8283C142D01E9002DBC64 /* SBSection.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = 
SBSection.h; path = include/lldb/API/SBSection.h; sourceTree = ""; };
2611FF08142D83060017FEA3 /* SBSection.i */ = {isa = 
PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = 
SBSection.i; sourceTree = ""; };
@@ -4739,7 +4742,9 @@
26F2F8FD1B156678007857DE /* StructuredData.h */,
AFEC3361194A8ABA00FF05C6 /* StructuredData.cpp 
*/,
AFF8FF0B1E779D4B003830EF /* 
TildeExpressionResolver.cpp */,
+   DD1E0AC9220B660100B815F8 /* SBReproducer.cpp */,
AFF8FF0D1E779D51003830EF /* 
TildeExpressionResolver.h */,
+   DD1E0ACB220B660E00B815F8 /* 
SBReproducerPrivate.h */,
26BC7D7E10F1B77400F91463 /* Timer.h */,
26BC7E9610F1B85900F91463 /* Timer.cpp */,
2654A6911E552F3C00DA1013 /* UriParser.h */,
@@ -8497,6 +8502,7 @@
26D7E45D13D5E30A007FD12B /* SocketAddress.cpp 
in Sources */,
94CD7D0C19A3FBCE00908B7C /* 
AppleObjCTypeEncodingParser.cpp in Sources */,
94B6E76213D88365005F417F /* 
ValueObjectSyntheticFilter.cpp in Sources */,
+   DD1E0ACA220B660100B815F8 /* SBReproducer.cpp in 
Sources */,
267A47FF1B1411D90021A5BC /* 
NativeWatchpointList.cpp in Sources */,
26F4A21C13FBA31A0064B613 /* ThreadMemory.cpp in 
Sources */,

[Lldb-commits] [PATCH] D57830: Add functionality to trace a function within lldb

2019-02-06 Thread Aditya Kumar via Phabricator via lldb-commits
hiraditya created this revision.
hiraditya added reviewers: xiaobai, clayborg.
Herald added a reviewer: serge-sans-paille.
Herald added a project: LLDB.

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D57830

Files:
  examples/python/process_events.py


Index: examples/python/process_events.py
===
--- examples/python/process_events.py
+++ examples/python/process_events.py
@@ -184,6 +184,12 @@
 help='Specify the timeout in seconds to wait for process state change 
events.',
 default=lldb.UINT32_MAX)
 parser.add_option(
+'-f',
+'--trace-function',
+type='string',
+dest='trace_function',
+help='Trace a function during execution, Warning: tracing is really 
slow.')
+parser.add_option(
 '-e',
 '--environment',
 action='append',
@@ -275,6 +281,9 @@
 for bp in options.breakpoints:
 debugger.HandleCommand("_regexp-break %s" % (bp))
 run_commands(command_interpreter, ['breakpoint list'])
+if launch_info and options.trace_function:
+debugger.HandleCommand("_regexp-break &%s" % 
(options.trace_function))
+run_commands(command_interpreter, ['breakpoint list'])
 
 for run_idx in range(options.run_count):
 # Launch the process. Since we specified synchronous mode, we 
won't return
@@ -348,7 +357,10 @@
 stop_idx += 1
 print_threads(process, options)
 print "continuing process %u" % (pid)
-process.Continue()
+if options.trace_function:
+process.GetThreadAtIndex(0).StepInto()
+else:
+process.Continue()
 elif state == lldb.eStateExited:
 exit_desc = process.GetExitDescription()
 if exit_desc:


Index: examples/python/process_events.py
===
--- examples/python/process_events.py
+++ examples/python/process_events.py
@@ -184,6 +184,12 @@
 help='Specify the timeout in seconds to wait for process state change events.',
 default=lldb.UINT32_MAX)
 parser.add_option(
+'-f',
+'--trace-function',
+type='string',
+dest='trace_function',
+help='Trace a function during execution, Warning: tracing is really slow.')
+parser.add_option(
 '-e',
 '--environment',
 action='append',
@@ -275,6 +281,9 @@
 for bp in options.breakpoints:
 debugger.HandleCommand("_regexp-break %s" % (bp))
 run_commands(command_interpreter, ['breakpoint list'])
+if launch_info and options.trace_function:
+debugger.HandleCommand("_regexp-break &%s" % (options.trace_function))
+run_commands(command_interpreter, ['breakpoint list'])
 
 for run_idx in range(options.run_count):
 # Launch the process. Since we specified synchronous mode, we won't return
@@ -348,7 +357,10 @@
 stop_idx += 1
 print_threads(process, options)
 print "continuing process %u" % (pid)
-process.Continue()
+if options.trace_function:
+process.GetThreadAtIndex(0).StepInto()
+else:
+process.Continue()
 elif state == lldb.eStateExited:
 exit_desc = process.GetExitDescription()
 if exit_desc:
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D57402: build: remove custom variables

2019-02-06 Thread Saleem Abdulrasool via Phabricator via lldb-commits
compnerd added a comment.

@sgraenitz yeah, I passed `LLVM_DIR` and `Clang_DIR`, but, this is for a 
**standalone** build, so I think that it is pretty reasonable to ask that the 
user tell us where LLVM and Clang are built.  Although, if you install LLVM and 
Clang to your root (like on Linux), you do not need to specify that because it 
will search the system by default.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D57402



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


[Lldb-commits] [PATCH] D57840: [Py3/TestAppleOSSimulator] Another byte<->str interoperability issue.

2019-02-06 Thread Davide Italiano via Phabricator via lldb-commits
davide created this revision.
davide added reviewers: JDevlieghere, friss, zturner, labath, jingham.
Herald added a reviewer: serge-sans-paille.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

[testsuite] Convert a pexpect test to lit.


Repository:
  rL LLVM

https://reviews.llvm.org/D57840

Files:
  lldb/lit/Commands/command-regex-2.test
  lldb/lit/Commands/command-regex.test
  lldb/packages/Python/lldbsuite/test/functionalities/command_regex/.categories
  
lldb/packages/Python/lldbsuite/test/functionalities/command_regex/TestCommandRegex.py
  
lldb/packages/Python/lldbsuite/test/tools/lldb-server/TestAppleSimulatorOSType.py

Index: lldb/packages/Python/lldbsuite/test/tools/lldb-server/TestAppleSimulatorOSType.py
===
--- lldb/packages/Python/lldbsuite/test/tools/lldb-server/TestAppleSimulatorOSType.py
+++ lldb/packages/Python/lldbsuite/test/tools/lldb-server/TestAppleSimulatorOSType.py
@@ -15,7 +15,7 @@
 
 def check_simulator_ostype(self, sdk, platform, arch='x86_64'):
 sim_devices_str = subprocess.check_output(['xcrun', 'simctl', 'list',
-   '-j', 'devices'])
+   '-j', 'devices']).decode("utf-8")
 sim_devices = json.loads(sim_devices_str)['devices']
 # Find an available simulator for the requested platform
 deviceUDID = None
Index: lldb/packages/Python/lldbsuite/test/functionalities/command_regex/TestCommandRegex.py
===
--- lldb/packages/Python/lldbsuite/test/functionalities/command_regex/TestCommandRegex.py
+++ /dev/null
@@ -1,63 +0,0 @@
-"""
-Test lldb 'commands regex' command which allows the user to create a regular expression command.
-"""
-
-from __future__ import print_function
-
-
-import os
-import lldb
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-
-
-class CommandRegexTestCase(TestBase):
-
-mydir = TestBase.compute_mydir(__file__)
-
-@expectedFailureAll(
-hostoslist=["windows"],
-bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
-@no_debug_info_test
-def test_command_regex(self):
-"""Test a simple scenario of 'command regex' invocation and subsequent use."""
-import pexpect
-prompt = "(lldb) "
-regex_prompt = "Enter one of more sed substitution commands in the form: 's///'.\r\nTerminate the substitution list with an empty line.\r\n"
-regex_prompt1 = "\r\n"
-
-child = pexpect.spawn('%s %s' %
-  (lldbtest_config.lldbExec, self.lldbOption))
-# Turn on logging for what the child sends back.
-if self.TraceOn():
-child.logfile_read = sys.stdout
-# So that the spawned lldb session gets shutdown durng teardown.
-self.child = child
-
-# Substitute 'Help!' for 'help' using the 'commands regex' mechanism.
-child.expect_exact(prompt)
-child.sendline("command regex 'Help__'")
-child.expect_exact(regex_prompt)
-child.sendline('s/^$/help/')
-child.expect_exact(regex_prompt1)
-child.sendline('')
-child.expect_exact(prompt)
-# Help!
-child.sendline('Help__')
-# If we see the familiar 'help' output, the test is done.
-child.expect('Debugger commands:')
-# Try and incorrectly remove "Help__" using "command unalias" and
-# verify we fail
-child.sendline('command unalias Help__')
-child.expect_exact(
-"error: 'Help__' is not an alias, it is a debugger command which can be removed using the 'command delete' command")
-child.expect_exact(prompt)
-
-# Delete the regex command using "command delete"
-child.sendline('command delete Help__')
-child.expect_exact(prompt)
-# Verify the command was removed
-child.sendline('Help__')
-child.expect_exact("error: 'Help__' is not a valid command")
-child.expect_exact(prompt)
Index: lldb/packages/Python/lldbsuite/test/functionalities/command_regex/.categories
===
--- lldb/packages/Python/lldbsuite/test/functionalities/command_regex/.categories
+++ /dev/null
@@ -1 +0,0 @@
-cmdline
Index: lldb/lit/Commands/command-regex.test
===
--- /dev/null
+++ lldb/lit/Commands/command-regex.test
@@ -0,0 +1,14 @@
+# Check basic functionality of command regex.
+# RUN: %lldb -s %s 2>&1 | FileCheck %s
+
+command regex 'Help__'
+# CHECK: Enter one of more sed substitution commands in the form
+# We need to leave a new line after to end the regex.
+s/^$/help/
+
+Help__
+# CHECK: Debugger commands:
+
+command delete Help__
+Help__
+# CHECK: error: 'Help__' 

[Lldb-commits] [PATCH] D57840: [Py3/TestAppleOSSimulator] Another byte<->str interoperability issue.

2019-02-06 Thread Davide Italiano via Phabricator via lldb-commits
davide marked an inline comment as done.
davide added inline comments.



Comment at: 
lldb/packages/Python/lldbsuite/test/tools/lldb-server/TestAppleSimulatorOSType.py:18
 sim_devices_str = subprocess.check_output(['xcrun', 'simctl', 'list',
-   '-j', 'devices'])
+   '-j', 
'devices']).decode("utf-8")
 sim_devices = json.loads(sim_devices_str)['devices']

Ignore this bit, I already pushed it.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D57840



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


[Lldb-commits] [PATCH] D57840: [Py3/TestAppleOSSimulator] Another byte<->str interoperability issue.

2019-02-06 Thread Davide Italiano via Phabricator via lldb-commits
davide updated this revision to Diff 185621.
davide added a comment.

update with the correct patch.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D57840

Files:
  lldb/lit/Commands/command-regex-2.test
  lldb/lit/Commands/command-regex.test
  lldb/packages/Python/lldbsuite/test/functionalities/command_regex/.categories
  
lldb/packages/Python/lldbsuite/test/functionalities/command_regex/TestCommandRegex.py

Index: lldb/packages/Python/lldbsuite/test/functionalities/command_regex/TestCommandRegex.py
===
--- lldb/packages/Python/lldbsuite/test/functionalities/command_regex/TestCommandRegex.py
+++ /dev/null
@@ -1,63 +0,0 @@
-"""
-Test lldb 'commands regex' command which allows the user to create a regular expression command.
-"""
-
-from __future__ import print_function
-
-
-import os
-import lldb
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-
-
-class CommandRegexTestCase(TestBase):
-
-mydir = TestBase.compute_mydir(__file__)
-
-@expectedFailureAll(
-hostoslist=["windows"],
-bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
-@no_debug_info_test
-def test_command_regex(self):
-"""Test a simple scenario of 'command regex' invocation and subsequent use."""
-import pexpect
-prompt = "(lldb) "
-regex_prompt = "Enter one of more sed substitution commands in the form: 's///'.\r\nTerminate the substitution list with an empty line.\r\n"
-regex_prompt1 = "\r\n"
-
-child = pexpect.spawn('%s %s' %
-  (lldbtest_config.lldbExec, self.lldbOption))
-# Turn on logging for what the child sends back.
-if self.TraceOn():
-child.logfile_read = sys.stdout
-# So that the spawned lldb session gets shutdown durng teardown.
-self.child = child
-
-# Substitute 'Help!' for 'help' using the 'commands regex' mechanism.
-child.expect_exact(prompt)
-child.sendline("command regex 'Help__'")
-child.expect_exact(regex_prompt)
-child.sendline('s/^$/help/')
-child.expect_exact(regex_prompt1)
-child.sendline('')
-child.expect_exact(prompt)
-# Help!
-child.sendline('Help__')
-# If we see the familiar 'help' output, the test is done.
-child.expect('Debugger commands:')
-# Try and incorrectly remove "Help__" using "command unalias" and
-# verify we fail
-child.sendline('command unalias Help__')
-child.expect_exact(
-"error: 'Help__' is not an alias, it is a debugger command which can be removed using the 'command delete' command")
-child.expect_exact(prompt)
-
-# Delete the regex command using "command delete"
-child.sendline('command delete Help__')
-child.expect_exact(prompt)
-# Verify the command was removed
-child.sendline('Help__')
-child.expect_exact("error: 'Help__' is not a valid command")
-child.expect_exact(prompt)
Index: lldb/packages/Python/lldbsuite/test/functionalities/command_regex/.categories
===
--- lldb/packages/Python/lldbsuite/test/functionalities/command_regex/.categories
+++ /dev/null
@@ -1 +0,0 @@
-cmdline
Index: lldb/lit/Commands/command-regex.test
===
--- /dev/null
+++ lldb/lit/Commands/command-regex.test
@@ -0,0 +1,14 @@
+# Check basic functionality of command regex.
+# RUN: %lldb -s %s 2>&1 | FileCheck %s
+
+command regex 'Help__'
+# CHECK: Enter one of more sed substitution commands in the form
+# We need to leave a new line after to end the regex.
+s/^$/help/
+
+Help__
+# CHECK: Debugger commands:
+
+command delete Help__
+Help__
+# CHECK: error: 'Help__' is not a valid command
Index: lldb/lit/Commands/command-regex-2.test
===
--- /dev/null
+++ lldb/lit/Commands/command-regex-2.test
@@ -0,0 +1,11 @@
+# Check that commands created with command regex cannot be unaliased
+# RUN: %lldb -s %s 2>&1 | FileCheck %s
+
+command regex 'Help__'
+# CHECK: Enter one of more sed substitution commands in the form
+# We need to leave a new line after to end the regex.
+s/^$/help/
+
+command unalias Help__
+Help__
+# CHECK: error: 'Help__' is not an alias
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D57840: Convert TestCommandRegex to lit (from expect)

2019-02-06 Thread Zachary Turner via Phabricator via lldb-commits
zturner accepted this revision.
zturner added a comment.
This revision is now accepted and ready to land.

Can you rename these two tests to `command-regex-delete.test` and 
`command-regex-unalias.test`?  Otherwise, lgtm


Repository:
  rL LLVM

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

https://reviews.llvm.org/D57840



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


[Lldb-commits] [PATCH] D57840: Convert TestCommandRegex to lit (from expect)

2019-02-06 Thread Davide Italiano via Phabricator via lldb-commits
davide updated this revision to Diff 185633.
davide added a comment.

zturner's update.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D57840

Files:
  lldb/packages/Python/lldbsuite/test/functionalities/command_regex/.categories
  
lldb/packages/Python/lldbsuite/test/functionalities/command_regex/TestCommandRegex.py


Index: 
lldb/packages/Python/lldbsuite/test/functionalities/command_regex/TestCommandRegex.py
===
--- 
lldb/packages/Python/lldbsuite/test/functionalities/command_regex/TestCommandRegex.py
+++ /dev/null
@@ -1,63 +0,0 @@
-"""
-Test lldb 'commands regex' command which allows the user to create a regular 
expression command.
-"""
-
-from __future__ import print_function
-
-
-import os
-import lldb
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-
-
-class CommandRegexTestCase(TestBase):
-
-mydir = TestBase.compute_mydir(__file__)
-
-@expectedFailureAll(
-hostoslist=["windows"],
-bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
-@no_debug_info_test
-def test_command_regex(self):
-"""Test a simple scenario of 'command regex' invocation and subsequent 
use."""
-import pexpect
-prompt = "(lldb) "
-regex_prompt = "Enter one of more sed substitution commands in the 
form: 's///'.\r\nTerminate the substitution list with an empty 
line.\r\n"
-regex_prompt1 = "\r\n"
-
-child = pexpect.spawn('%s %s' %
-  (lldbtest_config.lldbExec, self.lldbOption))
-# Turn on logging for what the child sends back.
-if self.TraceOn():
-child.logfile_read = sys.stdout
-# So that the spawned lldb session gets shutdown durng teardown.
-self.child = child
-
-# Substitute 'Help!' for 'help' using the 'commands regex' mechanism.
-child.expect_exact(prompt)
-child.sendline("command regex 'Help__'")
-child.expect_exact(regex_prompt)
-child.sendline('s/^$/help/')
-child.expect_exact(regex_prompt1)
-child.sendline('')
-child.expect_exact(prompt)
-# Help!
-child.sendline('Help__')
-# If we see the familiar 'help' output, the test is done.
-child.expect('Debugger commands:')
-# Try and incorrectly remove "Help__" using "command unalias" and
-# verify we fail
-child.sendline('command unalias Help__')
-child.expect_exact(
-"error: 'Help__' is not an alias, it is a debugger command which 
can be removed using the 'command delete' command")
-child.expect_exact(prompt)
-
-# Delete the regex command using "command delete"
-child.sendline('command delete Help__')
-child.expect_exact(prompt)
-# Verify the command was removed
-child.sendline('Help__')
-child.expect_exact("error: 'Help__' is not a valid command")
-child.expect_exact(prompt)
Index: 
lldb/packages/Python/lldbsuite/test/functionalities/command_regex/.categories
===
--- 
lldb/packages/Python/lldbsuite/test/functionalities/command_regex/.categories
+++ /dev/null
@@ -1 +0,0 @@
-cmdline


Index: lldb/packages/Python/lldbsuite/test/functionalities/command_regex/TestCommandRegex.py
===
--- lldb/packages/Python/lldbsuite/test/functionalities/command_regex/TestCommandRegex.py
+++ /dev/null
@@ -1,63 +0,0 @@
-"""
-Test lldb 'commands regex' command which allows the user to create a regular expression command.
-"""
-
-from __future__ import print_function
-
-
-import os
-import lldb
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-
-
-class CommandRegexTestCase(TestBase):
-
-mydir = TestBase.compute_mydir(__file__)
-
-@expectedFailureAll(
-hostoslist=["windows"],
-bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
-@no_debug_info_test
-def test_command_regex(self):
-"""Test a simple scenario of 'command regex' invocation and subsequent use."""
-import pexpect
-prompt = "(lldb) "
-regex_prompt = "Enter one of more sed substitution commands in the form: 's///'.\r\nTerminate the substitution list with an empty line.\r\n"
-regex_prompt1 = "\r\n"
-
-child = pexpect.spawn('%s %s' %
-  (lldbtest_config.lldbExec, self.lldbOption))
-# Turn on logging for what the child sends back.
-if self.TraceOn():
-child.logfile_read = sys.stdout
-# So that the spawned lldb session gets shutdown durng teardown.
-self.child = child
-
-# Substitute 'Help!' for 'help' using the '

[Lldb-commits] [PATCH] D57840: Convert TestCommandRegex to lit (from expect)

2019-02-06 Thread Davide Italiano via Phabricator via lldb-commits
davide updated this revision to Diff 185634.
davide added a comment.

jonas was right


Repository:
  rL LLVM

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

https://reviews.llvm.org/D57840

Files:
  lldb/lit/Commands/command-regex-delete.test
  lldb/lit/Commands/command-regex-unalias.test
  lldb/packages/Python/lldbsuite/test/functionalities/command_regex/.categories
  
lldb/packages/Python/lldbsuite/test/functionalities/command_regex/TestCommandRegex.py

Index: lldb/packages/Python/lldbsuite/test/functionalities/command_regex/TestCommandRegex.py
===
--- lldb/packages/Python/lldbsuite/test/functionalities/command_regex/TestCommandRegex.py
+++ /dev/null
@@ -1,63 +0,0 @@
-"""
-Test lldb 'commands regex' command which allows the user to create a regular expression command.
-"""
-
-from __future__ import print_function
-
-
-import os
-import lldb
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-
-
-class CommandRegexTestCase(TestBase):
-
-mydir = TestBase.compute_mydir(__file__)
-
-@expectedFailureAll(
-hostoslist=["windows"],
-bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
-@no_debug_info_test
-def test_command_regex(self):
-"""Test a simple scenario of 'command regex' invocation and subsequent use."""
-import pexpect
-prompt = "(lldb) "
-regex_prompt = "Enter one of more sed substitution commands in the form: 's///'.\r\nTerminate the substitution list with an empty line.\r\n"
-regex_prompt1 = "\r\n"
-
-child = pexpect.spawn('%s %s' %
-  (lldbtest_config.lldbExec, self.lldbOption))
-# Turn on logging for what the child sends back.
-if self.TraceOn():
-child.logfile_read = sys.stdout
-# So that the spawned lldb session gets shutdown durng teardown.
-self.child = child
-
-# Substitute 'Help!' for 'help' using the 'commands regex' mechanism.
-child.expect_exact(prompt)
-child.sendline("command regex 'Help__'")
-child.expect_exact(regex_prompt)
-child.sendline('s/^$/help/')
-child.expect_exact(regex_prompt1)
-child.sendline('')
-child.expect_exact(prompt)
-# Help!
-child.sendline('Help__')
-# If we see the familiar 'help' output, the test is done.
-child.expect('Debugger commands:')
-# Try and incorrectly remove "Help__" using "command unalias" and
-# verify we fail
-child.sendline('command unalias Help__')
-child.expect_exact(
-"error: 'Help__' is not an alias, it is a debugger command which can be removed using the 'command delete' command")
-child.expect_exact(prompt)
-
-# Delete the regex command using "command delete"
-child.sendline('command delete Help__')
-child.expect_exact(prompt)
-# Verify the command was removed
-child.sendline('Help__')
-child.expect_exact("error: 'Help__' is not a valid command")
-child.expect_exact(prompt)
Index: lldb/packages/Python/lldbsuite/test/functionalities/command_regex/.categories
===
--- lldb/packages/Python/lldbsuite/test/functionalities/command_regex/.categories
+++ /dev/null
@@ -1 +0,0 @@
-cmdline
Index: lldb/lit/Commands/command-regex-unalias.test
===
--- /dev/null
+++ lldb/lit/Commands/command-regex-unalias.test
@@ -0,0 +1,11 @@
+# Check that commands created with command regex cannot be unaliased
+# RUN: %lldb -s %s 2>&1 | FileCheck %s
+
+command regex 'Help__'
+# CHECK: Enter one of more sed substitution commands in the form
+# We need to leave a new line after to end the regex.
+s/^$/help/
+
+command unalias Help__
+Help__
+# CHECK: error: 'Help__' is not an alias
Index: lldb/lit/Commands/command-regex-delete.test
===
--- /dev/null
+++ lldb/lit/Commands/command-regex-delete.test
@@ -0,0 +1,14 @@
+# Check basic functionality of command regex.
+# RUN: %lldb -s %s 2>&1 | FileCheck %s
+
+command regex 'Help__'
+# CHECK: Enter one of more sed substitution commands in the form
+# We need to leave a new line after to end the regex.
+s/^$/help/
+
+Help__
+# CHECK: Debugger commands:
+
+command delete Help__
+Help__
+# CHECK: error: 'Help__' is not a valid command
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r353345 - [testsuite] Convert a pexpect test to lit.

2019-02-06 Thread Davide Italiano via lldb-commits
Author: davide
Date: Wed Feb  6 13:48:01 2019
New Revision: 353345

URL: http://llvm.org/viewvc/llvm-project?rev=353345&view=rev
Log:
[testsuite] Convert a pexpect test to lit.

Summary:

Reviewers: JDevlieghere, friss, zturner, labath, jingham, serge-sans-paille

Subscribers: llvm-commits, lldb-commits

Tags: #llvm

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

Added:
lldb/trunk/lit/Commands/
lldb/trunk/lit/Commands/command-regex-delete.test
lldb/trunk/lit/Commands/command-regex-unalias.test
Removed:
lldb/trunk/packages/Python/lldbsuite/test/functionalities/command_regex/

Added: lldb/trunk/lit/Commands/command-regex-delete.test
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Commands/command-regex-delete.test?rev=353345&view=auto
==
--- lldb/trunk/lit/Commands/command-regex-delete.test (added)
+++ lldb/trunk/lit/Commands/command-regex-delete.test Wed Feb  6 13:48:01 2019
@@ -0,0 +1,14 @@
+# Check basic functionality of command regex.
+# RUN: %lldb -s %s 2>&1 | FileCheck %s
+
+command regex 'Help__'
+# CHECK: Enter one of more sed substitution commands in the form
+# We need to leave a new line after to end the regex.
+s/^$/help/
+
+Help__
+# CHECK: Debugger commands:
+
+command delete Help__
+Help__
+# CHECK: error: 'Help__' is not a valid command

Added: lldb/trunk/lit/Commands/command-regex-unalias.test
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Commands/command-regex-unalias.test?rev=353345&view=auto
==
--- lldb/trunk/lit/Commands/command-regex-unalias.test (added)
+++ lldb/trunk/lit/Commands/command-regex-unalias.test Wed Feb  6 13:48:01 2019
@@ -0,0 +1,11 @@
+# Check that commands created with command regex cannot be unaliased
+# RUN: %lldb -s %s 2>&1 | FileCheck %s
+
+command regex 'Help__'
+# CHECK: Enter one of more sed substitution commands in the form
+# We need to leave a new line after to end the regex.
+s/^$/help/
+
+command unalias Help__
+Help__
+# CHECK: error: 'Help__' is not an alias


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


[Lldb-commits] [PATCH] D57840: Convert TestCommandRegex to lit (from expect)

2019-02-06 Thread Davide Italiano via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL353345: [testsuite] Convert a pexpect test to lit. (authored 
by davide, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D57840?vs=185634&id=185635#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D57840

Files:
  lldb/trunk/lit/Commands/command-regex-delete.test
  lldb/trunk/lit/Commands/command-regex-unalias.test
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/command_regex/.categories
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/command_regex/TestCommandRegex.py

Index: lldb/trunk/lit/Commands/command-regex-unalias.test
===
--- lldb/trunk/lit/Commands/command-regex-unalias.test
+++ lldb/trunk/lit/Commands/command-regex-unalias.test
@@ -0,0 +1,11 @@
+# Check that commands created with command regex cannot be unaliased
+# RUN: %lldb -s %s 2>&1 | FileCheck %s
+
+command regex 'Help__'
+# CHECK: Enter one of more sed substitution commands in the form
+# We need to leave a new line after to end the regex.
+s/^$/help/
+
+command unalias Help__
+Help__
+# CHECK: error: 'Help__' is not an alias
Index: lldb/trunk/lit/Commands/command-regex-delete.test
===
--- lldb/trunk/lit/Commands/command-regex-delete.test
+++ lldb/trunk/lit/Commands/command-regex-delete.test
@@ -0,0 +1,14 @@
+# Check basic functionality of command regex.
+# RUN: %lldb -s %s 2>&1 | FileCheck %s
+
+command regex 'Help__'
+# CHECK: Enter one of more sed substitution commands in the form
+# We need to leave a new line after to end the regex.
+s/^$/help/
+
+Help__
+# CHECK: Debugger commands:
+
+command delete Help__
+Help__
+# CHECK: error: 'Help__' is not a valid command
Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/command_regex/.categories
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/command_regex/.categories
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/command_regex/.categories
@@ -1 +0,0 @@
-cmdline
Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/command_regex/TestCommandRegex.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/command_regex/TestCommandRegex.py
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/command_regex/TestCommandRegex.py
@@ -1,63 +0,0 @@
-"""
-Test lldb 'commands regex' command which allows the user to create a regular expression command.
-"""
-
-from __future__ import print_function
-
-
-import os
-import lldb
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-
-
-class CommandRegexTestCase(TestBase):
-
-mydir = TestBase.compute_mydir(__file__)
-
-@expectedFailureAll(
-hostoslist=["windows"],
-bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
-@no_debug_info_test
-def test_command_regex(self):
-"""Test a simple scenario of 'command regex' invocation and subsequent use."""
-import pexpect
-prompt = "(lldb) "
-regex_prompt = "Enter one of more sed substitution commands in the form: 's///'.\r\nTerminate the substitution list with an empty line.\r\n"
-regex_prompt1 = "\r\n"
-
-child = pexpect.spawn('%s %s' %
-  (lldbtest_config.lldbExec, self.lldbOption))
-# Turn on logging for what the child sends back.
-if self.TraceOn():
-child.logfile_read = sys.stdout
-# So that the spawned lldb session gets shutdown durng teardown.
-self.child = child
-
-# Substitute 'Help!' for 'help' using the 'commands regex' mechanism.
-child.expect_exact(prompt)
-child.sendline("command regex 'Help__'")
-child.expect_exact(regex_prompt)
-child.sendline('s/^$/help/')
-child.expect_exact(regex_prompt1)
-child.sendline('')
-child.expect_exact(prompt)
-# Help!
-child.sendline('Help__')
-# If we see the familiar 'help' output, the test is done.
-child.expect('Debugger commands:')
-# Try and incorrectly remove "Help__" using "command unalias" and
-# verify we fail
-child.sendline('command unalias Help__')
-child.expect_exact(
-"error: 'Help__' is not an alias, it is a debugger command which can be removed using the 'command delete' command")
-child.expect_exact(prompt)
-
-# Delete the regex command using "command delete"
-child.sendline('command delete Help__')
-child.expect_exact(prompt)
-# Verify the command was removed
-child.sendline('Help__')
-child.expect_e

[Lldb-commits] [PATCH] D57840: Convert TestCommandRegex to lit (from expect)

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

LGTM, thanks!


Repository:
  rL LLVM

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

https://reviews.llvm.org/D57840



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


[Lldb-commits] [lldb] r353361 - Fix my mistake adding SBReproducer the Xcode project

2019-02-06 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Wed Feb  6 17:42:47 2019
New Revision: 353361

URL: http://llvm.org/viewvc/llvm-project?rev=353361&view=rev
Log:
Fix my mistake adding SBReproducer the Xcode project

Modified:
lldb/trunk/lldb.xcodeproj/project.pbxproj

Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=353361&r1=353360&r2=353361&view=diff
==
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Wed Feb  6 17:42:47 2019
@@ -824,7 +824,8 @@
AF0EBBEC185941360059E52F /* SBQueue.h in Headers */ = {isa = 
PBXBuildFile; fileRef = AF0EBBEA185941360059E52F /* SBQueue.h */; settings = 
{ATTRIBUTES = (Public, ); }; };
AF0EBBE9185940FB0059E52F /* SBQueueItem.cpp in Sources */ = 
{isa = PBXBuildFile; fileRef = AF0EBBE7185940FB0059E52F /* SBQueueItem.cpp */; 
};
AF0EBBED185941360059E52F /* SBQueueItem.h in Headers */ = {isa 
= PBXBuildFile; fileRef = AF0EBBEB185941360059E52F /* SBQueueItem.h */; 
settings = {ATTRIBUTES = (Public, ); }; };
-   DD1E0ACA220B660100B815F8 /* SBReproducer.cpp in Sources */ = 
{isa = PBXBuildFile; fileRef = DD1E0AC9220B660100B815F8 /* SBReproducer.cpp */; 
};
+   DD1E0ACE220BC3A100B815F8 /* SBReproducer.cpp in Sources */ = 
{isa = PBXBuildFile; fileRef = DD1E0AC9220B660100B815F8 /* SBReproducer.cpp */; 
};
+   DD1E0AD1220BC3DC00B815F8 /* SBReproducer.h in Headers */ = {isa 
= PBXBuildFile; fileRef = DD1E0AD0220BC3D400B815F8 /* SBReproducer.h */; 
settings = {ATTRIBUTES = (Public, ); }; };
26B82840142D020F002DBC64 /* SBSection.cpp in Sources */ = {isa 
= PBXBuildFile; fileRef = 26B8283F142D020F002DBC64 /* SBSection.cpp */; };
26B8283D142D01E9002DBC64 /* SBSection.h in Headers */ = {isa = 
PBXBuildFile; fileRef = 26B8283C142D01E9002DBC64 /* SBSection.h */; settings = 
{ATTRIBUTES = (Public, ); }; };
26680327116005DC008E1FE4 /* SBSourceManager.cpp in Sources */ = 
{isa = PBXBuildFile; fileRef = 9A9831051125FC5800A56CB0 /* SBSourceManager.cpp 
*/; };
@@ -2848,6 +2849,7 @@
AF0EBBEB185941360059E52F /* SBQueueItem.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = 
SBQueueItem.h; path = include/lldb/API/SBQueueItem.h; sourceTree = ""; };
AF0EBBEF1859419F0059E52F /* SBQueueItem.i */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = 
sourcecode.c.c.preprocessed; path = SBQueueItem.i; sourceTree = ""; };
DD1E0AC9220B660100B815F8 /* SBReproducer.cpp */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; 
name = SBReproducer.cpp; path = source/API/SBReproducer.cpp; sourceTree = 
""; };
+   DD1E0AD0220BC3D400B815F8 /* SBReproducer.h */ = {isa = 
PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SBReproducer.h; 
path = "include/lldb/API/SBReproducer.h"; sourceTree = ""; };
DD1E0ACB220B660E00B815F8 /* SBReproducerPrivate.h */ = {isa = 
PBXFileReference; lastKnownFileType = sourcecode.c.h; name = 
SBReproducerPrivate.h; path = source/API/SBReproducerPrivate.h; sourceTree = 
""; };
26B8283F142D020F002DBC64 /* SBSection.cpp */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; 
name = SBSection.cpp; path = source/API/SBSection.cpp; sourceTree = ""; 
};
26B8283C142D01E9002DBC64 /* SBSection.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = 
SBSection.h; path = include/lldb/API/SBSection.h; sourceTree = ""; };
@@ -4423,6 +4425,9 @@
2617447911685869005ADD65 /* SBType.h */,
261744771168585B005ADD65 /* SBType.cpp */,
9475C18514E5E9C5001BFC6D /* SBTypeCategory.h */,
+   DD1E0AC9220B660100B815F8 /* SBReproducer.cpp */,
+   DD1E0AD0220BC3D400B815F8 /* SBReproducer.h */,
+   DD1E0ACB220B660E00B815F8 /* 
SBReproducerPrivate.h */,
9475C18714E5E9FA001BFC6D /* SBTypeCategory.cpp 
*/,
23EFE388193D1ABC00E54E54 /* SBTypeEnumMember.h 
*/,
23EFE38A193D1AEC00E54E54 /* 
SBTypeEnumMember.cpp */,
@@ -4742,9 +4747,7 @@
26F2F8FD1B156678007857DE /* StructuredData.h */,
AFEC3361194A8ABA00FF05C6 /* StructuredData.cpp 
*/,
AFF8FF0B1E779D4B003830EF /* 
TildeExpressionResolver.cpp */,
-   DD1E0AC9220B660100B815F8 /* SBReproducer.cpp */,
AFF8FF0D1E779D51003830EF /* 
TildeExpressionResolver.h */,

[Lldb-commits] [lldb] r353362 - [Driver] Don't try to replay reproducer in the driver.

2019-02-06 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Wed Feb  6 17:49:07 2019
New Revision: 353362

URL: http://llvm.org/viewvc/llvm-project?rev=353362&view=rev
Log:
[Driver] Don't try to replay reproducer in the driver.

Because the macros for the SBReproducers have not been committed yet,
the driver should not attempt to replay a reproducer this way.

Modified:
lldb/trunk/tools/driver/Driver.cpp

Modified: lldb/trunk/tools/driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=353362&r1=353361&r2=353362&view=diff
==
--- lldb/trunk/tools/driver/Driver.cpp (original)
+++ lldb/trunk/tools/driver/Driver.cpp Wed Feb  6 17:49:07 2019
@@ -13,7 +13,6 @@
 #include "lldb/API/SBDebugger.h"
 #include "lldb/API/SBHostOS.h"
 #include "lldb/API/SBLanguageRuntime.h"
-#include "lldb/API/SBReproducer.h"
 #include "lldb/API/SBStream.h"
 #include "lldb/API/SBStringList.h"
 
@@ -913,14 +912,6 @@ main(int argc, char const *argv[])
 return 1;
   }
 
-  if (replay) {
-SBReproducer reproducer;
-if (!reproducer.Replay()) {
-  WithColor::error() << "something went wrong running the reporducer.\n";
-}
-return 0;
-  }
-
   SBHostOS::ThreadCreated("");
 
   signal(SIGINT, sigint_handler);


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


[Lldb-commits] [lldb] r353363 - [lldb] Make frame recognizers vend synthesized eValueTypeVariableArgument values

2019-02-06 Thread Kuba Mracek via lldb-commits
Author: kuba.brecka
Date: Wed Feb  6 17:49:10 2019
New Revision: 353363

URL: http://llvm.org/viewvc/llvm-project?rev=353363&view=rev
Log:
[lldb] Make frame recognizers vend synthesized eValueTypeVariableArgument values


Modified:
lldb/trunk/include/lldb/Target/StackFrameRecognizer.h

lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/TestFrameRecognizer.py

lldb/trunk/packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py

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

Modified: lldb/trunk/include/lldb/Target/StackFrameRecognizer.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/StackFrameRecognizer.h?rev=353363&r1=353362&r2=353363&view=diff
==
--- lldb/trunk/include/lldb/Target/StackFrameRecognizer.h (original)
+++ lldb/trunk/include/lldb/Target/StackFrameRecognizer.h Wed Feb  6 17:49:10 
2019
@@ -9,6 +9,7 @@
 #ifndef liblldb_StackFrameRecognizer_h_
 #define liblldb_StackFrameRecognizer_h_
 
+#include "lldb/Core/ValueObject.h"
 #include "lldb/Core/ValueObjectList.h"
 #include "lldb/Symbol/VariableList.h"
 #include "lldb/Utility/StructuredData.h"
@@ -123,6 +124,42 @@ public:
   static lldb::RecognizedStackFrameSP RecognizeFrame(lldb::StackFrameSP frame);
 };
 
+/// @class ValueObjectRecognizerSynthesizedValue
+///
+/// ValueObject subclass that presents the passed ValueObject as a recognized
+/// value with the specified ValueType. Frame recognizers should return
+/// instances of this class as the returned objects in 
GetRecognizedArguments().
+
+class ValueObjectRecognizerSynthesizedValue : public ValueObject {
+ public:
+  static lldb::ValueObjectSP Create(ValueObject &parent, lldb::ValueType type) 
{
+return (new ValueObjectRecognizerSynthesizedValue(parent, type))->GetSP();
+  }
+  ValueObjectRecognizerSynthesizedValue(ValueObject &parent,
+lldb::ValueType type)
+  : ValueObject(parent), m_type(type) {
+SetName(parent.GetName());
+  }
+
+  uint64_t GetByteSize() override { return m_parent->GetByteSize(); }
+  lldb::ValueType GetValueType() const override { return m_type; }
+  bool UpdateValue() override {
+if (!m_parent->UpdateValueIfNeeded()) return false;
+m_value = m_parent->GetValue();
+return true;
+  }
+  size_t CalculateNumChildren(uint32_t max = UINT32_MAX) override {
+return m_parent->GetNumChildren(max);
+  }
+  CompilerType GetCompilerTypeImpl() override {
+return m_parent->GetCompilerType();
+  }
+  bool IsSynthetic() override { return true; }
+
+ private:
+  lldb::ValueType m_type;
+};
+
 } // namespace lldb_private
 
 #endif // liblldb_StackFrameRecognizer_h_

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/TestFrameRecognizer.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/TestFrameRecognizer.py?rev=353363&r1=353362&r2=353363&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/TestFrameRecognizer.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/TestFrameRecognizer.py
 Wed Feb  6 17:49:10 2019
@@ -89,8 +89,10 @@ class FrameRecognizerTestCase(TestBase):
 self.assertEqual(variables.GetSize(), 2)
 self.assertEqual(variables.GetValueAtIndex(0).name, "a")
 self.assertEqual(variables.GetValueAtIndex(0).signed, 42)
+self.assertEqual(variables.GetValueAtIndex(0).GetValueType(), 
lldb.eValueTypeVariableArgument)
 self.assertEqual(variables.GetValueAtIndex(1).name, "b")
 self.assertEqual(variables.GetValueAtIndex(1).signed, 56)
+self.assertEqual(variables.GetValueAtIndex(1).GetValueType(), 
lldb.eValueTypeVariableArgument)
 
 self.expect("frame recognizer info 0",
 substrs=['frame 0 is recognized by 
recognizer.MyFrameRecognizer'])

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py?rev=353363&r1=353362&r2=353363&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py
 Wed Feb  6 17:49:10 2019
@@ -44,6 +44,7 @@ class ObjCExceptionsTestCase(TestBase):
 
 self.assertEqual(variables.GetSize(), 1)
 self.assertEqual(variables.GetValueAtIndex(0).name, "exception")
+self.assertEqual(variables.GetValueAtIndex(0).GetValu

[Lldb-commits] [PATCH] D56221: [lldb] Make frame recognizers vend synthesized eValueTypeVariableArgument values

2019-02-06 Thread Kuba (Brecka) Mracek via Phabricator via lldb-commits
kubamracek closed this revision.
kubamracek added a comment.

Landed in r353363.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D56221



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