Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> C/c++ -gdb Linux Debug Tool, Simple Gdb tutorial
kanade
post May 30 2008, 09:48 AM
Post #1


Member [ Level 1 ]
Group Icon

Group: [HOSTED]
Posts: 34
Joined: 15-May 08
Member No.: 30,356



To run the C/C++ file use

$ gcc –g –o test sample.cpp

To debug the code use following command

$ gdb test --- you will get following messages

GNU gdb Red Hat Linux (6.3.0.0-1.122rh) 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 "i386-redhat-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1".

(gdb) b 4 -- Set the break point for your code, here I have set for 4th line of the code

Breakpoint 1 at 0x8048384: file test2.c, line 4.

(gdb) r -- once the break point is set use “r “ to run the code

Starting program: /home/tests/test
Reading symbols from shared object read from target memory...done.
Loaded system supplied DSO at 0x8b5000
Breakpoint 1, main () at test2.c:5
5 {

(gdb) n -----press “n” to go to next line

main () at test2.c:7
7 max=MAX(5,4,3);

(gdb) n -----press “n” to go to next line

8 printf("\n%d",max);

(gdb) print max -----use “print” command to print any variables

$1 = 5

(gdb)

will add some more command to this at later stage.......
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. How To Remove Bad Sectors Or Bad Clusters From HDD(16)
  2. 3ds Max Tutorial #2-creating Reflective Materials(1)
  3. Photoshop Tutorial: Full Grunge Signature(16)
  4. What Language Is Linux Written In ?(15)
  5. Alt Txt Tooltip Popups Over Text Links, How To Do?(11)
  6. PHP Tutorial: Form Verification And Simple Validation(12)
  7. VB.NET: MS-Access Interaction Tutorial (Part I)(18)
  8. What Made You Switch To Linux?(60)
  9. Using The Php Mail() Function For Images Or Attachments(3)
  10. Pre Loader Tutorial For Flash(6)
  11. Installing Glut To Dev C++(3)
  12. Wireless: Bypassing Mac Filtering(10)
  13. Freeware Dvd Authoring Tool(2)
  14. Looking For Linux(34)
  15. A Simple Register Script(3)
  1. How To Make An Test-based Rpg Game!(4)
  2. Safety(9)
  3. How To Install Linux Suse(1)
  4. How To Copy File & Folders From Linux To Windows?.(12)
  5. Linux Beginners - Tutorial On Editors In Linux.(3)
  6. Simple Java Question(3)
  7. Gimp Userbar Tutorial(3)
  8. Why Linux?(23)
  9. Bulletproof Ftp Server Tutorial(0)
  10. Moving To Fedora 9(1)
  11. Which Linux Version For Newbies?(14)
  12. [c/c++][linux] Linking With A -l Is Static Or Dynamic?(0)
  13. Internet Connection In Linux Through Mobile(2)


 



- Lo-Fi Version Time is now: 8th September 2008 - 04:43 AM