Link to home
Start Free TrialLog in
Avatar of winward
winward

asked on

Debugging skips over breakpoints

Using C++ .NET 2003 and getting:

"The breakpoint will not currently be hit. No executable code is associated with this line."

My app links to my static library and when I try debugging either one, I can't debug any code from the library it calls, although I can debug the main app.  It skips over the breakpoint even if I try setting it after starting the debugger.  This is true if I set the breakpoint by function name or line number.

My configuration manager is set to debug (not release).  /ZI is being used for compile flags.  I've tried deleting my library then rebuilding to verify that it's using the correct one.  

Thanks for any help!
Avatar of guitaristx
guitaristx

It's a tricky thing debugging library code.  I would recommend opening the project that compiles the library, and debug the library - you'll have to point it to the app's .exe file.
Avatar of winward

ASKER

Thanks for the suggestion.  When I do this though, I still have the same problem.  I can debug the code from my main app but it skips over breakpoints I set in the library.  Before debugging, the breakpoints appear as solid red dots.  Once I start debugging, they appear as question marks.
>Before debugging, the breakpoints appear as solid red dots.  Once I start debugging, they appear as question marks.
This means that the source code you're trying to debug is not associated with the binary file (static lib) that the debugger runs. This may occur if: you're linking with a .lib located somwhere else than the output of the debugged source code, .pdb file missing or corrupted, etc.

If you have both the app and the library in the same VC++ solution, you can try this: set the library as the active project, set in the project properties under the 'Debugging' section, your app in the 'Command line' field. So you'll be debugging the library with your app as executable.
nonubik is correct - you must debug with the library's project set as the "active" project.  Don't debug the _app_, debug the _library_.  If you get a dialog asking for an executable file, you're on the right track =)
Avatar of winward

ASKER

Still not working.  Previously, I was using 2 instances of C++ .NET so I created a solution with 2 projects - one for the library and one for the library.  I set the library as the startup project and selected it.  I assume that one of these actions makes the library "active".  Also, the library was listed as an item of the app's project.  I removed the library item and set the app to depend on the library project and set the library to be built first.

With the library selected, I pressed F10.  After specifying the executable, I immediately saw the app's source code.  I continued stepping over instructions until I got to the first call to the library.  When I tried stepping into this, it simply stepped over it.

I'm beginning to wonder if a DLL would be easier.  At least this way I would know that my symbols are being loaded and there are explicit instructions in the KB for a DLL.  Of course, maybe this wouldn't solve the problem.  I've never done this before so I'd prefer to just stick with the static library.
Place breakpoints in the library source code. Start debugging with F5, not F10 (which is stet by step).
Your breakpoints should be active if the app links with your library that you're debugging.
Avatar of winward

ASKER

My app is not linking to the library I'm debugging.  It may be because my library and app are located in 2 different directories.  Perhaps my project settings are incorrect.  Which files should be in which directories? Or how can I set the project settings for the library and the app so that the app links to the library I'm debugging? Thanks.
ASKER CERTIFIED SOLUTION
Avatar of nonubik
nonubik

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of winward

ASKER

I haven't had a chance to try this yet.  Because of my earlier troubles and time constraints, I just merged the two projects and debugged.  This was effective but not the solution I wanted.  Anyway, I'll give nonubik the points for all of his help, and I when I do try again (whenever that may be???), I hope it will work :-) Thanks for all your input.
10x anyway :o)