Presentation is loading. Please wait.

Presentation is loading. Please wait.

17/02/2016S. Ponce / EP-LBC1 Debugging Under Linux Sebastien Ponce Friday, 8 March 2002.

Similar presentations


Presentation on theme: "17/02/2016S. Ponce / EP-LBC1 Debugging Under Linux Sebastien Ponce Friday, 8 March 2002."— Presentation transcript:

1 17/02/2016S. Ponce / EP-LBC1 Debugging Under Linux Sebastien Ponce Friday, 8 March 2002

2 08/03/2002S. Ponce / EP-LBC2 Overview  When to use a debugger ?  Available debuggers  Very short introduction to gvd (GNU Visual Debugger)  Some hints on debugging Gaudi Jobs  Demo

3 08/03/2002S. Ponce / EP-LBC3 When to Use a Debugger ?  If you compiled in debug mode : When you want to trace an application execution (breakpoints, step in,...)When you want to trace an application execution (breakpoints, step in,...) When you want to know where the execution crashes (segmentation fault is handled)When you want to know where the execution crashes (segmentation fault is handled)  If you compiled in optimize mode : You can still know which functions were called and which one failedYou can still know which functions were called and which one failed

4 08/03/2002S. Ponce / EP-LBC4 What to Do With a Core ?  You can still debug a program after a segmentation fault if you have a core file  You can learn about Where it failed Where it failed What were the values of variables at this time What were the values of variables at this time What was the call stack at this time What was the call stack at this time

5 08/03/2002S. Ponce / EP-LBC5 Available Debuggers  GDB  Default linux debugger  Powerfull & stable  Installed on lxplus  BUT for experts only  DDD  Based on gdb  Installed on lxplus  Allow Visual debugging  BUT not stable  GVD  Based on gdb  Installed in LHCb  Allow visual debug  Stable  Can be found for free at http://libre.act-europe.fr/gvd/  Very easy to install locally PREFERED CHOICE

6 08/03/2002S. Ponce / EP-LBC6 Launching gvd  Launching gvd : source setup.csh gvd  Inside gvd : [set breaking points] run  In case of core dump : source setup.csh gvd  Inside gvd : File  Open Core Dump

7 08/03/2002S. Ponce / EP-LBC7 gvd Basics gvd Basics Menu bar Tool bar Call stack Source files Gdb window Data display Current Line Source code

8 08/03/2002S. Ponce / EP-LBC8 Some Hints for Gaudi Jobs  Gaudi is using shared libraries  The source files of these do no appear in gvd before the libraries are loaded  The trick is : gvd gvd break main run run next  here we loaded the ApplicationMgr break ApplicationMgr::configure cont finish  now every dll is loaded

9 08/03/2002S. Ponce / EP-LBC9 Demo (1)  Launch : tar xvf demo.tar cd demo make./hello Segmentation Fault gvd hello

10 08/03/2002S. Ponce / EP-LBC10 Demo (2)  gdb windows : (gdb) run Starting Program: /home/sponce/demo/hello Program received signal SIGSEGV, Segmentation fault 0x400e1630 in strcmp() from /lib/libc.so.6 (gdb)  In menu Data  Call Stack  In Tool Bar Up

11 08/03/2002S. Ponce / EP-LBC11 Demo (3) argument line was 0x0 strcmp called from Hello::print Click "Up" once more to see where the line argument was set to 0x0

12 08/03/2002S. Ponce / EP-LBC12 Demo (4) Hello::print called from Hello::displayMessage with no argument when print argument is missing, the default is a 0 pointer and fails. The default has to be changed to empty string

13 08/03/2002S. Ponce / EP-LBC13 Demo (5)  Edition of Hello.h : static void print (char* line = 0); becomes : static void print (char* line = "");  In a shell : make./hello Segmentation Fault gvd hello  In gvd run There is another bug !

14 08/03/2002S. Ponce / EP-LBC14 Demo (6)  In gvd : display Call Stack “Up"  The bug is still in strcmp, line is still 0x0  In gvd : “Up" Data  Display Any Expression  ”this” Then click on the fields of this to see the internal values

15 08/03/2002S. Ponce / EP-LBC15 Demo (7) this  m_message is 0x0 We'll try to place a breakpoint where the initialization of m_message is done, i.e. In the constructor of Hello.

16 08/03/2002S. Ponce / EP-LBC16 Demo (8)  In gvd : Click on the blue point in front of line 4 of Hello.cpp to set a break point there Click run Say you want to start from beginning  gvd stops when the program reaches line 4 obviously the constructor was called with message = 0x0 Click "Up" to see where we came from

17 08/03/2002S. Ponce / EP-LBC17 Demo (9) We were suppose to go through line 20, not 22 since we gave no argument This should have been 1 == argc !!! Fix and run. All Right !

18 08/03/2002S. Ponce / EP-LBC18 Demo (10) This is an example of what you get in case of non debug mode You still have the call stack but not the values of the arguments

19 08/03/2002S. Ponce / EP-LBC19 Demo (11) This show you what you get from a core : gvd hello File->Open Core It’s equivalent to run the program inside the debugger


Download ppt "17/02/2016S. Ponce / EP-LBC1 Debugging Under Linux Sebastien Ponce Friday, 8 March 2002."

Similar presentations


Ads by Google