https://wiki.projectskyfire.org/index.php?title=Linux_GDB_Debugging&feed=atom&action=historyLinux GDB Debugging - Revision history2024-03-29T07:56:26ZRevision history for this page on the wikiMediaWiki 1.39.1https://wiki.projectskyfire.org/index.php?title=Linux_GDB_Debugging&diff=165&oldid=prevMarqin: decat2011-09-18T20:56:36Z<p>decat</p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 15:56, 18 September 2011</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l108">Line 108:</td>
<td colspan="2" class="diff-lineno">Line 108:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>To get correct version information about SkyFire ( so no need to specify it in the bug report ... its already there and its correct, and you can't forget it ).</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>To get correct version information about SkyFire ( so no need to specify it in the bug report ... its already there and its correct, and you can't forget it ).</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del style="font-weight: bold; text-decoration: none;">[[Category:English]]</del></div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> </div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>[[Category:Guides]]</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>[[Category:Guides]]</div></td></tr>
</table>Marqinhttps://wiki.projectskyfire.org/index.php?title=Linux_GDB_Debugging&diff=35&oldid=prevMarqin: moved from old wiki2011-09-03T19:54:26Z<p>moved from old wiki</p>
<p><b>New page</b></p><div> GDB: The GNU Project Debugger. <br />
Original Author is Derex from the MaNGOS project.<br />
http://getmangos.com/community/topic/4579/howto-gdb-debugging/<br />
<br />
Hi, this is a simple/dirty tutorial of what is GDB and how to use it.<br />
<br />
This tutorial assumes that you can start your worldserver by typing:<br />
<br />
worldserver<br />
<br />
in the console.<br />
<br />
1. Before you start debugging SkyFire you need to have ensured that it is compiled with debug information. To build SkyFire with debug info just add --with-debug-info to your options when running ../configure. Then compile and install SkyFire as usual.<br />
<br />
2. Now you can start SkyFire with gdb by typing this.<br />
<br />
gdb worldserver<br />
<br />
Then you will most likely see something like this:<br />
<br />
derex@*:~/workspace/SkyFire/build$ gdb worldserver<br />
GNU gdb 6.8-debian<br />
Copyright (C) 2008 Free Software Foundation, Inc.<br />
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html><br />
This is free software: you are free to change and redistribute it.<br />
There is NO WARRANTY, to the extent permitted by law. Type "show copying"<br />
and "show warranty" for details.<br />
This GDB was configured as "x86_64-linux-gnu"...<br />
(gdb)<br />
<br />
(gdb) - is the GDB command prompt smile , here you can type some commands, almost like in normal shell.<br />
<br />
Now after you have gdb running, you may instruct it to start SkyFire ( by having gdb start SkyFire you can debug it ), here is the command:<br />
<br />
run<br />
<br />
Just type it and if you are lucky you will have SkyFire loading.<br />
<br />
Ok ... you made it, now SkyFire runs. Take a break until it crash ,then you can come back smile<br />
<br />
3. When SkyFire crashes you will most likely see this message, or any similar.<br />
<br />
Program received signal SIGSEGV, Segmentation fault.<br />
[Switching to Thread 0x42c5c950 (LWP 9283)]<br />
Player (this=0x42c598e0, session=0x0) at ../../../src/game/Player.cpp:265<br />
265 ../../../src/game/Player.cpp: No such file or directory.<br />
in ../../../src/game/Player.cpp<br />
(gdb)<br />
<br />
Now you can type some commands to get information about the crash, and possibly give it to some dev to fix the problem.<br />
<br />
Here are the commands that are best to be typed ( or at least I find the most useful for crash report )<br />
<br />
shell echo -e "\nCRASH ON" `date`<br />
info program<br />
shell echo -e "\nBACKTRACE\n"<br />
bt<br />
shell echo -e "\nBACKTRACE FULL\n"<br />
bt full<br />
shell echo -e "\nTHREADS\n"<br />
info threads<br />
shell echo -e "\nTHREADS BACKTRACE\n"<br />
thread apply all bt full<br />
<br />
Just type them one after another and give the output in your bug report ...<br />
<br />
OK. That is it, now we can think of some way to automate all this process. GDB has 2 very good switches:<br />
<br />
--batch Exit after processing options.<br />
--command=FILE, -x Execute GDB commands from FILE.<br />
<br />
<br />
4. So you can put all the commands in one file and have GDB execute it, and when it finishes to exit. Lets say we put this in one file called gdb-commands.<br />
<br />
run<br />
shell echo -e "\nCRASH ON" `date`<br />
info program<br />
shell echo -e "\nBACKTRACE\n"<br />
bt<br />
shell echo -e "\nBACKTRACE FULL\n"<br />
bt full<br />
shell echo -e "\nTHREADS\n"<br />
info threads<br />
thread apply all bt full<br />
<br />
Now you can start the whole monster with:<br />
<br />
gdb worldserver --batch -x /path/to/gdb-commands<br />
<br />
<br />
TIPS<br />
1.You can also redirect stdout to some log file. I mean this:<br />
<br />
gdb worldserver --batch -x /path/to/gdb-commands > /some/log/file<br />
<br />
2.You can add a tail command to gdb-commands file to get the latest lines from your server.log file:<br />
<br />
shell echo -e "\nSERVER.LOG\n"<br />
shell tail -n 50 /path/to/your/server.log<br />
<br />
50 means how much lanes to take from server.log<br />
<br />
3. You can add -ggdb3 -g3 flags to your CXXFLAGS in order to get more debug output. If you add them there is no need to add --with-debug-info switch in order to get meaningful back-trace.<br />
<br />
4. You can pass arguments to worldserver by passing them to the run gdb command ( run -c /path/to/worldserver.conf ).<br />
<br />
<br />
To get correct version information about SkyFire ( so no need to specify it in the bug report ... its already there and its correct, and you can't forget it ).<br />
<br />
[[Category:English]]<br />
[[Category:Guides]]</div>Marqin