how to use a c debugger in linux/unix


 
Thread Tools Search this Thread
Top Forums Programming how to use a c debugger in linux/unix
# 1  
Old 02-18-2005
how to use a c debugger in linux/unix

can anyone suggest tutorial sites for using c debugger in linux/unix environments
# 2  
Old 02-18-2005
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-19-2005 at 02:11 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. Fedora

Which is the better platform to learn UNIX/Linux (Kali Linux Vs. Red Hat or other)?

I just started a new semester and I started my UNIX class yesterday. I've already decided to use python along with my learning process but what I really want to use with it is Kali as my UNIX/Linux platform to learn off of since I already wanted to learn Cyber Sec. anyways. I just wanted to know if... (12 Replies)
Discussion started by: ApacheOmega
12 Replies

2. Programming

Alternative debugger to GNU insight debugger

GNU insight debugger is not available now a days and it is required to debug/inspect assembly code as written in the book Assembly Language Programming step by step in Linux so my question is; is there any alternative to insight that I can use instead of insight in which I can get the same... (5 Replies)
Discussion started by: vectrum
5 Replies

3. HP-UX

symbolic debugger for UNIX

I'm wanting to use a symbolic debugger to find a problem with a C program I'm working on in the HP-UX engine B.10.20 E 9000/800 environment; I've used the GNU debugger on Linux, but it does not exist on UNIX. A fellow here mentioned DDE, Distributed Debugging Environment, but I don't seem to be... (3 Replies)
Discussion started by: cleopard
3 Replies

4. UNIX for Dummies Questions & Answers

unix debugger

hello i'm working on cobol with unix just want to know if there is any command in unix that related to debugger i've been told something like anim command i try to search for man anim result :ERROR: Manual entry does not exist for page anim does anyone have an answer ? another thing ... (1 Reply)
Discussion started by: naamas03
1 Replies

5. UNIX for Advanced & Expert Users

Unix GDB Debugger info

Can any body gime a link for sample programs which can help me to debug the C programs using unix gdb debuger. Please send me the sample programs wch can explain debugging also. I am a begginer for GDB. KG (1 Reply)
Discussion started by: kapi.goel
1 Replies

6. Programming

wdb debugger

Hi all, is it possible to skip a function with the wdb debugger ? could be helpful instead of compiling the whole bunch again does someone know how to do this ? thx Sven (4 Replies)
Discussion started by: Sven28
4 Replies
Login or Register to Ask a Question