[Lldb-commits] Inconsistency in cmakefile vs code

2019-07-10 Thread Carlo Kok via lldb-commits

In:
lldb\source\Plugins\Process\Windows\Common\CMakeLists.txt

these files are built based on the SYSTEM Architecture:

if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64")
  target_sources(lldbPluginProcessWindowsCommon PRIVATE
x64/RegisterContextWindows_x64.cpp)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "i?86|X86")
  target_sources(lldbPluginProcessWindowsCommon PRIVATE
x86/RegisterContextWindows_x86.cpp)
endif()


but later they're used based on the defines (which will the target arch, it's 
not uncommon to compile on x86_64 for i386, since the engine has to match 
exactly on Windows)
#if defined(_M_AMD64)
...
#if defined(_M_IX86)
...

Locally I've changed this to unconditionally include the files and use ifdefs 
in the context files. but that is less than ideal.
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r365615 - [CMake] Remove extra lldb-framework target

2019-07-10 Thread Stefan Granitz via lldb-commits
Author: stefan.graenitz
Date: Wed Jul 10 04:09:01 2019
New Revision: 365615

URL: http://llvm.org/viewvc/llvm-project?rev=365615&view=rev
Log:
[CMake] Remove extra lldb-framework target

Summary: The custom lldb-framework target was meant to encapsulate all build 
steps that LLDB.framework needs on top of the ordinaly liblldb. In the end all 
of it happens in post-build steps, so we can do the same with liblldb and cut 
down another source of confusion.

Reviewers: xiaobai, JDevlieghere

Reviewed By: xiaobai, JDevlieghere

Subscribers: mgorny, lldb-commits, #lldb

Tags: #lldb

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

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

Modified: lldb/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/CMakeLists.txt?rev=365615&r1=365614&r2=365615&view=diff
==
--- lldb/trunk/CMakeLists.txt (original)
+++ lldb/trunk/CMakeLists.txt Wed Jul 10 04:09:01 2019
@@ -203,10 +203,6 @@ if (NOT LLDB_DISABLE_PYTHON)
 # Ensure we do the python post-build step when building lldb.
 add_dependencies(lldb finish_swig)
 
-if(LLDB_BUILD_FRAMEWORK)
-  add_dependencies(lldb-framework finish_swig)
-endif()
-
 # Add a Post-Build Event to copy the custom Python DLL to the lldb 
binaries dir so that Windows can find it when launching
 # lldb.exe or any other executables that were linked with liblldb.
 if (WIN32 AND NOT "${PYTHON_DLL}" STREQUAL "")

Modified: lldb/trunk/cmake/modules/LLDBFramework.cmake
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/LLDBFramework.cmake?rev=365615&r1=365614&r2=365615&view=diff
==
--- lldb/trunk/cmake/modules/LLDBFramework.cmake (original)
+++ lldb/trunk/cmake/modules/LLDBFramework.cmake Wed Jul 10 04:09:01 2019
@@ -42,12 +42,8 @@ else()
 XCODE_ATTRIBUTE_MACOSX_DEPLOYMENT_TARGET "${MACOSX_DEPLOYMENT_TARGET}")
 endif()
 
-# Target to capture extra steps for a fully functional framework bundle.
-add_custom_target(lldb-framework ALL)
-add_dependencies(lldb-framework liblldb)
-
 # Apart from this one, CMake creates all required symlinks in the framework 
bundle.
-add_custom_command(TARGET lldb-framework POST_BUILD
+add_custom_command(TARGET liblldb POST_BUILD
   COMMAND ${CMAKE_COMMAND} -E create_symlink
   Versions/Current/Headers
   ${framework_target_dir}/LLDB.framework/Headers
@@ -79,12 +75,12 @@ foreach(header
 endforeach()
 
 # Wrap output in a target, so lldb-framework can depend on it.
-add_custom_target(lldb-framework-headers DEPENDS ${lldb_staged_headers})
-add_dependencies(lldb-framework lldb-framework-headers)
+add_custom_target(liblldb-resource-headers DEPENDS ${lldb_staged_headers})
+add_dependencies(liblldb liblldb-resource-headers)
 
 # At build time, copy the staged headers into the framework bundle (and do
 # some post-processing in-place).
-add_custom_command(TARGET lldb-framework-headers POST_BUILD
+add_custom_command(TARGET liblldb POST_BUILD
   COMMAND ${CMAKE_COMMAND} -E copy_directory ${lldb_header_staging} 
$/Headers
   COMMAND ${LLDB_SOURCE_DIR}/scripts/framework-header-fix.sh 
$/Headers ${LLDB_VERSION}
   COMMENT "LLDB.framework: copy framework headers"
@@ -93,7 +89,7 @@ add_custom_command(TARGET lldb-framework
 # Copy vendor-specific headers from clang (without staging).
 if(NOT IOS)
   if (TARGET clang-resource-headers)
-add_dependencies(lldb-framework clang-resource-headers)
+add_dependencies(liblldb clang-resource-headers)
 set(clang_resource_headers_dir 
$)
   else()
 # In standalone builds try the best possible guess
@@ -115,7 +111,7 @@ if(NOT IOS)
 endif()
   endif()
 
-  add_custom_command(TARGET lldb-framework POST_BUILD
+  add_custom_command(TARGET liblldb POST_BUILD
 COMMAND ${CMAKE_COMMAND} -E copy_directory
 ${clang_resource_headers_dir}
 $/Resources/Clang/include


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


[Lldb-commits] [lldb] r365616 - [CMake] Distribution builds for LLDB standalone

2019-07-10 Thread Stefan Granitz via lldb-commits
Author: stefan.graenitz
Date: Wed Jul 10 04:09:11 2019
New Revision: 365616

URL: http://llvm.org/viewvc/llvm-project?rev=365616&view=rev
Log:
[CMake] Distribution builds for LLDB standalone

Summary:
Enable `distribution` and `install-distribution` targets in LLDB standalone and 
pre-populate the cache accordingly on macOS.
Documentation for distribution builds is here: 
https://llvm.org/docs/BuildingADistribution.html

Reviewers: xiaobai, mgorny, JDevlieghere, davide, compnerd

Reviewed By: xiaobai, JDevlieghere

Subscribers: lldb-commits, #lldb

Tags: #lldb

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

Modified:
lldb/trunk/CMakeLists.txt
lldb/trunk/cmake/caches/Apple-lldb-macOS.cmake
lldb/trunk/cmake/modules/LLDBStandalone.cmake

Modified: lldb/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/CMakeLists.txt?rev=365616&r1=365615&r2=365616&view=diff
==
--- lldb/trunk/CMakeLists.txt (original)
+++ lldb/trunk/CMakeLists.txt Wed Jul 10 04:09:11 2019
@@ -216,3 +216,7 @@ if (NOT LLDB_DISABLE_PYTHON)
 COMMENT "Copying Python DLL to LLDB binaries directory.")
 endif ()
 endif ()
+
+if(LLDB_BUILT_STANDALONE)
+  llvm_distribution_add_targets()
+endif()

Modified: lldb/trunk/cmake/caches/Apple-lldb-macOS.cmake
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/caches/Apple-lldb-macOS.cmake?rev=365616&r1=365615&r2=365616&view=diff
==
--- lldb/trunk/cmake/caches/Apple-lldb-macOS.cmake (original)
+++ lldb/trunk/cmake/caches/Apple-lldb-macOS.cmake Wed Jul 10 04:09:11 2019
@@ -15,5 +15,13 @@ set(LLDB_FRAMEWORK_INSTALL_DIR /Applicat
 
 # Release builds may change these:
 set(CMAKE_OSX_DEPLOYMENT_TARGET 10.11 CACHE STRING "")
-set(LLDB_USE_SYSTEM_DEBUGSERVER ON CACHE BOOL "")
+set(LLDB_USE_SYSTEM_DEBUGSERVER OFF CACHE BOOL "")
 set(LLVM_EXTERNALIZE_DEBUGINFO OFF CACHE BOOL "")
+
+set(LLVM_DISTRIBUTION_COMPONENTS
+  lldb
+  liblldb
+  lldb-argdumper
+  darwin-debug
+  debugserver
+  CACHE STRING "")

Modified: lldb/trunk/cmake/modules/LLDBStandalone.cmake
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/LLDBStandalone.cmake?rev=365616&r1=365615&r2=365616&view=diff
==
--- lldb/trunk/cmake/modules/LLDBStandalone.cmake (original)
+++ lldb/trunk/cmake/modules/LLDBStandalone.cmake Wed Jul 10 04:09:11 2019
@@ -85,6 +85,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
   include(TableGen)
   include(HandleLLVMOptions)
   include(CheckAtomic)
+  include(LLVMDistributionSupport)
 
   if (PYTHON_EXECUTABLE STREQUAL "")
 set(Python_ADDITIONAL_VERSIONS 3.5 3.4 3.3 3.2 3.1 3.0 2.7 2.6 2.5)


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


[Lldb-commits] [lldb] r365617 - [CMake] `install-distribution` for LLDB on Darwin

2019-07-10 Thread Stefan Granitz via lldb-commits
Author: stefan.graenitz
Date: Wed Jul 10 04:09:29 2019
New Revision: 365617

URL: http://llvm.org/viewvc/llvm-project?rev=365617&view=rev
Log:
[CMake] `install-distribution` for LLDB on Darwin

Summary:
There's a number of requirements for installing LLDB on macOS that are 
untypical for LLVM projects: use special install-prefix for LLDB.framework, 
ship headers and tools as framework resources, patch RPATHs, externalize 
debug-info to dSYM's and strip binaries with `-ST`. For some of it we could use 
`llvm_externalize_debuginfo()` in the past and just add special cases. However, 
this complicates the code for all projects and comes with the major drawback, 
that it adds all these actions at build-time, i.e. dSYM creation and stripping 
take a lot of time and don't make sense at build-time.

LLVM's distribution mechanism 
(https://llvm.org/docs/BuildingADistribution.html) appears to be the natural 
candidate to install LLDB. Based on D64399 (enable in standalone builds), this 
patch integrates framework installation with the distribution mechanism and 
adds custom stripping flags and dSYM creation at install-time. Unlike the 
abandoned D61952, it leaves build-tree binaries untouched, so there's no 
side-effects on testing. Potential install-order issues must be handled 
externally.

Please let me know what you think, while I run a few more tests and add 
remarks+documentation.

Reviewers: xiaobai, compnerd, JDevlieghere, davide, labath, mgorny

Reviewed By: xiaobai, JDevlieghere

Subscribers: lldb-commits, #lldb

Tags: #lldb

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

Modified:
lldb/trunk/cmake/caches/Apple-lldb-macOS.cmake
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/tools/argdumper/CMakeLists.txt
lldb/trunk/tools/darwin-debug/CMakeLists.txt
lldb/trunk/tools/debugserver/source/CMakeLists.txt

Modified: lldb/trunk/cmake/caches/Apple-lldb-macOS.cmake
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/caches/Apple-lldb-macOS.cmake?rev=365617&r1=365616&r2=365617&view=diff
==
--- lldb/trunk/cmake/caches/Apple-lldb-macOS.cmake (original)
+++ lldb/trunk/cmake/caches/Apple-lldb-macOS.cmake Wed Jul 10 04:09:29 2019
@@ -13,6 +13,9 @@ set(CMAKE_INSTALL_PREFIX /Applications/X
 # CMAKE_INSTALL_PREFIX. In any case, DESTDIR will be an extra prefix.
 set(LLDB_FRAMEWORK_INSTALL_DIR 
/Applications/Xcode.app/Contents/SharedFrameworks CACHE STRING "")
 
+# DESTDIR will be an extra prefix
+set(LLDB_DEBUGINFO_INSTALL_PREFIX /debuginfo CACHE STRING "")
+
 # Release builds may change these:
 set(CMAKE_OSX_DEPLOYMENT_TARGET 10.11 CACHE STRING "")
 set(LLDB_USE_SYSTEM_DEBUGSERVER OFF CACHE BOOL "")

Modified: lldb/trunk/cmake/modules/AddLLDB.cmake
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/AddLLDB.cmake?rev=365617&r1=365616&r2=365617&view=diff
==
--- lldb/trunk/cmake/modules/AddLLDB.cmake (original)
+++ lldb/trunk/cmake/modules/AddLLDB.cmake Wed Jul 10 04:09:29 2019
@@ -3,7 +3,7 @@ function(add_lldb_library name)
   # MODULE;SHARED;STATIC library type and source files
   cmake_parse_arguments(PARAM
 "MODULE;SHARED;STATIC;OBJECT;PLUGIN"
-"ENTITLEMENTS"
+"INSTALL_PREFIX;ENTITLEMENTS"
 "EXTRA_CXXFLAGS;DEPENDS;LINK_LIBS;LINK_COMPONENTS"
 ${ARGN})
   llvm_process_sources(srcs ${PARAM_UNPARSED_ARGUMENTS})
@@ -58,38 +58,26 @@ function(add_lldb_library name)
   ${pass_ENTITLEMENTS}
   ${pass_NO_INSTALL_RPATH}
 )
+  endif()
 
-if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "liblldb")
-  if (PARAM_SHARED)
-if(${name} STREQUAL "liblldb" AND LLDB_BUILD_FRAMEWORK)
-  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 ${install_dir}
-  ARCHIVE DESTINATION ${install_dir})
-  else()
-install(TARGETS ${name}
-  COMPONENT ${name}
-  LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
-  ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
-  endif()
-  if (NOT CMAKE_CONFIGURATION_TYPES)
-add_llvm_install_targets(install-${name}
- DEPENDS ${name}
- COMPONENT ${name})
-  endif()
+  if(PARAM_SHARED)
+set(install_dest lib${LLVM_LIBDIR_SUFFIX})
+if(PARAM_INSTALL_PREFIX)
+  set(install_dest ${PARAM_INSTALL_PREFIX})
+endif()
+# RUNTIME is relevant for DLL platforms, FRAMEWORK for macOS
+   

[Lldb-commits] [PATCH] D64397: [CMake] Remove extra lldb-framework target

2019-07-10 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365615: [CMake] Remove extra lldb-framework target (authored 
by stefan.graenitz, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64397?vs=208632&id=208914#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64397

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


Index: lldb/trunk/cmake/modules/LLDBFramework.cmake
===
--- lldb/trunk/cmake/modules/LLDBFramework.cmake
+++ lldb/trunk/cmake/modules/LLDBFramework.cmake
@@ -42,12 +42,8 @@
 XCODE_ATTRIBUTE_MACOSX_DEPLOYMENT_TARGET "${MACOSX_DEPLOYMENT_TARGET}")
 endif()
 
-# Target to capture extra steps for a fully functional framework bundle.
-add_custom_target(lldb-framework ALL)
-add_dependencies(lldb-framework liblldb)
-
 # Apart from this one, CMake creates all required symlinks in the framework 
bundle.
-add_custom_command(TARGET lldb-framework POST_BUILD
+add_custom_command(TARGET liblldb POST_BUILD
   COMMAND ${CMAKE_COMMAND} -E create_symlink
   Versions/Current/Headers
   ${framework_target_dir}/LLDB.framework/Headers
@@ -79,12 +75,12 @@
 endforeach()
 
 # Wrap output in a target, so lldb-framework can depend on it.
-add_custom_target(lldb-framework-headers DEPENDS ${lldb_staged_headers})
-add_dependencies(lldb-framework lldb-framework-headers)
+add_custom_target(liblldb-resource-headers DEPENDS ${lldb_staged_headers})
+add_dependencies(liblldb liblldb-resource-headers)
 
 # At build time, copy the staged headers into the framework bundle (and do
 # some post-processing in-place).
-add_custom_command(TARGET lldb-framework-headers POST_BUILD
+add_custom_command(TARGET liblldb POST_BUILD
   COMMAND ${CMAKE_COMMAND} -E copy_directory ${lldb_header_staging} 
$/Headers
   COMMAND ${LLDB_SOURCE_DIR}/scripts/framework-header-fix.sh 
$/Headers ${LLDB_VERSION}
   COMMENT "LLDB.framework: copy framework headers"
@@ -93,7 +89,7 @@
 # Copy vendor-specific headers from clang (without staging).
 if(NOT IOS)
   if (TARGET clang-resource-headers)
-add_dependencies(lldb-framework clang-resource-headers)
+add_dependencies(liblldb clang-resource-headers)
 set(clang_resource_headers_dir 
$)
   else()
 # In standalone builds try the best possible guess
@@ -115,7 +111,7 @@
 endif()
   endif()
 
-  add_custom_command(TARGET lldb-framework POST_BUILD
+  add_custom_command(TARGET liblldb POST_BUILD
 COMMAND ${CMAKE_COMMAND} -E copy_directory
 ${clang_resource_headers_dir}
 $/Resources/Clang/include
Index: lldb/trunk/CMakeLists.txt
===
--- lldb/trunk/CMakeLists.txt
+++ lldb/trunk/CMakeLists.txt
@@ -203,10 +203,6 @@
 # Ensure we do the python post-build step when building lldb.
 add_dependencies(lldb finish_swig)
 
-if(LLDB_BUILD_FRAMEWORK)
-  add_dependencies(lldb-framework finish_swig)
-endif()
-
 # Add a Post-Build Event to copy the custom Python DLL to the lldb 
binaries dir so that Windows can find it when launching
 # lldb.exe or any other executables that were linked with liblldb.
 if (WIN32 AND NOT "${PYTHON_DLL}" STREQUAL "")


Index: lldb/trunk/cmake/modules/LLDBFramework.cmake
===
--- lldb/trunk/cmake/modules/LLDBFramework.cmake
+++ lldb/trunk/cmake/modules/LLDBFramework.cmake
@@ -42,12 +42,8 @@
 XCODE_ATTRIBUTE_MACOSX_DEPLOYMENT_TARGET "${MACOSX_DEPLOYMENT_TARGET}")
 endif()
 
-# Target to capture extra steps for a fully functional framework bundle.
-add_custom_target(lldb-framework ALL)
-add_dependencies(lldb-framework liblldb)
-
 # Apart from this one, CMake creates all required symlinks in the framework bundle.
-add_custom_command(TARGET lldb-framework POST_BUILD
+add_custom_command(TARGET liblldb POST_BUILD
   COMMAND ${CMAKE_COMMAND} -E create_symlink
   Versions/Current/Headers
   ${framework_target_dir}/LLDB.framework/Headers
@@ -79,12 +75,12 @@
 endforeach()
 
 # Wrap output in a target, so lldb-framework can depend on it.
-add_custom_target(lldb-framework-headers DEPENDS ${lldb_staged_headers})
-add_dependencies(lldb-framework lldb-framework-headers)
+add_custom_target(liblldb-resource-headers DEPENDS ${lldb_staged_headers})
+add_dependencies(liblldb liblldb-resource-headers)
 
 # At build time, copy the staged headers into the framework bundle (and do
 # some post-processing in-place).
-add_custom_command(TARGET lldb-framework-headers POST_BUILD
+add_custom_command(TARGET liblldb POST_BUILD
   COMMAND ${CMAKE_COMMAND} -E copy_directory ${lldb_header_staging} $/Headers
   COMMAND ${LLDB_SOURCE_DIR}/scripts/framework-header-fix.sh $/Headers ${LLDB_VERSION}
   COMMENT "L

[Lldb-commits] [PATCH] D64399: [CMake] Distribution builds for LLDB standalone

2019-07-10 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365616: [CMake] Distribution builds for LLDB standalone 
(authored by stefan.graenitz, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64399?vs=208695&id=208915#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64399

Files:
  lldb/trunk/CMakeLists.txt
  lldb/trunk/cmake/caches/Apple-lldb-macOS.cmake
  lldb/trunk/cmake/modules/LLDBStandalone.cmake


Index: lldb/trunk/cmake/modules/LLDBStandalone.cmake
===
--- lldb/trunk/cmake/modules/LLDBStandalone.cmake
+++ lldb/trunk/cmake/modules/LLDBStandalone.cmake
@@ -85,6 +85,7 @@
   include(TableGen)
   include(HandleLLVMOptions)
   include(CheckAtomic)
+  include(LLVMDistributionSupport)
 
   if (PYTHON_EXECUTABLE STREQUAL "")
 set(Python_ADDITIONAL_VERSIONS 3.5 3.4 3.3 3.2 3.1 3.0 2.7 2.6 2.5)
Index: lldb/trunk/cmake/caches/Apple-lldb-macOS.cmake
===
--- lldb/trunk/cmake/caches/Apple-lldb-macOS.cmake
+++ lldb/trunk/cmake/caches/Apple-lldb-macOS.cmake
@@ -15,5 +15,13 @@
 
 # Release builds may change these:
 set(CMAKE_OSX_DEPLOYMENT_TARGET 10.11 CACHE STRING "")
-set(LLDB_USE_SYSTEM_DEBUGSERVER ON CACHE BOOL "")
+set(LLDB_USE_SYSTEM_DEBUGSERVER OFF CACHE BOOL "")
 set(LLVM_EXTERNALIZE_DEBUGINFO OFF CACHE BOOL "")
+
+set(LLVM_DISTRIBUTION_COMPONENTS
+  lldb
+  liblldb
+  lldb-argdumper
+  darwin-debug
+  debugserver
+  CACHE STRING "")
Index: lldb/trunk/CMakeLists.txt
===
--- lldb/trunk/CMakeLists.txt
+++ lldb/trunk/CMakeLists.txt
@@ -216,3 +216,7 @@
 COMMENT "Copying Python DLL to LLDB binaries directory.")
 endif ()
 endif ()
+
+if(LLDB_BUILT_STANDALONE)
+  llvm_distribution_add_targets()
+endif()


Index: lldb/trunk/cmake/modules/LLDBStandalone.cmake
===
--- lldb/trunk/cmake/modules/LLDBStandalone.cmake
+++ lldb/trunk/cmake/modules/LLDBStandalone.cmake
@@ -85,6 +85,7 @@
   include(TableGen)
   include(HandleLLVMOptions)
   include(CheckAtomic)
+  include(LLVMDistributionSupport)
 
   if (PYTHON_EXECUTABLE STREQUAL "")
 set(Python_ADDITIONAL_VERSIONS 3.5 3.4 3.3 3.2 3.1 3.0 2.7 2.6 2.5)
Index: lldb/trunk/cmake/caches/Apple-lldb-macOS.cmake
===
--- lldb/trunk/cmake/caches/Apple-lldb-macOS.cmake
+++ lldb/trunk/cmake/caches/Apple-lldb-macOS.cmake
@@ -15,5 +15,13 @@
 
 # Release builds may change these:
 set(CMAKE_OSX_DEPLOYMENT_TARGET 10.11 CACHE STRING "")
-set(LLDB_USE_SYSTEM_DEBUGSERVER ON CACHE BOOL "")
+set(LLDB_USE_SYSTEM_DEBUGSERVER OFF CACHE BOOL "")
 set(LLVM_EXTERNALIZE_DEBUGINFO OFF CACHE BOOL "")
+
+set(LLVM_DISTRIBUTION_COMPONENTS
+  lldb
+  liblldb
+  lldb-argdumper
+  darwin-debug
+  debugserver
+  CACHE STRING "")
Index: lldb/trunk/CMakeLists.txt
===
--- lldb/trunk/CMakeLists.txt
+++ lldb/trunk/CMakeLists.txt
@@ -216,3 +216,7 @@
 COMMENT "Copying Python DLL to LLDB binaries directory.")
 endif ()
 endif ()
+
+if(LLDB_BUILT_STANDALONE)
+  llvm_distribution_add_targets()
+endif()
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D64408: [CMake] `install-distribution` for LLDB on Darwin

2019-07-10 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365617: [CMake] `install-distribution` for LLDB on Darwin 
(authored by stefan.graenitz, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64408?vs=208657&id=208916#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64408

Files:
  lldb/trunk/cmake/caches/Apple-lldb-macOS.cmake
  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/tools/argdumper/CMakeLists.txt
  lldb/trunk/tools/darwin-debug/CMakeLists.txt
  lldb/trunk/tools/debugserver/source/CMakeLists.txt

Index: lldb/trunk/cmake/modules/AddLLDB.cmake
===
--- lldb/trunk/cmake/modules/AddLLDB.cmake
+++ lldb/trunk/cmake/modules/AddLLDB.cmake
@@ -3,7 +3,7 @@
   # MODULE;SHARED;STATIC library type and source files
   cmake_parse_arguments(PARAM
 "MODULE;SHARED;STATIC;OBJECT;PLUGIN"
-"ENTITLEMENTS"
+"INSTALL_PREFIX;ENTITLEMENTS"
 "EXTRA_CXXFLAGS;DEPENDS;LINK_LIBS;LINK_COMPONENTS"
 ${ARGN})
   llvm_process_sources(srcs ${PARAM_UNPARSED_ARGUMENTS})
@@ -58,38 +58,26 @@
   ${pass_ENTITLEMENTS}
   ${pass_NO_INSTALL_RPATH}
 )
+  endif()
 
-if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "liblldb")
-  if (PARAM_SHARED)
-if(${name} STREQUAL "liblldb" AND LLDB_BUILD_FRAMEWORK)
-  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 ${install_dir}
-  ARCHIVE DESTINATION ${install_dir})
-  else()
-install(TARGETS ${name}
-  COMPONENT ${name}
-  LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
-  ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
-  endif()
-  if (NOT CMAKE_CONFIGURATION_TYPES)
-add_llvm_install_targets(install-${name}
- DEPENDS ${name}
- COMPONENT ${name})
-  endif()
+  if(PARAM_SHARED)
+set(install_dest lib${LLVM_LIBDIR_SUFFIX})
+if(PARAM_INSTALL_PREFIX)
+  set(install_dest ${PARAM_INSTALL_PREFIX})
+endif()
+# RUNTIME is relevant for DLL platforms, FRAMEWORK for macOS
+install(TARGETS ${name} COMPONENT ${name}
+  RUNTIME DESTINATION bin
+  LIBRARY DESTINATION ${install_dest}
+  ARCHIVE DESTINATION ${install_dest}
+  FRAMEWORK DESTINATION ${install_dest})
+if (NOT CMAKE_CONFIGURATION_TYPES)
+  add_llvm_install_targets(install-${name}
+  DEPENDS ${name}
+  COMPONENT ${name})
 endif()
   endif()
 
-
   # Hack: only some LLDB libraries depend on the clang autogenerated headers,
   # but it is simple enough to make all of LLDB depend on some of those
   # headers without negatively impacting much of anything.
@@ -110,7 +98,7 @@
 function(add_lldb_executable name)
   cmake_parse_arguments(ARG
 "GENERATE_INSTALL"
-"ENTITLEMENTS"
+"INSTALL_PREFIX;ENTITLEMENTS"
 "LINK_LIBS;LINK_COMPONENTS"
 ${ARGN}
 )
@@ -134,16 +122,22 @@
   set_target_properties(${name} PROPERTIES FOLDER "lldb executables")
 
   if(ARG_GENERATE_INSTALL)
-install(TARGETS ${name}
-COMPONENT ${name}
-RUNTIME DESTINATION bin)
+set(install_dest bin)
+if(ARG_INSTALL_PREFIX)
+  set(install_dest ${ARG_INSTALL_PREFIX})
+endif()
+install(TARGETS ${name} COMPONENT ${name}
+RUNTIME DESTINATION ${install_dest})
 if (NOT CMAKE_CONFIGURATION_TYPES)
   add_llvm_install_targets(install-${name}
DEPENDS ${name}
COMPONENT ${name})
 endif()
+if(APPLE AND ARG_INSTALL_PREFIX)
+  lldb_add_post_install_steps_darwin(${name} ${ARG_INSTALL_PREFIX})
+endif()
   endif()
-endfunction(add_lldb_executable)
+endfunction()
 
 
 macro(add_lldb_tool_subdirectory name)
@@ -151,7 +145,19 @@
 endmacro()
 
 function(add_lldb_tool name)
-  add_lldb_executable(${name} GENERATE_INSTALL ${ARGN})
+  cmake_parse_arguments(ARG "ADD_TO_FRAMEWORK" "" "" ${ARGN})
+  if(LLDB_BUILD_FRAMEWORK AND ARG_ADD_TO_FRAMEWORK)
+set(subdir LLDB.framework/Versions/${LLDB_FRAMEWORK_VERSION}/Resources)
+add_lldb_executable(${name}
+  GENERATE_INSTALL
+  INSTALL_PREFIX ${LLDB_FRAMEWORK_INSTALL_DIR}/${subdir}
+  ${ARG_UNPARSED_ARGUMENTS}
+)
+lldb_add_to_buildtree_lldb_framework(${name} ${subdir})
+return()
+  endif()

[Lldb-commits] [lldb] r365649 - [CMake] Add Apple-lldb-Linux.cmake cache

2019-07-10 Thread Stefan Granitz via lldb-commits
Author: stefan.graenitz
Date: Wed Jul 10 08:59:56 2019
New Revision: 365649

URL: http://llvm.org/viewvc/llvm-project?rev=365649&view=rev
Log:
[CMake] Add Apple-lldb-Linux.cmake cache

Added:
lldb/trunk/cmake/caches/Apple-lldb-Linux.cmake

Added: lldb/trunk/cmake/caches/Apple-lldb-Linux.cmake
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/caches/Apple-lldb-Linux.cmake?rev=365649&view=auto
==
--- lldb/trunk/cmake/caches/Apple-lldb-Linux.cmake (added)
+++ lldb/trunk/cmake/caches/Apple-lldb-Linux.cmake Wed Jul 10 08:59:56 2019
@@ -0,0 +1,8 @@
+include(${CMAKE_CURRENT_LIST_DIR}/Apple-lldb-base.cmake)
+
+set(LLVM_DISTRIBUTION_COMPONENTS
+  lldb
+  liblldb
+  lldb-argdumper
+  lldb-server
+  CACHE STRING "")


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


[Lldb-commits] [lldb] r365648 - [CMake] Polish Apple-lldb caches

2019-07-10 Thread Stefan Granitz via lldb-commits
Author: stefan.graenitz
Date: Wed Jul 10 08:59:50 2019
New Revision: 365648

URL: http://llvm.org/viewvc/llvm-project?rev=365648&view=rev
Log:
[CMake] Polish Apple-lldb caches

Modified:
lldb/trunk/cmake/caches/Apple-lldb-base.cmake
lldb/trunk/cmake/caches/Apple-lldb-macOS.cmake

Modified: lldb/trunk/cmake/caches/Apple-lldb-base.cmake
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/caches/Apple-lldb-base.cmake?rev=365648&r1=365647&r2=365648&view=diff
==
--- lldb/trunk/cmake/caches/Apple-lldb-base.cmake (original)
+++ lldb/trunk/cmake/caches/Apple-lldb-base.cmake Wed Jul 10 08:59:50 2019
@@ -7,9 +7,3 @@ set(LLVM_ENABLE_MODULES ON CACHE BOOL ""
 
 set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
 set(LIBCXX_ENABLE_STATIC OFF CACHE BOOL "")
-
-# Release builds set these explicitly:
-#set(LLDB_VERSION_MAJOR  CACHE STRING "")
-#set(LLDB_VERSION_MINOR 9 CACHE STRING "")
-#set(LLDB_VERSION_PATCH 9 CACHE STRING "")
-#set(LLDB_VERSION_SUFFIX git CACHE STRING "")

Modified: lldb/trunk/cmake/caches/Apple-lldb-macOS.cmake
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/caches/Apple-lldb-macOS.cmake?rev=365648&r1=365647&r2=365648&view=diff
==
--- lldb/trunk/cmake/caches/Apple-lldb-macOS.cmake (original)
+++ lldb/trunk/cmake/caches/Apple-lldb-macOS.cmake Wed Jul 10 08:59:50 2019
@@ -2,25 +2,21 @@ include(${CMAKE_CURRENT_LIST_DIR}/Apple-
 
 set(LLDB_BUILD_FRAMEWORK ON CACHE BOOL "")
 set(LLDB_NO_INSTALL_DEFAULT_RPATH ON CACHE BOOL "")
+set(CMAKE_OSX_DEPLOYMENT_TARGET 10.11 CACHE STRING "")
 
-# Set the install prefix to the default install location on the enduser 
machine.
-# If the location is not writeable on the build machine, specify another prefix
-# in the DESTDIR environment variable, e.g.: DESTDIR=/tmp ninja install
+# Default install location on the enduser machine. On the build machine, use 
the
+# DESTDIR environment variable in order to relocate the whole installation, 
e.g.:
+# `DESTDIR=/tmp ninja install-distribution`
 set(CMAKE_INSTALL_PREFIX /Applications/Xcode.app/Contents/Developer/usr CACHE 
STRING "")
 
-# Choose the install location for LLDB.framework so that it matches the
-# INSTALL_RPATH of the lldb driver. It's either absolute or relative to
-# CMAKE_INSTALL_PREFIX. In any case, DESTDIR will be an extra prefix.
+# Install location for LLDB.framework on the enduser machine.
+# DESTDIR will be an extra prefix.
 set(LLDB_FRAMEWORK_INSTALL_DIR 
/Applications/Xcode.app/Contents/SharedFrameworks CACHE STRING "")
 
-# DESTDIR will be an extra prefix
+# Install location for externalized debug-info on the build machine.
+# DESTDIR will be an extra prefix.
 set(LLDB_DEBUGINFO_INSTALL_PREFIX /debuginfo CACHE STRING "")
 
-# Release builds may change these:
-set(CMAKE_OSX_DEPLOYMENT_TARGET 10.11 CACHE STRING "")
-set(LLDB_USE_SYSTEM_DEBUGSERVER OFF CACHE BOOL "")
-set(LLVM_EXTERNALIZE_DEBUGINFO OFF CACHE BOOL "")
-
 set(LLVM_DISTRIBUTION_COMPONENTS
   lldb
   liblldb


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


[Lldb-commits] [lldb] r365650 - [CMake][NFC] Polish comments in AddLLDB.cmake

2019-07-10 Thread Stefan Granitz via lldb-commits
Author: stefan.graenitz
Date: Wed Jul 10 09:00:03 2019
New Revision: 365650

URL: http://llvm.org/viewvc/llvm-project?rev=365650&view=rev
Log:
[CMake][NFC] Polish comments in AddLLDB.cmake

Modified:
lldb/trunk/cmake/modules/AddLLDB.cmake

Modified: lldb/trunk/cmake/modules/AddLLDB.cmake
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/AddLLDB.cmake?rev=365650&r1=365649&r2=365650&view=diff
==
--- lldb/trunk/cmake/modules/AddLLDB.cmake (original)
+++ lldb/trunk/cmake/modules/AddLLDB.cmake Wed Jul 10 09:00:03 2019
@@ -176,18 +176,22 @@ function(lldb_append_link_flags target_n
   set_target_properties(${target_name} PROPERTIES LINK_FLAGS ${new_link_flags})
 endfunction()
 
+# The test suite relies on finding LLDB.framework binary resources in the
+# build-tree. Remove them before installing to avoid collisions with their
+# own install targets.
 function(lldb_add_to_buildtree_lldb_framework name subdir)
   # Destination for the copy in the build-tree. While the framework target may
   # not exist yet, it will exist when the generator expression gets expanded.
   set(copy_dest "$/../../../${subdir}")
 
-  # Copy into the framework's Resources directory for testing.
+  # Copy into the given subdirectory for testing.
   add_custom_command(TARGET ${name} POST_BUILD
 COMMAND ${CMAKE_COMMAND} -E copy $ ${copy_dest}
 COMMENT "Copy ${name} to ${copy_dest}"
   )
 endfunction()
 
+# Add extra install steps for dSYM creation and stripping for the given target.
 function(lldb_add_post_install_steps_darwin name install_prefix)
   if(NOT APPLE)
 message(WARNING "Darwin-specific functionality; not currently available on 
non-Apple platforms.")
@@ -219,7 +223,7 @@ function(lldb_add_post_install_steps_dar
 endif()
   endif()
 
-  # Generate dSYM in symroot
+  # Generate dSYM
   set(dsym_name ${output_name}.dSYM)
   if(is_framework)
 set(dsym_name ${output_name}.framework.dSYM)


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


[Lldb-commits] [lldb] r365651 - [CMake][NFC] Remove dead code lldb_append_link_flags() from AddLLDB.cmake

2019-07-10 Thread Stefan Granitz via lldb-commits
Author: stefan.graenitz
Date: Wed Jul 10 09:02:46 2019
New Revision: 365651

URL: http://llvm.org/viewvc/llvm-project?rev=365651&view=rev
Log:
[CMake][NFC] Remove dead code lldb_append_link_flags() from AddLLDB.cmake

Modified:
lldb/trunk/cmake/modules/AddLLDB.cmake

Modified: lldb/trunk/cmake/modules/AddLLDB.cmake
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/AddLLDB.cmake?rev=365651&r1=365650&r2=365651&view=diff
==
--- lldb/trunk/cmake/modules/AddLLDB.cmake (original)
+++ lldb/trunk/cmake/modules/AddLLDB.cmake Wed Jul 10 09:02:46 2019
@@ -160,22 +160,6 @@ function(add_lldb_tool name)
   add_lldb_executable(${name} GENERATE_INSTALL ${ARG_UNPARSED_ARGUMENTS})
 endfunction()
 
-# Support appending linker flags to an existing target.
-# This will preserve the existing linker flags on the
-# target, if there are any.
-function(lldb_append_link_flags target_name new_link_flags)
-  # Retrieve existing linker flags.
-  get_target_property(current_link_flags ${target_name} LINK_FLAGS)
-
-  # If we had any linker flags, include them first in the new linker flags.
-  if(current_link_flags)
-set(new_link_flags "${current_link_flags} ${new_link_flags}")
-  endif()
-
-  # Now set them onto the target.
-  set_target_properties(${target_name} PROPERTIES LINK_FLAGS ${new_link_flags})
-endfunction()
-
 # The test suite relies on finding LLDB.framework binary resources in the
 # build-tree. Remove them before installing to avoid collisions with their
 # own install targets.


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


[Lldb-commits] [lldb] r365654 - ObjectFileELF: Add support for gnu-style compressed sections

2019-07-10 Thread Pavel Labath via lldb-commits
Author: labath
Date: Wed Jul 10 09:10:43 2019
New Revision: 365654

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

With this style, a compressed section is indicated by a "z" in the section
name, instead of a section header flag. This patch consists of two small tweaks:
- use an llvm Decompressor method in order to properly detect compressed 
sections
- make sure we recognise .zdebug_info (and friends) when classifying section 
types.

Added:
lldb/trunk/lit/SymbolFile/DWARF/gnu-style-compression.cpp
Modified:
lldb/trunk/lit/Modules/ELF/compressed-sections.yaml
lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp

Modified: lldb/trunk/lit/Modules/ELF/compressed-sections.yaml
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/ELF/compressed-sections.yaml?rev=365654&r1=365653&r2=365654&view=diff
==
--- lldb/trunk/lit/Modules/ELF/compressed-sections.yaml (original)
+++ lldb/trunk/lit/Modules/ELF/compressed-sections.yaml Wed Jul 10 09:10:43 2019
@@ -16,14 +16,18 @@ Sections:
 Type:SHT_PROGBITS
 Flags:   [ SHF_COMPRESSED ]
 Content: deadbeefbaadf00d
+  - Name:.zdebug_info
+Type:SHT_PROGBITS
+Content: 5A4C49420008789c533070084828689809c802c1
 
 # CHECK: Name: .hello_elf
 # CHECK-NEXT: Type: regular
 # CHECK: VM address: 0
 # CHECK-NEXT: VM size: 0
 # CHECK-NEXT: File size: 28
-# CHECK-NEXT: Data:
+# CHECK-NEXT: Data: (
 # CHECK-NEXT: 20304050 60708090
+# CHECK-NEXT: )
 
 # CHECK: Name: .bogus
 # CHECK-NEXT: Type: regular
@@ -31,3 +35,10 @@ Sections:
 # CHECK-NEXT: VM size: 0
 # CHECK-NEXT: File size: 8
 # CHECK-NEXT: Data: ()
+
+# CHECK: Name: .zdebug_info
+# CHECK: dwarf-info
+# CHECK: File size: 28
+# CHECK: Data: (
+# CHECK-NEXT: 20304050 60708090
+# CHECK-NEXT: )

Added: lldb/trunk/lit/SymbolFile/DWARF/gnu-style-compression.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/DWARF/gnu-style-compression.cpp?rev=365654&view=auto
==
--- lldb/trunk/lit/SymbolFile/DWARF/gnu-style-compression.cpp (added)
+++ lldb/trunk/lit/SymbolFile/DWARF/gnu-style-compression.cpp Wed Jul 10 
09:10:43 2019
@@ -0,0 +1,14 @@
+// REQUIRES: zlib
+
+// RUN: %clang %s -target x86_64-pc-linux -g -gsplit-dwarf -c -o %t \
+// RUN:   -Wa,--compress-debug-sections=zlib-gnu
+// RUN: %lldb %t -o "target var s a" -b | FileCheck %s
+
+// CHECK: (const short) s = 47
+// CHECK: (const A) a = (a = 42)
+
+struct A {
+  long a = 42;
+};
+extern constexpr short s = 47;
+extern constexpr A a{};

Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp?rev=365654&r1=365653&r2=365654&view=diff
==
--- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Wed Jul 10 
09:10:43 2019
@@ -1674,38 +1674,40 @@ lldb::user_id_t ObjectFileELF::GetSectio
 }
 
 static SectionType GetSectionTypeFromName(llvm::StringRef Name) {
+  if (Name.consume_front(".debug_") || Name.consume_front(".zdebug_")) {
+return llvm::StringSwitch(Name)
+.Case("abbrev", eSectionTypeDWARFDebugAbbrev)
+.Case("abbrev.dwo", eSectionTypeDWARFDebugAbbrevDwo)
+.Case("addr", eSectionTypeDWARFDebugAddr)
+.Case("aranges", eSectionTypeDWARFDebugAranges)
+.Case("cu_index", eSectionTypeDWARFDebugCuIndex)
+.Case("frame", eSectionTypeDWARFDebugFrame)
+.Case("info", eSectionTypeDWARFDebugInfo)
+.Case("info.dwo", eSectionTypeDWARFDebugInfoDwo)
+.Cases("line", "line.dwo", eSectionTypeDWARFDebugLine)
+.Cases("line_str", "line_str.dwo", eSectionTypeDWARFDebugLineStr)
+.Cases("loc", "loc.dwo", eSectionTypeDWARFDebugLoc)
+.Cases("loclists", "loclists.dwo", eSectionTypeDWARFDebugLocLists)
+.Case("macinfo", eSectionTypeDWARFDebugMacInfo)
+.Cases("macro", "macro.dwo", eSectionTypeDWARFDebugMacro)
+.Case("names", eSectionTypeDWARFDebugNames)
+.Case("pubnames", eSectionTypeDWARFDebugPubNames)
+.Case("pubtypes", eSectionTypeDWARFDebugPubTypes)
+.Case("ranges", eSectionTypeDWARFDebugRanges)
+.Case("rnglists", eSectionTypeDWARFDebugRngLists)
+.Case("str", eSectionTypeDWARFDebugStr)
+.Case("str.dwo", eSectionTypeDWARFDebugStrDwo)
+.Case("str_offsets", eSectionTypeDWARFDebugStrOffsets)
+.Case("str_offsets.dwo", eSectionTypeDWARFDebugStrOffsetsDwo)
+.Case("types", eSectionTypeDWARFDebugTypes)
+.Case("types.dwo", eSectionTypeDWARFDebugTypesDwo)
+.Default(eSectionTypeOther);
+  }

[Lldb-commits] [lldb] r365665 - Options: Reduce code duplication

2019-07-10 Thread Pavel Labath via lldb-commits
Author: labath
Date: Wed Jul 10 10:09:47 2019
New Revision: 365665

URL: http://llvm.org/viewvc/llvm-project?rev=365665&view=rev
Log:
Options: Reduce code duplication

Summary:
While investigating breakages caused by D63110, I noticed we were
building the short options strings in three places. Some of them used a
leading ':' to detect missing arguments, and some didn't. This was the
indirect cause of D63110. Here, I move the common code into a utility
function.

Also, unify the code which appends the sentinel value at the end of the
option vector, and make it harder for users to pass invalid argc-argv
combos to getopt (another component of D63110) by having the
OptionParser::Parse function take a (Mutable)ArrayRef.

This unification has uncovered that we don't handle missing arguments
while building aliases, However, it's not possible to write an effective
test for this, as right now it is not possible to return an error out of
the alias parsing code (which means we are printing the generic
"failure" message even after this patch).

Reviewers: mgorny, aprantl

Reviewed By: mgorny

Subscribers: lldb-commits

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

Modified:
lldb/trunk/include/lldb/Host/OptionParser.h
lldb/trunk/source/Host/common/OptionParser.cpp
lldb/trunk/source/Interpreter/CommandAlias.cpp
lldb/trunk/source/Interpreter/Options.cpp

Modified: lldb/trunk/include/lldb/Host/OptionParser.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/OptionParser.h?rev=365665&r1=365664&r2=365665&view=diff
==
--- lldb/trunk/include/lldb/Host/OptionParser.h (original)
+++ lldb/trunk/include/lldb/Host/OptionParser.h Wed Jul 10 10:09:47 2019
@@ -13,6 +13,7 @@
 #include 
 
 #include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/ArrayRef.h"
 
 struct option;
 
@@ -37,8 +38,11 @@ public:
 
   static void EnableError(bool error);
 
-  static int Parse(int argc, char *const argv[], llvm::StringRef optstring,
-   const Option *longopts, int *longindex);
+  /// Argv must be an argument vector "as passed to main", i.e. terminated with
+  /// a nullptr.
+  static int Parse(llvm::MutableArrayRef argv,
+   llvm::StringRef optstring, const Option *longopts,
+   int *longindex);
 
   static char *GetOptionArgument();
   static int GetOptionIndex();

Modified: lldb/trunk/source/Host/common/OptionParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/OptionParser.cpp?rev=365665&r1=365664&r2=365665&view=diff
==
--- lldb/trunk/source/Host/common/OptionParser.cpp (original)
+++ lldb/trunk/source/Host/common/OptionParser.cpp Wed Jul 10 10:09:47 2019
@@ -27,8 +27,9 @@ void OptionParser::Prepare(std::unique_l
 
 void OptionParser::EnableError(bool error) { opterr = error ? 1 : 0; }
 
-int OptionParser::Parse(int argc, char *const argv[], llvm::StringRef 
optstring,
-const Option *longopts, int *longindex) {
+int OptionParser::Parse(llvm::MutableArrayRef argv,
+llvm::StringRef optstring, const Option *longopts,
+int *longindex) {
   std::vector opts;
   while (longopts->definition != nullptr) {
 option opt;
@@ -41,7 +42,8 @@ int OptionParser::Parse(int argc, char *
   }
   opts.push_back(option());
   std::string opt_cstr = optstring;
-  return getopt_long_only(argc, argv, opt_cstr.c_str(), &opts[0], longindex);
+  return getopt_long_only(argv.size() - 1, argv.data(), opt_cstr.c_str(),
+  &opts[0], longindex);
 }
 
 char *OptionParser::GetOptionArgument() { return optarg; }

Modified: lldb/trunk/source/Interpreter/CommandAlias.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandAlias.cpp?rev=365665&r1=365664&r2=365665&view=diff
==
--- lldb/trunk/source/Interpreter/CommandAlias.cpp (original)
+++ lldb/trunk/source/Interpreter/CommandAlias.cpp Wed Jul 10 10:09:47 2019
@@ -30,6 +30,8 @@ static bool ProcessAliasOptionsArgs(lldb
 
   Args args(options_args);
   std::string options_string(options_args);
+  // TODO: Find a way to propagate errors in this CommandReturnObject up the
+  // stack.
   CommandReturnObject result;
   // Check to see if the command being aliased can take any command options.
   Options *options = cmd_obj_sp->GetOptions();

Modified: lldb/trunk/source/Interpreter/Options.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Options.cpp?rev=365665&r1=365664&r2=365665&view=diff
==
--- lldb/trunk/source/Interpreter/Options.cpp (original)
+++ lldb/trunk/source/Interpreter/Options.cpp Wed Jul 10 10:09:47 2019
@@ -930,6 +930,7 @@ static std::vector GetArgvForPar

[Lldb-commits] [PATCH] D63770: Options: Reduce code duplication

2019-07-10 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365665: Options: Reduce code duplication (authored by 
labath, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D63770

Files:
  lldb/trunk/include/lldb/Host/OptionParser.h
  lldb/trunk/source/Host/common/OptionParser.cpp
  lldb/trunk/source/Interpreter/CommandAlias.cpp
  lldb/trunk/source/Interpreter/Options.cpp

Index: lldb/trunk/source/Interpreter/CommandAlias.cpp
===
--- lldb/trunk/source/Interpreter/CommandAlias.cpp
+++ lldb/trunk/source/Interpreter/CommandAlias.cpp
@@ -30,6 +30,8 @@
 
   Args args(options_args);
   std::string options_string(options_args);
+  // TODO: Find a way to propagate errors in this CommandReturnObject up the
+  // stack.
   CommandReturnObject result;
   // Check to see if the command being aliased can take any command options.
   Options *options = cmd_obj_sp->GetOptions();
Index: lldb/trunk/source/Interpreter/Options.cpp
===
--- lldb/trunk/source/Interpreter/Options.cpp
+++ lldb/trunk/source/Interpreter/Options.cpp
@@ -930,6 +930,7 @@
   result.push_back(const_cast(""));
   for (const Args::ArgEntry &entry : args)
 result.push_back(const_cast(entry.c_str()));
+  result.push_back(nullptr);
   return result;
 }
 
@@ -972,19 +973,15 @@
   return size_t(-1);
 }
 
-llvm::Expected Options::ParseAlias(const Args &args,
- OptionArgVector *option_arg_vector,
- std::string &input_line) {
-  StreamString sstr;
-  int i;
-  Option *long_options = GetLongOptions();
+static std::string BuildShortOptions(const Option *long_options) {
+  std::string storage;
+  llvm::raw_string_ostream sstr(storage);
 
-  if (long_options == nullptr) {
-return llvm::make_error("Invalid long options",
-   llvm::inconvertibleErrorCode());
-  }
+  // Leading : tells getopt to return a : for a missing option argument AND to
+  // suppress error messages.
+  sstr << ":";
 
-  for (i = 0; long_options[i].definition != nullptr; ++i) {
+  for (size_t i = 0; long_options[i].definition != nullptr; ++i) {
 if (long_options[i].flag == nullptr) {
   sstr << (char)long_options[i].val;
   switch (long_options[i].definition->option_has_arg) {
@@ -1000,6 +997,20 @@
   }
 }
   }
+  return std::move(sstr.str());
+}
+
+llvm::Expected Options::ParseAlias(const Args &args,
+ OptionArgVector *option_arg_vector,
+ std::string &input_line) {
+  Option *long_options = GetLongOptions();
+
+  if (long_options == nullptr) {
+return llvm::make_error("Invalid long options",
+   llvm::inconvertibleErrorCode());
+  }
+
+  std::string short_options = BuildShortOptions(long_options);
 
   Args args_copy = args;
   std::vector argv = GetArgvForParsing(args);
@@ -1009,8 +1020,13 @@
   int val;
   while (true) {
 int long_options_index = -1;
-val = OptionParser::Parse(argv.size(), &*argv.begin(), sstr.GetString(),
-  long_options, &long_options_index);
+val = OptionParser::Parse(argv, short_options, long_options,
+  &long_options_index);
+
+if (val == ':') {
+  return llvm::createStringError(llvm::inconvertibleErrorCode(),
+ "last option requires an argument");
+}
 
 if (val == -1)
   break;
@@ -1116,33 +1132,13 @@
 OptionElementVector Options::ParseForCompletion(const Args &args,
 uint32_t cursor_index) {
   OptionElementVector option_element_vector;
-  StreamString sstr;
   Option *long_options = GetLongOptions();
   option_element_vector.clear();
 
   if (long_options == nullptr)
 return option_element_vector;
 
-  // Leading : tells getopt to return a : for a missing option argument AND to
-  // suppress error messages.
-
-  sstr << ":";
-  for (int i = 0; long_options[i].definition != nullptr; ++i) {
-if (long_options[i].flag == nullptr) {
-  sstr << (char)long_options[i].val;
-  switch (long_options[i].definition->option_has_arg) {
-  default:
-  case OptionParser::eNoArgument:
-break;
-  case OptionParser::eRequiredArgument:
-sstr << ":";
-break;
-  case OptionParser::eOptionalArgument:
-sstr << "::";
-break;
-  }
-}
-  }
+  std::string short_options = BuildShortOptions(long_options);
 
   std::unique_lock lock;
   OptionParser::Prepare(lock);
@@ -1153,10 +1149,6 @@
 
   std::vector dummy_vec = GetArgvForParsing(args);
 
-  // I stick an element on

[Lldb-commits] [PATCH] D64194: [lldb] Fix crash due to unicode characters and dollars in variable names.

2019-07-10 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor marked an inline comment as done.
teemperor added inline comments.



Comment at: 
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp:223
+// Returns true if this is the last token we get from the lexer.
+exit = lex.LexFromRawLexer(token);
+

JDevlieghere wrote:
> Can we write this as `while(!lex.LexFromRawLexer(token))`?
LexFromRawLexer seems to return `true` when the current result is the last 
token (but still a valid token), so I think no :(


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

https://reviews.llvm.org/D64194



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


[Lldb-commits] [PATCH] D62503: Add ReadCStringFromMemory for faster string reads

2019-07-10 Thread António Afonso via Phabricator via lldb-commits
aadsm added a comment.

@jankratochvil I'm planning to follow Pavel's plan now that the new setting has 
landed and finally got some time for this.

It will be:

- Revert rL364751  (which is a revert itself)
- Revert 9c10b620c061 
 (will 
re-apply this one)
- Land D64013  once it's approved (which I 
just realized it hasn't yet, will ping it)

Does it sound good to you?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D62503



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


[Lldb-commits] [PATCH] D64013: Correctly use GetLoadedModuleList to take advantage of libraries-svr4

2019-07-10 Thread António Afonso via Phabricator via lldb-commits
aadsm added a comment.

@labath can I ask for a re-review on this one please? :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64013



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


[Lldb-commits] [lldb] r365677 - [scripts] Remove the unused 'shush' script.

2019-07-10 Thread Davide Italiano via lldb-commits
Author: davide
Date: Wed Jul 10 11:13:46 2019
New Revision: 365677

URL: http://llvm.org/viewvc/llvm-project?rev=365677&view=rev
Log:
[scripts] Remove the unused 'shush' script.

There are pre-made utilities doing this. If somebody finds an
use for it and wants to resurrect, I would recommend to revise
the error messages.

Removed:
lldb/trunk/scripts/shush

Removed: lldb/trunk/scripts/shush
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/shush?rev=365676&view=auto
==
--- lldb/trunk/scripts/shush (original)
+++ lldb/trunk/scripts/shush (removed)
@@ -1,64 +0,0 @@
-#!/usr/bin/env python
-
-import sys
-import subprocess
-import tempfile
-import time
-import os
-
-class Printer(object):
-def __init__(self):
-pass
-
-@classmethod
-def write(self, message):
-sys.stdout.write("%s\n" % message)
-sys.stdout.flush()
-
-def command():
-return ' '.join(sys.argv[1:])
-
-def tmpfile(suffix=None):
-if suffix is None: suffix = ""
-return tempfile.NamedTemporaryFile(prefix='shush', suffix=suffix, 
delete=False)
-
-def launch(cmd="/bin/ls", sin=None, sout=None):
-class Process(object):
-def __init__(self, p, i, o):
-self.p = p
-self.stdin = i
-self.stdout = o
-
-def poll(self):
-self.returncode = self.p.poll()
-return self.returncode
-
-return Process(subprocess.Popen(cmd, shell=True, stdin=sin, stdout=sout, 
stderr=subprocess.STDOUT), sin, sout)
-
-def wait(p):
-while p.poll() is None:
-time.sleep(5)
-Printer.write("still running @ %s..." % time.strftime("%Y%m%d%H%M%S")) 
# fool Xcode into thinking that I am doing something...
-return p
-
-def exit(p):
-code = p.returncode
-if code != 0:
-Printer.write("error: sucks to be you")
-Printer.write("error: shushed process failed - go check %s for 
details" % (p.stdout.name))
-else:
-Printer.write("shush: success - output is going away")
-try:
-os.remove(p.stdout.name)
-finally:
-pass
-sys.exit(code)
-
-def main():
-out = tmpfile()
-cmd = command()
-Printer.write("shush: launching '%s' - std{out|err}=%s" % (cmd, out.name))
-p = wait(launch(cmd=cmd, sout=out))
-exit(p)
-
-main()


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


[Lldb-commits] [PATCH] D64194: [lldb] Fix crash due to unicode characters and dollars in variable names.

2019-07-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.

LGTM


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

https://reviews.llvm.org/D64194



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


[Lldb-commits] [PATCH] D62503: Add ReadCStringFromMemory for faster string reads

2019-07-10 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

In D62503#1578934 , @aadsm wrote:

> Does it sound good to you?


Yes, that sounds great, thanks. Sorry I am not participating these days.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D62503



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


[Lldb-commits] [PATCH] D62931: [lldb-server] Add setting to force 'g' packet use

2019-07-10 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added inline comments.



Comment at: lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h:103
   lldb_private::LazyBool m_associated_with_libdispatch_queue;
+  bool m_use_g_packet;
 

Not a big deal, but might be easier to store this in ProcessGDBRemote and 
access it there?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62931



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


[Lldb-commits] [PATCH] D64444: Add Python 3.6 and 3.7 to the version list

2019-07-10 Thread Christian Biesinger via Phabricator via lldb-commits
cbiesinger added a comment.

Thanks Greg! I'm not a committer -- how do I get this committed?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D6



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


[Lldb-commits] [PATCH] D64373: Don't use PyInt on Python 3

2019-07-10 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

ok, so do you want to abandon this patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64373



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


[Lldb-commits] [PATCH] D64373: Don't use PyInt on Python 3

2019-07-10 Thread Christian Biesinger via Phabricator via lldb-commits
cbiesinger added a comment.

Yeah. (I thought I did? I'm not super familiar with this interface)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64373



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


[Lldb-commits] [lldb] r365688 - Add Python 3.6 and 3.7 to the version list

2019-07-10 Thread Nico Weber via lldb-commits
Author: nico
Date: Wed Jul 10 12:18:38 2019
New Revision: 365688

URL: http://llvm.org/viewvc/llvm-project?rev=365688&view=rev
Log:
Add Python 3.6 and 3.7 to the version list

Python 3.6 and 3.7 have been released.

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

Patch from Christian Biesinger !

Modified:
lldb/trunk/cmake/modules/LLDBStandalone.cmake

Modified: lldb/trunk/cmake/modules/LLDBStandalone.cmake
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/LLDBStandalone.cmake?rev=365688&r1=365687&r2=365688&view=diff
==
--- lldb/trunk/cmake/modules/LLDBStandalone.cmake (original)
+++ lldb/trunk/cmake/modules/LLDBStandalone.cmake Wed Jul 10 12:18:38 2019
@@ -88,7 +88,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
   include(LLVMDistributionSupport)
 
   if (PYTHON_EXECUTABLE STREQUAL "")
-set(Python_ADDITIONAL_VERSIONS 3.5 3.4 3.3 3.2 3.1 3.0 2.7 2.6 2.5)
+set(Python_ADDITIONAL_VERSIONS 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0 2.7 2.6 2.5)
 include(FindPythonInterp)
 if( NOT PYTHONINTERP_FOUND )
   message(FATAL_ERROR


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


[Lldb-commits] [PATCH] D64444: Add Python 3.6 and 3.7 to the version list

2019-07-10 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365688: Add Python 3.6 and 3.7 to the version list (authored 
by nico, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D6?vs=208791&id=209043#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D6

Files:
  lldb/trunk/cmake/modules/LLDBStandalone.cmake


Index: lldb/trunk/cmake/modules/LLDBStandalone.cmake
===
--- lldb/trunk/cmake/modules/LLDBStandalone.cmake
+++ lldb/trunk/cmake/modules/LLDBStandalone.cmake
@@ -88,7 +88,7 @@
   include(LLVMDistributionSupport)
 
   if (PYTHON_EXECUTABLE STREQUAL "")
-set(Python_ADDITIONAL_VERSIONS 3.5 3.4 3.3 3.2 3.1 3.0 2.7 2.6 2.5)
+set(Python_ADDITIONAL_VERSIONS 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0 2.7 2.6 2.5)
 include(FindPythonInterp)
 if( NOT PYTHONINTERP_FOUND )
   message(FATAL_ERROR


Index: lldb/trunk/cmake/modules/LLDBStandalone.cmake
===
--- lldb/trunk/cmake/modules/LLDBStandalone.cmake
+++ lldb/trunk/cmake/modules/LLDBStandalone.cmake
@@ -88,7 +88,7 @@
   include(LLVMDistributionSupport)
 
   if (PYTHON_EXECUTABLE STREQUAL "")
-set(Python_ADDITIONAL_VERSIONS 3.5 3.4 3.3 3.2 3.1 3.0 2.7 2.6 2.5)
+set(Python_ADDITIONAL_VERSIONS 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0 2.7 2.6 2.5)
 include(FindPythonInterp)
 if( NOT PYTHONINTERP_FOUND )
   message(FATAL_ERROR
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D64373: Don't use PyInt on Python 3

2019-07-10 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

never mind, I missed that you had!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64373



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


[Lldb-commits] [lldb] r365696 - [Expression] IR Instrumenters should have a UtilityFunction

2019-07-10 Thread Alex Langford via lldb-commits
Author: xiaobai
Date: Wed Jul 10 13:41:36 2019
New Revision: 365696

URL: http://llvm.org/viewvc/llvm-project?rev=365696&view=rev
Log:
[Expression] IR Instrumenters should have a UtilityFunction

Right now, IR Instrumenters take a DynamicCheckerFunctions object which
has all the UtilityFunctions used to instrument IR for expressions.
However, each Instrumenter (in practice) uses exactly one
UtilityFunction, so let's change the abstraction.

Modified:
lldb/trunk/include/lldb/Expression/IRDynamicChecks.h
lldb/trunk/source/Expression/IRDynamicChecks.cpp

Modified: lldb/trunk/include/lldb/Expression/IRDynamicChecks.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/IRDynamicChecks.h?rev=365696&r1=365695&r2=365696&view=diff
==
--- lldb/trunk/include/lldb/Expression/IRDynamicChecks.h (original)
+++ lldb/trunk/include/lldb/Expression/IRDynamicChecks.h Wed Jul 10 13:41:36 
2019
@@ -1,5 +1,4 @@
-//===-- IRDynamicChecks.h -*- C++
-//-*-===//
+//===-- IRDynamicChecks.h ---*- C++ 
-*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -68,8 +67,8 @@ public:
 
   bool DoCheckersExplainStop(lldb::addr_t addr, Stream &message);
 
-  std::unique_ptr m_valid_pointer_check;
-  std::unique_ptr m_objc_object_check;
+  std::shared_ptr m_valid_pointer_check;
+  std::shared_ptr m_objc_object_check;
 };
 
 /// \class IRDynamicChecks IRDynamicChecks.h

Modified: lldb/trunk/source/Expression/IRDynamicChecks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRDynamicChecks.cpp?rev=365696&r1=365695&r2=365696&view=diff
==
--- lldb/trunk/source/Expression/IRDynamicChecks.cpp (original)
+++ lldb/trunk/source/Expression/IRDynamicChecks.cpp Wed Jul 10 13:41:36 2019
@@ -134,8 +134,9 @@ public:
   ///
   /// \param[in] module
   /// The module being instrumented.
-  Instrumenter(llvm::Module &module, DynamicCheckerFunctions 
&checker_functions)
-  : m_module(module), m_checker_functions(checker_functions),
+  Instrumenter(llvm::Module &module,
+   std::shared_ptr checker_function)
+  : m_module(module), m_checker_function(checker_function),
 m_i8ptr_ty(nullptr), m_intptr_ty(nullptr) {}
 
   virtual ~Instrumenter() = default;
@@ -296,8 +297,8 @@ protected:
 
   InstVector m_to_instrument; ///< List of instructions the inspector found
   llvm::Module &m_module; ///< The module which is being instrumented
-  DynamicCheckerFunctions
-  &m_checker_functions; ///< The dynamic checker functions for the process
+  std::shared_ptr
+  m_checker_function; ///< The dynamic checker function for the process
 
 private:
   PointerType *m_i8ptr_ty;
@@ -307,8 +308,8 @@ private:
 class ValidPointerChecker : public Instrumenter {
 public:
   ValidPointerChecker(llvm::Module &module,
-  DynamicCheckerFunctions &checker_functions)
-  : Instrumenter(module, checker_functions),
+  std::shared_ptr checker_function)
+  : Instrumenter(module, checker_function),
 m_valid_pointer_check_func(nullptr) {}
 
   ~ValidPointerChecker() override = default;
@@ -322,8 +323,8 @@ protected:
   PrintValue(inst).c_str());
 
 if (!m_valid_pointer_check_func)
-  m_valid_pointer_check_func = BuildPointerValidatorFunc(
-  m_checker_functions.m_valid_pointer_check->StartAddress());
+  m_valid_pointer_check_func =
+  BuildPointerValidatorFunc(m_checker_function->StartAddress());
 
 llvm::Value *dereferenced_ptr = nullptr;
 
@@ -366,8 +367,8 @@ private:
 class ObjcObjectChecker : public Instrumenter {
 public:
   ObjcObjectChecker(llvm::Module &module,
-DynamicCheckerFunctions &checker_functions)
-  : Instrumenter(module, checker_functions),
+std::shared_ptr checker_function)
+  : Instrumenter(module, checker_function),
 m_objc_object_check_func(nullptr) {}
 
   ~ObjcObjectChecker() override = default;
@@ -391,8 +392,8 @@ protected:
 // InspectInstruction wouldn't have registered it
 
 if (!m_objc_object_check_func)
-  m_objc_object_check_func = BuildObjectCheckerFunc(
-  m_checker_functions.m_objc_object_check->StartAddress());
+  m_objc_object_check_func =
+  BuildObjectCheckerFunc(m_checker_function->StartAddress());
 
 // id objc_msgSend(id theReceiver, SEL theSelector, ...)
 
@@ -552,7 +553,7 @@ bool IRDynamicChecks::runOnModule(llvm::
   }
 
   if (m_checker_functions.m_valid_pointer_check) {
-ValidPointerChecker vpc(M, m_checker_functions);
+ValidPointerChecker vpc(M, m_checker_functions.m_valid_pointer_check);
 
 if (!vpc.Ins

[Lldb-commits] [PATCH] D64013: Correctly use GetLoadedModuleList to take advantage of libraries-svr4

2019-07-10 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Looks mostly good. Just a couple of style comments.




Comment at: 
lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp:185-207
+  if (
+  // When the previous and current states are consistent this is the first
+  // time we have been asked to update.  Just take a snapshot of the
+  // currently loaded modules.
+  (m_previous.state == eConsistent && m_current.state == eConsistent) ||
+  // If we are about to add or remove a shared object clear out the current
+  // state and take a snapshot of the currently loaded images.

This logic is pretty hard to follow. I'd suggest trying to structure as some 
switch statements. Something like:
```
switch(current_state) {
case Consistent:
  switch (previous_state) {
case Consistent: return TakeSnapshot;
case Add: return Add;
case Remove: return Remove;
  }
case Add: case Remove:
  @#%@#%!@%
}
```



Comment at: lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp:240
+bool DYLDRendezvous::UpdateSOEntries() {
+  auto action = GetAction();
 

Use a switch here.



Comment at: lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h:265
+  /// state
+  enum RendezvousAction GetAction() const;
 };

We don't usually use the enum tag here.



Comment at: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp:2731
   if (addr == LLDB_INVALID_ADDRESS) {
-LoadedModuleInfoList list;
-if (GetLoadedModuleList(list).Success())
-  addr = list.m_link_map;
+llvm::Expected list = GetLoadedModuleList();
+if (list)

You'll need to somehow handle the case when GetLoadedModuleList fails (maybe by 
logging the error).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64013



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


[Lldb-commits] [lldb] r365698 - [lldb] Fix handling of dollar characters in expr command

2019-07-10 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Wed Jul 10 14:04:01 2019
New Revision: 365698

URL: http://llvm.org/viewvc/llvm-project?rev=365698&view=rev
Log:
[lldb] Fix handling of dollar characters in expr command

Added:

lldb/trunk/packages/Python/lldbsuite/test/expression_command/dollar-in-variable/

lldb/trunk/packages/Python/lldbsuite/test/expression_command/dollar-in-variable/Makefile

lldb/trunk/packages/Python/lldbsuite/test/expression_command/dollar-in-variable/TestDollarInVariable.py

lldb/trunk/packages/Python/lldbsuite/test/expression_command/dollar-in-variable/main.c

lldb/trunk/packages/Python/lldbsuite/test/expression_command/unicode-in-variable/

lldb/trunk/packages/Python/lldbsuite/test/expression_command/unicode-in-variable/Makefile

lldb/trunk/packages/Python/lldbsuite/test/expression_command/unicode-in-variable/TestUnicodeInVariable.py

lldb/trunk/packages/Python/lldbsuite/test/expression_command/unicode-in-variable/main.cpp
Modified:

lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp

Added: 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/dollar-in-variable/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/dollar-in-variable/Makefile?rev=365698&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/dollar-in-variable/Makefile
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/dollar-in-variable/Makefile
 Wed Jul 10 14:04:01 2019
@@ -0,0 +1,3 @@
+LEVEL = ../../make
+C_SOURCES := main.c
+include $(LEVEL)/Makefile.rules

Added: 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/dollar-in-variable/TestDollarInVariable.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/dollar-in-variable/TestDollarInVariable.py?rev=365698&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/dollar-in-variable/TestDollarInVariable.py
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/dollar-in-variable/TestDollarInVariable.py
 Wed Jul 10 14:04:01 2019
@@ -0,0 +1,4 @@
+from lldbsuite.test import lldbinline
+from lldbsuite.test import decorators
+
+lldbinline.MakeInlineTest(__file__, globals(), None)

Added: 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/dollar-in-variable/main.c
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/dollar-in-variable/main.c?rev=365698&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/dollar-in-variable/main.c
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/dollar-in-variable/main.c
 Wed Jul 10 14:04:01 2019
@@ -0,0 +1,21 @@
+// Make sure we correctly handle $ in variable names.
+
+int main() {
+  // Some variables that might conflict with our variables below.
+  int __lldb_expr_result = 2;
+  int $$foo = 1;
+  int R0 = 2;
+
+  // Some variables with dollar signs that should work (and shadow
+  // any built-in LLDB variables).
+  int $__lldb_expr_result = 11;
+  int $foo = 12;
+  int $R0 = 13;
+  int $0 = 14;
+
+  //%self.expect("expr $__lldb_expr_result", substrs=['(int) $0 = 11'])
+  //%self.expect("expr $foo", substrs=['(int)', ' = 12'])
+  //%self.expect("expr $R0", substrs=['(int)', ' = 13'])
+  //%self.expect("expr int $foo = 123", error=True, substrs=["declaration 
conflicts"])
+  return 0; //%self.expect("expr $0", substrs=['(int)', ' = 14'])
+}

Added: 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/unicode-in-variable/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/unicode-in-variable/Makefile?rev=365698&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/unicode-in-variable/Makefile
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/unicode-in-variable/Makefile
 Wed Jul 10 14:04:01 2019
@@ -0,0 +1,4 @@
+LEVEL = ../../make
+CXX_SOURCES := main.cpp
+CXX_FLAGS_EXTRA := -finput-charset=UTF-8 -fextended-identifiers
+include $(LEVEL)/Makefile.rules

Added: 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/unicode-in-variable/TestUnicodeInVariable.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/unicode-in-variable/TestUnicodeInVariable.py?rev=365698&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/unicode-in-variable/TestUnicodeInVariable.py
 (added)
+++ 
lldb/trunk/packages/Pyt

[Lldb-commits] [PATCH] D62931: [lldb-server] Add setting to force 'g' packet use

2019-07-10 Thread Guilherme Andrade via Phabricator via lldb-commits
guiandrade updated this revision to Diff 209063.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62931

Files:
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
  lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
  lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp

Index: lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
===
--- lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
+++ lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
@@ -128,6 +128,12 @@
   ASSERT_EQ(0,
 memcmp(buffer_sp->GetBytes(), one_register, sizeof one_register));
 
+  async_result = std::async(std::launch::async,
+[&] { return client.GetgPacketSupported(tid); });
+  Handle_QThreadSuffixSupported(server, true);
+  HandlePacket(server, "g;thread:0047;", all_registers_hex);
+  ASSERT_TRUE(async_result.get());
+
   read_result = std::async(std::launch::async,
[&] { return client.ReadAllRegisters(tid); });
   HandlePacket(server, "g;thread:0047;", all_registers_hex);
Index: lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
@@ -303,10 +303,13 @@
 if (process_sp) {
   ProcessGDBRemote *gdb_process =
   static_cast(process_sp.get());
-  // read_all_registers_at_once will be true if 'p' packet is not
-  // supported.
+  // read_all_registers_at_once will be true if the server supports 'g'
+  // packet and either the flag gdb_process->m_use_g_packet is true or 'p'
+  // packet is not supported.
   bool read_all_registers_at_once =
-  !gdb_process->GetGDBRemote().GetpPacketSupported(GetID());
+  gdb_process->GetGDBRemote().GetgPacketSupported(GetID()) &&
+  (gdb_process->m_use_g_packet ||
+   !gdb_process->GetGDBRemote().GetpPacketSupported(GetID()));
   reg_ctx_sp = std::make_shared(
   *this, concrete_frame_idx, gdb_process->m_register_info,
   read_all_registers_at_once);
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
@@ -283,6 +283,7 @@
   lldb::CommandObjectSP m_command_sp;
   int64_t m_breakpoint_pc_offset;
   lldb::tid_t m_initial_tid; // The initial thread ID, given by stub on attach
+  bool m_use_g_packet;
 
   bool m_replay_mode;
   bool m_allow_flash_writes;
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -138,12 +138,20 @@
  nullptr,
  {},
  "If true, the libraries-svr4 feature will be used to get a hold of the "
- "process's loaded modules."}};
+ "process's loaded modules."},
+{"use-g-packet",
+ OptionValue::eTypeBoolean,
+ true,
+ 1,
+ nullptr,
+ {},
+ "Specify if the server should use 'g' packets."}};
 
 enum {
   ePropertyPacketTimeout,
   ePropertyTargetDefinitionFile,
-  ePropertyUseSVR4
+  ePropertyUseSVR4,
+  ePropertyUseGPacket
 };
 
 class PluginProperties : public Properties {
@@ -180,6 +188,11 @@
 return m_collection_sp->GetPropertyAtIndexAsBoolean(
 nullptr, idx, g_properties[idx].default_uint_value != 0);
   }
+
+  bool GetUseGPacket() const {
+const uint32_t idx = ePropertyUseGPacket;
+return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, true);
+  }
 };
 
 typedef std::shared_ptr ProcessKDPPropertiesSP;
@@ -374,6 +387,8 @@
   GetGlobalPluginProperties()->GetPacketTimeout();
   if (timeout_seconds > 0)
 m_gdb_comm.SetPacketTimeout(std::chrono::seconds(timeout_seconds));
+
+  m_use_g_packet = GetGlobalPluginProperties()->GetUseGPacket();
 }
 
 // Destructor
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
@@ -234,6 +234,8 @@
 
   bool GetpPacketSupported(lldb::tid_t tid);
 
+  bool GetgPacketSupported(lldb::tid_t tid);
+
   bool GetxPacketSupported();
 
   bool GetVAtta

[Lldb-commits] [PATCH] D63854: [NFC] Convert large lambda into method

2019-07-10 Thread Evgenii Stepanov via Phabricator via lldb-commits
eugenis accepted this revision.
eugenis added a comment.
This revision is now accepted and ready to land.

LGTM if it's really NFC


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63854



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


[Lldb-commits] [PATCH] D64535: Add convenience methods to convert LLDB to LLVM data structures.

2019-07-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: labath, clayborg.
Herald added a subscriber: aprantl.
Herald added a project: LLDB.

This adds two convenience methods named `GetAsLLVM` to the LLDB versions of the 
DWARF DataExtractor and the DWARF context.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D64535

Files:
  lldb/include/lldb/Core/Section.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h

Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h
@@ -11,6 +11,7 @@
 
 #include "lldb/Core/dwarf.h"
 #include "lldb/Utility/DataExtractor.h"
+#include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h"
 
 namespace lldb_private {
 
@@ -28,6 +29,8 @@
 
   size_t GetDWARFSizeofInitialLength() const { return 4; }
   size_t GetDWARFSizeOfOffset() const { return 4; }
+
+  llvm::DWARFDataExtractor GetAsLLVM() const;
 };
 }
 
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "DWARFDataExtractor.h"
+#include "llvm/ADT/StringRef.h"
 
 namespace lldb_private {
 
@@ -19,4 +20,11 @@
 DWARFDataExtractor::GetDWARFOffset(lldb::offset_t *offset_ptr) const {
   return GetMaxU64(offset_ptr, GetDWARFSizeOfOffset());
 }
+
+llvm::DWARFDataExtractor DWARFDataExtractor::GetAsLLVM() const {
+  return llvm::DWARFDataExtractor(
+  llvm::StringRef(reinterpret_cast(GetDataStart()),
+  GetByteSize()),
+  GetByteOrder() == lldb::eByteOrderLittle, GetAddressByteSize());
 }
+} // namespace lldb_private
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h
@@ -12,6 +12,7 @@
 #include "DWARFDataExtractor.h"
 #include "lldb/Core/Section.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/DebugInfo/DWARF/DWARFContext.h"
 #include "llvm/Support/Threading.h"
 #include 
 
@@ -64,6 +65,8 @@
   const DWARFDataExtractor &getOrLoadStrData();
   const DWARFDataExtractor &getOrLoadStrOffsetsData();
   const DWARFDataExtractor &getOrLoadDebugTypesData();
+
+  std::unique_ptr GetAsLLVM() const;
 };
 } // namespace lldb_private
 
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
@@ -100,3 +100,34 @@
   return LoadOrGetSection(eSectionTypeDWARFDebugTypes,
   eSectionTypeDWARFDebugTypesDwo, m_data_debug_types);
 }
+
+std::unique_ptr DWARFContext::GetAsLLVM() const {
+  llvm::StringMap> section_map;
+  uint8_t addr_size = 0;
+
+  auto AddSection = [&](Section §ion) {
+DataExtractor section_data;
+section.GetSectionData(section_data);
+
+// Set the address size the first time we see it.
+if (addr_size == 0)
+  addr_size = section_data.GetByteSize();
+
+llvm::StringRef data = llvm::toStringRef(section_data.GetData());
+llvm::StringRef name = section.GetName().GetStringRef();
+section_map.try_emplace(
+name, llvm::MemoryBuffer::getMemBuffer(data, name, false));
+  };
+
+  if (m_main_section_list) {
+for (auto §ion : *m_main_section_list)
+  AddSection(*section);
+  }
+
+  if (m_dwo_section_list) {
+for (auto §ion : *m_dwo_section_list)
+  AddSection(*section);
+  }
+
+  return llvm::DWARFContext::create(section_map, addr_size);
+}
Index: lldb/include/lldb/Core/Section.h
===
--- lldb/include/lldb/Core/Section.h
+++ lldb/include/lldb/Core/Section.h
@@ -38,6 +38,11 @@
   typedef collection::iterator iterator;
   typedef collection::const_iterator const_iterator;
 
+  const_iterator begin() const { return m_sections.begin(); }
+  const_iterator end() const { return m_sections.end(); }
+  const_iterator begin() { return m_sections.begin(); }
+  const_iterator end() { return m_sections.end(); }
+
   SectionList();
 
   ~SectionList();
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D64251: Don't depend on psutil on AIX

2019-07-10 Thread David Tenty via Phabricator via lldb-commits
daltenty added a comment.

In D64251#1577374 , @davide wrote:

> This is adding a fair amount of complexity on something that just works fine 
> on basically every platform but AIX.
>  If AIX has issue with `psutil`, maybe the fix should be submitted to 
> `psutil` upstream instead of having this dance here?


I appreciate the concern, however in the original change which added timeout 
functionality to lit (review D14706 ), it was 
already noted that depending on psutil wasn't supposed to be permanent. 
Removing this external dependency from lit would be desirable and hopefully 
other platforms will follow suit in the future.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64251



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


[Lldb-commits] [PATCH] D64535: Add convenience methods to convert LLDB to LLVM data structures.

2019-07-10 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

Just wondering if we want to cache the llvm::DWARFContext in the LLDB 
DWARFContext. See inline comments.




Comment at: lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h:69
+
+  std::unique_ptr GetAsLLVM() const;
 };

Should we cache this lldb's DWARFContext and just hand out a pointer or 
reference that is owned by this class? Or are we ok creating temp 
llvm::DWARFContext objects that we will throw away? Is there any state in 
llvm::DWARFContext that we wouldn't want to re-create or parse is my main 
concern.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D64535



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


[Lldb-commits] [PATCH] D63854: NFC: Convert large lambda into method

2019-07-10 Thread Vitaly Buka via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365708: NFC: Convert large lambda into method (authored by 
vitalybuka, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D63854?vs=206771&id=209085#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D63854

Files:
  cfe/trunk/lib/CodeGen/CGDecl.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.h

Index: cfe/trunk/lib/CodeGen/CGDecl.cpp
===
--- cfe/trunk/lib/CodeGen/CGDecl.cpp
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp
@@ -1663,6 +1663,87 @@
   return false;
 }
 
+void CodeGenFunction::emitZeroOrPatternForAutoVarInit(QualType type,
+  const VarDecl &D,
+  Address Loc) {
+  auto trivialAutoVarInit = getContext().getLangOpts().getTrivialAutoVarInit();
+  CharUnits Size = getContext().getTypeSizeInChars(type);
+  bool isVolatile = type.isVolatileQualified();
+  if (!Size.isZero()) {
+switch (trivialAutoVarInit) {
+case LangOptions::TrivialAutoVarInitKind::Uninitialized:
+  llvm_unreachable("Uninitialized handled by caller");
+case LangOptions::TrivialAutoVarInitKind::Zero:
+  emitStoresForZeroInit(CGM, D, Loc, isVolatile, Builder);
+  break;
+case LangOptions::TrivialAutoVarInitKind::Pattern:
+  emitStoresForPatternInit(CGM, D, Loc, isVolatile, Builder);
+  break;
+}
+return;
+  }
+
+  // VLAs look zero-sized to getTypeInfo. We can't emit constant stores to
+  // them, so emit a memcpy with the VLA size to initialize each element.
+  // Technically zero-sized or negative-sized VLAs are undefined, and UBSan
+  // will catch that code, but there exists code which generates zero-sized
+  // VLAs. Be nice and initialize whatever they requested.
+  const auto *VlaType = getContext().getAsVariableArrayType(type);
+  if (!VlaType)
+return;
+  auto VlaSize = getVLASize(VlaType);
+  auto SizeVal = VlaSize.NumElts;
+  CharUnits EltSize = getContext().getTypeSizeInChars(VlaSize.Type);
+  switch (trivialAutoVarInit) {
+  case LangOptions::TrivialAutoVarInitKind::Uninitialized:
+llvm_unreachable("Uninitialized handled by caller");
+
+  case LangOptions::TrivialAutoVarInitKind::Zero:
+if (!EltSize.isOne())
+  SizeVal = Builder.CreateNUWMul(SizeVal, CGM.getSize(EltSize));
+Builder.CreateMemSet(Loc, llvm::ConstantInt::get(Int8Ty, 0), SizeVal,
+ isVolatile);
+break;
+
+  case LangOptions::TrivialAutoVarInitKind::Pattern: {
+llvm::Type *ElTy = Loc.getElementType();
+llvm::Constant *Constant = constWithPadding(
+CGM, IsPattern::Yes, initializationPatternFor(CGM, ElTy));
+CharUnits ConstantAlign = getContext().getTypeAlignInChars(VlaSize.Type);
+llvm::BasicBlock *SetupBB = createBasicBlock("vla-setup.loop");
+llvm::BasicBlock *LoopBB = createBasicBlock("vla-init.loop");
+llvm::BasicBlock *ContBB = createBasicBlock("vla-init.cont");
+llvm::Value *IsZeroSizedVLA = Builder.CreateICmpEQ(
+SizeVal, llvm::ConstantInt::get(SizeVal->getType(), 0),
+"vla.iszerosized");
+Builder.CreateCondBr(IsZeroSizedVLA, ContBB, SetupBB);
+EmitBlock(SetupBB);
+if (!EltSize.isOne())
+  SizeVal = Builder.CreateNUWMul(SizeVal, CGM.getSize(EltSize));
+llvm::Value *BaseSizeInChars =
+llvm::ConstantInt::get(IntPtrTy, EltSize.getQuantity());
+Address Begin = Builder.CreateElementBitCast(Loc, Int8Ty, "vla.begin");
+llvm::Value *End =
+Builder.CreateInBoundsGEP(Begin.getPointer(), SizeVal, "vla.end");
+llvm::BasicBlock *OriginBB = Builder.GetInsertBlock();
+EmitBlock(LoopBB);
+llvm::PHINode *Cur = Builder.CreatePHI(Begin.getType(), 2, "vla.cur");
+Cur->addIncoming(Begin.getPointer(), OriginBB);
+CharUnits CurAlign = Loc.getAlignment().alignmentOfArrayElement(EltSize);
+Builder.CreateMemCpy(Address(Cur, CurAlign),
+ createUnnamedGlobalForMemcpyFrom(
+ CGM, D, Builder, Constant, ConstantAlign),
+ BaseSizeInChars, isVolatile);
+llvm::Value *Next =
+Builder.CreateInBoundsGEP(Int8Ty, Cur, BaseSizeInChars, "vla.next");
+llvm::Value *Done = Builder.CreateICmpEQ(Next, End, "vla-init.isdone");
+Builder.CreateCondBr(Done, ContBB, LoopBB);
+Cur->addIncoming(Next, LoopBB);
+EmitBlock(ContBB);
+  } break;
+  }
+}
+
 void CodeGenFunction::EmitAutoVarInit(const AutoVarEmission &emission) {
   assert(emission.Variable && "emission was not valid!");
 
@@ -1727,87 +1808,11 @@
 if (emission.IsEscapingByRef && !locIsByrefHeader)
   Loc = emitBlockByrefAddress(Loc, &D, /*follow=*/false);
 
-bool isVolatile = type.isVolatileQualified();
-CharUnits Size = get

[Lldb-commits] [lldb] r365718 - [swig] Add workaround for old swig

2019-07-10 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Wed Jul 10 17:12:59 2019
New Revision: 365718

URL: http://llvm.org/viewvc/llvm-project?rev=365718&view=rev
Log:
[swig] Add workaround for old swig

Apparently, when using swig 1.3.40, properties to set values do not work
without the `__swig_setmethods__` workaround. I conditionally added this
back for SBTypeCategory, as it's causing a test failure on GreenDragon,
while I investigate this further.

Modified:
lldb/trunk/scripts/interface/SBTypeCategory.i

Modified: lldb/trunk/scripts/interface/SBTypeCategory.i
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/interface/SBTypeCategory.i?rev=365718&r1=365717&r2=365718&view=diff
==
--- lldb/trunk/scripts/interface/SBTypeCategory.i (original)
+++ lldb/trunk/scripts/interface/SBTypeCategory.i Wed Jul 10 17:12:59 2019
@@ -213,6 +213,11 @@ namespace lldb {
 name = property(GetName, None)
 enabled = property(GetEnabled, SetEnabled)
 %}
+#if SWIG_VERSION < 0x030009
+%pythoncode %{
+   __swig_setmethods__["enabled"] = SetEnabled
+%}
+#endif
 
 };
 


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


[Lldb-commits] [lldb] r365719 - [lldb] Disable TestDollarInVariable.py on Windows

2019-07-10 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Wed Jul 10 17:35:31 2019
New Revision: 365719

URL: http://llvm.org/viewvc/llvm-project?rev=365719&view=rev
Log:
[lldb] Disable TestDollarInVariable.py on Windows

It seems on Windows we don't handle the lldb_expr_result variable correctly:

```
AssertionError: False is not True : 'expr $__lldb_expr_result' returns expected 
result, got '(int &) $0 = 0x'
```

I'll disable the test until I can find a way to debug this on Windows.

Modified:

lldb/trunk/packages/Python/lldbsuite/test/expression_command/dollar-in-variable/TestDollarInVariable.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/dollar-in-variable/TestDollarInVariable.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/dollar-in-variable/TestDollarInVariable.py?rev=365719&r1=365718&r2=365719&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/dollar-in-variable/TestDollarInVariable.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/dollar-in-variable/TestDollarInVariable.py
 Wed Jul 10 17:35:31 2019
@@ -1,4 +1,5 @@
 from lldbsuite.test import lldbinline
 from lldbsuite.test import decorators
 
-lldbinline.MakeInlineTest(__file__, globals(), None)
+lldbinline.MakeInlineTest(__file__, globals(),
+  [lldbinline.expectedFailureAll(oslist=["windows"])])


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


[Lldb-commits] [PATCH] D64535: Add convenience methods to convert LLDB to LLVM data structures.

2019-07-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 209106.
JDevlieghere added a comment.

Cache the LLVM DWARF context.


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

https://reviews.llvm.org/D64535

Files:
  lldb/include/lldb/Core/Section.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h

Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h
@@ -11,6 +11,7 @@
 
 #include "lldb/Core/dwarf.h"
 #include "lldb/Utility/DataExtractor.h"
+#include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h"
 
 namespace lldb_private {
 
@@ -28,6 +29,8 @@
 
   size_t GetDWARFSizeofInitialLength() const { return 4; }
   size_t GetDWARFSizeOfOffset() const { return 4; }
+
+  llvm::DWARFDataExtractor GetAsLLVM() const;
 };
 }
 
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "DWARFDataExtractor.h"
+#include "llvm/ADT/StringRef.h"
 
 namespace lldb_private {
 
@@ -19,4 +20,11 @@
 DWARFDataExtractor::GetDWARFOffset(lldb::offset_t *offset_ptr) const {
   return GetMaxU64(offset_ptr, GetDWARFSizeOfOffset());
 }
+
+llvm::DWARFDataExtractor DWARFDataExtractor::GetAsLLVM() const {
+  return llvm::DWARFDataExtractor(
+  llvm::StringRef(reinterpret_cast(GetDataStart()),
+  GetByteSize()),
+  GetByteOrder() == lldb::eByteOrderLittle, GetAddressByteSize());
 }
+} // namespace lldb_private
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h
@@ -12,6 +12,7 @@
 #include "DWARFDataExtractor.h"
 #include "lldb/Core/Section.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/DebugInfo/DWARF/DWARFContext.h"
 #include "llvm/Support/Threading.h"
 #include 
 
@@ -20,6 +21,7 @@
 private:
   SectionList *m_main_section_list;
   SectionList *m_dwo_section_list;
+  mutable std::unique_ptr m_llvm_context;
 
   struct SectionData {
 llvm::once_flag flag;
@@ -64,6 +66,8 @@
   const DWARFDataExtractor &getOrLoadStrData();
   const DWARFDataExtractor &getOrLoadStrOffsetsData();
   const DWARFDataExtractor &getOrLoadDebugTypesData();
+
+  llvm::DWARFContext &GetAsLLVM();
 };
 } // namespace lldb_private
 
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
@@ -100,3 +100,37 @@
   return LoadOrGetSection(eSectionTypeDWARFDebugTypes,
   eSectionTypeDWARFDebugTypesDwo, m_data_debug_types);
 }
+
+llvm::DWARFContext &DWARFContext::GetAsLLVM() {
+  if (!m_llvm_context) {
+llvm::StringMap> section_map;
+uint8_t addr_size = 0;
+
+auto AddSection = [&](Section §ion) {
+  DataExtractor section_data;
+  section.GetSectionData(section_data);
+
+  // Set the address size the first time we see it.
+  if (addr_size == 0)
+addr_size = section_data.GetByteSize();
+
+  llvm::StringRef data = llvm::toStringRef(section_data.GetData());
+  llvm::StringRef name = section.GetName().GetStringRef();
+  section_map.try_emplace(
+  name, llvm::MemoryBuffer::getMemBuffer(data, name, false));
+};
+
+if (m_main_section_list) {
+  for (auto §ion : *m_main_section_list)
+AddSection(*section);
+}
+
+if (m_dwo_section_list) {
+  for (auto §ion : *m_dwo_section_list)
+AddSection(*section);
+}
+
+m_llvm_context = llvm::DWARFContext::create(section_map, addr_size);
+  }
+  return *m_llvm_context;
+}
Index: lldb/include/lldb/Core/Section.h
===
--- lldb/include/lldb/Core/Section.h
+++ lldb/include/lldb/Core/Section.h
@@ -38,6 +38,11 @@
   typedef collection::iterator iterator;
   typedef collection::const_iterator const_iterator;
 
+  const_iterator begin() const { return m_sections.begin(); }
+  const_iterator end() const { return m_sections.end(); }
+  const_iterator begin() { return m_sections.begin(); }
+  const_iterator end() { return m_sections.end(); }
+
   SectionList();
 
   ~SectionList();
___
lldb-commits mailing list
lldb-commits@lists.llvm.org

[Lldb-commits] [PATCH] D64535: Add convenience methods to convert LLDB to LLVM data structures.

2019-07-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 209107.
JDevlieghere added a comment.
Herald added a subscriber: arphaman.

Update use in debug names.


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

https://reviews.llvm.org/D64535

Files:
  lldb/include/lldb/Core/Section.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h
  lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp

Index: lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
@@ -16,13 +16,6 @@
 using namespace lldb_private;
 using namespace lldb;
 
-static llvm::DWARFDataExtractor ToLLVM(const DWARFDataExtractor &data) {
-  return llvm::DWARFDataExtractor(
-  llvm::StringRef(reinterpret_cast(data.GetDataStart()),
-  data.GetByteSize()),
-  data.GetByteOrder() == eByteOrderLittle, data.GetAddressByteSize());
-}
-
 llvm::Expected>
 DebugNamesDWARFIndex::Create(Module &module, DWARFDataExtractor debug_names,
  DWARFDataExtractor debug_str,
@@ -31,8 +24,8 @@
 return llvm::make_error("debug info null",
llvm::inconvertibleErrorCode());
   }
-  auto index_up =
-  llvm::make_unique(ToLLVM(debug_names), ToLLVM(debug_str));
+  auto index_up = llvm::make_unique(debug_names.GetAsLLVM(),
+debug_str.GetAsLLVM());
   if (llvm::Error E = index_up->extract())
 return std::move(E);
 
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h
@@ -11,6 +11,7 @@
 
 #include "lldb/Core/dwarf.h"
 #include "lldb/Utility/DataExtractor.h"
+#include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h"
 
 namespace lldb_private {
 
@@ -28,6 +29,8 @@
 
   size_t GetDWARFSizeofInitialLength() const { return 4; }
   size_t GetDWARFSizeOfOffset() const { return 4; }
+
+  llvm::DWARFDataExtractor GetAsLLVM() const;
 };
 }
 
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "DWARFDataExtractor.h"
+#include "llvm/ADT/StringRef.h"
 
 namespace lldb_private {
 
@@ -19,4 +20,11 @@
 DWARFDataExtractor::GetDWARFOffset(lldb::offset_t *offset_ptr) const {
   return GetMaxU64(offset_ptr, GetDWARFSizeOfOffset());
 }
+
+llvm::DWARFDataExtractor DWARFDataExtractor::GetAsLLVM() const {
+  return llvm::DWARFDataExtractor(
+  llvm::StringRef(reinterpret_cast(GetDataStart()),
+  GetByteSize()),
+  GetByteOrder() == lldb::eByteOrderLittle, GetAddressByteSize());
 }
+} // namespace lldb_private
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h
@@ -12,6 +12,7 @@
 #include "DWARFDataExtractor.h"
 #include "lldb/Core/Section.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/DebugInfo/DWARF/DWARFContext.h"
 #include "llvm/Support/Threading.h"
 #include 
 
@@ -20,6 +21,7 @@
 private:
   SectionList *m_main_section_list;
   SectionList *m_dwo_section_list;
+  mutable std::unique_ptr m_llvm_context;
 
   struct SectionData {
 llvm::once_flag flag;
@@ -64,6 +66,8 @@
   const DWARFDataExtractor &getOrLoadStrData();
   const DWARFDataExtractor &getOrLoadStrOffsetsData();
   const DWARFDataExtractor &getOrLoadDebugTypesData();
+
+  llvm::DWARFContext &GetAsLLVM();
 };
 } // namespace lldb_private
 
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
@@ -100,3 +100,37 @@
   return LoadOrGetSection(eSectionTypeDWARFDebugTypes,
   eSectionTypeDWARFDebugTypesDwo, m_data_debug_types);
 }
+
+llvm::DWARFContext &DWARFContext::GetAsLLVM() {
+  if (!m_llvm_context) {
+llvm::StringMap> section_map;
+uint8_t addr_size = 0;
+
+auto AddSection = [&](Section §ion) {
+  DataExtractor section_data;
+  section.GetSectionData(section_data);
+
+  // Set the address size the first time we see it.
+ 

[Lldb-commits] [PATCH] D64365: [lldb] Let table gen create command option initializers.

2019-07-10 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor updated this revision to Diff 209119.
teemperor added a comment.

- Better formatting and comments for generated Options.inc
- Added support and example for arguments that have enum values.
- Fixed some typos in the Options.td definitions that caused some tests to fail.


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

https://reviews.llvm.org/D64365

Files:
  lldb/CMakeLists.txt
  lldb/cmake/modules/AddLLDB.cmake
  lldb/source/Commands/CMakeLists.txt
  lldb/source/Commands/CommandObjectBreakpoint.cpp
  lldb/source/Commands/CommandObjectHelp.cpp
  lldb/source/Commands/CommandObjectSettings.cpp
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/source/Commands/Options.td
  lldb/source/Commands/OptionsBase.td
  lldb/utils/TableGen/CMakeLists.txt
  lldb/utils/TableGen/LLDBOptionDefEmitter.cpp
  lldb/utils/TableGen/LLDBTableGen.cpp
  lldb/utils/TableGen/LLDBTableGenBackends.h

Index: lldb/utils/TableGen/LLDBTableGenBackends.h
===
--- /dev/null
+++ lldb/utils/TableGen/LLDBTableGenBackends.h
@@ -0,0 +1,34 @@
+//===- TableGen.cpp - Top-Level TableGen implementation for Clang -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file contains the declarations for all of the LLDB TableGen
+// backends. A "TableGen backend" is just a function. See
+// "$LLVM_ROOT/utils/TableGen/TableGenBackends.h" for more info.
+//
+//===--===//
+
+#ifndef LLVM_LLDB_UTILS_TABLEGEN_TABLEGENBACKENDS_H
+#define LLVM_LLDB_UTILS_TABLEGEN_TABLEGENBACKENDS_H
+
+#include 
+
+namespace llvm {
+class raw_ostream;
+class RecordKeeper;
+} // namespace llvm
+
+using llvm::raw_ostream;
+using llvm::RecordKeeper;
+
+namespace lldb_private {
+
+void EmitOptionDefs(RecordKeeper &RK, raw_ostream &OS);
+
+} // namespace lldb_private
+
+#endif
Index: lldb/utils/TableGen/LLDBTableGen.cpp
===
--- /dev/null
+++ lldb/utils/TableGen/LLDBTableGen.cpp
@@ -0,0 +1,71 @@
+//===- TableGen.cpp - Top-Level TableGen implementation for Clang -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file contains the main function for Clang's TableGen.
+//
+//===--===//
+
+#include "LLDBTableGenBackends.h" // Declares all backends.
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/PrettyStackTrace.h"
+#include "llvm/Support/Signals.h"
+#include "llvm/TableGen/Error.h"
+#include "llvm/TableGen/Main.h"
+#include "llvm/TableGen/Record.h"
+
+using namespace llvm;
+using namespace lldb_private;
+
+enum ActionType {
+  PrintRecords,
+  DumpJSON,
+  GenOptionDefs,
+};
+
+static cl::opt
+Action(cl::desc("Action to perform:"),
+   cl::values(clEnumValN(PrintRecords, "print-records",
+ "Print all records to stdout (default)"),
+  clEnumValN(DumpJSON, "dump-json",
+ "Dump all records as machine-readable JSON"),
+  clEnumValN(GenOptionDefs, "gen-lldb-option-defs",
+ "Generate clang attribute clases")));
+
+static bool LLDBTableGenMain(raw_ostream &OS, RecordKeeper &Records) {
+  switch (Action) {
+  case PrintRecords:
+OS << Records; // No argument, dump all contents
+break;
+  case DumpJSON:
+EmitJSON(Records, OS);
+break;
+  case GenOptionDefs:
+EmitOptionDefs(Records, OS);
+break;
+  }
+  return false;
+}
+
+int main(int argc, char **argv) {
+  sys::PrintStackTraceOnErrorSignal(argv[0]);
+  PrettyStackTraceProgram X(argc, argv);
+  cl::ParseCommandLineOptions(argc, argv);
+
+  llvm_shutdown_obj Y;
+
+  return TableGenMain(argv[0], &LLDBTableGenMain);
+}
+
+#ifdef __has_feature
+#if __has_feature(address_sanitizer)
+#include 
+// Disable LeakSanitizer for this binary as it has too many leaks that are not
+// very interesting to fix. See compiler-rt/include/sanitizer/lsan_interface.h .
+int __lsan_is_turned_off() { return 1; }
+#endif // __has_feature(address_sanitizer)
+#endif // defined(__has_feature)
Index: lldb/utils/TableGen/LLDBOptionDefEmitter.cpp
===
--- /dev/null
+++ lldb/utils/TableGen/LLDBOptionDefEmitter.cpp
@@ -0,0 +1,152 @@
+//===- TableGen.cpp - Top-Level TableGen implementation for Clang -===//
+//

[Lldb-commits] [PATCH] D64545: [lldb] Don't use __FUNCTION__ as a file name

2019-07-10 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
teemperor added a reviewer: davide.
Herald added subscribers: lldb-commits, abidh.
Herald added a project: LLDB.

I saw while debugging that we call this file `ParseInternal`, which is not a 
very good name for our
fake expression file and also adds this unnecessary link between the way we 
name this function
and the other source location names we get from the expression parser. This 
patch is renaming
it to `` which is closer to the way Clang names its buffers, it 
doesn't depend on the
function name (which changes when I refactor this code) and it's easier to grep 
for.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D64545

Files:
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp


Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -920,7 +920,7 @@
 
   if (!created_main_file) {
 std::unique_ptr memory_buffer =
-MemoryBuffer::getMemBufferCopy(expr_text, __FUNCTION__);
+MemoryBuffer::getMemBufferCopy(expr_text, "");
 
source_mgr.setMainFileID(source_mgr.createFileID(std::move(memory_buffer)));
   }
 


Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -920,7 +920,7 @@
 
   if (!created_main_file) {
 std::unique_ptr memory_buffer =
-MemoryBuffer::getMemBufferCopy(expr_text, __FUNCTION__);
+MemoryBuffer::getMemBufferCopy(expr_text, "");
 source_mgr.setMainFileID(source_mgr.createFileID(std::move(memory_buffer)));
   }
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D64546: [lldb] Make TestDeletedExecutable more reliable

2019-07-10 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
teemperor added a reviewer: davide.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

It seems that calling Popen can return to the caller before the started process 
has read all the needed information
from its executable. This means that in case we delete the executable while the 
process is still starting up,
this test will create a zombie process which in turn leads to a failing test. 
On my macOS system this happens quite frequently.

The startup time for this process is really short, so waiting half a second 
before deleting the executable seems to be
long enough to make this test pass consistently.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D64546

Files:
  
lldb/packages/Python/lldbsuite/test/functionalities/deleted-executable/TestDeletedExecutable.py


Index: 
lldb/packages/Python/lldbsuite/test/functionalities/deleted-executable/TestDeletedExecutable.py
===
--- 
lldb/packages/Python/lldbsuite/test/functionalities/deleted-executable/TestDeletedExecutable.py
+++ 
lldb/packages/Python/lldbsuite/test/functionalities/deleted-executable/TestDeletedExecutable.py
@@ -26,6 +26,8 @@
 
 popen = self.spawnSubprocess(exe)
 self.addTearDownHook(self.cleanupSubprocesses)
+# Give the process some time to start.
+time.sleep(0.5)
 os.remove(exe)
 
 self.runCmd("process attach -p " + str(popen.pid))


Index: lldb/packages/Python/lldbsuite/test/functionalities/deleted-executable/TestDeletedExecutable.py
===
--- lldb/packages/Python/lldbsuite/test/functionalities/deleted-executable/TestDeletedExecutable.py
+++ lldb/packages/Python/lldbsuite/test/functionalities/deleted-executable/TestDeletedExecutable.py
@@ -26,6 +26,8 @@
 
 popen = self.spawnSubprocess(exe)
 self.addTearDownHook(self.cleanupSubprocesses)
+# Give the process some time to start.
+time.sleep(0.5)
 os.remove(exe)
 
 self.runCmd("process attach -p " + str(popen.pid))
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits