Thread: can not set breakpoint in release mode

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    1,579

    can not set breakpoint in release mode

    Hello everyone,


    For the following code, I can not set breakpoint in release mode, but the same command in WinDbg works fine in debug mode. Anything wrong?

    Here is my Windbg command and output in release mode and source codes. I have tested in release mode breakpoint at foo does not take effect, but in debug mode it takes effect.

    Code:
    0:000> bp foo
    Bp expression 'foo' could not be resolved, adding deferred bp
    0:000> bp main
    0:000> bl
     0 eu                      0001 (0001) (foo)
     1 e 00000001`40001000     0001 (0001)  0:**** Test64bitDebug!main
    
    int foo (int a, int b)
    {
     return a+b;
    }
    int main()
    {
     int a1 = 100;
     int b1 = a1 + 100;
     a1 = foo (a1, b1);
     return 0;
    }

    thanks in advance,
    George

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    Probably - in the release mode the line of code does not exists in the exe - removed by the code optimizer... So you'll need to find a line that was not removed and put th ebreakpoint there
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  3. #3
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Not really a good idea to rely on breakpoints in release mode or for that matter try to debug while in release mode.

  4. #4
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    If you don't mind setting the breakpoints at compile time you can use this instead
    Code:
    __asm { int 3};
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  5. #5
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by vart View Post
    Probably - in the release mode the line of code does not exists in the exe - removed by the code optimizer... So you'll need to find a line that was not removed and put th ebreakpoint there
    Yes, it could for example have inlined the function, and if the function is also static, there would be no function to set a breakpoint in. Study the assembler output of the generated code to determine what happened during the compile phase.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 6 measly errors
    By beene in forum Game Programming
    Replies: 11
    Last Post: 11-14-2006, 11:06 AM
  2. Replies: 4
    Last Post: 09-16-2006, 07:11 PM
  3. The new FAQ
    By Hammer in forum A Brief History of Cprogramming.com
    Replies: 34
    Last Post: 08-30-2006, 10:05 AM
  4. C help for network animator
    By fastshadow in forum Tech Board
    Replies: 7
    Last Post: 03-17-2006, 03:44 AM
  5. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM