Results 1 to 5 of 5
Hi Guys,
I am starting to learn C++ in Unix environment. I have emacs as an editor. I am VERY new to emcas and programming in it. I saw some ...
- 10-04-2007 #1Just Joined!
- Join Date
- Feb 2007
- Posts
- 29
Problem using GDB for C++ in emacs
Hi Guys,
I am starting to learn C++ in Unix environment. I have emacs as an editor. I am VERY new to emcas and programming in it. I saw some online tutorials explaing how to use GDB, but i have some questions.
I can write a "hello world" code and can compile it using g++. When i use "gdb", it ask for " Run gdb (like this): " . I dont know what to do next. I normally mention my output file name here as "Run gdb (like this): ./a.out" and it runs the file giving me the output. I think my confusion is that how do i use the debugger.
Can you please help me out?
- 10-04-2007 #2
Well, this is what I use most:
break <line# or functionName>
step
print <variable>
cont
Break sets a breakpoint, all debuggers have these. You can give it a line number or function name to break at. Step goes line by line throuhg the code, and print will print the value of any variable. Cont (short for continue) executes up to the next breakpoint, or exit of the program. Gdb is very advanced, but I find myself using those commands all the time.
- 10-05-2007 #3Just Joined!
- Join Date
- Oct 2007
- Posts
- 22
If you are new to programming/unix I recommend using DDD instead. DDD is a visual front end for GDB. Once you are comfortable with DDD you can easily move to GDB if you find the command line back end more efficient for you.
- 10-05-2007 #4Just Joined!
- Join Date
- Feb 2007
- Posts
- 29
How do I get DDD in mandriva or ubuntu? does it come with the package or I need to install it?
Thanks for ur replies.
- 10-05-2007 #5Just Joined!
- Join Date
- Oct 2007
- Posts
- 22
I use Debian, so I cant say for sure. Correct me if Im wrong, doesnt Ubuntu use apt-get package manager? Being a Debian user I can use
to install DDD. Refer to your Distro's documentation on a package manager and package name, or you can compile it yourself by going to: DDD - Data Display Debugger - GNU Project - Free Software Foundation (FSF) and following their instructions. If you are not familiar with compiling yourself, I recommend using a package manager.Code:su apt-get install ddd


Reply With Quote