[Lldb-commits] [PATCH] [Accepted] D24498: [LLDB][MIPS] Fix TestReturnValue failure for MIPS

2016-09-30 Thread Bhushan Attarde via lldb-commits
bhushan accepted this revision.
bhushan added a comment.
This revision is now accepted and ready to land.

Looks good as far as correctness is concerned.


https://reviews.llvm.org/D24498



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


[Lldb-commits] [PATCH] [Commented On] D13154: [MIPS] Use Address::GetAddressClass() instead of elf flags to decide address space of an address

2016-09-30 Thread Bhushan Attarde via lldb-commits
bhushan added a comment.

Hi Eugene,

I did not commit this patch because @zturner had asked for a testcase for this 
change. But the test will require to build it for micromips target (-mmicromips 
option) and currently I don't have any micromips hardware available. I had 
tested this patch with simulator.

I can rebase and commit it if @clayborg and @zturner agrees.


Repository:
  rL LLVM

https://reviews.llvm.org/D13154



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


[Lldb-commits] [PATCH] [Updated, 58 lines] D25021: [LLDB][MIPS] Fix qProcessInfo to return correct pointer size based on ELF ABI

2016-09-30 Thread Nitesh Jain via lldb-commits
nitesh.jain removed rL LLVM as the repository for this revision.
nitesh.jain updated this revision to Diff 73029.
nitesh.jain added a comment.

We just require ABI information so that auxv vector is parse when lldb try to 
attach a process via "attach -p pid"


https://reviews.llvm.org/D25021

Files:
  include/lldb/Core/ArchSpec.h
  source/Core/ArchSpec.cpp
  source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp

Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
===
--- source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
+++ source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
@@ -1212,13 +1212,12 @@
   // Nothing.
   break;
 }
-
-if (proc_triple.isArch64Bit())
-  response.PutCString("ptrsize:8;");
-else if (proc_triple.isArch32Bit())
-  response.PutCString("ptrsize:4;");
-else if (proc_triple.isArch16Bit())
-  response.PutCString("ptrsize:2;");
+// In case of MIPS64, pointer size is depend on ELF ABI
+// For N32 the pointer size is 4 and for N64 it is 8
+std::string abi = proc_arch.GetTargetABI();
+if (!abi.empty())
+  response.Printf("elf_abi:%s;",abi.c_str());
+response.Printf("ptrsize:%d;", proc_arch.GetAddressByteSize()); 
   }
 }
 
Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
===
--- source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -1847,6 +1847,7 @@
   std::string os_name;
   std::string vendor_name;
   std::string triple;
+  std::string elf_abi;
   uint32_t pointer_byte_size = 0;
   StringExtractor extractor;
   ByteOrder byte_order = eByteOrderInvalid;
@@ -1883,6 +1884,9 @@
 } else if (name.equals("pid")) {
   if (!value.getAsInteger(16, pid))
 ++num_keys_decoded;
+} else if (name.equals("elf_abi")) {
+elf_abi = value;
+++num_keys_decoded;
 }
   }
   if (num_keys_decoded > 0)
@@ -1895,6 +1899,7 @@
   // Set the ArchSpec from the triple if we have it.
   if (!triple.empty()) {
 m_process_arch.SetTriple(triple.c_str());
+m_process_arch.SetFlags(elf_abi);
 if (pointer_byte_size) {
   assert(pointer_byte_size == m_process_arch.GetAddressByteSize());
 }
Index: source/Core/ArchSpec.cpp
===
--- source/Core/ArchSpec.cpp
+++ source/Core/ArchSpec.cpp
@@ -627,6 +627,42 @@
   return false;
 }
 
+std::string ArchSpec::GetTargetABI() const {
+
+  std::string abi;
+
+  if (IsMIPS()) {
+switch (GetFlags() & ArchSpec::eMIPSABI_mask) {
+case ArchSpec::eMIPSABI_N64:
+  abi = "n64";
+  return abi;
+case ArchSpec::eMIPSABI_N32:
+  abi = "n32";
+  return abi;
+case ArchSpec::eMIPSABI_O32:
+  abi = "o32";
+  return abi;
+default:
+  return abi;
+}
+  }
+  return abi;
+}
+
+void ArchSpec::SetFlags(std::string elf_abi) {
+
+  uint32_t flag = GetFlags();
+  if (IsMIPS()) {
+if (elf_abi == "n64")
+  flag |= ArchSpec::eMIPSABI_N64;
+else if (elf_abi == "n32")
+  flag |= ArchSpec::eMIPSABI_N32;
+else if (elf_abi == "o32")
+  flag |= ArchSpec::eMIPSABI_O32;
+  }
+  SetFlags(flag);
+}
+
 std::string ArchSpec::GetClangTargetCPU() {
   std::string cpu;
   const llvm::Triple::ArchType machine = GetMachine();
Index: include/lldb/Core/ArchSpec.h
===
--- include/lldb/Core/ArchSpec.h
+++ include/lldb/Core/ArchSpec.h
@@ -307,6 +307,8 @@
   //--
   std::string GetClangTargetCPU();
 
+  std::string GetTargetABI() const;
+
   //--
   /// Clears the object state.
   ///
@@ -592,6 +594,8 @@
 
   void SetFlags(uint32_t flags) { m_flags = flags; }
 
+  void SetFlags(std::string elf_abi);
+
 protected:
   bool IsEqualTo(const ArchSpec &rhs, bool exact_match) const;
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r282848 - Fix PDB unittests on non-windows platforms

2016-09-30 Thread Pavel Labath via lldb-commits
Author: labath
Date: Fri Sep 30 06:47:54 2016
New Revision: 282848

URL: http://llvm.org/viewvc/llvm-project?rev=282848&view=rev
Log:
Fix PDB unittests on non-windows platforms

llvm r282788 changed how the presence of windows DIA SDK is signalled. Adjust to
that.

Modified:
lldb/trunk/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp

Modified: lldb/trunk/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp?rev=282848&r1=282847&r2=282848&view=diff
==
--- lldb/trunk/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp (original)
+++ lldb/trunk/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp Fri Sep 30 
06:47:54 2016
@@ -154,7 +154,7 @@ protected:
   }
 };
 
-#if defined(HAVE_DIA_SDK)
+#if HAVE_DIA_SDK
 #define REQUIRES_DIA_SDK(TestName) TestName
 #else
 #define REQUIRES_DIA_SDK(TestName) DISABLED_##TestName


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


[Lldb-commits] [lldb] r282849 - XFAIL TestSBData for gcc-4.9 i386

2016-09-30 Thread Pavel Labath via lldb-commits
Author: labath
Date: Fri Sep 30 07:12:15 2016
New Revision: 282849

URL: http://llvm.org/viewvc/llvm-project?rev=282849&view=rev
Log:
XFAIL TestSBData for gcc-4.9 i386

test broken in r282659.

Modified:
lldb/trunk/packages/Python/lldbsuite/test/python_api/sbdata/TestSBData.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/python_api/sbdata/TestSBData.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/python_api/sbdata/TestSBData.py?rev=282849&r1=282848&r2=282849&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/python_api/sbdata/TestSBData.py 
(original)
+++ lldb/trunk/packages/Python/lldbsuite/test/python_api/sbdata/TestSBData.py 
Fri Sep 30 07:12:15 2016
@@ -22,6 +22,7 @@ class SBDataAPICase(TestBase):
 self.line = line_number('main.cpp', '// set breakpoint here')
 
 @add_test_categories(['pyapi'])
+@expectedFailureAll(compiler="gcc", compiler_version=[">=", "4.9"])
 def test_with_run_command(self):
 """Test the SBData APIs."""
 self.build()


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


Re: [Lldb-commits] [lldb] r282683 - Add a unit test for an x86_64 assembly inspection of

2016-09-30 Thread Pavel Labath via lldb-commits
I made a quick investigation today. The problem is indeed specific to
gcc-4.9. The main differences I could see is that gcc-4.9 generates a
different prologue for the function, and uses pushl for argument passing.
This confuses the emulator/augmenter and the unwind information at some
points ends up being incorrect. Since the problem starts to occur after the
first pushl instruction, i am guessing the problem is with those. I'll try
to investigate more next week.

 For reference, the function with 4.9 looks like this:

a.out`main:

0x80484eb <+0>:   leal   0x4(%esp), %ecx

0x80484ef <+4>:   andl   $-0x10, %esp

0x80484f2 <+7>:   pushl  -0x4(%ecx)

0x80484f5 <+10>:  pushl  %ebp

0x80484f6 <+11>:  movl   %esp, %ebp

0x80484f8 <+13>:  pushl  %edi

0x80484f9 <+14>:  pushl  %esi

0x80484fa <+15>:  pushl  %ebx

0x80484fb <+16>:  pushl  %ecx

0x80484fc <+17>:  subl   $0x28, %esp

0x80484ff <+20>:  subl   $0xc, %esp

0x8048502 <+23>:  pushl  $0x18

0x8048504 <+25>:  calll  0x80483d0 ; symbol stub for:
operator new[](unsigned int)

0x8048509 <+30>:  addl   $0x10, %esp

0x804850c <+33>:  movl   %eax, %edi

0x804850e <+35>:  movl   %edi, %eax

0x8048510 <+37>:  movl   $0x1, %esi

0x8048515 <+42>:  movl   %eax, %ebx

0x8048517 <+44>:  jmp0x804852b ; <+64> at
main.cpp:26

0x8048519 <+46>:  subl   $0xc, %esp

0x804851c <+49>:  pushl  %ebx

0x804851d <+50>:  calll  0x80485cc ; foo::foo at
main.cpp:16

0x8048522 <+55>:  addl   $0x10, %esp

0x8048525 <+58>:  addl   $0xc, %ebx

0x8048528 <+61>:  subl   $0x1, %esi

0x804852b <+64>:  cmpl   $-0x1, %esi

0x804852e <+67>:  jne0x8048519 ; <+46> at
main.cpp:26

0x8048530 <+69>:  movl   %edi, -0x1c(%ebp)

0x8048533 <+72>:  movl   -0x1c(%ebp), %eax

0x8048536 <+75>:  movl   $0x1, (%eax)

0x804853c <+81>:  movl   -0x1c(%ebp), %eax

0x804853f <+84>:  movl   $0x9, 0x4(%eax)

0x8048546 <+91>:  movl   -0x1c(%ebp), %eax

0x8048549 <+94>:  addl   $0xc, %eax

0x804854c <+97>:  movl   $0x8, (%eax)

0x8048552 <+103>: movl   -0x1c(%ebp), %eax

0x8048555 <+106>: addl   $0xc, %eax

0x8048558 <+109>: movl   $0x5, 0x4(%eax)

0x804855f <+116>: movl   -0x1c(%ebp), %eax

0x8048562 <+119>: addl   $0xc, %eax

0x8048565 <+122>: movl   $0x7, 0x4(%eax)

0x804856c <+129>: movl   -0x1c(%ebp), %eax

0x804856f <+132>: leal   0xc(%eax), %edx

0x8048572 <+135>: movl   0x80486a4, %eax

0x8048577 <+140>: movl   %eax, 0x8(%edx)

0x804857a <+143>: leal   -0x34(%ebp), %ebx

0x804857d <+146>: movl   0x80486a8, %eax

0x8048582 <+151>: pushl  %eax

0x8048583 <+152>: pushl  $0x2

0x8048585 <+154>: pushl  $0x1

0x8048587 <+156>: pushl  %ebx

->  0x8048588 <+157>: calll  0x80485f0 ; foo::foo at
main.cpp:17

0x804858d <+162>: addl   $0x10, %esp

0x8048590 <+165>: leal   0xc(%ebx), %edx

0x8048593 <+168>: movl   0x80486ac, %eax

0x8048598 <+173>: pushl  %eax

0x8048599 <+174>: pushl  $0x5

0x804859b <+176>: pushl  $0x4

0x804859d <+178>: pushl  %edx

0x804859e <+179>: calll  0x80485f0 ; foo::foo at
main.cpp:17

0x80485a3 <+184>: addl   $0x10, %esp

0x80485a6 <+187>: cmpl   $0x0, -0x1c(%ebp)

0x80485aa <+191>: je 0x80485ba ; <+207> at
main.cpp:42

0x80485ac <+193>: subl   $0xc, %esp

0x80485af <+196>: pushl  -0x1c(%ebp)

0x80485b2 <+199>: calll  0x80483e0 ; symbol stub for:
operator delete[](void*)

0x80485b7 <+204>: addl   $0x10, %esp

0x80485ba <+207>: movl   $0x0, %eax

0x80485bf <+212>: leal   -0x10(%ebp), %esp

0x80485c2 <+215>: popl   %ecx

0x80485c3 <+216>: popl   %ebx

0x80485c4 <+217>: popl   %esi

0x80485c5 <+218>: popl   %edi

0x80485c6 <+219>: popl   %ebp

0x80485c7 <+220>: leal   -0x4(%ecx), %esp

0x80485ca <+223>: retl



whereas the same function compiled with gcc-4.8 is this:

0x804850d <+0>:   pushl  %ebp

0x804850e <+1>:   movl   %esp, %ebp

0x8048510 <+3>:   pushl  %edi

0x8048511 <+4>:   pushl  %esi

0x8048512 <+5>:   pushl  %ebx

0x8048513 <+6>:   andl   $-0x10, %esp

0x8048516 <+9>:   subl   $0x30, %esp

0x8048519 <+12>:  movl   $0x18, (%esp)

0x8048520 <+19>:  calll  0x80483f0 ; symbol stub for:
operator new[](unsigned int)

0x8048525 <+24>:  movl   %eax, %edi

0x8048527 <+26>:  movl   %edi, %eax

0x8048529 <+28>:  movl   $0x1, %esi

0x804852e <+33>:  movl   %eax, %ebx

0x8048530 <+35>:  jmp0x8048540 ; <+51> at
main.cpp:26

0x8048532 <+37>:  movl   %ebx, (%esp)

0x8048535 <+40>:  calll  0x8048600 ; foo::foo at
main.cpp:16

0x804853a <+45>:  addl   $0xc, %ebx

0x804853d <+48>:  subl   $0x1, %esi

0x8048540 <+51>:  cmpl   $-0x1, %esi

0x80485

[Lldb-commits] [lldb] r282862 - Fixing windows build breakage caused by rL282822

2016-09-30 Thread Dimitar Vlahovski via lldb-commits
Author: dvlahovski
Date: Fri Sep 30 09:36:17 2016
New Revision: 282862

URL: http://llvm.org/viewvc/llvm-project?rev=282862&view=rev
Log:
Fixing windows build breakage caused by rL282822

The breakage was because of the moving of the UTF functions to the llvm
namespace

Modified:
lldb/trunk/source/Host/windows/Windows.cpp

Modified: lldb/trunk/source/Host/windows/Windows.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/Windows.cpp?rev=282862&r1=282861&r2=282862&view=diff
==
--- lldb/trunk/source/Host/windows/Windows.cpp (original)
+++ lldb/trunk/source/Host/windows/Windows.cpp Fri Sep 30 09:36:17 2016
@@ -32,21 +32,21 @@ int _chdir(const char *path);
 
 namespace {
 bool utf8ToWide(const char *utf8, wchar_t *buf, size_t bufSize) {
-  const UTF8 *sourceStart = reinterpret_cast(utf8);
+  const llvm::UTF8 *sourceStart = reinterpret_cast(utf8);
   size_t sourceLen = strlen(utf8) + 1 /* convert null too */;
-  UTF16 *target = reinterpret_cast(buf);
-  ConversionFlags flags = strictConversion;
-  return ConvertUTF8toUTF16(&sourceStart, sourceStart + sourceLen, &target,
-target + bufSize, flags) == conversionOK;
+  llvm::UTF16 *target = reinterpret_cast(buf);
+  llvm::ConversionFlags flags = strictConversion;
+  return llvm::ConvertUTF8toUTF16(&sourceStart, sourceStart + sourceLen, 
&target,
+target + bufSize, flags) == llvm::conversionOK;
 }
 
 bool wideToUtf8(const wchar_t *wide, char *buf, size_t bufSize) {
-  const UTF16 *sourceStart = reinterpret_cast(wide);
+  const llvm::UTF16 *sourceStart = reinterpret_cast(wide);
   size_t sourceLen = wcslen(wide) + 1 /* convert null too */;
-  UTF8 *target = reinterpret_cast(buf);
-  ConversionFlags flags = strictConversion;
-  return ConvertUTF16toUTF8(&sourceStart, sourceStart + sourceLen, &target,
-target + bufSize, flags) == conversionOK;
+  llvm::UTF8 *target = reinterpret_cast(buf);
+  llvm::ConversionFlags flags = strictConversion;
+  return llvm::ConvertUTF16toUTF8(&sourceStart, sourceStart + sourceLen, 
&target,
+target + bufSize, flags) == llvm::conversionOK;
 }
 }
 


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


[Lldb-commits] [lldb] r282866 - Again fixing windows build breakage like in rL282862

2016-09-30 Thread Dimitar Vlahovski via lldb-commits
Author: dvlahovski
Date: Fri Sep 30 10:41:33 2016
New Revision: 282866

URL: http://llvm.org/viewvc/llvm-project?rev=282866&view=rev
Log:
Again fixing windows build breakage like in rL282862

Modified:
lldb/trunk/source/Host/windows/Windows.cpp

Modified: lldb/trunk/source/Host/windows/Windows.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/Windows.cpp?rev=282866&r1=282865&r2=282866&view=diff
==
--- lldb/trunk/source/Host/windows/Windows.cpp (original)
+++ lldb/trunk/source/Host/windows/Windows.cpp Fri Sep 30 10:41:33 2016
@@ -35,7 +35,7 @@ bool utf8ToWide(const char *utf8, wchar_
   const llvm::UTF8 *sourceStart = reinterpret_cast(utf8);
   size_t sourceLen = strlen(utf8) + 1 /* convert null too */;
   llvm::UTF16 *target = reinterpret_cast(buf);
-  llvm::ConversionFlags flags = strictConversion;
+  llvm::ConversionFlags flags = llvm::strictConversion;
   return llvm::ConvertUTF8toUTF16(&sourceStart, sourceStart + sourceLen, 
&target,
 target + bufSize, flags) == llvm::conversionOK;
 }
@@ -44,7 +44,7 @@ bool wideToUtf8(const wchar_t *wide, cha
   const llvm::UTF16 *sourceStart = reinterpret_cast(wide);
   size_t sourceLen = wcslen(wide) + 1 /* convert null too */;
   llvm::UTF8 *target = reinterpret_cast(buf);
-  llvm::ConversionFlags flags = strictConversion;
+  llvm::ConversionFlags flags = llvm::strictConversion;
   return llvm::ConvertUTF16toUTF8(&sourceStart, sourceStart + sourceLen, 
&target,
 target + bufSize, flags) == llvm::conversionOK;
 }


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


[Lldb-commits] [lldb] r282869 - Skip TestRuntimeIvars on i386; the Objective-C V1 runtime doesn't list ivars.

2016-09-30 Thread Sean Callanan via lldb-commits
Author: spyffe
Date: Fri Sep 30 11:02:28 2016
New Revision: 282869

URL: http://llvm.org/viewvc/llvm-project?rev=282869&view=rev
Log:
Skip TestRuntimeIvars on i386; the Objective-C V1 runtime doesn't list ivars.

Modified:

lldb/trunk/packages/Python/lldbsuite/test/lang/objc/objc-runtime-ivars/TestRuntimeIvars.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/lang/objc/objc-runtime-ivars/TestRuntimeIvars.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/objc/objc-runtime-ivars/TestRuntimeIvars.py?rev=282869&r1=282868&r2=282869&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/lang/objc/objc-runtime-ivars/TestRuntimeIvars.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/lang/objc/objc-runtime-ivars/TestRuntimeIvars.py
 Fri Sep 30 11:02:28 2016
@@ -3,4 +3,4 @@ from lldbsuite.test import decorators
 
 lldbinline.MakeInlineTest(
 __file__, globals(), [
-decorators.skipIfFreeBSD, decorators.skipIfLinux, 
decorators.skipIfWindows])
+decorators.skipIfFreeBSD, decorators.skipIfLinux, 
decorators.skipIfWindows, decorators.skipIf(archs=["i386", "i686"])])


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


[Lldb-commits] [PATCH] D25099: Refactor Args a different way

2016-09-30 Thread Zachary Turner via lldb-commits
zturner created this revision.
zturner added a reviewer: clayborg.
zturner added subscribers: lldb-commits, LLDB.

In https://reviews.llvm.org/D24952 I tried to refactor the `Args` class to get 
rid of `m_argv`.  The original motivation for this is that I wanted a way to 
implement `GetArgumentAtIndex()` so as to return a `StringRef`.  I could have 
just returned a `StringRef` from the `m_argv` array, but it seems wasteful to 
calculate the length every time when we were already storing a `std::string`.   
Unfortunately the `std::string` was in a `std::list` (required so that it would 
not be invalidated when inserting items into the arg list) so there was no 
random access.  So I wanted to see if I could do better, and that was the 
motivation for the original patch.

However, after fixing up all the places in the code to use the "new" `Args`, I 
wasn't completely satisfied.  I like that the old code could just give you an 
`argv` pointer that you can pass to a system API.  So I started over and ended 
up with this.  Quick overview of changes:

1. Instead of using a `std::list` to own the memory, we use a 
`std::vector>`.  This provides random access, which is 
something `list` couldn't provide, and it also provides non-const access to the 
underlying buffer, which is something that `std::string` couldn't provide, 
leading to a lot of `const_cast` which are no longer necessary.
2. Each entry's quote char, backing memory (i.e. `std::unique_ptr`), 
and `StringRef` with precomputed length are stored together in a single entry.  
This guarantees by design that the various arrays' lengths do not need to stay 
in sync with each other, because there is only one array.
3. Some longstanding undefined behavior is documented and left for someone else 
to fix.
4. Asserts are added to the code to document the pre-conditions.  I know we are 
allergic to asserts, but I want to emphasize that none of these asserts have 
anything to do with the input parameters.  The asserts are ALWAYS on internal 
class state.

With this change it should finally be easy to change `GetArgumentAtIndex()` to 
return a `StringRef`, because it can just return `m_entries[idx].ref`.


https://reviews.llvm.org/D25099

Files:
  include/lldb/Interpreter/Args.h
  source/Core/StringList.cpp
  source/Interpreter/Args.cpp
  unittests/Interpreter/TestArgs.cpp

Index: unittests/Interpreter/TestArgs.cpp
===
--- unittests/Interpreter/TestArgs.cpp
+++ unittests/Interpreter/TestArgs.cpp
@@ -66,6 +66,109 @@
   EXPECT_STREQ(args.GetArgumentAtIndex(1), "second_arg");
 }
 
+TEST(ArgsTest, TestInsertArg) {
+  Args args;
+  args.AppendArgument("1");
+  args.AppendArgument("2");
+  args.AppendArgument("3");
+  args.InsertArgumentAtIndex(1, "1.5");
+  args.InsertArgumentAtIndex(4, "3.5");
+
+  ASSERT_EQ(5u, args.GetArgumentCount());
+  EXPECT_STREQ("1", args.GetArgumentAtIndex(0));
+  EXPECT_STREQ("1.5", args.GetArgumentAtIndex(1));
+  EXPECT_STREQ("2", args.GetArgumentAtIndex(2));
+  EXPECT_STREQ("3", args.GetArgumentAtIndex(3));
+  EXPECT_STREQ("3.5", args.GetArgumentAtIndex(4));
+}
+
+TEST(ArgsTest, TestArgv) {
+  Args args;
+  EXPECT_EQ(nullptr, args.GetArgumentVector()[0]);
+
+  args.AppendArgument("1");
+  EXPECT_NE(nullptr, args.GetArgumentVector()[0]);
+  EXPECT_EQ(nullptr, args.GetArgumentVector()[1]);
+
+  args.AppendArgument("2");
+  EXPECT_NE(nullptr, args.GetArgumentVector()[0]);
+  EXPECT_NE(nullptr, args.GetArgumentVector()[1]);
+  EXPECT_EQ(nullptr, args.GetArgumentVector()[2]);
+
+  args.AppendArgument("3");
+  EXPECT_NE(nullptr, args.GetArgumentVector()[0]);
+  EXPECT_NE(nullptr, args.GetArgumentVector()[1]);
+  EXPECT_NE(nullptr, args.GetArgumentVector()[2]);
+  EXPECT_EQ(nullptr, args.GetArgumentVector()[3]);
+
+  args.InsertArgumentAtIndex(1, "1.5");
+  EXPECT_NE(nullptr, args.GetArgumentVector()[0]);
+  EXPECT_NE(nullptr, args.GetArgumentVector()[1]);
+  EXPECT_NE(nullptr, args.GetArgumentVector()[2]);
+  EXPECT_NE(nullptr, args.GetArgumentVector()[3]);
+  EXPECT_EQ(nullptr, args.GetArgumentVector()[4]);
+
+  args.InsertArgumentAtIndex(4, "3.5");
+  EXPECT_NE(nullptr, args.GetArgumentVector()[0]);
+  EXPECT_NE(nullptr, args.GetArgumentVector()[1]);
+  EXPECT_NE(nullptr, args.GetArgumentVector()[2]);
+  EXPECT_NE(nullptr, args.GetArgumentVector()[3]);
+  EXPECT_NE(nullptr, args.GetArgumentVector()[4]);
+  EXPECT_EQ(nullptr, args.GetArgumentVector()[5]);
+}
+
+TEST(ArgsTest, GetQuotedCommandString) {
+  Args args;
+  const char *str = "process launch -o stdout.txt -- \"a b c\"";
+  args.SetCommandString(str);
+
+  std::string stdstr;
+  ASSERT_TRUE(args.GetQuotedCommandString(stdstr));
+  EXPECT_EQ(str, stdstr);
+}
+
+TEST(ArgsTest, BareSingleQuote) {
+  Args args;
+  args.SetCommandString("a\\'b");
+  EXPECT_EQ(1u, args.GetArgumentCount());
+
+  EXPECT_STREQ("a'b", args.GetArgumentAtIndex(0));
+}
+
+TEST(ArgsTest, DoubleQuotedItem) {
+  Args args;
+  args.SetCommandString("\"a b c\

[Lldb-commits] [lldb] r282871 - Add namespace qualifiers for UTF functions that just moved.

2016-09-30 Thread Adrian McCarthy via lldb-commits
Author: amccarth
Date: Fri Sep 30 11:11:42 2016
New Revision: 282871

URL: http://llvm.org/viewvc/llvm-project?rev=282871&view=rev
Log:
Add namespace qualifiers for UTF functions that just moved.

Modified:
lldb/trunk/source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp
lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp

Modified: lldb/trunk/source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp?rev=282871&r1=282870&r2=282871&view=diff
==
--- lldb/trunk/source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp Fri Sep 30 
11:11:42 2016
@@ -33,7 +33,7 @@ bool SaveMiniDump(const lldb::ProcessSP
   std::wstring wide_name;
   wide_name.resize(file_name.size() + 1);
   char *result_ptr = reinterpret_cast(&wide_name[0]);
-  const UTF8 *error_ptr = nullptr;
+  const llvm::UTF8 *error_ptr = nullptr;
   if (!llvm::ConvertUTF8toWide(sizeof(wchar_t), file_name, result_ptr,
error_ptr)) {
 error.SetErrorString("cannot convert file name");

Modified: 
lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp?rev=282871&r1=282870&r2=282871&view=diff
==
--- lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp 
(original)
+++ lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp 
Fri Sep 30 11:11:42 2016
@@ -505,17 +505,17 @@ std::string ProcessWinMiniDump::Impl::Ge
   }
   auto md_string = reinterpret_cast(
   static_cast(m_base_addr) + rva);
-  auto source_start = reinterpret_cast(md_string->Buffer);
+  auto source_start = reinterpret_cast(md_string->Buffer);
   const auto source_length = ::wcslen(md_string->Buffer);
   const auto source_end = source_start + source_length;
   result.resize(UNI_MAX_UTF8_BYTES_PER_CODE_POINT *
 source_length); // worst case length
-  auto result_start = reinterpret_cast(&result[0]);
+  auto result_start = reinterpret_cast(&result[0]);
   const auto result_end = result_start + result.size();
-  ConvertUTF16toUTF8(&source_start, source_end, &result_start, result_end,
- strictConversion);
+  llvm::ConvertUTF16toUTF8(&source_start, source_end, &result_start, 
result_end,
+   llvm::ConversionFlags::strictConversion);
   const auto result_size =
-  std::distance(reinterpret_cast(&result[0]), result_start);
+  std::distance(reinterpret_cast(&result[0]), result_start);
   result.resize(result_size); // shrink to actual length
   return result;
 }


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


[Lldb-commits] [PATCH] D25099: Refactor Args a different way

2016-09-30 Thread Adrian McCarthy via lldb-commits
amccarth added a comment.

Just a drive by.



> Args.h:449
>//--
>// Classes that inherit from Args can see and modify these
>//--

This comment is no longer true given the change from protected to private just 
above.

> Args.cpp:96
> +ParseSingleArgument(llvm::StringRef command) {
> +  // Argument can be split into multiple discontiguous pieces, // for 
> example:
>//  "Hello ""World"

Minor formatting glitch with the `\\` in the comment.

> Args.cpp:192
> +//--
> +// We have to be very careful on the copy constructor of this class
> +// to make sure we copy all of the string values, but we can't copy the

This says "copy constructor" but it seems to be documenting the copy assignment 
operator.

> Args.cpp:195
> +// rhs.m_argv into m_argv since it will point to the "const char *" c
> +// strings in rhs.m_args. We need to copy the string list and update our
> +// own m_argv appropriately.

You got right of m_args, so maybe this whole comment needs a rewrite.

> Args.cpp:282
> +
> +  // Now m_argv might be out of date with m_args, so we need to fix that.
> +  // This happens because getopt_long_only may permute the order of the

`m_args` is gone.

https://reviews.llvm.org/D25099



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


[Lldb-commits] [PATCH] D25099: Refactor Args a different way

2016-09-30 Thread Zachary Turner via lldb-commits
zturner updated this revision to Diff 73099.
zturner added a comment.

Renamed `EntryData` to `ArgEntry` and made it public.  This will be useful 
later for providing iterator support over the entries.


https://reviews.llvm.org/D25099

Files:
  include/lldb/Interpreter/Args.h
  source/Core/StringList.cpp
  source/Interpreter/Args.cpp
  unittests/Interpreter/TestArgs.cpp

Index: unittests/Interpreter/TestArgs.cpp
===
--- unittests/Interpreter/TestArgs.cpp
+++ unittests/Interpreter/TestArgs.cpp
@@ -66,6 +66,109 @@
   EXPECT_STREQ(args.GetArgumentAtIndex(1), "second_arg");
 }
 
+TEST(ArgsTest, TestInsertArg) {
+  Args args;
+  args.AppendArgument("1");
+  args.AppendArgument("2");
+  args.AppendArgument("3");
+  args.InsertArgumentAtIndex(1, "1.5");
+  args.InsertArgumentAtIndex(4, "3.5");
+
+  ASSERT_EQ(5u, args.GetArgumentCount());
+  EXPECT_STREQ("1", args.GetArgumentAtIndex(0));
+  EXPECT_STREQ("1.5", args.GetArgumentAtIndex(1));
+  EXPECT_STREQ("2", args.GetArgumentAtIndex(2));
+  EXPECT_STREQ("3", args.GetArgumentAtIndex(3));
+  EXPECT_STREQ("3.5", args.GetArgumentAtIndex(4));
+}
+
+TEST(ArgsTest, TestArgv) {
+  Args args;
+  EXPECT_EQ(nullptr, args.GetArgumentVector()[0]);
+
+  args.AppendArgument("1");
+  EXPECT_NE(nullptr, args.GetArgumentVector()[0]);
+  EXPECT_EQ(nullptr, args.GetArgumentVector()[1]);
+
+  args.AppendArgument("2");
+  EXPECT_NE(nullptr, args.GetArgumentVector()[0]);
+  EXPECT_NE(nullptr, args.GetArgumentVector()[1]);
+  EXPECT_EQ(nullptr, args.GetArgumentVector()[2]);
+
+  args.AppendArgument("3");
+  EXPECT_NE(nullptr, args.GetArgumentVector()[0]);
+  EXPECT_NE(nullptr, args.GetArgumentVector()[1]);
+  EXPECT_NE(nullptr, args.GetArgumentVector()[2]);
+  EXPECT_EQ(nullptr, args.GetArgumentVector()[3]);
+
+  args.InsertArgumentAtIndex(1, "1.5");
+  EXPECT_NE(nullptr, args.GetArgumentVector()[0]);
+  EXPECT_NE(nullptr, args.GetArgumentVector()[1]);
+  EXPECT_NE(nullptr, args.GetArgumentVector()[2]);
+  EXPECT_NE(nullptr, args.GetArgumentVector()[3]);
+  EXPECT_EQ(nullptr, args.GetArgumentVector()[4]);
+
+  args.InsertArgumentAtIndex(4, "3.5");
+  EXPECT_NE(nullptr, args.GetArgumentVector()[0]);
+  EXPECT_NE(nullptr, args.GetArgumentVector()[1]);
+  EXPECT_NE(nullptr, args.GetArgumentVector()[2]);
+  EXPECT_NE(nullptr, args.GetArgumentVector()[3]);
+  EXPECT_NE(nullptr, args.GetArgumentVector()[4]);
+  EXPECT_EQ(nullptr, args.GetArgumentVector()[5]);
+}
+
+TEST(ArgsTest, GetQuotedCommandString) {
+  Args args;
+  const char *str = "process launch -o stdout.txt -- \"a b c\"";
+  args.SetCommandString(str);
+
+  std::string stdstr;
+  ASSERT_TRUE(args.GetQuotedCommandString(stdstr));
+  EXPECT_EQ(str, stdstr);
+}
+
+TEST(ArgsTest, BareSingleQuote) {
+  Args args;
+  args.SetCommandString("a\\'b");
+  EXPECT_EQ(1u, args.GetArgumentCount());
+
+  EXPECT_STREQ("a'b", args.GetArgumentAtIndex(0));
+}
+
+TEST(ArgsTest, DoubleQuotedItem) {
+  Args args;
+  args.SetCommandString("\"a b c\"");
+  EXPECT_EQ(1u, args.GetArgumentCount());
+
+  EXPECT_STREQ("a b c", args.GetArgumentAtIndex(0));
+}
+
+TEST(ArgsTest, AppendArguments) {
+  Args args;
+  const char *argv[] = {"1", "2", nullptr};
+  const char *argv2[] = {"3", "4", nullptr};
+
+  args.AppendArguments(argv);
+  ASSERT_EQ(2u, args.GetArgumentCount());
+  EXPECT_STREQ("1", args.GetArgumentVector()[0]);
+  EXPECT_STREQ("2", args.GetArgumentVector()[1]);
+  EXPECT_EQ(nullptr, args.GetArgumentVector()[2]);
+  EXPECT_STREQ("1", args.GetArgumentAtIndex(0));
+  EXPECT_STREQ("2", args.GetArgumentAtIndex(1));
+
+  args.AppendArguments(argv2);
+  ASSERT_EQ(4u, args.GetArgumentCount());
+  EXPECT_STREQ("1", args.GetArgumentVector()[0]);
+  EXPECT_STREQ("2", args.GetArgumentVector()[1]);
+  EXPECT_STREQ("3", args.GetArgumentVector()[2]);
+  EXPECT_STREQ("4", args.GetArgumentVector()[3]);
+  EXPECT_EQ(nullptr, args.GetArgumentVector()[4]);
+  EXPECT_STREQ("1", args.GetArgumentAtIndex(0));
+  EXPECT_STREQ("2", args.GetArgumentAtIndex(1));
+  EXPECT_STREQ("3", args.GetArgumentAtIndex(2));
+  EXPECT_STREQ("4", args.GetArgumentAtIndex(3));
+}
+
 TEST(ArgsTest, StringToBoolean) {
   bool success = false;
   EXPECT_TRUE(Args::StringToBoolean(llvm::StringRef("true"), false, nullptr));
Index: source/Interpreter/Args.cpp
===
--- source/Interpreter/Args.cpp
+++ source/Interpreter/Args.cpp
@@ -25,95 +25,12 @@
 #include "lldb/Target/StackFrame.h"
 #include "lldb/Target/Target.h"
 
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringSwitch.h"
 
 using namespace lldb;
 using namespace lldb_private;
 
-//--
-// Args constructor
-//--
-Args::Args(llvm::StringRef command) : m_args(), m_argv(), m_args_quote_char() {
-  SetCommandString(command);
-}
-
-//---

[Lldb-commits] [PATCH] D25099: Refactor Args a different way

2016-09-30 Thread Zachary Turner via lldb-commits
zturner updated this revision to Diff 73095.

https://reviews.llvm.org/D25099

Files:
  include/lldb/Interpreter/Args.h
  source/Core/StringList.cpp
  source/Interpreter/Args.cpp
  unittests/Interpreter/TestArgs.cpp

Index: unittests/Interpreter/TestArgs.cpp
===
--- unittests/Interpreter/TestArgs.cpp
+++ unittests/Interpreter/TestArgs.cpp
@@ -66,6 +66,109 @@
   EXPECT_STREQ(args.GetArgumentAtIndex(1), "second_arg");
 }
 
+TEST(ArgsTest, TestInsertArg) {
+  Args args;
+  args.AppendArgument("1");
+  args.AppendArgument("2");
+  args.AppendArgument("3");
+  args.InsertArgumentAtIndex(1, "1.5");
+  args.InsertArgumentAtIndex(4, "3.5");
+
+  ASSERT_EQ(5u, args.GetArgumentCount());
+  EXPECT_STREQ("1", args.GetArgumentAtIndex(0));
+  EXPECT_STREQ("1.5", args.GetArgumentAtIndex(1));
+  EXPECT_STREQ("2", args.GetArgumentAtIndex(2));
+  EXPECT_STREQ("3", args.GetArgumentAtIndex(3));
+  EXPECT_STREQ("3.5", args.GetArgumentAtIndex(4));
+}
+
+TEST(ArgsTest, TestArgv) {
+  Args args;
+  EXPECT_EQ(nullptr, args.GetArgumentVector()[0]);
+
+  args.AppendArgument("1");
+  EXPECT_NE(nullptr, args.GetArgumentVector()[0]);
+  EXPECT_EQ(nullptr, args.GetArgumentVector()[1]);
+
+  args.AppendArgument("2");
+  EXPECT_NE(nullptr, args.GetArgumentVector()[0]);
+  EXPECT_NE(nullptr, args.GetArgumentVector()[1]);
+  EXPECT_EQ(nullptr, args.GetArgumentVector()[2]);
+
+  args.AppendArgument("3");
+  EXPECT_NE(nullptr, args.GetArgumentVector()[0]);
+  EXPECT_NE(nullptr, args.GetArgumentVector()[1]);
+  EXPECT_NE(nullptr, args.GetArgumentVector()[2]);
+  EXPECT_EQ(nullptr, args.GetArgumentVector()[3]);
+
+  args.InsertArgumentAtIndex(1, "1.5");
+  EXPECT_NE(nullptr, args.GetArgumentVector()[0]);
+  EXPECT_NE(nullptr, args.GetArgumentVector()[1]);
+  EXPECT_NE(nullptr, args.GetArgumentVector()[2]);
+  EXPECT_NE(nullptr, args.GetArgumentVector()[3]);
+  EXPECT_EQ(nullptr, args.GetArgumentVector()[4]);
+
+  args.InsertArgumentAtIndex(4, "3.5");
+  EXPECT_NE(nullptr, args.GetArgumentVector()[0]);
+  EXPECT_NE(nullptr, args.GetArgumentVector()[1]);
+  EXPECT_NE(nullptr, args.GetArgumentVector()[2]);
+  EXPECT_NE(nullptr, args.GetArgumentVector()[3]);
+  EXPECT_NE(nullptr, args.GetArgumentVector()[4]);
+  EXPECT_EQ(nullptr, args.GetArgumentVector()[5]);
+}
+
+TEST(ArgsTest, GetQuotedCommandString) {
+  Args args;
+  const char *str = "process launch -o stdout.txt -- \"a b c\"";
+  args.SetCommandString(str);
+
+  std::string stdstr;
+  ASSERT_TRUE(args.GetQuotedCommandString(stdstr));
+  EXPECT_EQ(str, stdstr);
+}
+
+TEST(ArgsTest, BareSingleQuote) {
+  Args args;
+  args.SetCommandString("a\\'b");
+  EXPECT_EQ(1u, args.GetArgumentCount());
+
+  EXPECT_STREQ("a'b", args.GetArgumentAtIndex(0));
+}
+
+TEST(ArgsTest, DoubleQuotedItem) {
+  Args args;
+  args.SetCommandString("\"a b c\"");
+  EXPECT_EQ(1u, args.GetArgumentCount());
+
+  EXPECT_STREQ("a b c", args.GetArgumentAtIndex(0));
+}
+
+TEST(ArgsTest, AppendArguments) {
+  Args args;
+  const char *argv[] = {"1", "2", nullptr};
+  const char *argv2[] = {"3", "4", nullptr};
+
+  args.AppendArguments(argv);
+  ASSERT_EQ(2u, args.GetArgumentCount());
+  EXPECT_STREQ("1", args.GetArgumentVector()[0]);
+  EXPECT_STREQ("2", args.GetArgumentVector()[1]);
+  EXPECT_EQ(nullptr, args.GetArgumentVector()[2]);
+  EXPECT_STREQ("1", args.GetArgumentAtIndex(0));
+  EXPECT_STREQ("2", args.GetArgumentAtIndex(1));
+
+  args.AppendArguments(argv2);
+  ASSERT_EQ(4u, args.GetArgumentCount());
+  EXPECT_STREQ("1", args.GetArgumentVector()[0]);
+  EXPECT_STREQ("2", args.GetArgumentVector()[1]);
+  EXPECT_STREQ("3", args.GetArgumentVector()[2]);
+  EXPECT_STREQ("4", args.GetArgumentVector()[3]);
+  EXPECT_EQ(nullptr, args.GetArgumentVector()[4]);
+  EXPECT_STREQ("1", args.GetArgumentAtIndex(0));
+  EXPECT_STREQ("2", args.GetArgumentAtIndex(1));
+  EXPECT_STREQ("3", args.GetArgumentAtIndex(2));
+  EXPECT_STREQ("4", args.GetArgumentAtIndex(3));
+}
+
 TEST(ArgsTest, StringToBoolean) {
   bool success = false;
   EXPECT_TRUE(Args::StringToBoolean(llvm::StringRef("true"), false, nullptr));
Index: source/Interpreter/Args.cpp
===
--- source/Interpreter/Args.cpp
+++ source/Interpreter/Args.cpp
@@ -25,95 +25,12 @@
 #include "lldb/Target/StackFrame.h"
 #include "lldb/Target/Target.h"
 
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringSwitch.h"
 
 using namespace lldb;
 using namespace lldb_private;
 
-//--
-// Args constructor
-//--
-Args::Args(llvm::StringRef command) : m_args(), m_argv(), m_args_quote_char() {
-  SetCommandString(command);
-}
-
-//--
-// We have to be very careful on the copy constructor of this class
-// to make sure we copy all of the string values, but we can't c

[Lldb-commits] [lldb] r282898 - Fixed several i386 Objective-C tests by completing objects, not their pointers.

2016-09-30 Thread Sean Callanan via lldb-commits
Author: spyffe
Date: Fri Sep 30 13:44:43 2016
New Revision: 282898

URL: http://llvm.org/viewvc/llvm-project?rev=282898&view=rev
Log:
Fixed several i386 Objective-C tests by completing objects, not their pointers.

Modified:
lldb/trunk/source/Symbol/ClangASTContext.cpp

Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=282898&r1=282897&r2=282898&view=diff
==
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Fri Sep 30 13:44:43 2016
@@ -4463,19 +4463,22 @@ ClangASTContext::GetNumMemberFunctions(l
   }
   break;
 
-case clang::Type::ObjCObjectPointer:
-  if (GetCompleteType(type)) {
-const clang::ObjCObjectPointerType *objc_class_type =
-qual_type->getAsObjCInterfacePointerType();
-if (objc_class_type) {
-  clang::ObjCInterfaceDecl *class_interface_decl =
-  objc_class_type->getInterfaceDecl();
-  if (class_interface_decl)
-num_functions = std::distance(class_interface_decl->meth_begin(),
-  class_interface_decl->meth_end());
+case clang::Type::ObjCObjectPointer: {
+  const clang::ObjCObjectPointerType *objc_class_type =
+  qual_type->getAsObjCInterfacePointerType();
+  const clang::ObjCInterfaceType *objc_interface_type =
+  objc_class_type->getInterfaceType();
+  if (objc_interface_type &&
+  GetCompleteType((lldb::opaque_compiler_type_t)objc_interface_type)) {
+clang::ObjCInterfaceDecl *class_interface_decl =
+objc_interface_type->getDecl();
+if (class_interface_decl) {
+  num_functions = std::distance(class_interface_decl->meth_begin(),
+class_interface_decl->meth_end());
 }
   }
   break;
+}
 
 case clang::Type::ObjCObject:
 case clang::Type::ObjCInterface:
@@ -4568,34 +4571,36 @@ ClangASTContext::GetMemberFunctionAtInde
   }
   break;
 
-case clang::Type::ObjCObjectPointer:
-  if (GetCompleteType(type)) {
-const clang::ObjCObjectPointerType *objc_class_type =
-qual_type->getAsObjCInterfacePointerType();
-if (objc_class_type) {
-  clang::ObjCInterfaceDecl *class_interface_decl =
-  objc_class_type->getInterfaceDecl();
-  if (class_interface_decl) {
-auto method_iter = class_interface_decl->meth_begin();
-auto method_end = class_interface_decl->meth_end();
-if (idx <
-static_cast(std::distance(method_iter, method_end))) {
-  std::advance(method_iter, idx);
-  clang::ObjCMethodDecl *objc_method_decl =
-  method_iter->getCanonicalDecl();
-  if (objc_method_decl) {
-clang_decl = CompilerDecl(this, objc_method_decl);
-name = objc_method_decl->getSelector().getAsString();
-if (objc_method_decl->isClassMethod())
-  kind = lldb::eMemberFunctionKindStaticMethod;
-else
-  kind = lldb::eMemberFunctionKindInstanceMethod;
-  }
+case clang::Type::ObjCObjectPointer: {
+  const clang::ObjCObjectPointerType *objc_class_type =
+  qual_type->getAsObjCInterfacePointerType();
+  const clang::ObjCInterfaceType *objc_interface_type =
+  objc_class_type->getInterfaceType();
+  if (objc_interface_type &&
+  GetCompleteType((lldb::opaque_compiler_type_t)objc_interface_type)) {
+clang::ObjCInterfaceDecl *class_interface_decl =
+objc_interface_type->getDecl();
+if (class_interface_decl) {
+  auto method_iter = class_interface_decl->meth_begin();
+  auto method_end = class_interface_decl->meth_end();
+  if (idx <
+  static_cast(std::distance(method_iter, method_end))) {
+std::advance(method_iter, idx);
+clang::ObjCMethodDecl *objc_method_decl =
+method_iter->getCanonicalDecl();
+if (objc_method_decl) {
+  clang_decl = CompilerDecl(this, objc_method_decl);
+  name = objc_method_decl->getSelector().getAsString();
+  if (objc_method_decl->isClassMethod())
+kind = lldb::eMemberFunctionKindStaticMethod;
+  else
+kind = lldb::eMemberFunctionKindInstanceMethod;
 }
   }
 }
   }
   break;
+}
 
 case clang::Type::ObjCObject:
 case clang::Type::ObjCInterface:
@@ -5629,19 +5634,21 @@ uint32_t ClangASTContext::GetNumFields(l
 .GetNumFields();
 break;
 
-  case clang::Type::ObjCObjectPointer:
-if (GetCompleteType(type)) {
-  const clang::ObjCObjectPointerType *objc_cl

Re: [Lldb-commits] [lldb] r282683 - Add a unit test for an x86_64 assembly inspection of

2016-09-30 Thread Jason Molenda via lldb-commits
Thanks for the help!  It took me most of yesterday to get gcc-4.9 built (it's 
been more than a decade since I've built gcc) - I think I've got it set up now, 
so I'll figure this out today.  I'm in the middle of looking into a bug in the 
32-bit assembly assembly instruction unwind plan creation that I turned up 
while writing a unit test, but I'll look at this as soon as I'm done with that.

J

> On Sep 30, 2016, at 5:27 AM, Pavel Labath  wrote:
> 
> I made a quick investigation today. The problem is indeed specific to 
> gcc-4.9. The main differences I could see is that gcc-4.9 generates a 
> different prologue for the function, and uses pushl for argument passing. 
> This confuses the emulator/augmenter and the unwind information at some 
> points ends up being incorrect. Since the problem starts to occur after the 
> first pushl instruction, i am guessing the problem is with those. I'll try to 
> investigate more next week.
> 
>  For reference, the function with 4.9 looks like this:
> 
> a.out`main:
> 
> 0x80484eb <+0>:   leal   0x4(%esp), %ecx
> 
> 0x80484ef <+4>:   andl   $-0x10, %esp
> 
> 0x80484f2 <+7>:   pushl  -0x4(%ecx)
> 
> 0x80484f5 <+10>:  pushl  %ebp
> 
> 0x80484f6 <+11>:  movl   %esp, %ebp
> 
> 0x80484f8 <+13>:  pushl  %edi
> 
> 0x80484f9 <+14>:  pushl  %esi
> 
> 0x80484fa <+15>:  pushl  %ebx
> 
> 0x80484fb <+16>:  pushl  %ecx
> 
> 0x80484fc <+17>:  subl   $0x28, %esp
> 
> 0x80484ff <+20>:  subl   $0xc, %esp
> 
> 0x8048502 <+23>:  pushl  $0x18
> 
> 0x8048504 <+25>:  calll  0x80483d0 ; symbol stub for: 
> operator new[](unsigned int)
> 
> 0x8048509 <+30>:  addl   $0x10, %esp
> 
> 0x804850c <+33>:  movl   %eax, %edi
> 
> 0x804850e <+35>:  movl   %edi, %eax
> 
> 0x8048510 <+37>:  movl   $0x1, %esi
> 
> 0x8048515 <+42>:  movl   %eax, %ebx
> 
> 0x8048517 <+44>:  jmp0x804852b ; <+64> at main.cpp:26
> 
> 0x8048519 <+46>:  subl   $0xc, %esp
> 
> 0x804851c <+49>:  pushl  %ebx
> 
> 0x804851d <+50>:  calll  0x80485cc ; foo::foo at 
> main.cpp:16
> 
> 0x8048522 <+55>:  addl   $0x10, %esp
> 
> 0x8048525 <+58>:  addl   $0xc, %ebx
> 
> 0x8048528 <+61>:  subl   $0x1, %esi
> 
> 0x804852b <+64>:  cmpl   $-0x1, %esi
> 
> 0x804852e <+67>:  jne0x8048519 ; <+46> at main.cpp:26
> 
> 0x8048530 <+69>:  movl   %edi, -0x1c(%ebp)
> 
> 0x8048533 <+72>:  movl   -0x1c(%ebp), %eax
> 
> 0x8048536 <+75>:  movl   $0x1, (%eax)
> 
> 0x804853c <+81>:  movl   -0x1c(%ebp), %eax
> 
> 0x804853f <+84>:  movl   $0x9, 0x4(%eax)
> 
> 0x8048546 <+91>:  movl   -0x1c(%ebp), %eax
> 
> 0x8048549 <+94>:  addl   $0xc, %eax
> 
> 0x804854c <+97>:  movl   $0x8, (%eax)
> 
> 0x8048552 <+103>: movl   -0x1c(%ebp), %eax
> 
> 0x8048555 <+106>: addl   $0xc, %eax
> 
> 0x8048558 <+109>: movl   $0x5, 0x4(%eax)
> 
> 0x804855f <+116>: movl   -0x1c(%ebp), %eax
> 
> 0x8048562 <+119>: addl   $0xc, %eax
> 
> 0x8048565 <+122>: movl   $0x7, 0x4(%eax)
> 
> 0x804856c <+129>: movl   -0x1c(%ebp), %eax
> 
> 0x804856f <+132>: leal   0xc(%eax), %edx
> 
> 0x8048572 <+135>: movl   0x80486a4, %eax
> 
> 0x8048577 <+140>: movl   %eax, 0x8(%edx)
> 
> 0x804857a <+143>: leal   -0x34(%ebp), %ebx
> 
> 0x804857d <+146>: movl   0x80486a8, %eax
> 
> 0x8048582 <+151>: pushl  %eax
> 
> 0x8048583 <+152>: pushl  $0x2
> 
> 0x8048585 <+154>: pushl  $0x1
> 
> 0x8048587 <+156>: pushl  %ebx
> 
> ->  0x8048588 <+157>: calll  0x80485f0 ; foo::foo at 
> main.cpp:17
> 
> 0x804858d <+162>: addl   $0x10, %esp
> 
> 0x8048590 <+165>: leal   0xc(%ebx), %edx
> 
> 0x8048593 <+168>: movl   0x80486ac, %eax
> 
> 0x8048598 <+173>: pushl  %eax
> 
> 0x8048599 <+174>: pushl  $0x5
> 
> 0x804859b <+176>: pushl  $0x4
> 
> 0x804859d <+178>: pushl  %edx
> 
> 0x804859e <+179>: calll  0x80485f0 ; foo::foo at 
> main.cpp:17
> 
> 0x80485a3 <+184>: addl   $0x10, %esp
> 
> 0x80485a6 <+187>: cmpl   $0x0, -0x1c(%ebp)
> 
> 0x80485aa <+191>: je 0x80485ba ; <+207> at main.cpp:42
> 
> 0x80485ac <+193>: subl   $0xc, %esp
> 
> 0x80485af <+196>: pushl  -0x1c(%ebp)
> 
> 0x80485b2 <+199>: calll  0x80483e0 ; symbol stub for: 
> operator delete[](void*)
> 
> 0x80485b7 <+204>: addl   $0x10, %esp
> 
> 0x80485ba <+207>: movl   $0x0, %eax
> 
> 0x80485bf <+212>: leal   -0x10(%ebp), %esp
> 
> 0x80485c2 <+215>: popl   %ecx
> 
> 0x80485c3 <+216>: popl   %ebx
> 
> 0x80485c4 <+217>: popl   %esi
> 
> 0x80485c5 <+218>: popl   %edi
> 
> 0x80485c6 <+219>: popl   %ebp
> 
> 0x80485c7 <+220>: leal   -0x4(%ecx), %esp
> 
> 0x80485ca <+223>: retl   
> 
> 
> 
> 
> 
> whereas the same function compiled with gcc-4.8 is this:
> 
> 0x804850d <+0>:   pushl  %ebp
> 
> 0x804850e <+1>:   movl   %esp, %ebp
> 
> 0x8048

[Lldb-commits] [lldb] r282941 - Fix comment - Module::PrepareForFunctionNameLookup should be Module::LookupInfo::LookupInfo.

2016-09-30 Thread Dawn Perchik via lldb-commits
Author: dperchik
Date: Fri Sep 30 15:38:33 2016
New Revision: 282941

URL: http://llvm.org/viewvc/llvm-project?rev=282941&view=rev
Log:
Fix comment - Module::PrepareForFunctionNameLookup should be 
Module::LookupInfo::LookupInfo.

Modified:
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/trunk/source/Symbol/Symtab.cpp

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=282941&r1=282940&r2=282941&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Fri Sep 30 
15:38:33 2016
@@ -2395,7 +2395,7 @@ SymbolFileDWARF::FindFunctions(const Con
  name.AsCString());
 
   // eFunctionNameTypeAuto should be pre-resolved by a call to
-  // Module::PrepareForFunctionNameLookup()
+  // Module::LookupInfo::LookupInfo()
   assert((name_type_mask & eFunctionNameTypeAuto) == 0);
 
   Log *log(LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS));

Modified: lldb/trunk/source/Symbol/Symtab.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Symtab.cpp?rev=282941&r1=282940&r2=282941&view=diff
==
--- lldb/trunk/source/Symbol/Symtab.cpp (original)
+++ lldb/trunk/source/Symbol/Symtab.cpp Fri Sep 30 15:38:33 2016
@@ -1069,7 +1069,7 @@ size_t Symtab::FindFunctionSymbols(const
   const char *name_cstr = name.GetCString();
 
   // eFunctionNameTypeAuto should be pre-resolved by a call to
-  // Module::PrepareForFunctionNameLookup()
+  // Module::LookupInfo::LookupInfo()
   assert((name_type_mask & eFunctionNameTypeAuto) == 0);
 
   if (name_type_mask & (eFunctionNameTypeBase | eFunctionNameTypeFull)) {


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


[Lldb-commits] [lldb] r282943 - Adding ivars in class extensions isn't supported on i386; skip a test.

2016-09-30 Thread Sean Callanan via lldb-commits
Author: spyffe
Date: Fri Sep 30 15:46:09 2016
New Revision: 282943

URL: http://llvm.org/viewvc/llvm-project?rev=282943&view=rev
Log:
Adding ivars in class extensions isn't supported on i386; skip a test.

Modified:

lldb/trunk/packages/Python/lldbsuite/test/expression_command/persist_objc_pointeetype/TestPersistObjCPointeeType.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/persist_objc_pointeetype/TestPersistObjCPointeeType.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/persist_objc_pointeetype/TestPersistObjCPointeeType.py?rev=282943&r1=282942&r2=282943&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/persist_objc_pointeetype/TestPersistObjCPointeeType.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/persist_objc_pointeetype/TestPersistObjCPointeeType.py
 Fri Sep 30 15:46:09 2016
@@ -25,6 +25,7 @@ class PersistObjCPointeeType(TestBase):
 @expectedFailureAll(
 bugnumber='http://llvm.org/pr23504',
 oslist=['macosx'], compiler='clang', compiler_version=['<', '7.0.0'])
+@skipIf(archs=["i386", "i686"])
 def test_with(self):
 """Test that we can p *objcObject"""
 self.build()


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


[Lldb-commits] [lldb] r282966 - IsValid is the way to ask a breakpoint location whether it is valid.

2016-09-30 Thread Jim Ingham via lldb-commits
Author: jingham
Date: Fri Sep 30 17:07:41 2016
New Revision: 282966

URL: http://llvm.org/viewvc/llvm-project?rev=282966&view=rev
Log:
IsValid is the way to ask a breakpoint location whether it is valid.

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/TestBreakpointCaseSensitivity.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/TestBreakpointCaseSensitivity.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/TestBreakpointCaseSensitivity.py?rev=282966&r1=282965&r2=282966&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/TestBreakpointCaseSensitivity.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/TestBreakpointCaseSensitivity.py
 Fri Sep 30 17:07:41 2016
@@ -27,7 +27,7 @@ class BreakpointCaseSensitivityTestCase(
 
 @skipIf(oslist=['windows'])  # Skip for windows platforms
 # Failing for unknown reason on non-Windows platforms.
-@expectedFailureAll()
+
 def test_breakpoint_doesnt_match_file_with_different_case(self):
 """Set breakpoint on file, shouldn't match files with different case 
on POSIX systems"""
 self.build()
@@ -98,7 +98,8 @@ class BreakpointCaseSensitivityTestCase(
 # Get the breakpoint location from breakpoint after we verified that,
 # indeed, it has one location.
 location = breakpoint.GetLocationAtIndex(0)
-self.assertEqual(location and location.IsEnabled(),
+
+self.assertEqual(location.IsValid(),
  should_hit,
  VALID_BREAKPOINT_LOCATION + desc)
 


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


[Lldb-commits] [PATCH] D25137: [lldbmi] Fix prompt which can get inserted in the middle of lldb-mi output

2016-09-30 Thread Dawn Perchik via lldb-commits
dawn created this revision.
dawn added reviewers: ted, zturner, clayborg.
dawn added subscribers: amccarth, lldb-commits.
dawn set the repository for this revision to rL LLVM.

The code added in svn trunk 264332 causes "(lldb)" to be printed in the middle 
of program console output.   This fix restores the behavior for non-Windows 
platforms to before the patch.

From a C++ program with the following source:

  ...
  printf("\n#Break: Function parameters - arrays");
  printf("\n#Evaluate:A[0]-C[0] + (A[1]-C[1])*1000 #ExpectedEval:%d", 1001);
  printf("\n#Evaluate:FuncArr(C,B) #ExpectedEval:%d", RES);
  printf("\n#Evaluate:A[0]-C[0] + (A[1]-C[1])*1000 + 0 #ExpectedEval:%d", 0);
  printf("\n#Evaluate:ref[0] + ref[1]*10 #ExpectedEval:%d", 65);
  printf("\n#Evaluate:FuncArrRet(7,8) #ExpectedLike:deferred");
  ...

produce the following output on iOS:

  #Break: Function parameters - arrays
  #Evaluate:A[0]-C[0] + (A[1]-C[1])*1000 #ExpectedEval:1001
  #Evaluate:FuncArr(C,B) #ExpectedEval:4321
  #Evaluate:A[0]-C[0] + (A[1]-C[1])*1000 + 0 #ExpectedEval:0
  #Evaluate:ref[0] + ref[1]*10 #ExpectedEval:65
  #Evalua(lldb) te:FuncArrRet(7,8) #ExpectedLike:deferred
  ...

Note the "(lldb) " inserted into the program output of the 6th print statement.


Repository:
  rL LLVM

https://reviews.llvm.org/D25137

Files:
  source/Core/IOHandler.cpp


Index: source/Core/IOHandler.cpp
===
--- source/Core/IOHandler.cpp
+++ source/Core/IOHandler.cpp
@@ -590,8 +590,8 @@
   else
 #endif
   {
+#ifdef _MSC_VER
 const char *prompt = GetPrompt();
-#ifdef _MSC_VER
 if (prompt) {
   // Back up over previous prompt using Windows API
   CONSOLE_SCREEN_BUFFER_INFO screen_buffer_info;
@@ -605,9 +605,11 @@
 }
 #endif
 IOHandler::PrintAsync(stream, s, len);
+#ifdef _MSC_VER
 if (prompt)
   IOHandler::PrintAsync(GetOutputStreamFile().get(), prompt,
 strlen(prompt));
+#endif
   }
 }
 


Index: source/Core/IOHandler.cpp
===
--- source/Core/IOHandler.cpp
+++ source/Core/IOHandler.cpp
@@ -590,8 +590,8 @@
   else
 #endif
   {
+#ifdef _MSC_VER
 const char *prompt = GetPrompt();
-#ifdef _MSC_VER
 if (prompt) {
   // Back up over previous prompt using Windows API
   CONSOLE_SCREEN_BUFFER_INFO screen_buffer_info;
@@ -605,9 +605,11 @@
 }
 #endif
 IOHandler::PrintAsync(stream, s, len);
+#ifdef _MSC_VER
 if (prompt)
   IOHandler::PrintAsync(GetOutputStreamFile().get(), prompt,
 strlen(prompt));
+#endif
   }
 }
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r282969 - Add the radar from our end to the bugreport string.

2016-09-30 Thread Jim Ingham via lldb-commits
Author: jingham
Date: Fri Sep 30 17:22:09 2016
New Revision: 282969

URL: http://llvm.org/viewvc/llvm-project?rev=282969&view=rev
Log:
Add the radar from our end to the bugreport string.

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py?rev=282969&r1=282968&r2=282969&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
 Fri Sep 30 17:22:09 2016
@@ -300,7 +300,7 @@ class CommandLineCompletionTestCase(Test
 @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679")
 @expectedFailureAll(
 oslist=lldbplatform.darwin_all,
-bugnumber="llvm.org/pr25485")
+bugnumber="llvm.org/pr25485,")
 def test_symbol_name(self):
 self.build()
 self.complete_from_to('''file a.out


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


[Lldb-commits] [lldb] r282970 - Add the radar on our end to the bugreport string.

2016-09-30 Thread Jim Ingham via lldb-commits
Author: jingham
Date: Fri Sep 30 17:24:11 2016
New Revision: 282970

URL: http://llvm.org/viewvc/llvm-project?rev=282970&view=rev
Log:
Add the radar on our end to the bugreport string.

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/TestCreateDuringStep.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/TestCreateDuringStep.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/TestCreateDuringStep.py?rev=282970&r1=282969&r2=282970&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/TestCreateDuringStep.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/TestCreateDuringStep.py
 Fri Sep 30 17:24:11 2016
@@ -22,7 +22,7 @@ class CreateDuringStepTestCase(TestBase)
 bugnumber="llvm.org/pr15824 thread states not properly maintained")
 @expectedFailureAll(
 oslist=lldbplatformutil.getDarwinOSTriples(),
-bugnumber="llvm.org/pr15824 thread states not properly maintained")
+bugnumber="llvm.org/pr15824 thread states not properly maintained, 
")
 @expectedFailureAll(
 oslist=["freebsd"],
 bugnumber="llvm.org/pr18190 thread states not properly maintained")
@@ -41,7 +41,7 @@ class CreateDuringStepTestCase(TestBase)
 bugnumber="llvm.org/pr15824 thread states not properly maintained")
 @expectedFailureAll(
 oslist=lldbplatformutil.getDarwinOSTriples(),
-bugnumber="llvm.org/pr15824 thread states not properly maintained")
+bugnumber="llvm.org/pr15824 thread states not properly maintained, 
")
 @expectedFailureAll(
 oslist=["freebsd"],
 bugnumber="llvm.org/pr18190 thread states not properly maintained")
@@ -60,7 +60,7 @@ class CreateDuringStepTestCase(TestBase)
 bugnumber="llvm.org/pr15824 thread states not properly maintained")
 @expectedFailureAll(
 oslist=lldbplatformutil.getDarwinOSTriples(),
-bugnumber="llvm.org/pr15824 thread states not properly maintained")
+bugnumber="llvm.org/pr15824 thread states not properly maintained, 
")
 @expectedFailureAll(
 oslist=["freebsd"],
 bugnumber="llvm.org/pr18190 thread states not properly maintained")


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


[Lldb-commits] [PATCH] D25137: [lldbmi] Fix prompt which can get inserted in the middle of lldb-mi output

2016-09-30 Thread Ted Woodward via lldb-commits
ted accepted this revision.
ted added a comment.
This revision is now accepted and ready to land.

The problem this scenario has is asynchronous output from 2 different sources. 
The original fix made Windows (or any lldb without libedit) much better, but I 
think most non-Windows builds will use libedit, because it's extremely useful. 
lldb-mi has a different set of constraints; the position of the prompt isn't as 
important, since users won't use it as a cue to tell when the debugger can 
accept more input.

Since this improves lldb-mi, and only hurts a use case I think is not very 
prevalent (LLDB_DISABLE_LIBEDIT on a non-Windows platform), I think it's OK. 
LGTM.


Repository:
  rL LLVM

https://reviews.llvm.org/D25137



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


[Lldb-commits] [lldb] r282976 - Fix up the test so it gets closer to passing.

2016-09-30 Thread Jim Ingham via lldb-commits
Author: jingham
Date: Fri Sep 30 17:55:57 2016
New Revision: 282976

URL: http://llvm.org/viewvc/llvm-project?rev=282976&view=rev
Log:
Fix up the test so it gets closer to passing.

Remove the test for thread stopped states from this test.  
That isn't set properly now, and its setting doesn't matter till we actually 
support non-stop debugging, so
we shouldn't have unrelated tests failing from it.

Also changed some code that was trying and failing to grub command line output, 
and replaced
it by SB API calls.

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/TestCreateDuringStep.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/TestCreateDuringStep.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/TestCreateDuringStep.py?rev=282976&r1=282975&r2=282976&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/TestCreateDuringStep.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/TestCreateDuringStep.py
 Fri Sep 30 17:55:57 2016
@@ -60,7 +60,7 @@ class CreateDuringStepTestCase(TestBase)
 bugnumber="llvm.org/pr15824 thread states not properly maintained")
 @expectedFailureAll(
 oslist=lldbplatformutil.getDarwinOSTriples(),
-bugnumber="llvm.org/pr15824 thread states not properly maintained, 
")
+bugnumber="")
 @expectedFailureAll(
 oslist=["freebsd"],
 bugnumber="llvm.org/pr18190 thread states not properly maintained")
@@ -86,30 +86,21 @@ class CreateDuringStepTestCase(TestBase)
 exe = os.path.join(os.getcwd(), "a.out")
 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
 
-# This should create a breakpoint in the stepping thread.
-self.bp_num = lldbutil.run_break_set_by_file_and_line(
-self, "main.cpp", self.breakpoint, num_expected_locations=1)
+# Get the target process
+target = self.dbg.GetSelectedTarget()
 
-# The breakpoint list should show 1 location.
-self.expect(
-"breakpoint list -f",
-"Breakpoint location shown correctly",
-substrs=[
-"1: file = 'main.cpp', line = %d, locations = 1" %
-self.breakpoint])
+# This should create a breakpoint in the stepping thread.
+self.bkpt = target.BreakpointCreateByLocation("main.cpp", 
self.breakpoint) 
 
 # Run the program.
 self.runCmd("run", RUN_SUCCEEDED)
 
-# The stop reason of the thread should be breakpoint.
-self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
-substrs=['stopped',
- 'stop reason = breakpoint'])
-
-# Get the target process
-target = self.dbg.GetSelectedTarget()
 process = target.GetProcess()
 
+# The stop reason of the thread should be breakpoint.
+stepping_thread = 
lldbutil.get_one_thread_stopped_at_breakpoint(process, self.bkpt)
+self.assertTrue(stepping_thread.IsValid(), "We stopped at the right 
breakpoint")
+
 # Get the number of threads
 num_threads = process.GetNumThreads()
 
@@ -122,25 +113,6 @@ class CreateDuringStepTestCase(TestBase)
 thread1 = process.GetThreadAtIndex(0)
 thread2 = process.GetThreadAtIndex(1)
 
-# Make sure both threads are stopped
-self.assertTrue(
-thread1.IsStopped(),
-"Thread 1 didn't stop during breakpoint")
-self.assertTrue(
-thread2.IsStopped(),
-"Thread 2 didn't stop during breakpoint")
-
-# Find the thread that is stopped at the breakpoint
-stepping_thread = None
-for thread in process:
-expected_bp_desc = "breakpoint %s." % self.bp_num
-if expected_bp_desc in thread.GetStopDescription(100):
-stepping_thread = thread
-break
-self.assertTrue(
-stepping_thread is not None,
-"unable to find thread stopped at %s" %
-expected_bp_desc)
 current_line = self.breakpoint
 # Keep stepping until we've reached our designated continue point
 while current_line != self.continuepoint:
@@ -170,9 +142,8 @@ class CreateDuringStepTestCase(TestBase)
 num_threads == 3,
 'Number of expected threads and actual threads do not match after 
thread exit.')
 
-self.expect("thread list", 'Process state is stopped due to step',
-substrs=['stopped',
- step_stop_reason])
+stop_reason = stepping_thread.GetStopReason()
+self.assertEqual(stop_reason, lldb.eStopReasonPlanComplete, "Stopped 
for plan completion")
 

[Lldb-commits] [lldb] r282990 - test infra: clear file-charged issues on rerun of file

2016-09-30 Thread Todd Fiala via lldb-commits
Author: tfiala
Date: Fri Sep 30 19:17:08 2016
New Revision: 282990

URL: http://llvm.org/viewvc/llvm-project?rev=282990&view=rev
Log:
test infra: clear file-charged issues on rerun of file

This change addresses the corner case bug in the test
infrastructure where a test file times out *outside*
of any running test method.  In those cases, the issue
was charged to the file, not to a test method within
the file.  When that file is re-run successfully,
none of the test-method-level successes would clear
the file-level issue.

This change fixes that: for all test files that are
getting rerun (whether by being marked flaky or
via the --rerun-all-issues flag), file-level test
issues are searched for in each of those files.  Each
file-level issue found in the rerun file list then
gets cleared.

A test of this feature is added to issue_verification,
using the technique there of moving the *.py.park file
to *.py to do an end-to-end validation.

This change also adds a .gitignore entry for pyenv
project-level files and fixes up a few minor pep8
formatting violations in files I touched.

Fixes:
llvm.org/pr27423

Added:

lldb/trunk/packages/Python/lldbsuite/test/issue_verification/TestRerunFileLevelTimeout.py.park
Modified:
lldb/trunk/.gitignore
lldb/trunk/packages/Python/lldbsuite/test/dosep.py

lldb/trunk/packages/Python/lldbsuite/test_event/formatter/results_formatter.py

Modified: lldb/trunk/.gitignore
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/.gitignore?rev=282990&r1=282989&r2=282990&view=diff
==
--- lldb/trunk/.gitignore (original)
+++ lldb/trunk/.gitignore Fri Sep 30 19:17:08 2016
@@ -16,6 +16,8 @@
 # Byte compiled python modules.
 *.pyc
 *.pyproj
+# pyenv settings
+.python-version
 *.sln
 *.suo
 # vim swap files

Modified: lldb/trunk/packages/Python/lldbsuite/test/dosep.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/dosep.py?rev=282990&r1=282989&r2=282990&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/dosep.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/dosep.py Fri Sep 30 19:17:08 2016
@@ -1151,8 +1151,11 @@ def inprocess_exec_test_runner(test_work
runner_context)
 
 # We're always worker index 0
+def get_single_worker_index():
+return 0
+
 global GET_WORKER_INDEX
-GET_WORKER_INDEX = lambda: 0
+GET_WORKER_INDEX = get_single_worker_index
 
 # Run the listener and related channel maps in a separate thread.
 # global RUNNER_PROCESS_ASYNC_MAP
@@ -1443,7 +1446,8 @@ def adjust_inferior_options(dotest_argv)
 # every dotest invocation from creating its own directory
 import datetime
 # The windows platforms don't like ':' in the pathname.
-timestamp_started = 
datetime.datetime.now().strftime("%Y-%m-%d-%H_%M_%S")
+timestamp_started = (datetime.datetime.now()
+ .strftime("%Y-%m-%d-%H_%M_%S"))
 dotest_argv.append('-s')
 dotest_argv.append(timestamp_started)
 dotest_options.s = timestamp_started
@@ -1627,7 +1631,8 @@ def main(num_threads, test_subdir, test_
 test_subdir = os.path.join(test_directory, test_subdir)
 if not os.path.isdir(test_subdir):
 print(
-'specified test subdirectory {} is not a valid 
directory\n'.format(test_subdir))
+'specified test subdirectory {} is not a valid directory\n'
+.format(test_subdir))
 else:
 test_subdir = test_directory
 
@@ -1696,6 +1701,12 @@ def main(num_threads, test_subdir, test_
 print("\n{} test files marked for rerun\n".format(
 rerun_file_count))
 
+# Clear errors charged to any of the files of the tests that
+# we are rerunning.
+# https://llvm.org/bugs/show_bug.cgi?id=27423
+results_formatter.clear_file_level_issues(tests_for_rerun,
+  sys.stdout)
+
 # Check if the number of files exceeds the max cutoff.  If so,
 # we skip the rerun step.
 if rerun_file_count > configuration.rerun_max_file_threshold:

Added: 
lldb/trunk/packages/Python/lldbsuite/test/issue_verification/TestRerunFileLevelTimeout.py.park
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/issue_verification/TestRerunFileLevelTimeout.py.park?rev=282990&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/issue_verification/TestRerunFileLevelTimeout.py.park
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/issue_verification/TestRerunFileLevelTimeout.py.park
 Fri Sep 30 19:17:08 2016
@@ -0,0 +1,33 @@
+"""Tests that a timeout is detecte

[Lldb-commits] [lldb] r282991 - Add support for some extended push instructions in i386/x86_64 like

2016-09-30 Thread Jason Molenda via lldb-commits
Author: jmolenda
Date: Fri Sep 30 19:19:26 2016
New Revision: 282991

URL: http://llvm.org/viewvc/llvm-project?rev=282991&view=rev
Log:
Add support for some extended push instructions in i386/x86_64 like
'push 0x20(%esp)' which clang can generate when emitting
-fomit-frame-pointer code for 32-bit.

Add a unit test program which includes this instruction.

Also fix a bug in the refactoring/rewrite of the x86 assembly
instruction profiler where I'd hard coded it as a 64-bit disassembler
instead of using the ArchSpec to pick a 32-bit or 64-bit disassembler
from llvm.  When the disassembler would hit an instruction
that is invalid in 64-bit mode, it would stop disassembling the function.
This likely led to the TestSBData testsuite failure on linux with 32-bit
i386 and gcc-4.9; I'll test that in a bit.

The newly added unit test program is 32-bit i386 code and it includes
an instruction which is invalid in 64-bit mode so it will catch this.

 


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

Modified: 
lldb/trunk/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp?rev=282991&r1=282990&r2=282991&view=diff
==
--- 
lldb/trunk/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp 
(original)
+++ 
lldb/trunk/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp 
Fri Sep 30 19:19:26 2016
@@ -29,10 +29,9 @@ x86AssemblyInspectionEngine::x86Assembly
 
   m_reg_map(), m_arch(arch), m_cpu(k_cpu_unspecified), m_wordsize(-1),
   m_register_map_initialized(false), m_disasm_context() {
-  m_disasm_context = ::LLVMCreateDisasm("x86_64-apple-macosx", nullptr,
-/*TagType=*/1, nullptr, nullptr);
-  //  ::LLVMCreateDisasm(arch.GetTriple().getTriple().c_str(), nullptr,
-  // /*TagType=*/1, nullptr, nullptr);
+  m_disasm_context =
+  ::LLVMCreateDisasm(arch.GetTriple().getTriple().c_str(), nullptr,
+ /*TagType=*/1, nullptr, nullptr);
 }
 
 x86AssemblyInspectionEngine::~x86AssemblyInspectionEngine() {
@@ -320,6 +319,50 @@ bool x86AssemblyInspectionEngine::push_i
   return false;
 }
 
+// pushl imm8(%esp)
+//
+// e.g. 0xff 0x74 0x24 0x20 - 'pushl 0x20(%esp)'
+// (same byte pattern for 'pushq 0x20(%rsp)' in an x86_64 program)
+//
+// 0xff (with opcode bits '6' in next byte, PUSH r/m32)
+// 0x74 (ModR/M byte with three bits used to specify the opcode)
+//  mod == b01, opcode == b110, R/M == b100
+//  "+disp8"
+// 0x24 (SIB byte - scaled index = 0, r32 == esp)
+// 0x20 imm8 value
+
+bool x86AssemblyInspectionEngine::push_extended_pattern_p() {
+  if (*m_cur_insn == 0xff) {
+// Get the 3 opcode bits from the ModR/M byte
+uint8_t opcode = (*(m_cur_insn + 1) >> 3) & 7;
+if (opcode == 6) {
+  // I'm only looking for 0xff /6 here - I
+  // don't really care what value is being pushed,
+  // just that we're pushing a 32/64 bit value on
+  // to the stack is enough.
+  return true;
+}
+  }
+  return false;
+}
+
+// pushq %rbx
+// pushl %ebx
+bool x86AssemblyInspectionEngine::push_reg_p(int ®no) {
+  uint8_t *p = m_cur_insn;
+  int regno_prefix_bit = 0;
+  // If we have a rex prefix byte, check to see if a B bit is set
+  if (m_wordsize == 8 && *p == 0x41) {
+regno_prefix_bit = 1 << 3;
+p++;
+  }
+  if (*p >= 0x50 && *p <= 0x57) {
+regno = (*p - 0x50) | regno_prefix_bit;
+return true;
+  }
+  return false;
+}
+
 // movq %rsp, %rbp [0x48 0x8b 0xec] or [0x48 0x89 0xe5]
 // movl %esp, %ebp [0x8b 0xec] or [0x89 0xe5]
 bool x86AssemblyInspectionEngine::mov_rsp_rbp_pattern_p() {
@@ -395,23 +438,6 @@ bool x86AssemblyInspectionEngine::lea_rs
   return false;
 }
 
-// pushq %rbx
-// pushl %ebx
-bool x86AssemblyInspectionEngine::push_reg_p(int ®no) {
-  uint8_t *p = m_cur_insn;
-  int regno_prefix_bit = 0;
-  // If we have a rex prefix byte, check to see if a B bit is set
-  if (m_wordsize == 8 && *p == 0x41) {
-regno_prefix_bit = 1 << 3;
-p++;
-  }
-  if (*p >= 0x50 && *p <= 0x57) {
-regno = (*p - 0x50) | regno_prefix_bit;
-return true;
-  }
-  return false;
-}
-
 // popq %rbx
 // popl %ebx
 bool x86AssemblyInspectionEngine::pop_reg_p(int ®no) {
@@ -762,6 +788,14 @@ bool x86AssemblyInspectionEngine::GetNon
   in_epilogue = true;
 }
 
+else if (push_extended_pattern_p() || push_imm_pattern_p()) {
+  current_sp_bytes_offset_from_cfa += m_wordsize;
+  if (row->GetCFAValue().GetRegisterNumber() == m_lldb_sp_regnum) {
+row->GetCFAValue().SetOffset(current_sp_bytes_offset_from_cfa);
+row_updated = true;
+  }
+}

[Lldb-commits] [lldb] r282993 - Fix up this test case.

2016-09-30 Thread Jim Ingham via lldb-commits
Author: jingham
Date: Fri Sep 30 19:49:12 2016
New Revision: 282993

URL: http://llvm.org/viewvc/llvm-project?rev=282993&view=rev
Log:
Fix up this test case.

The lldbutil.run_break_set_by_file_and_line has already checked that the number 
of 
locations was 1, so don't check it again.  And certainly don't check it again 
by 
grubbing in break list output.

Also, we know the Thread's IsStopped state is wrong, and have a test for that, 
so 
don't keep testing it in other files where that isn't the primary thing we're 
testing.

I removed the xfail for Darwin.  If this also passes on other systems, we can 
remove
the xfails from them as we find that out.

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/TestExitDuringBreak.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/TestExitDuringBreak.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/TestExitDuringBreak.py?rev=282993&r1=282992&r2=282993&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/TestExitDuringBreak.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/TestExitDuringBreak.py
 Fri Sep 30 19:49:12 2016
@@ -27,9 +27,6 @@ class ExitDuringBreakpointTestCase(TestB
 oslist=["linux"],
 bugnumber="llvm.org/pr15824 thread states not properly maintained")
 @expectedFailureAll(
-oslist=lldbplatformutil.getDarwinOSTriples(),
-bugnumber="llvm.org/pr15824 thread states not properly maintained")
-@expectedFailureAll(
 oslist=["freebsd"],
 bugnumber="llvm.org/pr18190 thread states not properly maintained")
 @expectedFailureAll(
@@ -45,14 +42,6 @@ class ExitDuringBreakpointTestCase(TestB
 lldbutil.run_break_set_by_file_and_line(
 self, "main.cpp", self.breakpoint, num_expected_locations=1)
 
-# The breakpoint list should show 1 location.
-self.expect(
-"breakpoint list -f",
-"Breakpoint location shown correctly",
-substrs=[
-"1: file = 'main.cpp', line = %d, locations = 1" %
-self.breakpoint])
-
 # Run the program.
 self.runCmd("run", RUN_SUCCEEDED)
 
@@ -77,30 +66,6 @@ class ExitDuringBreakpointTestCase(TestB
 num_threads >= 5,
 'Number of expected threads and actual threads do not match.')
 
-# Get the thread objects
-thread1 = process.GetThreadAtIndex(0)
-thread2 = process.GetThreadAtIndex(1)
-thread3 = process.GetThreadAtIndex(2)
-thread4 = process.GetThreadAtIndex(3)
-thread5 = process.GetThreadAtIndex(4)
-
-# Make sure all threads are stopped
-self.assertTrue(
-thread1.IsStopped(),
-"Thread 1 didn't stop during breakpoint")
-self.assertTrue(
-thread2.IsStopped(),
-"Thread 2 didn't stop during breakpoint")
-self.assertTrue(
-thread3.IsStopped(),
-"Thread 3 didn't stop during breakpoint")
-self.assertTrue(
-thread4.IsStopped(),
-"Thread 4 didn't stop during breakpoint")
-self.assertTrue(
-thread5.IsStopped(),
-"Thread 5 didn't stop during breakpoint")
-
 # Run to completion
 self.runCmd("continue")
 


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


[Lldb-commits] [lldb] r283010 - Add unit tests for specific instruction patterns that the x86

2016-09-30 Thread Jason Molenda via lldb-commits
Author: jmolenda
Date: Fri Sep 30 23:50:25 2016
New Revision: 283010

URL: http://llvm.org/viewvc/llvm-project?rev=283010&view=rev
Log:
Add unit tests for specific instruction patterns that the x86
assembly inspection class is designed to detect.  This is only about
half of the instructions that it needs to recognize - I'll complete
this in a separate checkin.

The larger full-function style test cases I'd checked in previously
covered nearly all of these already, but I wanted simpler test cases
too, so if they fail in the future, it will be easier to spot the
issue.


Modified:
lldb/trunk/unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp

Modified: 
lldb/trunk/unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp?rev=283010&r1=283009&r2=283010&view=diff
==
--- lldb/trunk/unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp 
(original)
+++ lldb/trunk/unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp 
Fri Sep 30 23:50:25 2016
@@ -952,3 +952,522 @@ TEST_F(Testx86AssemblyInspectionEngine,
   EXPECT_TRUE(row_sp->GetCFAValue().IsRegisterPlusOffset() == true);
   EXPECT_EQ(4, row_sp->GetCFAValue().GetOffset());
 }
+
+TEST_F(Testx86AssemblyInspectionEngine, TestPushRBP) {
+  UnwindPlan::Row::RegisterLocation regloc;
+  UnwindPlan::RowSP row_sp;
+
+  uint8_t data[] = {
+  0x55, // pushq $rbp
+  0x90  // nop
+  };
+
+  AddressRange sample_range(0x1000, sizeof(data));
+  UnwindPlan unwind_plan(eRegisterKindLLDB);
+
+  std::unique_ptr engine64 = Getx86_64Inspector();
+  EXPECT_TRUE(engine64->GetNonCallSiteUnwindPlanFromAssembly(
+  data, sizeof(data), sample_range, unwind_plan));
+
+  row_sp = unwind_plan.GetRowForFunctionOffset(1);
+
+  EXPECT_EQ(1, row_sp->GetOffset());
+  EXPECT_TRUE(row_sp->GetCFAValue().GetRegisterNumber() == k_rsp);
+  EXPECT_TRUE(row_sp->GetCFAValue().IsRegisterPlusOffset() == true);
+  EXPECT_EQ(16, row_sp->GetCFAValue().GetOffset());
+
+  EXPECT_TRUE(row_sp->GetRegisterInfo(k_rbp, regloc));
+  EXPECT_TRUE(regloc.IsAtCFAPlusOffset());
+  EXPECT_EQ(-16, regloc.GetOffset());
+
+  std::unique_ptr engine32 = Geti386Inspector();
+  EXPECT_TRUE(engine32->GetNonCallSiteUnwindPlanFromAssembly(
+  data, sizeof(data), sample_range, unwind_plan));
+
+  row_sp = unwind_plan.GetRowForFunctionOffset(1);
+
+  EXPECT_EQ(1, 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_rbp, regloc));
+  EXPECT_TRUE(regloc.IsAtCFAPlusOffset());
+  EXPECT_EQ(-8, regloc.GetOffset());
+}
+
+TEST_F(Testx86AssemblyInspectionEngine, TestPushImm) {
+  UnwindPlan::Row::RegisterLocation regloc;
+  UnwindPlan::RowSP row_sp;
+
+  uint8_t data[] = {
+  0x68, 0xff, 0xff, 0x01, 0x69, // pushq $0x6901
+  0x90  // nop
+  };
+
+  AddressRange sample_range(0x1000, sizeof(data));
+  UnwindPlan unwind_plan(eRegisterKindLLDB);
+
+  std::unique_ptr engine64 = Getx86_64Inspector();
+  EXPECT_TRUE(engine64->GetNonCallSiteUnwindPlanFromAssembly(
+  data, sizeof(data), sample_range, unwind_plan));
+
+  row_sp = unwind_plan.GetRowForFunctionOffset(5);
+
+  EXPECT_EQ(5, 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());
+
+  std::unique_ptr engine32 = Geti386Inspector();
+  EXPECT_TRUE(engine32->GetNonCallSiteUnwindPlanFromAssembly(
+  data, sizeof(data), sample_range, unwind_plan));
+
+  row_sp = unwind_plan.GetRowForFunctionOffset(5);
+
+  EXPECT_EQ(5, 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());
+}
+
+// We treat 'pushq $0' / 'pushl $0' specially - this shows up
+// in the first function called in a new thread and it needs to
+// put a 0 as the saved pc.  We pretend it didn't change the CFA.
+TEST_F(Testx86AssemblyInspectionEngine, TestPush0) {
+  UnwindPlan::Row::RegisterLocation regloc;
+  UnwindPlan::RowSP row_sp;
+
+  uint8_t data[] = {
+  0x6a, 0x00, // pushq $0
+  0x90// nop
+  };
+
+  AddressRange sample_range(0x1000, sizeof(data));
+  UnwindPlan unwind_plan(eRegisterKindLLDB);
+
+  std::unique_ptr engine64 = Getx86_64Inspector();
+  EXPECT_TRUE(engine64->GetNonCallSiteUnwindPlanFromAssembly(
+  data, sizeof(data), sample_range, unwind_plan));
+
+  row_sp = unwind_plan.GetRowForFunctionOffset(2);
+
+  // We're verifying that no row was created for the 'pushq $0'
+  EXPECT_EQ(0, row_sp->GetOff

[Lldb-commits] [lldb] r283018 - Use StringRef instead of raw pointers in MCAsmInfo/MCInstrInfo APIs (NFC)

2016-09-30 Thread Mehdi Amini via lldb-commits
Author: mehdi_amini
Date: Sat Oct  1 01:46:33 2016
New Revision: 283018

URL: http://llvm.org/viewvc/llvm-project?rev=283018&view=rev
Log:
Use StringRef instead of raw pointers in MCAsmInfo/MCInstrInfo APIs (NFC)

Modified:
lldb/trunk/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp
lldb/trunk/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp

Modified: lldb/trunk/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp?rev=283018&r1=283017&r2=283018&view=diff
==
--- lldb/trunk/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp 
(original)
+++ lldb/trunk/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp Sat 
Oct  1 01:46:33 2016
@@ -1101,7 +1101,7 @@ bool EmulateInstructionMIPS::EvaluateIns
* mc_insn.getOpcode() returns decoded opcode. However to make use
* of llvm::Mips:: we would need "MipsGenInstrInfo.inc".
   */
-  const char *op_name = m_insn_info->getName(mc_insn.getOpcode());
+  const char *op_name = m_insn_info->getName(mc_insn.getOpcode()).data();
 
   if (op_name == NULL)
 return false;
@@ -1373,7 +1373,7 @@ bool EmulateInstructionMIPS::Emulate_SUB
   bool success = false;
   uint64_t result;
   uint8_t src, dst, rt;
-  const char *op_name = m_insn_info->getName(insn.getOpcode());
+  const char *op_name = m_insn_info->getName(insn.getOpcode()).data();
 
   dst = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
   src = m_reg_info->getEncodingValue(insn.getOperand(1).getReg());
@@ -1834,7 +1834,7 @@ bool EmulateInstructionMIPS::Emulate_BXX
   bool success = false;
   uint32_t rs, rt;
   int32_t offset, pc, target = 0, rs_val, rt_val;
-  const char *op_name = m_insn_info->getName(insn.getOpcode());
+  const char *op_name = m_insn_info->getName(insn.getOpcode()).data();
 
   rs = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
   rt = m_reg_info->getEncodingValue(insn.getOperand(1).getReg());
@@ -1886,7 +1886,7 @@ bool EmulateInstructionMIPS::Emulate_BXX
   bool success = false;
   uint32_t rs, rt;
   int32_t offset, pc, target = 0, rs_val, rt_val;
-  const char *op_name = m_insn_info->getName(insn.getOpcode());
+  const char *op_name = m_insn_info->getName(insn.getOpcode()).data();
   uint32_t current_inst_size = m_insn_info->get(insn.getOpcode()).getSize();
 
   rs = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
@@ -1969,7 +1969,7 @@ bool EmulateInstructionMIPS::Emulate_Bco
   uint32_t rs;
   int32_t offset, pc, target = 0;
   int32_t rs_val;
-  const char *op_name = m_insn_info->getName(insn.getOpcode());
+  const char *op_name = m_insn_info->getName(insn.getOpcode()).data();
 
   rs = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
   offset = insn.getOperand(1).getImm();
@@ -2038,7 +2038,7 @@ bool EmulateInstructionMIPS::Emulate_Bco
   uint32_t rs;
   int32_t offset, pc, target = 0;
   int32_t rs_val;
-  const char *op_name = m_insn_info->getName(insn.getOpcode());
+  const char *op_name = m_insn_info->getName(insn.getOpcode()).data();
 
   rs = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
   offset = insn.getOperand(1).getImm();
@@ -2088,7 +2088,7 @@ bool EmulateInstructionMIPS::Emulate_BXX
   uint32_t rs;
   int32_t offset, pc, target = 0;
   int32_t rs_val;
-  const char *op_name = m_insn_info->getName(insn.getOpcode());
+  const char *op_name = m_insn_info->getName(insn.getOpcode()).data();
 
   rs = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
   offset = insn.getOperand(1).getImm();
@@ -2144,7 +2144,7 @@ bool EmulateInstructionMIPS::Emulate_BXX
   uint32_t rs;
   int32_t offset, pc, target = 0;
   int32_t rs_val;
-  const char *op_name = m_insn_info->getName(insn.getOpcode());
+  const char *op_name = m_insn_info->getName(insn.getOpcode()).data();
   uint32_t current_inst_size = m_insn_info->get(insn.getOpcode()).getSize();
 
   rs = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
@@ -2236,7 +2236,7 @@ bool EmulateInstructionMIPS::Emulate_Bra
   bool success = false;
   int32_t target = 0;
   uint32_t current_inst_size = m_insn_info->get(insn.getOpcode()).getSize();
-  const char *op_name = m_insn_info->getName(insn.getOpcode());
+  const char *op_name = m_insn_info->getName(insn.getOpcode()).data();
   bool update_ra = false;
   uint32_t ra_offset = 0;
 
@@ -2336,7 +2336,7 @@ bool EmulateInstructionMIPS::Emulate_Bra
 bool EmulateInstructionMIPS::Emulate_JALRx16_MM(llvm::MCInst &insn) {
   bool success = false;
   uint32_t ra_offset = 0;
-  const char *op_name = m_insn_info->getName(insn.getOpcode());
+  const char *op_name = m_insn_info->getName(insn.getOpcode()).data();
 
   uint32_t rs = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
 
@@ -2375,7 +2375,7 @@ bool EmulateInstructionMIPS::Emulate_JAL
 bool EmulateInstructionMIPS::Emulate_JALx(llvm::