Monday, April 30, 2007

Zero to breakpoint in 10 seconds

We're getting close to our first release candidate, RC0, of CDT 4. One of the key objectives for CDT 4 was to simplify the new user experience. Thanks to some new features in the CDT like new project templates and in the Platform like contextual launching, we can now get you from a blank workspace to your first breakpoint in 10 seconds (faster if you type faster :).

Here's how:
  1. File->New Project.
  2. In the New Project Wizard, select C++ -> C++ project, click Next.
  3. Select the Executable project type, clicking the + and selecting one of the Hello World templates and if more than one Toolchain is listed, pick one. Type in the Project name and click Next.
  4. Fill in the form with information the template needs to generate your Hello World app, click Finish (or next to play with the build configurations, but the defaults are fine).
  5. Click the Build button in the toolbar, wait for the build to finish.
  6. Click the Debug button (one click debugging!) and accept the switch to the Debug perspective.

And you're done. The debugger hits the default breakpoint on main and you are set to go.

Give that we're not done yet with CDT 4, there is a caveat at the moment. The one click debugging only works with the MinGW integration. To set that up, simply run the MinGW compiler and gdb installers from www.mingw.org, or have MinGW installed in C:\MinGW. The CDT will automatically pick up the install location. We'll get the other ones (Cygwin, Linux, etc) working as by the time CDT 4 ships at the end of June.

10 comments:

  1. I went to go see what state debugging with Microsoft's debugger was in, but it looks like the code got refactored. It used to be in org.eclipse.cdt.debug.win32.core. Any ideas where that ended up?

    ReplyDelete
  2. The Microsoft debugger is on hold. It's current state can be found in CVS under org.eclipse.cdt/windows along with the build integration and the beginnings of C# edit and build support.

    ReplyDelete
  3. By the way, good work with the MinGW integration. I compile with it simply as a check for compatibility but rely mostly on the Visual Studio build (especially for debugging). This is a very welcome feature and hopefully I will have some time to try it out!

    ReplyDelete
  4. Last night I got ansy and tried build I200704302030 (the current RC0 candidate).

    I think it must have gotten confused since I have mingw and cygwin both installed; I selected a MinGW project with the 'hello world' template and when I ran it in choked on the opening bracket saying, "Previous frame inner to this frame (corrupt stack?)".

    I'll need to get it to recognize my MinGW directories and then see what happens.

    ReplyDelete
  5. I'm using Eclipse 3.3 and CDT 4.0 and I have both MinGW and Cygwin installed. I'm running Vista (not sure if this matters). No matter what I do I can't get GDB working either for Cygwin or MinGW. I have the GDB installed in both. For Cygwin, when I start the debugger the application I'm testing crashes right away and according the crash report it is because of the cygwin.dll file. So then the debugger complains there is no process to debug. For MinGW, I get a weird error, "No source available for "ntdll!LdrAccessResource() "" I've tried looking this error up but am having trouble finding plausible material. I have tweaked almost every setting in Eclipse. I can easily compile program in Cygwin and MinGW but am only able to run MinGW program inside Eclipse. Programs debugged using Cygwin can be ran in the Cygwin terminal. Any help would be appreciated. Thanks.

    ReplyDelete
  6. Chaz, I'm having the exact same problem. I simply cannot get the Eclipse/CDT implementation of the MinGW GDB debugger. Depending on how I tweak the Eclipse settings, I either get an error message stating "No source available for ntdll!LdrAccessResource()", or I get "Unable to set working directory: mi_cmd_env_cd: Usage DIRECTORY".

    The frustrating thing is that my gdb works perfectly from the command line. It only crashes when I try to use it graphically on Eclipse. Any ideas?

    ReplyDelete
  7. Yeah I'm getting the same result with Eclipse 3.4 now and Cygwin

    Eclipse compiles my code just fine. I copied the cygwin1.dll file into my c:\Windows directory and I can run the program I compiled just fine. But I still can't debug the application. I've tried making sure my Path variable has ";c:\cygwin\bin" in there and still the same problem.

    I orginally had Cygwin gdb selected but then it wouldn't even try to run the debugger but just gave an error that "gdb could not be found"

    I can switch from the Cygwin gdb to the mingw gdb which points automatically to where cygwin stores the gdb and I get the error No source available for "ntdll!LdrAccessResource() " again. Grrr, very fustrated. Any help would be wonderful.

    ReplyDelete
  8. There are so many people searching for ntdll!LdrAccessResource(), I need to update everyone.

    The fact is that there is an issue with gdb 6.8 and CDT that makes this happen and makes it very difficult to debug.

    I have no ETA on a solution but we are talking about it in the CDT community. Maybe CDT 6.0, maybe...

    ReplyDelete
  9. Luan Perdomo Young12:50 a.m. GMT+1

    I got the same problem and I could solve.

    Let "Load shared library symbols automatically" unchecked at Debugger options.

    I hope it helped you.

    ReplyDelete
  10. Hello thr..any updates on - No source available for "ntdll!LdrAccessResource() " error
    I have CDT 5.0.2 + gdb 6.8 + cygwin + windows

    Thanks in advance

    ReplyDelete