Pull debug symbols into a separate file, check that RelWithDebInfo is used when using breakpad

This commit is contained in:
David Sansome 2013-08-04 17:59:26 +10:00
parent 22de2f34d4
commit d30a46c7dc
5 changed files with 37 additions and 3 deletions

View File

@ -9,6 +9,7 @@ include(cmake/Deb.cmake)
include(cmake/Rpm.cmake) include(cmake/Rpm.cmake)
include(cmake/SpotifyVersion.cmake) include(cmake/SpotifyVersion.cmake)
include(cmake/OptionalSource.cmake) include(cmake/OptionalSource.cmake)
include(cmake/DumpSymbolsMacros.cmake)
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
if (CMAKE_CXX_COMPILER MATCHES ".*clang") if (CMAKE_CXX_COMPILER MATCHES ".*clang")

View File

@ -1,4 +1,8 @@
if (HAVE_BREAKPAD) if (HAVE_BREAKPAD)
if (NOT CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
message(SEND_ERROR "You must set CMAKE_BUILD_TYPE to RelWithDebInfo when using Breakpad")
endif()
add_custom_target(breakpad_symbols add_custom_target(breakpad_symbols
WORKING_DIRECTORY ${CMAKE_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMAND python COMMAND python

View File

@ -0,0 +1,17 @@
macro(separate_debug_symbols TARGET)
if (HAVE_BREAKPAD)
add_custom_command(
TARGET ${TARGET} POST_BUILD
COMMAND objcopy
--only-keep-debug
"$<TARGET_FILE:${TARGET}>"
"$<TARGET_FILE:${TARGET}>.dbg"
COMMAND objcopy
--strip-debug
"$<TARGET_FILE:${TARGET}>"
COMMAND objcopy
--add-gnu-debuglink="$<TARGET_FILE:${TARGET}>".dbg
"$<TARGET_FILE:${TARGET}>"
)
endif()
endmacro()

View File

@ -115,9 +115,19 @@ class Dumper(object):
# Run dump_syms # Run dump_syms
with self.impl.DebugSymbolsFilename(binary_filename) as symbol_filename: with self.impl.DebugSymbolsFilename(binary_filename) as symbol_filename:
stdout = subprocess.check_output( symbol_directory = os.path.dirname(symbol_filename)
[self.dump_syms_binary, symbol_filename], handle = subprocess.Popen(
stderr=subprocess.PIPE) [self.dump_syms_binary, symbol_filename, symbol_directory],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = handle.communicate()
if handle.returncode != 0:
if ("Failed to open debug ELF file" in stderr or
"does not contain a .gnu_debuglink section" in stderr):
logging.warning("Skipping file with missing debug symbols: '%s'",
binary_filename)
return
raise Exception("dump_syms failed for %s\nstdout: %s\nstderr: %s" % (
binary_filename, stdout, stderr))
# The first line of the output contains the hash. # The first line of the output contains the hash.
first_line = stdout[0:stdout.find("\n")] first_line = stdout[0:stdout.find("\n")]

View File

@ -1308,6 +1308,8 @@ target_link_libraries(clementine
clementine_lib clementine_lib
) )
separate_debug_symbols(clementine)
# macdeploy.py relies on the blob being built first. # macdeploy.py relies on the blob being built first.
if(HAVE_SPOTIFY_BLOB) if(HAVE_SPOTIFY_BLOB)
add_dependencies(clementine clementine-spotifyblob) add_dependencies(clementine clementine-spotifyblob)