[arch-general] Generating gdb debug logs for devs
Hi, I have segfaulting lxrandr and I was referred to https://wiki.archlinux.org/index.php/Debug_-_Getting_Traces after filing bug report. I've installed ABS, modified PKGBUILD and made my own /etc/makepkg-dev.conf makepkg -sf --config /etc/makepkg-dev.conf generates the executable. Still gdb gives very little info after running cd lxrandr/pkg/lxrandr/usr/bin gdb -ex "set logging file debug.log" -ex "set logging overwrite on" -ex "thread apply all bt full" -ex "set logging on" -ex "run" -ex "backtrace" -ex "frame 0" -ex "kill" -ex "quit" ./lxrandr I'm guessing because I need to add debugging to libraries which lxrandr is using too. In the wiki there's --- snip --- Note: It is insufficient to simply install the newly compiled debug package, because the debugger will check that the file containing the debug symbols is from the same build as the associated library and executable. You must install both of the recompiled packages. In Arch, the debug symbols files are installed under /usr/lib/debug. See the GDB documentation for more information about debug packages. --- snip --- But as a non c/c++ dev this doesn't say anything. What do I need to install/run and where? So could the wiki page be enhanced by adding concrete example(s)? Original bug report: https://bugs.archlinux.org/task/51480 -- Pekka Järvinen
So uh for all this to take effect you have to do the updates on the PKGBUILD options=(!strip debug) most notably I guess... not sure what makepkg.conf adjustments you made, but I'm pretty sure the main lifting is up to these two options being set. Is it possible that you would share the makepkg.conf you were using as well as the PKGBUILD you were doing the build with? cheers! mar77i
Hi, Here's the configs: lxrandr: % cat PKGBUILD # $Id: PKGBUILD 162929 2016-02-21 01:19:49Z bgyorgy $ # Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com> # Contributor: Geoffroy Carrier <geoffroy.carrier@koon.fr> options=(debug !strip) pkgbase=lxrandr pkgname=(lxrandr lxrandr-gtk3) pkgver=0.3.1 pkgrel=1 pkgdesc="Monitor configuration tool (part of LXDE)" arch=('i686' 'x86_64') license=('GPL2') url="http://lxde.org/" depends=('gtk2' 'gtk3' 'xorg-xrandr') makedepends=('intltool') source=("http://downloads.sourceforge.net/lxde/$pkgbase-$pkgver.tar.xz") md5sums=('b327938f18a4baac85c4707f927d606e') build() { export CFLAGS="$CFLAGS -O0 -fbuiltin -g" export CXXFLAGS="$CXXFLAGS -O0 -fbuiltin -g" # GTK+ 2 version [ -d gtk2 ] || cp -r $pkgbase-$pkgver gtk2 cd gtk2 ./configure --sysconfdir=/etc --prefix=/usr make cd "$srcdir" # GTK+ 3 version [ -d gtk3 ] || cp -r $pkgbase-$pkgver gtk3 cd gtk3 ./configure --sysconfdir=/etc --prefix=/usr --enable-gtk3 make } package_lxrandr() { groups=('lxde') depends=('gtk2' 'xorg-xrandr') cd gtk2 make DESTDIR="$pkgdir" install } package_lxrandr-gtk3() { groups=('lxde-gtk3') pkgdesc+=' (GTK+ 3 version)' depends=('gtk3' 'xorg-xrandr') conflicts=('lxrandr') cd gtk3 make DESTDIR="$pkgdir" install } ----------------- % cat /etc/makepkg-debug.conf | grep -v ^# DLAGENTS=('ftp::/usr/bin/curl -fC - --ftp-pasv --retry 3 --retry-delay 3 -o %o %u' 'http::/usr/bin/curl -fLC - --retry 3 --retry-delay 3 -o %o %u' 'https::/usr/bin/curl -fLC - --retry 3 --retry-delay 3 -o %o %u' 'rsync::/usr/bin/rsync --no-motd -z %u %o' 'scp::/usr/bin/scp -C %u %o') VCSCLIENTS=('bzr::bzr' 'git::git' 'hg::mercurial' 'svn::subversion') CARCH="x86_64" CHOST="x86_64-pc-linux-gnu" CPPFLAGS="-D_FORTIFY_SOURCE=2" CFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong" CXXFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong" LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro" DEBUG_CFLAGS="-g -fvar-tracking-assignments" DEBUG_CXXFLAGS="-g -fvar-tracking-assignments" BUILDENV=(!distcc color !ccache check !sign) OPTIONS=(!strip docs !libtool !staticlibs emptydirs zipman purge !optipng !upx debug) INTEGRITY_CHECK=(md5) STRIP_BINARIES="--strip-all" STRIP_SHARED="--strip-unneeded" STRIP_STATIC="--strip-debug" MAN_DIRS=({usr{,/local}{,/share},opt/*}/{man,info}) DOC_DIRS=(usr/{,local/}{,share/}{doc,gtk-doc} opt/*/{doc,gtk-doc}) PURGE_TARGETS=(usr/{,share}/info/dir .packlist *.pod) COMPRESSGZ=(gzip -c -f -n) COMPRESSBZ2=(bzip2 -c -f) COMPRESSXZ=(xz -c -z -) COMPRESSLRZ=(lrzip -q) COMPRESSLZO=(lzop -q) COMPRESSZ=(compress -c -f) PKGEXT='.pkg.tar.xz' SRCEXT='.src.tar.gz' 2017-02-02 2:05 GMT+02:00 Martin Kühne via arch-general < arch-general@archlinux.org>:
So uh for all this to take effect you have to do the updates on the PKGBUILD options=(!strip debug) most notably I guess... not sure what makepkg.conf adjustments you made, but I'm pretty sure the main lifting is up to these two options being set.
Is it possible that you would share the makepkg.conf you were using as well as the PKGBUILD you were doing the build with?
cheers! mar77i
-- Pekka Järvinen
I've installed ABS, modified PKGBUILD and made my own /etc/makepkg-dev.conf
No need to change both makepkg.conf and the PKGBUILD. Either will do.
makepkg -sf --config /etc/makepkg-dev.conf generates the executable.
This will only build the package. Make sure to install it, or use 'makepkg -sfi' to install it automatically.
Still gdb gives very little info after running cd lxrandr/pkg/lxrandr/usr/bin gdb -ex "set logging file debug.log" -ex "set logging overwrite on" -ex "thread apply all bt full" -ex "set logging on" -ex "run" -ex "backtrace" -ex "frame 0" -ex "kill" -ex "quit" ./lxrandr
I'm guessing because I need to add debugging to libraries which lxrandr is using too.
You should see symbols for the stackframes in lxrandr, but stackframes inside libraries might not resolve until you also build debug versions for them.
In the wiki there's --- snip --- Note: It is insufficient to simply install the newly compiled debug package, because the debugger will check that the file containing the debug symbols is from the same build as the associated library and executable. You must install both of the recompiled packages. In Arch, the debug symbols files are installed under /usr/lib/debug. See the GDB documentation for more information about debug packages. --- snip ---
This is referring to using split debug packages. When using option=(debug) without !split, makepkg will create a separate package with debug symbols. If using this approach, you must install both, simply installing the symbols won't work because they have to match the binary they were built for.
But as a non c/c++ dev this doesn't say anything. What do I need to install/run and where?
You most likely need to install debug symbols for the libraries used when lxrandr crashes. Chris
Hi, This will only build the package. Make sure to install it, or use
'makepkg -sfi' to install it automatically.
% makepkg -sfi ... loading packages... warning: lxrandr-0.3.1-1 is up to date -- reinstalling resolving dependencies... looking for conflicting packages... error: unresolvable package conflicts detected error: failed to prepare transaction (conflicting dependencies) :: lxrandr-gtk3 and lxrandr are in conflict ==> WARNING: Failed to install built package(s). Ok, let's try with pacman: % sudo pacman -U lxrandr-0.3.1-1-x86_64.pkg.tar.xz loading packages... warning: lxrandr-0.3.1-1 is up to date -- reinstalling resolving dependencies... looking for conflicting packages... Packages (1) lxrandr-0.3.1-1 Total Installed Size: 0.22 MiB Net Upgrade Size: 0.01 MiB :: Proceed with installation? [Y/n] (1/1) checking keys in keyring [####################################################################] 100% (1/1) checking package integrity [####################################################################] 100% (1/1) loading package files [####################################################################] 100% (1/1) checking for file conflicts [####################################################################] 100% (1/1) checking available disk space [####################################################################] 100% :: Processing package changes... (1/1) reinstalling lxrandr [####################################################################] 100% :: Running post-transaction hooks... (1/2) Arming ConditionNeedsUpdate... (2/2) Updating the desktop file MIME type cache... % lxrandr zsh: segmentation fault (core dumped) lxrandr Still crashing as expected. % gdb lxrandr GNU gdb (GDB) 7.12.1 Copyright (C) 2017 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-pc-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from lxrandr...(no debugging symbols found)...done. (gdb) run Starting program: /usr/bin/lxrandr [Thread debugging using libthread_db enabled] Using host libthread_db library "/usr/lib/libthread_db.so.1". Program received signal SIGSEGV, Segmentation fault. 0x00000000004035d4 in main () (gdb) But still no proper info..
You most likely need to install debug symbols for the libraries used when lxrandr crashes.
So how/where I can find out what I need to install? -- Pekka Järvinen
A few notes: You can use, eg., the file command to check if executables are stripped. (with something like "file /bin/executable") But gdb already tells you that no debugging symbols were found for the executable. Thus, you either need install an lxrandr package with debugging symbols (with -g and unstripped), or (if you splitted out the debugging symbols during the build) install lxrandr together with its split debugging symbols.
BTW, maybe arandr would suffice as a replacement for lxrandr?
After glimpsing through your makepkg and PKGBUILD: Are you sure you are using makepkg-debug.conf instead of makepkg.conf as the config? Since you are a beginner, maybe it would have been better to first just compile lxrandr manually, instead of with makepkg.
Hi, 2017-02-02 21:43 GMT+02:00 Neven Sajko via arch-general < arch-general@archlinux.org>:
Since you are a beginner, maybe it would have been better to first just compile lxrandr manually, instead of with makepkg.
This finally provided results! main (argc=<optimized out>, argv=<optimized out>) at lxrandr.c:783 783 fixed = LVDS ? LVDS : monitors->data; I would suggest mentioning this manual compiling to the wiki page https://wiki.archlinux.org/index.php/Debug_-_Getting_Traces so that others don't need to use hours/days figuring out this again. And yes, I used the makepkg-debug.conf without getting debug info. -- Pekka Järvinen
On Fri, 3 Feb 2017 02:37:53 +0200, Pekka Järvinen wrote:
I would suggest mentioning this manual compiling to the wiki page
Hi, IMO using a PKGBUILD from ABS and changing options by the PKGBUILD or a config is the easiest way to go. Compiling without building a package could lead to issues. Could the package be removed or does it require to at least build a dummy package, to resolve dependencies? Or, if a user keeps a package, will installing without a package overwrite the files provided by the package, or will it become a mess of manually installed files and files installed by the package? The best approach seems to be, to rebuild the package with the required options and then to replace the installed package by the new package. FWIW everybody could edit the Wiki ;). Regards, Ralf
On Fri, Feb 3, 2017 at 2:37 AM, Pekka Järvinen via arch-general <arch-general@archlinux.org> wrote:
This finally provided results!
main (argc=<optimized out>, argv=<optimized out>) at lxrandr.c:783 783 fixed = LVDS ? LVDS : monitors->data;
At this point, lxrandr has crashed and you are left at the gdb prompt. Type "bt" to create a backtrace showing all functions and line numbers of the current call stack. In your example, lxrandr is crashing in main(), so there is only one stack frame. Also, it might help the developers to print the values of relevant variables. In the above example, it looks like LVDS evaluates to false, and monitors is NULL, causing the segfault. You can confirm this by printing those variables at the prompt, and include it in your bug report: (gdb) p LVDS ... (gdb) p monitors ...
I would suggest mentioning this manual compiling to the wiki page https://wiki.archlinux.org/index.php/Debug_-_Getting_Traces so that others don't need to use hours/days figuring out this again.
Manual compiling is not the recommended way. Chris -- echo mailto: NOSPAM !#$.'<*>'|sed 's. ..'|tr "<*> !#:2" org@fr33z3
On Thu, Feb 2, 2017 at 3:54 PM, Pekka Järvinen via arch-general <arch-general@archlinux.org> wrote:
% makepkg -sfi ... error: unresolvable package conflicts detected error: failed to prepare transaction (conflicting dependencies) :: lxrandr-gtk3 and lxrandr are in conflict
Ah, in this case -i won't work because the PKGBUILD builds two conflicting versions, and -i tries to install them all.
Ok, let's try with pacman:
% sudo pacman -U lxrandr-0.3.1-1-x86_64.pkg.tar.xz ... Packages (1) lxrandr-0.3.1-1
Total Installed Size: 0.22 MiB Net Upgrade Size: 0.01 MiB
This seems too small to contain the debug symbols. Something went wrong during your build. Try to clean the build dir and try again, using the upstream PKGBUILD and simply adding: options+=(debug) Building it should result in packages lxrandr-0.3.1-1 and lxrandr-debug-0.3.1-1. Installing both should get you proper backtraces.
% gdb lxrandr ... Reading symbols from lxrandr...(no debugging symbols found)...done.
This indicates that you have no debug symbols for lxrandr. Chris -- echo mailto: NOSPAM !#$.'<*>'|sed 's. ..'|tr "<*> !#:2" org@fr33z3
participants (5)
-
Christoph Gysin
-
Martin Kühne
-
Neven Sajko
-
Pekka Järvinen
-
Ralf Mardorf