The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
opengeosolutions Chooses totalview Debugger to Streamline the ... - Linux PR (press r iBot UNIX and Linux RSS News 0 12-03-2007 10:30 AM
TOTALVIEW DEBUGGER NOW AVAILABLE ON PLATFORM OCS DVD MEDIA KIT ... - Linux PR (press iBot UNIX and Linux RSS News 0 07-16-2007 08:20 AM
TOTALVIEW DEBUGGER PORTED TO SICORTEX LINUX CLUSTER COMPUTERS - Linux PR (press relea iBot UNIX and Linux RSS News 0 06-26-2007 12:00 PM
TotalView(R) Debugger Ported to SiCortex Linux Cluster Computers - Earthtimes.org iBot UNIX and Linux RSS News 0 06-26-2007 06:00 AM
unix debugger naamas03 UNIX for Dummies Questions & Answers 1 09-14-2006 10:31 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 02-17-2005
Registered User
 

Join Date: Feb 2005
Posts: 40
how to use a c debugger in linux/unix

can anyone suggest tutorial sites for using c debugger in linux/unix environments
Reply With Quote
Forum Sponsor
  #2  
Old 02-18-2005
bhargav's Avatar
Registered User
 

Join Date: Sep 2004
Location: USA
Posts: 511
One of the debuggers we use on AIX is "dbx"

See the following example how we use .. dbx

Compile the following .cpp file using -g option
include appropriate include files. ( i have skipped them here ...)

Code:
void
main() 
{
    for (int i=0; 1; i++) 
    {
        cout << "i = " << i << endl ;
        sleep (10) ;
    }
   
    return ;
 }
After compilation the binary name is "db"

I run the db and get the PID of it. Its PID is 60622

Code:
$dbx -a 60622
Waiting to attach to process 60622 ...
Successfully attached to db.
Type 'help' for help.
reading symbolic information ...
stopped in _p_nsleep at 0xd0013b54 ($t1)
0xd0013b54 (_p_nsleep+0x10) 80410014        lwz   r2,0x14(r1)
(dbx) where
_p_nsleep(??, ??) at 0xd0013b54
raise.nsleep(??, ??) at 0xd018776c
sleep(??) at 0xd01e2578
main(), line 22 in "db.cpp"
(dbx) print i
4 
(dbx) printf("hello world")
printf("hello world")
^ unrecognized command
(dbx) print ("hello world");
hello world 
(dbx) file
db.cpp
(dbx) ?i
no match
(dbx) /i
    1   #include <iostream.h>
(dbx) next
stopped in main at line 19 in file "db.cpp" ($t1)
   19       for (int i=0; 1; i++) 
(dbx) next
stopped in main at line 21 in file "db.cpp" ($t1)
   21           cout << "i = " << i << endl ;
(dbx) next
stopped in main at line 22 in file "db.cpp" ($t1)
   22           sleep (10) ;
(dbx) next
stopped in main at line 19 in file "db.cpp" ($t1)
   19       for (int i=0; 1; i++) 
(dbx) print i
5 
(dbx) help
Commands:
 alias       assign      attribute   call        case        catch      
 clear       cleari      condition   cont        delete      detach     
 display(/)  down        dump        edit        file        func       
 goto        gotoi       help        ignore      list        listi      
 map         move        multproc    mutex       next        nexti      
 print       prompt      quit        registers   rerun       return     
 run         rwlock      screen      search(/?)  set         sh         
 skip        source      status      step        stepi       stop       
 stopi       thread      trace       tracei      unalias     unset      
 up          use         whatis      where       whereis     which      


Topics:
 startup        execution      breakpoints    files          data          
 machine        environment    threads        expressions    scope         
 set_variables  usage         

Type "help <command>" or "help <topic>" for help on a command or topic.
(dbx) quit

This gives you some idea how to start debugging ...
This is same in most of the unix debuggers ... ;

For more infomration on dbx,
check the following URL:

http://www.unet.univie.ac.at/aix/cmds/aixcmds2/dbx.htm

Last edited by bhargav; 02-18-2005 at 11:11 PM.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 06:37 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0