views:

9212

answers:

15

I teach a sort of "lite" C++ programming course to novices ("lite" meaning no pointers, no classes, just plain old C, plus references and STL string and vectors). Students have no previous experience in programming, so I believe that using an interactive debugger would help them understand program flow, variables, and recursion.

The course is taught in Linux. Teaching them to use gdb is just overkill (they will not use nor understand most features). I just need something simple but easy to use: to see at which line the program is now, what is in the stack (local variables, previous calls, etc.). I look something similar to old Turbo Pascal or Turbo C++ Borland's debugger, or Visual Studio debugger.

Thank you,

+9  A: 

ddd is a graphical front-end to gdb that is pretty nice. One of the down sides is a classic X interface, but I seem to recall it being pretty intuitive.

ajbl
I can't praise DDD enough, but since he says no pointers, you lose much of its' advantage - no need for the top pane in http://www.gnu.org/software/ddd/all.png
Mawg
DDD really is a great frontend. I used to teach C++. My students never could understand how to use gdb, but after showing them a quick tour of ddd (just the very basics, and telling them to compile with -g) they quickly became much more proficient at debugging their code and understanding what happened. The UI might look "old and dated", but why fix what obviously works?
wasatz
+3  A: 

This might not be the best answer, but I would suggest you teach them only the gdb features that they really need to know. Being in industry now, I would have appreciated that back then....

Of course, the other option is to follow the curriculum your university has laid out. Give them the basics they'll at least need to get through the rest of their program.

jdt141
+4  A: 

ddd

It's still probably overkill (I'm pretty sure any kind of debugger would be overkill given your description of the course...), but ddd is a fairly simple front-end for gdb.

http://www.gnu.org/software/ddd/

Josh Wright
+2  A: 

cgdb, a vim like front-end for gdb.

+1  A: 

ddd is indeed a good choice to start, specially if you are running on linux.

You can also go for Eclipse with the c++ plugin, which should run on linux/mac/windows. Another advantage of this approach is that they will play with the Eclipse platform.

Alexandre Hauser
+9  A: 

You may want to check out Eclipse CDT. It provides a C/C++ IDE that runs on multiple platforms (e.g. Windows, Linux, Mac OS X, etc.). Debugging with Eclipse CDT is comparable to using other tools such as Visual Studio.

You can check out the Eclipse CDT Debug tutorial that also includes a number of screenshots.

Jon Ball
+6  A: 

Perhaps it is indirect to gdb (because it's an IDE), but my recommendations would be KDevelop. Being quite spoiled with Visual Studio's debugger (professionally at work for many years), I've so far felt the most comfortable debugging in KDevelop (as hobby at home, because I could not afford Visual Studio for personal use - until Express Edition came out). It does "look something similar to" Visual Studio compared to other IDE's I've experimented with (including Eclipse CDT) when it comes to debugging step-through, step-in, etc (placing break points is a bit awkward because I don't like to use mouse too much when coding, but it's not difficult).

HidekiAI
+3  A: 

Another vote for ddd! Not only is it a decent, free OSS graphical debugger, but it can gently introduce gdb itself. Some of your beginner students may end up wanting to delve deeper, and having a "magic door into the underworld" might actually entice them...

Kevin Little
+1  A: 

I've used KDBG under Linux before - it seems to be fairly good

+1  A: 

I've been in the situation, too many times, where we are porting our applications to multiple platforms and we do not have a toolset that comes with a nice IDE. Often times, it is left to the developer to fend for themselves and find the tools then need (to be productive). What tools are almost always available in a Unix/Linux environment:

  • gdb
  • vi/vim
  • emacs

Ignoring compilers.

I think that learning the basics with gdb will pay huge dividends over time for any working developer. Many of the heroes in the offices I have been in are the ones that understand how to navigate the program stack, jump between threads, and see what the program is doing.

GDB is an excellent tool to teach the basics of program execution, how to decode what is going on in your application, and then maybe, just maybe, find a bug. Of course if GDB and other debuggers were that good at helping us find bugs we would not have to result to the many other tricks required to solve program bugs. That said, if more programmers knew how to interactively get into their applications and see what was going on we would all save a lot of time.

Mark Thistle
+1  A: 

You may also use the integration of GDB within Emacs. You invoke it with M-x gdb. Then you can:

  • You may set a breakpoint directly in the buffer displaying your source code.
  • In the toolbar you have the usual Step into/Finish function/... operations.
  • you have access to the GDB command line.

You should be quite confortable with the Emacs user experience though.

Pierre
+2  A: 

I see that a few recommend DDD (my personal favorite), but since OP says "no pinters", it loses its advantage - as shown in the top pane of http://www.gnu.org/software/ddd/all.png - although it can still be useful for displaying seem arrays - as in http://www.gnu.org/software/ddd/plots.png

Op doesn't say how they edit their code. If he is trying to be "gentle", then maybe a simple text editor. perhaps an IDE is too complex for them? But, in the real world, they're probably going to have to learn to use one anyway (and increase their productivity).

Kdevelop is pretty good, but my personal choice is for Eclipse. It's cross platform, so might be more useful in "real Life". I also love its myriad plugins and woudl introduce them immediately to the DoxyGen plugin and ingrain the habit of docuemnting their code.

Mawg
+1  A: 

I work for TotalView Tech and we have a free-for-students version of our commercial linux C++ (also Fortran and MPI, and threads) debugger.

http://www.totalviewtech.com/academia/totalview_express.html

It is worth noting we also have deeply discounted pricing for "shared -- in classroom" licenses.

See http://www.totalviewtech.com/support/videos.html?via=resources#0 for some quick videos illustrating how the product works.

Some specific features that TotalView has for C++:

  • Automatic transformation of STL collection classes into something reasoanble
  • "Dive" on pointers to see what is pointed to
  • Easy "casting" of pointers to arrays
  • The ability to look at a single field of data in each instance of an object in an array of objects
  • Set a breakpoint on all instances of a class

Chris Gottbrath Product Manager TotalView Technologies

Chris Gottbrath
+1  A: 

CodeLite works pretty well, it use the same key shortcut as Visual Studio for debugging. But as it's a wxWidget program, there is a problem with the space bar in Ubuntu.

Raoul Supercopter
+1  A: 

Qt Creator, apart from other goodies, also has a good debugger integration, for CDB, GDB and the Symnbian debugger, on all supported platforms. You don't need to use Qt to use the Qt Creator IDE, nor do you need to use QMake - it also has CMake integration, although QMake is very easy to use.

You may want to use Qt Creator as the IDE to teach programming with, consider it has some good features:

  • Very smart and advanced C++ editor
  • Project and build management tools
  • QMake and CMake integration
  • Integrated, context-sensitive help system
  • Excellent visual debugger (CDB, GDB and Symbian)
  • Supports GCC and VC++
  • Rapid code navigation tools
  • Supports Windows, Linux and Mac OS X
iconiK