Trac is being migrated to new services! Issues can be found in our new YouTrack instance and WIKI pages can be found on our website.

Changes between Initial Version and Version 1 of GetABacktrace


Ignore:
Timestamp:
Apr 27, 2007, 10:30:33 PM (17 years ago)
Author:
John Bailey
Comment:

Migrating gdb.php to the wiki

Legend:

Unmodified
Added
Removed
Modified
  • GetABacktrace

    v1 v1  
     1= Getting A Backtrace =
     2If Pidgin or Finch has crashed, before you submit a bug you should get a backtrace.  Useful backtraces will help us find where in Pidgin, Finch, or !LibPurple your bug exists, which will help us fix the bug.
     3
     4== Distribution-Specific Notes ==
     5Please follow the instructions here if you are using these distributions.
     6
     7 * Ubuntu: see the [https://wiki.ubuntu.com/Backtrace Ubuntu wiki page] on obtaining backtraces.
     8 * Debian: see the [http://wiki.debian.org/?HowToGetABacktrace Debian wiki page] on obtaining backtraces.
     9 * Fedora: Install the -debuginfo rpm first. See [http://fedoraproject.org/wiki/StackTraces these instructions].
     10 * Redhat: Install the -debuginfo rpm first, then follow our instructions below.
     11 * Gentoo: emerge pidgin with `USE=debug`, and report the bug to Gentoo's bug tracker.
     12
     13== The Easy Way ==
     14If you can reproduce the crash, the easiest way to obtain a backtrace is by running with gdb.  Here are the basics:
     15{{{
     16   ~ $ gdb pidgin
     17}}}
     18
     19Next you'll see some information from gdb, similar to this:
     20{{{
     21   GNU gdb Red Hat Linux (5.3post-0.20021129.18rh)
     22   Copyright 2003 Free Software Foundation, Inc.
     23   GDB is free software, covered by the GNU General Public License, and you are
     24   welcome to change it and/or distribute copies of it under certain conditions.
     25   Type "show copying" to see the conditions.
     26   There is absolutely no warranty for GDB.  Type "show warranty" for details.
     27   This GDB was configured as "i386-redhat-linux-gnu"...
     28   (no debugging symbols found)...
     29}}}
     30
     31You will want to do two things now:
     32{{{
     33   (gdb) handle SIGPIPE nostop
     34   (gdb) run
     35}}}
     36
     37Information will pass by now.  You should reproduce your crash now.  Once the crash has happened, do the following:
     38{{{
     39   (gdb) bt full
     40}}}
     41
     42When you get the backtrace, instead of seeing function names, you might see '??' instead. If that's the case, gdb couldn't read the function names from Pidgin and so the backtrace won't end up being very useful after all.  If you see function names, copy and paste all of the backtrace into your bug report.  You'll want to be careful to make sure the [wiki:WikiFormatting wiki formatting] doesn't butcher your pasted backtrace--you'll want to use the Preview button here.
     43
     44Now you can exit gdb by typing quit:
     45{{{
     46   (gdb) quit
     47   ~ $
     48}}}
     49
     50== The Hard Way (a.k.a. Making Use of Core Files) ==
     51When an application crashes, it typically leaves a core file behind. In a console window when you run ls, you should see a file called `core`:
     52{{{
     53   ~ $ ls
     54   core
     55}}}
     56
     57Sometimes this file is also called pidgin.core or something similar, depending on what OS you use and what your settings are. If you don't see this file, it's possible that it's in a different location, and you should look at the settings for your OS to see where it might be. It's also possible that the core file was not created at all; this would happen if your system was configured not to leave a core file. Often you just need to tell your shell to not restrict the size of core files (this may only work for the bash shell):
     58{{{
     59   ~ $ ulimit -c unlimited
     60}}}
     61
     62If you have a core file, first check to make sure that it was created by Pidgin, by using `file` to examine it:
     63{{{
     64   ~ $ file core
     65   core: ELF 32-bit LSB core file of 'pidgin' (signal 11), Intel 80386, version 1, from 'pidgin'
     66}}}
     67
     68The output of `file` may look different depending on your OS and hardware, but it should still be apparent that it was created by Pidgin.
     69
     70Now that you have the core file, you'll want to get the useful information out of it. In order to do that, you'll have to open it in GDB. GDB stands for GNU DeBugger, and is a very useful programmer's tool. It needs to know which application created the core file and what the core file name is, so run:
     71{{{
     72   ~ $ gdb pidgin core
     73}}}
     74
     75At this point, you will see some information from gdb:
     76{{{
     77   GNU gdb 5.0
     78   Copyright 2000 Free Software Foundation, Inc.
     79   GDB is free software, covered by the GNU General Public License, and you are
     80   welcome to change it and/or distribute copies of it under certain conditions.
     81   Type "show copying" to see the conditions.
     82   There is absolutely no warranty for GDB.  Type "show warranty" for details.
     83   This GDB was configured as "i686-pc-linux-gnu"...
     84   Core was generated by `Pidgin'.
     85   Program terminated with signal 11, Segmentation fault.
     86   Reading symbols from /usr/lib/libesd.so.0...done.
     87   Loaded symbols for /usr/lib/libesd.so.0
     88   Reading symbols from /lib/libm.so.6...done.
     89   Loaded symbols for /lib/libm.so.6
     90}}}
     91
     92And so forth. There are a couple reasons why you might see something other than this. One reason is if gdb can't find something it needs, it might give a warning such as `No such file or directory`, in which case you may have to give the full path to both Pidgin and the core file. Another reason would be if the core file isn't created by Pidgin, you may see a message saying `warning: core file may not match specified executable file.`
     93
     94If gdb loaded Pidgin and the core file successfully, then once it's done loading all the symbols that it will need, it should print the information from the top of the stack, and prompt you:
     95{{{
     96   #0  0x404f1140 in poll () from /lib/libc.so.6
     97   (gdb)
     98}}}
     99
     100Now you'll want to get the backtrace.  Type `bt full` at the prompt.  gdb should then print a list of all the functions that were called leading up to the crash, and the values of some variables.  When you get the backtrace, instead of seeing function names, you might see '??' instead. If that's the case, gdb couldn't read the function names from Pidgin and the core file, and so the core file won't end up being very useful after all. However, if you were able to see the function names, then copy all of the output from the backtrace and post a bug report. Be sure to also indicate what you were doing at the time.
     101
     102Now you can exit gdb by typing quit:
     103{{{
     104   (gdb) quit
     105   ~ $
     106}}}
     107
     108There may be other useful information that can be retrieved from the core file, such as the values of variables. For this reason it's a good idea to keep the core file. If you upgrade Pidgin, the core file will no longer match the binary, and it won't be useful anymore; however, don't let that stop you from upgrading Pidgin, since there's a good chance your bug will have been fixed.
     109
     110== Additional Notes for Those Users Wanting To Do More ==
     111Often, you will see a backtrace where one or more of the top lines is in `malloc()` or `g_malloc()`. When this happens, chances are your backtrace isn't very useful. The easiest way to find some useful information is to set the environment variable `MALLOC_CHECK_` to a value of 2. In bash this would be:
     112{{{
     113   export MALLOC_CHECK_=2
     114}}}
     115
     116You can re-run pidgin inside gdb to get a new backtrace. Note that if you used a core file for getting a backtrace, this does not affect existing core files.
All information, including names and email addresses, entered onto this website or sent to mailing lists affiliated with this website will be public. Do not post confidential information, especially passwords!