(Preparando los paquetes KDE)
(Preparando los paquetes KDE)
Line 77: Line 77:
 
Here's a list of how to obtain debug packages for some distributions:
 
Here's a list of how to obtain debug packages for some distributions:
  
    * Debian - Debian offers -dbg packages to easy create useful backtraces. Just install the corresponding -dbg package. e.g. kdepim-dbg for KMail crashes. The dependencies of -dbg makes sure to pull in the other right packages (kdelibs-dbg, gdb, and so on).
+
*'''Debian''' - Debian offers <tt>-dbg</tt> packages to easy create useful backtraces. Just install the corresponding <tt>-dbg</tt> package. e.g. <tt>kdepim-dbg</tt> for KMail crashes. The dependencies of -dbg makes sure to pull in the other right packages (kdelibs-dbg, gdb, and so on).
    * FreeBSD ports - Please refer to the KDE on FreeBSD FAQ.
+
<!--*'''Fedora''' ???-->
    * Gentoo - Gentoo has its own document describing how to proceed.
+
*'''FreeBSD ports''' - Please refer to the [http://freebsd.kde.org/faq.php#AKDEapplicationcrashedandIwanttofileabugreportathttpbugskdeorgbutthebacktraceintheKDECrashManagerisuselessWhatcanIdo KDE on FreeBSD FAQ].
    * Mandriva - Mandriva 2007.0 and up has additional debugging packages for all of KDE (in fact, for all of its packages). Just install the corresponding -debug package, like kdebase-debug and kdemultimedia-debug. You probably want to install kdelibs-debug anyways.
+
*'''Gentoo''' - Gentoo has its [http://www.gentoo.org/proj/en/qa/backtraces.xml own document] describing how to proceed.
          o Note: the -debug packages are in separate repositories. For instance, for all packages in main, you'll find the debugging package in repository debug_main.  
+
*'''Mandriva''' - Mandriva 2007.0 and up has additional debugging packages for all of KDE (in fact, for all of its packages). Just install the corresponding <tt>-debug</tt> package, like <tt>kdebase-debug</tt> and <tt>kdemultimedia-debug</tt>. You probably want to install <tt>kdelibs-debug</tt> anyways.
    * Kubuntu/Ubuntu - The Ubuntu family makes things quite easy. Every official KDE module has an additional package in the repository, suffixed with -dbg. Always install kdelibs5-dbg, because all KDE applications use kdelibs (kdelibs-dbg for KDE 3 applications). Then you should install a -dbg package for the application which crashed. For example if KOrganizer crashed you should install kdepim-dbg as well. If the program is not from an official KDE module and has no -dbg package, you can install the -dbgsym package from the repository listed on this Debugging Program Crashes page.
+
** Note: the <tt>-debug</tt> packages are in separate repositories. For instance, for all packages in <tt>main</tt>, you'll find the debugging package in repository <tt>debug_main</tt>.
    * openSUSE - You should only install the -debuginfo packages, for example: kdepimlibs4-debuginfo. You can find these packages in KDE repositories. There is also a dedicated openSUSE debugging page.
+
*'''Kubuntu/Ubuntu''' - The Ubuntu family makes things quite easy. Every official KDE module has an additional package in the repository, suffixed with <tt>-dbg</tt>. Always install <tt>kdelibs5-dbg</tt>, because all KDE applications use kdelibs (kdelibs-dbg for KDE 3 applications). Then you should install a -dbg package for the application which crashed. For example if KOrganizer crashed you should install <tt>kdepim-dbg</tt> as well. If the program is not from an official KDE module and has no -dbg package, you can install the -dbgsym package from the repository listed on this [https://wiki.kubuntu.org/DebuggingProgramCrash Debugging Program Crashes] page.
    * Fedora - Fedora has its own document describing how to proceed. (A debuginfo repository has to be enabled.)  
+
*'''openSUSE''' - You should only install the <tt>-debuginfo</tt> packages, for example: <tt>kdepimlibs4-debuginfo</tt>. You can find these packages in [http://en.opensuse.org/KDE/Repositories KDE repositories]. There is also a dedicated [http://en.opensuse.org/Bugs:An_application_crashed openSUSE debugging page].
 +
*'''Fedora''' - Fedora has its [http://fedoraproject.org/wiki/StackTraces own document] describing how to proceed. (A debuginfo repository has to be enabled.)
  
 
If your distribution doesn't have debugging-enabled packages for KDE, you'll have to compile KDE from sources:
 
If your distribution doesn't have debugging-enabled packages for KDE, you'll have to compile KDE from sources:
  
    * If you're using KDE 3, then at the configure stage, you should supply the parameter --enable-debug=full in order to build debug symbols in the resulting files.
+
* If you're using KDE 3, then at the configure stage, you should supply the parameter <tt>--enable-debug=full</tt> in order to build debug symbols in the resulting files.
    * If you're using KDE 4, then at the cmake stage, you should supply the parameter -DCMAKE_BUILD_TYPE=debugfull. If you want to specify your own CXXFLAGS, then use -DCMAKE_BUILD_TYPE=None CMAKE_CXX_FLAGS="-O0 -g". You can change the CMAKE_CXX_FLAGS as appropriate for your needs.  
+
* If you're using KDE 4, then at the cmake stage, you should supply the parameter <tt>-DCMAKE_BUILD_TYPE=debugfull</tt>. If you want to specify your own CXXFLAGS, then use <tt>-DCMAKE_BUILD_TYPE=None CMAKE_CXX_FLAGS="-O0 -g"</tt>. You can change the CMAKE_CXX_FLAGS as appropriate for your needs.
  
Then it's just make and make install as you're used to.
+
Then it's just <tt>make</tt> and <tt>make install</tt> as you're used to.
[edit] Crash!
 
 
 
Now it's time to crash your application. The KDE Crash Dialog should appear right after the crash, which shows the Backtrace tab.
 
KDE Crash Dialog
 
 
 
Click that tab and wait for a minute. This process may take quite some memory, so things may go sluggish all of a sudden. But the result should look much better. For example:
 
 
 
Using host libthread_db library "/lib/libthread_db.so.1".
 
[Thread debugging using libthread_db enabled]
 
[New Thread -1232783168 (LWP 7604)]
 
[KCrash handler]
 
#6  0x0806be76 in TreeMapItem::parent (this=0x0)
 
    at /home/bram/KDE/kde3/kdeaddons/konq-plugins/fsview/treemap.h:285
 
#7  0x08065fea in TreeMapItemList::compareItems (this=0xbfec04a8, item1=0x0,
 
    item2=0x0)
 
    at /home/bram/KDE/kde3/kdeaddons/konq-plugins/fsview/treemap.cpp:720
 
#8  0xb7281619 in QGList::operator== () from /usr/qt/3/lib/libqt-mt.so.3
 
#9  0x0806d498 in QPtrList<TreeMapItem>::operator== (this=0xbfec04a8,
 
    [email protected]) at /usr/qt/3/include/qptrlist.h:74
 
#10 0x08062e18 in TreeMapWidget::mousePressEvent (this=0xbfec03ac,
 
    e=0xbfebff1c)
 
    at /home/bram/KDE/kde3/kdeaddons/konq-plugins/fsview/treemap.cpp:1840
 
#11 0xb7004a63 in QWidget::event () from /usr/qt/3/lib/libqt-mt.so.3
 
#12 0xb6f6bca7 in QApplication::internalNotify ()
 
  from /usr/qt/3/lib/libqt-mt.so.3
 
#13 0xb6f6ca88 in QApplication::notify () from /usr/qt/3/lib/libqt-mt.so.3
 
#14 0xb7725a84 in KApplication::notify (this=0xbfec055c, receiver=0xbfec03ac,
 
    event=0xbfebff1c)
 
    at /home/bram/KDE/kde3/kdelibs/kdecore/kapplication.cpp:550
 
#15 0xb6f0bfd2 in QETWidget::translateMouseEvent ()
 
  from /usr/qt/3/lib/libqt-mt.so.3
 
#16 0xb6f0b8b0 in QApplication::x11ProcessEvent ()
 
  from /usr/qt/3/lib/libqt-mt.so.3
 
#17 0xb6f1b761 in QEventLoop::processEvents () from /usr/qt/3/lib/libqt-mt.so.3
 
#18 0xb6f82831 in QEventLoop::enterLoop () from /usr/qt/3/lib/libqt-mt.so.3
 
#19 0xb6f826b6 in QEventLoop::exec () from /usr/qt/3/lib/libqt-mt.so.3
 
#20 0xb6f6b72f in QApplication::exec () from /usr/qt/3/lib/libqt-mt.so.3
 
#21 0x0805181e in main (argc=134673960, argv=0xffffffff)
 
    at /home/bram/KDE/kde3/kdeaddons/konq-plugins/fsview/main.cpp:55
 
 
 
This looks better, right? It shows memory addresses, the source files and line numbers and the parameters passed to functions. Which make it more helpful to the developer where to look for the problem.
 
 
 
 
 
Note
 
noframe
 
You need GDB installed to get the backtrace of a crash. Please read the next section to know what GDB is, and how to install it.
 
  
 
===Obteniendo la pila de las últimas funciones ejecutadas con GDB===
 
===Obteniendo la pila de las últimas funciones ejecutadas con GDB===

Revision as of 08:22, 19 November 2008

Introducción

Este documento describe cómo crear pilas de las últimas funciones ejecutadas de un casque de una aplicación KDE. Primero se muestra algo de información general y luego se describe cómo preparar KDE en varias distribuciones para obtener estas pilas. Esto debería ser bastante para la mayoría de los casos. Hay secciones adicionales sobre cómo obtener la pila de las últimas funciones ejecutas con el depurador GNU (GDB) y con Valgrind, que son útiles en algunos casos.

Cómo crear informes de fallos útiles

Un buen informe de fallos en Bugzilla consiste de dos partes:

  • Una descripción de cómo reproducir el fallo, y
  • una pila de las últimas funciones ejecutadas (backtrace en inglés) en el momento del fallo.

Si falla uno de estos elementos, se vuelve mucho más dificil, si no imposible, resolver el problema a los desarrolladores.

Una descripción debería consistir en algo más que "cascó". Intente describir todo lo que estaba haciendo en el momento del fallo con el KDE, por ejemplo: ¿pulsó un botón, abrió una web o un fichero en particular que causó los problemas? Recuerde que el desarrollador intentará averiguar dónde está el fallo siguiendo los pasos descritos en el informe. Cualquier detalle que le pueda parecer superfluo relacionado con el fallo podría ser la clave para el desarrollador, así que escríbalo. Más vale pecar por exceso de información que por defecto.

Hay un artículo sobre cómo escribir buenos informes de fallos en este enlace, por favor, leálo antes de informar sobre fallos.

No adjunte la pila de las últimas funciones ejecutadas al informe, simplemente péguelo en el. De este modo es mucho más fácil buscar informes duplicados, porque no se busca en los ficheros adjuntos.

Al pegar la pila de las últimas funciones ejecutadas, elimine la mayoría de las líneas

(no debugging symbols found)

excepto una o dos, porque lo hacen más dificil de leer.

Aunque pegar la pila de las últimas funciones ejecutadas directamente al informe se prefiere a añadirlo como adjunto, por favor, no haga lo mismo con otra información como trazas (valgrind, strace o salida del terminal) o datos de ejemplo (correos, ficheros HTML,...), utilize ficheros adjuntos para esos datos.

pila de las últimas funciones ejecutadas

La pila de las últimas funciones ejecutadas, aunque pueda parecer un galimatías, contiene información muy valiosa para los desarrolladores. Estas pilas describen qué funciones se llamaron justo en el momento del casque, así que los desarrolladores puede saber qué funciones son las culpables del fallo. Pero tener buenas pilas tiene un lado negativo, los ejecutables y bibliotecas que utilizan ocupan mucho más espacio en disco que sus equivalentes optimizados. Por esta razón la mayoría de las distribuciones elijen instalar ejecutables sin símbolos para depuración (stripped en inglés), que producen pilas de últimas funciones ejecutadas inservibles:

(no debugging symbols found)
Using host libthread_db library "/lib/tls/i686/cmov/libthread_db.so.1".
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[Thread debugging using libthread_db enabled]
[New Thread -1233848624 (LWP 12212)]
[New Thread -1255081072 (LWP 12820)]
[New Thread -1240921200 (LWP 12819)]
[New Thread -1266680944 (LWP 12818)]
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
0xffffe410 in __kernel_vsyscall ()
#0  0xffffe410 in __kernel_vsyscall ()
#1  0xb6a1210b in ?? () from /lib/tls/i686/cmov/libpthread.so.0
#2  0xb6a85afe in ?? () from /usr/lib/libX11.so.6
#3  0x00000003 in ?? ()
#4  0x082149c0 in ?? ()
#5  0x00003ffc in ?? ()
#6  0x00000000 in ?? ()

Pero no todo está perdido, con algunas modificaciones se pueden crear pilas de las últimas funciones ejecutadas con toda la información necesaria para los desarrolladores del KDE.

Preparando los paquetes KDE

Si su distribución tiene paquetes de depuración (debug), instálelos.

Es fácil saber qué paquetes hacen falta con símbolos de depuración mirando la pila de las funciones recientes. Por ejemplo, de una línea como la siguiente:

#6  0xb7975bdc in ?? () from /usr/lib/libkmailprivate.so.4

El ?? indica que la biblioteca libkmailprivat.so.4 no tiene información de depuración, que puede estar disponible en paquetes de depuración separados. En este caso, es bastante fácil averiguar que necesita instalar los paquetes de depuración de KMail para obtener una pila con información útil.

Sometimes, you need to install more than one debug package to get a good backtrace. This depends on how the distribution splits up the packages. For example, for some distributions it is enough to install the debug package for kdepim to get enough debugging information for a crash in KMail, for other distributions there is an additional debug package just for KMail.

Here's a list of how to obtain debug packages for some distributions:

  • Debian - Debian offers -dbg packages to easy create useful backtraces. Just install the corresponding -dbg package. e.g. kdepim-dbg for KMail crashes. The dependencies of -dbg makes sure to pull in the other right packages (kdelibs-dbg, gdb, and so on).
  • FreeBSD ports - Please refer to the KDE on FreeBSD FAQ.
  • Gentoo - Gentoo has its own document describing how to proceed.
  • Mandriva - Mandriva 2007.0 and up has additional debugging packages for all of KDE (in fact, for all of its packages). Just install the corresponding -debug package, like kdebase-debug and kdemultimedia-debug. You probably want to install kdelibs-debug anyways.
    • Note: the -debug packages are in separate repositories. For instance, for all packages in main, you'll find the debugging package in repository debug_main.
  • Kubuntu/Ubuntu - The Ubuntu family makes things quite easy. Every official KDE module has an additional package in the repository, suffixed with -dbg. Always install kdelibs5-dbg, because all KDE applications use kdelibs (kdelibs-dbg for KDE 3 applications). Then you should install a -dbg package for the application which crashed. For example if KOrganizer crashed you should install kdepim-dbg as well. If the program is not from an official KDE module and has no -dbg package, you can install the -dbgsym package from the repository listed on this Debugging Program Crashes page.
  • openSUSE - You should only install the -debuginfo packages, for example: kdepimlibs4-debuginfo. You can find these packages in KDE repositories. There is also a dedicated openSUSE debugging page.
  • Fedora - Fedora has its own document describing how to proceed. (A debuginfo repository has to be enabled.)

If your distribution doesn't have debugging-enabled packages for KDE, you'll have to compile KDE from sources:

  • If you're using KDE 3, then at the configure stage, you should supply the parameter --enable-debug=full in order to build debug symbols in the resulting files.
  • If you're using KDE 4, then at the cmake stage, you should supply the parameter -DCMAKE_BUILD_TYPE=debugfull. If you want to specify your own CXXFLAGS, then use -DCMAKE_BUILD_TYPE=None CMAKE_CXX_FLAGS="-O0 -g". You can change the CMAKE_CXX_FLAGS as appropriate for your needs.

Then it's just make and make install as you're used to.

Obteniendo la pila de las últimas funciones ejecutadas con GDB

En algunos casos, no es posible crear la pila de las últimas funciones ejecutadas dentro del diálogo de aplicación fallida del KDE. Esto puede ser porque una aplicacón entró en un bucle sin fin, o el diálogo de aplicación fallida no aparece por algún motivo. Siempre puede intentar obtener la instantánea de donde aparece el fallo con gdb, el depurador GNU. GDB está disponible para instalarse en la inmensa mayoría de las distribuciones en su almacén de programas.

Hay dos formas de utilizad GDB:

  • iniciar una aplicación dentro de gdb, o
  • depurar una aplicación que ya está funcionando, útil en el caso de una aplicación que se encuentra en un bucle sin fin.

Primero empezaremos por iniciar una aplicación dentro de gdb. Desde el terminal, ejecutamos:

$ gdb someKDEapp

El GDB The GDB prompt will appear. Note that this does not start the application itself, you should run it by invoking the run command:

(gdb) run

This will run the application like you are used to, and you can work with it like normal (it only consumes far more memory and may feel sluggish). Now it's time to reproduce your crash. When you succeed, the application just closes and you should return to your GDB prompt. Now it's time to run the 'backtrace' command:


Note noframe Some KDE applications (such as JuK and KTorrent) have special code to ensure that there is only one running instance of the application at a time. For these applications you should type in "run --nofork" at the (gdb) prompt instead of "run" because otherwise gdb will try to debug the wrong process. If you are unsure as to whether to use --nofork just try it. If the application says it's an unknown option you can remove --nofork.


(gdb) thread apply all backtrace

This should give a good backtrace which can be posted at the KDE Bugzilla.

In case you want to attach to an existing process, run the following command in the shell:

$ gdb someKDEapp pid

where pid is the process ID of the process you want to attach to. Once attached, and the process is in an infinite loop, after using the 'backtrace' command again a useful backtrace will appear. You can use 'continue' command to let the application run again and press Ctrl+C in gdb to be able to again enter commands. [edit] Retrieving a backtrace with Valgrind

When it comes to crashes, Valgrind is also a useful tool to create a backtrace. It's not a substitution for GDB, but rather a supplement.

When you run an application in valgrind, every piece of memory read or written by the application is being checked. Valgrind will report erroneous memory operations in the standard output or in a log file. Since most crashes are due to an invalid memory read, valgrind can be useful to track down where the problem occurs.


Note noframe Valgrind consists of several tools in order to check or profile an application. For this article, we only use memcheck, the default tool when valgrind is being invoked.


Like GDB, Valgrind makes running an application much slower, while consuming a lot more resources.

Start the application within valgrind:

$ valgrind --log-file=someKDEapp someKDEapp

Now reproduce the crash. As soon as this happens, the application and valgrind will terminate. What's left is a file named someKDEapp.pid where pid is replaced by the process ID of the valgrind process. The file may list more errors than the one causing the crash. Here's the bit causing the crash which corresponds to the GDB backtrace above:

==23292== Invalid read of size 4
==23292==    at 0x806BD9E: TreeMapItem::parent() const (treemap.h:285)
==23292==    by 0x8065FB9: TreeMapItemList::compareItems(void*, void*) (treemap.cpp:720)
==23292==    by 0x50AC618: QGList::operator==(QGList const&) const (in /usr/qt/3/lib/libqt-mt.so.3.3.8)
==23292==    by 0x806D3BF: QPtrList<TreeMapItem>::operator==(QPtrList<TreeMapItem> const&) const (qptrlist.h:74)
==23292==    by 0x8062DE7: TreeMapWidget::mousePressEvent(QMouseEvent*) (treemap.cpp:1840)
==23292==    by 0x4E2FA62: QWidget::event(QEvent*) (in /usr/qt/3/lib/libqt-mt.so.3.3.8)
==23292==    by 0x4D96CA6: QApplication::internalNotify(QObject*, QEvent*) (in /usr/qt/3/lib/libqt-mt.so.3.3.8)
==23292==    by 0x4D97A87: QApplication::notify(QObject*, QEvent*) (in /usr/qt/3/lib/libqt-mt.so.3.3.8)
==23292==    by 0x4809AC3: KApplication::notify(QObject*, QEvent*) (kapplication.cpp:550)
==23292==    by 0x4D36FD1: QETWidget::translateMouseEvent(_XEvent const*) (in /usr/qt/3/lib/libqt-mt.so.3.3.8)
==23292==    by 0x4D368AF: QApplication::x11ProcessEvent(_XEvent*) (in /usr/qt/3/lib/libqt-mt.so.3.3.8)
==23292==    by 0x4D46760: QEventLoop::processEvents(unsigned) (in /usr/qt/3/lib/libqt-mt.so.3.3.8)
==23292==  Address 0x2C is not stack'd, malloc'd or (recently) free'd

But to be sure, just attach the whole log file to the crash report.


Content is available under Creative Commons License SA 4.0 unless otherwise noted.