[Lldb-commits] [PATCH] D53785: [FileSystem] Move EnumerateDirectory from FileSpec to FileSystem.

2018-10-30 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D53785



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


[Lldb-commits] [PATCH] D53532: [FileSystem] Extend file system and have it use the VFS.

2018-10-30 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In https://reviews.llvm.org/D53532#1279022, @JDevlieghere wrote:

> Address Pavel's feedback:
>
> - Change to `Initialize` method which can only be called once.


I suppose this is slightly better, but what I meant was to have a `static` 
(like all other functions with the same name) `Initialize` function, which has 
to be called before the first call to `Instance()`. During normal startup, this 
could be called from `SystemInitializer`, but I am not sure how would that work 
for record/replay (that's why I was asking how you planned to initialize 
those). It would require to setup the record/replay machinery very early on, 
which may be tricky. But on the other hand, you probably want to initialize 
these as early as possible anyway.

Do you think something like that would be possible?


https://reviews.llvm.org/D53532



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


[Lldb-commits] [PATCH] D53761: [Target] Do not skip a stop on a breakpoint if a plan was completed

2018-10-30 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov added a comment.

Thank you!


https://reviews.llvm.org/D53761



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


[Lldb-commits] [PATCH] D53435: [x86] Fix issues with a realigned stack in MSVC compiled applications

2018-10-30 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov marked 2 inline comments as done.
aleksandr.urakov added a comment.

Thank you! I'll update the patch.




Comment at: source/Plugins/Process/Utility/RegisterContextLLDB.h:195
 
   // Get the CFA register for a given frame.
+  bool ReadFrameAddress(lldb::RegisterKind register_kind,

jasonmolenda wrote:
> Comment update, e.g. Get the Frame Address register for a given frame.
Yes, thanks for pointing to that!



Comment at: source/Symbol/UnwindPlan.cpp:202
+  m_afa_value.Dump(s, unwind_plan, thread);
+
   s.Printf(" => ");

jasonmolenda wrote:
> What do you think about only printing the AFA= entry if it is != 
> LLDB_INVALID_ADDRESS?
Yes, sure!


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D53435



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


[Lldb-commits] [PATCH] D53435: [x86] Fix issues with a realigned stack in MSVC compiled applications

2018-10-30 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov updated this revision to Diff 171650.
aleksandr.urakov marked 2 inline comments as done.
aleksandr.urakov added a comment.

Update the patch according to comments.


https://reviews.llvm.org/D53435

Files:
  include/lldb/Symbol/UnwindPlan.h
  source/Plugins/Process/Utility/RegisterContextLLDB.cpp
  source/Plugins/Process/Utility/RegisterContextLLDB.h
  source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp
  source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
  source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.h
  source/Symbol/UnwindPlan.cpp
  unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp

Index: unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp
===
--- unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp
+++ unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp
@@ -133,7 +133,7 @@
 
 namespace lldb_private {
 static std::ostream &operator<<(std::ostream &OS,
-const UnwindPlan::Row::CFAValue &CFA) {
+const UnwindPlan::Row::FAValue &CFA) {
   StreamString S;
   CFA.Dump(S, nullptr, nullptr);
   return OS << S.GetData();
@@ -2368,7 +2368,7 @@
   ASSERT_TRUE(engine->GetNonCallSiteUnwindPlanFromAssembly(data, sizeof(data),
sample_range, plan));
 
-  UnwindPlan::Row::CFAValue esp_plus_4, esp_plus_8, ebp_plus_8;
+  UnwindPlan::Row::FAValue esp_plus_4, esp_plus_8, ebp_plus_8;
   esp_plus_4.SetIsRegisterPlusOffset(k_esp, 4);
   esp_plus_8.SetIsRegisterPlusOffset(k_esp, 8);
   ebp_plus_8.SetIsRegisterPlusOffset(k_ebp, 8);
@@ -2402,7 +2402,7 @@
   ASSERT_TRUE(engine->GetNonCallSiteUnwindPlanFromAssembly(data, sizeof(data),
sample_range, plan));
 
-  UnwindPlan::Row::CFAValue rsp_plus_8, rsp_plus_16, rbp_plus_16;
+  UnwindPlan::Row::FAValue rsp_plus_8, rsp_plus_16, rbp_plus_16;
   rsp_plus_8.SetIsRegisterPlusOffset(k_rsp, 8);
   rsp_plus_16.SetIsRegisterPlusOffset(k_rsp, 16);
   rbp_plus_16.SetIsRegisterPlusOffset(k_rbp, 16);
@@ -2416,6 +2416,65 @@
 plan.GetRowForFunctionOffset(sizeof(data) - 1)->GetCFAValue());
 }
 
+TEST_F(Testx86AssemblyInspectionEngine, TestStackRealignMSVC_i386) {
+  std::unique_ptr engine = Geti386Inspector();
+
+  uint8_t data[] = {
+  0x53,   // offset 00 -- pushl %ebx
+  0x8b, 0xdc, // offset 01 -- movl %esp, %ebx
+  0x83, 0xec, 0x08,   // offset 03 -- subl $8, %esp
+  0x81, 0xe4, 0x00, 0xff, 0xff, 0xff, // offset 06 -- andl $-256, %esp
+  0x83, 0xc4, 0x04,   // offset 12 -- addl $4, %esp
+  0x55,   // offset 15 -- pushl %ebp
+  0x8b, 0xec, // offset 16 -- movl %esp, %ebp
+  0x81, 0xec, 0x00, 0x02, 0x00, 0x00, // offset 18 -- subl $512, %esp
+  0x89, 0x7d, 0xfc,   // offset 24 -- movl %edi, -4(%ebp)
+  0x8b, 0xe5, // offset 27 -- movl %ebp, %esp
+  0x5d,   // offset 29 -- popl %ebp
+  0x8b, 0xe3, // offset 30 -- movl %ebx, %esp
+  0x5b,   // offset 32 -- popl %ebx
+  0xc3// offset 33 -- retl
+  };
+
+  AddressRange sample_range(0x1000, sizeof(data));
+  UnwindPlan plan(eRegisterKindLLDB);
+  ASSERT_TRUE(engine->GetNonCallSiteUnwindPlanFromAssembly(data, sizeof(data),
+   sample_range, plan));
+
+  UnwindPlan::Row::FAValue esp_minus_4, esp_plus_0, esp_plus_4, esp_plus_8,
+  ebx_plus_8, ebp_plus_0;
+  esp_minus_4.SetIsRegisterPlusOffset(k_esp, -4);
+  esp_plus_0.SetIsRegisterPlusOffset(k_esp, 0);
+  esp_plus_4.SetIsRegisterPlusOffset(k_esp, 4);
+  esp_plus_8.SetIsRegisterPlusOffset(k_esp, 8);
+  ebx_plus_8.SetIsRegisterPlusOffset(k_ebx, 8);
+  ebp_plus_0.SetIsRegisterPlusOffset(k_ebp, 0);
+
+  // Test CFA
+  EXPECT_EQ(esp_plus_4, plan.GetRowForFunctionOffset(0)->GetCFAValue());
+  EXPECT_EQ(esp_plus_8, plan.GetRowForFunctionOffset(1)->GetCFAValue());
+  for (size_t i = 3; i < 33; ++i)
+EXPECT_EQ(ebx_plus_8, plan.GetRowForFunctionOffset(i)->GetCFAValue())
+<< "i: " << i;
+  EXPECT_EQ(esp_plus_4, plan.GetRowForFunctionOffset(33)->GetCFAValue());
+
+  // Test AFA
+  EXPECT_EQ(esp_plus_0, plan.GetRowForFunctionOffset(12)->GetAFAValue());
+  EXPECT_EQ(esp_minus_4, plan.GetRowForFunctionOffset(15)->GetAFAValue());
+  EXPECT_EQ(esp_plus_0, plan.GetRowForFunctionOffset(16)->GetAFAValue());
+  for (size_t i = 18; i < 30; ++i)
+EXPECT_EQ(ebp_plus_0, plan.GetRowForFunctionOffset(i)->GetAFAValue())
+<< "i: " << i;
+  EXPECT_EQ(esp_minus_4, plan.GetRowForFunctionOffset(30)->GetAFAValue());
+
+  // Test saved register
+  UnwindPlan

[Lldb-commits] [PATCH] D53435: [x86] Fix issues with a realigned stack in MSVC compiled applications

2018-10-30 Thread Aleksandr Urakov via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB345577: [x86] Fix issues with a realigned stack in MSVC 
compiled applications (authored by aleksandr.urakov, committed by ).

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D53435

Files:
  include/lldb/Symbol/UnwindPlan.h
  source/Plugins/Process/Utility/RegisterContextLLDB.cpp
  source/Plugins/Process/Utility/RegisterContextLLDB.h
  source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp
  source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
  source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.h
  source/Symbol/UnwindPlan.cpp
  unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp

Index: unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp
===
--- unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp
+++ unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp
@@ -133,7 +133,7 @@
 
 namespace lldb_private {
 static std::ostream &operator<<(std::ostream &OS,
-const UnwindPlan::Row::CFAValue &CFA) {
+const UnwindPlan::Row::FAValue &CFA) {
   StreamString S;
   CFA.Dump(S, nullptr, nullptr);
   return OS << S.GetData();
@@ -2368,7 +2368,7 @@
   ASSERT_TRUE(engine->GetNonCallSiteUnwindPlanFromAssembly(data, sizeof(data),
sample_range, plan));
 
-  UnwindPlan::Row::CFAValue esp_plus_4, esp_plus_8, ebp_plus_8;
+  UnwindPlan::Row::FAValue esp_plus_4, esp_plus_8, ebp_plus_8;
   esp_plus_4.SetIsRegisterPlusOffset(k_esp, 4);
   esp_plus_8.SetIsRegisterPlusOffset(k_esp, 8);
   ebp_plus_8.SetIsRegisterPlusOffset(k_ebp, 8);
@@ -2402,7 +2402,7 @@
   ASSERT_TRUE(engine->GetNonCallSiteUnwindPlanFromAssembly(data, sizeof(data),
sample_range, plan));
 
-  UnwindPlan::Row::CFAValue rsp_plus_8, rsp_plus_16, rbp_plus_16;
+  UnwindPlan::Row::FAValue rsp_plus_8, rsp_plus_16, rbp_plus_16;
   rsp_plus_8.SetIsRegisterPlusOffset(k_rsp, 8);
   rsp_plus_16.SetIsRegisterPlusOffset(k_rsp, 16);
   rbp_plus_16.SetIsRegisterPlusOffset(k_rbp, 16);
@@ -2416,6 +2416,65 @@
 plan.GetRowForFunctionOffset(sizeof(data) - 1)->GetCFAValue());
 }
 
+TEST_F(Testx86AssemblyInspectionEngine, TestStackRealignMSVC_i386) {
+  std::unique_ptr engine = Geti386Inspector();
+
+  uint8_t data[] = {
+  0x53,   // offset 00 -- pushl %ebx
+  0x8b, 0xdc, // offset 01 -- movl %esp, %ebx
+  0x83, 0xec, 0x08,   // offset 03 -- subl $8, %esp
+  0x81, 0xe4, 0x00, 0xff, 0xff, 0xff, // offset 06 -- andl $-256, %esp
+  0x83, 0xc4, 0x04,   // offset 12 -- addl $4, %esp
+  0x55,   // offset 15 -- pushl %ebp
+  0x8b, 0xec, // offset 16 -- movl %esp, %ebp
+  0x81, 0xec, 0x00, 0x02, 0x00, 0x00, // offset 18 -- subl $512, %esp
+  0x89, 0x7d, 0xfc,   // offset 24 -- movl %edi, -4(%ebp)
+  0x8b, 0xe5, // offset 27 -- movl %ebp, %esp
+  0x5d,   // offset 29 -- popl %ebp
+  0x8b, 0xe3, // offset 30 -- movl %ebx, %esp
+  0x5b,   // offset 32 -- popl %ebx
+  0xc3// offset 33 -- retl
+  };
+
+  AddressRange sample_range(0x1000, sizeof(data));
+  UnwindPlan plan(eRegisterKindLLDB);
+  ASSERT_TRUE(engine->GetNonCallSiteUnwindPlanFromAssembly(data, sizeof(data),
+   sample_range, plan));
+
+  UnwindPlan::Row::FAValue esp_minus_4, esp_plus_0, esp_plus_4, esp_plus_8,
+  ebx_plus_8, ebp_plus_0;
+  esp_minus_4.SetIsRegisterPlusOffset(k_esp, -4);
+  esp_plus_0.SetIsRegisterPlusOffset(k_esp, 0);
+  esp_plus_4.SetIsRegisterPlusOffset(k_esp, 4);
+  esp_plus_8.SetIsRegisterPlusOffset(k_esp, 8);
+  ebx_plus_8.SetIsRegisterPlusOffset(k_ebx, 8);
+  ebp_plus_0.SetIsRegisterPlusOffset(k_ebp, 0);
+
+  // Test CFA
+  EXPECT_EQ(esp_plus_4, plan.GetRowForFunctionOffset(0)->GetCFAValue());
+  EXPECT_EQ(esp_plus_8, plan.GetRowForFunctionOffset(1)->GetCFAValue());
+  for (size_t i = 3; i < 33; ++i)
+EXPECT_EQ(ebx_plus_8, plan.GetRowForFunctionOffset(i)->GetCFAValue())
+<< "i: " << i;
+  EXPECT_EQ(esp_plus_4, plan.GetRowForFunctionOffset(33)->GetCFAValue());
+
+  // Test AFA
+  EXPECT_EQ(esp_plus_0, plan.GetRowForFunctionOffset(12)->GetAFAValue());
+  EXPECT_EQ(esp_minus_4, plan.GetRowForFunctionOffset(15)->GetAFAValue());
+  EXPECT_EQ(esp_plus_0, plan.GetRowForFunctionOffset(16)->GetAFAValue());
+  for (size_t i = 18; i < 30; ++i)
+EXPECT_EQ(ebp_plus_0, plan.GetRowForFunctionOffset(i)->GetAFAValue())
+<< "i: " << i;
+  EXPECT_EQ(esp_minus_4, plan.GetRowForFunctionOff

[Lldb-commits] [lldb] r345577 - [x86] Fix issues with a realigned stack in MSVC compiled applications

2018-10-30 Thread Aleksandr Urakov via lldb-commits
Author: aleksandr.urakov
Date: Tue Oct 30 03:07:08 2018
New Revision: 345577

URL: http://llvm.org/viewvc/llvm-project?rev=345577&view=rev
Log:
[x86] Fix issues with a realigned stack in MSVC compiled applications

Summary:
This patch fixes issues with a stack realignment.

MSVC maintains two frame pointers (`ebx` and `ebp`) for a realigned stack - one
is used for access to function parameters, while another is used for access to
locals. To support this the patch:
- adds an alternative frame pointer (`ebx`);
- considers stack realignment instructions (e.g. `and esp, -32`);
- along with CFA (Canonical Frame Address) which point to the position next to
  the saved return address (or to the first parameter on the stack) introduces
  AFA (Aligned Frame Address) which points to the position of the stack pointer
  right after realignment. AFA is used for access to registers saved after the
  realignment (see the test);

Here is an example of the code with the realignment:
```
struct __declspec(align(256)) OverAligned {
  char c;
};

void foo(int foo_arg) {
  OverAligned oa_foo = { 1 };
  auto aaa_foo = 1234;
}

void bar(int bar_arg) {
  OverAligned oa_bar = { 2 };
  auto aaa_bar = 5678;
  foo();
}

int main() {
  bar();
  return 0;
}
```
and here is the `bar` disassembly:
```
pushebx
mov ebx, esp
sub esp, 8
and esp, -100h
add esp, 4
pushebp
mov ebp, [ebx+4]
mov [esp+4], ebp
mov ebp, esp
sub esp, 200h
mov byte ptr [ebp-200h], 2
mov dword ptr [ebp-4], 5678
push; foo_arg
callj_?foo@@YAXH@Z  ; foo(int)
add esp, 4
mov esp, ebp
pop ebp
mov esp, ebx
pop ebx
retn
```

Reviewers: labath, zturner, jasonmolenda, stella.stamenova

Reviewed By: jasonmolenda

Subscribers: abidh, lldb-commits

Tags: #lldb

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

Modified:
lldb/trunk/include/lldb/Symbol/UnwindPlan.h
lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h
lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp
lldb/trunk/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
lldb/trunk/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.h
lldb/trunk/source/Symbol/UnwindPlan.cpp
lldb/trunk/unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp

Modified: lldb/trunk/include/lldb/Symbol/UnwindPlan.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/UnwindPlan.h?rev=345577&r1=345576&r2=345577&view=diff
==
--- lldb/trunk/include/lldb/Symbol/UnwindPlan.h (original)
+++ lldb/trunk/include/lldb/Symbol/UnwindPlan.h Tue Oct 30 03:07:08 2018
@@ -28,14 +28,22 @@ namespace lldb_private {
 // The UnwindPlan object specifies how to unwind out of a function - where this
 // function saves the caller's register values before modifying them (for non-
 // volatile aka saved registers) and how to find this frame's Canonical Frame
-// Address (CFA).
+// Address (CFA) or Aligned Frame Address (AFA).
 
+// CFA is a DWARF's Canonical Frame Address.
 // Most commonly, registers are saved on the stack, offset some bytes from the
 // Canonical Frame Address, or CFA, which is the starting address of this
 // function's stack frame (the CFA is same as the eh_frame's CFA, whatever that
 // may be on a given architecture). The CFA address for the stack frame does
 // not change during the lifetime of the function.
 
+// AFA is an artificially introduced Aligned Frame Address.
+// It is used only for stack frames with realignment (e.g. when some of the
+// locals has an alignment requirement higher than the stack alignment right
+// after the function call). It is used to access register values saved on the
+// stack after the realignment (and so they are inaccessible through the CFA).
+// AFA usually equals the stack pointer value right after the realignment.
+
 // Internally, the UnwindPlan is structured as a vector of register locations
 // organized by code address in the function, showing which registers have been
 // saved at that point and where they are saved. It can be thought of as the
@@ -61,6 +69,8 @@ public:
 same,  // reg is unchanged
 atCFAPlusOffset,   // reg = deref(CFA + offset)
 isCFAPlusOffset,   // reg = CFA + offset
+atAFAPlusOffset,   // reg = deref(AFA + offset)
+isAFAPlusOffset,   // reg = AFA + offset
 inOtherRegister,   // reg = other reg
 atDWARFExpression, // reg = deref(eval(dwarf_expr))
 isDWARFExpression  // reg = eval(dwarf_expr)
@@ -90,6 +100,10 @@ public:
 
   bool IsAtCFAPlusOffset() const { return m_type == atCFAPlusOffset; }
 
+  bool IsAFAPlusOffset() const { return m_type == isAFAPlusOffset; }
+
+  bool IsAtAFAPlusOffset() const { return m_type == atAFAPlusOffset; }
+
   bo

[Lldb-commits] [PATCH] D53435: [x86] Fix issues with a realigned stack in MSVC compiled applications

2018-10-30 Thread Aleksandr Urakov via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL345577: [x86] Fix issues with a realigned stack in MSVC 
compiled applications (authored by aleksandr.urakov, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D53435?vs=171650&id=171651#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D53435

Files:
  lldb/trunk/include/lldb/Symbol/UnwindPlan.h
  lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
  lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h
  lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp
  lldb/trunk/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
  lldb/trunk/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.h
  lldb/trunk/source/Symbol/UnwindPlan.cpp
  lldb/trunk/unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp

Index: lldb/trunk/unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp
===
--- lldb/trunk/unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp
+++ lldb/trunk/unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp
@@ -133,7 +133,7 @@
 
 namespace lldb_private {
 static std::ostream &operator<<(std::ostream &OS,
-const UnwindPlan::Row::CFAValue &CFA) {
+const UnwindPlan::Row::FAValue &CFA) {
   StreamString S;
   CFA.Dump(S, nullptr, nullptr);
   return OS << S.GetData();
@@ -2368,7 +2368,7 @@
   ASSERT_TRUE(engine->GetNonCallSiteUnwindPlanFromAssembly(data, sizeof(data),
sample_range, plan));
 
-  UnwindPlan::Row::CFAValue esp_plus_4, esp_plus_8, ebp_plus_8;
+  UnwindPlan::Row::FAValue esp_plus_4, esp_plus_8, ebp_plus_8;
   esp_plus_4.SetIsRegisterPlusOffset(k_esp, 4);
   esp_plus_8.SetIsRegisterPlusOffset(k_esp, 8);
   ebp_plus_8.SetIsRegisterPlusOffset(k_ebp, 8);
@@ -2402,7 +2402,7 @@
   ASSERT_TRUE(engine->GetNonCallSiteUnwindPlanFromAssembly(data, sizeof(data),
sample_range, plan));
 
-  UnwindPlan::Row::CFAValue rsp_plus_8, rsp_plus_16, rbp_plus_16;
+  UnwindPlan::Row::FAValue rsp_plus_8, rsp_plus_16, rbp_plus_16;
   rsp_plus_8.SetIsRegisterPlusOffset(k_rsp, 8);
   rsp_plus_16.SetIsRegisterPlusOffset(k_rsp, 16);
   rbp_plus_16.SetIsRegisterPlusOffset(k_rbp, 16);
@@ -2416,6 +2416,65 @@
 plan.GetRowForFunctionOffset(sizeof(data) - 1)->GetCFAValue());
 }
 
+TEST_F(Testx86AssemblyInspectionEngine, TestStackRealignMSVC_i386) {
+  std::unique_ptr engine = Geti386Inspector();
+
+  uint8_t data[] = {
+  0x53,   // offset 00 -- pushl %ebx
+  0x8b, 0xdc, // offset 01 -- movl %esp, %ebx
+  0x83, 0xec, 0x08,   // offset 03 -- subl $8, %esp
+  0x81, 0xe4, 0x00, 0xff, 0xff, 0xff, // offset 06 -- andl $-256, %esp
+  0x83, 0xc4, 0x04,   // offset 12 -- addl $4, %esp
+  0x55,   // offset 15 -- pushl %ebp
+  0x8b, 0xec, // offset 16 -- movl %esp, %ebp
+  0x81, 0xec, 0x00, 0x02, 0x00, 0x00, // offset 18 -- subl $512, %esp
+  0x89, 0x7d, 0xfc,   // offset 24 -- movl %edi, -4(%ebp)
+  0x8b, 0xe5, // offset 27 -- movl %ebp, %esp
+  0x5d,   // offset 29 -- popl %ebp
+  0x8b, 0xe3, // offset 30 -- movl %ebx, %esp
+  0x5b,   // offset 32 -- popl %ebx
+  0xc3// offset 33 -- retl
+  };
+
+  AddressRange sample_range(0x1000, sizeof(data));
+  UnwindPlan plan(eRegisterKindLLDB);
+  ASSERT_TRUE(engine->GetNonCallSiteUnwindPlanFromAssembly(data, sizeof(data),
+   sample_range, plan));
+
+  UnwindPlan::Row::FAValue esp_minus_4, esp_plus_0, esp_plus_4, esp_plus_8,
+  ebx_plus_8, ebp_plus_0;
+  esp_minus_4.SetIsRegisterPlusOffset(k_esp, -4);
+  esp_plus_0.SetIsRegisterPlusOffset(k_esp, 0);
+  esp_plus_4.SetIsRegisterPlusOffset(k_esp, 4);
+  esp_plus_8.SetIsRegisterPlusOffset(k_esp, 8);
+  ebx_plus_8.SetIsRegisterPlusOffset(k_ebx, 8);
+  ebp_plus_0.SetIsRegisterPlusOffset(k_ebp, 0);
+
+  // Test CFA
+  EXPECT_EQ(esp_plus_4, plan.GetRowForFunctionOffset(0)->GetCFAValue());
+  EXPECT_EQ(esp_plus_8, plan.GetRowForFunctionOffset(1)->GetCFAValue());
+  for (size_t i = 3; i < 33; ++i)
+EXPECT_EQ(ebx_plus_8, plan.GetRowForFunctionOffset(i)->GetCFAValue())
+<< "i: " << i;
+  EXPECT_EQ(esp_plus_4, plan.GetRowForFunctionOffset(33)->GetCFAValue());
+
+  // Test AFA
+  EXPECT_EQ(esp_plus_0, plan.GetRowForFunctionOffset(12)->GetAFAValue());
+  EXPECT_EQ(esp_minus_4, plan.GetRowForFunctionOffset(15)->GetAFAValue());
+  EXPECT_EQ(esp_plus

[Lldb-commits] [PATCH] D53822: [NativePDB] Add tests for dumping global variables of class type

2018-10-30 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov accepted this revision.
aleksandr.urakov added a comment.
This revision is now accepted and ready to land.

Looks awesome, thank you!


https://reviews.llvm.org/D53822



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


[Lldb-commits] [PATCH] D53506: [ClangASTContext] Extract VTable pointers from C++ objects

2018-10-30 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov added a comment.

Ping! Can you take a look at this, please?


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D53506



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


[Lldb-commits] [PATCH] D52461: [PDB] Introduce `MSVCUndecoratedNameParser`

2018-10-30 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov updated this revision to Diff 171707.
aleksandr.urakov retitled this revision from "[PDB] Introduce `PDBNameParser`" 
to "[PDB] Introduce `MSVCUndecoratedNameParser`".
aleksandr.urakov edited the summary of this revision.
aleksandr.urakov added a reviewer: shafik.
aleksandr.urakov added a comment.

Update the diff according to the discussion, making it possible to parse MSVC 
demangled names by `CPlusPlusLanguage`. The old PDB plugin still uses 
`MSVCUndecoratedNameParser` directly because:

- we are sure that the name in PDB is an MSVC name;
- it has a more convenient interface, especially for restoring namespaces from 
the parsed name.


https://reviews.llvm.org/D52461

Files:
  lit/SymbolFile/PDB/Inputs/AstRestoreTest.cpp
  lit/SymbolFile/PDB/ast-restore.test
  source/Plugins/Language/CPlusPlus/CMakeLists.txt
  source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  source/Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.cpp
  source/Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.h
  source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
  source/Plugins/SymbolFile/PDB/PDBASTParser.h
  source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
  source/Plugins/SymbolFile/PDB/SymbolFilePDB.h

Index: source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
===
--- source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
+++ source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
@@ -187,7 +187,7 @@
   const llvm::pdb::PDBSymbolCompiland &pdb_compiland,
   llvm::DenseMap &index_map) const;
 
-  void FindTypesByName(const std::string &name,
+  void FindTypesByName(llvm::StringRef name,
const lldb_private::CompilerDeclContext *parent_decl_ctx,
uint32_t max_matches, lldb_private::TypeMap &types);
 
Index: source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
===
--- source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -9,6 +9,9 @@
 
 #include "SymbolFilePDB.h"
 
+#include "PDBASTParser.h"
+#include "PDBLocationToDWARFExpression.h"
+
 #include "clang/Lex/Lexer.h"
 
 #include "lldb/Core/Module.h"
@@ -46,9 +49,8 @@
 #include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h"
 
 #include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h" // For IsCPPMangledName
+#include "Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.h"
 #include "Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h"
-#include "Plugins/SymbolFile/PDB/PDBASTParser.h"
-#include "Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.h"
 
 #include 
 
@@ -1063,7 +1065,7 @@
 lldbassert(sc.module_sp.get());
 
 if (!name.GetStringRef().equals(
-PDBASTParser::PDBNameDropScope(pdb_data->getName(
+MSVCUndecoratedNameParser::DropScope(pdb_data->getName(
   continue;
 
 sc.comp_unit = ParseCompileUnitForUID(GetCompilandId(*pdb_data)).get();
@@ -1170,22 +1172,11 @@
 // Class. We won't bother to check if the parent is UDT or Enum here.
 m_func_method_names.Append(ConstString(name), uid);
 
-ConstString cstr_name(name);
-
 // To search a method name, like NS::Class:MemberFunc, LLDB searches
 // its base name, i.e. MemberFunc by default. Since PDBSymbolFunc does
 // not have inforamtion of this, we extract base names and cache them
 // by our own effort.
-llvm::StringRef basename;
-CPlusPlusLanguage::MethodName cpp_method(cstr_name);
-if (cpp_method.IsValid()) {
-  llvm::StringRef context;
-  basename = cpp_method.GetBasename();
-  if (basename.empty())
-CPlusPlusLanguage::ExtractContextAndIdentifier(name.c_str(),
-   context, basename);
-}
-
+llvm::StringRef basename = MSVCUndecoratedNameParser::DropScope(name);
 if (!basename.empty())
   m_func_base_names.Append(ConstString(basename), uid);
 else {
@@ -1198,11 +1189,12 @@
   } else {
 // Handle not-method symbols.
 
-// The function name might contain namespace, or its lexical scope. It
-// is not safe to get its base name by applying same scheme as we deal
-// with the method names.
-// FIXME: Remove namespace if function is static in a scope.
-m_func_base_names.Append(ConstString(name), uid);
+// The function name might contain namespace, or its lexical scope.
+llvm::StringRef basename = MSVCUndecoratedNameParser::DropScope(name);
+if (!basename.empty())
+  m_func_base_names.Append(ConstString(basename), uid);
+else
+  m_func_base_names.Append(ConstString(name), uid);
 
 if (name == "main") {
   m_func_full_names.Append(ConstString(name), uid);
@@ -1348,10 +1340,8 @@
   searched_symbol_files.clear();
   searched_symbol_files.insert(this);
 
-  std

[Lldb-commits] [PATCH] D53813: [LLDB] - Add support for DW_FORM_addrx[1-4]? forms.

2018-10-30 Thread George Rimar via Phabricator via lldb-commits
grimar added a comment.

I have a patch for `DW_FORM_rnglistx`. Will be happy to land this one first 
though, as they share a code in DWARFUnit.h/cpp a bit.


https://reviews.llvm.org/D53813



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


[Lldb-commits] [PATCH] D52618: [Windows] A basic implementation of memory allocations in a debuggee process

2018-10-30 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Ok, if that's how you guys feel, then I won't stand in your way. I am fine with 
this patch then.


https://reviews.llvm.org/D52618



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


[Lldb-commits] [PATCH] D53506: [ClangASTContext] Extract VTable pointers from C++ objects

2018-10-30 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

Looks fine to me. Make sure no one else has any objections.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D53506



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


[Lldb-commits] [PATCH] D53532: [FileSystem] Extend file system and have it use the VFS.

2018-10-30 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

In https://reviews.llvm.org/D53532#1280018, @labath wrote:

> In https://reviews.llvm.org/D53532#1279022, @JDevlieghere wrote:
>
> > Address Pavel's feedback:
> >
> > - Change to `Initialize` method which can only be called once.
>
>
> I suppose this is slightly better, but what I meant was to have a `static` 
> (like all other functions with the same name) `Initialize` function, which 
> has to be called before the first call to `Instance()`. During normal 
> startup, this could be called from `SystemInitializer`, but I am not sure how 
> would that work for record/replay (that's why I was asking how you planned to 
> initialize those). It would require to setup the record/replay machinery very 
> early on, which may be tricky. But on the other hand, you probably want to 
> initialize these as early as possible anyway.
>
> Do you think something like that would be possible?


Alright, I see what you mean. You know more about the architecture, but it 
looks like we initialize the system before even reading the command line 
arguments in the driver. I have to read the reproducer before I can set the 
appropriate file system, so I'm not sure if this is possible.


https://reviews.llvm.org/D53532



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


[Lldb-commits] [PATCH] D44603: [lldb] Introduce StackFrameRecognizer

2018-10-30 Thread Kuba (Brecka) Mracek via Phabricator via lldb-commits
kubamracek added a comment.

Ping.


https://reviews.llvm.org/D44603



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


[Lldb-commits] [PATCH] D44603: [lldb] Introduce StackFrameRecognizer

2018-10-30 Thread Jim Ingham via Phabricator via lldb-commits
jingham accepted this revision.
jingham added a comment.
This revision is now accepted and ready to land.

LGTM.  Thanks for working on this!


https://reviews.llvm.org/D44603



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


[Lldb-commits] [lldb] r345629 - [NativePDB] Add support for dumping global variables of class type.

2018-10-30 Thread Zachary Turner via lldb-commits
Author: zturner
Date: Tue Oct 30 11:57:08 2018
New Revision: 345629

URL: http://llvm.org/viewvc/llvm-project?rev=345629&view=rev
Log:
[NativePDB] Add support for dumping global variables of class type.

Previous patches added support for dumping global variables of
primitive types, so we now do the same for class types.

For the most part, everything just worked, there was only one
minor bug needing fixed, which was that for variables of modified
types (e.g. const, volatile, etc) we can't resolve the forward
decl in CreateAndCacheType because the PdbSymUid must point to the
LF_MODIFIER which must point to the forward decl.  So when it comes
time to call CompleteType, an assert was firing because we expected
to get a class, struct, union, or enum, but we were getting an
LF_MODIFIER instead.

The other issue is that one the newly added tests is for an array
member, which was not yet supported, so we add support for that
now in this patch.

There's probably room for other interesting layout test cases
here, but this at least should test the basics.

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

Added:
lldb/trunk/lit/SymbolFile/NativePDB/Inputs/globals-classes.lldbinit
lldb/trunk/lit/SymbolFile/NativePDB/global-classes.cpp
Modified:
lldb/trunk/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp
lldb/trunk/source/Plugins/SymbolFile/NativePDB/PdbUtil.h
lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h

Added: lldb/trunk/lit/SymbolFile/NativePDB/Inputs/globals-classes.lldbinit
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/NativePDB/Inputs/globals-classes.lldbinit?rev=345629&view=auto
==
--- lldb/trunk/lit/SymbolFile/NativePDB/Inputs/globals-classes.lldbinit (added)
+++ lldb/trunk/lit/SymbolFile/NativePDB/Inputs/globals-classes.lldbinit Tue Oct 
30 11:57:08 2018
@@ -0,0 +1,14 @@
+settings set auto-one-line-summaries false
+
+target variable -T ClassWithPaddingInstance
+target variable -T ClassNoPaddingInstance
+target variable -T DC
+target variable -T EBOC
+target variable -T PBC
+
+target variable -T UnnamedClassInstance
+
+target variable -T PointersInstance
+target variable -T ReferencesInstance
+
+quit
\ No newline at end of file

Added: lldb/trunk/lit/SymbolFile/NativePDB/global-classes.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/NativePDB/global-classes.cpp?rev=345629&view=auto
==
--- lldb/trunk/lit/SymbolFile/NativePDB/global-classes.cpp (added)
+++ lldb/trunk/lit/SymbolFile/NativePDB/global-classes.cpp Tue Oct 30 11:57:08 
2018
@@ -0,0 +1,275 @@
+// clang-format off
+// REQUIRES: lld
+
+// Test that we can display tag types.
+// RUN: clang-cl /Z7 /GS- /GR- /c -Xclang -fkeep-static-consts /Fo%t.obj -- %s
+// RUN: lld-link /DEBUG /nodefaultlib /entry:main /OUT:%t.exe /PDB:%t.pdb -- 
%t.obj
+// RUN: env LLDB_USE_NATIVE_PDB_READER=1 lldb -f %t.exe -s \
+// RUN: %p/Inputs/globals-classes.lldbinit | FileCheck %s
+
+enum class EnumType : unsigned {
+  A = 1,
+  B = 2
+};
+
+class ClassNoPadding {
+  /* [ 0] */ unsigned char a = 86;
+  /* [ 1] */ char b = 'a';
+  /* [ 2] */ bool c = false;
+  /* [ 3] */ bool d = true;
+  /* [ 4] */ short e = -1234;
+  /* [ 6] */ unsigned short f = 8123;
+  /* [ 8] */ unsigned int g = 123908;
+  /* [12] */ int h = -890234;
+  /* [16] */ unsigned long i = 2908234;
+  /* [20] */ long j = 7234890;
+  /* [24] */ float k = 908234.12392;
+  /* [28] */ EnumType l = EnumType::A;
+  /* [32] */ double m = 23890.897423;
+  /* [40] */ unsigned long long n = 23490782;
+  /* [48] */ long long o = -923409823;
+  /* [56] */ int p[5] = { 2, 3, 5, 8, 13 };
+};
+
+class ClassWithPadding {
+  /* [ 0] */ char a = '0';
+  // char padding[1];
+  /* [ 2] */ short b = 50;
+  /* [ 4] */ char c[2] = { '0', '1' };
+  // char padding[2];
+  /* [ 8] */ int d = 100;
+  /* [12] */ char e = '0';
+  // char padding[3];
+  /* [16] */ int f = 200;
+  // char padding[4];
+  /* [24] */ long long g = 300;
+  /* [32] */ char h[3] = { '0', '1', '2' };
+  // char padding[5];
+  /* [40] */ long long i = 400;
+  /* [48] */ char j[2] = { '0', '1' };
+  // char padding[6];
+  /* [56] */ long long k = 500;
+  /* [64] */ char l = '0';
+  // char padding[7];
+  /* [72] */ long long m = 600;
+} ;
+
+struct EmptyBase {};
+
+template
+struct BaseClass {
+  constexpr BaseClass(int N)
+: BaseMember(N) {}
+
+  int BaseMember;
+};
+
+struct DerivedClass : public BaseClass {
+  constexpr DerivedClass(int Base, int Derived)
+: BaseClass(Base), DerivedMember(Derived) {}
+
+  int DerivedMember;
+};
+
+struct EBO : public EmptyBase {
+  constexpr EBO(int N) : Member(N) {}
+  int Member;
+};
+
+struct PaddedBases : public BaseClass, public BaseClass, 
BaseCl

[Lldb-commits] [PATCH] D53822: [NativePDB] Add tests for dumping global variables of class type

2018-10-30 Thread Zachary Turner via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL345629: [NativePDB] Add support for dumping global variables 
of class type. (authored by zturner, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D53822?vs=171537&id=171755#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D53822

Files:
  lldb/trunk/lit/SymbolFile/NativePDB/Inputs/globals-classes.lldbinit
  lldb/trunk/lit/SymbolFile/NativePDB/global-classes.cpp
  lldb/trunk/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp
  lldb/trunk/source/Plugins/SymbolFile/NativePDB/PdbUtil.h
  lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
  lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h

Index: lldb/trunk/source/Plugins/SymbolFile/NativePDB/PdbUtil.h
===
--- lldb/trunk/source/Plugins/SymbolFile/NativePDB/PdbUtil.h
+++ lldb/trunk/source/Plugins/SymbolFile/NativePDB/PdbUtil.h
@@ -59,6 +59,8 @@
 
 lldb::AccessType TranslateMemberAccess(llvm::codeview::MemberAccess access);
 llvm::codeview::TypeIndex GetFieldListIndex(llvm::codeview::CVType cvt);
+llvm::codeview::TypeIndex
+LookThroughModifierRecord(llvm::codeview::CVType modifier);
 
 llvm::StringRef DropNameScope(llvm::StringRef name);
 
Index: lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
===
--- lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
+++ lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
@@ -170,6 +170,8 @@
  const llvm::codeview::EnumRecord &er);
   lldb::TypeSP CreateTagType(PdbSymUid type_uid,
  const llvm::codeview::UnionRecord &ur);
+  lldb::TypeSP CreateArrayType(PdbSymUid type_uid,
+   const llvm::codeview::ArrayRecord &ar);
   lldb::TypeSP
   CreateClassStructUnion(PdbSymUid type_uid, llvm::StringRef name, size_t size,
  clang::TagTypeKind ttk,
Index: lldb/trunk/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp
@@ -343,6 +343,13 @@
   }
 }
 
+TypeIndex lldb_private::npdb::LookThroughModifierRecord(CVType modifier) {
+  lldbassert(modifier.kind() == LF_MODIFIER);
+  ModifierRecord mr;
+  llvm::cantFail(TypeDeserializer::deserializeAs(modifier, mr));
+  return mr.ModifiedType;
+}
+
 llvm::StringRef lldb_private::npdb::DropNameScope(llvm::StringRef name) {
   // Not all PDB names can be parsed with CPlusPlusNameParser.
   // E.g. it fails on names containing `anonymous namespace'.
Index: lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
@@ -391,9 +391,7 @@
   // If this is an LF_MODIFIER, look through it to get the kind that it
   // modifies.  Note that it's not possible to have an LF_MODIFIER that
   // modifies another LF_MODIFIER, although this would handle that anyway.
-  ModifierRecord mr;
-  llvm::cantFail(TypeDeserializer::deserializeAs(cvt, mr));
-  return GetPdbSymType(tpi, mr.ModifiedType);
+  return GetPdbSymType(tpi, LookThroughModifierRecord(cvt));
 }
 
 static clang::TagTypeKind TranslateUdtKind(const TagRecord &cr) {
@@ -775,6 +773,25 @@
   lldb_private::Type::eResolveStateForward);
 }
 
+TypeSP SymbolFileNativePDB::CreateArrayType(PdbSymUid type_uid,
+const ArrayRecord &ar) {
+  TypeSP element_type = GetOrCreateType(ar.ElementType);
+  uint64_t element_count = ar.Size / element_type->GetByteSize();
+
+  CompilerType element_ct = element_type->GetFullCompilerType();
+
+  CompilerType array_ct =
+  m_clang->CreateArrayType(element_ct, element_count, false);
+
+  Declaration decl;
+  TypeSP array_sp = std::make_shared(
+  type_uid.toOpaqueId(), m_clang->GetSymbolFile(), ConstString(), ar.Size,
+  nullptr, LLDB_INVALID_UID, lldb_private::Type::eEncodingIsUID, decl,
+  array_ct, lldb_private::Type::eResolveStateFull);
+  array_sp->SetEncodingType(element_type.get());
+  return array_sp;
+}
+
 TypeSP SymbolFileNativePDB::CreateType(PdbSymUid type_uid) {
   const PdbTypeSymId &tsid = type_uid.asTypeSym();
   TypeIndex index(tsid.index);
@@ -817,6 +834,12 @@
 return CreateTagType(type_uid, ur);
   }
 
+  if (cvt.kind() == LF_ARRAY) {
+ArrayRecord ar;
+llvm::cantFail(TypeDeserializer::deserializeAs(cvt, ar));
+return CreateArrayType(type_uid, ar);
+  }
+
   return nullptr;
 }
 
@@ -1442,6 +1465,25 @@
   auto types_iter = m_types.find(uid.toOpaqueId())

[Lldb-commits] [PATCH] D53532: [FileSystem] Extend file system and have it use the VFS.

2018-10-30 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In https://reviews.llvm.org/D53532#1280734, @JDevlieghere wrote:

> In https://reviews.llvm.org/D53532#1280018, @labath wrote:
>
> > In https://reviews.llvm.org/D53532#1279022, @JDevlieghere wrote:
> >
> > > Address Pavel's feedback:
> > >
> > > - Change to `Initialize` method which can only be called once.
> >
> >
> > I suppose this is slightly better, but what I meant was to have a `static` 
> > (like all other functions with the same name) `Initialize` function, which 
> > has to be called before the first call to `Instance()`. During normal 
> > startup, this could be called from `SystemInitializer`, but I am not sure 
> > how would that work for record/replay (that's why I was asking how you 
> > planned to initialize those). It would require to setup the record/replay 
> > machinery very early on, which may be tricky. But on the other hand, you 
> > probably want to initialize these as early as possible anyway.
> >
> > Do you think something like that would be possible?
>
>
> Alright, I see what you mean. You know more about the architecture, but it 
> looks like we initialize the system before even reading the command line 
> arguments in the driver. I have to read the reproducer before I can set the 
> appropriate file system, so I'm not sure if this is possible.


Yes, right now it certainly seems to be the case that we parse cmdline late in 
the game. However, it's not clear to me whether that has to be the case.

I can't say I have thought this through to the end, but it seems to me that 
setting up the repro engine should be one of the first (if not THE first) SB 
calls from the driver. Right now the parsing happens too late (e.g. we already 
have an SBDebugger instance created at that point). I am not sure you could 
safely initialize record/replay at that point, even if you got FileSystem 
switching working.

Architecturally, the cleanest solution to me seems to be doing the command line 
parsing (even if it's just the repro-related args) before 
SBDebugger::Initialize, and then have special versions of the `Initialize` 
function like `Initialize(args_for_record)` and `Initialize(args_for_replay)`. 
The interesting repro-related stuff would then happen in these functions, which 
can then call the `Initialize` functions of relevant components (like 
`FileSystem`) and pass appropriate arguments.

However, I can't say how would that fit into your intended design or any code 
you already have implemented.


https://reviews.llvm.org/D53532



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


[Lldb-commits] [PATCH] D53532: [FileSystem] Extend file system and have it use the VFS.

2018-10-30 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

In https://reviews.llvm.org/D53532#1280880, @labath wrote:

> Yes, right now it certainly seems to be the case that we parse cmdline late 
> in the game. However, it's not clear to me whether that has to be the case.
>
> I can't say I have thought this through to the end, but it seems to me that 
> setting up the repro engine should be one of the first (if not THE first) SB 
> calls from the driver. Right now the parsing happens too late (e.g. we 
> already have an SBDebugger instance created at that point). I am not sure you 
> could safely initialize record/replay at that point, even if you got 
> FileSystem switching working.
>
> Architecturally, the cleanest solution to me seems to be doing the command 
> line parsing (even if it's just the repro-related args) before 
> SBDebugger::Initialize, and then have special versions of the `Initialize` 
> function like `Initialize(args_for_record)` and 
> `Initialize(args_for_replay)`. The interesting repro-related stuff would then 
> happen in these functions, which can then call the `Initialize` functions of 
> relevant components (like `FileSystem`) and pass appropriate arguments.
>
> However, I can't say how would that fit into your intended design or any code 
> you already have implemented.


Sounds reasonable. Let's go with the static Initialize approach now and figure 
out the details about initializing the reproducer later.


https://reviews.llvm.org/D53532



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


[Lldb-commits] [lldb] r345668 - [testsuite] Skip an already failing test on MacOS.

2018-10-30 Thread Davide Italiano via lldb-commits
Author: davide
Date: Tue Oct 30 15:49:22 2018
New Revision: 345668

URL: http://llvm.org/viewvc/llvm-project?rev=345668&view=rev
Log:
[testsuite] Skip an already failing test on MacOS.

Due to some libcxx changes to inlining, this now also crashes,
so it gets reported as "failure" by the bot. This commit doesn't
really change the status quo, just placates the bots.

Modified:
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/stl/TestSTL.py

Modified: lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/stl/TestSTL.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/stl/TestSTL.py?rev=345668&r1=345667&r2=345668&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/stl/TestSTL.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/stl/TestSTL.py Tue Oct 
30 15:49:22 2018
@@ -26,6 +26,7 @@ class STLTestCase(TestBase):
 self.line = line_number(
 self.source, '// Set break point at this line.')
 
+@skipIf
 @expectedFailureAll(bugnumber="llvm.org/PR36713")
 def test(self):
 """Test some expressions involving STL data types."""


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


[Lldb-commits] [lldb] r345678 - [lldb] Introduce StackFrameRecognizer

2018-10-30 Thread Kuba Mracek via lldb-commits
Author: kuba.brecka
Date: Tue Oct 30 17:21:03 2018
New Revision: 345678

URL: http://llvm.org/viewvc/llvm-project?rev=345678&view=rev
Log:
[lldb] Introduce StackFrameRecognizer

This patch introduces a concept of "frame recognizer" and "recognized frame". 
This should be an extensible mechanism that retrieves information about special 
frames based on ABI, arguments or other special properties of that frame, even 
without source code. A few examples where that could be useful could be 1) 
objc_exception_throw, where we'd like to get the current exception, 2) 
terminate_with_reason and extracting the current terminate string, 3) 
recognizing Objective-C frames and automatically extracting the 
receiver+selector, or perhaps all arguments (based on selector).

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


Added:
lldb/trunk/include/lldb/Target/StackFrameRecognizer.h
lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/

lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/Makefile

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

lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/main.m

lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/recognizer.py
lldb/trunk/source/Target/StackFrameRecognizer.cpp
Modified:
lldb/trunk/include/lldb/API/SBVariablesOptions.h
lldb/trunk/include/lldb/Interpreter/OptionGroupVariable.h
lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h
lldb/trunk/include/lldb/Target/StackFrame.h
lldb/trunk/include/lldb/lldb-forward.h
lldb/trunk/lldb.xcodeproj/project.pbxproj
lldb/trunk/scripts/Python/python-wrapper.swig
lldb/trunk/scripts/interface/SBVariablesOptions.i
lldb/trunk/source/API/SBFrame.cpp
lldb/trunk/source/API/SBVariablesOptions.cpp
lldb/trunk/source/API/SystemInitializerFull.cpp
lldb/trunk/source/Commands/CommandObjectFrame.cpp
lldb/trunk/source/Interpreter/OptionGroupVariable.cpp

lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
lldb/trunk/source/Target/CMakeLists.txt
lldb/trunk/source/Target/StackFrame.cpp
lldb/trunk/www/python-reference.html

Modified: lldb/trunk/include/lldb/API/SBVariablesOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBVariablesOptions.h?rev=345678&r1=345677&r2=345678&view=diff
==
--- lldb/trunk/include/lldb/API/SBVariablesOptions.h (original)
+++ lldb/trunk/include/lldb/API/SBVariablesOptions.h Tue Oct 30 17:21:03 2018
@@ -33,6 +33,10 @@ public:
 
   void SetIncludeArguments(bool);
 
+  bool GetIncludeRecognizedArguments() const;
+
+  void SetIncludeRecognizedArguments(bool);
+
   bool GetIncludeLocals() const;
 
   void SetIncludeLocals(bool);

Modified: lldb/trunk/include/lldb/Interpreter/OptionGroupVariable.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/OptionGroupVariable.h?rev=345678&r1=345677&r2=345678&view=diff
==
--- lldb/trunk/include/lldb/Interpreter/OptionGroupVariable.h (original)
+++ lldb/trunk/include/lldb/Interpreter/OptionGroupVariable.h Tue Oct 30 
17:21:03 2018
@@ -39,6 +39,8 @@ public:
 
   bool include_frame_options : 1,
   show_args : 1,// Frame option only (include_frame_options == true)
+  show_recognized_args : 1,  // Frame option only (include_frame_options ==
+ // true)
   show_locals : 1,  // Frame option only (include_frame_options == true)
   show_globals : 1, // Frame option only (include_frame_options == true)
   use_regex : 1, show_scope : 1, show_decl : 1;

Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h?rev=345678&r1=345677&r2=345678&view=diff
==
--- lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h (original)
+++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h Tue Oct 30 17:21:03 
2018
@@ -174,6 +174,17 @@ public:
   }
 
   virtual StructuredData::GenericSP
+  CreateFrameRecognizer(const char *class_name) {
+return StructuredData::GenericSP();
+  }
+
+  virtual lldb::ValueObjectListSP GetRecognizedArguments(
+  const StructuredData::ObjectSP &implementor,
+  lldb::StackFrameSP frame_sp) {
+return lldb::ValueObjectListSP();
+  }
+
+  virtual StructuredData::GenericSP
   OSPlugin_CreatePluginObject(const char *class_name,
   lldb::ProcessSP process_sp) {
 return StructuredData::GenericSP();

Modified: lldb/trunk/include/lldb/Target/StackFrame.h
URL: 

[Lldb-commits] [PATCH] D44603: [lldb] Introduce StackFrameRecognizer

2018-10-30 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL345678: [lldb] Introduce StackFrameRecognizer (authored by 
kuba.brecka, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D44603?vs=170809&id=171844#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D44603

Files:
  lldb/trunk/include/lldb/API/SBVariablesOptions.h
  lldb/trunk/include/lldb/Interpreter/OptionGroupVariable.h
  lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h
  lldb/trunk/include/lldb/Target/StackFrame.h
  lldb/trunk/include/lldb/Target/StackFrameRecognizer.h
  lldb/trunk/include/lldb/lldb-forward.h
  lldb/trunk/lldb.xcodeproj/project.pbxproj
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/Makefile
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/TestFrameRecognizer.py
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/main.m
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/recognizer.py
  lldb/trunk/scripts/Python/python-wrapper.swig
  lldb/trunk/scripts/interface/SBVariablesOptions.i
  lldb/trunk/source/API/SBFrame.cpp
  lldb/trunk/source/API/SBVariablesOptions.cpp
  lldb/trunk/source/API/SystemInitializerFull.cpp
  lldb/trunk/source/Commands/CommandObjectFrame.cpp
  lldb/trunk/source/Interpreter/OptionGroupVariable.cpp
  lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
  lldb/trunk/source/Target/CMakeLists.txt
  lldb/trunk/source/Target/StackFrame.cpp
  lldb/trunk/source/Target/StackFrameRecognizer.cpp
  lldb/trunk/www/python-reference.html

Index: lldb/trunk/source/Target/StackFrameRecognizer.cpp
===
--- lldb/trunk/source/Target/StackFrameRecognizer.cpp
+++ lldb/trunk/source/Target/StackFrameRecognizer.cpp
@@ -0,0 +1,190 @@
+//===-- StackFrameRecognizer.cpp *- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+// C Includes
+// C++ Includes
+#include 
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Core/Module.h"
+#include "lldb/Interpreter/ScriptInterpreter.h"
+#include "lldb/Symbol/Symbol.h"
+#include "lldb/Target/StackFrame.h"
+#include "lldb/Target/StackFrameRecognizer.h"
+#include "lldb/Utility/RegularExpression.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+class ScriptedRecognizedStackFrame : public RecognizedStackFrame {
+public:
+  ScriptedRecognizedStackFrame(ValueObjectListSP args) {
+m_arguments = args;
+  }
+};
+
+ScriptedStackFrameRecognizer::ScriptedStackFrameRecognizer(
+ScriptInterpreter *interpreter, const char *pclass)
+: m_interpreter(interpreter), m_python_class(pclass) {
+  m_python_object_sp =
+  m_interpreter->CreateFrameRecognizer(m_python_class.c_str());
+}
+
+RecognizedStackFrameSP
+ScriptedStackFrameRecognizer::RecognizeFrame(lldb::StackFrameSP frame) {
+  if (!m_python_object_sp || !m_interpreter)
+return RecognizedStackFrameSP();
+
+  ValueObjectListSP args =
+  m_interpreter->GetRecognizedArguments(m_python_object_sp, frame);
+
+  return RecognizedStackFrameSP(new ScriptedRecognizedStackFrame(args));
+}
+
+class StackFrameRecognizerManagerImpl {
+public:
+  void AddRecognizer(StackFrameRecognizerSP recognizer, ConstString &module,
+ ConstString &symbol, bool first_instruction_only) {
+m_recognizers.push_front({(uint32_t)m_recognizers.size(), false, recognizer, false, module, RegularExpressionSP(),
+  symbol, RegularExpressionSP(),
+  first_instruction_only});
+  }
+
+  void AddRecognizer(StackFrameRecognizerSP recognizer,
+ RegularExpressionSP module, RegularExpressionSP symbol,
+ bool first_instruction_only) {
+m_recognizers.push_front({(uint32_t)m_recognizers.size(), false, recognizer, true, ConstString(), module,
+  ConstString(), symbol, first_instruction_only});
+  }
+
+  void ForEach(
+  std::function const &callback) {
+for (auto entry : m_recognizers) {
+  if (entry.is_regexp) {
+callback(entry.recognizer_id, entry.recognizer->GetName(), entry.module_regexp->GetText(),
+ entry.symbol_regexp->GetText(), true);
+  } else {
+callback(entry.recognizer_id, entry.recognizer->GetName(), entry.module.GetCString(),
+ entry.symbol.GetCString(), false);
+  }
+}
+  }
+
+  bool RemoveRecognizerWithID(uint32_t recognizer_id) {
+if (recognizer_id >= m_recognizers.size()

[Lldb-commits] [PATCH] D53532: [FileSystem] Extend file system and have it use the VFS.

2018-10-30 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 171845.
JDevlieghere added a comment.

Add static initializers.


https://reviews.llvm.org/D53532

Files:
  include/lldb/Host/FileSystem.h
  include/lldb/Utility/FileSpec.h
  source/Core/Disassembler.cpp
  source/Core/Module.cpp
  source/Core/ModuleList.cpp
  source/Core/SourceManager.cpp
  source/Host/common/FileSystem.cpp
  source/Host/common/HostInfoBase.cpp
  source/Host/common/Symbols.cpp
  source/Host/posix/HostProcessPosix.cpp
  source/Initialization/SystemInitializerCommon.cpp
  source/Interpreter/OptionValueFileSpec.cpp
  source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
  source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
  source/Plugins/Platform/Android/AdbClient.cpp
  source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
  source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
  source/Target/Platform.cpp
  unittests/Host/FileSystemTest.cpp

Index: unittests/Host/FileSystemTest.cpp
===
--- unittests/Host/FileSystemTest.cpp
+++ unittests/Host/FileSystemTest.cpp
@@ -10,10 +10,157 @@
 #include "gtest/gtest.h"
 
 #include "lldb/Host/FileSystem.h"
+#include "llvm/Support/Errc.h"
 
 extern const char *TestMainArgv0;
 
 using namespace lldb_private;
+using namespace llvm;
+using llvm::sys::fs::UniqueID;
+
+// Modified from llvm/unittests/Support/VirtualFileSystemTest.cpp
+namespace {
+struct DummyFile : public vfs::File {
+  vfs::Status S;
+  explicit DummyFile(vfs::Status S) : S(S) {}
+  llvm::ErrorOr status() override { return S; }
+  llvm::ErrorOr>
+  getBuffer(const Twine &Name, int64_t FileSize, bool RequiresNullTerminator,
+bool IsVolatile) override {
+llvm_unreachable("unimplemented");
+  }
+  std::error_code close() override { return std::error_code(); }
+};
+
+class DummyFileSystem : public vfs::FileSystem {
+  int FSID;   // used to produce UniqueIDs
+  int FileID; // used to produce UniqueIDs
+  std::string cwd;
+  std::map FilesAndDirs;
+
+  static int getNextFSID() {
+static int Count = 0;
+return Count++;
+  }
+
+public:
+  DummyFileSystem() : FSID(getNextFSID()), FileID(0) {}
+
+  ErrorOr status(const Twine &Path) override {
+std::map::iterator I =
+FilesAndDirs.find(Path.str());
+if (I == FilesAndDirs.end())
+  return make_error_code(llvm::errc::no_such_file_or_directory);
+return I->second;
+  }
+  ErrorOr>
+  openFileForRead(const Twine &Path) override {
+auto S = status(Path);
+if (S)
+  return std::unique_ptr(new DummyFile{*S});
+return S.getError();
+  }
+  llvm::ErrorOr getCurrentWorkingDirectory() const override {
+return cwd;
+  }
+  std::error_code setCurrentWorkingDirectory(const Twine &Path) override {
+cwd = Path.str();
+return std::error_code();
+  }
+  // Map any symlink to "/symlink".
+  std::error_code getRealPath(const Twine &Path,
+  SmallVectorImpl &Output) const override {
+auto I = FilesAndDirs.find(Path.str());
+if (I == FilesAndDirs.end())
+  return make_error_code(llvm::errc::no_such_file_or_directory);
+if (I->second.isSymlink()) {
+  Output.clear();
+  Twine("/symlink").toVector(Output);
+  return std::error_code();
+}
+Output.clear();
+Path.toVector(Output);
+return std::error_code();
+  }
+
+  struct DirIterImpl : public llvm::vfs::detail::DirIterImpl {
+std::map &FilesAndDirs;
+std::map::iterator I;
+std::string Path;
+bool isInPath(StringRef S) {
+  if (Path.size() < S.size() && S.find(Path) == 0) {
+auto LastSep = S.find_last_of('/');
+if (LastSep == Path.size() || LastSep == Path.size() - 1)
+  return true;
+  }
+  return false;
+}
+DirIterImpl(std::map &FilesAndDirs,
+const Twine &_Path)
+: FilesAndDirs(FilesAndDirs), I(FilesAndDirs.begin()),
+  Path(_Path.str()) {
+  for (; I != FilesAndDirs.end(); ++I) {
+if (isInPath(I->first)) {
+  CurrentEntry =
+  vfs::directory_entry(I->second.getName(), I->second.getType());
+  break;
+}
+  }
+}
+std::error_code increment() override {
+  ++I;
+  for (; I != FilesAndDirs.end(); ++I) {
+if (isInPath(I->first)) {
+  CurrentEntry =
+  vfs::directory_entry(I->second.getName(), I->second.getType());
+  break;
+}
+  }
+  if (I == FilesAndDirs.end())
+CurrentEntry = vfs::directory_entry();
+  return std::error_code();
+}
+  };
+
+  vfs::directory_iterator dir_begin(const Twine &Dir,
+std::error_code &EC) override {
+return vfs::directory_iterator(
+std::make_shared(FilesAndDirs, Dir));
+  }
+
+  void addEntry(StringRef Path, const vfs::

[Lldb-commits] [lldb] r345680 - Revert r345678 (build failure on Linux machines).

2018-10-30 Thread Kuba Mracek via lldb-commits
Author: kuba.brecka
Date: Tue Oct 30 17:29:17 2018
New Revision: 345680

URL: http://llvm.org/viewvc/llvm-project?rev=345680&view=rev
Log:
Revert r345678 (build failure on Linux machines).


Modified:
lldb/trunk/include/lldb/API/SBVariablesOptions.h
lldb/trunk/include/lldb/Interpreter/OptionGroupVariable.h
lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h
lldb/trunk/include/lldb/Target/StackFrame.h
lldb/trunk/include/lldb/Target/StackFrameRecognizer.h
lldb/trunk/include/lldb/lldb-forward.h
lldb/trunk/lldb.xcodeproj/project.pbxproj

lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/Makefile

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

lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/main.m

lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/recognizer.py
lldb/trunk/scripts/Python/python-wrapper.swig
lldb/trunk/scripts/interface/SBVariablesOptions.i
lldb/trunk/source/API/SBFrame.cpp
lldb/trunk/source/API/SBVariablesOptions.cpp
lldb/trunk/source/API/SystemInitializerFull.cpp
lldb/trunk/source/Commands/CommandObjectFrame.cpp
lldb/trunk/source/Interpreter/OptionGroupVariable.cpp

lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
lldb/trunk/source/Target/CMakeLists.txt
lldb/trunk/source/Target/StackFrame.cpp
lldb/trunk/source/Target/StackFrameRecognizer.cpp
lldb/trunk/www/python-reference.html

Modified: lldb/trunk/include/lldb/API/SBVariablesOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBVariablesOptions.h?rev=345680&r1=345679&r2=345680&view=diff
==
--- lldb/trunk/include/lldb/API/SBVariablesOptions.h (original)
+++ lldb/trunk/include/lldb/API/SBVariablesOptions.h Tue Oct 30 17:29:17 2018
@@ -33,10 +33,6 @@ public:
 
   void SetIncludeArguments(bool);
 
-  bool GetIncludeRecognizedArguments() const;
-
-  void SetIncludeRecognizedArguments(bool);
-
   bool GetIncludeLocals() const;
 
   void SetIncludeLocals(bool);

Modified: lldb/trunk/include/lldb/Interpreter/OptionGroupVariable.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/OptionGroupVariable.h?rev=345680&r1=345679&r2=345680&view=diff
==
--- lldb/trunk/include/lldb/Interpreter/OptionGroupVariable.h (original)
+++ lldb/trunk/include/lldb/Interpreter/OptionGroupVariable.h Tue Oct 30 
17:29:17 2018
@@ -39,8 +39,6 @@ public:
 
   bool include_frame_options : 1,
   show_args : 1,// Frame option only (include_frame_options == true)
-  show_recognized_args : 1,  // Frame option only (include_frame_options ==
- // true)
   show_locals : 1,  // Frame option only (include_frame_options == true)
   show_globals : 1, // Frame option only (include_frame_options == true)
   use_regex : 1, show_scope : 1, show_decl : 1;

Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h?rev=345680&r1=345679&r2=345680&view=diff
==
--- lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h (original)
+++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h Tue Oct 30 17:29:17 
2018
@@ -174,17 +174,6 @@ public:
   }
 
   virtual StructuredData::GenericSP
-  CreateFrameRecognizer(const char *class_name) {
-return StructuredData::GenericSP();
-  }
-
-  virtual lldb::ValueObjectListSP GetRecognizedArguments(
-  const StructuredData::ObjectSP &implementor,
-  lldb::StackFrameSP frame_sp) {
-return lldb::ValueObjectListSP();
-  }
-
-  virtual StructuredData::GenericSP
   OSPlugin_CreatePluginObject(const char *class_name,
   lldb::ProcessSP process_sp) {
 return StructuredData::GenericSP();

Modified: lldb/trunk/include/lldb/Target/StackFrame.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/StackFrame.h?rev=345680&r1=345679&r2=345680&view=diff
==
--- lldb/trunk/include/lldb/Target/StackFrame.h (original)
+++ lldb/trunk/include/lldb/Target/StackFrame.h Tue Oct 30 17:29:17 2018
@@ -544,8 +544,6 @@ public:
 
   void CalculateExecutionContext(ExecutionContext &exe_ctx) override;
 
-  lldb::RecognizedStackFrameSP GetRecognizedFrame();
-
 protected:
   friend class StackFrameList;
 
@@ -580,7 +578,6 @@ private:
   ValueObjectList m_variable_list_value_objects; // Value objects for each
  // variable in
  

[Lldb-commits] [lldb] r345686 - [lldb] Introduce StackFrameRecognizer [take 2]

2018-10-30 Thread Kuba Mracek via lldb-commits
Author: kuba.brecka
Date: Tue Oct 30 17:36:20 2018
New Revision: 345686

URL: http://llvm.org/viewvc/llvm-project?rev=345686&view=rev
Log:
[lldb] Introduce StackFrameRecognizer [take 2]

This patch introduces a concept of "frame recognizer" and "recognized frame". 
This should be an extensible mechanism that retrieves information about special 
frames based on ABI, arguments or other special properties of that frame, even 
without source code. A few examples where that could be useful could be 1) 
objc_exception_throw, where we'd like to get the current exception, 2) 
terminate_with_reason and extracting the current terminate string, 3) 
recognizing Objective-C frames and automatically extracting the 
receiver+selector, or perhaps all arguments (based on selector).

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


Modified:
lldb/trunk/include/lldb/API/SBVariablesOptions.h
lldb/trunk/include/lldb/Interpreter/OptionGroupVariable.h
lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h
lldb/trunk/include/lldb/Target/StackFrame.h
lldb/trunk/include/lldb/Target/StackFrameRecognizer.h
lldb/trunk/include/lldb/lldb-forward.h
lldb/trunk/lldb.xcodeproj/project.pbxproj

lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/Makefile

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

lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/main.m

lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/recognizer.py
lldb/trunk/scripts/Python/python-wrapper.swig
lldb/trunk/scripts/interface/SBVariablesOptions.i
lldb/trunk/source/API/SBFrame.cpp
lldb/trunk/source/API/SBVariablesOptions.cpp
lldb/trunk/source/API/SystemInitializerFull.cpp
lldb/trunk/source/Commands/CommandObjectFrame.cpp
lldb/trunk/source/Interpreter/OptionGroupVariable.cpp

lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
lldb/trunk/source/Target/CMakeLists.txt
lldb/trunk/source/Target/StackFrame.cpp
lldb/trunk/source/Target/StackFrameRecognizer.cpp
lldb/trunk/www/python-reference.html

Modified: lldb/trunk/include/lldb/API/SBVariablesOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBVariablesOptions.h?rev=345686&r1=345685&r2=345686&view=diff
==
--- lldb/trunk/include/lldb/API/SBVariablesOptions.h (original)
+++ lldb/trunk/include/lldb/API/SBVariablesOptions.h Tue Oct 30 17:36:20 2018
@@ -33,6 +33,10 @@ public:
 
   void SetIncludeArguments(bool);
 
+  bool GetIncludeRecognizedArguments() const;
+
+  void SetIncludeRecognizedArguments(bool);
+
   bool GetIncludeLocals() const;
 
   void SetIncludeLocals(bool);

Modified: lldb/trunk/include/lldb/Interpreter/OptionGroupVariable.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/OptionGroupVariable.h?rev=345686&r1=345685&r2=345686&view=diff
==
--- lldb/trunk/include/lldb/Interpreter/OptionGroupVariable.h (original)
+++ lldb/trunk/include/lldb/Interpreter/OptionGroupVariable.h Tue Oct 30 
17:36:20 2018
@@ -39,6 +39,8 @@ public:
 
   bool include_frame_options : 1,
   show_args : 1,// Frame option only (include_frame_options == true)
+  show_recognized_args : 1,  // Frame option only (include_frame_options ==
+ // true)
   show_locals : 1,  // Frame option only (include_frame_options == true)
   show_globals : 1, // Frame option only (include_frame_options == true)
   use_regex : 1, show_scope : 1, show_decl : 1;

Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h?rev=345686&r1=345685&r2=345686&view=diff
==
--- lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h (original)
+++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h Tue Oct 30 17:36:20 
2018
@@ -174,6 +174,17 @@ public:
   }
 
   virtual StructuredData::GenericSP
+  CreateFrameRecognizer(const char *class_name) {
+return StructuredData::GenericSP();
+  }
+
+  virtual lldb::ValueObjectListSP GetRecognizedArguments(
+  const StructuredData::ObjectSP &implementor,
+  lldb::StackFrameSP frame_sp) {
+return lldb::ValueObjectListSP();
+  }
+
+  virtual StructuredData::GenericSP
   OSPlugin_CreatePluginObject(const char *class_name,
   lldb::ProcessSP process_sp) {
 return StructuredData::GenericSP();

Modified: lldb/trunk/include/lldb/Target/StackFrame.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/StackFrame.

[Lldb-commits] [PATCH] D44603: [lldb] Introduce StackFrameRecognizer

2018-10-30 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB345686: [lldb] Introduce StackFrameRecognizer [take 2] 
(authored by kuba.brecka, committed by ).
Herald added subscribers: teemperor, abidh.

Changed prior to commit:
  https://reviews.llvm.org/D44603?vs=171844&id=171848#toc

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D44603

Files:
  include/lldb/API/SBVariablesOptions.h
  include/lldb/Interpreter/OptionGroupVariable.h
  include/lldb/Interpreter/ScriptInterpreter.h
  include/lldb/Target/StackFrame.h
  include/lldb/Target/StackFrameRecognizer.h
  include/lldb/lldb-forward.h
  lldb.xcodeproj/project.pbxproj
  packages/Python/lldbsuite/test/functionalities/frame-recognizer/Makefile
  
packages/Python/lldbsuite/test/functionalities/frame-recognizer/TestFrameRecognizer.py
  packages/Python/lldbsuite/test/functionalities/frame-recognizer/main.m
  packages/Python/lldbsuite/test/functionalities/frame-recognizer/recognizer.py
  scripts/Python/python-wrapper.swig
  scripts/interface/SBVariablesOptions.i
  source/API/SBFrame.cpp
  source/API/SBVariablesOptions.cpp
  source/API/SystemInitializerFull.cpp
  source/Commands/CommandObjectFrame.cpp
  source/Interpreter/OptionGroupVariable.cpp
  source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
  source/Target/CMakeLists.txt
  source/Target/StackFrame.cpp
  source/Target/StackFrameRecognizer.cpp
  www/python-reference.html

Index: source/Target/StackFrame.cpp
===
--- source/Target/StackFrame.cpp
+++ source/Target/StackFrame.cpp
@@ -31,6 +31,7 @@
 #include "lldb/Target/ExecutionContext.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/RegisterContext.h"
+#include "lldb/Target/StackFrameRecognizer.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Target/Thread.h"
 #include "lldb/Utility/RegisterValue.h"
@@ -58,7 +59,8 @@
   m_id(pc, cfa, nullptr), m_frame_code_addr(pc), m_sc(), m_flags(),
   m_frame_base(), m_frame_base_error(), m_cfa_is_valid(cfa_is_valid),
   m_stack_frame_kind(kind), m_variable_list_sp(),
-  m_variable_list_value_objects(), m_disassembly(), m_mutex() {
+  m_variable_list_value_objects(), m_recognized_frame_sp(), m_disassembly(),
+  m_mutex() {
   // If we don't have a CFA value, use the frame index for our StackID so that
   // recursive functions properly aren't confused with one another on a history
   // stack.
@@ -82,7 +84,8 @@
   m_frame_code_addr(pc), m_sc(), m_flags(), m_frame_base(),
   m_frame_base_error(), m_cfa_is_valid(true),
   m_stack_frame_kind(StackFrame::Kind::Regular), m_variable_list_sp(),
-  m_variable_list_value_objects(), m_disassembly(), m_mutex() {
+  m_variable_list_value_objects(), m_recognized_frame_sp(), m_disassembly(),
+  m_mutex() {
   if (sc_ptr != nullptr) {
 m_sc = *sc_ptr;
 m_flags.Set(m_sc.GetResolvedMask());
@@ -107,7 +110,8 @@
   m_frame_code_addr(pc_addr), m_sc(), m_flags(), m_frame_base(),
   m_frame_base_error(), m_cfa_is_valid(true),
   m_stack_frame_kind(StackFrame::Kind::Regular), m_variable_list_sp(),
-  m_variable_list_value_objects(), m_disassembly(), m_mutex() {
+  m_variable_list_value_objects(), m_recognized_frame_sp(), m_disassembly(),
+  m_mutex() {
   if (sc_ptr != nullptr) {
 m_sc = *sc_ptr;
 m_flags.Set(m_sc.GetResolvedMask());
@@ -1952,3 +1956,11 @@
   }
   return true;
 }
+
+RecognizedStackFrameSP StackFrame::GetRecognizedFrame() {
+  if (!m_recognized_frame_sp) {
+m_recognized_frame_sp =
+StackFrameRecognizerManager::RecognizeFrame(CalculateStackFrame());
+  }
+  return m_recognized_frame_sp;
+}
Index: source/Target/StackFrameRecognizer.cpp
===
--- source/Target/StackFrameRecognizer.cpp
+++ source/Target/StackFrameRecognizer.cpp
@@ -0,0 +1,190 @@
+//===-- StackFrameRecognizer.cpp *- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+// C Includes
+// C++ Includes
+#include 
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Core/Module.h"
+#include "lldb/Interpreter/ScriptInterpreter.h"
+#include "lldb/Symbol/Symbol.h"
+#include "lldb/Target/StackFrame.h"
+#include "lldb/Target/StackFrameRecognizer.h"
+#include "lldb/Utility/RegularExpression.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+class ScriptedRecognizedStackFrame : public RecognizedStackFrame {
+public:
+  ScriptedRecognizedStackFrame(ValueObjectListSP args) {
+m_arguments = args;
+  }
+};
+
+ScriptedStackFrameRecognizer::ScriptedStackFrameRecognizer(
+Scr

[Lldb-commits] [PATCH] D53917: [lldb] Fix race condition in framework installation

2018-10-30 Thread Shoaib Meenai via Phabricator via lldb-commits
smeenai created this revision.
smeenai added a reviewer: xiaobai.
Herald added a subscriber: mgorny.

We need the install-liblldb-stripped target to also depend on the
llvm-framework target in order for the installation to be guaranteed to
behave as intended. I believe this is simply a typo.


https://reviews.llvm.org/D53917

Files:
  cmake/modules/AddLLDB.cmake


Index: cmake/modules/AddLLDB.cmake
===
--- cmake/modules/AddLLDB.cmake
+++ cmake/modules/AddLLDB.cmake
@@ -79,7 +79,7 @@
 # framework, so it must rely on the framework being fully built first.
 if (LLDB_BUILD_FRAMEWORK AND ${name} STREQUAL "liblldb")
   add_dependencies(install-${name} lldb-framework)
-  add_dependencies(install-lldb-framework-stripped lldb-framework)
+  add_dependencies(install-${name}-stripped lldb-framework)
 endif()
   endif()
 endif()


Index: cmake/modules/AddLLDB.cmake
===
--- cmake/modules/AddLLDB.cmake
+++ cmake/modules/AddLLDB.cmake
@@ -79,7 +79,7 @@
 # framework, so it must rely on the framework being fully built first.
 if (LLDB_BUILD_FRAMEWORK AND ${name} STREQUAL "liblldb")
   add_dependencies(install-${name} lldb-framework)
-  add_dependencies(install-lldb-framework-stripped lldb-framework)
+  add_dependencies(install-${name}-stripped lldb-framework)
 endif()
   endif()
 endif()
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r345688 - Revert r345686 due to build failures

2018-10-30 Thread Kuba Mracek via lldb-commits
Author: kuba.brecka
Date: Tue Oct 30 18:22:48 2018
New Revision: 345688

URL: http://llvm.org/viewvc/llvm-project?rev=345688&view=rev
Log:
Revert r345686 due to build failures

Removed:
lldb/trunk/include/lldb/Target/StackFrameRecognizer.h
lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/
lldb/trunk/source/Target/StackFrameRecognizer.cpp
Modified:
lldb/trunk/include/lldb/API/SBVariablesOptions.h
lldb/trunk/include/lldb/Interpreter/OptionGroupVariable.h
lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h
lldb/trunk/include/lldb/Target/StackFrame.h
lldb/trunk/include/lldb/lldb-forward.h
lldb/trunk/lldb.xcodeproj/project.pbxproj
lldb/trunk/scripts/Python/python-wrapper.swig
lldb/trunk/scripts/interface/SBVariablesOptions.i
lldb/trunk/source/API/SBFrame.cpp
lldb/trunk/source/API/SBVariablesOptions.cpp
lldb/trunk/source/API/SystemInitializerFull.cpp
lldb/trunk/source/Commands/CommandObjectFrame.cpp
lldb/trunk/source/Interpreter/OptionGroupVariable.cpp

lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
lldb/trunk/source/Target/CMakeLists.txt
lldb/trunk/source/Target/StackFrame.cpp
lldb/trunk/www/python-reference.html

Modified: lldb/trunk/include/lldb/API/SBVariablesOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBVariablesOptions.h?rev=345688&r1=345687&r2=345688&view=diff
==
--- lldb/trunk/include/lldb/API/SBVariablesOptions.h (original)
+++ lldb/trunk/include/lldb/API/SBVariablesOptions.h Tue Oct 30 18:22:48 2018
@@ -33,10 +33,6 @@ public:
 
   void SetIncludeArguments(bool);
 
-  bool GetIncludeRecognizedArguments() const;
-
-  void SetIncludeRecognizedArguments(bool);
-
   bool GetIncludeLocals() const;
 
   void SetIncludeLocals(bool);

Modified: lldb/trunk/include/lldb/Interpreter/OptionGroupVariable.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/OptionGroupVariable.h?rev=345688&r1=345687&r2=345688&view=diff
==
--- lldb/trunk/include/lldb/Interpreter/OptionGroupVariable.h (original)
+++ lldb/trunk/include/lldb/Interpreter/OptionGroupVariable.h Tue Oct 30 
18:22:48 2018
@@ -39,8 +39,6 @@ public:
 
   bool include_frame_options : 1,
   show_args : 1,// Frame option only (include_frame_options == true)
-  show_recognized_args : 1,  // Frame option only (include_frame_options ==
- // true)
   show_locals : 1,  // Frame option only (include_frame_options == true)
   show_globals : 1, // Frame option only (include_frame_options == true)
   use_regex : 1, show_scope : 1, show_decl : 1;

Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h?rev=345688&r1=345687&r2=345688&view=diff
==
--- lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h (original)
+++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h Tue Oct 30 18:22:48 
2018
@@ -174,17 +174,6 @@ public:
   }
 
   virtual StructuredData::GenericSP
-  CreateFrameRecognizer(const char *class_name) {
-return StructuredData::GenericSP();
-  }
-
-  virtual lldb::ValueObjectListSP GetRecognizedArguments(
-  const StructuredData::ObjectSP &implementor,
-  lldb::StackFrameSP frame_sp) {
-return lldb::ValueObjectListSP();
-  }
-
-  virtual StructuredData::GenericSP
   OSPlugin_CreatePluginObject(const char *class_name,
   lldb::ProcessSP process_sp) {
 return StructuredData::GenericSP();

Modified: lldb/trunk/include/lldb/Target/StackFrame.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/StackFrame.h?rev=345688&r1=345687&r2=345688&view=diff
==
--- lldb/trunk/include/lldb/Target/StackFrame.h (original)
+++ lldb/trunk/include/lldb/Target/StackFrame.h Tue Oct 30 18:22:48 2018
@@ -544,8 +544,6 @@ public:
 
   void CalculateExecutionContext(ExecutionContext &exe_ctx) override;
 
-  lldb::RecognizedStackFrameSP GetRecognizedFrame();
-
 protected:
   friend class StackFrameList;
 
@@ -580,7 +578,6 @@ private:
   ValueObjectList m_variable_list_value_objects; // Value objects for each
  // variable in
  // m_variable_list_sp
-  lldb::RecognizedStackFrameSP m_recognized_frame_sp;
   StreamString m_disassembly;
   std::recursive_mutex m_mutex;
 

Removed: lldb/trunk/include/lldb/Target/StackFrameRecognizer.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/in

[Lldb-commits] [PATCH] D53917: [lldb] Fix race condition in framework installation

2018-10-30 Thread Alex Langford via Phabricator via lldb-commits
xiaobai accepted this revision.
xiaobai added a comment.
This revision is now accepted and ready to land.

Good catch! Thank you so much.


https://reviews.llvm.org/D53917



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


[Lldb-commits] [PATCH] D52461: [PDB] Introduce `MSVCUndecoratedNameParser`

2018-10-30 Thread Zachary Turner via Phabricator via lldb-commits
zturner added a comment.

In https://reviews.llvm.org/D52461#1280527, @aleksandr.urakov wrote:

> Update the diff according to the discussion, making it possible to parse MSVC 
> demangled names by `CPlusPlusLanguage`. The old PDB plugin still uses 
> `MSVCUndecoratedNameParser` directly because:
>
> - we are sure that the name in PDB is an MSVC name;
> - it has a more convenient interface, especially for restoring namespaces 
> from the parsed name.


So I had an interesting solution to this while working on the native pdb 
plugin.  it is impossible to use it with the old pdb plugin, but given that it 
works flawlessly for the native pdb plugin, depending on how urgent your need 
is, maybe you can just put off working on this until you're ready to move over 
to the native pdb plugin?

Basically the idea is that the raw PDB contains mangled type names for every 
type.  You can see this by dumping types using `llvm-pdbutil`, as follows (I 
just picked a random one from my build directory).

  D:\src\llvmbuild\ninja-x64>bin\llvm-pdbutil.exe dump -types bin\sancov.pdb | 
grep -A 2 LF_STRUCT | more
  0x1001 | LF_STRUCTURE [size = 88] ``anonymous-namespace'::RawCoverage`
   unique name: `.?AURawCoverage@?A0xa74cdb40@@`
   vtable: , base list: , field list: 
  --
  0x100A | LF_STRUCTURE [size = 212] `std::default_delete,std::allocator > >`
   unique name: 
`.?AU?$default_delete@V?$set@_KU?$less@_K@std@@V?$allocator@_K@2@@std@@@std@@`
   vtable: , base list: , field list: 
  --
  0x102B | LF_STRUCTURE [size = 88] ``anonymous-namespace'::FileHeader`
   unique name: `.?AUFileHeader@?A0xa74cdb40@@`
   vtable: , base list: , field list: 
  --
  0x1031 | LF_STRUCTURE [size = 112] 
`std::default_delete`
   unique name: `.?AU?$default_delete@VMemoryBuffer@llvm@@@std@@`
   vtable: , base list: , field list: 
  --
  0x1081 | LF_STRUCTURE [size = 304] 
`llvm::AlignedCharArrayUnion
 >,char,char,char,char,char,char,char,char,char>`
   unique name: 
`.?AU?$AlignedCharArrayUnion@V?$unique_ptr@VMemoryBuffer@llvm@@U?$default_delete@VMemoryBuffer@llvm@@@std@@@std@@D@llvm@@`
   vtable: , base list: , field list: 
  --
  0x1082 | LF_STRUCTURE [size = 176] 
`llvm::AlignedCharArrayUnion`
   unique name: 
`.?AU?$AlignedCharArrayUnion@Verror_code@std@@D@llvm@@`
   vtable: , base list: , field list: 

So the interesting thing here is this "unique name" field.  This is not 
possible to access via DIA SDK but it gives us complete rich information about 
the type that is otherwise impossible.  We don't even have to guess, because we 
can just demangle the name.  And coincidentally, I recently just finished 
writing an Microsoft ABI demangler which is now in LLVM.  :)   This `.?AU` 
syntax is non-standard, but it was easy for me to figure out, and I hacked up 
our demangle library to support this prefix (it's not checked in yet).  And 
basically everything that comes after it exactly matches a mangled type.

So, just to give an example.  Instead of teaching `CPlusPlusNameParser` to 
handle ``anonymous namespace'::RawCoverage`, we simply demangle 
`.?AURawCoverage@?A0xa74cdb40@@`, and we get back a vector of 2 strings which 
are ``anonymous namespace'` and `RawCoverage`.  But instead of just that, there 
are so many other benefits.  Since PDB doesn't contain rich information about 
template parameters, all we could do until now is just say create an entry in 
the AST that says "there's a type with this enormously long name that contains 
angle brackets and other junk".  But with this technique, we could actually 
create legitimate template decls in the AST the way it's supposed to be.

There is obviously a lot of complexity in doing it here, but I think long term 
it will be a richer experience if we parse the mangled name than if we parse 
the demangled name.  But it's only possible with the native plugin.

What do you think?


https://reviews.llvm.org/D52461



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


[Lldb-commits] [lldb] r345693 - [lldb] Introduce StackFrameRecognizer [take 3]

2018-10-30 Thread Kuba Mracek via lldb-commits
Author: kuba.brecka
Date: Tue Oct 30 21:00:22 2018
New Revision: 345693

URL: http://llvm.org/viewvc/llvm-project?rev=345693&view=rev
Log:
[lldb] Introduce StackFrameRecognizer [take 3]

This patch introduces a concept of "frame recognizer" and "recognized frame". 
This should be an extensible mechanism that retrieves information about special 
frames based on ABI, arguments or other special properties of that frame, even 
without source code. A few examples where that could be useful could be 1) 
objc_exception_throw, where we'd like to get the current exception, 2) 
terminate_with_reason and extracting the current terminate string, 3) 
recognizing Objective-C frames and automatically extracting the 
receiver+selector, or perhaps all arguments (based on selector).

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


Added:
lldb/trunk/include/lldb/Target/StackFrameRecognizer.h
lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/

lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/Makefile

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

lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/main.m

lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/recognizer.py
lldb/trunk/source/Target/StackFrameRecognizer.cpp
Modified:
lldb/trunk/include/lldb/API/SBVariablesOptions.h
lldb/trunk/include/lldb/Interpreter/OptionGroupVariable.h
lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h
lldb/trunk/include/lldb/Target/StackFrame.h
lldb/trunk/include/lldb/lldb-forward.h
lldb/trunk/lldb.xcodeproj/project.pbxproj
lldb/trunk/scripts/Python/python-wrapper.swig
lldb/trunk/scripts/interface/SBVariablesOptions.i
lldb/trunk/source/API/SBFrame.cpp
lldb/trunk/source/API/SBVariablesOptions.cpp
lldb/trunk/source/API/SystemInitializerFull.cpp
lldb/trunk/source/Commands/CommandObjectFrame.cpp
lldb/trunk/source/Interpreter/OptionGroupVariable.cpp

lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
lldb/trunk/source/Target/CMakeLists.txt
lldb/trunk/source/Target/StackFrame.cpp
lldb/trunk/www/python-reference.html

Modified: lldb/trunk/include/lldb/API/SBVariablesOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBVariablesOptions.h?rev=345693&r1=345692&r2=345693&view=diff
==
--- lldb/trunk/include/lldb/API/SBVariablesOptions.h (original)
+++ lldb/trunk/include/lldb/API/SBVariablesOptions.h Tue Oct 30 21:00:22 2018
@@ -33,6 +33,10 @@ public:
 
   void SetIncludeArguments(bool);
 
+  bool GetIncludeRecognizedArguments() const;
+
+  void SetIncludeRecognizedArguments(bool);
+
   bool GetIncludeLocals() const;
 
   void SetIncludeLocals(bool);

Modified: lldb/trunk/include/lldb/Interpreter/OptionGroupVariable.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/OptionGroupVariable.h?rev=345693&r1=345692&r2=345693&view=diff
==
--- lldb/trunk/include/lldb/Interpreter/OptionGroupVariable.h (original)
+++ lldb/trunk/include/lldb/Interpreter/OptionGroupVariable.h Tue Oct 30 
21:00:22 2018
@@ -39,6 +39,8 @@ public:
 
   bool include_frame_options : 1,
   show_args : 1,// Frame option only (include_frame_options == true)
+  show_recognized_args : 1,  // Frame option only (include_frame_options ==
+ // true)
   show_locals : 1,  // Frame option only (include_frame_options == true)
   show_globals : 1, // Frame option only (include_frame_options == true)
   use_regex : 1, show_scope : 1, show_decl : 1;

Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h?rev=345693&r1=345692&r2=345693&view=diff
==
--- lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h (original)
+++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h Tue Oct 30 21:00:22 
2018
@@ -174,6 +174,17 @@ public:
   }
 
   virtual StructuredData::GenericSP
+  CreateFrameRecognizer(const char *class_name) {
+return StructuredData::GenericSP();
+  }
+
+  virtual lldb::ValueObjectListSP GetRecognizedArguments(
+  const StructuredData::ObjectSP &implementor,
+  lldb::StackFrameSP frame_sp) {
+return lldb::ValueObjectListSP();
+  }
+
+  virtual StructuredData::GenericSP
   OSPlugin_CreatePluginObject(const char *class_name,
   lldb::ProcessSP process_sp) {
 return StructuredData::GenericSP();

Modified: lldb/trunk/include/lldb/Target/StackFrame

[Lldb-commits] [PATCH] D44603: [lldb] Introduce StackFrameRecognizer

2018-10-30 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL345693: [lldb] Introduce StackFrameRecognizer [take 3] 
(authored by kuba.brecka, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D44603?vs=171848&id=171860#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D44603

Files:
  lldb/trunk/include/lldb/API/SBVariablesOptions.h
  lldb/trunk/include/lldb/Interpreter/OptionGroupVariable.h
  lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h
  lldb/trunk/include/lldb/Target/StackFrame.h
  lldb/trunk/include/lldb/Target/StackFrameRecognizer.h
  lldb/trunk/include/lldb/lldb-forward.h
  lldb/trunk/lldb.xcodeproj/project.pbxproj
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/Makefile
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/TestFrameRecognizer.py
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/main.m
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/recognizer.py
  lldb/trunk/scripts/Python/python-wrapper.swig
  lldb/trunk/scripts/interface/SBVariablesOptions.i
  lldb/trunk/source/API/SBFrame.cpp
  lldb/trunk/source/API/SBVariablesOptions.cpp
  lldb/trunk/source/API/SystemInitializerFull.cpp
  lldb/trunk/source/Commands/CommandObjectFrame.cpp
  lldb/trunk/source/Interpreter/OptionGroupVariable.cpp
  lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
  lldb/trunk/source/Target/CMakeLists.txt
  lldb/trunk/source/Target/StackFrame.cpp
  lldb/trunk/source/Target/StackFrameRecognizer.cpp
  lldb/trunk/www/python-reference.html

Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/recognizer.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/recognizer.py
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/recognizer.py
@@ -0,0 +1,21 @@
+# encoding: utf-8
+
+import lldb
+
+class MyFrameRecognizer(object):
+def get_recognized_arguments(self, frame):
+if frame.name == "foo":
+arg1 = frame.EvaluateExpression("$arg1").signed
+arg2 = frame.EvaluateExpression("$arg2").signed
+val1 = lldb.target.CreateValueFromExpression("a", "%d" % arg1)
+val2 = lldb.target.CreateValueFromExpression("b", "%d" % arg2)
+return [val1, val2]
+elif frame.name == "bar":
+arg1 = frame.EvaluateExpression("$arg1").signed
+val1 = lldb.target.CreateValueFromExpression("a", "(int *)%d" % arg1)
+return [val1]
+return []
+
+class MyOtherFrameRecognizer(object):
+def get_recognized_arguments(self, frame):
+return []
Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/Makefile
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/Makefile
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/Makefile
@@ -0,0 +1,10 @@
+LEVEL = ../../make
+
+OBJC_SOURCES := main.m
+
+CFLAGS_EXTRAS += -g0 # No debug info.
+MAKE_DSYM := NO
+
+include $(LEVEL)/Makefile.rules
+
+LDFLAGS += -framework Foundation
Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/TestFrameRecognizer.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/TestFrameRecognizer.py
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/TestFrameRecognizer.py
@@ -0,0 +1,102 @@
+# encoding: utf-8
+"""
+Test lldb's frame recognizers.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+import recognizer
+
+class FrameRecognizerTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+NO_DEBUG_INFO_TESTCASE = True
+
+@skipUnlessDarwin
+def test_frame_recognizer_1(self):
+self.build()
+
+target = self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+self.assertTrue(target, VALID_TARGET)
+
+self.runCmd("command script import " + os.path.join(self.getSourceDir(), "recognizer.py"))
+
+self.expect("frame recognizer list",
+substrs=['no matching results found.'])
+
+self.runCmd("frame recognizer add -l recognizer.MyFrameRecognizer -s a.out -n foo")
+
+self.expect("frame recognizer list",
+substrs=['0: recognizer.MyFrameRecognizer, module a.out, function foo'])
+
+self.runCmd("frame recognizer add -l recognizer.MyOtherFrameRecognizer -s a.out -n bar -x")
+
+self.expect("frame recognizer list",
+substrs=['0: 

[Lldb-commits] [lldb] r345694 - Fixup the Python-less build of ScriptedRecognizedStackFrame

2018-10-30 Thread Kuba Mracek via lldb-commits
Author: kuba.brecka
Date: Tue Oct 30 21:43:09 2018
New Revision: 345694

URL: http://llvm.org/viewvc/llvm-project?rev=345694&view=rev
Log:
Fixup the Python-less build of ScriptedRecognizedStackFrame

Modified:
lldb/trunk/source/Commands/CommandObjectFrame.cpp
lldb/trunk/source/Target/StackFrameRecognizer.cpp

Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=345694&r1=345693&r2=345694&view=diff
==
--- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Tue Oct 30 21:43:09 2018
@@ -883,6 +883,7 @@ Process 1234 stopped
 
 bool CommandObjectFrameRecognizerAdd::DoExecute(Args &command,
 CommandReturnObject &result) {
+#ifndef LLDB_DISABLE_PYTHON
   if (m_options.m_class_name.empty()) {
 result.AppendErrorWithFormat(
 "%s needs a Python class name (-l argument).\n", m_cmd_name.c_str());
@@ -927,6 +928,7 @@ bool CommandObjectFrameRecognizerAdd::Do
 auto func = ConstString(m_options.m_function);
 StackFrameRecognizerManager::AddRecognizer(recognizer_sp, module, func);
   }
+#endif
 
   result.SetStatus(eReturnStatusSuccessFinishNoResult);
   return result.Succeeded();

Modified: lldb/trunk/source/Target/StackFrameRecognizer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrameRecognizer.cpp?rev=345694&r1=345693&r2=345694&view=diff
==
--- lldb/trunk/source/Target/StackFrameRecognizer.cpp (original)
+++ lldb/trunk/source/Target/StackFrameRecognizer.cpp Tue Oct 30 21:43:09 2018
@@ -22,6 +22,8 @@
 using namespace lldb;
 using namespace lldb_private;
 
+#ifndef LLDB_DISABLE_PYTHON
+
 class ScriptedRecognizedStackFrame : public RecognizedStackFrame {
 public:
   ScriptedRecognizedStackFrame(ValueObjectListSP args) {
@@ -47,6 +49,8 @@ ScriptedStackFrameRecognizer::RecognizeF
   return RecognizedStackFrameSP(new ScriptedRecognizedStackFrame(args));
 }
 
+#endif
+
 class StackFrameRecognizerManagerImpl {
 public:
   void AddRecognizer(StackFrameRecognizerSP recognizer, ConstString &module,


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