[Lldb-commits] [lldb] r335955 - Modernize completion tests

2018-06-29 Thread Pavel Labath via lldb-commits
Author: labath
Date: Fri Jun 29 02:06:42 2018
New Revision: 335955

URL: http://llvm.org/viewvc/llvm-project?rev=335955&view=rev
Log:
Modernize completion tests

Now that we have gmock, we can use its matchers to better express the
test assertions. The main advantage of this is that when things fail,
the test will now print the expected and actual lists of completed
strings instead of just a not-very-helpful "false is not true" message.

Modified:
lldb/trunk/unittests/Interpreter/TestCompletion.cpp

Modified: lldb/trunk/unittests/Interpreter/TestCompletion.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Interpreter/TestCompletion.cpp?rev=335955&r1=335954&r2=335955&view=diff
==
--- lldb/trunk/unittests/Interpreter/TestCompletion.cpp (original)
+++ lldb/trunk/unittests/Interpreter/TestCompletion.cpp Fri Jun 29 02:06:42 2018
@@ -7,10 +7,11 @@
 //
 
//===--===//
 
-#include "gtest/gtest.h"
 #include "lldb/Interpreter/CommandCompletions.h"
 #include "lldb/Utility/StringList.h"
 #include "lldb/Utility/TildeExpressionResolver.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
 
 #include "TestingSupport/MockTildeExpressionResolver.h"
 #include "llvm/ADT/SmallString.h"
@@ -103,16 +104,6 @@ protected:
 return false;
   }
 
-  static bool ContainsExactString(const Twine &Str, const StringList &Paths) {
-SmallString<16> Storage;
-StringRef Rendered = Str.toStringRef(Storage);
-for (size_t I = 0; I < Paths.GetSize(); ++I) {
-  if (Paths[I] == Rendered)
-return true;
-}
-return false;
-  }
-
   void DoDirCompletions(const Twine &Prefix,
 StandardTildeExpressionResolver &Resolver,
 StringList &Results) {
@@ -157,6 +148,14 @@ SmallString<128> CompletionTest::FileBar
 SmallString<128> CompletionTest::FileBaz;
 }
 
+static std::vector toVector(const StringList &SL) {
+  std::vector Result;
+  for (size_t Idx = 0; Idx < SL.GetSize(); ++Idx)
+Result.push_back(SL[Idx]);
+  return Result;
+}
+using testing::UnorderedElementsAre;
+
 TEST_F(CompletionTest, DirCompletionAbsolute) {
   // All calls to DiskDirectories() return only directories, even when
   // there are files which also match.  The tests below all check this
@@ -254,67 +253,47 @@ TEST_F(CompletionTest, DirCompletionUser
   Resolver.AddKnownUser("Lars", DirFooC);
   Resolver.AddKnownUser("Jason", DirFoo);
   Resolver.AddKnownUser("Larry", DirFooA);
+  std::string sep = path::get_separator();
 
   // Just resolving current user's home directory by itself should return the
   // directory.
   StringList Results;
   size_t Count = CommandCompletions::DiskDirectories("~", Results, Resolver);
-  ASSERT_EQ(1u, Count);
-  ASSERT_EQ(Count, Results.GetSize());
-  EXPECT_TRUE(ContainsExactString(Twine("~") + path::get_separator(), 
Results));
+  EXPECT_EQ(Count, Results.GetSize());
+  EXPECT_THAT(toVector(Results), UnorderedElementsAre("~" + sep));
 
   // With a slash appended, it should return all items in the directory.
   Count = CommandCompletions::DiskDirectories("~/", Results, Resolver);
-  ASSERT_EQ(7u, Count);
-  ASSERT_EQ(Count, Results.GetSize());
-  EXPECT_TRUE(
-  ContainsExactString(Twine("~/foo") + path::get_separator(), Results));
-  EXPECT_TRUE(
-  ContainsExactString(Twine("~/fooa") + path::get_separator(), Results));
-  EXPECT_TRUE(
-  ContainsExactString(Twine("~/foob") + path::get_separator(), Results));
-  EXPECT_TRUE(
-  ContainsExactString(Twine("~/fooc") + path::get_separator(), Results));
-  EXPECT_TRUE(
-  ContainsExactString(Twine("~/bar") + path::get_separator(), Results));
-  EXPECT_TRUE(
-  ContainsExactString(Twine("~/baz") + path::get_separator(), Results));
-  EXPECT_TRUE(ContainsExactString(
-  Twine("~/test_folder") + path::get_separator(), Results));
+  EXPECT_THAT(toVector(Results),
+  UnorderedElementsAre(
+  "~/foo" + sep, "~/fooa" + sep, "~/foob" + sep, "~/fooc" + 
sep,
+  "~/bar" + sep, "~/baz" + sep, "~/test_folder" + sep));
+  EXPECT_EQ(Count, Results.GetSize());
 
   // Check that we can complete directories in nested paths
   Count = CommandCompletions::DiskDirectories("~/foo/", Results, Resolver);
-  ASSERT_EQ(1u, Count);
-  ASSERT_EQ(Count, Results.GetSize());
-  EXPECT_TRUE(ContainsExactString(Twine("~/foo/nested") + 
path::get_separator(),
-  Results));
+  EXPECT_EQ(Count, Results.GetSize());
+  EXPECT_THAT(toVector(Results), UnorderedElementsAre("~/foo/nested" + sep));
+
   Count = CommandCompletions::DiskDirectories("~/foo/nes", Results, Resolver);
-  ASSERT_EQ(1u, Count);
-  ASSERT_EQ(Count, Results.GetSize());
-  EXPECT_TRUE(ContainsExactString(Twine("~/foo/nested") + 
path::get_separator(),
-  Results));
+  EXPECT_EQ(Count, Results.Ge

[Lldb-commits] [lldb] r335956 - Fix TestLoadUsingPaths on linux

2018-06-29 Thread Pavel Labath via lldb-commits
Author: labath
Date: Fri Jun 29 02:22:07 2018
New Revision: 335956

URL: http://llvm.org/viewvc/llvm-project?rev=335956&view=rev
Log:
Fix TestLoadUsingPaths on linux

we need to explicitly link the test program with -ldl for the dlopen
function to be available.

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_using_paths/Makefile

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_using_paths/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_using_paths/Makefile?rev=335956&r1=335955&r2=335956&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_using_paths/Makefile
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_using_paths/Makefile
 Fri Jun 29 02:22:07 2018
@@ -1,6 +1,7 @@
 LEVEL := ../../make
 
 CXX_SOURCES := main.cpp
+LD_EXTRAS := -ldl
 
 include $(LEVEL)/Makefile.rules
 


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


[Lldb-commits] [lldb] r335960 - Fix use-after-free in CommandCompletions.cpp

2018-06-29 Thread Pavel Labath via lldb-commits
Author: labath
Date: Fri Jun 29 03:27:18 2018
New Revision: 335960

URL: http://llvm.org/viewvc/llvm-project?rev=335960&view=rev
Log:
Fix use-after-free in CommandCompletions.cpp

The code was creating a StringRef to a temporary std::string. The
solution is to just drop the .str() from the original StringRef.

This manifested it self as the new TestCompletions test failing in some
configurations.

Modified:
lldb/trunk/source/Commands/CommandCompletions.cpp

Modified: lldb/trunk/source/Commands/CommandCompletions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandCompletions.cpp?rev=335960&r1=335959&r2=335960&view=diff
==
--- lldb/trunk/source/Commands/CommandCompletions.cpp (original)
+++ lldb/trunk/source/Commands/CommandCompletions.cpp Fri Jun 29 03:27:18 2018
@@ -164,7 +164,7 @@ static int DiskFilesOrDirectories(const
 // search in the fully resolved directory, but CompletionBuffer keeps the
 // unmodified form that the user typed.
 Storage = Resolved;
-llvm::StringRef RemainderDir = path::parent_path(Remainder.str());
+llvm::StringRef RemainderDir = path::parent_path(Remainder);
 if (!RemainderDir.empty()) {
   // Append the remaining path to the resolved directory.
   Storage.append(path::get_separator());


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


[Lldb-commits] [PATCH] D48633: UUID: Add support for arbitrary-sized module IDs

2018-06-29 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL335963: UUID: Add support for arbitrary-sized module IDs 
(authored by labath, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D48633

Files:
  lldb/trunk/include/lldb/Utility/UUID.h
  lldb/trunk/source/Interpreter/OptionValueUUID.cpp
  lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/trunk/source/Utility/UUID.cpp
  lldb/trunk/unittests/Utility/UUIDTest.cpp

Index: lldb/trunk/unittests/Utility/UUIDTest.cpp
===
--- lldb/trunk/unittests/Utility/UUIDTest.cpp
+++ lldb/trunk/unittests/Utility/UUIDTest.cpp
@@ -71,3 +71,14 @@
   32u, u.SetFromStringRef("404142434445464748494a4b4c4d4e4f-50515253", 16));
   EXPECT_EQ(UUID::fromData("@ABCDEFGHIJKLMNO", 16), u);
 }
+
+TEST(UUIDTest, StringConverion) {
+  EXPECT_EQ("40414243", UUID::fromData("@ABC", 4).GetAsString());
+  EXPECT_EQ("40414243-4445-4647", UUID::fromData("@ABCDEFG", 8).GetAsString());
+  EXPECT_EQ("40414243-4445-4647-4849-4A4B",
+UUID::fromData("@ABCDEFGHIJK", 12).GetAsString());
+  EXPECT_EQ("40414243-4445-4647-4849-4A4B4C4D4E4F",
+UUID::fromData("@ABCDEFGHIJKLMNO", 16).GetAsString());
+  EXPECT_EQ("40414243-4445-4647-4849-4A4B4C4D4E4F-50515253",
+UUID::fromData("@ABCDEFGHIJKLMNOPQRS", 20).GetAsString());
+}
Index: lldb/trunk/source/Utility/UUID.cpp
===
--- lldb/trunk/source/Utility/UUID.cpp
+++ lldb/trunk/source/Utility/UUID.cpp
@@ -13,43 +13,44 @@
 // Project includes
 #include "lldb/Utility/Stream.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Format.h"
 
 // C Includes
 #include 
 #include 
 #include 
 
 using namespace lldb_private;
 
-UUID::UUID(llvm::ArrayRef bytes) {
-  if (bytes.size() != 20 && bytes.size() != 16)
-bytes = {};
-
-  m_num_uuid_bytes = bytes.size();
-  std::memcpy(m_uuid, bytes.data(), bytes.size());
+// Whether to put a separator after count uuid bytes.
+// For the first 16 bytes we follow the traditional UUID format. After that, we
+// simply put a dash after every 6 bytes.
+static inline bool separate(size_t count) {
+  if (count >= 10)
+return (count - 10) % 6 == 0;
+
+  switch (count) {
+  case 4:
+  case 6:
+  case 8:
+return true;
+  default:
+return false;
+  }
 }
 
-std::string UUID::GetAsString(const char *separator) const {
+std::string UUID::GetAsString(llvm::StringRef separator) const {
   std::string result;
-  char buf[256];
-  if (!separator)
-separator = "-";
-  const uint8_t *u = GetBytes().data();
-  if (sizeof(buf) >
-  (size_t)snprintf(buf, sizeof(buf), "%2.2X%2.2X%2.2X%2.2X%s%2.2X%2.2X%s%2."
- "2X%2.2X%s%2.2X%2.2X%s%2.2X%2.2X%2.2X%"
- "2.2X%2.2X%2.2X",
-   u[0], u[1], u[2], u[3], separator, u[4], u[5], separator,
-   u[6], u[7], separator, u[8], u[9], separator, u[10],
-   u[11], u[12], u[13], u[14], u[15])) {
-result.append(buf);
-if (m_num_uuid_bytes == 20) {
-  if (sizeof(buf) > (size_t)snprintf(buf, sizeof(buf),
- "%s%2.2X%2.2X%2.2X%2.2X", separator,
- u[16], u[17], u[18], u[19]))
-result.append(buf);
-}
+  llvm::raw_string_ostream os(result);
+
+  for (auto B : llvm::enumerate(GetBytes())) {
+if (separate(B.index()))
+  os << separator;
+
+os << llvm::format_hex_no_prefix(B.value(), 2, true);
   }
+  os.flush();
+
   return result;
 }
 
@@ -64,25 +65,24 @@
   return ch - '0';
 }
 
-llvm::StringRef UUID::DecodeUUIDBytesFromString(llvm::StringRef p,
-ValueType &uuid_bytes,
-uint32_t &bytes_decoded,
-uint32_t num_uuid_bytes) {
-  ::memset(uuid_bytes, 0, sizeof(uuid_bytes));
-  size_t uuid_byte_idx = 0;
+llvm::StringRef
+UUID::DecodeUUIDBytesFromString(llvm::StringRef p,
+llvm::SmallVectorImpl &uuid_bytes,
+uint32_t num_uuid_bytes) {
+  uuid_bytes.clear();
   while (!p.empty()) {
 if (isxdigit(p[0]) && isxdigit(p[1])) {
   int hi_nibble = xdigit_to_int(p[0]);
   int lo_nibble = xdigit_to_int(p[1]);
   // Translate the two hex nibble characters into a byte
-  uuid_bytes[uuid_byte_idx] = (hi_nibble << 4) + lo_nibble;
+  uuid_bytes.push_back((hi_nibble << 4) + lo_nibble);
 
   // Skip both hex digits
   p = p.drop_front(2);
 
   // Increment the byte that we are decoding within the UUID value and
   // break out if we are done
-  if (++uuid_byte_idx == num_uuid_bytes)
+  if (uuid_bytes.size() == num_uuid_bytes)
 break;
 } else if (

[Lldb-commits] [lldb] r335963 - UUID: Add support for arbitrary-sized module IDs

2018-06-29 Thread Pavel Labath via lldb-commits
Author: labath
Date: Fri Jun 29 04:20:29 2018
New Revision: 335963

URL: http://llvm.org/viewvc/llvm-project?rev=335963&view=rev
Log:
UUID: Add support for arbitrary-sized module IDs

Summary:
The data structure is optimized for the case where the UUID size is <=
20 bytes (standard length emitted by the GNU linkers), but larger sizes
are also possible.

I've modified the string conversion function to support the new sizes as
well. For standard UUIDs it maintains the traditional formatting
(4-2-2-2-6). If a UUID is shorter, we just cut this sequence short, and
for longer UUIDs it will just repeat the last 6-byte block as long as
necessary.

I've also modified ObjectFileELF to take advantage of the new UUIDs and
avoid manually padding the UUID to 16 bytes. While there, I also made
sure the computed UUID does not depend on host endianness.

Reviewers: clayborg, lemo, sas, davide, espindola

Subscribers: emaste, arichardson, lldb-commits

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

Modified:
lldb/trunk/include/lldb/Utility/UUID.h
lldb/trunk/source/Interpreter/OptionValueUUID.cpp
lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
lldb/trunk/source/Utility/UUID.cpp
lldb/trunk/unittests/Utility/UUIDTest.cpp

Modified: lldb/trunk/include/lldb/Utility/UUID.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/UUID.h?rev=335963&r1=335962&r2=335963&view=diff
==
--- lldb/trunk/include/lldb/Utility/UUID.h (original)
+++ lldb/trunk/include/lldb/Utility/UUID.h Fri Jun 29 04:20:29 2018
@@ -27,12 +27,6 @@ namespace lldb_private {
 
 class UUID {
 public:
-  // Most UUIDs are 16 bytes, but some Linux build-ids (SHA1) are 20.
-  typedef uint8_t ValueType[20];
-
-  //--
-  // Constructors and Destructors
-  //--
   UUID() = default;
 
   /// Creates a UUID from the data pointed to by the bytes argument. No special
@@ -64,18 +58,16 @@ public:
 return UUID(bytes);
   }
 
-  void Clear() { m_num_uuid_bytes = 0; }
+  void Clear() { m_bytes.clear(); }
 
   void Dump(Stream *s) const;
 
-  llvm::ArrayRef GetBytes() const {
-return {m_uuid, m_num_uuid_bytes};
-  }
+  llvm::ArrayRef GetBytes() const { return m_bytes; }
 
   explicit operator bool() const { return IsValid(); }
-  bool IsValid() const { return m_num_uuid_bytes > 0; }
+  bool IsValid() const { return !m_bytes.empty(); }
 
-  std::string GetAsString(const char *separator = nullptr) const;
+  std::string GetAsString(llvm::StringRef separator = "-") const;
 
   size_t SetFromStringRef(llvm::StringRef str, uint32_t num_uuid_bytes = 16);
 
@@ -99,24 +91,34 @@ public:
   /// The original string, with all decoded bytes removed.
   //--
   static llvm::StringRef
-  DecodeUUIDBytesFromString(llvm::StringRef str, ValueType &uuid_bytes,
-uint32_t &bytes_decoded,
+  DecodeUUIDBytesFromString(llvm::StringRef str,
+llvm::SmallVectorImpl &uuid_bytes,
 uint32_t num_uuid_bytes = 16);
 
 private:
-  UUID(llvm::ArrayRef bytes);
-
-  uint32_t m_num_uuid_bytes = 0; // Should be 0, 16 or 20
-  ValueType m_uuid;
-};
+  UUID(llvm::ArrayRef bytes) : m_bytes(bytes.begin(), bytes.end()) {}
 
-bool operator==(const UUID &lhs, const UUID &rhs);
-bool operator!=(const UUID &lhs, const UUID &rhs);
-bool operator<(const UUID &lhs, const UUID &rhs);
-bool operator<=(const UUID &lhs, const UUID &rhs);
-bool operator>(const UUID &lhs, const UUID &rhs);
-bool operator>=(const UUID &lhs, const UUID &rhs);
+  // GNU ld generates 20-byte build-ids. Size chosen to avoid heap allocations
+  // for this case.
+  llvm::SmallVector m_bytes;
 
+  friend bool operator==(const UUID &LHS, const UUID &RHS) {
+return LHS.m_bytes == RHS.m_bytes;
+  }
+  friend bool operator!=(const UUID &LHS, const UUID &RHS) {
+return !(LHS == RHS);
+  }
+  friend bool operator<(const UUID &LHS, const UUID &RHS) {
+return LHS.m_bytes < RHS.m_bytes;
+  }
+  friend bool operator<=(const UUID &LHS, const UUID &RHS) {
+return !(RHS < LHS);
+  }
+  friend bool operator>(const UUID &LHS, const UUID &RHS) { return RHS < LHS; }
+  friend bool operator>=(const UUID &LHS, const UUID &RHS) {
+return !(LHS < RHS);
+  }
+};
 } // namespace lldb_private
 
 #endif // LLDB_UTILITY_UUID_H

Modified: lldb/trunk/source/Interpreter/OptionValueUUID.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionValueUUID.cpp?rev=335963&r1=335962&r2=335963&view=diff
==
--- lldb/trunk/source/Interpreter/OptionValueUUID.cpp (original)
+++ lldb/trunk/source/Interpreter/OptionValueUUID.cpp Fri Jun 29 04:20:29 2018
@@ -76,21 +76,17 

[Lldb-commits] [lldb] r335967 - Add a test for reading lld-generated build-ids

2018-06-29 Thread Pavel Labath via lldb-commits
Author: labath
Date: Fri Jun 29 05:15:54 2018
New Revision: 335967

URL: http://llvm.org/viewvc/llvm-project?rev=335967&view=rev
Log:
Add a test for reading lld-generated build-ids

Summary:
This test makes sure we are able to read the shorter build-ids which are
generated by lld.

To make this work, I've extended lldb-test to print the UUID of the
loaded object file. I've renamed the lldb-test subcommand from
"module-sections" to "object-file" to reflect the fact it prints more
than just the sections.

I've also added the module Architecture to the output, so we could avoid
printing the entire symbol file information just to get the ArchSpec
details in the lc_version_min test (which was also the only test in it's
folder not using the module-sections command).

Reviewers: aprantl, zturner

Subscribers: lldb-commits

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

Added:
lldb/trunk/lit/Modules/short-build-id.yaml
Modified:
lldb/trunk/lit/Modules/build-id-case.yaml
lldb/trunk/lit/Modules/compressed-sections.yaml
lldb/trunk/lit/Modules/elf-duplicate-section.yaml
lldb/trunk/lit/Modules/elf-section-types.yaml
lldb/trunk/lit/Modules/lc_version_min.yaml
lldb/trunk/tools/lldb-test/lldb-test.cpp

Modified: lldb/trunk/lit/Modules/build-id-case.yaml
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/build-id-case.yaml?rev=335967&r1=335966&r2=335967&view=diff
==
--- lldb/trunk/lit/Modules/build-id-case.yaml (original)
+++ lldb/trunk/lit/Modules/build-id-case.yaml Fri Jun 29 05:15:54 2018
@@ -2,7 +2,7 @@
 # RUN: yaml2obj %s > 
%t/.build-id/1b/8a73ac238390e32a7ff4ac8ebe4d6a41ecf5c9.debug
 # RUN: cd %t
 # RUN: llvm-objcopy --strip-all 
--add-gnu-debuglink=.build-id/1b/8a73ac238390e32a7ff4ac8ebe4d6a41ecf5c9.debug 
%t/.build-id/1b/8a73ac238390e32a7ff4ac8ebe4d6a41ecf5c9.debug %t/stripped.out
-# RUN: lldb-test module-sections %t/stripped.out | FileCheck %s
+# RUN: lldb-test object-file %t/stripped.out | FileCheck %s
 
 # CHECK: Name: .debug_frame
 # CHECK-NEXT: Type: dwarf-frame

Modified: lldb/trunk/lit/Modules/compressed-sections.yaml
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/compressed-sections.yaml?rev=335967&r1=335966&r2=335967&view=diff
==
--- lldb/trunk/lit/Modules/compressed-sections.yaml (original)
+++ lldb/trunk/lit/Modules/compressed-sections.yaml Fri Jun 29 05:15:54 2018
@@ -1,6 +1,6 @@
 # REQUIRES: zlib
 # RUN: yaml2obj %s > %t
-# RUN: lldb-test module-sections --contents %t | FileCheck %s
+# RUN: lldb-test object-file --contents %t | FileCheck %s
 --- !ELF
 FileHeader:
   Class:   ELFCLASS32

Modified: lldb/trunk/lit/Modules/elf-duplicate-section.yaml
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/elf-duplicate-section.yaml?rev=335967&r1=335966&r2=335967&view=diff
==
--- lldb/trunk/lit/Modules/elf-duplicate-section.yaml (original)
+++ lldb/trunk/lit/Modules/elf-duplicate-section.yaml Fri Jun 29 05:15:54 2018
@@ -2,7 +2,7 @@
 # RUN: yaml2obj %s > 
%t/.build-id/1b/8a73ac238390e32a7ff4ac8ebe4d6a41ecf5c9.debug
 # RUN: cd %t
 # RUN: llvm-objcopy --strip-all 
--add-gnu-debuglink=.build-id/1b/8a73ac238390e32a7ff4ac8ebe4d6a41ecf5c9.debug 
%t/.build-id/1b/8a73ac238390e32a7ff4ac8ebe4d6a41ecf5c9.debug %t/stripped.out
-# RUN: lldb-test module-sections %t/stripped.out | FileCheck %s
+# RUN: lldb-test object-file %t/stripped.out | FileCheck %s
 
 # Make sure that the debug_frame section is present only once.
 # CHECK: Name: .debug_frame

Modified: lldb/trunk/lit/Modules/elf-section-types.yaml
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/elf-section-types.yaml?rev=335967&r1=335966&r2=335967&view=diff
==
--- lldb/trunk/lit/Modules/elf-section-types.yaml (original)
+++ lldb/trunk/lit/Modules/elf-section-types.yaml Fri Jun 29 05:15:54 2018
@@ -1,5 +1,5 @@
 # RUN: yaml2obj %s > %t
-# RUN: lldb-test module-sections %t | FileCheck %s
+# RUN: lldb-test object-file %t | FileCheck %s
 
 # CHECK: Name: .text
 # CHECK-NEXT: Type: code

Modified: lldb/trunk/lit/Modules/lc_version_min.yaml
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/lc_version_min.yaml?rev=335967&r1=335966&r2=335967&view=diff
==
--- lldb/trunk/lit/Modules/lc_version_min.yaml (original)
+++ lldb/trunk/lit/Modules/lc_version_min.yaml Fri Jun 29 05:15:54 2018
@@ -1,8 +1,8 @@
 # RUN: yaml2obj %s > %t.out
-# RUN: lldb-test symbols %t.out | FileCheck %s
+# RUN: lldb-test object-file %t.out | FileCheck %s
 
 # Test that the deployment target is parsed from the load commands.
-# CHECK: x86_64-apple-macosx10.9.0
+# CHECK: Architecture: x86_64-apple-macosx10.9.0
 --- !mac

[Lldb-commits] [PATCH] D48646: Add a test for reading lld-generated build-ids

2018-06-29 Thread Pavel Labath via Phabricator via lldb-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL335967: Add a test for reading lld-generated build-ids 
(authored by labath, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D48646

Files:
  lldb/trunk/lit/Modules/build-id-case.yaml
  lldb/trunk/lit/Modules/compressed-sections.yaml
  lldb/trunk/lit/Modules/elf-duplicate-section.yaml
  lldb/trunk/lit/Modules/elf-section-types.yaml
  lldb/trunk/lit/Modules/lc_version_min.yaml
  lldb/trunk/lit/Modules/short-build-id.yaml
  lldb/trunk/tools/lldb-test/lldb-test.cpp

Index: lldb/trunk/lit/Modules/elf-section-types.yaml
===
--- lldb/trunk/lit/Modules/elf-section-types.yaml
+++ lldb/trunk/lit/Modules/elf-section-types.yaml
@@ -1,5 +1,5 @@
 # RUN: yaml2obj %s > %t
-# RUN: lldb-test module-sections %t | FileCheck %s
+# RUN: lldb-test object-file %t | FileCheck %s
 
 # CHECK: Name: .text
 # CHECK-NEXT: Type: code
Index: lldb/trunk/lit/Modules/compressed-sections.yaml
===
--- lldb/trunk/lit/Modules/compressed-sections.yaml
+++ lldb/trunk/lit/Modules/compressed-sections.yaml
@@ -1,6 +1,6 @@
 # REQUIRES: zlib
 # RUN: yaml2obj %s > %t
-# RUN: lldb-test module-sections --contents %t | FileCheck %s
+# RUN: lldb-test object-file --contents %t | FileCheck %s
 --- !ELF
 FileHeader:
   Class:   ELFCLASS32
Index: lldb/trunk/lit/Modules/short-build-id.yaml
===
--- lldb/trunk/lit/Modules/short-build-id.yaml
+++ lldb/trunk/lit/Modules/short-build-id.yaml
@@ -0,0 +1,26 @@
+# RUN: yaml2obj %s >%t
+# RUN: lldb-test object-file %t | FileCheck %s
+
+# CHECK: UUID: 333059A4-3CC3-D5F9
+
+--- !ELF
+FileHeader:  
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_EXEC
+  Machine: EM_X86_64
+  Entry:   0x00201000
+Sections:
+  - Name:.note.gnu.build-id
+Type:SHT_NOTE
+Flags:   [ SHF_ALLOC ]
+Address: 0x00200190
+AddressAlign:0x0004
+Content: 040008000300474E5500333059A43CC3D5F9
+  - Name:.text
+Type:SHT_PROGBITS
+Flags:   [ SHF_ALLOC, SHF_EXECINSTR ]
+Address: 0x00201000
+AddressAlign:0x0004
+Content: ''
+...
Index: lldb/trunk/lit/Modules/lc_version_min.yaml
===
--- lldb/trunk/lit/Modules/lc_version_min.yaml
+++ lldb/trunk/lit/Modules/lc_version_min.yaml
@@ -1,8 +1,8 @@
 # RUN: yaml2obj %s > %t.out
-# RUN: lldb-test symbols %t.out | FileCheck %s
+# RUN: lldb-test object-file %t.out | FileCheck %s
 
 # Test that the deployment target is parsed from the load commands.
-# CHECK: x86_64-apple-macosx10.9.0
+# CHECK: Architecture: x86_64-apple-macosx10.9.0
 --- !mach-o
 FileHeader:  
   magic:   0xFEEDFACF
Index: lldb/trunk/lit/Modules/build-id-case.yaml
===
--- lldb/trunk/lit/Modules/build-id-case.yaml
+++ lldb/trunk/lit/Modules/build-id-case.yaml
@@ -2,7 +2,7 @@
 # RUN: yaml2obj %s > %t/.build-id/1b/8a73ac238390e32a7ff4ac8ebe4d6a41ecf5c9.debug
 # RUN: cd %t
 # RUN: llvm-objcopy --strip-all --add-gnu-debuglink=.build-id/1b/8a73ac238390e32a7ff4ac8ebe4d6a41ecf5c9.debug %t/.build-id/1b/8a73ac238390e32a7ff4ac8ebe4d6a41ecf5c9.debug %t/stripped.out
-# RUN: lldb-test module-sections %t/stripped.out | FileCheck %s
+# RUN: lldb-test object-file %t/stripped.out | FileCheck %s
 
 # CHECK: Name: .debug_frame
 # CHECK-NEXT: Type: dwarf-frame
Index: lldb/trunk/lit/Modules/elf-duplicate-section.yaml
===
--- lldb/trunk/lit/Modules/elf-duplicate-section.yaml
+++ lldb/trunk/lit/Modules/elf-duplicate-section.yaml
@@ -2,7 +2,7 @@
 # RUN: yaml2obj %s > %t/.build-id/1b/8a73ac238390e32a7ff4ac8ebe4d6a41ecf5c9.debug
 # RUN: cd %t
 # RUN: llvm-objcopy --strip-all --add-gnu-debuglink=.build-id/1b/8a73ac238390e32a7ff4ac8ebe4d6a41ecf5c9.debug %t/.build-id/1b/8a73ac238390e32a7ff4ac8ebe4d6a41ecf5c9.debug %t/stripped.out
-# RUN: lldb-test module-sections %t/stripped.out | FileCheck %s
+# RUN: lldb-test object-file %t/stripped.out | FileCheck %s
 
 # Make sure that the debug_frame section is present only once.
 # CHECK: Name: .debug_frame
Index: lldb/trunk/tools/lldb-test/lldb-test.cpp
===
--- lldb/trunk/tools/lldb-test/lldb-test.cpp
+++ lldb/trunk/tools/lldb-test/lldb-test.cpp
@@ -51,14 +51,15 @@
 namespace opts {
 static cl::SubCommand BreakpointSubcommand("breakpoints",
"Test bre

[Lldb-commits] [PATCH] D48775: Add new SBTarget::IsDummy method.

2018-06-29 Thread Alexander Polyakov via Phabricator via lldb-commits
apolyakov created this revision.
apolyakov added reviewers: aprantl, clayborg.

The new member function allows to check if a target is dummy or real.


https://reviews.llvm.org/D48775

Files:
  include/lldb/API/SBTarget.h
  scripts/interface/SBTarget.i
  source/API/SBTarget.cpp


Index: source/API/SBTarget.cpp
===
--- source/API/SBTarget.cpp
+++ source/API/SBTarget.cpp
@@ -146,6 +146,10 @@
   return m_opaque_sp.get() != NULL && m_opaque_sp->IsValid();
 }
 
+bool SBTarget::IsDummy() const {
+  return *this == GetDebugger().GetDummyTarget();
+}
+
 SBProcess SBTarget::GetProcess() {
   SBProcess sb_process;
   ProcessSP process_sp;
Index: scripts/interface/SBTarget.i
===
--- scripts/interface/SBTarget.i
+++ scripts/interface/SBTarget.i
@@ -81,6 +81,9 @@
 bool
 IsValid() const;
 
+bool
+IsDummy() const;
+
 static bool
 EventIsTargetEvent (const lldb::SBEvent &event);
 
Index: include/lldb/API/SBTarget.h
===
--- include/lldb/API/SBTarget.h
+++ include/lldb/API/SBTarget.h
@@ -62,6 +62,8 @@
 
   bool IsValid() const;
 
+  bool IsDummy() const;
+
   static bool EventIsTargetEvent(const lldb::SBEvent &event);
 
   static lldb::SBTarget GetTargetFromEvent(const lldb::SBEvent &event);


Index: source/API/SBTarget.cpp
===
--- source/API/SBTarget.cpp
+++ source/API/SBTarget.cpp
@@ -146,6 +146,10 @@
   return m_opaque_sp.get() != NULL && m_opaque_sp->IsValid();
 }
 
+bool SBTarget::IsDummy() const {
+  return *this == GetDebugger().GetDummyTarget();
+}
+
 SBProcess SBTarget::GetProcess() {
   SBProcess sb_process;
   ProcessSP process_sp;
Index: scripts/interface/SBTarget.i
===
--- scripts/interface/SBTarget.i
+++ scripts/interface/SBTarget.i
@@ -81,6 +81,9 @@
 bool
 IsValid() const;
 
+bool
+IsDummy() const;
+
 static bool
 EventIsTargetEvent (const lldb::SBEvent &event);
 
Index: include/lldb/API/SBTarget.h
===
--- include/lldb/API/SBTarget.h
+++ include/lldb/API/SBTarget.h
@@ -62,6 +62,8 @@
 
   bool IsValid() const;
 
+  bool IsDummy() const;
+
   static bool EventIsTargetEvent(const lldb::SBEvent &event);
 
   static lldb::SBTarget GetTargetFromEvent(const lldb::SBEvent &event);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D48775: Add new SBTarget::IsDummy method.

2018-06-29 Thread Bruce Mitchener via Phabricator via lldb-commits
brucem requested changes to this revision.
brucem added inline comments.
This revision now requires changes to proceed.



Comment at: include/lldb/API/SBTarget.h:65
 
+  bool IsDummy() const;
+

Could you add a doc comment here explaining it?



Comment at: scripts/interface/SBTarget.i:85
+bool
+IsDummy() const;
+

And here as well?


https://reviews.llvm.org/D48775



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


[Lldb-commits] [PATCH] D48775: Add new SBTarget::IsDummy method.

2018-06-29 Thread Alexander Polyakov via Phabricator via lldb-commits
apolyakov updated this revision to Diff 153516.
apolyakov edited the summary of this revision.
apolyakov added a comment.

Added description to source files and commit message.


https://reviews.llvm.org/D48775

Files:
  include/lldb/API/SBTarget.h
  scripts/interface/SBTarget.i
  source/API/SBTarget.cpp


Index: source/API/SBTarget.cpp
===
--- source/API/SBTarget.cpp
+++ source/API/SBTarget.cpp
@@ -146,6 +146,10 @@
   return m_opaque_sp.get() != NULL && m_opaque_sp->IsValid();
 }
 
+bool SBTarget::IsDummy() const {
+  return *this == GetDebugger().GetDummyTarget();
+}
+
 SBProcess SBTarget::GetProcess() {
   SBProcess sb_process;
   ProcessSP process_sp;
Index: scripts/interface/SBTarget.i
===
--- scripts/interface/SBTarget.i
+++ scripts/interface/SBTarget.i
@@ -81,6 +81,11 @@
 bool
 IsValid() const;
 
+%feature("docstring",
+"Returns true if *this target is a dummy one, false otherwise.") IsDummy;
+bool
+IsDummy () const;
+
 static bool
 EventIsTargetEvent (const lldb::SBEvent &event);
 
Index: include/lldb/API/SBTarget.h
===
--- include/lldb/API/SBTarget.h
+++ include/lldb/API/SBTarget.h
@@ -62,6 +62,9 @@
 
   bool IsValid() const;
 
+  // Returns true if *this target is a dummy one, false otherwise.
+  bool IsDummy() const;
+
   static bool EventIsTargetEvent(const lldb::SBEvent &event);
 
   static lldb::SBTarget GetTargetFromEvent(const lldb::SBEvent &event);


Index: source/API/SBTarget.cpp
===
--- source/API/SBTarget.cpp
+++ source/API/SBTarget.cpp
@@ -146,6 +146,10 @@
   return m_opaque_sp.get() != NULL && m_opaque_sp->IsValid();
 }
 
+bool SBTarget::IsDummy() const {
+  return *this == GetDebugger().GetDummyTarget();
+}
+
 SBProcess SBTarget::GetProcess() {
   SBProcess sb_process;
   ProcessSP process_sp;
Index: scripts/interface/SBTarget.i
===
--- scripts/interface/SBTarget.i
+++ scripts/interface/SBTarget.i
@@ -81,6 +81,11 @@
 bool
 IsValid() const;
 
+%feature("docstring",
+"Returns true if *this target is a dummy one, false otherwise.") IsDummy;
+bool
+IsDummy () const;
+
 static bool
 EventIsTargetEvent (const lldb::SBEvent &event);
 
Index: include/lldb/API/SBTarget.h
===
--- include/lldb/API/SBTarget.h
+++ include/lldb/API/SBTarget.h
@@ -62,6 +62,9 @@
 
   bool IsValid() const;
 
+  // Returns true if *this target is a dummy one, false otherwise.
+  bool IsDummy() const;
+
   static bool EventIsTargetEvent(const lldb::SBEvent &event);
 
   static lldb::SBTarget GetTargetFromEvent(const lldb::SBEvent &event);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D48775: Add new SBTarget::IsDummy method.

2018-06-29 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

Is the dummy target something we need to expose over the SBAPI? 
I see that other places in lldb-mi query `if (sbTarget == 
rSessionInfo.GetDebugger().GetDummyTarget())`. Would that be sufficient?


https://reviews.llvm.org/D48775



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


Re: [Lldb-commits] Adding a test for split-dwarf

2018-06-29 Thread Puyan Lotfi via lldb-commits
Thanks Adrian. My latest patch is here: https://reviews.llvm.org/D48782

This adds an option to the makefile
in llvm/tools/lldb/packages/Python/lldbsuite/test/make/Makefile.rules to
enable producing a DWP file from the DWO split dwarf files to enable
testing Dwarf Package Format (DWP).
I spoke with Greg and we think enabling this as a new testing flavor that
is disabled by default could be the way to go for now.

I am very open to feedback on this. Thanks.

PL

On Tue, Jun 26, 2018 at 4:58 PM Adrian Prantl  wrote:

> We just use reviews.llvm.org and CC lldb-commits.
>
> -- adrian
>
> On Jun 25, 2018, at 9:09 PM, Puyan Lotfi via lldb-commits <
> lldb-commits@lists.llvm.org> wrote:
>
> This is a first draft. Just trying to do some basic breakpoint and line
> number checks on a split dwarf compiled binary for now.
>
>
> Also, is there an LLDB phabricator? I didn't notice it in the project
> listing in reviews.llvm.org.
>
> PL
> ___
> lldb-commits mailing list
> lldb-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
>
>
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D48752: Quiet command regex instructions during batch execution

2018-06-29 Thread Dave Lee via Phabricator via lldb-commits
kastiglione added a comment.

Thanks @jingham.

> if the `IOHandlerDelegate` could say whether it wants to be notified for 
> `IOHandlerActivated` when non-interactive (like have a 
> "`ShouldNotifyWhenNonInteractive`" method), and then the `IOHandler` could 
> dispatch it or not based on the response to that method

So the "`ShouldNotifyWhenNonInteractive`" would only control whether 
`IOHandlerActivated` is called, not any of the other `IOHandlerDelegate` 
methods?

What do you think about adding a `IOHandlerActivatedInteractively`delegate 
method? This could be called in addition to `IOHandlerActivatedInteractively`, 
but only for interactive IO?


https://reviews.llvm.org/D48752



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


[Lldb-commits] [lldb] r336009 - [lldb-mi] Clean up and update a few MI commands.

2018-06-29 Thread Alexander Polyakov via lldb-commits
Author: apolyakov
Date: Fri Jun 29 12:58:31 2018
New Revision: 336009

URL: http://llvm.org/viewvc/llvm-project?rev=336009&view=rev
Log:
[lldb-mi] Clean up and update a few MI commands.

Summary:
This patch updates a few MI commands using a new way of
handling an errors in lldb-mi and removes unnecessary
m_lldbResult variables.

Reviewers: aprantl, clayborg, labath

Reviewed By: aprantl, clayborg

Subscribers: ki.stfu, lldb-commits

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

Modified:
lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp
lldb/trunk/tools/lldb-mi/MICmdCmdExec.h

Modified: lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp?rev=336009&r1=336008&r2=336009&view=diff
==
--- lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp Fri Jun 29 12:58:31 2018
@@ -126,21 +126,25 @@ bool CMICmdCmdExecRun::Execute() {
   }
 
   lldb::SBProcess process = rSessionInfo.GetTarget().Launch(launchInfo, error);
-  if ((!process.IsValid()) || (error.Fail())) {
+  if (!process.IsValid()) {
 SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_PROCESS),
m_cmdData.strMiCmd.c_str(),
errMsg.GetData()));
 return MIstatus::failure;
   }
 
-  if (!CMIDriver::Instance().SetDriverStateRunningDebugging()) {
-const CMIUtilString &rErrMsg(CMIDriver::Instance().GetErrorDescription());
-SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_SET_NEW_DRIVER_STATE),
-   m_cmdData.strMiCmd.c_str(),
-   rErrMsg.c_str()));
-return MIstatus::failure;
-  }
-  return MIstatus::success;
+  const auto successHandler = [this] {
+if (!CMIDriver::Instance().SetDriverStateRunningDebugging()) {
+  const CMIUtilString 
&rErrMsg(CMIDriver::Instance().GetErrorDescription());
+  SetError(CMIUtilString::Format(
+  MIRSRC(IDS_CMD_ERR_SET_NEW_DRIVER_STATE),
+  m_cmdData.strMiCmd.c_str(), rErrMsg.c_str()));
+  return MIstatus::failure;
+}
+return MIstatus::success;
+  };
+
+  return HandleSBErrorWithSuccess(error, successHandler);
 }
 
 //++
@@ -156,9 +160,8 @@ bool CMICmdCmdExecRun::Execute() {
 // Throws:  None.
 //--
 bool CMICmdCmdExecRun::Acknowledge() {
-  const CMICmnMIResultRecord miRecordResult(
+  m_miResultRecord = CMICmnMIResultRecord(
   m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Running);
-  m_miResultRecord = miRecordResult;
 
   CMICmnLLDBDebugSessionInfo &rSessionInfo(
   CMICmnLLDBDebugSessionInfo::Instance());
@@ -233,23 +236,21 @@ CMICmdCmdExecContinue::~CMICmdCmdExecCon
 // Throws:  None.
 //--
 bool CMICmdCmdExecContinue::Execute() {
-  lldb::SBError error =
-  CMICmnLLDBDebugSessionInfo::Instance().GetProcess().Continue();
- 
-  if (error.Success()) {
+  const auto successHandler = [this] {
 // CODETAG_DEBUG_SESSION_RUNNING_PROG_RECEIVED_SIGINT_PAUSE_PROGRAM
 if (!CMIDriver::Instance().SetDriverStateRunningDebugging()) {
   const CMIUtilString 
&rErrMsg(CMIDriver::Instance().GetErrorDescription());
-  SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_SET_NEW_DRIVER_STATE),
- m_cmdData.strMiCmd.c_str(),
- rErrMsg.c_str()));
+  SetError(CMIUtilString::Format(
+  MIRSRC(IDS_CMD_ERR_SET_NEW_DRIVER_STATE),
+  m_cmdData.strMiCmd.c_str(), rErrMsg.c_str()));
   return MIstatus::failure;
 }
 return MIstatus::success;
-  }
+  };
 
-  SetError(error.GetCString());
-  return MIstatus::failure;
+  return HandleSBErrorWithSuccess(
+  CMICmnLLDBDebugSessionInfo::Instance().GetProcess().Continue(),
+  successHandler);
 }
 
 //++
@@ -264,9 +265,8 @@ bool CMICmdCmdExecContinue::Execute() {
 // Throws:  None.
 //--
 bool CMICmdCmdExecContinue::Acknowledge() {
-  const CMICmnMIResultRecord miRecordResult(
+  m_miResultRecord = CMICmnMIResultRecord(
   m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Running);
-  m_miResultRecord = miRecordResult;
   return MIstatus::success;
 }
 
@@ -358,6 +358,7 @@ bool CMICmdCmdExecNext::Execute() {
   CMICmnLLDBDebugSessionInfo &rSessionInfo(
   CMICmnLLDBDebugSessionInfo::Instance());
 
+  lldb::SBError error;
   if (nThreadId != UINT64_MAX) {
 lldb::SBThread sbThread = 
rSessionInfo.GetProcess().GetThreadByIndexID(nThreadId);
 if (!sbThread.IsValid()) {
@@ -366,10 +367,12 @@ bool CMICmdCmdExecNext::Execute() {
  m_constStrArgThread.c_str()));
   return MIstatus::failure;
 }
-sbThread.StepOver();
-  } else rSessionInfo.GetProcess().GetSelectedThread().StepOver();
+sbThread.StepOver(lldb::eOnlyDuringStepping, error);
+  } else
+rSessionInfo.GetProcess().GetSelectedThread().StepOver(
+

[Lldb-commits] [PATCH] D47992: [lldb-mi] Clean up and update a few MI commands.

2018-06-29 Thread Alexander Polyakov via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL336009: [lldb-mi] Clean up and update a few MI commands. 
(authored by apolyakov, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D47992?vs=152694&id=153560#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47992

Files:
  lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp
  lldb/trunk/tools/lldb-mi/MICmdCmdExec.h

Index: lldb/trunk/tools/lldb-mi/MICmdCmdExec.h
===
--- lldb/trunk/tools/lldb-mi/MICmdCmdExec.h
+++ lldb/trunk/tools/lldb-mi/MICmdCmdExec.h
@@ -66,7 +66,6 @@
 private:
   const CMIUtilString m_constStrArgStart; // StopAtEntry - run to first
   // instruction or main() if specified
-  lldb::SBCommandReturnObject m_lldbResult;
 };
 
 //++
@@ -91,7 +90,6 @@
   bool Acknowledge() override;
   // From CMICmnBase
   /* dtor */ ~CMICmdCmdExecContinue() override;
-
   // Attributes:
 };
 
@@ -121,7 +119,6 @@
 
   // Attributes:
 private:
-  lldb::SBCommandReturnObject m_lldbResult;
   const CMIUtilString m_constStrArgNumber; // Not specified in MI spec but
// Eclipse gives this option
 };
Index: lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp
===
--- lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp
+++ lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp
@@ -126,21 +126,25 @@
   }
 
   lldb::SBProcess process = rSessionInfo.GetTarget().Launch(launchInfo, error);
-  if ((!process.IsValid()) || (error.Fail())) {
+  if (!process.IsValid()) {
 SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_PROCESS),
m_cmdData.strMiCmd.c_str(),
errMsg.GetData()));
 return MIstatus::failure;
   }
 
-  if (!CMIDriver::Instance().SetDriverStateRunningDebugging()) {
-const CMIUtilString &rErrMsg(CMIDriver::Instance().GetErrorDescription());
-SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_SET_NEW_DRIVER_STATE),
-   m_cmdData.strMiCmd.c_str(),
-   rErrMsg.c_str()));
-return MIstatus::failure;
-  }
-  return MIstatus::success;
+  const auto successHandler = [this] {
+if (!CMIDriver::Instance().SetDriverStateRunningDebugging()) {
+  const CMIUtilString &rErrMsg(CMIDriver::Instance().GetErrorDescription());
+  SetError(CMIUtilString::Format(
+  MIRSRC(IDS_CMD_ERR_SET_NEW_DRIVER_STATE),
+  m_cmdData.strMiCmd.c_str(), rErrMsg.c_str()));
+  return MIstatus::failure;
+}
+return MIstatus::success;
+  };
+
+  return HandleSBErrorWithSuccess(error, successHandler);
 }
 
 //++
@@ -156,9 +160,8 @@
 // Throws:  None.
 //--
 bool CMICmdCmdExecRun::Acknowledge() {
-  const CMICmnMIResultRecord miRecordResult(
+  m_miResultRecord = CMICmnMIResultRecord(
   m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Running);
-  m_miResultRecord = miRecordResult;
 
   CMICmnLLDBDebugSessionInfo &rSessionInfo(
   CMICmnLLDBDebugSessionInfo::Instance());
@@ -233,23 +236,21 @@
 // Throws:  None.
 //--
 bool CMICmdCmdExecContinue::Execute() {
-  lldb::SBError error =
-  CMICmnLLDBDebugSessionInfo::Instance().GetProcess().Continue();
- 
-  if (error.Success()) {
+  const auto successHandler = [this] {
 // CODETAG_DEBUG_SESSION_RUNNING_PROG_RECEIVED_SIGINT_PAUSE_PROGRAM
 if (!CMIDriver::Instance().SetDriverStateRunningDebugging()) {
   const CMIUtilString &rErrMsg(CMIDriver::Instance().GetErrorDescription());
-  SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_SET_NEW_DRIVER_STATE),
- m_cmdData.strMiCmd.c_str(),
- rErrMsg.c_str()));
+  SetError(CMIUtilString::Format(
+  MIRSRC(IDS_CMD_ERR_SET_NEW_DRIVER_STATE),
+  m_cmdData.strMiCmd.c_str(), rErrMsg.c_str()));
   return MIstatus::failure;
 }
 return MIstatus::success;
-  }
+  };
 
-  SetError(error.GetCString());
-  return MIstatus::failure;
+  return HandleSBErrorWithSuccess(
+  CMICmnLLDBDebugSessionInfo::Instance().GetProcess().Continue(),
+  successHandler);
 }
 
 //++
@@ -264,9 +265,8 @@
 // Throws:  None.
 //--
 bool CMICmdCmdExecContinue::Acknowledge() {
-  const CMICmnMIResultRecord miRecordResult(
+  m_miResultRecord = CMICmnMIResultRecord(
   m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Running);
-  m_miResultRecord = miRecordResult;
   return MIstatus::success;
 }
 
@@ -358,18 +358,21 @@
   CMICmnLLDBDebugSessionInfo &rSessionInfo(
   CMICmnLLDBDebugSessionInfo::Instance());
 
+  lldb::SBError error;
   if (nThreadId != UINT64_MAX) {
 lldb::SBThread sbThread = rSessionInfo.GetProcess().GetThreadByIndexID(nThreadId);
 if (!sbThread.IsValid()) {
   SetError(CMIUtilString::Format(MIRSRC

[Lldb-commits] [PATCH] D48782: LLDB Test Suite: Provide an Option to run all tests with Dwarf Package Format (DWP).

2018-06-29 Thread Alexander Shaposhnikov via Phabricator via lldb-commits
alexshap added inline comments.



Comment at: packages/Python/lldbsuite/test/make/Makefile.rules:238
 
+ifneq (,$(wildcard $(LLVM_DWP)))
+  MAKE_DWP=YES

aprantl wrote:
> Is the fact this this is *llvm-*dwp critical, or are llvm-dwp and GNU dwp 
> interchangeable? In the latter case, I'd prefer to drop the LLVM part from 
> the variable.
llvm-dwp and dwp should both work


https://reviews.llvm.org/D48782



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


[Lldb-commits] [PATCH] D48782: LLDB Test Suite: Provide an Option to run all tests with Dwarf Package Format (DWP).

2018-06-29 Thread Alexander Shaposhnikov via Phabricator via lldb-commits
alexshap added a comment.

@labath

> I am not denying that there is value in running the dotest suite in all of 
> these modes. In fact, I think that (the fact that we can use the same tests 
> to exercise a lot of different scenarios) is one of the strengths ?>of our 
> test suite. However, I don't believe all of these modes should be inflicted 
> onto everyone running lldb tests or be our first and only line of defense 
> against regressions.

for what it's worth - not sure how much you care about my opinion, but i think 
it's an important point but it doesn't actually contradict or prevent your 
second point regarding adding regression tests using lldb-test, however i think 
those should be added over time (sadly no tests were added when the support for 
.dwp was implemented / introduced) (not in this patch).
I think that the approach of this patch is still useful, this mode can be off 
by default, but if smb needs to run all the tests with dwps - it's easy to do 
by passing or setting a variable (for example).


https://reviews.llvm.org/D48782



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


[Lldb-commits] [PATCH] D48796: Refactoring for for the internal command line completion API (NFC)

2018-06-29 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
teemperor added reviewers: davide, jingham, labath.
Herald added a subscriber: mgorny.

This patch refactors the internal completion API. It now takes (as far as 
possible) a single
CompletionRequest object instead o half a dozen in/out/in-out parameters. The 
CompletionRequest
contains a common superset of the different parameters as far as it makes 
sense. This includes
the raw command line string and raw cursor position, which should make the 
`expr` command
possible to implement (at least without hacks that reconstruct the command line 
from the args).

This patch is not intended to change the observable behavior of lldb in any 
way. It's also as
minimal as possible and doesn't attempt to fix all the problems the API has.

Some Q&A:

Q: Why is this not fixing all the problems in the completion API?
A: Because is a blocker for the expr command completion which I want to get in 
ASAP. This is the

  smallest patch that unblocks the expr completion patch and which allows 
trivial refactoring in the future.
  The patch also doesn't really change the internal information flow in the 
API, so that hopefully
  saves us from ever having to revert and resubmit this humongous patch.

Q: Can we merge all the copy-pasted code in the completion methods

  (like computing the current incomplete arg) into CompletionRequest class?

A: Yes, but it's out of scope for this patch.

Q: Why the `word_complete = request.GetWordComplete(); ... ` pattern?
A: I don't want to add a getter that returns a reference to the internal 
integer. So we have

  to use a temporary variable and the Getter/Setter instead. We don't throw 
exceptions
  from what I can tell, so the behavior doesn't change.

Q: Why are we not owning the list of matches?
A: Because that's how the previous API works. But that should be fixed too (in 
another patch).

Q: Can we make the constructor simpler and compute some of the values from the 
plain command?
A: I think this works, but I rather want to have this in a follow up commit. 
Especially when making nested

  request it's a bit awkward that the parsed arguments behave as both 
input/output (as we should in theory
  propagate the changes on the nested request back to the parent request if we 
don't want to change the
  behavior too much).

Q: Can't we pass one const request object and then just return another result 
object instead of mixing

  them together in one in/out parameter?

A: It's hard to get keep the same behavior with that pattern, but I think we 
can also get a nice API with just

  a single request object. If we make all input parameters read-only, we have a 
clear separation between what
  is actually an input and what an output parameter (and hopefully we get rid 
of the in-out parameters).

Q: Can we throw out the 'match' variables that are not implemented according to 
the comment?
A: We currently just forward them as in the old code to the different methods, 
even though I think

  they are really not used. We can easily remove and readd them once every 
single completion method just
  takes a CompletionRequest, but for now I prefer NFC behavior from the 
perspective of the API user.


https://reviews.llvm.org/D48796

Files:
  include/lldb/Interpreter/CommandAlias.h
  include/lldb/Interpreter/CommandInterpreter.h
  include/lldb/Interpreter/CommandObject.h
  include/lldb/Interpreter/CommandObjectMultiword.h
  include/lldb/Interpreter/CommandObjectRegexCommand.h
  include/lldb/Utility/CompletionRequest.h
  source/Commands/CommandObjectCommands.cpp
  source/Commands/CommandObjectFrame.cpp
  source/Commands/CommandObjectHelp.cpp
  source/Commands/CommandObjectHelp.h
  source/Commands/CommandObjectMultiword.cpp
  source/Commands/CommandObjectPlatform.cpp
  source/Commands/CommandObjectPlugin.cpp
  source/Commands/CommandObjectProcess.cpp
  source/Commands/CommandObjectSettings.cpp
  source/Commands/CommandObjectTarget.cpp
  source/Interpreter/CommandAlias.cpp
  source/Interpreter/CommandInterpreter.cpp
  source/Interpreter/CommandObject.cpp
  source/Interpreter/CommandObjectRegexCommand.cpp
  source/Utility/CMakeLists.txt
  source/Utility/CompletionRequest.cpp
  unittests/Utility/CMakeLists.txt
  unittests/Utility/CompletionRequestTest.cpp

Index: unittests/Utility/CompletionRequestTest.cpp
===
--- /dev/null
+++ unittests/Utility/CompletionRequestTest.cpp
@@ -0,0 +1,38 @@
+//===-- CompletionRequestTest.cpp ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "gtest/gtest.h"
+
+#include "lldb/Utility/CompletionRequest.h"
+using namespace lldb_private;
+
+TEST(CompletionRequest, Constructor) {
+  std::string command = "a b";
+