From d30a46c7dc75635c757b15173912461008c8d342 Mon Sep 17 00:00:00 2001 From: David Sansome Date: Sun, 4 Aug 2013 17:59:26 +1000 Subject: [PATCH] Pull debug symbols into a separate file, check that RelWithDebInfo is used when using breakpad --- CMakeLists.txt | 1 + cmake/DumpSymbols.cmake | 4 ++++ cmake/DumpSymbolsMacros.cmake | 17 +++++++++++++++++ dist/dump_all_symbols.py | 16 +++++++++++++--- src/CMakeLists.txt | 2 ++ 5 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 cmake/DumpSymbolsMacros.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f59654a2..4ec4dba4c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,7 @@ include(cmake/Deb.cmake) include(cmake/Rpm.cmake) include(cmake/SpotifyVersion.cmake) include(cmake/OptionalSource.cmake) +include(cmake/DumpSymbolsMacros.cmake) set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) if (CMAKE_CXX_COMPILER MATCHES ".*clang") diff --git a/cmake/DumpSymbols.cmake b/cmake/DumpSymbols.cmake index d58055d8b..499c2325c 100644 --- a/cmake/DumpSymbols.cmake +++ b/cmake/DumpSymbols.cmake @@ -1,4 +1,8 @@ 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 WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMAND python diff --git a/cmake/DumpSymbolsMacros.cmake b/cmake/DumpSymbolsMacros.cmake new file mode 100644 index 000000000..403441975 --- /dev/null +++ b/cmake/DumpSymbolsMacros.cmake @@ -0,0 +1,17 @@ +macro(separate_debug_symbols TARGET) + if (HAVE_BREAKPAD) + add_custom_command( + TARGET ${TARGET} POST_BUILD + COMMAND objcopy + --only-keep-debug + "$" + "$.dbg" + COMMAND objcopy + --strip-debug + "$" + COMMAND objcopy + --add-gnu-debuglink="$".dbg + "$" + ) + endif() +endmacro() diff --git a/dist/dump_all_symbols.py b/dist/dump_all_symbols.py index 726d7528d..0c2bbe91a 100644 --- a/dist/dump_all_symbols.py +++ b/dist/dump_all_symbols.py @@ -115,9 +115,19 @@ class Dumper(object): # Run dump_syms with self.impl.DebugSymbolsFilename(binary_filename) as symbol_filename: - stdout = subprocess.check_output( - [self.dump_syms_binary, symbol_filename], - stderr=subprocess.PIPE) + symbol_directory = os.path.dirname(symbol_filename) + handle = subprocess.Popen( + [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. first_line = stdout[0:stdout.find("\n")] diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f4fa47c7b..519be4174 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1308,6 +1308,8 @@ target_link_libraries(clementine clementine_lib ) +separate_debug_symbols(clementine) + # macdeploy.py relies on the blob being built first. if(HAVE_SPOTIFY_BLOB) add_dependencies(clementine clementine-spotifyblob)