LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how to debug in ubuntu 12.04 (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-debug-in-ubuntu-12-04-a-4175538934/)

shyjuu 04-06-2015 01:24 PM

how to debug in ubuntu 12.04
 
How to debug class file i.e .cc and other files line by line in ubuntu 12.04, is there any command in ubuntu?

brianL 04-06-2015 01:29 PM

GDB is the main Linux debugger. Here's one of many tutorials found by a websearch:
http://www.cprogramming.com/gdb.html

shyjuu 04-06-2015 11:55 PM

Quote:

Originally Posted by brianL (Post 5343466)
GDB is the main Linux debugger. Here's one of many tutorials found by a websearch:
http://www.cprogramming.com/gdb.html

I want to go line by line execution, similar to Borland C, in which when i press F7 it executes the code line by line, Is this possible in gcc.

jdkaye 04-07-2015 12:09 AM

Quote:

Originally Posted by shyjuu (Post 5343632)
I want to go line by line execution, similar to Borland C, in which when i press F7 it executes the code line by line, Is this possible in gcc.

Have you actually looked at the link that BrianL provided?
Quote:

Next and Step

Just starting and stopping isn't much of a control. GDB also lets you to run the program line-by-line by the commands 'next' and 'step'. There is a little difference between the two, though. Next keeps the control strictly in the current scope whereas step follows the execution through function calls.
jdk

rtmistler 04-07-2015 06:50 AM

Quote:

Originally Posted by shyjuu (Post 5343632)
I want to go line by line execution, similar to Borland C, in which when i press F7 it executes the code line by line, Is this possible in gcc.

:banghead: Who in the world still uses Borland C? I honestly have not heard that word this entire millennium. I shouldn't knock it, I used it a lot back in the 80's as well as TurboDebugger, which was also a Borland product I believe.

What brianL and jdkaye said. GDB is very good and if you're not going to take the time to review an answer or ask a follow up, but just present your terms on exactly what you want, then you're not going to be too successful in your Linux ventures.

A thing to note is that GDB integrates very well with Emacs and when you run GDB from within Emacs, you get some more helpful UI based controls, all available in the command line, but just more well presented within Emacs.

So, run Emacs to create a Hello World! C source, you actually can compile from within Emacs using the compile command, but you should edit the command to just be "gcc -o <output-file-name> <source-file-name> and it will do a simple compile. You then can debug from within Emacs by issuing the gdb command from with Emacs. I think you'll like the interface, if you actually give it a try.

shyjuu 04-07-2015 02:23 PM

Quote:

Originally Posted by brianL (Post 5343466)
GDB is the main Linux debugger. Here's one of many tutorials found by a websearch:
http://www.cprogramming.com/gdb.html

but in ns-2 every c++ objects will be converted to Otcl objects, so how can i debug line by line
I just want to know while aodv.cc, aodv.hh executes which function is called when

rtmistler 04-07-2015 02:29 PM

Quote:

Originally Posted by shyjuu (Post 5343990)
but in ns-2 every c++ objects will be converted to Otcl objects, so how can i debug line by line
I just want to know while aodv.cc, aodv.hh executes which function is called when

GDB works with C++


All times are GMT -5. The time now is 03:48 PM.