kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #38207
Re: Separated debug symbols
-
To:
<kicad-developers@xxxxxxxxxxxxxxxxxxx>
-
From:
Maciej Suminski <maciej.suminski@xxxxxxx>
-
Date:
Sat, 27 Oct 2018 20:08:47 +0200
-
Authentication-results:
spf=pass (sender IP is 188.184.36.48) smtp.mailfrom=cern.ch; lists.launchpad.net; dkim=none (message not signed) header.d=none;lists.launchpad.net; dmarc=bestguesspass action=none header.from=cern.ch;
-
Autocrypt:
addr=maciej.suminski@xxxxxxx; prefer-encrypt=mutual; keydata= xsBNBFKfmAwBCAC9tak+4mDO1WiNnAwegusPBMEdl+sV35XeaU4PGSt33mPSlXB2klamg4ih QUykvuWqNEg2KyTvCSKNfnHTpzeeFegEsIwWFdhbIc4uUAD6CHl4+uGTXQiMh1+IJkgLmwuD RCEx9mSKbdzzTKz05w+fzzT3mNfko8NICWlcmhFgo2RXnQRTqFg7CNNBpx4kr4+AWIvb+Rha AVMLVJj1s05+STGyFucu6sZmTmOC53ZtkV8HchJeGuQL0LPkjvX0VKGE3gkvuP4iLBcgFtNC Kcu/L6FmWd24m2IhWaHXoWLBiVFw7gGzUdB7gSAiNO1+SoWX+99rbud7RvqV49vOgoqbABEB AAHNKU1hY2llaiBTdW1pbnNraSA8bWFjaWVqLnN1bWluc2tpQGNlcm4uY2g+wsB5BBMBAgAj BQJSn5gMAhsDBwsJCAcDAgEGFQgCCQoLBBYCAwECHgECF4AACgkQFHAa7WGlsnU/JQf5AYW0 oFH+jOykZvlRkRZMoqw1vZGOHeRPK92vbjeiau/hALYX1FBvZMx+JMmVHN7DkRIY7bVoiJ6N n4Byn//BSd9F9eXjAphYVuBg2Xe5wp3/l9/z2Iw8KeLpfKAtfIybgpycvTuUxFIxm9mtpPt+ AoNFKBDhfLcpZLJTW7AwwpnzP+GDdjszjnW6rMt8Aq55liR+y/TZfz/tTEDcUcSPLlJBTmda TmkO5aPxPmeCeDMOT3YEd+bK57V5b7RgtqTdIT6CW7tjQKBPJbIGa8PQ0tUfz0yCBEPWghnY w+B/2JeArrRXDui78cGgTDy1ocQNAm3havk2WO2qykxziY6Owc7ATQRSn5gMAQgAxw+MRllT IPNnCeOAbRgX1KRzo7+7WpSIbmhrBzLY0O1SyIa7U05E6+4jDHDfDpSLqc61an1+M69e6l9Z E3ve3hymtj5ucXZQnveQ5klD6z5FBC/04of/YyrS+h6iRSM0nOmu1JOIqM0S2OzwsKRsS86r jCtRE5OxoBDCIB4xNPitezs4uvLoVfO3mVYUhiPRZMtTCInEi+tlM+AmaPjRkPAfhd0wsOjk oxkuJWEnZ8U8oHpeL0uqANZgLlIiT5yJMWsyyqlK01hdFbuIydIFFiyXJw1HDTXWX+tMxJrX VEvQJZALof9RU/jntqGltnQXArUgPMSGGu1f+7AH/CuMyQARAQABwsBfBBgBAgAJBQJSn5gM AhsMAAoJEBRwGu1hpbJ1maAH/RZPbvXaNIOouHZlnlkq/WORHxjkKfve+AbE62Ed8yFIwlAj tyZGKeEG9hDJl6f9BxDv+9qunTfWfXQuHxNIpdXstkxQIx4m043Kx3h7VdEmg53ybeGNgpvz BYk5HdgCH3yP6UbGNiel6xZOywmvpru3pEKNg4mJhzxm9JCG+djrvbRh+BZNOkDBgaSiCAuJ q6Ffo9Qk/qfl6Uim9G7GKSS4930ZQ2GoVObe+jXixOhWXFSDhGKX5meABmELJ9XTcW3Pp6XC 0KXOE2p0EHQPmFvXdU6OePI72jTgRzPJXRXbPkL0/NUfbZfxS/xnAG8jmODc2ufbtrvE2jPu INX35u4=
-
In-reply-to:
<b2cacfac-763f-ffec-922a-dcdcf2e17643@cern.ch>
-
Openpgp:
preference=signencrypt
-
Spamdiagnosticmetadata:
NSPM
-
Spamdiagnosticoutput:
1:99
-
User-agent:
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0
On 10/27/18 11:36 AM, Maciej Suminski wrote:
>> The GNU toolchain also has build IDs, which allows keeping multiple
>> versions of debug information, and
>>
>>
>> https://stackoverflow.com/questions/32861480/cmake-save-stripped-debug-information
>>
>> has a nice fragment for that, although the build ID needs to be
>> generated somewhere (and distros need a way to pass them in for
>> reproducible builds). The ID would be accessible from the About dialog
>> as well so you know which debug package to download.
>
> Build-IDs seem even better. I will explore this method, thank you for
> the tip.
I have just tested build-IDs. The attribute itself is useful to match
binaries with debug information, but it does not substitute
gnu-debuglink well enough. When only build-IDs are in play, one has to
place the debug information in .build-id/xx/yy...y.debug file where xx
and yy..y are parts of the build-id. It also requires setting
debug-symbol-dir in gdb, making it not very convenient. Another problem
is that the attribute is ELF specific, so it does not work with Windows.
All in all, I have kept gnu-debuglink enabled and added build-ID to
match debug files on Linux. The attached patch also has
KICAD_SPLIT_DEBUG turned on by default.
Cheers,
Orson
From d227ae2b9249050c2ad6b3fbdd33f80c20a97299 Mon Sep 17 00:00:00 2001
From: Maciej Suminski <maciej.suminski@xxxxxxx>
Date: Thu, 25 Oct 2018 20:51:32 +0200
Subject: [PATCH] Added KICAD_SPLIT_DEBUG CMake flag to store debug symbols as
a separate file
---
CMakeLists.txt | 12 ++++++++++++
CMakeModules/SplitDebug.cmake | 32 ++++++++++++++++++++++++++++++++
cvpcb/CMakeLists.txt | 4 ++++
eeschema/CMakeLists.txt | 5 +++++
gerbview/CMakeLists.txt | 5 +++++
pagelayout_editor/CMakeLists.txt | 5 +++++
pcb_calculator/CMakeLists.txt | 5 +++++
pcbnew/CMakeLists.txt | 5 +++++
8 files changed, 73 insertions(+)
create mode 100644 CMakeModules/SplitDebug.cmake
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 41bbe9a03..622374321 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -102,6 +102,10 @@ option( KICAD_INSTALL_DEMOS
"Install KiCad demos and examples (default ON)"
ON )
+option( KICAD_SPLIT_DEBUG
+ "Saves debugging data to a separate file (default ON)"
+ ON )
+
# when option KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES is enabled:
# PYTHON_EXECUTABLE can be defined when invoking cmake
# ( use -DPYTHON_EXECUTABLE=<python path>/python.exe or python2 )
@@ -120,6 +124,14 @@ if ( KICAD_SCRIPTING_ACTION_MENU AND NOT KICAD_SCRIPTING )
set ( KICAD_SCRIPTING ON )
endif()
+if( KICAD_SPLIT_DEBUG )
+ if( NOT CMAKE_BUILD_TYPE STREQUAL "Debug" )
+ message( WARNING "KICAD_SPLIT_DEBUG makes sense only for debug builds" )
+ endif()
+
+ include( SplitDebug )
+endif()
+
option( BUILD_GITHUB_PLUGIN "Build the GITHUB_PLUGIN for pcbnew." ON )
option( KICAD_SPICE "Build KiCad with internal Spice simulator." ON )
diff --git a/CMakeModules/SplitDebug.cmake b/CMakeModules/SplitDebug.cmake
new file mode 100644
index 000000000..dd4e56947
--- /dev/null
+++ b/CMakeModules/SplitDebug.cmake
@@ -0,0 +1,32 @@
+# Copyright (C) 2018 CERN
+# @author Maciej Suminski <maciej.suminski@xxxxxxx>
+#
+# This program is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation, either version 3 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# SplitDebug() separates debug information to another file, leaving the #
+# original binary stripped and compact. It also sets randomly generated BuildID
+# attribute for both binaries.
+function( SplitDebug target filename )
+ # Generate BuildID
+ string( RANDOM LENGTH 40 ALPHABET "0123456789abcdef" BUILD_ID )
+ message( STATUS "${filename} BuildID = 0x${BUILD_ID}" )
+ set_target_properties( ${target} PROPERTIES LINK_FLAGS "-Wl,--build-id=0x${BUILD_ID}" )
+
+ add_custom_command( TARGET ${target} POST_BUILD
+ COMMAND objcopy --only-keep-debug ${filename} ${filename}.debug
+ COMMAND strip --strip-debug --strip-unneeded ${filename}
+ COMMAND objcopy --add-gnu-debuglink="${filename}.debug" ${filename}
+ COMMENT "Creating a debug information file for '${filename}'"
+ )
+endfunction()
diff --git a/cvpcb/CMakeLists.txt b/cvpcb/CMakeLists.txt
index eb77f6b68..9c7b55509 100644
--- a/cvpcb/CMakeLists.txt
+++ b/cvpcb/CMakeLists.txt
@@ -193,6 +193,10 @@ if( MAKE_LINK_MAPS )
LINK_FLAGS "${TO_LINKER},-cref ${TO_LINKER},-Map=_cvpcb.kiface.map" )
endif()
+if( KICAD_SPLIT_DEBUG ) # create a debug info file and strip the output binary
+ SplitDebug( cvpcb_kiface _cvpcb.kiface )
+endif()
+
# these 2 binaries are a matched set, keep them together:
if( APPLE )
# puts binaries into the *.app bundle while linking
diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt
index e56f3c849..491b2e2c2 100644
--- a/eeschema/CMakeLists.txt
+++ b/eeschema/CMakeLists.txt
@@ -376,6 +376,11 @@ set_source_files_properties( eeschema.cpp PROPERTIES
# if building eeschema, then also build eeschema_kiface if out of date.
add_dependencies( eeschema eeschema_kiface )
+if( KICAD_SPLIT_DEBUG ) # create a debug info file and strip the output binary
+ SplitDebug( eeschema_kiface _eeschema.kiface )
+ SplitDebug( eeschema "eeschema${CMAKE_EXECUTABLE_SUFFIX}" )
+endif()
+
if( MAKE_LINK_MAPS )
# generate link map with cross reference
set_target_properties( eeschema_kiface PROPERTIES
diff --git a/gerbview/CMakeLists.txt b/gerbview/CMakeLists.txt
index 9f76f86a7..27a40f276 100644
--- a/gerbview/CMakeLists.txt
+++ b/gerbview/CMakeLists.txt
@@ -174,6 +174,11 @@ endif()
# if building gerbview, then also build gerbview_kiface if out of date.
add_dependencies( gerbview gerbview_kiface )
+if( KICAD_SPLIT_DEBUG ) # create a debug info file and strip the output binary
+ SplitDebug( gerbview_kiface _gerbview.kiface )
+ SplitDebug( gerbview "gerbview${CMAKE_EXECUTABLE_SUFFIX}" )
+endif()
+
# these 2 binaries are a matched set, keep them together
if( APPLE )
set_target_properties( gerbview PROPERTIES
diff --git a/pagelayout_editor/CMakeLists.txt b/pagelayout_editor/CMakeLists.txt
index 4e82fab7d..2070f0888 100644
--- a/pagelayout_editor/CMakeLists.txt
+++ b/pagelayout_editor/CMakeLists.txt
@@ -148,6 +148,11 @@ endif()
# if building pl_editor, then also build pl_editor_kiface if out of date.
add_dependencies( pl_editor pl_editor_kiface )
+if( KICAD_SPLIT_DEBUG ) # create a debug info file and strip the output binary
+ SplitDebug( pl_editor_kiface _pl_editor.kiface )
+ SplitDebug( pl_editor "pl_editor${CMAKE_EXECUTABLE_SUFFIX}" )
+endif()
+
# these 2 binaries are a matched set, keep them together:
if( APPLE )
set_target_properties( pl_editor PROPERTIES
diff --git a/pcb_calculator/CMakeLists.txt b/pcb_calculator/CMakeLists.txt
index 94d6ce469..9ead4402d 100644
--- a/pcb_calculator/CMakeLists.txt
+++ b/pcb_calculator/CMakeLists.txt
@@ -106,6 +106,11 @@ endif()
# if building pcb_calculator, then also build pcb_calculator_kiface if out of date.
add_dependencies( pcb_calculator pcb_calculator_kiface )
+if( KICAD_SPLIT_DEBUG ) # create a debug info file and strip the output binary
+ SplitDebug( pcb_calculator_kiface _pcb_calculator.kiface )
+ SplitDebug( pcb_calculator "pcb_calculator${CMAKE_EXECUTABLE_SUFFIX}" )
+endif()
+
# these 2 binaries are a matched set, keep them together
if( APPLE )
set_target_properties( pcb_calculator PROPERTIES
diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt
index efe36a5fe..03e4715d2 100644
--- a/pcbnew/CMakeLists.txt
+++ b/pcbnew/CMakeLists.txt
@@ -700,6 +700,11 @@ add_dependencies( pcbnew pcbnew_kiface )
# generation of autogenerated file
add_dependencies( pcbnew_kiface_objects specctra_lexer_source_files )
+if( KICAD_SPLIT_DEBUG ) # create a debug info file and strip the output binary
+ SplitDebug( pcbnew_kiface "_pcbnew.kiface" )
+ SplitDebug( pcbnew "pcbnew${CMAKE_EXECUTABLE_SUFFIX}" )
+endif()
+
# these 2 binaries are a matched set, keep them together:
if( APPLE )
set_target_properties( pcbnew PROPERTIES
--
2.18.0
Attachment:
signature.asc
Description: OpenPGP digital signature
Follow ups
References