[Lldb-commits] [PATCH] D57907: lldb: Fix compilation on OpenBSD

2019-02-07 Thread Todd Mortimer via Phabricator via lldb-commits
mortimer created this revision.
mortimer added a reviewer: krytarowski.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Update the OpenBSD Host.cpp for the new SetFile() function signature. Fixes 
compiling lldb on OpenBSD.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D57907

Files:
  lldb/source/Host/openbsd/Host.cpp


Index: lldb/source/Host/openbsd/Host.cpp
===
--- lldb/source/Host/openbsd/Host.cpp
+++ lldb/source/Host/openbsd/Host.cpp
@@ -67,8 +67,7 @@
 
   cstr = data.GetCStr(&offset);
   if (cstr) {
-process_info.GetExecutableFile().SetFile(cstr, false,
- FileSpec::Style::native);
+process_info.GetExecutableFile().SetFile(cstr, 
FileSpec::Style::native);
 
 if (!(match_info_ptr == NULL ||
   NameMatches(


Index: lldb/source/Host/openbsd/Host.cpp
===
--- lldb/source/Host/openbsd/Host.cpp
+++ lldb/source/Host/openbsd/Host.cpp
@@ -67,8 +67,7 @@
 
   cstr = data.GetCStr(&offset);
   if (cstr) {
-process_info.GetExecutableFile().SetFile(cstr, false,
- FileSpec::Style::native);
+process_info.GetExecutableFile().SetFile(cstr, FileSpec::Style::native);
 
 if (!(match_info_ptr == NULL ||
   NameMatches(
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D57928: Fix x86 return pattern detection

2019-02-07 Thread Todd Mortimer via Phabricator via lldb-commits
mortimer created this revision.
mortimer added a reviewer: jasonmolenda.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Replace 0xc9 (LEAVE) with 0xcb (RETF) in ret_pattern_p(). Also put 0xc3 first, 
since it is the most common form and will match first.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D57928

Files:
  lldb/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp


Index: lldb/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
===
--- lldb/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
+++ lldb/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
@@ -665,10 +665,10 @@
   return false;
 }
 
-// ret [0xc9] or [0xc2 imm8] or [0xca imm8]
+// ret [0xc3] or [0xcb] or [0xc2 imm16] or [0xca imm16]
 bool x86AssemblyInspectionEngine::ret_pattern_p() {
   uint8_t *p = m_cur_insn;
-  return *p == 0xc9 || *p == 0xc2 || *p == 0xca || *p == 0xc3;
+  return *p == 0xc3 || *p == 0xc2 || *p == 0xca || *p == 0xcb;
 }
 
 uint32_t x86AssemblyInspectionEngine::extract_4(uint8_t *b) {


Index: lldb/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
===
--- lldb/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
+++ lldb/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
@@ -665,10 +665,10 @@
   return false;
 }
 
-// ret [0xc9] or [0xc2 imm8] or [0xca imm8]
+// ret [0xc3] or [0xcb] or [0xc2 imm16] or [0xca imm16]
 bool x86AssemblyInspectionEngine::ret_pattern_p() {
   uint8_t *p = m_cur_insn;
-  return *p == 0xc9 || *p == 0xc2 || *p == 0xca || *p == 0xc3;
+  return *p == 0xc3 || *p == 0xc2 || *p == 0xca || *p == 0xcb;
 }
 
 uint32_t x86AssemblyInspectionEngine::extract_4(uint8_t *b) {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D57928: Fix x86 return pattern detection

2019-02-08 Thread Todd Mortimer via Phabricator via lldb-commits
mortimer added a comment.

For sure I can add a test.

I found this only because I was looking to fix something else (prologue 
detection on OpenBSD with -fret-protector) and noticed that the return pattern 
detect function was wrong. So nothing was broken that I found, though the 
inclusion of 0xc9 as a return pattern could conceivably cause problems under 
some circumstances. In any event, I figured it would be easy enough to submit a 
fix, since it’s a tiny change.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D57928



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


[Lldb-commits] [PATCH] D57928: Fix x86 return pattern detection

2019-02-09 Thread Todd Mortimer via Phabricator via lldb-commits
mortimer updated this revision to Diff 186144.
mortimer added a comment.

Added a test to verify that the unwind state is reset after each kind of return.


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

https://reviews.llvm.org/D57928

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

Index: lldb/unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp
===
--- lldb/unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp
+++ lldb/unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp
@@ -2552,3 +2552,173 @@
 
 }
 
+TEST_F(Testx86AssemblyInspectionEngine, TestReturnDetect) {
+  std::unique_ptr engine = Getx86_64Inspector();
+
+  // Single fragment with all four return forms.
+  // We want to verify that the unwind state is reset after each ret.
+  uint8_t data[] = {
+  0x55, // offset  0 -- pushq %rbp
+  0x48, 0x89, 0xe5, // offset  1 -- movq %rsp, %rbp
+  0x31, 0xc0,   // offset  4 -- xorl %eax, %eax
+  0x5d, // offset  6 -- popq %rbp
+  0xc3, // offset  7 -- retq
+  0x31, 0xc0,   // offset  8 -- xorl %eax, %eax
+  0x5d, // offset 10 -- popq %rbp
+  0xcb, // offset 11 -- retf
+  0x31, 0xc0,   // offset 12 -- xorl %eax, %eax
+  0x5d, // offset 14 -- popq %rbp
+  0xc2, 0x22, 0x11, // offset 15 -- retq 0x1122
+  0x31, 0xc0,   // offset 18 -- xorl %eax, %eax
+  0x5d, // offset 20 -- popq %rbp
+  0xca, 0x44, 0x33, // offset 21 -- retf 0x3344
+  0x31, 0xc0,   // offset 24 -- xorl %eax, %eax
+  };
+
+  AddressRange sample_range(0x1000, sizeof(data));
+
+  UnwindPlan unwind_plan(eRegisterKindLLDB);
+  EXPECT_TRUE(engine->GetNonCallSiteUnwindPlanFromAssembly(
+  data, sizeof(data), sample_range, unwind_plan));
+
+  // Expect following unwind rows:
+  //  0: CFA=rsp +8 => rsp=CFA+0 rip=[CFA-8]
+  //  1: CFA=rsp+16 => rbp=[CFA-16] rsp=CFA+0 rip=[CFA-8]
+  //  4: CFA=rbp+16 => rbp=[CFA-16] rsp=CFA+0 rip=[CFA-8]
+  //  7: CFA=rsp +8 => rsp=CFA+0 rip=[CFA-8]
+  //  8: CFA=rbp+16 => rbp=[CFA-16] rsp=CFA+0 rip=[CFA-8]
+  // 11: CFA=rsp +8 => rsp=CFA+0 rip=[CFA-8]
+  // 12: CFA=rbp+16 => rbp=[CFA-16] rsp=CFA+0 rip=[CFA-8]
+  // 15: CFA=rsp +8 => rsp=CFA+0 rip=[CFA-8]
+  // 18: CFA=rbp+16 => rbp=[CFA-16] rsp=CFA+0 rip=[CFA-8]
+  // 21: CFA=rsp +8 => rsp=CFA+0 rip=[CFA-8]
+  // 24: CFA=rbp+16 => rbp=[CFA-16] rsp=CFA+0 rip=[CFA-8]
+
+  EXPECT_TRUE(unwind_plan.GetInitialCFARegister() == k_rsp);
+  EXPECT_TRUE(unwind_plan.GetUnwindPlanValidAtAllInstructions() ==
+  eLazyBoolYes);
+  EXPECT_TRUE(unwind_plan.GetSourcedFromCompiler() == eLazyBoolNo);
+
+  UnwindPlan::Row::RegisterLocation regloc;
+
+  //  0: CFA=rsp +8 => rsp=CFA+0 rip=[CFA-8]
+  UnwindPlan::RowSP row_sp = unwind_plan.GetRowForFunctionOffset(0);
+  EXPECT_EQ(0ull, row_sp->GetOffset());
+  EXPECT_TRUE(row_sp->GetCFAValue().GetRegisterNumber() == k_rsp);
+  EXPECT_TRUE(row_sp->GetCFAValue().IsRegisterPlusOffset() == true);
+  EXPECT_EQ(8, row_sp->GetCFAValue().GetOffset());
+
+  EXPECT_TRUE(row_sp->GetRegisterInfo(k_rip, regloc));
+  EXPECT_TRUE(regloc.IsAtCFAPlusOffset());
+  EXPECT_EQ(-8, regloc.GetOffset());
+
+  //  1: CFA=rsp+16 => rbp=[CFA-16] rsp=CFA+0 rip=[CFA-8]
+  row_sp = unwind_plan.GetRowForFunctionOffset(1);
+  EXPECT_EQ(1ull, row_sp->GetOffset());
+  EXPECT_TRUE(row_sp->GetCFAValue().GetRegisterNumber() == k_rsp);
+  EXPECT_TRUE(row_sp->GetCFAValue().IsRegisterPlusOffset() == true);
+  EXPECT_EQ(16, row_sp->GetCFAValue().GetOffset());
+
+  EXPECT_TRUE(row_sp->GetRegisterInfo(k_rip, regloc));
+  EXPECT_TRUE(regloc.IsAtCFAPlusOffset());
+  EXPECT_EQ(-8, regloc.GetOffset());
+
+  //  4: CFA=rbp+16 => rbp=[CFA-16] rsp=CFA+0 rip=[CFA-8]
+  row_sp = unwind_plan.GetRowForFunctionOffset(4);
+  EXPECT_EQ(4ull, row_sp->GetOffset());
+  EXPECT_TRUE(row_sp->GetCFAValue().GetRegisterNumber() == k_rbp);
+  EXPECT_TRUE(row_sp->GetCFAValue().IsRegisterPlusOffset() == true);
+  EXPECT_EQ(16, row_sp->GetCFAValue().GetOffset());
+
+  EXPECT_TRUE(row_sp->GetRegisterInfo(k_rip, regloc));
+  EXPECT_TRUE(regloc.IsAtCFAPlusOffset());
+  EXPECT_EQ(-8, regloc.GetOffset());
+
+  //  7: CFA=rsp +8 => rsp=CFA+0 rip=[CFA-8]
+  row_sp = unwind_plan.GetRowForFunctionOffset(7);
+  EXPECT_EQ(7ull, row_sp->GetOffset());
+  EXPECT_TRUE(row_sp->GetCFAValue().GetRegisterNumber() == k_rsp);
+  EXPECT_TRUE(row_sp->GetCFAValue().IsRegisterPlusOffset() == true);
+  EXPECT_EQ(8, row_sp->GetCFAValue().GetOffset());
+
+  EXPECT_TRUE(row_sp->GetRegisterInfo(k_rip, regloc));
+  EXPECT_TRUE(regloc.IsAtCFAPlusOffset());
+  EXPECT_EQ(-8, regloc.GetOffset());
+
+  //  8: CFA=rbp+16 => rbp=[CFA-16] rsp=CFA+0 rip=[CFA-8]
+  row_sp = unwind_plan.GetRowForFunctionOffset(8);
+  EXPECT_EQ(8ull, row_sp->GetOffset());
+  EX

[Lldb-commits] [PATCH] D57928: Fix x86 return pattern detection

2019-02-10 Thread Todd Mortimer via Phabricator via lldb-commits
mortimer added a comment.

Happy to help out. :-) I do not have commit access.


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

https://reviews.llvm.org/D57928



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


[Lldb-commits] [PATCH] D57907: lldb: Fix compilation on OpenBSD

2019-02-10 Thread Todd Mortimer via Phabricator via lldb-commits
mortimer added a comment.

I don't have commit access, so if there is ready to land, could someone commit 
it? Thanks!


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D57907



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