Getting Stack Traces and Debugging Information on Gentoo

If you want to extract a useful debugging information from a crashing application do not try mistakenly to enable the “debug” USE flag in the corresponding ebuild. The “debug” USE flag is used for other purposes [1]. The proper way to do so, is mostly to enable the “-ggdb” compile flag and rebuild the application. In the case of “evince” the command line would be:

# CFLAGS="-march=native -pipe -O2 -ggdb" \
FEATURES="${FEATURES} splitdebug" emerge -1av evince

Luckily, there is no need to keep this in mind, because portage provides a possibility of configuration storing [2,3]. So the debugging configuration can be created once and used for all later purposes. To make use of it, create an “env” directory

# mkdir -p /etc/portage/env/

and put the above introduced debug setup in the file of your taste, like a “debug.conf”:

# cat /etc/portage/env/debug.conf
CFLAGS="-march=native -pipe -O2 -ggdb"
CXXFLAGS="${CFLAGS}"
FEATURES="${FEATURES} splitdebug"

For now you can place all packages you would like to debug in the “package.env” file, using the following already similar to you syntax:

# cat /etc/portage/package.env
app-text/evince debug.conf
dev-libs/glib debug.conf
dev-libs/gtk+ debug.conf
# >gnome-base/nautilus-3.8.1 debug.conf

Rebuild the desired packages and you are ready for debugging:

# emerge -a1v evince glib gtk+

Obtaining stack traces is a straightforward process from this point, which mainly consists of issuing the following commands in order within gdb [1,4]:

$ gdb evince
GNU gdb (Gentoo 7.5.1 p2) 7.5.1
[...]

(gdb) run
[...]

(gdb) set logging file backtrace.log
(gdb) set logging on
Copying output to backtrace.log.

(gdb) thread apply all bt full
[...]

(gdb) set logging off
Done logging to backtrace.log.
(gdb) quit

Further resources:

  1. How to get meaningful backtraces in Gentoo
  2. Overriding environment variables per package
  3. /etc/portage/env
  4. Getting Traces in GNOME
Advertisements

How to fix a keyboard indicator (in GNOME 3.8)

Recently and occasionally I have discovered a tiny issue, which I was forced to observe, every time I was looking at my desktop. This has happen after I have decided to add a keyboard layout for russian language, which was based on german phonetics. So this is what I ended with:

Quickly I have got slightly frustrated, because I started to mix up things a little bit, so I started to look at gnome’s source code, especially searching for a xml database in gnome-control-center and gnome-desktop, and gave up it this idea, as I was not able to find anything particular useful and started to ask around in the IRC channels. Lucky, as people sometimes say that any initiative can be hardly punished, I have got a response from Rui Matos, one of the GNOME developers working on gnome-desktop. He pointed me out to the right direction:

rtcm, I mean, how this names “de1” and “de2” or “ru” are generated, where can I find the corresponding code?
ibqn: the code is in the gnome-desktop module, but it’s just simply getting what’s defined in xkeyboard-config’s data, see http://cgit.freedesktop.org/xkeyboard-config/tree/rules/base.xml.in#n3223
rtcm, so why is it called “de2” and not “ru” instead? looks like a bug
ibqn: those labels are the elements, if you believe that specific layout should have ‘ru’ as its short description, file a bug (preferably with a patch) in freedesktop’s bugzilla
rtcm, thank you for making it clear to me.
ibqn: no prob, I hope I helped 🙂

The following procedure was almost straightforward, I simply cloned their git repository, modified the corresponding file, I believe should be right, committed it locally and finally created a trivial one liner patch:

From 2cbb166e05eae603a2e640eeb3558942a89ecd7e Mon Sep 17 00:00:00 2001
From: Evgeny Bobkin <evgen.ibqn@gmail.com>
Date: Thu, 16 May 2013 14:15:26 +0200
Subject: [PATCH] Fix keyboard indicator for russian (germany, phonetic)

---
 rules/base.xml.in | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/rules/base.xml.in b/rules/base.xml.in
index 5996738..2735723 100644
--- a/rules/base.xml.in
+++ b/rules/base.xml.in
@@ -3223,6 +3223,8 @@
         <variant>
           <configItem>
             <name>ru</name>
+            <!-- Keyboard indicator for Russian layouts -->
+            <_shortDescription>ru</_shortDescription>
             <_description>Russian (Germany, phonetic)</_description>
             <languageList>
               <iso639Id>rus</iso639Id>
-- 
1.8.1.5

As a gentoo user I also have the ability to test every particular package and change its source code without risking or being afraid of irreparably breaking my system, because, due to this modifications, all broken libraries can be easily tracked down and fixed by recreating their reverse dependencies (with revdep-rebuild for example). Therefore I have copied the xkeyboard-config ebuild to my local overlay and included the created patch to it, so I was able to test it and thus fixed the issue. Afterwards, I have filed a bug report and shortly this patch was included upstream. One more success story.

So, what can you do if you have no ability to apply the patch or use the latest version, or even if you want to fix the similar issue locally on your computer? There is also an easy way: you should try to modify the base.xml file accordingly, probably located here:

$ vim /usr/share/X11/xkb/rules/base.xml

And in the case of a new issue, please also open a bug report (with an attached patch to it), so that other people can also profit from your work done.
Enjoy!!!

PS: By the way my stand alone research was not that vain as I have described above, I finally found after years of looking for it, the source code of the Cyrillic (Transliterated) input method plugin, you observe every time when you right-click the mouse pointing on the text field (or entry box), followed by selecting the bottom menu item “Input Methods”

Emacs: How to use white spaces instead of tabs when writing C or Vala code

Many projects have their own policy regarding the code style, so it can happen to you that while working on one of them it is required to use white spaces as indentation instead of commonly used tabs. To activate this feature within the emacs editor only when working with C or Vala source code you can place this in your ~/.emacs file:

(add-hook 'c-mode-hook (lambda () (setq indent-tabs-mode nil)))
(add-hook 'vala-mode-hook (lambda () (setq indent-tabs-mode nil)))

A small note: If it should be applicable for a specific project one can combine the above feature with Directory Variables.

Additional references: spaces instead of tabs