Howto DEBUG for dummies

Ask for help regarding any technical issue or report any bug or OS independent issues.
Locked
User avatar
Sull
Novice
Novice
Posts: 163
Joined: 26 Apr 2004, 16:56
Location: Quebec,Montreal

Howto DEBUG for dummies

Post by Sull »

Well lets start. ive started to write that because lot of people dont know how.and i think getting a debugger output is a lot easier for dev to solve the issue.

then il explain it for linux user
  • Well at first get yourself a debugger.Maybe install it with your ditro tool. or get it here http://www.gnu.org/software/gdb/gdb.html.

    Nice is it Installed?,right. lets start.

    First lets launch gdb
    $ gdb tmw
    Nice you should have somethink like that
    GNU gdb 6.1
    Copyright 2004 Free Software Foundation, Inc.
    GDB is free software, covered by the GNU General Public License, and you are
    welcome to change it and/or distribute copies of it under certain conditions.
    Type "show copying" to see the conditions.
    There is absolutely no warranty for GDB. Type "show warranty" for details.
    This GDB was configured as "i686-pc-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1".

    (gdb)
    Lets run the game now.i suggest you to run tmw in windowed mode.to see the gdb terminal at the same time.
    lets type
    (gdb) run
    Starting program:/usr/bin/tmw
    Now the game should start normaly.now try to figure how the bug as been provoked.What it crashed?...nice is what we need.
    well if it crash you should get an output like that.
    Program received signal SIGSEGV, Segmentation fault.
    Being::isMonster (this=0x7f) at being.cpp:371
    371 return job > 200;
    No dont close the game yet(if its still open).
    Well its a good start but try to get something more detailed.
    Just do us a little "where" or "bt"
    (gdb) where
    #0 Being::isMonster (this=0x7f) at being.cpp:371
    #1 0x080b59f4 in do_input () at game.cpp:598
    #2 0x080ba451 in game () at game.cpp:140
    #3 0x080be299 in main (argc=1, argv=0x7f) at main.cpp:396
    yea thats the info we need.now get them and post them on irc or the forum.

    well now its time to quit.
    (gdb) quit
well dont forget to post your tmw version,system,arch,distro,video card.well as much info as posible info you can get,and say us how did you made it crash.
User avatar
Bjørn
Manasource
Manasource
Posts: 1438
Joined: 09 Dec 2004, 18:50
Location: North Rhine-Westphalia, Germany
Contact:

Post by Bjørn »

Before gdb can display files and line numbers, you first have to configure it to compile with debug info, for example:

./configure [--prefix=yourprefix] [--with-opengl] CXXFLAGS="-g"

Things between [ and ] are optional, the last part is about adding debug info.
Locked