[Lldb-commits] [lldb] r250299 - cmake: provide flag that enables 'log enable --stack' to provide useful file/function info on POSIX systems
Todd Fiala via lldb-commits
lldb-commits at lists.llvm.org
Wed Oct 14 07:52:15 PDT 2015
Author: tfiala
Date: Wed Oct 14 09:52:15 2015
New Revision: 250299
URL: http://llvm.org/viewvc/llvm-project?rev=250299&view=rev
Log:
cmake: provide flag that enables 'log enable --stack' to provide useful file/function info on POSIX systems
Adding the following flag to a cmake line:
-DLLDB_EXPORT_ALL_SYMBOLS=TRUE
will cause all symbols to be exported from liblldb. This enables the llvm
backtrace mechanism to see and report backtrace symbols properly when using
(lldb) log enable --stack ...
Prior to this change, only the SB API symbols would show up on Linux and other
systems that use a public-symbols-based backtrace lookup mechanism.
log enable --stack ... is a very handy, quick way to understand the flow
of how some log lines are getting hit within lldb without having to hook
up a top-level debugger over your current debug session.
Modified:
lldb/trunk/cmake/modules/AddLLDB.cmake
lldb/trunk/cmake/modules/LLDBConfig.cmake
lldb/trunk/source/API/CMakeLists.txt
Modified: lldb/trunk/cmake/modules/AddLLDB.cmake
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/AddLLDB.cmake?rev=250299&r1=250298&r2=250299&view=diff
==============================================================================
--- lldb/trunk/cmake/modules/AddLLDB.cmake (original)
+++ lldb/trunk/cmake/modules/AddLLDB.cmake Wed Oct 14 09:52:15 2015
@@ -96,3 +96,19 @@ macro(add_lldb_executable name)
add_llvm_executable(${name} ${ARGN})
set_target_properties(${name} PROPERTIES FOLDER "lldb executables")
endmacro(add_lldb_executable)
+
+# 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()
Modified: lldb/trunk/cmake/modules/LLDBConfig.cmake
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/LLDBConfig.cmake?rev=250299&r1=250298&r2=250299&view=diff
==============================================================================
--- lldb/trunk/cmake/modules/LLDBConfig.cmake (original)
+++ lldb/trunk/cmake/modules/LLDBConfig.cmake Wed Oct 14 09:52:15 2015
@@ -29,6 +29,15 @@ set(LLDB_DISABLE_CURSES ${LLDB_DEFAULT_D
set(LLDB_RELOCATABLE_PYTHON 0 CACHE BOOL
"Causes LLDB to use the PYTHONHOME environment variable to locate Python.")
+if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
+ set(LLDB_EXPORT_ALL_SYMBOLS 0 CACHE BOOL
+ "Causes lldb to export all symbols when building liblldb.")
+else()
+ # Windows doesn't support toggling this, so don't bother making it a
+ # cache variable.
+ set(LLDB_EXPORT_ALL_SYMBOLS 0)
+endif()
+
if ((NOT MSVC) OR MSVC12)
add_definitions( -DHAVE_ROUND )
endif()
Modified: lldb/trunk/source/API/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/CMakeLists.txt?rev=250299&r1=250298&r2=250299&view=diff
==============================================================================
--- lldb/trunk/source/API/CMakeLists.txt (original)
+++ lldb/trunk/source/API/CMakeLists.txt Wed Oct 14 09:52:15 2015
@@ -82,7 +82,21 @@ set_target_properties(liblldb
)
if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
- add_llvm_symbol_exports(liblldb ${CMAKE_CURRENT_SOURCE_DIR}/liblldb.exports)
+ if (NOT LLDB_EXPORT_ALL_SYMBOLS)
+ # If we're not exporting all symbols, we'll want to explicitly set
+ # the exported symbols here. This prevents 'log enable --stack ...'
+ # from working on some systems but limits the liblldb size.
+ MESSAGE("-- Symbols (liblldb): only exporting liblldb.exports symbols")
+ add_llvm_symbol_exports(liblldb ${CMAKE_CURRENT_SOURCE_DIR}/liblldb.exports)
+ else()
+ # Don't use an explicit export. Instead, tell the linker to
+ # export all symbols.
+ MESSAGE("-- Symbols (liblldb): exporting all symbols")
+ # Darwin linker doesn't need this extra step.
+ if (NOT CMAKE_SYSTEM_NAME MATCHES "Darwin")
+ lldb_append_link_flags(liblldb "-Wl,--export-dynamic")
+ endif()
+ endif()
endif()
if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
More information about the lldb-commits
mailing list