[Lldb-commits] [PATCH] D41245: Reduce x86 register context boilerplate.

2017-12-15 Thread Pavel Labath via Phabricator via lldb-commits
labath updated this revision to Diff 127111.
labath added a comment.

New version. This one keeps the fxsave/xsave distinction, but it makes FPR a
union directly, so it saves us one level of indirection.


https://reviews.llvm.org/D41245

Files:
  source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
  source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp
  source/Plugins/Process/Utility/RegisterContext_x86.h
  source/Plugins/Process/Utility/RegisterInfos_i386.h
  source/Plugins/Process/Utility/RegisterInfos_x86_64.h

Index: source/Plugins/Process/Utility/RegisterInfos_x86_64.h
===
--- source/Plugins/Process/Utility/RegisterInfos_x86_64.h
+++ source/Plugins/Process/Utility/RegisterInfos_x86_64.h
@@ -16,25 +16,25 @@
 // Computes the offset of the given FPR in the extended data area.
 #define FPR_OFFSET(regname)\
   (LLVM_EXTENSION offsetof(UserArea, fpr) +\
-   LLVM_EXTENSION offsetof(FPR, xstate) +  \
+   LLVM_EXTENSION offsetof(FPR, fxsave) +  \
LLVM_EXTENSION offsetof(FXSAVE, regname))
 
 // Computes the offset of the YMM register assembled from register halves.
 // Based on DNBArchImplX86_64.cpp from debugserver
 #define YMM_OFFSET(reg_index)  \
   (LLVM_EXTENSION offsetof(UserArea, fpr) +\
-   LLVM_EXTENSION offsetof(FPR, xstate) +  \
+   LLVM_EXTENSION offsetof(FPR, xsave) +   \
LLVM_EXTENSION offsetof(XSAVE, ymmh[0]) + (32 * reg_index))
 
-#define BNDR_OFFSET(reg_index) \
-(LLVM_EXTENSION offsetof(UserArea, fpr) + \
- LLVM_EXTENSION offsetof(FPR, xstate) + \
- LLVM_EXTENSION offsetof(XSAVE, mpxr[reg_index]))
+#define BNDR_OFFSET(reg_index) \
+  (LLVM_EXTENSION offsetof(UserArea, fpr) +\
+   LLVM_EXTENSION offsetof(FPR, xsave) +   \
+   LLVM_EXTENSION offsetof(XSAVE, mpxr[reg_index]))
 
-#define BNDC_OFFSET(reg_index) \
-(LLVM_EXTENSION offsetof(UserArea, fpr) + \
- LLVM_EXTENSION offsetof(FPR, xstate) + \
- LLVM_EXTENSION offsetof(XSAVE, mpxc[reg_index]))
+#define BNDC_OFFSET(reg_index) \
+  (LLVM_EXTENSION offsetof(UserArea, fpr) +\
+   LLVM_EXTENSION offsetof(FPR, xsave) +   \
+   LLVM_EXTENSION offsetof(XSAVE, mpxc[reg_index]))
 
 #ifdef DECLARE_REGISTER_INFOS_X86_64_STRUCT
 
Index: source/Plugins/Process/Utility/RegisterInfos_i386.h
===
--- source/Plugins/Process/Utility/RegisterInfos_i386.h
+++ source/Plugins/Process/Utility/RegisterInfos_i386.h
@@ -27,19 +27,19 @@
 // Based on DNBArchImplI386.cpp from debugserver
 #define YMM_OFFSET(reg_index)  \
   (LLVM_EXTENSION offsetof(UserArea, i387) +   \
-   LLVM_EXTENSION offsetof(FPR, xstate) +  \
+   LLVM_EXTENSION offsetof(FPR, fxsave) +  \
LLVM_EXTENSION offsetof(FXSAVE, xmm[7]) + sizeof(XMMReg) +  \
(32 * reg_index))
 
-#define BNDR_OFFSET(reg_index) \
-(LLVM_EXTENSION offsetof(UserArea, i387) + \
- LLVM_EXTENSION offsetof(FPR, xstate) + \
- LLVM_EXTENSION offsetof(XSAVE, mpxr[reg_index]))
+#define BNDR_OFFSET(reg_index) \
+  (LLVM_EXTENSION offsetof(UserArea, i387) +   \
+   LLVM_EXTENSION offsetof(FPR, xsave) +   \
+   LLVM_EXTENSION offsetof(XSAVE, mpxr[reg_index]))
 
-#define BNDC_OFFSET(reg_index) \
-(LLVM_EXTENSION offsetof(UserArea, i387) + \
- LLVM_EXTENSION offsetof(FPR, xstate) + \
- LLVM_EXTENSION offsetof(XSAVE, mpxc[reg_index]))
+#define BNDC_OFFSET(reg_index) \
+  (LLVM_EXTENSION offsetof(UserArea, i387) +   \
+   LLVM_EXTENSION offsetof(FPR, xsave) +   \
+   LLVM_EXTENSION offsetof(XSAVE, mpxc[reg_index]))
 
 // Number of bytes needed to represent a FPR.
 #if !defined(FPR_SIZE)
Index: source/Plugins/Process/Utility/RegisterContext_x86.h
===
--- source/Plugins/Process/Utility/RegisterContext_x86.h
+++ source/Plugins/Process/Utility/RegisterContext_x86.h
@@ -355,12 +355,9 @@
 LLVM_PACKED_END
 
 // Floating-point registers
-struct FPR {
-  // Thread state for the floating-point unit of the processor read by ptrace.
-  union XSTA

[Lldb-commits] [PATCH] D41245: Reduce x86 register context boilerplate.

2017-12-15 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In https://reviews.llvm.org/D41245#97, @krytarowski wrote:

> Maybe reuse FPR for FXSAVE/FSAVE and add next to it XSAVE/XSAVE_OPT.


I am not sure what you mean by that, but I don't think it can work that way, as 
xsave area already contains a copy of the fpu registers, so we will end up 
having them twice. I have a feeling that for supporting fsave you will need to 
define your own register context (or just handle the transformation at a 
different layer -- this is how we avoided defining separate register context 
for minidumps -- we just rearrange the registers around to match the existing 
register context layout).


https://reviews.llvm.org/D41245



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


[Lldb-commits] [lldb] r320809 - llgs-tests: Make addition of new tests easier

2017-12-15 Thread Pavel Labath via lldb-commits
Author: labath
Date: Fri Dec 15 05:56:22 2017
New Revision: 320809

URL: http://llvm.org/viewvc/llvm-project?rev=320809&view=rev
Log:
llgs-tests: Make addition of new tests easier

Summary:
Adding a new test would require one to duplicate a significant part of
the existing test that we have. This attempts to reduce that by moving
some part of that code to the test fixture. The StandardStartupTest
fixture automatically starts up the server and connects it to the
client. I also add a more low-level TestBase fixture, which allows one
to start up the client and server in a custom way (I am going to need
this for the test I am writing).

Reviewers: eugene, zturner

Subscribers: lldb-commits, mgorny

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

Added:
lldb/trunk/unittests/tools/lldb-server/tests/TestBase.cpp
lldb/trunk/unittests/tools/lldb-server/tests/TestBase.h
Modified:
lldb/trunk/unittests/tools/lldb-server/CMakeLists.txt
lldb/trunk/unittests/tools/lldb-server/tests/CMakeLists.txt
lldb/trunk/unittests/tools/lldb-server/tests/MessageObjects.h
lldb/trunk/unittests/tools/lldb-server/tests/TestClient.cpp
lldb/trunk/unittests/tools/lldb-server/tests/TestClient.h
lldb/trunk/unittests/tools/lldb-server/tests/ThreadIdsInJstopinfoTest.cpp

Modified: lldb/trunk/unittests/tools/lldb-server/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/tools/lldb-server/CMakeLists.txt?rev=320809&r1=320808&r2=320809&view=diff
==
--- lldb/trunk/unittests/tools/lldb-server/CMakeLists.txt (original)
+++ lldb/trunk/unittests/tools/lldb-server/CMakeLists.txt Fri Dec 15 05:56:22 
2017
@@ -1,8 +1,12 @@
+set(ALL_LLDB_TEST_EXECUTABLES)
+
 function(add_lldb_test_executable test_name)
   set(EXCLUDE_FROM_ALL ON)
   add_llvm_executable(${test_name} NO_INSTALL_RPATH ${ARGN})
   set(outdir ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR})
   set_output_directory(${test_name} BINARY_DIR ${outdir} LIBRARY_DIR ${outdir})
+  list(APPEND ALL_LLDB_TEST_EXECUTABLES ${test_name})
+  set(ALL_LLDB_TEST_EXECUTABLES ${ALL_LLDB_TEST_EXECUTABLES} PARENT_SCOPE)
 endfunction()
 
 add_lldb_test_executable(thread_inferior inferior/thread_inferior.cpp)
@@ -13,6 +17,8 @@ else()
   add_definitions(-DLLDB_SERVER="$")
 endif()
 
-add_definitions(-DTHREAD_INFERIOR="${CMAKE_CURRENT_BINARY_DIR}/thread_inferior")
+add_definitions(
+  -DLLDB_TEST_INFERIOR_PATH="${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}"
+  -DLLDB_TEST_INFERIOR_SUFFIX="${CMAKE_EXECUTABLE_SUFFIX}"
+  )
 add_subdirectory(tests)
-add_dependencies(LLDBServerTests thread_inferior)

Modified: lldb/trunk/unittests/tools/lldb-server/tests/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/tools/lldb-server/tests/CMakeLists.txt?rev=320809&r1=320808&r2=320809&view=diff
==
--- lldb/trunk/unittests/tools/lldb-server/tests/CMakeLists.txt (original)
+++ lldb/trunk/unittests/tools/lldb-server/tests/CMakeLists.txt Fri Dec 15 
05:56:22 2017
@@ -1,4 +1,5 @@
 add_lldb_unittest(LLDBServerTests
+  TestBase.cpp
   TestClient.cpp
   MessageObjects.cpp
   ThreadIdsInJstopinfoTest.cpp
@@ -15,3 +16,5 @@ add_lldb_unittest(LLDBServerTests
   LINK_COMPONENTS
 Support
   )
+
+add_dependencies(LLDBServerTests lldb-server ${ALL_LLDB_TEST_EXECUTABLES})

Modified: lldb/trunk/unittests/tools/lldb-server/tests/MessageObjects.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/tools/lldb-server/tests/MessageObjects.h?rev=320809&r1=320808&r2=320809&view=diff
==
--- lldb/trunk/unittests/tools/lldb-server/tests/MessageObjects.h (original)
+++ lldb/trunk/unittests/tools/lldb-server/tests/MessageObjects.h Fri Dec 15 
05:56:22 2017
@@ -7,6 +7,9 @@
 //
 
//===--===//
 
+#ifndef LLDB_SERVER_TESTS_MESSAGEOBJECTS_H
+#define LLDB_SERVER_TESTS_MESSAGEOBJECTS_H
+
 #include "lldb/lldb-types.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/SmallString.h"
@@ -102,4 +105,7 @@ llvm::Error make_parsing_error(llvm::Str
   return llvm::make_error(error,
  llvm::inconvertibleErrorCode());
 }
+
 } // namespace llgs_tests
+
+#endif // LLDB_SERVER_TESTS_MESSAGEOBJECTS_H

Added: lldb/trunk/unittests/tools/lldb-server/tests/TestBase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/tools/lldb-server/tests/TestBase.cpp?rev=320809&view=auto
==
--- lldb/trunk/unittests/tools/lldb-server/tests/TestBase.cpp (added)
+++ lldb/trunk/unittests/tools/lldb-server/tests/TestBase.cpp Fri Dec 15 
05:56:22 2017
@@ -0,0 +1,36 @@
+//===-- TestBase.cpp *- C++ 
-*-===//
+//
+// T

[Lldb-commits] [PATCH] D41066: llgs-tests: Make addition of new tests easier

2017-12-15 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL320809: llgs-tests: Make addition of new tests easier 
(authored by labath, committed by ).

Repository:
  rL LLVM

https://reviews.llvm.org/D41066

Files:
  lldb/trunk/unittests/tools/lldb-server/CMakeLists.txt
  lldb/trunk/unittests/tools/lldb-server/tests/CMakeLists.txt
  lldb/trunk/unittests/tools/lldb-server/tests/MessageObjects.h
  lldb/trunk/unittests/tools/lldb-server/tests/TestBase.cpp
  lldb/trunk/unittests/tools/lldb-server/tests/TestBase.h
  lldb/trunk/unittests/tools/lldb-server/tests/TestClient.cpp
  lldb/trunk/unittests/tools/lldb-server/tests/TestClient.h
  lldb/trunk/unittests/tools/lldb-server/tests/ThreadIdsInJstopinfoTest.cpp

Index: lldb/trunk/unittests/tools/lldb-server/tests/TestBase.h
===
--- lldb/trunk/unittests/tools/lldb-server/tests/TestBase.h
+++ lldb/trunk/unittests/tools/lldb-server/tests/TestBase.h
@@ -0,0 +1,48 @@
+//===-- TestBase.h --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLDB_SERVER_TESTS_TESTBASE_H
+#define LLDB_SERVER_TESTS_TESTBASE_H
+
+#include "TestClient.h"
+#include "lldb/Host/HostInfo.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Testing/Support/Error.h"
+#include "gtest/gtest.h"
+
+namespace llgs_tests {
+
+class TestBase: public ::testing::Test {
+public:
+  static void SetUpTestCase() { lldb_private::HostInfo::Initialize(); }
+
+  static std::string getInferiorPath(llvm::StringRef Name) {
+llvm::SmallString<64> Path(LLDB_TEST_INFERIOR_PATH);
+llvm::sys::path::append(Path, Name + LLDB_TEST_INFERIOR_SUFFIX);
+return Path.str();
+  }
+
+  static std::string getLogFileName();
+};
+
+class StandardStartupTest: public TestBase {
+public:
+  void SetUp() override {
+auto ClientOr = TestClient::launch(getLogFileName());
+ASSERT_THAT_EXPECTED(ClientOr, llvm::Succeeded());
+Client = std::move(*ClientOr);
+  }
+
+protected:
+  std::unique_ptr Client;
+};
+
+} // namespace llgs_tests
+
+#endif // LLDB_SERVER_TESTS_TESTBASE_H
Index: lldb/trunk/unittests/tools/lldb-server/tests/TestClient.cpp
===
--- lldb/trunk/unittests/tools/lldb-server/tests/TestClient.cpp
+++ lldb/trunk/unittests/tools/lldb-server/tests/TestClient.cpp
@@ -15,6 +15,7 @@
 #include "lldb/Target/ProcessLaunchInfo.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Testing/Support/Error.h"
 #include "gtest/gtest.h"
 #include 
 #include 
@@ -26,72 +27,73 @@
 using namespace llvm;
 
 namespace llgs_tests {
-void TestClient::Initialize() { HostInfo::Initialize(); }
-
 bool TestClient::IsDebugServer() {
   return sys::path::filename(LLDB_SERVER).contains("debugserver");
 }
 
 bool TestClient::IsLldbServer() { return !IsDebugServer(); }
 
-TestClient::TestClient(const std::string &test_name,
-   const std::string &test_case_name)
-: m_test_name(test_name), m_test_case_name(test_case_name),
-  m_pc_register(UINT_MAX) {}
+TestClient::TestClient(std::unique_ptr Conn) {
+  SetConnection(Conn.release());
+
+  SendAck(); // Send this as a handshake.
+}
+
+TestClient::~TestClient() {
+  std::string response;
+  // Debugserver (non-conformingly?) sends a reply to the k packet instead of
+  // simply closing the connection.
+  PacketResult result =
+  IsDebugServer() ? PacketResult::Success : PacketResult::ErrorDisconnected;
+  EXPECT_THAT_ERROR(SendMessage("k", response, result), Succeeded());
+}
 
-TestClient::~TestClient() {}
+Expected> TestClient::launch(StringRef Log) {
+  return launch(Log, {});
+}
 
-llvm::Error TestClient::StartDebugger() {
+Expected> TestClient::launch(StringRef Log, ArrayRef InferiorArgs) {
   const ArchSpec &arch_spec = HostInfo::GetArchitecture();
   Args args;
   args.AppendArgument(LLDB_SERVER);
-  if (IsLldbServer()) {
+  if (IsLldbServer())
 args.AppendArgument("gdbserver");
-args.AppendArgument("--log-channels=gdb-remote packets");
-  } else {
-args.AppendArgument("--log-flags=0x80");
-  }
   args.AppendArgument("--reverse-connect");
-  std::string log_file_name = GenerateLogFileName(arch_spec);
-  if (log_file_name.size())
-args.AppendArgument("--log-file=" + log_file_name);
+
+  if (!Log.empty()) {
+args.AppendArgument(("--log-file=" + Log).str());
+if (IsLldbServer())
+  args.AppendArgument("--log-channels=gdb-remote packets");
+else
+  args.AppendArgument("--log-flags=0x80");
+  }
 
   Status status;
   TCPSocket listen_socket(true, false);
   status = listen_socket.Listen("127.0.0.1:0", 5);
   if (status.Fail())
 return status.ToErr

[Lldb-commits] [lldb] r320813 - ObjectFileELF: Add support for compressed sections

2017-12-15 Thread Pavel Labath via lldb-commits
Author: labath
Date: Fri Dec 15 06:23:58 2017
New Revision: 320813

URL: http://llvm.org/viewvc/llvm-project?rev=320813&view=rev
Log:
ObjectFileELF: Add support for compressed sections

Summary:
We use the llvm decompressor to decompress SHF_COMPRESSED sections. This enables
us to read data from debug info sections, which are sometimes compressed,
particuarly in the split-dwarf case.  This functionality is only available if
llvm is compiled with zlib support.

Reviewers: clayborg, zturner

Subscribers: emaste, mgorny, aprantl, lldb-commits

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

Added:
lldb/trunk/lit/Modules/
lldb/trunk/lit/Modules/compressed-sections.yaml
lldb/trunk/lit/Modules/lit.local.cfg
Modified:
lldb/trunk/include/lldb/Symbol/ObjectFile.h
lldb/trunk/lit/CMakeLists.txt
lldb/trunk/lit/lit.cfg
lldb/trunk/lit/lit.site.cfg.in
lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
lldb/trunk/tools/lldb-test/lldb-test.cpp
lldb/trunk/unittests/ObjectFile/ELF/TestObjectFileELF.cpp

Modified: lldb/trunk/include/lldb/Symbol/ObjectFile.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ObjectFile.h?rev=320813&r1=320812&r2=320813&view=diff
==
--- lldb/trunk/include/lldb/Symbol/ObjectFile.h (original)
+++ lldb/trunk/include/lldb/Symbol/ObjectFile.h Fri Dec 15 06:23:58 2017
@@ -793,15 +793,24 @@ public:
   static lldb::DataBufferSP ReadMemory(const lldb::ProcessSP &process_sp,
lldb::addr_t addr, size_t byte_size);
 
+  // This function returns raw file contents. Do not use it if you want
+  // transparent decompression of section contents.
   size_t GetData(lldb::offset_t offset, size_t length,
  DataExtractor &data) const;
 
+  // This function returns raw file contents. Do not use it if you want
+  // transparent decompression of section contents.
   size_t CopyData(lldb::offset_t offset, size_t length, void *dst) const;
 
+  // This function will transparently decompress section data if the section if
+  // compressed.
   virtual size_t ReadSectionData(Section *section,
  lldb::offset_t section_offset, void *dst,
  size_t dst_len);
 
+  // This function will transparently decompress section data if the section if
+  // compressed. Note that for compressed section the resulting data size may 
be
+  // larger than what Section::GetFileSize reports.
   virtual size_t ReadSectionData(Section *section,
  DataExtractor §ion_data);
 

Modified: lldb/trunk/lit/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/CMakeLists.txt?rev=320813&r1=320812&r2=320813&view=diff
==
--- lldb/trunk/lit/CMakeLists.txt (original)
+++ lldb/trunk/lit/CMakeLists.txt Fri Dec 15 06:23:58 2017
@@ -22,10 +22,11 @@ configure_lit_site_cfg(
 set(LLDB_TEST_DEPS
   LLDBUnitTests
   lldb
+  lldb-test
   )
 
 if(NOT LLDB_BUILT_STANDALONE)
-  list(APPEND LLDB_TEST_DEPS FileCheck not)
+  list(APPEND LLDB_TEST_DEPS FileCheck not yaml2obj)
 endif()
   
 # lldb-server is not built on every platform.

Added: lldb/trunk/lit/Modules/compressed-sections.yaml
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/compressed-sections.yaml?rev=320813&view=auto
==
--- lldb/trunk/lit/Modules/compressed-sections.yaml (added)
+++ lldb/trunk/lit/Modules/compressed-sections.yaml Fri Dec 15 06:23:58 2017
@@ -0,0 +1,30 @@
+# REQUIRES: zlib
+# RUN: yaml2obj %s > %t
+# RUN: lldb-test module-sections --contents %t | FileCheck %s
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS32
+  Data:ELFDATA2LSB
+  Type:ET_REL
+  Machine: EM_386
+Sections:
+  - Name:.hello_elf
+Type:SHT_PROGBITS
+Flags:   [ SHF_COMPRESSED ]
+Content: 010008000100789c533070084828689809c802c1
+  - Name:.bogus
+Type:SHT_PROGBITS
+Flags:   [ SHF_COMPRESSED ]
+Content: deadbeefbaadf00d
+
+# CHECK: Name: .hello_elf
+# CHECK-NEXT: VM size: 0
+# CHECK-NEXT: File size: 28
+# CHECK-NEXT: Data:
+# CHECK-NEXT: 20304050 60708090
+
+# CHECK: Name: .bogus
+# CHECK-NEXT: VM size: 0
+# CHECK-NEXT: File size: 8
+# CHECK-NEXT: Data:
+# CHECK-NEXT: DEADBEEF BAADF00D

Added: lldb/trunk/lit/Modules/lit.local.cfg
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/lit.local.cfg?rev=320813&view=auto
==
--- lldb/trunk/lit/Modules/lit.local.cfg (added)
+++ lldb/trunk/lit/Modules/lit.local.cfg Fri Dec 15 06:23:58 2017
@@ -0,0 +1 @@
+config.suff

[Lldb-commits] [PATCH] D40616: ObjectFileELF: Add support for compressed sections

2017-12-15 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 rL320813: ObjectFileELF: Add support for compressed sections 
(authored by labath, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D40616?vs=126975&id=127120#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D40616

Files:
  lldb/trunk/include/lldb/Symbol/ObjectFile.h
  lldb/trunk/lit/CMakeLists.txt
  lldb/trunk/lit/Modules/compressed-sections.yaml
  lldb/trunk/lit/Modules/lit.local.cfg
  lldb/trunk/lit/lit.cfg
  lldb/trunk/lit/lit.site.cfg.in
  lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
  lldb/trunk/tools/lldb-test/lldb-test.cpp
  lldb/trunk/unittests/ObjectFile/ELF/TestObjectFileELF.cpp

Index: lldb/trunk/lit/lit.site.cfg.in
===
--- lldb/trunk/lit/lit.site.cfg.in
+++ lldb/trunk/lit/lit.site.cfg.in
@@ -12,6 +12,7 @@
 config.python_executable = "@PYTHON_EXECUTABLE@"
 config.cc = "@LLDB_TEST_C_COMPILER@"
 config.cxx = "@LLDB_TEST_CXX_COMPILER@"
+config.have_zlib = @HAVE_LIBZ@
 
 # Support substitution of the tools and libs dirs with user parameters. This is
 # used when we can't determine the tool dir at configuration time.
Index: lldb/trunk/lit/CMakeLists.txt
===
--- lldb/trunk/lit/CMakeLists.txt
+++ lldb/trunk/lit/CMakeLists.txt
@@ -22,10 +22,11 @@
 set(LLDB_TEST_DEPS
   LLDBUnitTests
   lldb
+  lldb-test
   )
 
 if(NOT LLDB_BUILT_STANDALONE)
-  list(APPEND LLDB_TEST_DEPS FileCheck not)
+  list(APPEND LLDB_TEST_DEPS FileCheck not yaml2obj)
 endif()
   
 # lldb-server is not built on every platform.
Index: lldb/trunk/lit/Modules/lit.local.cfg
===
--- lldb/trunk/lit/Modules/lit.local.cfg
+++ lldb/trunk/lit/Modules/lit.local.cfg
@@ -0,0 +1 @@
+config.suffixes = ['.yaml']
Index: lldb/trunk/lit/Modules/compressed-sections.yaml
===
--- lldb/trunk/lit/Modules/compressed-sections.yaml
+++ lldb/trunk/lit/Modules/compressed-sections.yaml
@@ -0,0 +1,30 @@
+# REQUIRES: zlib
+# RUN: yaml2obj %s > %t
+# RUN: lldb-test module-sections --contents %t | FileCheck %s
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS32
+  Data:ELFDATA2LSB
+  Type:ET_REL
+  Machine: EM_386
+Sections:
+  - Name:.hello_elf
+Type:SHT_PROGBITS
+Flags:   [ SHF_COMPRESSED ]
+Content: 010008000100789c533070084828689809c802c1
+  - Name:.bogus
+Type:SHT_PROGBITS
+Flags:   [ SHF_COMPRESSED ]
+Content: deadbeefbaadf00d
+
+# CHECK: Name: .hello_elf
+# CHECK-NEXT: VM size: 0
+# CHECK-NEXT: File size: 28
+# CHECK-NEXT: Data:
+# CHECK-NEXT: 20304050 60708090
+
+# CHECK: Name: .bogus
+# CHECK-NEXT: VM size: 0
+# CHECK-NEXT: File size: 8
+# CHECK-NEXT: Data:
+# CHECK-NEXT: DEADBEEF BAADF00D
Index: lldb/trunk/lit/lit.cfg
===
--- lldb/trunk/lit/lit.cfg
+++ lldb/trunk/lit/lit.cfg
@@ -9,6 +9,9 @@
 import lit.formats
 import lit.util
 
+def binary_feature(on, feature, off_prefix):
+  return feature if on else off_prefix + feature
+
 # Configuration file for the 'lit' test runner.
 
 # name: The name of this test suite.
@@ -81,6 +84,8 @@
 config.substitutions.append(('%debugserver', debugserver))
 
 for pattern in [r"\bFileCheck\b",
+r"\blldb-test\b",
+r"\byaml2obj\b",
 r"\| \bnot\b"]:
 tool_match = re.match(r"^(\\)?((\| )?)\W+b([0-9A-Za-z-_]+)\\b\W*$",
   pattern)
@@ -125,6 +130,8 @@
 elif re.match(r'cl', config.cc):
 config.available_features.add("compiler-msvc")
 
+config.available_features.add(binary_feature(config.have_zlib, "zlib", "no"))
+
 # llvm-config knows whether it is compiled with asserts (and)
 # whether we are operating in release/debug mode.
 import subprocess
Index: lldb/trunk/include/lldb/Symbol/ObjectFile.h
===
--- lldb/trunk/include/lldb/Symbol/ObjectFile.h
+++ lldb/trunk/include/lldb/Symbol/ObjectFile.h
@@ -793,15 +793,24 @@
   static lldb::DataBufferSP ReadMemory(const lldb::ProcessSP &process_sp,
lldb::addr_t addr, size_t byte_size);
 
+  // This function returns raw file contents. Do not use it if you want
+  // transparent decompression of section contents.
   size_t GetData(lldb::offset_t offset, size_t length,
  DataExtractor &data) const;
 
+  // This function returns raw file contents. Do not use it if you want
+  // transparent decompression of section contents.
   size_t CopyData(lldb::offset_t offset

[Lldb-commits] [lldb] r320816 - Fix 32-bit builds broken by 320813

2017-12-15 Thread Pavel Labath via lldb-commits
Author: labath
Date: Fri Dec 15 06:39:12 2017
New Revision: 320816

URL: http://llvm.org/viewvc/llvm-project?rev=320816&view=rev
Log:
Fix 32-bit builds broken by 320813

cast to size_t to avoid narrowing error.

Modified:
lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp

Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp?rev=320816&r1=320815&r2=320816&view=diff
==
--- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Fri Dec 15 
06:39:12 2017
@@ -3496,7 +3496,7 @@ size_t ObjectFileELF::ReadSectionData(Se
   auto Decompressor = llvm::object::Decompressor::create(
   section->GetName().GetStringRef(),
   {reinterpret_cast(section_data.GetDataStart()),
-   section_data.GetByteSize()},
+   size_t(section_data.GetByteSize())},
   GetByteOrder() == eByteOrderLittle, GetAddressByteSize() == 8);
   if (!Decompressor) {
 LLDB_LOG(log, "Unable to initialize decompressor for section {0}: {1}",
@@ -3507,7 +3507,7 @@ size_t ObjectFileELF::ReadSectionData(Se
   std::make_shared(Decompressor->getDecompressedSize(), 0);
   if (auto Error = Decompressor->decompress(
   {reinterpret_cast(buffer_sp->GetBytes()),
-   buffer_sp->GetByteSize()})) {
+   size_t(buffer_sp->GetByteSize())})) {
 LLDB_LOG(log, "Decompression of section {0} failed: {1}",
  section->GetName(), llvm::toString(std::move(Error)));
 return result;


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


[Lldb-commits] [PATCH] D41245: Reduce x86 register context boilerplate.

2017-12-15 Thread Kamil Rytarowski via Phabricator via lldb-commits
krytarowski added a comment.

In https://reviews.llvm.org/D41245#956644, @labath wrote:

> In https://reviews.llvm.org/D41245#97, @krytarowski wrote:
>
> > Maybe reuse FPR for FXSAVE/FSAVE and add next to it XSAVE/XSAVE_OPT.
>
>
> I am not sure what you mean by that, but I don't think it can work that way, 
> as xsave area already contains a copy of the fpu registers, so we will end up 
> having them twice. I have a feeling that for supporting fsave you will need 
> to define your own register context (or just handle the transformation at a 
> different layer -- this is how we avoided defining separate register context 
> for minidumps -- we just rearrange the registers around to match the existing 
> register context layout).


I was thinking about split of FPU into two or more structs/unions.

But the newer version on review is better!


https://reviews.llvm.org/D41245



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


[Lldb-commits] [PATCH] D41067: llgs-tests: Add support for "exit" stop-reply packets

2017-12-15 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL320820: llgs-tests: Add support for "exit" 
stop-reply packets (authored by labath, committed by ).

Repository:
  rL LLVM

https://reviews.llvm.org/D41067

Files:
  lldb/trunk/include/lldb/Host/Host.h
  lldb/trunk/unittests/tools/lldb-server/tests/MessageObjects.cpp
  lldb/trunk/unittests/tools/lldb-server/tests/MessageObjects.h
  lldb/trunk/unittests/tools/lldb-server/tests/TestClient.cpp
  lldb/trunk/unittests/tools/lldb-server/tests/TestClient.h
  lldb/trunk/unittests/tools/lldb-server/tests/ThreadIdsInJstopinfoTest.cpp

Index: lldb/trunk/include/lldb/Host/Host.h
===
--- lldb/trunk/include/lldb/Host/Host.h
+++ lldb/trunk/include/lldb/Host/Host.h
@@ -48,6 +48,12 @@
   static WaitStatus Decode(int wstatus);
 };
 
+inline bool operator==(WaitStatus a, WaitStatus b) {
+  return a.type == b.type && a.status == b.status;
+}
+
+inline bool operator!=(WaitStatus a, WaitStatus b) { return !(a == b); }
+
 //--
 /// @class Host Host.h "lldb/Host/Host.h"
 /// @brief A class that provides host computer information.
Index: lldb/trunk/unittests/tools/lldb-server/tests/TestClient.cpp
===
--- lldb/trunk/unittests/tools/lldb-server/tests/TestClient.cpp
+++ lldb/trunk/unittests/tools/lldb-server/tests/TestClient.cpp
@@ -154,7 +154,8 @@
 }
 
 const StopReply &TestClient::GetLatestStopReply() {
-  return m_stop_reply.getValue();
+  assert(m_stop_reply);
+  return *m_stop_reply;
 }
 
 Error TestClient::SendMessage(StringRef message) {
@@ -236,7 +237,7 @@
   std::string response;
   if (Error E = SendMessage(message, response))
 return E;
-  auto creation = StopReply::Create(response, m_process_info->GetEndian());
+  auto creation = StopReply::create(response, m_process_info->GetEndian());
   if (Error E = creation.takeError())
 return E;
 
Index: lldb/trunk/unittests/tools/lldb-server/tests/MessageObjects.cpp
===
--- lldb/trunk/unittests/tools/lldb-server/tests/MessageObjects.cpp
+++ lldb/trunk/unittests/tools/lldb-server/tests/MessageObjects.cpp
@@ -133,70 +133,91 @@
 }
 
 //== StopReply =
-const U64Map &StopReply::GetThreadPcs() const { return m_thread_pcs; }
-
-Expected StopReply::Create(StringRef response,
-  llvm::support::endianness endian) {
-  if (response.size() < 3 || !response.consume_front("T"))
+Expected>
+StopReply::create(StringRef Response, llvm::support::endianness Endian) {
+  if (Response.size() < 3)
 return make_parsing_error("StopReply: Invalid packet");
+  if (Response.consume_front("T"))
+return StopReplyStop::create(Response, Endian);
+  if (Response.consume_front("W"))
+return StopReplyExit::create(Response);
+  return make_parsing_error("StopReply: Invalid packet");
+}
 
-  StopReply stop_reply;
-
-  StringRef signal = response.take_front(2);
-  response = response.drop_front(2);
-  if (!llvm::to_integer(signal, stop_reply.m_signal, 16))
+Expected>
+StopReplyStop::create(StringRef Response, llvm::support::endianness Endian) {
+  unsigned int Signal;
+  StringRef SignalStr = Response.take_front(2);
+  Response = Response.drop_front(2);
+  if (!to_integer(SignalStr, Signal, 16))
 return make_parsing_error("StopReply: stop signal");
 
-  auto elements = SplitPairList(response);
-  for (StringRef field :
+  auto Elements = SplitPairList(Response);
+  for (StringRef Field :
{"name", "reason", "thread", "threads", "thread-pcs"}) {
 // This will insert an empty field if there is none. In the future, we
 // should probably differentiate between these fields not being present and
 // them being empty, but right now no tests depends on this.
-if (elements.insert({field, {""}}).first->second.size() != 1)
+if (Elements.insert({Field, {""}}).first->second.size() != 1)
   return make_parsing_error(
-  "StopReply: got multiple responses for the {0} field", field);
+  "StopReply: got multiple responses for the {0} field", Field);
   }
-  stop_reply.m_name = elements["name"][0];
-  stop_reply.m_reason = elements["reason"][0];
+  StringRef Name = Elements["name"][0];
+  StringRef Reason = Elements["reason"][0];
 
-  if (!llvm::to_integer(elements["thread"][0], stop_reply.m_thread, 16))
+  lldb::tid_t Thread;
+  if (!to_integer(Elements["thread"][0], Thread, 16))
 return make_parsing_error("StopReply: thread");
 
-  SmallVector threads;
-  SmallVector pcs;
-  elements["threads"][0].split(threads, ',');
-  elements["thread-pcs"][0].split(pcs, ',');
-  if (threads.size() != pcs.size())
+  SmallVector Threads;
+  SmallVector Pcs;
+  Elements["threads"][0].split(Threads, ',');
+  Elements["thread-pcs"]

[Lldb-commits] [lldb] r320820 - llgs-tests: Add support for "exit" stop-reply packets

2017-12-15 Thread Pavel Labath via lldb-commits
Author: labath
Date: Fri Dec 15 07:19:45 2017
New Revision: 320820

URL: http://llvm.org/viewvc/llvm-project?rev=320820&view=rev
Log:
llgs-tests: Add support for "exit" stop-reply packets

Summary:
This makes StopReply class abstract, so that we can represent different
types of stop replies such as StopReplyStop and StopReplyExit (there
should also be a StopReplySignal, but I don't need that right now so I
haven't implemented it yet).

This prepares the ground for a new test I'm writing.

Reviewers: eugene, zturner

Subscribers: lldb-commits

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

Modified:
lldb/trunk/include/lldb/Host/Host.h
lldb/trunk/unittests/tools/lldb-server/tests/MessageObjects.cpp
lldb/trunk/unittests/tools/lldb-server/tests/MessageObjects.h
lldb/trunk/unittests/tools/lldb-server/tests/TestClient.cpp
lldb/trunk/unittests/tools/lldb-server/tests/TestClient.h
lldb/trunk/unittests/tools/lldb-server/tests/ThreadIdsInJstopinfoTest.cpp

Modified: lldb/trunk/include/lldb/Host/Host.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Host.h?rev=320820&r1=320819&r2=320820&view=diff
==
--- lldb/trunk/include/lldb/Host/Host.h (original)
+++ lldb/trunk/include/lldb/Host/Host.h Fri Dec 15 07:19:45 2017
@@ -48,6 +48,12 @@ struct WaitStatus {
   static WaitStatus Decode(int wstatus);
 };
 
+inline bool operator==(WaitStatus a, WaitStatus b) {
+  return a.type == b.type && a.status == b.status;
+}
+
+inline bool operator!=(WaitStatus a, WaitStatus b) { return !(a == b); }
+
 //--
 /// @class Host Host.h "lldb/Host/Host.h"
 /// @brief A class that provides host computer information.

Modified: lldb/trunk/unittests/tools/lldb-server/tests/MessageObjects.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/tools/lldb-server/tests/MessageObjects.cpp?rev=320820&r1=320819&r2=320820&view=diff
==
--- lldb/trunk/unittests/tools/lldb-server/tests/MessageObjects.cpp (original)
+++ lldb/trunk/unittests/tools/lldb-server/tests/MessageObjects.cpp Fri Dec 15 
07:19:45 2017
@@ -133,70 +133,91 @@ const ThreadInfoMap &JThreadsInfo::GetTh
 }
 
 //== StopReply 
=
-const U64Map &StopReply::GetThreadPcs() const { return m_thread_pcs; }
-
-Expected StopReply::Create(StringRef response,
-  llvm::support::endianness endian) {
-  if (response.size() < 3 || !response.consume_front("T"))
+Expected>
+StopReply::create(StringRef Response, llvm::support::endianness Endian) {
+  if (Response.size() < 3)
 return make_parsing_error("StopReply: Invalid packet");
+  if (Response.consume_front("T"))
+return StopReplyStop::create(Response, Endian);
+  if (Response.consume_front("W"))
+return StopReplyExit::create(Response);
+  return make_parsing_error("StopReply: Invalid packet");
+}
 
-  StopReply stop_reply;
-
-  StringRef signal = response.take_front(2);
-  response = response.drop_front(2);
-  if (!llvm::to_integer(signal, stop_reply.m_signal, 16))
+Expected>
+StopReplyStop::create(StringRef Response, llvm::support::endianness Endian) {
+  unsigned int Signal;
+  StringRef SignalStr = Response.take_front(2);
+  Response = Response.drop_front(2);
+  if (!to_integer(SignalStr, Signal, 16))
 return make_parsing_error("StopReply: stop signal");
 
-  auto elements = SplitPairList(response);
-  for (StringRef field :
+  auto Elements = SplitPairList(Response);
+  for (StringRef Field :
{"name", "reason", "thread", "threads", "thread-pcs"}) {
 // This will insert an empty field if there is none. In the future, we
 // should probably differentiate between these fields not being present and
 // them being empty, but right now no tests depends on this.
-if (elements.insert({field, {""}}).first->second.size() != 1)
+if (Elements.insert({Field, {""}}).first->second.size() != 1)
   return make_parsing_error(
-  "StopReply: got multiple responses for the {0} field", field);
+  "StopReply: got multiple responses for the {0} field", Field);
   }
-  stop_reply.m_name = elements["name"][0];
-  stop_reply.m_reason = elements["reason"][0];
+  StringRef Name = Elements["name"][0];
+  StringRef Reason = Elements["reason"][0];
 
-  if (!llvm::to_integer(elements["thread"][0], stop_reply.m_thread, 16))
+  lldb::tid_t Thread;
+  if (!to_integer(Elements["thread"][0], Thread, 16))
 return make_parsing_error("StopReply: thread");
 
-  SmallVector threads;
-  SmallVector pcs;
-  elements["threads"][0].split(threads, ',');
-  elements["thread-pcs"][0].split(pcs, ',');
-  if (threads.size() != pcs.size())
+  SmallVector Threads;
+  SmallVector Pcs;
+  Elements["threads"][0].split(Threads, ',');
+  Elements["thread-pcs"][0

[Lldb-commits] [lldb] r320883 - [MacOSX/Queues] Relax an overly aggressive assertion in a test.

2017-12-15 Thread Davide Italiano via lldb-commits
Author: davide
Date: Fri Dec 15 14:22:51 2017
New Revision: 320883

URL: http://llvm.org/viewvc/llvm-project?rev=320883&view=rev
Log:
[MacOSX/Queues] Relax an overly aggressive assertion in a test.

"Default" is a valid QoS for a thread on older versions of macOS,
like the one installed in the bot.
Thanks to Jason Molenda for helping me figuring out the problem.



Modified:
lldb/trunk/packages/Python/lldbsuite/test/macosx/queues/TestQueues.py

Modified: lldb/trunk/packages/Python/lldbsuite/test/macosx/queues/TestQueues.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/macosx/queues/TestQueues.py?rev=320883&r1=320882&r2=320883&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/macosx/queues/TestQueues.py 
(original)
+++ lldb/trunk/packages/Python/lldbsuite/test/macosx/queues/TestQueues.py Fri 
Dec 15 14:22:51 2017
@@ -230,8 +230,9 @@ class TestQueues(TestBase):
 "requested_qos.printable_name",
 stream),
 "Get QoS printable string for unspecified QoS thread")
+qosName = stream.GetData()
 self.assertTrue(
-stream.GetData() == "User Initiated",
+qosName == "User Initiated" or qosName == "Default",
 "unspecified QoS thread name is valid")
 stream.Clear()
 self.assertTrue(


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


[Lldb-commits] [PATCH] D41245: Reduce x86 register context boilerplate.

2017-12-15 Thread Greg Clayton via Phabricator via lldb-commits
clayborg accepted this revision.
clayborg added a comment.

Looks good


https://reviews.llvm.org/D41245



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


[Lldb-commits] [lldb] r320891 - [CMake] darwin-debug is an hard dependency for tests on macOS.

2017-12-15 Thread Davide Italiano via lldb-commits
Author: davide
Date: Fri Dec 15 15:27:10 2017
New Revision: 320891

URL: http://llvm.org/viewvc/llvm-project?rev=320891&view=rev
Log:
[CMake] darwin-debug is an hard dependency for tests on macOS.

Fixes a few failured on the testsuite with CMake.

Modified:
lldb/trunk/test/CMakeLists.txt

Modified: lldb/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/CMakeLists.txt?rev=320891&r1=320890&r2=320891&view=diff
==
--- lldb/trunk/test/CMakeLists.txt (original)
+++ lldb/trunk/test/CMakeLists.txt Fri Dec 15 15:27:10 2017
@@ -15,6 +15,11 @@ endfunction()
 
 set(LLDB_TEST_DEPS lldb)
 
+# darwin-debug is an hard dependency for the testsuite.
+if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
+  list(APPEND LLDB_TEST_DEPS darwin-debug)
+endif()
+
 if(TARGET lldb-server)
   list(APPEND LLDB_TEST_DEPS lldb-server)
 endif()


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


[Lldb-commits] [PATCH] D40616: ObjectFileELF: Add support for compressed sections

2017-12-15 Thread Taiju Tsuiki via Phabricator via lldb-commits
tzik added inline comments.



Comment at: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:3496
+
+  auto Decompressor = llvm::object::Decompressor::create(
+  section->GetName().GetStringRef(),

This adds new dependency to LLVM Object component.
Could you add it into LINK_COMPONENTS section of CMakeLists.txt in this 
directory?


Repository:
  rL LLVM

https://reviews.llvm.org/D40616



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