[Lldb-commits] [PATCH] D56293: Use the minidump exception record if present

2019-01-04 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D56293#1345790 , @zturner wrote:

> I don't think we can check in an executable file, we should try to compile it 
> on the spot.  We have 1-2 existing unit tests that check in an exe and we 
> occasionally get reports that peoples' virus scanners flag them as trojans, 
> even though they obviously aren't.  In any case, I've been meaning to remove 
> those tests, so I think we should set a precedent that executable binaries 
> are never checked in.


While I agree that a checked-in exe shouldn't be needed in this (and most 
other) cases, I am not sure about the policy in general. For example, I can see 
a case for having a bunch of badly corrupted binaries (things like corrupted 
section headers, overlapping sections in the file; things that even yaml2obj 
will have trouble generating) and then a test that makes sure we do something 
reasonable (e.g., not crash) when opening them. These are exactly the kind of 
files that make paranoid virus scanners sound the alarm.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D56293



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


[Lldb-commits] [PATCH] D55434: ObjectFileBreakpad: Implement sections

2019-01-04 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

I was under the impression I've convinced you of this direction, but your 
questions make it sound like you're going back to the "standalone" breakpad 
file idea (which I am not fond of). I'll try to explain again what I'm doing 
here. This is going to be somewhat repetitive (for which I apologise), but I am 
trying to explain this from a slightly different angle this time.

The sections I'm creating here aren't the kind of sections that will be loaded 
in memory. They're non-loadable sections (like the sections without SHF_ALLOC 
flag in elf), whose only purpose is to carry data around. Similar to how 
.debug_info is a non-loadable section that carries DWARF data. In this code, 
I'm not trying to infer anything about the layout of the described executable 
file from the data in the breakpad file. I am only presenting a view **of** the 
data in the breakpad file, so that this connection can happen in 
SymbolFileBreakpad. So, ObjectFileBreakpad will create a section whose contents 
will be _literally_

  PUBLIC 1010 0 function1
  PUBLIC 1020 0 function2
  ...

Then, SymbolFileBreakpad will take this section, parse it (like SymbolFileDWARF 
parses .debug_info), cross-reference the information with the real object, and 
create appropriate symbols. This happens in D56173 
. I am currently working on other patches 
which take the line records from the breakpad file and create line tables. So 
here, ObjectFileBreakpad will provide a "FUNC" section (because in breakpad 
files line records are attached to the preceding FUNC record), similar to how 
ObjectFileELF provides .debug_line. Then SymbolFileBreakpad parses and presents 
it to LLDB (like SymbolFileDWARF parses .debug_line).

In this sense, a breakpad file should be similar to a symbol-only ELF file (the 
kind you produce with `strip --only-keep-debug`) -- this one also doesn't 
contain any loadable sections, and is merely a container for the symbol data.

When I speak about "discontinuity" in this patch, it means discontinuity in the 
descriptions themselves, not in the data being described. So a breakpad file 
like:

  FUNC 1000 10 0 function1
  FILE 0 /tmp/foo.c
  FUNC 1010 10 0 function2

is discontinuous because the two FUNC records are not next to each other even 
though the functions themselves are positioned one after the other. (I don't 
know why would anyone produce files like these, but the breakpad format 
description 
https://chromium.googlesource.com/breakpad/breakpad/+/master/docs/symbol_files.md
 explicitly allows that).

Also note that neither of these ObjectFileBreakpad nor SymbolFileBreakpad 
creates any loadable sections. I don't think that is necessary, as that can be 
done elsewhere (and better). I just use whatever sections are present in the 
main object file of the module. In practice this will either be a real loadable 
object file (elf/macho/coff), or a placeholder object file that is created when 
opening a minidump file. I think this makes sense for several reasons:

- determining the limits of the loadable section from the breakpad info is 
hard. There will always be some loaded data (various file headers, etc.) before 
the first symbol described by the breakpad file. And we won't also cannot be 
sure of the upper limit of the section if the last symbol is a PUBLIC symbol 
(as they don't have size). On the other hand, creating this from the minidump 
info is easy, as it knows the exact ranges (coming from /proc/pid/maps) and 
similar.
- better composability: having ObjectFileBreakpad be standalone will not allow 
us to get rid of the placeholder object files, as those will be still needed in 
cases when we don't have even the breakpad info. So we will need two branches 
in ObjectFileBreakpad (for when we have an object file vs. when we don't), and 
then placeholder files on top of that. Making breakpad files not be standalone 
let's us get rid of one of the branches in ObjectFileBreakpad
- Overall, I think object files should be as standalone as possible. They 
should not infer anything based on the information in other object files or 
elsewhere. They should just present the data that's present in the file itself 
and nothing more. Combining of data from should be done at a different level.

If this still hasn't convinced you :), and you think the standalone breakpad 
file is the better way to go, then I'd like to understand what are the 
advantages you see there, because right now I don't see any. In previous 
comments you were worried about being able to use a breakpad file without the 
matching exe file. If that isn't clear from the above, then I can reiterate 
that I do intend to support that flow. In fact, it is my primary use case. The 
only difference is I intend to achieve it via a combination of placeholder 
object files plus symbol information from breakpad files, rather than breakpad 
(object) files alone.


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

[Lldb-commits] [lldb] r350384 - Symtab: Remove one copy of symbol size computation code

2019-01-04 Thread Pavel Labath via lldb-commits
Author: labath
Date: Fri Jan  4 02:11:25 2019
New Revision: 350384

URL: http://llvm.org/viewvc/llvm-project?rev=350384&view=rev
Log:
Symtab: Remove one copy of symbol size computation code

Summary:
The implementation in CalculateSymbolSizes has been made redundant in
D19004, as this patch added another copy of size computation code into
InitAddressIndexes (which is called by CalculateSymbolSizes).

Reviewers: clayborg, jasonmolenda, tberghammer

Subscribers: lldb-commits

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

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

Modified: lldb/trunk/source/Symbol/Symtab.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Symtab.cpp?rev=350384&r1=350383&r2=350384&view=diff
==
--- lldb/trunk/source/Symbol/Symtab.cpp (original)
+++ lldb/trunk/source/Symbol/Symtab.cpp Fri Jan  4 02:11:25 2019
@@ -976,32 +976,8 @@ void Symtab::InitAddressIndexes() {
 
 void Symtab::CalculateSymbolSizes() {
   std::lock_guard guard(m_mutex);
-
-  if (!m_symbols.empty()) {
-if (!m_file_addr_to_index_computed)
-  InitAddressIndexes();
-
-const size_t num_entries = m_file_addr_to_index.GetSize();
-
-for (size_t i = 0; i < num_entries; ++i) {
-  // The entries in the m_file_addr_to_index have calculated the sizes
-  // already so we will use this size if we need to.
-  const FileRangeToIndexMap::Entry &entry =
-  m_file_addr_to_index.GetEntryRef(i);
-
-  Symbol &symbol = m_symbols[entry.data];
-
-  // If the symbol size is already valid, no need to do anything
-  if (symbol.GetByteSizeIsValid())
-continue;
-
-  const addr_t range_size = entry.GetByteSize();
-  if (range_size > 0) {
-symbol.SetByteSize(range_size);
-symbol.SetSizeIsSynthesized(true);
-  }
-}
-  }
+  // Size computation happens inside InitAddressIndexes.
+  InitAddressIndexes();
 }
 
 Symbol *Symtab::FindSymbolAtFileAddress(addr_t file_addr) {


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


[Lldb-commits] [PATCH] D56132: Symtab: Remove one copy of symbol size computation code

2019-01-04 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL350384: Symtab: Remove one copy of symbol size computation 
code (authored by labath, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D56132

Files:
  lldb/trunk/source/Symbol/Symtab.cpp


Index: lldb/trunk/source/Symbol/Symtab.cpp
===
--- lldb/trunk/source/Symbol/Symtab.cpp
+++ lldb/trunk/source/Symbol/Symtab.cpp
@@ -976,32 +976,8 @@
 
 void Symtab::CalculateSymbolSizes() {
   std::lock_guard guard(m_mutex);
-
-  if (!m_symbols.empty()) {
-if (!m_file_addr_to_index_computed)
-  InitAddressIndexes();
-
-const size_t num_entries = m_file_addr_to_index.GetSize();
-
-for (size_t i = 0; i < num_entries; ++i) {
-  // The entries in the m_file_addr_to_index have calculated the sizes
-  // already so we will use this size if we need to.
-  const FileRangeToIndexMap::Entry &entry =
-  m_file_addr_to_index.GetEntryRef(i);
-
-  Symbol &symbol = m_symbols[entry.data];
-
-  // If the symbol size is already valid, no need to do anything
-  if (symbol.GetByteSizeIsValid())
-continue;
-
-  const addr_t range_size = entry.GetByteSize();
-  if (range_size > 0) {
-symbol.SetByteSize(range_size);
-symbol.SetSizeIsSynthesized(true);
-  }
-}
-  }
+  // Size computation happens inside InitAddressIndexes.
+  InitAddressIndexes();
 }
 
 Symbol *Symtab::FindSymbolAtFileAddress(addr_t file_addr) {


Index: lldb/trunk/source/Symbol/Symtab.cpp
===
--- lldb/trunk/source/Symbol/Symtab.cpp
+++ lldb/trunk/source/Symbol/Symtab.cpp
@@ -976,32 +976,8 @@
 
 void Symtab::CalculateSymbolSizes() {
   std::lock_guard guard(m_mutex);
-
-  if (!m_symbols.empty()) {
-if (!m_file_addr_to_index_computed)
-  InitAddressIndexes();
-
-const size_t num_entries = m_file_addr_to_index.GetSize();
-
-for (size_t i = 0; i < num_entries; ++i) {
-  // The entries in the m_file_addr_to_index have calculated the sizes
-  // already so we will use this size if we need to.
-  const FileRangeToIndexMap::Entry &entry =
-  m_file_addr_to_index.GetEntryRef(i);
-
-  Symbol &symbol = m_symbols[entry.data];
-
-  // If the symbol size is already valid, no need to do anything
-  if (symbol.GetByteSizeIsValid())
-continue;
-
-  const addr_t range_size = entry.GetByteSize();
-  if (range_size > 0) {
-symbol.SetByteSize(range_size);
-symbol.SetSizeIsSynthesized(true);
-  }
-}
-  }
+  // Size computation happens inside InitAddressIndexes.
+  InitAddressIndexes();
 }
 
 Symbol *Symtab::FindSymbolAtFileAddress(addr_t file_addr) {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r350388 - [CMake] Streamline code signing for debugserver #2

2019-01-04 Thread Stefan Granitz via lldb-commits
Author: stefan.graenitz
Date: Fri Jan  4 04:46:30 2019
New Revision: 350388

URL: http://llvm.org/viewvc/llvm-project?rev=350388&view=rev
Log:
[CMake] Streamline code signing for debugserver #2

Summary:
Major fixes after D54476 (use Diff1 as base for comparison to see only recent 
changes):
* In standalone builds target directory for debugserver must be LLDB's bin, not 
LLVM's bin
* Default identity for code signing must not force-override 
LLVM_CODESIGNING_IDENTITY globally

We have a lot of cases, make them explicit:

* ID used for code signing (debugserver and in tests):
** `LLDB_CODESIGN_IDENTITY` if set explicitly, or otherwise
** `LLVM_CODESIGNING_IDENTITY` if set explicitly, or otherwise
** `lldb_codesign` as the default

* On Darwin we have a debugserver target that:

* On other systems, the debugserver target is not defined, which is equivalent 
to **[3A]**

Common configurations on Darwin:
* **[1A]** `cmake -GNinja ../llvm` builds debugserver from source and signs 
with `lldb_codesign`, no code signing for other binaries (prints status: //lldb 
debugserver: /path/to/bin/debugserver//)
* **[1A]** `cmake -GNinja -DLLVM_CODESIGNING_IDENTITY=- 
-DLLDB_CODESIGN_IDENTITY=lldb_codesign ../llvm` builds debugserver from source 
and signs with `lldb_codesign`, ad-hoc code signing for other binaries (prints 
status: //lldb debugserver: /path/to/bin/debugserver//)
* **[2A]** `cmake -GNinja -DLLVM_CODESIGNING_IDENTITY=- 
-DLLDB_USE_SYSTEM_DEBUGSERVER=ON ../llvm` copies debugserver from system, 
ad-hoc code signing for other binaries (prints status: //Copy system 
debugserver from: /path/to/system/debugserver//)
* **[2B]** `cmake -GNinja -DLLVM_CODESIGNING_IDENTITY=- ../llvm` same, but 
prints additional warning: //Cannot code sign debugserver with identity '-'. 
Will fall back to system's debugserver. Pass 
-DLLDB_CODESIGN_IDENTITY=lldb_codesign to override the LLVM value for 
debugserver.//
* **[3A]** `cmake -GNinja -DLLVM_CODESIGNING_IDENTITY=- 
-DLLDB_NO_DEBUGSERVER=ON ../llvm` debugserver not available (prints status: 
//lldb debugserver will not be available)//

Reviewers: JDevlieghere, beanz, davide, vsk, aprantl, labath

Reviewed By: JDevlieghere, labath

Subscribers: mgorny, #lldb, lldb-commits

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

Modified:
lldb/trunk/CMakeLists.txt
lldb/trunk/cmake/modules/AddLLDB.cmake
lldb/trunk/cmake/modules/LLDBConfig.cmake
lldb/trunk/test/CMakeLists.txt
lldb/trunk/tools/debugserver/CMakeLists.txt
lldb/trunk/tools/debugserver/source/CMakeLists.txt
lldb/trunk/unittests/tools/CMakeLists.txt
lldb/trunk/unittests/tools/lldb-server/CMakeLists.txt

Modified: lldb/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/CMakeLists.txt?rev=350388&r1=350387&r2=350388&view=diff
==
--- lldb/trunk/CMakeLists.txt (original)
+++ lldb/trunk/CMakeLists.txt Fri Jan  4 04:46:30 2019
@@ -138,9 +138,7 @@ if(LLDB_INCLUDE_TESTS)
   endif()
 
   if(TARGET debugserver)
-if(NOT CMAKE_HOST_APPLE OR LLDB_CODESIGN_IDENTITY)
-  list(APPEND LLDB_TEST_DEPS debugserver)
-endif()
+list(APPEND LLDB_TEST_DEPS debugserver)
   endif()
 
   if(TARGET lldb-mi)

Modified: lldb/trunk/cmake/modules/AddLLDB.cmake
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/AddLLDB.cmake?rev=350388&r1=350387&r2=350388&view=diff
==
--- lldb/trunk/cmake/modules/AddLLDB.cmake (original)
+++ lldb/trunk/cmake/modules/AddLLDB.cmake Fri Jan  4 04:46:30 2019
@@ -100,13 +100,13 @@ endfunction(add_lldb_library)
 function(add_lldb_executable name)
   cmake_parse_arguments(ARG
 "INCLUDE_IN_SUITE;GENERATE_INSTALL"
-""
+"ENTITLEMENTS"
 "LINK_LIBS;LINK_COMPONENTS"
 ${ARGN}
 )
 
   list(APPEND LLVM_LINK_COMPONENTS ${ARG_LINK_COMPONENTS})
-  add_llvm_executable(${name} ${ARG_UNPARSED_ARGUMENTS})
+  add_llvm_executable(${name} ${ARG_UNPARSED_ARGUMENTS} ENTITLEMENTS 
${ARG_ENTITLEMENTS})
 
   target_link_libraries(${name} PRIVATE ${ARG_LINK_LIBS})
   set_target_properties(${name} PROPERTIES

Modified: lldb/trunk/cmake/modules/LLDBConfig.cmake
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/LLDBConfig.cmake?rev=350388&r1=350387&r2=350388&view=diff
==
--- lldb/trunk/cmake/modules/LLDBConfig.cmake (original)
+++ lldb/trunk/cmake/modules/LLDBConfig.cmake Fri Jan  4 04:46:30 2019
@@ -50,6 +50,8 @@ if (LLDB_DISABLE_CURSES)
   add_definitions( -DLLDB_DISABLE_CURSES )
 endif()
 
+option(LLDB_USE_ENTITLEMENTS "When code signing, use entitlements if 
available" ON)
+
 # On Windows, we can't use the normal FindPythonLibs module that comes with 
CMake,
 # for a number of reasons.
 # 1) Prior to MSVC 2015, it is only possible to embed Python if python itself 
was

Modified: lldb/trunk/test/CMakeLis

[Lldb-commits] [lldb] r350389 - [CMake] Aggregate options for LLDB in LLDBConfig.cmake

2019-01-04 Thread Stefan Granitz via lldb-commits
Author: stefan.graenitz
Date: Fri Jan  4 04:46:34 2019
New Revision: 350389

URL: http://llvm.org/viewvc/llvm-project?rev=350389&view=rev
Log:
[CMake] Aggregate options for LLDB in LLDBConfig.cmake

Summary: In preparation for LLDB.framework changes, collect options for LLDB in 
LLDBConfig.cmake (used for both, standalone and in-tree builds of LLDB).

Reviewers: JDevlieghere, aprantl, xiaobai

Reviewed By: aprantl

Subscribers: srhines, mgorny, lldb-commits, #lldb

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

Modified:
lldb/trunk/CMakeLists.txt
lldb/trunk/cmake/modules/LLDBConfig.cmake

Modified: lldb/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/CMakeLists.txt?rev=350389&r1=350388&r2=350389&view=diff
==
--- lldb/trunk/CMakeLists.txt (original)
+++ lldb/trunk/CMakeLists.txt Fri Jan  4 04:46:34 2019
@@ -18,15 +18,6 @@ else()
   add_definitions( -DLLDB_CONFIGURATION_RELEASE )
 endif()
 
-if (CMAKE_SYSTEM_NAME MATCHES "Windows|Android")
-  set(LLDB_DEFAULT_DISABLE_LIBEDIT 1)
-else()
-  set(LLDB_DEFAULT_DISABLE_LIBEDIT 0)
-endif ()
-
-# We need libedit support to go down both the source and
-# the scripts directories.
-set(LLDB_DISABLE_LIBEDIT ${LLDB_DEFAULT_DISABLE_LIBEDIT} CACHE BOOL "Disables 
the use of editline.")
 if (LLDB_DISABLE_LIBEDIT)
   add_definitions( -DLLDB_DISABLE_LIBEDIT )
 else()
@@ -42,16 +33,9 @@ endif()
 add_custom_target(lldb-suite)
 set(LLDB_SUITE_TARGET lldb-suite)
 
-option(LLDB_BUILD_FRAMEWORK "Build the Darwin LLDB.framework" Off)
 if(LLDB_BUILD_FRAMEWORK)
-  if (CMAKE_VERSION VERSION_LESS 3.7)
-message(FATAL_ERROR "LLDB_BUILD_FRAMEWORK is not supported on CMake < 3.7")
-  endif()
-  if (NOT APPLE)
-message(FATAL_ERROR "LLDB.framework can only be generated when targeting 
Apple platforms")
-  endif()
-
   add_custom_target(lldb-framework)
+
   # These are used to fill out LLDB-Info.plist. These are relevant when 
building
   # the framework, and must be defined before building liblldb.
   set(PRODUCT_NAME "LLDB")

Modified: lldb/trunk/cmake/modules/LLDBConfig.cmake
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/LLDBConfig.cmake?rev=350389&r1=350388&r2=350389&view=diff
==
--- lldb/trunk/cmake/modules/LLDBConfig.cmake (original)
+++ lldb/trunk/cmake/modules/LLDBConfig.cmake Fri Jan  4 04:46:34 2019
@@ -10,28 +10,42 @@ if (LLVM_COMPILER_IS_GCC_COMPATIBLE AND
   set(LLDB_LINKER_SUPPORTS_GROUPS ON)
 endif()
 
-set(LLDB_DEFAULT_DISABLE_PYTHON 0)
-set(LLDB_DEFAULT_DISABLE_CURSES 0)
+set(default_disable_python OFF)
+set(default_disable_curses OFF)
+set(default_disable_libedit OFF)
 
-if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
-  set(LLDB_DEFAULT_DISABLE_CURSES 1)
-elseif (CMAKE_SYSTEM_NAME MATCHES "Android" )
-  set(LLDB_DEFAULT_DISABLE_PYTHON 1)
-  set(LLDB_DEFAULT_DISABLE_CURSES 1)
-elseif(IOS)
-  set(LLDB_DEFAULT_DISABLE_PYTHON 1)
+if(DEFINED LLVM_ENABLE_LIBEDIT AND NOT LLVM_ENABLE_LIBEDIT)
+  set(default_disable_libedit ON)
 endif()
 
-set(LLDB_DISABLE_PYTHON ${LLDB_DEFAULT_DISABLE_PYTHON} CACHE BOOL
-  "Disables the Python scripting integration.")
-set(LLDB_DISABLE_CURSES ${LLDB_DEFAULT_DISABLE_CURSES} CACHE BOOL
-  "Disables the Curses integration.")
-
-set(LLDB_RELOCATABLE_PYTHON 0 CACHE BOOL
-  "Causes LLDB to use the PYTHONHOME environment variable to locate Python.")
+if(CMAKE_SYSTEM_NAME MATCHES "Windows")
+  set(default_disable_curses ON)
+  set(default_disable_libedit ON)
+elseif(CMAKE_SYSTEM_NAME MATCHES "Android")
+  set(default_disable_python ON)
+  set(default_disable_curses ON)
+  set(default_disable_libedit ON)
+elseif(IOS)
+  set(default_disable_python ON)
+endif()
 
-set(LLDB_USE_SYSTEM_SIX 0 CACHE BOOL
-  "Use six.py shipped with system and do not install a copy of it")
+option(LLDB_DISABLE_PYTHON "Disable Python scripting integration." 
${default_disable_python})
+option(LLDB_DISABLE_CURSES "Disable Curses integration." 
${default_disable_curses})
+option(LLDB_DISABLE_LIBEDIT "Disable the use of editline." 
${default_disable_libedit})
+option(LLDB_RELOCATABLE_PYTHON "Use the PYTHONHOME environment variable to 
locate Python." OFF)
+option(LLDB_USE_SYSTEM_SIX "Use six.py shipped with system and do not install 
a copy of it" OFF)
+option(LLDB_USE_ENTITLEMENTS "When codesigning, use entitlements if available" 
ON)
+option(LLDB_BUILD_FRAMEWORK "Build LLDB.framework (Darwin only)" OFF)
+
+if(LLDB_BUILD_FRAMEWORK)
+  if(NOT APPLE)
+message(FATAL_ERROR "LLDB.framework can only be generated when targeting 
Apple platforms")
+  endif()
+  # CMake 3.6 did not correctly emit POST_BUILD commands for Apple Framework 
targets
+  if(CMAKE_VERSION VERSION_LESS 3.7)
+message(FATAL_ERROR "LLDB_BUILD_FRAMEWORK is not supported on CMake < 3.7")
+  endif()
+endif()
 
 if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
   set(LLDB_EXPORT_ALL_SYMBOLS 0 CACHE BOOL
@@ 

[Lldb-commits] [lldb] r350391 - [CMake] Revised LLDB.framework builds

2019-01-04 Thread Stefan Granitz via lldb-commits
Author: stefan.graenitz
Date: Fri Jan  4 04:46:50 2019
New Revision: 350391

URL: http://llvm.org/viewvc/llvm-project?rev=350391&view=rev
Log:
[CMake] Revised LLDB.framework builds

Summary:
Add features to LLDB CMake builds that have so far only been available in 
Xcode. Clean up a few inconveniences and prepare further improvements.

Options:
* `LLDB_FRAMEWORK_BUILD_DIR` determines target directory (in build-tree)
* `LLDB_FRAMEWORK_INSTALL_DIR` **only** determines target directory in 
install-tree
* `LLVM_EXTERNALIZE_DEBUGINFO` allows externalized debug info (dSYM on Darwin, 
emitted to `bin`)
* `LLDB_FRAMEWORK_TOOLS` determines which executables will be copied to the 
framework's Resources (dropped symlinking, removed INCLUDE_IN_SUITE, removed 
dummy targets)

Other changes:
* clean up `add_lldb_executable()`
* include `LLDBFramework.cmake` from `source/API/CMakeLists.txt`
* use `*.plist.in` files, which are typical for CMake and independent from Xcode
* add clang headers to the framework bundle

Reviewers: xiaobai, JDevlieghere, aprantl, davide, beanz, stella.stamenova, 
clayborg, labath

Reviewed By: aprantl

Subscribers: friss, mgorny, lldb-commits, #lldb

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

Added:
lldb/trunk/resources/LLDB-Info.plist.in
Modified:
lldb/trunk/CMakeLists.txt
lldb/trunk/cmake/modules/AddLLDB.cmake
lldb/trunk/cmake/modules/LLDBConfig.cmake
lldb/trunk/cmake/modules/LLDBFramework.cmake
lldb/trunk/source/API/CMakeLists.txt
lldb/trunk/test/CMakeLists.txt
lldb/trunk/tools/argdumper/CMakeLists.txt
lldb/trunk/tools/darwin-debug/CMakeLists.txt
lldb/trunk/tools/debugserver/CMakeLists.txt
lldb/trunk/tools/debugserver/source/CMakeLists.txt
lldb/trunk/tools/driver/CMakeLists.txt
lldb/trunk/tools/lldb-server/CMakeLists.txt

Modified: lldb/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/CMakeLists.txt?rev=350391&r1=350390&r2=350391&view=diff
==
--- lldb/trunk/CMakeLists.txt (original)
+++ lldb/trunk/CMakeLists.txt Fri Jan  4 04:46:50 2019
@@ -28,46 +28,18 @@ if(APPLE)
   add_definitions(-DLLDB_USE_OS_LOG)
 endif()
 
-# lldb-suite is a dummy target that encompasses all the necessary tools and
-# libraries for building a fully-functioning liblldb.
-add_custom_target(lldb-suite)
-set(LLDB_SUITE_TARGET lldb-suite)
-
-if(LLDB_BUILD_FRAMEWORK)
-  add_custom_target(lldb-framework)
-
-  # These are used to fill out LLDB-Info.plist. These are relevant when 
building
-  # the framework, and must be defined before building liblldb.
-  set(PRODUCT_NAME "LLDB")
-  set(EXECUTABLE_NAME "LLDB")
-  set(CURRENT_PROJECT_VERSION 
"${LLDB_VERSION_MAJOR}.${LLDB_VERSION_MINOR}.${LLDB_VERSION_PATCH}")
-  set(LLDB_SUITE_TARGET lldb-framework)
-
-  set(LLDB_FRAMEWORK_DIR
-${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_FRAMEWORK_INSTALL_DIR})
-  include(LLDBFramework)
-endif()
-
 add_subdirectory(docs)
 if (NOT LLDB_DISABLE_PYTHON)
-  if(LLDB_USE_SYSTEM_SIX)
-set(SIX_EXTRA_ARGS "--useSystemSix")
-  endif()
-
   set(LLDB_PYTHON_TARGET_DIR ${LLDB_BINARY_DIR}/scripts)
   set(LLDB_WRAP_PYTHON ${LLDB_BINARY_DIR}/scripts/LLDBWrapPython.cpp)
   if(LLDB_BUILD_FRAMEWORK)
-set(LLDB_PYTHON_TARGET_DIR ${LLDB_FRAMEWORK_DIR})
+set(LLDB_PYTHON_TARGET_DIR ${LLDB_FRAMEWORK_BUILD_DIR})
 set(LLDB_WRAP_PYTHON ${LLDB_PYTHON_TARGET_DIR}/LLDBWrapPython.cpp)
-  else()
-# Don't set -m when building the framework.
-set(FINISH_EXTRA_ARGS "-m")
   endif()
 
 
   add_subdirectory(scripts)
 endif ()
-
 add_subdirectory(source)
 add_subdirectory(tools)
 
@@ -154,8 +126,14 @@ if(LLDB_INCLUDE_TESTS)
   add_subdirectory(utils/lldb-dotest)
 endif()
 
-
 if (NOT LLDB_DISABLE_PYTHON)
+if(NOT LLDB_BUILD_FRAMEWORK)
+  set(use_python_wrapper_from_src_dir -m)
+endif()
+if(LLDB_USE_SYSTEM_SIX)
+  set(use_six_py_from_system --useSystemSix)
+endif()
+
 # Add a Post-Build Event to copy over Python files and create the symlink
 # to liblldb.so for the Python API(hardlink on Windows)
 add_custom_target(finish_swig ALL
@@ -167,29 +145,24 @@ if (NOT LLDB_DISABLE_PYTHON)
--prefix=${CMAKE_BINARY_DIR}
--cmakeBuildConfiguration=${CMAKE_CFG_INTDIR}
--lldbLibDir=lib${LLVM_LIBDIR_SUFFIX}
-   ${SIX_EXTRA_ARGS}
-   ${FINISH_EXTRA_ARGS}
+   ${use_python_wrapper_from_src_dir}
+   ${use_six_py_from_system}
 VERBATIM
 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py
 DEPENDS ${LLDB_PYTHON_TARGET_DIR}/lldb.py
 COMMENT "Python script sym-linking LLDB Python API")
 
-# We depend on liblldb and lldb-argdumper being built before we can do 
this step.
-add_dependencies(finish_swig ${LLDB_SUITE_TARGET})
 
-# If we build the readline module, we depend on that happening
-# first.
 if (TARGET read

[Lldb-commits] [PATCH] D55320: [CMake] Move debugserver options to separate debugserverConfig.cmake

2019-01-04 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL350390: [CMake] Move debugserver options to separate 
debugserverConfig.cmake (authored by stefan.graenitz, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55320

Files:
  lldb/trunk/cmake/modules/debugserverConfig.cmake
  lldb/trunk/tools/debugserver/CMakeLists.txt


Index: lldb/trunk/cmake/modules/debugserverConfig.cmake
===
--- lldb/trunk/cmake/modules/debugserverConfig.cmake
+++ lldb/trunk/cmake/modules/debugserverConfig.cmake
@@ -0,0 +1,3 @@
+# Duplicate options from LLDBConfig that are relevant for debugserver 
Standalone builds.
+
+option(LLDB_USE_ENTITLEMENTS "When code signing, use entitlements if 
available" ON)
Index: lldb/trunk/tools/debugserver/CMakeLists.txt
===
--- lldb/trunk/tools/debugserver/CMakeLists.txt
+++ lldb/trunk/tools/debugserver/CMakeLists.txt
@@ -10,13 +10,12 @@
 )
 
   include(LLDBStandalone)
+  include(debugserverConfig)
   include(AddLLDB)
 
   set(LLDB_SOURCE_DIR "${CMAKE_SOURCE_DIR}/../../")
   include_directories(${LLDB_SOURCE_DIR}/include)
 
-  option(LLDB_USE_ENTITLEMENTS "When code signing, use entitlements if 
available" ON)
-
   # lldb-suite is a dummy target that encompasses all the necessary tools and
   # libraries for building a fully-functioning liblldb.
   add_custom_target(lldb-suite)


Index: lldb/trunk/cmake/modules/debugserverConfig.cmake
===
--- lldb/trunk/cmake/modules/debugserverConfig.cmake
+++ lldb/trunk/cmake/modules/debugserverConfig.cmake
@@ -0,0 +1,3 @@
+# Duplicate options from LLDBConfig that are relevant for debugserver Standalone builds.
+
+option(LLDB_USE_ENTITLEMENTS "When code signing, use entitlements if available" ON)
Index: lldb/trunk/tools/debugserver/CMakeLists.txt
===
--- lldb/trunk/tools/debugserver/CMakeLists.txt
+++ lldb/trunk/tools/debugserver/CMakeLists.txt
@@ -10,13 +10,12 @@
 )
 
   include(LLDBStandalone)
+  include(debugserverConfig)
   include(AddLLDB)
 
   set(LLDB_SOURCE_DIR "${CMAKE_SOURCE_DIR}/../../")
   include_directories(${LLDB_SOURCE_DIR}/include)
 
-  option(LLDB_USE_ENTITLEMENTS "When code signing, use entitlements if available" ON)
-
   # lldb-suite is a dummy target that encompasses all the necessary tools and
   # libraries for building a fully-functioning liblldb.
   add_custom_target(lldb-suite)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r350393 - [CMake] Python bindings generation polishing

2019-01-04 Thread Stefan Granitz via lldb-commits
Author: stefan.graenitz
Date: Fri Jan  4 04:47:02 2019
New Revision: 350393

URL: http://llvm.org/viewvc/llvm-project?rev=350393&view=rev
Log:
[CMake] Python bindings generation polishing

Summary:
Simplify SWIG invocation and handling of generated files.

The `swig_wrapper` target can generate `LLDBWrapPython.cpp` and `lldb.py` in 
its own binary directory, so we can get rid of a few global variables and their 
logic. We can use the swig_wrapper's BINARY_DIR target property to refer to it 
and liblldb's LIBRARY_OUTPUT_DIRECTORY to refer to the framework/shared object 
output directory.

Reviewers: JDevlieghere, aprantl, stella.stamenova, beanz, zturner, xiaobai

Reviewed By: aprantl

Subscribers: mgorny, lldb-commits, #lldb

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

Modified:
lldb/trunk/CMakeLists.txt
lldb/trunk/scripts/CMakeLists.txt
lldb/trunk/source/API/CMakeLists.txt

Modified: lldb/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/CMakeLists.txt?rev=350393&r1=350392&r2=350393&view=diff
==
--- lldb/trunk/CMakeLists.txt (original)
+++ lldb/trunk/CMakeLists.txt Fri Jan  4 04:47:02 2019
@@ -30,14 +30,6 @@ endif()
 
 add_subdirectory(docs)
 if (NOT LLDB_DISABLE_PYTHON)
-  set(LLDB_PYTHON_TARGET_DIR ${LLDB_BINARY_DIR}/scripts)
-  set(LLDB_WRAP_PYTHON ${LLDB_BINARY_DIR}/scripts/LLDBWrapPython.cpp)
-  if(LLDB_BUILD_FRAMEWORK)
-set(LLDB_PYTHON_TARGET_DIR ${LLDB_FRAMEWORK_BUILD_DIR})
-set(LLDB_WRAP_PYTHON ${LLDB_PYTHON_TARGET_DIR}/LLDBWrapPython.cpp)
-  endif()
-
-
   add_subdirectory(scripts)
 endif ()
 add_subdirectory(source)
@@ -133,26 +125,27 @@ if (NOT LLDB_DISABLE_PYTHON)
 if(LLDB_USE_SYSTEM_SIX)
   set(use_six_py_from_system --useSystemSix)
 endif()
+get_target_property(lldb_scripts_dir swig_wrapper BINARY_DIR)
+get_target_property(liblldb_build_dir liblldb LIBRARY_OUTPUT_DIRECTORY)
 
 # Add a Post-Build Event to copy over Python files and create the symlink
 # to liblldb.so for the Python API(hardlink on Windows)
 add_custom_target(finish_swig ALL
 COMMAND
-   ${PYTHON_EXECUTABLE} 
${CMAKE_CURRENT_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py
+   ${PYTHON_EXECUTABLE} 
${LLDB_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py
--srcRoot=${LLDB_SOURCE_DIR}
-   --targetDir=${LLDB_PYTHON_TARGET_DIR}
-   --cfgBldDir=${LLDB_PYTHON_TARGET_DIR}
+   --targetDir=${liblldb_build_dir}
+   --cfgBldDir=${lldb_scripts_dir}
--prefix=${CMAKE_BINARY_DIR}
--cmakeBuildConfiguration=${CMAKE_CFG_INTDIR}
--lldbLibDir=lib${LLVM_LIBDIR_SUFFIX}
${use_python_wrapper_from_src_dir}
${use_six_py_from_system}
 VERBATIM
-DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py
-DEPENDS ${LLDB_PYTHON_TARGET_DIR}/lldb.py
+DEPENDS ${LLDB_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py
+DEPENDS ${lldb_scripts_dir}/lldb.py
 COMMENT "Python script sym-linking LLDB Python API")
 
-
 if (TARGET readline)
   set(readline_dep readline)
 endif()

Modified: lldb/trunk/scripts/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/CMakeLists.txt?rev=350393&r1=350392&r2=350393&view=diff
==
--- lldb/trunk/scripts/CMakeLists.txt (original)
+++ lldb/trunk/scripts/CMakeLists.txt Fri Jan  4 04:47:02 2019
@@ -11,31 +11,14 @@ set(SWIG_HEADERS
 
 include(FindPythonInterp)
 
-if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
-  set(SWIG_PYTHON_DIR
-
${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR})
-else()
-  set(SWIG_PYTHON_DIR 
${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/site-packages)
-endif()
-
-set(SWIG_INSTALL_DIR lib${LLVM_LIBDIR_SUFFIX})
-
-# Generating the LLDB framework correctly is a bit complicated because the
-# framework depends on the swig output.
 if(LLDB_BUILD_FRAMEWORK)
   set(framework_arg --framework --target-platform Darwin)
-  set(SWIG_PYTHON_DIR
-${LLDB_PYTHON_TARGET_DIR}/${LLDB_FRAMEWORK_RESOURCE_DIR}/Python)
-  set(SWIG_INSTALL_DIR
-${LLDB_FRAMEWORK_INSTALL_DIR}/${LLDB_FRAMEWORK_RESOURCE_DIR})
 endif()
 
-get_filename_component(CFGBLDDIR ${LLDB_WRAP_PYTHON} DIRECTORY)
-
 find_package(SWIG REQUIRED)
 add_custom_command(
-  OUTPUT ${LLDB_WRAP_PYTHON}
-  OUTPUT ${LLDB_PYTHON_TARGET_DIR}/lldb.py
+  OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/LLDBWrapPython.cpp
+  OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lldb.py
   DEPENDS ${SWIG_SOURCES}
   DEPENDS ${SWIG_INTERFACES}
   DEPENDS ${SWIG_HEADERS}
@@ -44,19 +27,31 @@ add_custom_command(
   COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/prepare_bindings.py
   ${framework_arg}
   --srcRoot=${LLDB_SOURCE_DIR}
-  --targetDir=${LLDB_PY

[Lldb-commits] [lldb] r350390 - [CMake] Move debugserver options to separate debugserverConfig.cmake

2019-01-04 Thread Stefan Granitz via lldb-commits
Author: stefan.graenitz
Date: Fri Jan  4 04:46:38 2019
New Revision: 350390

URL: http://llvm.org/viewvc/llvm-project?rev=350390&view=rev
Log:
[CMake] Move debugserver options to separate debugserverConfig.cmake

Summary:
One place for debugserver options, analog to LLDBConfig for LLDB options (see 
D55317). It was discussed in earlier reviews already, e.g. D55013.

Reviewers: JDevlieghere, aprantl, xiaobai

Reviewed By: aprantl, xiaobai

Subscribers: mgorny, lldb-commits, #lldb

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

Added:
lldb/trunk/cmake/modules/debugserverConfig.cmake
Modified:
lldb/trunk/tools/debugserver/CMakeLists.txt

Added: lldb/trunk/cmake/modules/debugserverConfig.cmake
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/debugserverConfig.cmake?rev=350390&view=auto
==
--- lldb/trunk/cmake/modules/debugserverConfig.cmake (added)
+++ lldb/trunk/cmake/modules/debugserverConfig.cmake Fri Jan  4 04:46:38 2019
@@ -0,0 +1,3 @@
+# Duplicate options from LLDBConfig that are relevant for debugserver 
Standalone builds.
+
+option(LLDB_USE_ENTITLEMENTS "When code signing, use entitlements if 
available" ON)

Modified: lldb/trunk/tools/debugserver/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/CMakeLists.txt?rev=350390&r1=350389&r2=350390&view=diff
==
--- lldb/trunk/tools/debugserver/CMakeLists.txt (original)
+++ lldb/trunk/tools/debugserver/CMakeLists.txt Fri Jan  4 04:46:38 2019
@@ -10,13 +10,12 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
 )
 
   include(LLDBStandalone)
+  include(debugserverConfig)
   include(AddLLDB)
 
   set(LLDB_SOURCE_DIR "${CMAKE_SOURCE_DIR}/../../")
   include_directories(${LLDB_SOURCE_DIR}/include)
 
-  option(LLDB_USE_ENTITLEMENTS "When code signing, use entitlements if 
available" ON)
-
   # lldb-suite is a dummy target that encompasses all the necessary tools and
   # libraries for building a fully-functioning liblldb.
   add_custom_target(lldb-suite)


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


[Lldb-commits] [lldb] r350392 - [CMake] Revised RPATH handling

2019-01-04 Thread Stefan Granitz via lldb-commits
Author: stefan.graenitz
Date: Fri Jan  4 04:46:57 2019
New Revision: 350392

URL: http://llvm.org/viewvc/llvm-project?rev=350392&view=rev
Log:
[CMake] Revised RPATH handling

Summary:
If we build LLDB.framework, dependant tools need appropriate RPATHs in both 
locations, the build-tree (for testing) and the install-tree (for deployment). 
Luckily, CMake can handle it for us: 
https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/RPATH-handling.

* In the build-tree, tools use the absolute path to the framework's actual 
output location.
* In the install-tree, tools get a list of RPATHs to look for the framework 
when deployed.

`LLDB_FRAMEWORK_INSTALL_DIR` is added to the `CMAKE_INSTALL_PREFIX` to change 
the relative location of LLDB.framework in the install-tree.
If it is not empty, it will be added as an additional RPATH to all dependant 
tools (so they are functional in the install-tree).
If it is empty, LLDB.framework goes to the root and tools will not be 
functional in the directory structure of the LLVM install-tree.
For historical reasons `LLDB_FRAMEWORK_INSTALL_DIR` defaults to 
"Library/Frameworks".

Reviewers: xiaobai, JDevlieghere, aprantl, clayborg

Reviewed By: JDevlieghere

Subscribers: ki.stfu, mgorny, lldb-commits, #lldb

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

Modified:
lldb/trunk/cmake/modules/AddLLDB.cmake
lldb/trunk/cmake/modules/LLDBConfig.cmake
lldb/trunk/tools/driver/CMakeLists.txt
lldb/trunk/tools/lldb-mi/CMakeLists.txt
lldb/trunk/tools/lldb-vscode/CMakeLists.txt

Modified: lldb/trunk/cmake/modules/AddLLDB.cmake
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/AddLLDB.cmake?rev=350392&r1=350391&r2=350392&view=diff
==
--- lldb/trunk/cmake/modules/AddLLDB.cmake (original)
+++ lldb/trunk/cmake/modules/AddLLDB.cmake Fri Jan  4 04:46:57 2019
@@ -44,9 +44,15 @@ function(add_lldb_library name)
   if (PARAM_OBJECT)
 add_library(${name} ${libkind} ${srcs})
   else()
-llvm_add_library(${name} ${libkind} ${srcs} LINK_LIBS
-${PARAM_LINK_LIBS}
-DEPENDS ${PARAM_DEPENDS})
+if(LLDB_NO_INSTALL_DEFAULT_RPATH)
+  set(pass_NO_INSTALL_RPATH NO_INSTALL_RPATH)
+endif()
+
+llvm_add_library(${name} ${libkind} ${srcs}
+  LINK_LIBS ${PARAM_LINK_LIBS}
+  DEPENDS ${PARAM_DEPENDS}
+  ${pass_NO_INSTALL_RPATH}
+)
 
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "liblldb")
   if (PARAM_SHARED)
@@ -98,8 +104,15 @@ function(add_lldb_executable name)
 ${ARGN}
 )
 
+  if(LLDB_NO_INSTALL_DEFAULT_RPATH)
+set(pass_NO_INSTALL_RPATH NO_INSTALL_RPATH)
+  endif()
+
   list(APPEND LLVM_LINK_COMPONENTS ${ARG_LINK_COMPONENTS})
-  add_llvm_executable(${name} ${ARG_UNPARSED_ARGUMENTS} ENTITLEMENTS 
${ARG_ENTITLEMENTS})
+  add_llvm_executable(${name} ${ARG_UNPARSED_ARGUMENTS}
+ENTITLEMENTS ${ARG_ENTITLEMENTS}
+${pass_NO_INSTALL_RPATH}
+  )
 
   target_link_libraries(${name} PRIVATE ${ARG_LINK_LIBS})
   set_target_properties(${name} PROPERTIES FOLDER "lldb executables")
@@ -135,3 +148,40 @@ function(lldb_append_link_flags target_n
   # Now set them onto the target.
   set_target_properties(${target_name} PROPERTIES LINK_FLAGS ${new_link_flags})
 endfunction()
+
+# For tools that depend on liblldb, account for varying directory structures in
+# which LLDB.framework can be used and distributed: In the build-tree we find 
it
+# by its absolute target path. This is only relevant for running the test 
suite.
+# In the install step CMake will remove this entry and insert the final RPATHs.
+# These are relative to the file path from where the tool will be loaded on the
+# enduser system.
+#
+# Note that the LLVM install-tree doesn't match the enduser system structure
+# for LLDB.framework, so by default dependent tools will not be functional in
+# their install location. The LLDB_FRAMEWORK_INSTALL_DIR variable allows to fix
+# this. If specified, it causes the install-tree location of the framework to 
be
+# added as an extra RPATH below.
+#
+function(lldb_setup_framework_rpaths_in_tool name)
+  # In the build-tree, we know the exact path to the binary in the framework.
+  set(rpath_build_tree "$")
+
+  # The installed framework is relocatable and can be in different locations.
+  set(rpaths_install_tree "@loader_path/../../../SharedFrameworks")
+  list(APPEND rpaths_install_tree 
"@loader_path/../../System/Library/PrivateFrameworks")
+  list(APPEND rpaths_install_tree 
"@loader_path/../../Library/PrivateFrameworks")
+
+  if(LLDB_FRAMEWORK_INSTALL_DIR)
+set(rpaths_install_tree "@loader_path/../${LLDB_FRAMEWORK_INSTALL_DIR}")
+  endif()
+
+  # If LLDB_NO_INSTALL_DEFAULT_RPATH was NOT enabled (default), this overwrites
+  # the default settings from llvm_setup_rpath().
+  set_target_properties(${name} PROPERTIES
+BUILD_WITH_INSTALL_RPATH OFF
+BUILD_RPATH "

[Lldb-commits] [PATCH] D55013: [CMake] Streamline code signing for debugserver #2

2019-01-04 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL350388: [CMake] Streamline code signing for debugserver #2 
(authored by stefan.graenitz, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D55013?vs=177577&id=180227#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55013

Files:
  lldb/trunk/CMakeLists.txt
  lldb/trunk/cmake/modules/AddLLDB.cmake
  lldb/trunk/cmake/modules/LLDBConfig.cmake
  lldb/trunk/test/CMakeLists.txt
  lldb/trunk/tools/debugserver/CMakeLists.txt
  lldb/trunk/tools/debugserver/source/CMakeLists.txt
  lldb/trunk/unittests/tools/CMakeLists.txt
  lldb/trunk/unittests/tools/lldb-server/CMakeLists.txt

Index: lldb/trunk/cmake/modules/AddLLDB.cmake
===
--- lldb/trunk/cmake/modules/AddLLDB.cmake
+++ lldb/trunk/cmake/modules/AddLLDB.cmake
@@ -100,13 +100,13 @@
 function(add_lldb_executable name)
   cmake_parse_arguments(ARG
 "INCLUDE_IN_SUITE;GENERATE_INSTALL"
-""
+"ENTITLEMENTS"
 "LINK_LIBS;LINK_COMPONENTS"
 ${ARGN}
 )
 
   list(APPEND LLVM_LINK_COMPONENTS ${ARG_LINK_COMPONENTS})
-  add_llvm_executable(${name} ${ARG_UNPARSED_ARGUMENTS})
+  add_llvm_executable(${name} ${ARG_UNPARSED_ARGUMENTS} ENTITLEMENTS ${ARG_ENTITLEMENTS})
 
   target_link_libraries(${name} PRIVATE ${ARG_LINK_LIBS})
   set_target_properties(${name} PROPERTIES
Index: lldb/trunk/cmake/modules/LLDBConfig.cmake
===
--- lldb/trunk/cmake/modules/LLDBConfig.cmake
+++ lldb/trunk/cmake/modules/LLDBConfig.cmake
@@ -50,6 +50,8 @@
   add_definitions( -DLLDB_DISABLE_CURSES )
 endif()
 
+option(LLDB_USE_ENTITLEMENTS "When code signing, use entitlements if available" ON)
+
 # On Windows, we can't use the normal FindPythonLibs module that comes with CMake,
 # for a number of reasons.
 # 1) Prior to MSVC 2015, it is only possible to embed Python if python itself was
Index: lldb/trunk/test/CMakeLists.txt
===
--- lldb/trunk/test/CMakeLists.txt
+++ lldb/trunk/test/CMakeLists.txt
@@ -74,8 +74,8 @@
   endif()
 endif()
 
-if(LLDB_CODESIGN_IDENTITY)
-  list(APPEND LLDB_TEST_COMMON_ARGS --codesign-identity "${LLDB_CODESIGN_IDENTITY}")
+if(LLDB_CODESIGN_IDENTITY_USED)
+  list(APPEND LLDB_TEST_COMMON_ARGS --codesign-identity "${LLDB_CODESIGN_IDENTITY_USED}")
 endif()
 
 if(LLDB_BUILD_FRAMEWORK)
@@ -93,11 +93,11 @@
   endif()
 endif()
 
-if(CMAKE_HOST_APPLE)
+if(CMAKE_HOST_APPLE AND DEBUGSERVER_PATH)
   list(APPEND LLDB_TEST_COMMON_ARGS --server ${DEBUGSERVER_PATH})
 endif()
 
-if(SKIP_DEBUGSERVER)
+if(SKIP_TEST_DEBUGSERVER)
   list(APPEND LLDB_TEST_COMMON_ARGS --out-of-tree-debugserver)
 endif()
 
Index: lldb/trunk/CMakeLists.txt
===
--- lldb/trunk/CMakeLists.txt
+++ lldb/trunk/CMakeLists.txt
@@ -138,9 +138,7 @@
   endif()
 
   if(TARGET debugserver)
-if(NOT CMAKE_HOST_APPLE OR LLDB_CODESIGN_IDENTITY)
-  list(APPEND LLDB_TEST_DEPS debugserver)
-endif()
+list(APPEND LLDB_TEST_DEPS debugserver)
   endif()
 
   if(TARGET lldb-mi)
Index: lldb/trunk/unittests/tools/lldb-server/CMakeLists.txt
===
--- lldb/trunk/unittests/tools/lldb-server/CMakeLists.txt
+++ lldb/trunk/unittests/tools/lldb-server/CMakeLists.txt
@@ -12,7 +12,7 @@
 add_lldb_test_executable(thread_inferior inferior/thread_inferior.cpp)
 add_lldb_test_executable(environment_check inferior/environment_check.cpp)
 
-if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
+if(DEBUGSERVER_PATH)
   add_definitions(-DLLDB_SERVER="${DEBUGSERVER_PATH}" -DLLDB_SERVER_IS_DEBUGSERVER=1)
 else()
   add_definitions(-DLLDB_SERVER="$" -DLLDB_SERVER_IS_DEBUGSERVER=0)
Index: lldb/trunk/unittests/tools/CMakeLists.txt
===
--- lldb/trunk/unittests/tools/CMakeLists.txt
+++ lldb/trunk/unittests/tools/CMakeLists.txt
@@ -1,5 +1,5 @@
 if(CMAKE_SYSTEM_NAME MATCHES "Android|Darwin|Linux|NetBSD")
-  if ((CMAKE_SYSTEM_NAME MATCHES "Darwin" AND SKIP_DEBUGSERVER) OR (NOT CMAKE_SYSTEM_NAME MATCHES "Darwin" AND SKIP_LLDB_SERVER_BUILD))
+  if ((CMAKE_SYSTEM_NAME MATCHES "Darwin" AND SKIP_TEST_DEBUGSERVER) OR (NOT CMAKE_SYSTEM_NAME MATCHES "Darwin" AND SKIP_LLDB_SERVER_BUILD))
 # These tests are meant to test lldb-server/debugserver in isolation, and
 # don't provide any value if run against a server copied from somewhere.
   else()
Index: lldb/trunk/tools/debugserver/source/CMakeLists.txt
===
--- lldb/trunk/tools/debugserver/source/CMakeLists.txt
+++ lldb/trunk/tools/debugserver/source/CMakeLists.txt
@@ -94,32 +94,121 @@
 
 add_library(lldbDebugserverCommon ${lldbDebugserverCommonSourc

[Lldb-commits] [PATCH] D55317: [CMake] Aggregate options for LLDB in LLDBConfig.cmake

2019-01-04 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL350389: [CMake] Aggregate options for LLDB in 
LLDBConfig.cmake (authored by stefan.graenitz, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55317

Files:
  lldb/trunk/CMakeLists.txt
  lldb/trunk/cmake/modules/LLDBConfig.cmake

Index: lldb/trunk/cmake/modules/LLDBConfig.cmake
===
--- lldb/trunk/cmake/modules/LLDBConfig.cmake
+++ lldb/trunk/cmake/modules/LLDBConfig.cmake
@@ -10,28 +10,42 @@
   set(LLDB_LINKER_SUPPORTS_GROUPS ON)
 endif()
 
-set(LLDB_DEFAULT_DISABLE_PYTHON 0)
-set(LLDB_DEFAULT_DISABLE_CURSES 0)
+set(default_disable_python OFF)
+set(default_disable_curses OFF)
+set(default_disable_libedit OFF)
+
+if(DEFINED LLVM_ENABLE_LIBEDIT AND NOT LLVM_ENABLE_LIBEDIT)
+  set(default_disable_libedit ON)
+endif()
 
-if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
-  set(LLDB_DEFAULT_DISABLE_CURSES 1)
-elseif (CMAKE_SYSTEM_NAME MATCHES "Android" )
-  set(LLDB_DEFAULT_DISABLE_PYTHON 1)
-  set(LLDB_DEFAULT_DISABLE_CURSES 1)
+if(CMAKE_SYSTEM_NAME MATCHES "Windows")
+  set(default_disable_curses ON)
+  set(default_disable_libedit ON)
+elseif(CMAKE_SYSTEM_NAME MATCHES "Android")
+  set(default_disable_python ON)
+  set(default_disable_curses ON)
+  set(default_disable_libedit ON)
 elseif(IOS)
-  set(LLDB_DEFAULT_DISABLE_PYTHON 1)
+  set(default_disable_python ON)
 endif()
 
-set(LLDB_DISABLE_PYTHON ${LLDB_DEFAULT_DISABLE_PYTHON} CACHE BOOL
-  "Disables the Python scripting integration.")
-set(LLDB_DISABLE_CURSES ${LLDB_DEFAULT_DISABLE_CURSES} CACHE BOOL
-  "Disables the Curses integration.")
-
-set(LLDB_RELOCATABLE_PYTHON 0 CACHE BOOL
-  "Causes LLDB to use the PYTHONHOME environment variable to locate Python.")
-
-set(LLDB_USE_SYSTEM_SIX 0 CACHE BOOL
-  "Use six.py shipped with system and do not install a copy of it")
+option(LLDB_DISABLE_PYTHON "Disable Python scripting integration." ${default_disable_python})
+option(LLDB_DISABLE_CURSES "Disable Curses integration." ${default_disable_curses})
+option(LLDB_DISABLE_LIBEDIT "Disable the use of editline." ${default_disable_libedit})
+option(LLDB_RELOCATABLE_PYTHON "Use the PYTHONHOME environment variable to locate Python." OFF)
+option(LLDB_USE_SYSTEM_SIX "Use six.py shipped with system and do not install a copy of it" OFF)
+option(LLDB_USE_ENTITLEMENTS "When codesigning, use entitlements if available" ON)
+option(LLDB_BUILD_FRAMEWORK "Build LLDB.framework (Darwin only)" OFF)
+
+if(LLDB_BUILD_FRAMEWORK)
+  if(NOT APPLE)
+message(FATAL_ERROR "LLDB.framework can only be generated when targeting Apple platforms")
+  endif()
+  # CMake 3.6 did not correctly emit POST_BUILD commands for Apple Framework targets
+  if(CMAKE_VERSION VERSION_LESS 3.7)
+message(FATAL_ERROR "LLDB_BUILD_FRAMEWORK is not supported on CMake < 3.7")
+  endif()
+endif()
 
 if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
   set(LLDB_EXPORT_ALL_SYMBOLS 0 CACHE BOOL
@@ -50,8 +64,6 @@
   add_definitions( -DLLDB_DISABLE_CURSES )
 endif()
 
-option(LLDB_USE_ENTITLEMENTS "When code signing, use entitlements if available" ON)
-
 # On Windows, we can't use the normal FindPythonLibs module that comes with CMake,
 # for a number of reasons.
 # 1) Prior to MSVC 2015, it is only possible to embed Python if python itself was
Index: lldb/trunk/CMakeLists.txt
===
--- lldb/trunk/CMakeLists.txt
+++ lldb/trunk/CMakeLists.txt
@@ -18,15 +18,6 @@
   add_definitions( -DLLDB_CONFIGURATION_RELEASE )
 endif()
 
-if (CMAKE_SYSTEM_NAME MATCHES "Windows|Android")
-  set(LLDB_DEFAULT_DISABLE_LIBEDIT 1)
-else()
-  set(LLDB_DEFAULT_DISABLE_LIBEDIT 0)
-endif ()
-
-# We need libedit support to go down both the source and
-# the scripts directories.
-set(LLDB_DISABLE_LIBEDIT ${LLDB_DEFAULT_DISABLE_LIBEDIT} CACHE BOOL "Disables the use of editline.")
 if (LLDB_DISABLE_LIBEDIT)
   add_definitions( -DLLDB_DISABLE_LIBEDIT )
 else()
@@ -42,16 +33,9 @@
 add_custom_target(lldb-suite)
 set(LLDB_SUITE_TARGET lldb-suite)
 
-option(LLDB_BUILD_FRAMEWORK "Build the Darwin LLDB.framework" Off)
 if(LLDB_BUILD_FRAMEWORK)
-  if (CMAKE_VERSION VERSION_LESS 3.7)
-message(FATAL_ERROR "LLDB_BUILD_FRAMEWORK is not supported on CMake < 3.7")
-  endif()
-  if (NOT APPLE)
-message(FATAL_ERROR "LLDB.framework can only be generated when targeting Apple platforms")
-  endif()
-
   add_custom_target(lldb-framework)
+
   # These are used to fill out LLDB-Info.plist. These are relevant when building
   # the framework, and must be defined before building liblldb.
   set(PRODUCT_NAME "LLDB")
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D55328: [CMake] Revised LLDB.framework builds

2019-01-04 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL350391: [CMake] Revised LLDB.framework builds (authored by 
stefan.graenitz, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D55328?vs=177554&id=180230#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55328

Files:
  lldb/trunk/CMakeLists.txt
  lldb/trunk/cmake/modules/AddLLDB.cmake
  lldb/trunk/cmake/modules/LLDBConfig.cmake
  lldb/trunk/cmake/modules/LLDBFramework.cmake
  lldb/trunk/resources/LLDB-Info.plist.in
  lldb/trunk/source/API/CMakeLists.txt
  lldb/trunk/test/CMakeLists.txt
  lldb/trunk/tools/argdumper/CMakeLists.txt
  lldb/trunk/tools/darwin-debug/CMakeLists.txt
  lldb/trunk/tools/debugserver/CMakeLists.txt
  lldb/trunk/tools/debugserver/source/CMakeLists.txt
  lldb/trunk/tools/driver/CMakeLists.txt
  lldb/trunk/tools/lldb-server/CMakeLists.txt

Index: lldb/trunk/cmake/modules/AddLLDB.cmake
===
--- lldb/trunk/cmake/modules/AddLLDB.cmake
+++ lldb/trunk/cmake/modules/AddLLDB.cmake
@@ -50,20 +50,20 @@
 
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "liblldb")
   if (PARAM_SHARED)
-set(out_dir lib${LLVM_LIBDIR_SUFFIX})
 if(${name} STREQUAL "liblldb" AND LLDB_BUILD_FRAMEWORK)
-  set(out_dir ${LLDB_FRAMEWORK_INSTALL_DIR})
-  # The framework that is generated will install with install-liblldb
-  # because we enable CMake's framework support. CMake will copy all the
-  # headers and resources for us.
-  add_dependencies(install-lldb-framework install-${name})
-  add_dependencies(install-lldb-framework-stripped install-${name}-stripped)
+  if(LLDB_FRAMEWORK_INSTALL_DIR)
+set(install_dir ${LLDB_FRAMEWORK_INSTALL_DIR})
+  else()
+set(install_dir ".")
+  endif()
+else()
+  set(install_dir lib${LLVM_LIBDIR_SUFFIX})
 endif()
 install(TARGETS ${name}
   COMPONENT ${name}
   RUNTIME DESTINATION bin
-  LIBRARY DESTINATION ${out_dir}
-  ARCHIVE DESTINATION ${out_dir})
+  LIBRARY DESTINATION ${install_dir}
+  ARCHIVE DESTINATION ${install_dir})
   else()
 install(TARGETS ${name}
   COMPONENT ${name}
@@ -74,13 +74,6 @@
 add_llvm_install_targets(install-${name}
  DEPENDS $
  COMPONENT ${name})
-
-# install-liblldb{,-stripped} is the actual target that will install the
-# framework, so it must rely on the framework being fully built first.
-if (LLDB_BUILD_FRAMEWORK AND ${name} STREQUAL "liblldb")
-  add_dependencies(install-${name} lldb-framework)
-  add_dependencies(install-${name}-stripped lldb-framework)
-endif()
   endif()
 endif()
   endif()
@@ -99,7 +92,7 @@
 
 function(add_lldb_executable name)
   cmake_parse_arguments(ARG
-"INCLUDE_IN_SUITE;GENERATE_INSTALL"
+"GENERATE_INSTALL"
 "ENTITLEMENTS"
 "LINK_LIBS;LINK_COMPONENTS"
 ${ARGN}
@@ -109,53 +102,18 @@
   add_llvm_executable(${name} ${ARG_UNPARSED_ARGUMENTS} ENTITLEMENTS ${ARG_ENTITLEMENTS})
 
   target_link_libraries(${name} PRIVATE ${ARG_LINK_LIBS})
-  set_target_properties(${name} PROPERTIES
-FOLDER "lldb executables")
-
-  if(ARG_INCLUDE_IN_SUITE)
-add_dependencies(lldb-suite ${name})
-if(LLDB_BUILD_FRAMEWORK)
-  if(NOT IOS)
-set(resource_dir "/Resources")
-set(resource_dots "../")
-  endif()
-  string(REGEX REPLACE "[^/]+" ".." _dots ${LLDB_FRAMEWORK_INSTALL_DIR})
-  set_target_properties(${name} PROPERTIES
-RUNTIME_OUTPUT_DIRECTORY $${resource_dir}
-BUILD_WITH_INSTALL_RPATH On
-INSTALL_RPATH "@loader_path/../../../${resource_dots}${_dots}/${LLDB_FRAMEWORK_INSTALL_DIR}")
-endif()
-  endif()
-
-  if(LLDB_BUILD_FRAMEWORK AND NOT ARG_INCLUDE_IN_SUITE)
-set_target_properties(${name} PROPERTIES
-  BUILD_WITH_INSTALL_RPATH On
-  INSTALL_RPATH "@loader_path/../${LLDB_FRAMEWORK_INSTALL_DIR}")
-  endif()
+  set_target_properties(${name} PROPERTIES FOLDER "lldb executables")
 
   if(ARG_GENERATE_INSTALL)
-set(out_dir "bin")
-if (LLDB_BUILD_FRAMEWORK AND ARG_INCLUDE_IN_SUITE)
-  set(out_dir ${LLDB_FRAMEWORK_INSTALL_DIR}/${LLDB_FRAMEWORK_RESOURCE_DIR})
-  # While install-liblldb-stripped will handle copying the tools, it will
-  # not strip them. We depend on this target to guarantee a stripped version
-  # will get installed in the framework.
-  add_dependencies(install-lldb-framework-stripped install-${name}-stripped)
-endif()
 install(TARGETS ${name}
-  COMPONENT ${name}
-  RUNTIME DESTINATION ${out_dir})
+COMPONENT ${name}
+RUNTI

[Lldb-commits] [PATCH] D55330: [CMake] Revised RPATH handling

2019-01-04 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL350392: [CMake] Revised RPATH handling (authored by 
stefan.graenitz, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55330

Files:
  lldb/trunk/cmake/modules/AddLLDB.cmake
  lldb/trunk/cmake/modules/LLDBConfig.cmake
  lldb/trunk/tools/driver/CMakeLists.txt
  lldb/trunk/tools/lldb-mi/CMakeLists.txt
  lldb/trunk/tools/lldb-vscode/CMakeLists.txt

Index: lldb/trunk/tools/lldb-vscode/CMakeLists.txt
===
--- lldb/trunk/tools/lldb-vscode/CMakeLists.txt
+++ lldb/trunk/tools/lldb-vscode/CMakeLists.txt
@@ -28,3 +28,7 @@
   LINK_COMPONENTS
 Support
   )
+
+if(LLDB_BUILD_FRAMEWORK)
+  lldb_setup_framework_rpaths_in_tool(lldb-vscode)
+endif()
Index: lldb/trunk/tools/driver/CMakeLists.txt
===
--- lldb/trunk/tools/driver/CMakeLists.txt
+++ lldb/trunk/tools/driver/CMakeLists.txt
@@ -22,3 +22,7 @@
   LLDBOptionsTableGen
   ${tablegen_deps}
 )
+
+if(LLDB_BUILD_FRAMEWORK)
+  lldb_setup_framework_rpaths_in_tool(lldb)
+endif()
Index: lldb/trunk/tools/lldb-mi/CMakeLists.txt
===
--- lldb/trunk/tools/lldb-mi/CMakeLists.txt
+++ lldb/trunk/tools/lldb-mi/CMakeLists.txt
@@ -93,3 +93,7 @@
   LINK_COMPONENTS
 Support
   )
+
+if(LLDB_BUILD_FRAMEWORK)
+  lldb_setup_framework_rpaths_in_tool(lldb-mi)
+endif()
Index: lldb/trunk/cmake/modules/AddLLDB.cmake
===
--- lldb/trunk/cmake/modules/AddLLDB.cmake
+++ lldb/trunk/cmake/modules/AddLLDB.cmake
@@ -44,9 +44,15 @@
   if (PARAM_OBJECT)
 add_library(${name} ${libkind} ${srcs})
   else()
-llvm_add_library(${name} ${libkind} ${srcs} LINK_LIBS
-${PARAM_LINK_LIBS}
-DEPENDS ${PARAM_DEPENDS})
+if(LLDB_NO_INSTALL_DEFAULT_RPATH)
+  set(pass_NO_INSTALL_RPATH NO_INSTALL_RPATH)
+endif()
+
+llvm_add_library(${name} ${libkind} ${srcs}
+  LINK_LIBS ${PARAM_LINK_LIBS}
+  DEPENDS ${PARAM_DEPENDS}
+  ${pass_NO_INSTALL_RPATH}
+)
 
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "liblldb")
   if (PARAM_SHARED)
@@ -98,8 +104,15 @@
 ${ARGN}
 )
 
+  if(LLDB_NO_INSTALL_DEFAULT_RPATH)
+set(pass_NO_INSTALL_RPATH NO_INSTALL_RPATH)
+  endif()
+
   list(APPEND LLVM_LINK_COMPONENTS ${ARG_LINK_COMPONENTS})
-  add_llvm_executable(${name} ${ARG_UNPARSED_ARGUMENTS} ENTITLEMENTS ${ARG_ENTITLEMENTS})
+  add_llvm_executable(${name} ${ARG_UNPARSED_ARGUMENTS}
+ENTITLEMENTS ${ARG_ENTITLEMENTS}
+${pass_NO_INSTALL_RPATH}
+  )
 
   target_link_libraries(${name} PRIVATE ${ARG_LINK_LIBS})
   set_target_properties(${name} PROPERTIES FOLDER "lldb executables")
@@ -135,3 +148,40 @@
   # Now set them onto the target.
   set_target_properties(${target_name} PROPERTIES LINK_FLAGS ${new_link_flags})
 endfunction()
+
+# For tools that depend on liblldb, account for varying directory structures in
+# which LLDB.framework can be used and distributed: In the build-tree we find it
+# by its absolute target path. This is only relevant for running the test suite.
+# In the install step CMake will remove this entry and insert the final RPATHs.
+# These are relative to the file path from where the tool will be loaded on the
+# enduser system.
+#
+# Note that the LLVM install-tree doesn't match the enduser system structure
+# for LLDB.framework, so by default dependent tools will not be functional in
+# their install location. The LLDB_FRAMEWORK_INSTALL_DIR variable allows to fix
+# this. If specified, it causes the install-tree location of the framework to be
+# added as an extra RPATH below.
+#
+function(lldb_setup_framework_rpaths_in_tool name)
+  # In the build-tree, we know the exact path to the binary in the framework.
+  set(rpath_build_tree "$")
+
+  # The installed framework is relocatable and can be in different locations.
+  set(rpaths_install_tree "@loader_path/../../../SharedFrameworks")
+  list(APPEND rpaths_install_tree "@loader_path/../../System/Library/PrivateFrameworks")
+  list(APPEND rpaths_install_tree "@loader_path/../../Library/PrivateFrameworks")
+
+  if(LLDB_FRAMEWORK_INSTALL_DIR)
+set(rpaths_install_tree "@loader_path/../${LLDB_FRAMEWORK_INSTALL_DIR}")
+  endif()
+
+  # If LLDB_NO_INSTALL_DEFAULT_RPATH was NOT enabled (default), this overwrites
+  # the default settings from llvm_setup_rpath().
+  set_target_properties(${name} PROPERTIES
+BUILD_WITH_INSTALL_RPATH OFF
+BUILD_RPATH "${rpath_build_tree}"
+INSTALL_RPATH "${rpaths_install_tree}"
+  )
+
+  add_dependencies(${name} lldb-framework)
+endfunction()
Index: lldb/trunk/cmake/modules/LLDBConfig.cmake
=

[Lldb-commits] [PATCH] D55332: [CMake] Python bindings generation polishing

2019-01-04 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB350393: [CMake] Python bindings generation polishing 
(authored by stefan.graenitz, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D55332?vs=177533&id=180232#toc

Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D55332

Files:
  CMakeLists.txt
  scripts/CMakeLists.txt
  source/API/CMakeLists.txt

Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -30,14 +30,6 @@
 
 add_subdirectory(docs)
 if (NOT LLDB_DISABLE_PYTHON)
-  set(LLDB_PYTHON_TARGET_DIR ${LLDB_BINARY_DIR}/scripts)
-  set(LLDB_WRAP_PYTHON ${LLDB_BINARY_DIR}/scripts/LLDBWrapPython.cpp)
-  if(LLDB_BUILD_FRAMEWORK)
-set(LLDB_PYTHON_TARGET_DIR ${LLDB_FRAMEWORK_BUILD_DIR})
-set(LLDB_WRAP_PYTHON ${LLDB_PYTHON_TARGET_DIR}/LLDBWrapPython.cpp)
-  endif()
-
-
   add_subdirectory(scripts)
 endif ()
 add_subdirectory(source)
@@ -133,26 +125,27 @@
 if(LLDB_USE_SYSTEM_SIX)
   set(use_six_py_from_system --useSystemSix)
 endif()
+get_target_property(lldb_scripts_dir swig_wrapper BINARY_DIR)
+get_target_property(liblldb_build_dir liblldb LIBRARY_OUTPUT_DIRECTORY)
 
 # Add a Post-Build Event to copy over Python files and create the symlink
 # to liblldb.so for the Python API(hardlink on Windows)
 add_custom_target(finish_swig ALL
 COMMAND
-   ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py
+   ${PYTHON_EXECUTABLE} ${LLDB_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py
--srcRoot=${LLDB_SOURCE_DIR}
-   --targetDir=${LLDB_PYTHON_TARGET_DIR}
-   --cfgBldDir=${LLDB_PYTHON_TARGET_DIR}
+   --targetDir=${liblldb_build_dir}
+   --cfgBldDir=${lldb_scripts_dir}
--prefix=${CMAKE_BINARY_DIR}
--cmakeBuildConfiguration=${CMAKE_CFG_INTDIR}
--lldbLibDir=lib${LLVM_LIBDIR_SUFFIX}
${use_python_wrapper_from_src_dir}
${use_six_py_from_system}
 VERBATIM
-DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py
-DEPENDS ${LLDB_PYTHON_TARGET_DIR}/lldb.py
+DEPENDS ${LLDB_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py
+DEPENDS ${lldb_scripts_dir}/lldb.py
 COMMENT "Python script sym-linking LLDB Python API")
 
-
 if (TARGET readline)
   set(readline_dep readline)
 endif()
Index: source/API/CMakeLists.txt
===
--- source/API/CMakeLists.txt
+++ source/API/CMakeLists.txt
@@ -4,6 +4,11 @@
 
 get_property(LLDB_ALL_PLUGINS GLOBAL PROPERTY LLDB_PLUGINS)
 
+if(NOT LLDB_DISABLE_PYTHON)
+  get_target_property(lldb_scripts_dir swig_wrapper BINARY_DIR)
+  set(lldb_python_wrapper ${lldb_scripts_dir}/LLDBWrapPython.cpp)
+endif()
+
 add_lldb_library(liblldb SHARED
   SBAddress.cpp
   SBAttachInfo.cpp
@@ -73,7 +78,7 @@
   SBWatchpoint.cpp
   SBUnixSignals.cpp
   SystemInitializerFull.cpp
-  ${LLDB_WRAP_PYTHON}
+  ${lldb_python_wrapper}
 
   LINK_LIBS
 lldbBase
@@ -92,23 +97,23 @@
 Support
   )
 
-if(LLDB_WRAP_PYTHON)
+if(lldb_python_wrapper)
   add_dependencies(liblldb swig_wrapper)
 
   if (MSVC)
-set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING PROPERTY COMPILE_FLAGS " /W0")
+set_property(SOURCE ${lldb_python_wrapper} APPEND_STRING PROPERTY COMPILE_FLAGS " /W0")
   else()
-set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING PROPERTY COMPILE_FLAGS " -w")
+set_property(SOURCE ${lldb_python_wrapper} APPEND_STRING PROPERTY COMPILE_FLAGS " -w")
   endif()
 
-  set_source_files_properties(${LLDB_WRAP_PYTHON} PROPERTIES GENERATED 1)
+  set_source_files_properties(${lldb_python_wrapper} PROPERTIES GENERATED ON)
   if (CLANG_CL)
-set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING
+set_property(SOURCE ${lldb_python_wrapper} APPEND_STRING
   PROPERTY COMPILE_FLAGS " -Wno-unused-function")
   endif()
   if (LLVM_COMPILER_IS_GCC_COMPATIBLE AND
   NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
-set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING
+set_property(SOURCE ${lldb_python_wrapper} APPEND_STRING
   PROPERTY COMPILE_FLAGS " -Wno-sequence-point -Wno-cast-qual")
   endif ()
 endif()
Index: scripts/CMakeLists.txt
===
--- scripts/CMakeLists.txt
+++ scripts/CMakeLists.txt
@@ -11,31 +11,14 @@
 
 include(FindPythonInterp)
 
-if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
-  set(SWIG_PYTHON_DIR
-${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR})
-else()
-  set(SWIG_PYTHON_DIR ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/site-packages)
-endif()
-
-set(SWIG_INSTALL_DIR lib${LLVM_LIBDIR_SUFFIX})
-
-# Generating th

[Lldb-commits] [PATCH] D56315: Add a verbose mode to "image dump line-table" and use it to write a .debug_line test

2019-01-04 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added reviewers: clayborg, zturner.
Herald added a subscriber: JDevlieghere.

The motivation for this is being able to write tests for the upcoming
breakpad line table parser, but this could be useful for testing the
low-level workings of any line table format. Or simply for viewing the
line table information with more detail (the brief format doesn't
include any of the flags for end_of_prologue and similar).

I've also removed the load_addresses argument from the
DumpCompileUnitLineTable function, as it wasn't being used anywhere.


https://reviews.llvm.org/D56315

Files:
  lit/SymbolFile/DWARF/debug-line-basic.s
  source/Commands/CommandObjectTarget.cpp

Index: source/Commands/CommandObjectTarget.cpp
===
--- source/Commands/CommandObjectTarget.cpp
+++ source/Commands/CommandObjectTarget.cpp
@@ -1348,7 +1348,7 @@
 static uint32_t DumpCompileUnitLineTable(CommandInterpreter &interpreter,
  Stream &strm, Module *module,
  const FileSpec &file_spec,
- bool load_addresses) {
+ lldb::DescriptionLevel desc_level) {
   uint32_t num_matches = 0;
   if (module) {
 SymbolContextList sc_list;
@@ -1367,7 +1367,7 @@
 if (line_table)
   line_table->GetDescription(
   &strm, interpreter.GetExecutionContext().GetTargetPtr(),
-  lldb::eDescriptionLevelBrief);
+  desc_level);
 else
   strm << "No line table";
   }
@@ -2411,6 +2411,8 @@
 
   ~CommandObjectTargetModulesDumpLineTable() override = default;
 
+  Options *GetOptions() override { return &m_options; }
+
 protected:
   bool DoExecute(Args &command, CommandReturnObject &result) override {
 Target *target = m_exe_ctx.GetTargetPtr();
@@ -2443,8 +2445,9 @@
 if (DumpCompileUnitLineTable(
 m_interpreter, result.GetOutputStream(),
 target_modules.GetModulePointerAtIndexUnlocked(i),
-file_spec, m_exe_ctx.GetProcessPtr() &&
-   m_exe_ctx.GetProcessRef().IsAlive()))
+file_spec,
+m_options.m_verbose ? eDescriptionLevelFull
+: eDescriptionLevelBrief))
   num_dumped++;
   }
   if (num_dumped == 0)
@@ -2464,6 +2467,43 @@
 }
 return result.Succeeded();
   }
+
+  class CommandOptions : public Options {
+  public:
+CommandOptions() : Options() { OptionParsingStarting(nullptr); }
+
+Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
+  ExecutionContext *execution_context) override {
+  assert(option_idx == 0 && "We only have one option.");
+  m_verbose = true;
+
+  return Status();
+}
+
+void OptionParsingStarting(ExecutionContext *execution_context) override {
+  m_verbose = false;
+}
+
+llvm::ArrayRef GetDefinitions() override {
+  static constexpr OptionDefinition g_options[] = {
+  {LLDB_OPT_SET_ALL,
+   false,
+   "verbose",
+   'v',
+   OptionParser::eNoArgument,
+   nullptr,
+   {},
+   0,
+   eArgTypeNone,
+   "Enable verbose dump."},
+  };
+  return llvm::makeArrayRef(g_options);
+}
+
+bool m_verbose;
+  };
+
+  CommandOptions m_options;
 };
 
 #pragma mark CommandObjectTargetModulesDump
Index: lit/SymbolFile/DWARF/debug-line-basic.s
===
--- /dev/null
+++ lit/SymbolFile/DWARF/debug-line-basic.s
@@ -0,0 +1,75 @@
+# REQUIRES: lld
+
+# RUN: llvm-mc -triple x86_64-pc-linux %s -filetype=obj > %t.o
+# RUN: ld.lld %t.o -o %t
+# RUN: %lldb %t -o "image dump line-table -v a.c" -o exit | FileCheck %s
+
+
+	.text
+	.globl	_start
+_start:
+# CHECK: Line table for /tmp/a.c
+	.file	1 "/tmp/b.c"
+	.loc	1 0 0
+nop
+# CHECK-NEXT: 0x00201000: /tmp/b.c, is_start_of_statement = TRUE{{$}}
+	.loc	1 1 0
+nop
+# CHECK-NEXT: 0x00201001: /tmp/b.c:1, is_start_of_statement = TRUE{{$}}
+.loc   1 1 1
+nop
+# CHECK-NEXT: 0x00201002: /tmp/b.c:1:1, is_start_of_statement = TRUE{{$}}
+.loc   1 2 0 is_stmt 0
+nop
+# CHECK-NEXT: 0x00201003: /tmp/b.c:2{{$}}
+.loc   1 2 0 is_stmt 0 basic_block
+nop
+# CHECK-NEXT: 0x00201004: /tmp/b.c:2, is_start_of_basic_block = TRUE{{$}}
+.loc   1 2 0 is_stmt 0 prologue_end
+nop
+# CHECK-NEXT: 0x00201005: /tmp/b.c:2, is_prologue_end = TRUE{{$}}
+.loc   1 2 0 is_stmt 0 epilogue_begin
+nop
+# CHECK-NEXT: 0x00201006: /tmp/b.c:2, is_epilogue_begin = TRUE{{$}}
+	.file  2 "/tmp/c.c"
+	.loc   2 1 0 is_stmt 0
+nop
+# CHECK-NEXT: 0x

[Lldb-commits] [PATCH] D56173: Introduce SymbolFileBreakpad and use it to fill symtab

2019-01-04 Thread Pavel Labath via Phabricator via lldb-commits
labath updated this revision to Diff 180240.
labath added a comment.

A couple of minor tweaks to the patch:

- log in case we were unable to fetch the base address of the object file
- extend the test case to cover ICF-ed symbols (marked with m)
- move the yaml representation of an empty ELF file to a separate Inputs file, 
so it can be reused in other tests


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

https://reviews.llvm.org/D56173

Files:
  lit/SymbolFile/Breakpad/Inputs/basic-elf.yaml
  lit/SymbolFile/Breakpad/Inputs/symtab.syms
  lit/SymbolFile/Breakpad/lit.local.cfg
  lit/SymbolFile/Breakpad/symtab.test
  source/API/SystemInitializerFull.cpp
  source/Plugins/SymbolFile/Breakpad/CMakeLists.txt
  source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
  source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
  source/Plugins/SymbolFile/CMakeLists.txt
  source/Symbol/SymbolVendor.cpp
  tools/lldb-test/SystemInitializerTest.cpp
  tools/lldb-test/lldb-test.cpp

Index: tools/lldb-test/lldb-test.cpp
===
--- tools/lldb-test/lldb-test.cpp
+++ tools/lldb-test/lldb-test.cpp
@@ -100,10 +100,14 @@
 } // namespace object
 
 namespace symbols {
-static cl::list InputFilenames(cl::Positional,
-cl::desc(""),
-cl::OneOrMore,
-cl::sub(SymbolsSubcommand));
+static cl::opt InputFile(cl::Positional, cl::desc(""),
+  cl::Required, cl::sub(SymbolsSubcommand));
+
+static cl::opt
+SymbolPath("symbol-file",
+   cl::desc("The file from which to fetch symbol information."),
+   cl::value_desc("file"), cl::sub(SymbolsSubcommand));
+
 enum class FindType {
   None,
   Function,
@@ -694,28 +698,24 @@
   }
   auto Action = *ActionOr;
 
-  int HadErrors = 0;
-  for (const auto &File : InputFilenames) {
-outs() << "Module: " << File << "\n";
-ModuleSpec Spec{FileSpec(File)};
-Spec.GetSymbolFileSpec().SetFile(File, FileSpec::Style::native);
-
-auto ModulePtr = std::make_shared(Spec);
-SymbolVendor *Vendor = ModulePtr->GetSymbolVendor();
-if (!Vendor) {
-  WithColor::error() << "Module has no symbol vendor.\n";
-  HadErrors = 1;
-  continue;
-}
+  outs() << "Module: " << InputFile << "\n";
+  ModuleSpec Spec{FileSpec(InputFile)};
+  StringRef Symbols = SymbolPath.empty() ? InputFile : SymbolPath;
+  Spec.GetSymbolFileSpec().SetFile(Symbols, FileSpec::Style::native);
 
-if (Error E = Action(*ModulePtr)) {
-  WithColor::error() << toString(std::move(E)) << "\n";
-  HadErrors = 1;
-}
+  auto ModulePtr = std::make_shared(Spec);
+  SymbolVendor *Vendor = ModulePtr->GetSymbolVendor();
+  if (!Vendor) {
+WithColor::error() << "Module has no symbol vendor.\n";
+return 1;
+  }
 
-outs().flush();
+  if (Error E = Action(*ModulePtr)) {
+WithColor::error() << toString(std::move(E)) << "\n";
+return 1;
   }
-  return HadErrors;
+
+  return 0;
 }
 
 static void dumpSectionList(LinePrinter &Printer, const SectionList &List, bool is_subsection) {
Index: tools/lldb-test/SystemInitializerTest.cpp
===
--- tools/lldb-test/SystemInitializerTest.cpp
+++ tools/lldb-test/SystemInitializerTest.cpp
@@ -70,6 +70,7 @@
 #include "Plugins/Process/gdb-remote/ProcessGDBRemote.h"
 #include "Plugins/Process/minidump/ProcessMinidump.h"
 #include "Plugins/ScriptInterpreter/None/ScriptInterpreterNone.h"
+#include "Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h"
 #include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h"
 #include "Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h"
 #include "Plugins/SymbolFile/PDB/SymbolFilePDB.h"
@@ -176,6 +177,7 @@
   MainThreadCheckerRuntime::Initialize();
 
   SymbolVendorELF::Initialize();
+  breakpad::SymbolFileBreakpad::Initialize();
   SymbolFileDWARF::Initialize();
   SymbolFilePDB::Initialize();
   SymbolFileSymtab::Initialize();
@@ -274,6 +276,7 @@
   UndefinedBehaviorSanitizerRuntime::Terminate();
   MainThreadCheckerRuntime::Terminate();
   SymbolVendorELF::Terminate();
+  breakpad::SymbolFileBreakpad::Terminate();
   SymbolFileDWARF::Terminate();
   SymbolFilePDB::Terminate();
   SymbolFileSymtab::Terminate();
Index: source/Symbol/SymbolVendor.cpp
===
--- source/Symbol/SymbolVendor.cpp
+++ source/Symbol/SymbolVendor.cpp
@@ -384,6 +384,7 @@
 s->Indent();
 s->PutCString("SymbolVendor");
 if (m_sym_file_ap.get()) {
+  *s << " " << m_sym_file_ap->GetPluginName();
   ObjectFile *objfile = m_sym_file_ap->GetObjectFile();
   if (objfile) {
 const FileSpec &objfile_file_spec = objfile->GetFileSpec();
@@ -408,6 +409,9 @@
 (*cu_pos)->Dump(s, show_context);
 }
 
+if (Symtab *symtab = GetSymtab())
+  symtab-

[Lldb-commits] [PATCH] D55761: lldb-test ir-memory-map: Use IntervalMap::contains

2019-01-04 Thread Pavel Labath via Phabricator via lldb-commits
labath closed this revision.
labath added a comment.

Landed in r350087.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D55761



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


Re: [Lldb-commits] [PATCH] D56293: Use the minidump exception record if present

2019-01-04 Thread Zachary Turner via lldb-commits
For those kinds of cases, we could use obj2yaml and check in yaml right?
Fwiw I tried to round-trip an exe through obj->yaml->obj recently and the
resulting exe was incorrect but it was close, so I think there’s only some
small fixes needed.

In regards to your previous response, couldn’t we have lldb generate the
mini dump itself as the first step of the test?

On Thu, Jan 3, 2019 at 11:59 PM Pavel Labath via Phabricator <
revi...@reviews.llvm.org> wrote:

> labath added a comment.
>
> In D56293#1345790 , @zturner
> wrote:
>
> > I don't think we can check in an executable file, we should try to
> compile it on the spot.  We have 1-2 existing unit tests that check in an
> exe and we occasionally get reports that peoples' virus scanners flag them
> as trojans, even though they obviously aren't.  In any case, I've been
> meaning to remove those tests, so I think we should set a precedent that
> executable binaries are never checked in.
>
>
> While I agree that a checked-in exe shouldn't be needed in this (and most
> other) cases, I am not sure about the policy in general. For example, I can
> see a case for having a bunch of badly corrupted binaries (things like
> corrupted section headers, overlapping sections in the file; things that
> even yaml2obj will have trouble generating) and then a test that makes sure
> we do something reasonable (e.g., not crash) when opening them. These are
> exactly the kind of files that make paranoid virus scanners sound the alarm.
>
>
> Repository:
>   rLLDB LLDB
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D56293/new/
>
> https://reviews.llvm.org/D56293
>
>
>
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D56315: Add a verbose mode to "image dump line-table" and use it to write a .debug_line test

2019-01-04 Thread Zachary Turner via lldb-commits
It seems like this test could be made to work with non dwarf debug info by
compiling a real source file. WDYT?
On Fri, Jan 4, 2019 at 5:31 AM Pavel Labath via Phabricator <
revi...@reviews.llvm.org> wrote:

> labath created this revision.
> labath added reviewers: clayborg, zturner.
> Herald added a subscriber: JDevlieghere.
>
> The motivation for this is being able to write tests for the upcoming
> breakpad line table parser, but this could be useful for testing the
> low-level workings of any line table format. Or simply for viewing the
> line table information with more detail (the brief format doesn't
> include any of the flags for end_of_prologue and similar).
>
> I've also removed the load_addresses argument from the
> DumpCompileUnitLineTable function, as it wasn't being used anywhere.
>
>
> https://reviews.llvm.org/D56315
>
> Files:
>   lit/SymbolFile/DWARF/debug-line-basic.s
>   source/Commands/CommandObjectTarget.cpp
>
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D56293: Use the minidump exception record if present

2019-01-04 Thread Leonard Mosescu via Phabricator via lldb-commits
lemo updated this revision to Diff 180263.
lemo added a comment.

Removed sigsegv.exe from the test inputs


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

https://reviews.llvm.org/D56293

Files:
  lit/Minidump/Windows/Sigsegv/Inputs/sigsegv.cpp
  lit/Minidump/Windows/Sigsegv/Inputs/sigsegv.dmp
  lit/Minidump/Windows/Sigsegv/Inputs/sigsegv.lldbinit
  lit/Minidump/Windows/Sigsegv/Inputs/sigsegv.pdb
  lit/Minidump/Windows/Sigsegv/sigsegv.test
  source/Plugins/Process/minidump/MinidumpParser.cpp
  source/Plugins/Process/minidump/MinidumpParser.h
  source/Plugins/Process/minidump/ProcessMinidump.cpp

Index: source/Plugins/Process/minidump/ProcessMinidump.cpp
===
--- source/Plugins/Process/minidump/ProcessMinidump.cpp
+++ source/Plugins/Process/minidump/ProcessMinidump.cpp
@@ -34,6 +34,7 @@
 #include "llvm/Support/Threading.h"
 
 #include "Plugins/Process/Utility/StopInfoMachException.h"
+
 // C includes
 // C++ includes
 
@@ -80,7 +81,7 @@
 section_sp, module->base_of_image);
   }
 
-  ObjectFile *GetObjectFile() override { return nullptr; }
+ObjectFile *GetObjectFile() override { return nullptr; }
 
   SectionList *GetSectionList() override {
 return Module::GetUnifiedSectionList();
@@ -309,15 +310,23 @@
   if (m_thread_list.size() > 0)
 num_threads = m_thread_list.size();
 
-  for (lldb::tid_t tid = 0; tid < num_threads; ++tid) {
+  for (size_t t_index = 0; t_index < num_threads; ++t_index) {
 llvm::ArrayRef context;
+const auto& thread = m_thread_list[t_index];
+auto context_location = thread.thread_context;
+
+// If the minidump contains an exception context, use it
+if (m_active_exception != nullptr &&
+m_active_exception->thread_id == thread.thread_id) {
+  context_location = m_active_exception->thread_context;
+}
+
 if (!m_is_wow64)
-  context = m_minidump_parser.GetThreadContext(m_thread_list[tid]);
+  context = m_minidump_parser.GetThreadContext(context_location);
 else
-  context = m_minidump_parser.GetThreadContextWow64(m_thread_list[tid]);
+  context = m_minidump_parser.GetThreadContextWow64(thread);
 
-lldb::ThreadSP thread_sp(
-new ThreadMinidump(*this, m_thread_list[tid], context));
+lldb::ThreadSP thread_sp(new ThreadMinidump(*this, thread, context));
 new_thread_list.AddThread(thread_sp);
   }
   return new_thread_list.GetSize(false) > 0;
@@ -549,9 +558,9 @@
 APPEND_OPT(m_dump_linux_all);
 m_option_group.Finalize();
   }
-  
+
   ~CommandObjectProcessMinidumpDump() {}
-  
+
   Options *GetOptions() override { return &m_option_group; }
 
   bool DoExecute(Args &command, CommandReturnObject &result) override {
@@ -563,7 +572,7 @@
   return false;
 }
 SetDefaultOptionsIfNoneAreSet();
-
+
 ProcessMinidump *process = static_cast(
 m_interpreter.GetExecutionContext().GetProcessPtr());
 result.SetStatus(eReturnStatusSuccessFinishResult);
@@ -635,7 +644,7 @@
 LoadSubCommand("dump",
 CommandObjectSP(new CommandObjectProcessMinidumpDump(interpreter)));
   }
-  
+
   ~CommandObjectMultiwordProcessMinidump() {}
 };
 
Index: source/Plugins/Process/minidump/MinidumpParser.h
===
--- source/Plugins/Process/minidump/MinidumpParser.h
+++ source/Plugins/Process/minidump/MinidumpParser.h
@@ -58,6 +58,9 @@
 
   llvm::ArrayRef GetThreads();
 
+  llvm::ArrayRef
+  GetThreadContext(const MinidumpLocationDescriptor &location);
+
   llvm::ArrayRef GetThreadContext(const MinidumpThread &td);
 
   llvm::ArrayRef GetThreadContextWow64(const MinidumpThread &td);
Index: source/Plugins/Process/minidump/MinidumpParser.cpp
===
--- source/Plugins/Process/minidump/MinidumpParser.cpp
+++ source/Plugins/Process/minidump/MinidumpParser.cpp
@@ -107,11 +107,15 @@
 }
 
 llvm::ArrayRef
-MinidumpParser::GetThreadContext(const MinidumpThread &td) {
-  if (td.thread_context.rva + td.thread_context.data_size > GetData().size())
+MinidumpParser::GetThreadContext(const MinidumpLocationDescriptor &location) {
+  if (location.rva + location.data_size > GetData().size())
 return {};
+  return GetData().slice(location.rva, location.data_size);
+}
 
-  return GetData().slice(td.thread_context.rva, td.thread_context.data_size);
+llvm::ArrayRef
+MinidumpParser::GetThreadContext(const MinidumpThread &td) {
+  return GetThreadContext(td.thread_context);
 }
 
 llvm::ArrayRef
Index: lit/Minidump/Windows/Sigsegv/sigsegv.test
===
--- lit/Minidump/Windows/Sigsegv/sigsegv.test
+++ lit/Minidump/Windows/Sigsegv/sigsegv.test
@@ -0,0 +1,13 @@
+// RUN: cd %p/Inputs
+// RUN: env LLDB_USE_NATIVE_PDB_READER=1 \
+// RUN:   %lldb -c sigsegv.dmp -s sigsegv.lldbinit | FileCheck %s
+
+CHECK: * thread #1, stop reason = Exception 0xc005 encountered

Re: [Lldb-commits] [PATCH] D56293: Use the minidump exception record if present

2019-01-04 Thread Leonard Mosescu via lldb-commits
>
> I have a minidump generator if you need me to make any specific minidump
> files for you.
>

Maybe not in this case, but it seems an interesting idea. What are the
capabilities of this generator tool?

On Thu, Jan 3, 2019 at 3:49 PM Greg Clayton via Phabricator <
revi...@reviews.llvm.org> wrote:

> clayborg added a comment.
>
> I have a minidump generator if you need me to make any specific minidump
> files for you.
>
>
> Repository:
>   rLLDB LLDB
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D56293/new/
>
> https://reviews.llvm.org/D56293
>
>
>
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D56293: Use the minidump exception record if present

2019-01-04 Thread Leonard Mosescu via lldb-commits
>
> ouldn’t we have lldb generate the mini dump itself as the first step of
> the test?
>

How would this work cross-platform?

On Fri, Jan 4, 2019 at 8:48 AM Zachary Turner  wrote:

> For those kinds of cases, we could use obj2yaml and check in yaml right?
> Fwiw I tried to round-trip an exe through obj->yaml->obj recently and the
> resulting exe was incorrect but it was close, so I think there’s only some
> small fixes needed.
>
> In regards to your previous response, couldn’t we have lldb generate the
> mini dump itself as the first step of the test?
>
> On Thu, Jan 3, 2019 at 11:59 PM Pavel Labath via Phabricator <
> revi...@reviews.llvm.org> wrote:
>
>> labath added a comment.
>>
>> In D56293#1345790 , @zturner
>> wrote:
>>
>> > I don't think we can check in an executable file, we should try to
>> compile it on the spot.  We have 1-2 existing unit tests that check in an
>> exe and we occasionally get reports that peoples' virus scanners flag them
>> as trojans, even though they obviously aren't.  In any case, I've been
>> meaning to remove those tests, so I think we should set a precedent that
>> executable binaries are never checked in.
>>
>>
>> While I agree that a checked-in exe shouldn't be needed in this (and most
>> other) cases, I am not sure about the policy in general. For example, I can
>> see a case for having a bunch of badly corrupted binaries (things like
>> corrupted section headers, overlapping sections in the file; things that
>> even yaml2obj will have trouble generating) and then a test that makes sure
>> we do something reasonable (e.g., not crash) when opening them. These are
>> exactly the kind of files that make paranoid virus scanners sound the alarm.
>>
>>
>> Repository:
>>   rLLDB LLDB
>>
>> CHANGES SINCE LAST ACTION
>>   https://reviews.llvm.org/D56293/new/
>>
>> https://reviews.llvm.org/D56293
>>
>>
>>
>>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D56293: Use the minidump exception record if present

2019-01-04 Thread Zachary Turner via lldb-commits
You're right, it wouldn't.  I didn't think of that.  I guess the obj ->
yaml round-tripping would be the only way in that case, and the tool would
need to be fixed first so that it can round trip executable object files.

On Fri, Jan 4, 2019 at 9:46 AM Leonard Mosescu  wrote:

> ouldn’t we have lldb generate the mini dump itself as the first step of
>> the test?
>>
>
> How would this work cross-platform?
>
> On Fri, Jan 4, 2019 at 8:48 AM Zachary Turner  wrote:
>
>> For those kinds of cases, we could use obj2yaml and check in yaml right?
>> Fwiw I tried to round-trip an exe through obj->yaml->obj recently and the
>> resulting exe was incorrect but it was close, so I think there’s only some
>> small fixes needed.
>>
>> In regards to your previous response, couldn’t we have lldb generate the
>> mini dump itself as the first step of the test?
>>
>> On Thu, Jan 3, 2019 at 11:59 PM Pavel Labath via Phabricator <
>> revi...@reviews.llvm.org> wrote:
>>
>>> labath added a comment.
>>>
>>> In D56293#1345790 , @zturner
>>> wrote:
>>>
>>> > I don't think we can check in an executable file, we should try to
>>> compile it on the spot.  We have 1-2 existing unit tests that check in an
>>> exe and we occasionally get reports that peoples' virus scanners flag them
>>> as trojans, even though they obviously aren't.  In any case, I've been
>>> meaning to remove those tests, so I think we should set a precedent that
>>> executable binaries are never checked in.
>>>
>>>
>>> While I agree that a checked-in exe shouldn't be needed in this (and
>>> most other) cases, I am not sure about the policy in general. For example,
>>> I can see a case for having a bunch of badly corrupted binaries (things
>>> like corrupted section headers, overlapping sections in the file; things
>>> that even yaml2obj will have trouble generating) and then a test that makes
>>> sure we do something reasonable (e.g., not crash) when opening them. These
>>> are exactly the kind of files that make paranoid virus scanners sound the
>>> alarm.
>>>
>>>
>>> Repository:
>>>   rLLDB LLDB
>>>
>>> CHANGES SINCE LAST ACTION
>>>   https://reviews.llvm.org/D56293/new/
>>>
>>> https://reviews.llvm.org/D56293
>>>
>>>
>>>
>>>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D56293: Use the minidump exception record if present

2019-01-04 Thread Greg Clayton via lldb-commits


> On Jan 4, 2019, at 9:45 AM, Leonard Mosescu  wrote:
> 
> I have a minidump generator if you need me to make any specific minidump 
> files for you.
> 
> Maybe not in this case, but it seems an interesting idea. What are the 
> capabilities of this generator tool?

I can generate threads contexts, any of the textual directory streams, memory 
regions (32 and 64), module lists, and more.

Example code from my python "minidump" module that shows generation of a 
minidump. Not all of this goes together (example code for ARM and ARM64), but 
it shows what you can easily do:

system_info = minidump.SystemInfo(
ProcessorArchitecture=minidump.PROCESSOR_ARCHITECTURE_ARM64,
PlatformId=minidump.VER_PLATFORM_LINUX,
CSDVersion=minidump.String('15E216'))

md = minidump.Generator(system_info, ProcessId=123)

x = []
v = []
for i in range(32):
x.append(i+1 | i+2 << 32 | i+3 << 48)
for i in range(32):
for j in range(16):
v.append(i+j)

thread = minidump.Thread(ThreadId=0x1000,
Registers=minidump.ThreadContext_ARM64(
x=x, pc=0x1000, cpsr=0x11223344,
fpsr=0x55667788, fpcr=0x99AABBCC, v=v))

system_info = minidump.SystemInfo(
ProcessorArchitecture=minidump.PROCESSOR_ARCHITECTURE_ARM,
PlatformId=minidump.VER_PLATFORM_MACOSX,
CSDVersion=minidump.String('ABC123'))

md = minidump.Generator(system_info, ProcessId=123)

r = []
d = []
extra = []
for i in range(1, 17):
r.append(i)
for i in range(1, 33):
d.append(i | i << 8 | i << 32 | i << 48)
for i in range(8):
extra.append(i | i << 16)

thread = minidump.Thread(ThreadId=0x1000,
Registers=minidump.ThreadContext_ARM(
r=r, cpsr=0x11223344,
fpscr=0x55667788AABBCCDD, d=d,
extra=extra))
md.add_thread(thread)
md.add_thread(minidump.Thread(ThreadId=0x55667788))

md.add_module(minidump.Module(BaseOfImage=0x1,
SizeOfImage=0x2000,
CheckSum=0,
TimeDateStamp=0,
ModuleName="/tmp/b",
VersionInfo=None,
CvRecord=None,
MiscRecord=None,
Reserved0=0,
Reserved1=0))

md.add_module(minidump.Module(BaseOfImage=0x2000,
SizeOfImage=0x1000,
CheckSum=0,
TimeDateStamp=0,
ModuleName="/tmp/a",
VersionInfo=None,
CvRecord=None,
MiscRecord=None,
Reserved0=0,
Reserved1=0))

md.add_module(minidump.Module(BaseOfImage=0x1000,
SizeOfImage=0x1000,
CheckSum=0,
TimeDateStamp=0,
ModuleName="/tmp/b",
VersionInfo=None,
CvRecord=None,
MiscRecord=None,
Reserved0=0,
Reserved1=0))


md.add_module(minidump.Module(BaseOfImage=0x5000,
SizeOfImage=0x3000,
CheckSum=0,
TimeDateStamp=0,
ModuleName="/tmp/b",
VersionInfo=None,
CvRecord=None,
MiscRecord=None,
Reserved0=0,
Reserved1=0))
md.add_memory(minidump.MemoryDescriptor(StartOfMemoryRange=0x8000,
Bytes='Hello world!'))
md.add_memory(minidump.MemoryDescriptor(StartOfMemoryRange=0x8010,
Bytes='Goodbye moon...'))
md.add_memory64(minidump.MemoryDescriptor64(StartOfMemoryRange=0x1000,
Bytes='1' * 16))
md.add_memory64(minidump.MemoryDescriptor64(StartOfMemoryRange=0x2000,
Bytes='3' * 32))

md.add_memory(minidump.MemoryDescriptor(StartOfMemoryRange=0x1000,
Bytes='1' * 16))
md.add_memory(minidump.MemoryDescriptor(StartOfMemoryRange=0x2000,
Bytes='3' * 32))

maps = '''400d9000-400db000 r-xp  b3:04 227
/system/bin/app_process
400db000-400dc000 r--p 1000 b3:04 227/system/bin/app_process
400dc000-400dd000 rw-p  00:00 0 
'''
md.add_stream_as_string(minidump.BreakpadLinuxMaps, maps)
pad = True
add

Re: [Lldb-commits] [PATCH] D56293: Use the minidump exception record if present

2019-01-04 Thread Zachary Turner via lldb-commits
Waiiit a second.  Why don't we just teach obj2yaml and yaml2obj to
round-trip minidumps?  This way you could run it on a minidump, then
hand-edit it to customize some bits you want to change, then check in the
yaml.

On Fri, Jan 4, 2019 at 10:56 AM Greg Clayton  wrote:

>
> On Jan 4, 2019, at 9:45 AM, Leonard Mosescu  wrote:
>
> I have a minidump generator if you need me to make any specific minidump
>> files for you.
>>
>
> Maybe not in this case, but it seems an interesting idea. What are the
> capabilities of this generator tool?
>
>
> I can generate threads contexts, any of the textual directory streams,
> memory regions (32 and 64), module lists, and more.
>
> Example code from my python "minidump" module that shows generation of a
> minidump. Not all of this goes together (example code for ARM and ARM64),
> but it shows what you can easily do:
>
> system_info = minidump.SystemInfo(
> ProcessorArchitecture=minidump.PROCESSOR_ARCHITECTURE_ARM64,
> PlatformId=minidump.VER_PLATFORM_LINUX,
> CSDVersion=minidump.String('15E216'))
>
> md = minidump.Generator(system_info, ProcessId=123)
>
> x = []
> v = []
> for i in range(32):
> x.append(i+1 | i+2 << 32 | i+3 << 48)
> for i in range(32):
> for j in range(16):
> v.append(i+j)
>
> thread = minidump.Thread(ThreadId=0x1000,
> Registers=minidump.ThreadContext_ARM64(
> x=x, pc=0x1000, cpsr=0x11223344,
> fpsr=0x55667788, fpcr=0x99AABBCC, v=v))
>
> system_info = minidump.SystemInfo(
> ProcessorArchitecture=minidump.PROCESSOR_ARCHITECTURE_ARM,
> PlatformId=minidump.VER_PLATFORM_MACOSX,
> CSDVersion=minidump.String('ABC123'))
>
> md = minidump.Generator(system_info, ProcessId=123)
>
> r = []
> d = []
> extra = []
> for i in range(1, 17):
> r.append(i)
> for i in range(1, 33):
> d.append(i | i << 8 | i << 32 | i << 48)
> for i in range(8):
> extra.append(i | i << 16)
>
> thread = minidump.Thread(ThreadId=0x1000,
> Registers=minidump.ThreadContext_ARM(
> r=r, cpsr=0x11223344,
> fpscr=0x55667788AABBCCDD, d=d,
> extra=extra))
> md.add_thread(thread)
> md.add_thread(minidump.Thread(ThreadId=0x55667788))
>
> md.add_module(minidump.Module(BaseOfImage=0x1,
> SizeOfImage=0x2000,
> CheckSum=0,
> TimeDateStamp=0,
> ModuleName="/tmp/b",
> VersionInfo=None,
> CvRecord=None,
> MiscRecord=None,
> Reserved0=0,
> Reserved1=0))
>
> md.add_module(minidump.Module(BaseOfImage=0x2000,
> SizeOfImage=0x1000,
> CheckSum=0,
> TimeDateStamp=0,
> ModuleName="/tmp/a",
> VersionInfo=None,
> CvRecord=None,
> MiscRecord=None,
> Reserved0=0,
> Reserved1=0))
>
> md.add_module(minidump.Module(BaseOfImage=0x1000,
> SizeOfImage=0x1000,
> CheckSum=0,
> TimeDateStamp=0,
> ModuleName="/tmp/b",
> VersionInfo=None,
> CvRecord=None,
> MiscRecord=None,
> Reserved0=0,
> Reserved1=0))
>
>
> md.add_module(minidump.Module(BaseOfImage=0x5000,
> SizeOfImage=0x3000,
> CheckSum=0,
> TimeDateStamp=0,
> ModuleName="/tmp/b",
> VersionInfo=None,
> CvRecord=None,
> MiscRecord=None,
> Reserved0=0,
> Reserved1=0))
> md.add_memory(minidump.MemoryDescriptor(StartOfMemoryRange=0x8000,
> Bytes='Hello world!'))
> md.add_memory(minidump.MemoryDescriptor(StartOfMemoryRange=0x8010,
> Bytes='Goodbye moon...'))
> md.add_memory64(minidump.MemoryDescriptor64(StartOfMemoryRange=0x1000,
> Bytes='1' * 16))
> md.add_memory64(minidump.MemoryDescriptor64(StartOfMemoryRange=0x2000,
> Bytes='3' * 32))
>
> md.add_memory(minidump.MemoryDescriptor(StartOfMemo

[Lldb-commits] [PATCH] D55434: ObjectFileBreakpad: Implement sections

2019-01-04 Thread Greg Clayton via Phabricator via lldb-commits
clayborg accepted this revision.
clayborg added a comment.
This revision is now accepted and ready to land.

You have convinced me! Sorry I had paged out the original intent you conveyed 
from before the break. Thanks for the details.


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

https://reviews.llvm.org/D55434



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


Re: [Lldb-commits] [PATCH] D56293: Use the minidump exception record if present

2019-01-04 Thread Greg Clayton via lldb-commits
The main goal for this minidump module was so I could load it into lldb and 
then run "minidump --save" to save the current process as a minidump file since 
I like minidump files better than core files... It just happens to work for 
generating very small and targeted minidump files for testing as a benefit of 
code reuse.

Greg


> On Jan 4, 2019, at 11:07 AM, Zachary Turner  wrote:
> 
> Waiiit a second.  Why don't we just teach obj2yaml and yaml2obj to 
> round-trip minidumps?  This way you could run it on a minidump, then 
> hand-edit it to customize some bits you want to change, then check in the 
> yaml.
> 
> On Fri, Jan 4, 2019 at 10:56 AM Greg Clayton  > wrote:
> 
>> On Jan 4, 2019, at 9:45 AM, Leonard Mosescu > > wrote:
>> 
>> I have a minidump generator if you need me to make any specific minidump 
>> files for you.
>> 
>> Maybe not in this case, but it seems an interesting idea. What are the 
>> capabilities of this generator tool?
> 
> I can generate threads contexts, any of the textual directory streams, memory 
> regions (32 and 64), module lists, and more.
> 
> Example code from my python "minidump" module that shows generation of a 
> minidump. Not all of this goes together (example code for ARM and ARM64), but 
> it shows what you can easily do:
> 
> system_info = minidump.SystemInfo(
> ProcessorArchitecture=minidump.PROCESSOR_ARCHITECTURE_ARM64,
> PlatformId=minidump.VER_PLATFORM_LINUX,
> CSDVersion=minidump.String('15E216'))
> 
> md = minidump.Generator(system_info, ProcessId=123)
> 
> x = []
> v = []
> for i in range(32):
> x.append(i+1 | i+2 << 32 | i+3 << 48)
> for i in range(32):
> for j in range(16):
> v.append(i+j)
> 
> thread = minidump.Thread(ThreadId=0x1000,
> Registers=minidump.ThreadContext_ARM64(
> x=x, pc=0x1000, cpsr=0x11223344,
> fpsr=0x55667788, fpcr=0x99AABBCC, v=v))
> 
> system_info = minidump.SystemInfo(
> ProcessorArchitecture=minidump.PROCESSOR_ARCHITECTURE_ARM,
> PlatformId=minidump.VER_PLATFORM_MACOSX,
> CSDVersion=minidump.String('ABC123'))
> 
> md = minidump.Generator(system_info, ProcessId=123)
> 
> r = []
> d = []
> extra = []
> for i in range(1, 17):
> r.append(i)
> for i in range(1, 33):
> d.append(i | i << 8 | i << 32 | i << 48)
> for i in range(8):
> extra.append(i | i << 16)
> 
> thread = minidump.Thread(ThreadId=0x1000,
> Registers=minidump.ThreadContext_ARM(
> r=r, cpsr=0x11223344,
> fpscr=0x55667788AABBCCDD, d=d,
> extra=extra))
> md.add_thread(thread)
> md.add_thread(minidump.Thread(ThreadId=0x55667788))
> 
> md.add_module(minidump.Module(BaseOfImage=0x1,
> SizeOfImage=0x2000,
> CheckSum=0,
> TimeDateStamp=0,
> ModuleName="/tmp/b",
> VersionInfo=None,
> CvRecord=None,
> MiscRecord=None,
> Reserved0=0,
> Reserved1=0))
> 
> md.add_module(minidump.Module(BaseOfImage=0x2000,
> SizeOfImage=0x1000,
> CheckSum=0,
> TimeDateStamp=0,
> ModuleName="/tmp/a",
> VersionInfo=None,
> CvRecord=None,
> MiscRecord=None,
> Reserved0=0,
> Reserved1=0))
> 
> md.add_module(minidump.Module(BaseOfImage=0x1000,
> SizeOfImage=0x1000,
> CheckSum=0,
> TimeDateStamp=0,
> ModuleName="/tmp/b",
> VersionInfo=None,
> CvRecord=None,
> MiscRecord=None,
> Reserved0=0,
> Reserved1=0))
> 
> 
> md.add_module(minidump.Module(BaseOfImage=0x5000,
> SizeOfImage=0x3000,
> CheckSum=0,
> TimeDateStamp=0,
> ModuleName="/tmp/b",
> VersionInfo=None,
> CvRecord=None,
> MiscRecord=None,
> Reserved0=0,
> Reserved1=0))
> md.add_memory(minidump.MemoryDescriptor(StartOfMemoryRange=0x8000,
>

[Lldb-commits] [lldb] r350428 - [Scalar] Simplify comparison operators and add coverage.

2019-01-04 Thread Davide Italiano via lldb-commits
Author: davide
Date: Fri Jan  4 11:23:52 2019
New Revision: 350428

URL: http://llvm.org/viewvc/llvm-project?rev=350428&view=rev
Log:
[Scalar] Simplify comparison operators and add coverage.

Modified:
lldb/trunk/source/Utility/Scalar.cpp
lldb/trunk/unittests/Utility/ScalarTest.cpp

Modified: lldb/trunk/source/Utility/Scalar.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/Scalar.cpp?rev=350428&r1=350427&r2=350428&view=diff
==
--- lldb/trunk/source/Utility/Scalar.cpp (original)
+++ lldb/trunk/source/Utility/Scalar.cpp Fri Jan  4 11:23:52 2019
@@ -2635,104 +2635,15 @@ bool lldb_private::operator<(const Scala
 }
 
 bool lldb_private::operator<=(const Scalar &lhs, const Scalar &rhs) {
-  if (lhs.m_type == Scalar::e_void || rhs.m_type == Scalar::e_void)
-return false;
-
-  Scalar temp_value;
-  const Scalar *a;
-  const Scalar *b;
-  llvm::APFloat::cmpResult result;
-  switch (PromoteToMaxType(lhs, rhs, temp_value, a, b)) {
-  case Scalar::e_void:
-break;
-  case Scalar::e_sint:
-  case Scalar::e_slong:
-  case Scalar::e_slonglong:
-  case Scalar::e_sint128:
-  case Scalar::e_sint256:
-return a->m_integer.sle(b->m_integer);
-  case Scalar::e_uint:
-  case Scalar::e_ulong:
-  case Scalar::e_ulonglong:
-  case Scalar::e_uint128:
-  case Scalar::e_uint256:
-return a->m_integer.ule(b->m_integer);
-  case Scalar::e_float:
-  case Scalar::e_double:
-  case Scalar::e_long_double:
-result = a->m_float.compare(b->m_float);
-if (result == llvm::APFloat::cmpLessThan ||
-result == llvm::APFloat::cmpEqual)
-  return true;
-  }
-  return false;
+  return !(rhs < lhs);
 }
 
 bool lldb_private::operator>(const Scalar &lhs, const Scalar &rhs) {
-  if (lhs.m_type == Scalar::e_void || rhs.m_type == Scalar::e_void)
-return false;
-
-  Scalar temp_value;
-  const Scalar *a;
-  const Scalar *b;
-  llvm::APFloat::cmpResult result;
-  switch (PromoteToMaxType(lhs, rhs, temp_value, a, b)) {
-  case Scalar::e_void:
-break;
-  case Scalar::e_sint:
-  case Scalar::e_slong:
-  case Scalar::e_slonglong:
-  case Scalar::e_sint128:
-  case Scalar::e_sint256:
-return a->m_integer.sgt(b->m_integer);
-  case Scalar::e_uint:
-  case Scalar::e_ulong:
-  case Scalar::e_ulonglong:
-  case Scalar::e_uint128:
-  case Scalar::e_uint256:
-return a->m_integer.ugt(b->m_integer);
-  case Scalar::e_float:
-  case Scalar::e_double:
-  case Scalar::e_long_double:
-result = a->m_float.compare(b->m_float);
-if (result == llvm::APFloat::cmpGreaterThan)
-  return true;
-  }
-  return false;
+  return rhs < lhs;
 }
 
 bool lldb_private::operator>=(const Scalar &lhs, const Scalar &rhs) {
-  if (lhs.m_type == Scalar::e_void || rhs.m_type == Scalar::e_void)
-return false;
-
-  Scalar temp_value;
-  const Scalar *a;
-  const Scalar *b;
-  llvm::APFloat::cmpResult result;
-  switch (PromoteToMaxType(lhs, rhs, temp_value, a, b)) {
-  case Scalar::e_void:
-break;
-  case Scalar::e_sint:
-  case Scalar::e_slong:
-  case Scalar::e_slonglong:
-  case Scalar::e_sint128:
-  case Scalar::e_sint256:
-return a->m_integer.sge(b->m_integer);
-  case Scalar::e_uint:
-  case Scalar::e_ulong:
-  case Scalar::e_ulonglong:
-  case Scalar::e_uint128:
-  case Scalar::e_uint256:
-return a->m_integer.uge(b->m_integer);
-  case Scalar::e_float:
-  case Scalar::e_double:
-  case Scalar::e_long_double:
-result = a->m_float.compare(b->m_float);
-if (result == llvm::APFloat::cmpGreaterThan ||
-result == llvm::APFloat::cmpEqual)
-  return true;
-  }
-  return false;
+  return !(lhs < rhs);
 }
 
 bool Scalar::ClearBit(uint32_t bit) {

Modified: lldb/trunk/unittests/Utility/ScalarTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Utility/ScalarTest.cpp?rev=350428&r1=350427&r2=350428&view=diff
==
--- lldb/trunk/unittests/Utility/ScalarTest.cpp (original)
+++ lldb/trunk/unittests/Utility/ScalarTest.cpp Fri Jan  4 11:23:52 2019
@@ -47,6 +47,24 @@ TEST(ScalarTest, Equality) {
   ASSERT_FALSE(void1 == Scalar(f1));
 }
 
+TEST(ScalarTest, Comparison) {
+  auto s1 = Scalar(23);
+  auto s2 = Scalar(46);
+  ASSERT_TRUE(s1 < s2);
+  ASSERT_TRUE(s1 <= s2);
+  ASSERT_TRUE(s2 > s1);
+  ASSERT_TRUE(s2 >= s1);
+}
+
+TEST(ScalarTest, ComparisonFloat) {
+  auto s1 = Scalar(23.0f);
+  auto s2 = Scalar(46.0f);
+  ASSERT_TRUE(s1 < s2);
+  ASSERT_TRUE(s1 <= s2);
+  ASSERT_TRUE(s2 > s1);
+  ASSERT_TRUE(s2 >= s1);
+}
+
 TEST(ScalarTest, RightShiftOperator) {
   int a = 0x1000;
   int b = 0x;


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


Re: [Lldb-commits] [PATCH] D56293: Use the minidump exception record if present

2019-01-04 Thread Leonard Mosescu via lldb-commits
Sounds very useful. Are you planning to add it to the LLDB repository?


On Fri, Jan 4, 2019 at 10:56 AM Greg Clayton  wrote:

>
>
> On Jan 4, 2019, at 9:45 AM, Leonard Mosescu  wrote:
>
> I have a minidump generator if you need me to make any specific minidump
>> files for you.
>>
>
> Maybe not in this case, but it seems an interesting idea. What are the
> capabilities of this generator tool?
>
>
> I can generate threads contexts, any of the textual directory streams,
> memory regions (32 and 64), module lists, and more.
>
> Example code from my python "minidump" module that shows generation of a
> minidump. Not all of this goes together (example code for ARM and ARM64),
> but it shows what you can easily do:
>
> system_info = minidump.SystemInfo(
> ProcessorArchitecture=minidump.PROCESSOR_ARCHITECTURE_ARM64,
> PlatformId=minidump.VER_PLATFORM_LINUX,
> CSDVersion=minidump.String('15E216'))
>
> md = minidump.Generator(system_info, ProcessId=123)
>
> x = []
> v = []
> for i in range(32):
> x.append(i+1 | i+2 << 32 | i+3 << 48)
> for i in range(32):
> for j in range(16):
> v.append(i+j)
>
> thread = minidump.Thread(ThreadId=0x1000,
> Registers=minidump.ThreadContext_ARM64(
> x=x, pc=0x1000, cpsr=0x11223344,
> fpsr=0x55667788, fpcr=0x99AABBCC, v=v))
>
> system_info = minidump.SystemInfo(
> ProcessorArchitecture=minidump.PROCESSOR_ARCHITECTURE_ARM,
> PlatformId=minidump.VER_PLATFORM_MACOSX,
> CSDVersion=minidump.String('ABC123'))
>
> md = minidump.Generator(system_info, ProcessId=123)
>
> r = []
> d = []
> extra = []
> for i in range(1, 17):
> r.append(i)
> for i in range(1, 33):
> d.append(i | i << 8 | i << 32 | i << 48)
> for i in range(8):
> extra.append(i | i << 16)
>
> thread = minidump.Thread(ThreadId=0x1000,
> Registers=minidump.ThreadContext_ARM(
> r=r, cpsr=0x11223344,
> fpscr=0x55667788AABBCCDD, d=d,
> extra=extra))
> md.add_thread(thread)
> md.add_thread(minidump.Thread(ThreadId=0x55667788))
>
> md.add_module(minidump.Module(BaseOfImage=0x1,
> SizeOfImage=0x2000,
> CheckSum=0,
> TimeDateStamp=0,
> ModuleName="/tmp/b",
> VersionInfo=None,
> CvRecord=None,
> MiscRecord=None,
> Reserved0=0,
> Reserved1=0))
>
> md.add_module(minidump.Module(BaseOfImage=0x2000,
> SizeOfImage=0x1000,
> CheckSum=0,
> TimeDateStamp=0,
> ModuleName="/tmp/a",
> VersionInfo=None,
> CvRecord=None,
> MiscRecord=None,
> Reserved0=0,
> Reserved1=0))
>
> md.add_module(minidump.Module(BaseOfImage=0x1000,
> SizeOfImage=0x1000,
> CheckSum=0,
> TimeDateStamp=0,
> ModuleName="/tmp/b",
> VersionInfo=None,
> CvRecord=None,
> MiscRecord=None,
> Reserved0=0,
> Reserved1=0))
>
>
> md.add_module(minidump.Module(BaseOfImage=0x5000,
> SizeOfImage=0x3000,
> CheckSum=0,
> TimeDateStamp=0,
> ModuleName="/tmp/b",
> VersionInfo=None,
> CvRecord=None,
> MiscRecord=None,
> Reserved0=0,
> Reserved1=0))
> md.add_memory(minidump.MemoryDescriptor(StartOfMemoryRange=0x8000,
> Bytes='Hello world!'))
> md.add_memory(minidump.MemoryDescriptor(StartOfMemoryRange=0x8010,
> Bytes='Goodbye moon...'))
> md.add_memory64(minidump.MemoryDescriptor64(StartOfMemoryRange=0x1000,
> Bytes='1' * 16))
> md.add_memory64(minidump.MemoryDescriptor64(StartOfMemoryRange=0x2000,
> Bytes='3' * 32))
>
> md.add_memory(minidump.MemoryDescriptor(StartOfMemoryRange=0x1000,
> Bytes='1' * 16))
> md.add_memory(minidump.MemoryDescriptor(StartOfMemoryRange=0x2000,
> 

Re: [Lldb-commits] [PATCH] D56293: Use the minidump exception record if present

2019-01-04 Thread Greg Clayton via lldb-commits


> On Jan 4, 2019, at 12:37 PM, Leonard Mosescu  wrote:
> 
> Sounds very useful. Are you planning to add it to the LLDB repository?

Yes
> 
> 
> On Fri, Jan 4, 2019 at 10:56 AM Greg Clayton  > wrote:
> 
> 
>> On Jan 4, 2019, at 9:45 AM, Leonard Mosescu > > wrote:
>> 
>> I have a minidump generator if you need me to make any specific minidump 
>> files for you.
>> 
>> Maybe not in this case, but it seems an interesting idea. What are the 
>> capabilities of this generator tool?
> 
> I can generate threads contexts, any of the textual directory streams, memory 
> regions (32 and 64), module lists, and more.
> 
> Example code from my python "minidump" module that shows generation of a 
> minidump. Not all of this goes together (example code for ARM and ARM64), but 
> it shows what you can easily do:
> 
> system_info = minidump.SystemInfo(
> ProcessorArchitecture=minidump.PROCESSOR_ARCHITECTURE_ARM64,
> PlatformId=minidump.VER_PLATFORM_LINUX,
> CSDVersion=minidump.String('15E216'))
> 
> md = minidump.Generator(system_info, ProcessId=123)
> 
> x = []
> v = []
> for i in range(32):
> x.append(i+1 | i+2 << 32 | i+3 << 48)
> for i in range(32):
> for j in range(16):
> v.append(i+j)
> 
> thread = minidump.Thread(ThreadId=0x1000,
> Registers=minidump.ThreadContext_ARM64(
> x=x, pc=0x1000, cpsr=0x11223344,
> fpsr=0x55667788, fpcr=0x99AABBCC, v=v))
> 
> system_info = minidump.SystemInfo(
> ProcessorArchitecture=minidump.PROCESSOR_ARCHITECTURE_ARM,
> PlatformId=minidump.VER_PLATFORM_MACOSX,
> CSDVersion=minidump.String('ABC123'))
> 
> md = minidump.Generator(system_info, ProcessId=123)
> 
> r = []
> d = []
> extra = []
> for i in range(1, 17):
> r.append(i)
> for i in range(1, 33):
> d.append(i | i << 8 | i << 32 | i << 48)
> for i in range(8):
> extra.append(i | i << 16)
> 
> thread = minidump.Thread(ThreadId=0x1000,
> Registers=minidump.ThreadContext_ARM(
> r=r, cpsr=0x11223344,
> fpscr=0x55667788AABBCCDD, d=d,
> extra=extra))
> md.add_thread(thread)
> md.add_thread(minidump.Thread(ThreadId=0x55667788))
> 
> md.add_module(minidump.Module(BaseOfImage=0x1,
> SizeOfImage=0x2000,
> CheckSum=0,
> TimeDateStamp=0,
> ModuleName="/tmp/b",
> VersionInfo=None,
> CvRecord=None,
> MiscRecord=None,
> Reserved0=0,
> Reserved1=0))
> 
> md.add_module(minidump.Module(BaseOfImage=0x2000,
> SizeOfImage=0x1000,
> CheckSum=0,
> TimeDateStamp=0,
> ModuleName="/tmp/a",
> VersionInfo=None,
> CvRecord=None,
> MiscRecord=None,
> Reserved0=0,
> Reserved1=0))
> 
> md.add_module(minidump.Module(BaseOfImage=0x1000,
> SizeOfImage=0x1000,
> CheckSum=0,
> TimeDateStamp=0,
> ModuleName="/tmp/b",
> VersionInfo=None,
> CvRecord=None,
> MiscRecord=None,
> Reserved0=0,
> Reserved1=0))
> 
> 
> md.add_module(minidump.Module(BaseOfImage=0x5000,
> SizeOfImage=0x3000,
> CheckSum=0,
> TimeDateStamp=0,
> ModuleName="/tmp/b",
> VersionInfo=None,
> CvRecord=None,
> MiscRecord=None,
> Reserved0=0,
> Reserved1=0))
> md.add_memory(minidump.MemoryDescriptor(StartOfMemoryRange=0x8000,
> Bytes='Hello world!'))
> md.add_memory(minidump.MemoryDescriptor(StartOfMemoryRange=0x8010,
> Bytes='Goodbye moon...'))
> md.add_memory64(minidump.MemoryDescriptor64(StartOfMemoryRange=0x1000,
> Bytes='1' * 16))
> md.add_memory64(minidump.MemoryDescriptor64(StartOfMemoryRange=0x2000,
> Bytes='3' * 32))
> 
> md.add_memory(minidump.MemoryDescriptor(

Re: [Lldb-commits] [PATCH] D56293: Use the minidump exception record if present

2019-01-04 Thread Leonard Mosescu via lldb-commits
Great! I can see how we can put this to good use.

In the meantime, I'd like to submit this change as is - the included input
files are intended to be reused for future test cases as well (they are
extracted from my larger change to add support for the native PDB reader +
minidumps).

On Fri, Jan 4, 2019 at 12:39 PM Greg Clayton  wrote:

>
>
> On Jan 4, 2019, at 12:37 PM, Leonard Mosescu  wrote:
>
> Sounds very useful. Are you planning to add it to the LLDB repository?
>
>
> Yes
>
>
>
> On Fri, Jan 4, 2019 at 10:56 AM Greg Clayton  wrote:
>
>>
>>
>> On Jan 4, 2019, at 9:45 AM, Leonard Mosescu  wrote:
>>
>> I have a minidump generator if you need me to make any specific minidump
>>> files for you.
>>>
>>
>> Maybe not in this case, but it seems an interesting idea. What are the
>> capabilities of this generator tool?
>>
>>
>> I can generate threads contexts, any of the textual directory streams,
>> memory regions (32 and 64), module lists, and more.
>>
>> Example code from my python "minidump" module that shows generation of a
>> minidump. Not all of this goes together (example code for ARM and ARM64),
>> but it shows what you can easily do:
>>
>> system_info = minidump.SystemInfo(
>> ProcessorArchitecture=minidump.PROCESSOR_ARCHITECTURE_ARM64,
>> PlatformId=minidump.VER_PLATFORM_LINUX,
>> CSDVersion=minidump.String('15E216'))
>>
>> md = minidump.Generator(system_info, ProcessId=123)
>>
>> x = []
>> v = []
>> for i in range(32):
>> x.append(i+1 | i+2 << 32 | i+3 << 48)
>> for i in range(32):
>> for j in range(16):
>> v.append(i+j)
>>
>> thread = minidump.Thread(ThreadId=0x1000,
>> Registers=minidump.ThreadContext_ARM64(
>> x=x, pc=0x1000, cpsr=0x11223344,
>> fpsr=0x55667788, fpcr=0x99AABBCC, v=v))
>>
>> system_info = minidump.SystemInfo(
>> ProcessorArchitecture=minidump.PROCESSOR_ARCHITECTURE_ARM,
>> PlatformId=minidump.VER_PLATFORM_MACOSX,
>> CSDVersion=minidump.String('ABC123'))
>>
>> md = minidump.Generator(system_info, ProcessId=123)
>>
>> r = []
>> d = []
>> extra = []
>> for i in range(1, 17):
>> r.append(i)
>> for i in range(1, 33):
>> d.append(i | i << 8 | i << 32 | i << 48)
>> for i in range(8):
>> extra.append(i | i << 16)
>>
>> thread = minidump.Thread(ThreadId=0x1000,
>> Registers=minidump.ThreadContext_ARM(
>> r=r, cpsr=0x11223344,
>> fpscr=0x55667788AABBCCDD, d=d,
>> extra=extra))
>> md.add_thread(thread)
>> md.add_thread(minidump.Thread(ThreadId=0x55667788))
>>
>> md.add_module(minidump.Module(BaseOfImage=0x1,
>> SizeOfImage=0x2000,
>> CheckSum=0,
>> TimeDateStamp=0,
>> ModuleName="/tmp/b",
>> VersionInfo=None,
>> CvRecord=None,
>> MiscRecord=None,
>> Reserved0=0,
>> Reserved1=0))
>>
>> md.add_module(minidump.Module(BaseOfImage=0x2000,
>> SizeOfImage=0x1000,
>> CheckSum=0,
>> TimeDateStamp=0,
>> ModuleName="/tmp/a",
>> VersionInfo=None,
>> CvRecord=None,
>> MiscRecord=None,
>> Reserved0=0,
>> Reserved1=0))
>>
>> md.add_module(minidump.Module(BaseOfImage=0x1000,
>> SizeOfImage=0x1000,
>> CheckSum=0,
>> TimeDateStamp=0,
>> ModuleName="/tmp/b",
>> VersionInfo=None,
>> CvRecord=None,
>> MiscRecord=None,
>> Reserved0=0,
>> Reserved1=0))
>>
>>
>> md.add_module(minidump.Module(BaseOfImage=0x5000,
>> SizeOfImage=0x3000,
>> CheckSum=0,
>> TimeDateStamp=0,
>> ModuleName="/tmp/b",
>> VersionInfo=None,
>> CvRecord=None,
>> MiscRecord=None,
>> Reserved0=0,
>> Reserved1=0))
>> md.add_memory(minidump.MemoryDescriptor(StartOfMemoryRange=0x8000,
>> Bytes='Hello world!'))
>> md.add_memory(minidump.MemoryDescriptor(StartOfMemoryRange=0x8010,
>>

[Lldb-commits] [PATCH] D56231: [lldb-server] Improve support on Windows

2019-01-04 Thread Hui Huang via Phabricator via lldb-commits
Hui added a comment.

With all the aaron's pending reviews on lldb-server, I could try the patch with 
the following platform apis.

Seems to me is working on Windows and no regression on Linux side.  Some 
difference (performance) might be

(1) Previous, the vfile:write packet has a maximum as 1024 bytes, now it turns 
to 16384 byte from observations.
(2) FileSystem::Instance().Open will introduce some performance bumps however I 
think it is minor along with the ctor/dtor of the File

I think the python tests already cover the changes in this commit, especially 
for Linux.

Not applicable for Windows I think, since we need the availability of 
lldb-server.exe.

Remote:
./lldb-server.exe p --listen *:2000 --log-channels="lldb all:gdb-remote 
all:windows all"

LLDB:
platform select remote-windows
platform connect 
file a.exe
r




Comment at: source/Host/common/File.cpp:607
 long cur = ::lseek(m_descriptor, 0, SEEK_CUR);
+SeekFromStart(offset);
 error = Write(buf, num_bytes);

I think this line makes Windows equivalence since posix part is using 'pwrite' 
which means to write from a set offset in the file.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D56231



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


[Lldb-commits] [PATCH] D56229: [PECOFF] Implementation of ObjectFilePECOFF:: GetUUID()

2019-01-04 Thread Hui Huang via Phabricator via lldb-commits
Hui added a comment.

Not quite sure but correct me if i am wrong.

(1) I think the Debug Directory is optional for COFF if it does have debug 
information and pdb to match with.

(2) The Debug Directory does not contain COFF timestamp.

Using md5 seems very tentative. Please elaborate how to leverage both COFF 
contents and the existing GUID mentioned?


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D56229



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


[Lldb-commits] [PATCH] D56230: [gdb-remote] Use lldb's portable Host::GetEnvironment() instead of getenv

2019-01-04 Thread Hui Huang via Phabricator via lldb-commits
Hui added inline comments.



Comment at: source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp:1138
+  // Double quote the string.
+  ::snprintf(arg_cstr, sizeof(arg_cstr), "--log-channels=\"%s\"",
+ env_debugserver_log_channels.c_str());

This change is essential others seem not that necessary but nice to have in 
order to support multiple systems.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D56230



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


[Lldb-commits] [PATCH] D56229: [PECOFF] Implementation of ObjectFilePECOFF:: GetUUID()

2019-01-04 Thread Zachary Turner via Phabricator via lldb-commits
zturner added a comment.

In D56229#1346869 , @Hui wrote:

> Not quite sure but correct me if i am wrong.
>
> (1) I think the Debug Directory is optional for COFF if it does have debug 
> information and pdb to match with.
>
> (2) The Debug Directory does not contain COFF timestamp.
>
> Using md5 seems very tentative. Please elaborate how to leverage both COFF 
> contents and the existing GUID mentioned?


Well, I guess I would ask what you want to do with the GUID?  If you want to 
match it to a debug information file, then the Debug Directory is the correct 
way to do that, and using a hash of the file path will not even be helpful.

Another option would be to check for a debug directory of type 
`IMAGE_DEBUG_TYPE_REPRO`, and if that exists, then it means that the COFF 
timestamp is a hash of the binary, so it should be stable.

If neither of these is present, then I think we should simply return `false` 
from this function and not mislead the caller.  The caller might wish to use 
special logic if the function returns false that says "if I couldn't get a UUID 
from the file, then try hashing the path and doing some kind of lookup based on 
that", but I don't think that should be part of this function.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D56229



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


[Lldb-commits] [PATCH] D56230: [gdb-remote] Use lldb's portable Host::GetEnvironment() instead of getenv

2019-01-04 Thread Zachary Turner via Phabricator via lldb-commits
zturner added inline comments.



Comment at: source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp:1138
+  // Double quote the string.
+  ::snprintf(arg_cstr, sizeof(arg_cstr), "--log-channels=\"%s\"",
+ env_debugserver_log_channels.c_str());

Hui wrote:
> This change is essential others seem not that necessary but nice to have in 
> order to support multiple systems.
I would prefer to avoid using C-style formatting if possible.  LLVM has some 
nice formatting routines that are safer and easier to understand.

While we're here, perhaps we could change `char arg_cstr[PATH_MAX];` up at the 
top of this function to `std::string arg_str;`

Regardless, we can re-write this in a number of ways, such as:
```
arg_str = llvm::formatv("--log-channels = \"{0}\", 
env_debugserver_log_channels).str();
arg_str = (Twine("--log-channels = \"") + env_debugserver_log_channels + 
"\"").str();
arg_str = llvm::format("--log-channels = \"%s\"", env_debugserver_log_channels);
```

to get rid of this snprintf call.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D56230



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


[Lldb-commits] [PATCH] D56229: [PECOFF] Implementation of ObjectFilePECOFF:: GetUUID()

2019-01-04 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

The UUID that is used in ELF and Mach-o is designed to be something that is 
stable in a binary after it has been linked and should be the same before and 
after any kind of post production (stripping symbols, stripping section content 
to make a stand alone symbol file, etc). When someone types "target symbols add 
/path/to/symbol/file/a.out" we will grab its UUID and try to match it up with 
an existing object file.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D56229



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


[Lldb-commits] [lldb] r350446 - [Driver] Some more cleanup. NFC

2019-01-04 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Fri Jan  4 16:01:04 2019
New Revision: 350446

URL: http://llvm.org/viewvc/llvm-project?rev=350446&view=rev
Log:
[Driver] Some more cleanup. NFC

Modified:
lldb/trunk/tools/driver/Driver.cpp
lldb/trunk/tools/driver/Driver.h

Modified: lldb/trunk/tools/driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=350446&r1=350445&r2=350446&view=diff
==
--- lldb/trunk/tools/driver/Driver.cpp (original)
+++ lldb/trunk/tools/driver/Driver.cpp Fri Jan  4 16:01:04 2019
@@ -69,7 +69,7 @@ enum ID {
 #include "Options.inc"
 #undef PREFIX
 
-static const opt::OptTable::Info InfoTable[] = {
+const opt::OptTable::Info InfoTable[] = {
 #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,  
\
HELPTEXT, METAVAR, VALUES)  
\
   {
\
@@ -91,7 +91,7 @@ static void reset_stdin_termios();
 static bool g_old_stdin_termios_is_valid = false;
 static struct termios g_old_stdin_termios;
 
-static Driver *g_driver = NULL;
+static Driver *g_driver = nullptr;
 
 // In the Driver::MainLoop, we change the terminal settings.  This function is
 // added as an atexit handler to make sure we clean them up.
@@ -103,15 +103,14 @@ static void reset_stdin_termios() {
 }
 
 Driver::Driver()
-: SBBroadcaster("Driver"), m_debugger(SBDebugger::Create(false)),
-  m_option_data() {
+: SBBroadcaster("Driver"), m_debugger(SBDebugger::Create(false)) {
   // We want to be able to handle CTRL+D in the terminal to have it terminate
   // certain input
   m_debugger.SetCloseInputOnEOF(false);
   g_driver = this;
 }
 
-Driver::~Driver() { g_driver = NULL; }
+Driver::~Driver() { g_driver = nullptr; }
 
 void Driver::OptionData::AddLocalLLDBInit() {
   // If there is a local .lldbinit, add that to the list of things to be
@@ -165,13 +164,13 @@ void Driver::OptionData::AddInitialComma
 
 const char *Driver::GetFilename() const {
   if (m_option_data.m_args.empty())
-return NULL;
+return nullptr;
   return m_option_data.m_args.front().c_str();
 }
 
 const char *Driver::GetCrashLogFilename() const {
   if (m_option_data.m_crash_log.empty())
-return NULL;
+return nullptr;
   return m_option_data.m_crash_log.c_str();
 }
 
@@ -202,7 +201,7 @@ void Driver::WriteCommandsForSourcing(Co
   // file in the current working directory), only read it if
   // target.load-cwd-lldbinit is 'true'.
   if (command_entry.is_cwd_lldbinit_file_read) {
-SBStringList strlist = m_debugger.GetInternalVariableValue(
+SBStringList strlist = lldb::SBDebugger::GetInternalVariableValue(
 "target.load-cwd-lldbinit", m_debugger.GetInstanceName());
 if (strlist.GetSize() == 1 &&
 strcmp(strlist.GetStringAtIndex(0), "warn") == 0) {
@@ -229,7 +228,8 @@ void Driver::WriteCommandsForSourcing(Co
   }
   bool source_quietly =
   m_option_data.m_source_quietly || command_entry.source_quietly;
-  strm.Printf("command source -s %i '%s'\n", source_quietly, command);
+  strm.Printf("command source -s %i '%s'\n",
+  static_cast(source_quietly), command);
 } else
   strm.Printf("%s\n", command);
   }
@@ -296,11 +296,11 @@ SBError Driver::ProcessArgs(const opt::I
 auto arg_value = arg->getValue();
 SBFileSpec file(arg_value);
 if (file.Exists()) {
-  m_option_data.m_args.push_back(arg_value);
+  m_option_data.m_args.emplace_back(arg_value);
 } else if (file.ResolveExecutableLocation()) {
   char path[PATH_MAX];
   file.GetPath(path, sizeof(path));
-  m_option_data.m_args.push_back(path);
+  m_option_data.m_args.emplace_back(path);
 } else {
   error.SetErrorStringWithFormat(
   "file specified in --file (-f) option doesn't exist: '%s'",
@@ -311,7 +311,7 @@ SBError Driver::ProcessArgs(const opt::I
 
   if (auto *arg = args.getLastArg(OPT_arch)) {
 auto arg_value = arg->getValue();
-if (!m_debugger.SetDefaultArchitecture(arg_value)) {
+if (!lldb::SBDebugger::SetDefaultArchitecture(arg_value)) {
   error.SetErrorStringWithFormat(
   "invalid architecture in the -a or --arch option: '%s'", arg_value);
   return error;
@@ -439,14 +439,14 @@ SBError Driver::ProcessArgs(const opt::I
 // Any argument following -- is an argument for the inferior.
 if (auto *arg = args.getLastArgNoClaim(OPT_REM)) {
   for (auto value : arg->getValues())
-m_option_data.m_args.push_back(value);
+m_option_data.m_args.emplace_back(value);
 }
-  } else if (args.getLastArgNoClaim()) {
+  } else if (args.getLastArgNoClaim() != nullptr) {
 WithColor::warning() << "program arguments are ignored when attaching.\n";
   }
 
   if (m_option_data.m_print_version) {
-llvm::outs() << m_debugger.GetVer