• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 265
  • Last Modified:

Can''t put breakpoint in Release version but works in Debug version

Hi,
  If I put the breakpoint in Release version and try to debug, the breakpoint is automatically getting removed (Not all of them. 1 or 2 places) but it works in Debug version. I am using Visual studio.NET for unmaged C++ code.

Thanks in advance
0
kiru
Asked:
kiru
1 Solution
 
jkrCommented:
You'll need to add debugging information to your release build - enable that in your project settings.
0
 
jkrCommented:
See http://msdn.microsoft.com/library/en-us/vccore98/html/_core_turn_on_generation_of_debug_information_for_the_release_build.asp ("Turn on Generation of Debug Information for the Release Build"). This is VC6, but the prnciole appiles to more recent versions also.
0
 
jkrCommented:
Oh, and http://support.microsoft.com/default.aspx?scid=kb;en-us;291585 ("How to Create Debug Symbols for a Visual C++ Application") describes that for all versions.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
AxterCommented:
Check for code that is not initializing variables to NULL values.

The debug version will set variables to NULL or zero values, but the release version does not.
0
 
kiruAuthor Commented:
Thanks for the reply. I have Debug info enabled for Release version.
I think my question is not clear.
It is allowing me to put breakpoints but when I start debugging it is removing couple of them not all of them

For ex.
I put break points at Line1, Line3, Line 8, Line 10 etc When I press F5 it is removing the breakpoints at Line3 and Line 8.  When I start to step over Lines 3(Jumps from Line 2 to Line 4) & 8 are missed.
But this deosn't happen with Debug version builds

Hope I made it clear this time.

Thanks
0
 
jkrCommented:
That's most likely because the optimizations the compiler performs in the release build don't allow to correctly correllate the source lines to the debug information. Turn off the optimizations before debugging the release version.
0
 
kiruAuthor Commented:
Hi
 I set optimization as Disable and tried. Still same problem.

Here is the Code.

L1. LV_ITEM lvItem;
L2. lvItem.iItem = item_index;
L3. GetItem(&lvItem);

L4. Row *row= reinterpret_cast<Row*> (lvItem.lParam);

L5. delete prow;

I put the breakpoint  L2 through L5. When I start to debug (release version) it removes the break point on L2 & L4. When I try to stepover from L3 to L4 it misses L4 and goes directly to L5 and crashes at L5.
0
 
jkrCommented:
Hmm, that's strange - regarding the 'crash' - are you checking the return value of 'GetItem()', e.g.

if (GetItem(&lvItem))
{
 Row *row= reinterpret_cast<Row*> (lvItem.lParam);

 delete prow;
}

If 'GetItem()' returns 'FALSE', 'delete' will not have any valid data to delete.


0
 
waysideCommented:
No comment has been added to this question in more than 21 days, so it is now classified as abandoned..
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: jkr

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

wayside
EE Cleanup Volunteer
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now