Clockworks Gaming Archive 4.0.6_4.1.0_4.2.2_4.3.0_4.3.4_5.1.0
Welcome to my dev archive. I hope you find what your looking for. Kind regards _Ikester_
Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» phoenix-w7r8
Wed Nov 05, 2014 12:05 am by _IKESTER_

» Please come visit my new site
Tue Jul 22, 2014 3:45 pm by _IKESTER_

» 5.1.0 Mop_Eve_online multi server.
Thu Jun 26, 2014 3:26 am by _IKESTER_

» Clockworks cata updated 2014
Sat Jan 11, 2014 3:23 pm by _IKESTER_

» {Release} Tree Trinity 3.3.5 Stable Playerbots v17
Mon Dec 09, 2013 5:23 pm by _IKESTER_

» 2500_PHP_SCRIPTS_MEGA_PACK
Thu Oct 31, 2013 11:27 am by _IKESTER_

» 5000 Web Templates Incl. Php,Flash,_Ikester_.rar
Thu Oct 31, 2013 11:25 am by _IKESTER_

» Top wow addons
Sun Oct 27, 2013 1:26 pm by _IKESTER_

» Large lua script bundle for arcemu.
Mon Oct 21, 2013 10:15 am by _IKESTER_

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search
January 2017
MonTueWedThuFriSatSun
      1
2345678
9101112131415
16171819202122
23242526272829
3031     

Calendar Calendar

IKESTER

How-to:Advanced:GDB

View previous topic View next topic Go down

How-to:Advanced:GDB

Post by EVIL MONKEY on Tue Jan 18, 2011 4:46 pm

GDB: The GNU Project Debugger Trinity
This is a simple/dirty tutorial of what is GDB and how to use it.
This tutorial asumes that you can start your trinity-core by typing:
trinity-core
in the console.
1. Before you start debugging trinity you need to have ensured that it is compiled with debug information. To build trinity with debug info just add -DWITH_COREDEBUG=1 and -DCMAKE_BUILD_TYPE=Debug to your options when running cmake. Then compile and install trinity as usual.
2. Now you can start trinity with gdb by typing this.
gdb trinity-core
Then you will most likely see something like this:
user@*:~/home/sources/build$ gdb trinity-core
GNU gdb 6.8-debian
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu"...
(gdb)
(gdb) - is the GDB command prompt , here you can type some commands, almost like in normal shell.
Now after you have gdb running, you may instruct it to start trinity (by having gdb start trinity you can debug it), here is the command:
run
Just type it and if you are lucky you will have trinity loading.
Ok ... you made it, now trinity runs. Take a break until it crash, then you can come back
3. When trinity crashes you will most likely see this message, or any similar.
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x42c5c950 (LWP 9283)]
Player (this=0x42c598e0, session=0x0) at ../../../src/game/Player.cpp:265
265 ../../../src/game/Player.cpp: No such file or directory.
in ../../../src/game/Player.cpp
(gdb)
Now you can type some comands to get information about the crash, and possibly give it to some dev to fix the problem.
Here are the commands that are best to be typed ( or at least I find the most usefull for crash report )
shell echo -e "\nCRASH ON" `date`
info program
shell echo -e "\nBACKTRACE\n"
bt
shell echo -e "\nBACKTRACE FULL\n"
bt full
shell echo -e "\nTHREADS\n"
info threads
shell echo -e "\nTHREADS BACKTRACE\n"
thread apply all bt full
Just type them one after another and give the output in your bug report ...
OK. Thats it, now we can think of some way to automate all this process. GDB has 2 very good switches:
--batch Exit after processing options.
--command=FILE, -x Execute GDB commands from FILE.
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.
run
shell echo -e "\nCRASH ON" `date`
info program
shell echo -e "\nBACKTRACE\n"
bt
shell echo -e "\nBACKTRACE FULL\n"
bt full
shell echo -e "\nTHREADS\n"
info threads
thread apply all bt full[/code]Now you can start the whole monster with:
Code:

gdb trinity-core --batch -x /path/to/gdb-commands

[TIPS] 1.You can also redirect stdout to some log file. I mean this:
gdb trinity-core --batch -x /path/to/gdb-commands > /some/log/file
2.You can add a tail command to gdb-commands file to get the latest lines from your server.log file:
shell echo -e "\nSERVER.LOG\n"
shell tail -n 50 /path/to/your/server.log
50 means how much lanes to take from server.log
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 meaningfull backtrace.
4. You can pass arguments to trinity-core by passing them to the run gdb command ( run -c /path/to/trinitycore.conf ).

-- original by Derex

EVIL MONKEY
GLOBAL MOD
GLOBAL MOD

Posts : 26
Points : 37016
Reputation : 7368
Join date : 2010-01-09

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum