CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 12 of 12
  1. #1
    Join Date
    Mar 2001
    Posts
    2,529

    debugger demands more???

    Hey,

    How do I set a breakpoint to occur when a byte in a buffer changes from 0x04h to any other value? I am using MSVC 6.0 and Windows XP.

    The debugger complains hartily when I try to do this.

    Code:
    	unsigned char* pbuf = new unsigned char[256];
    	for (int i = 0; i < 256; i++)
    	{//INITIALIZE ALL DATA
    		*(pbuf+i) = 0x04;
    	}
    	for (i = 0; i < 256; i++)
    	{//CHANGE DATA TO SIMULATE RE-INITIALIZE SHARED MEM
    		*(pbuf+i) = i;
    	}
    	delete[] pbuf;
    Here is my example breakpoint:
    *(pbuf+100) != 0x04

    What is the best way to do this?

    TIA,

    ahoodin

  2. #2
    Join Date
    Jul 2003
    Posts
    731

    Re: debugger demands more???

    Do you try the menu Edit > Breakpoints and data tab?
    Good Answers, Good Points.

  3. #3
    Join Date
    Mar 2001
    Posts
    2,529

    Re: debugger demands more???

    Yep, that is how I am setting the breakpoints.
    In response when I start the debug session it also says that the breakpoints have been disabled.
    Any ideas?

  4. #4
    Join Date
    Feb 2005
    Location
    Pasadena, MD, USA
    Posts
    105

    Re: debugger demands more???

    Hi ahoodin,

    Setting Breakpoints When Values Change may be useful for you.

    Jeff

  5. #5
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: debugger demands more???

    Well, can't test right now with VC++ 6.0, but it works ok with VC++ 7.1.
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  6. #6
    Join Date
    Mar 2001
    Posts
    2,529

    Re: debugger demands more???

    I have the MSDN. I knew that stuff 5 years ago.
    Thanks. I still have the problem. Anybody?

    ahoodin

  7. #7
    Join Date
    Mar 2001
    Posts
    2,529

    Re: debugger demands more???

    Quote Originally Posted by cilu
    Well, can't test right now with VC++ 6.0, but it works ok with VC++ 7.1.
    Thanks Cilu,

    Will report back!

    ahoodin

  8. #8
    Join Date
    Jul 2003
    Posts
    731

    Re: debugger demands more???

    ye there is some catch associated with it, I can not seem to remember what was it.
    Good Answers, Good Points.

  9. #9
    Join Date
    Feb 2002
    Posts
    4,640

    Re: debugger demands more???

    Hmm, I can't seem to bring up the web page linked above, but you should be able to set the breakpoint. Then hit CTRL-B, to bring up the "Breakpoints" dialog. Now, highlight your breakpoint in the bottom list, and hit the "Condition" button. Enter the condition into the edit box, and hit OK.

    Note that the variable in question must be in the scope of the breakpoint, otherwise you won't "break".

    Viggy

  10. #10
    Join Date
    Mar 2001
    Posts
    2,529

    Re: debugger demands more???

    Quote Originally Posted by MrViggy
    Hmm, I can't seem to bring up the web page linked above, but you should be able to set the breakpoint. Then hit CTRL-B, to bring up the "Breakpoints" dialog. Now, highlight your breakpoint in the bottom list, and hit the "Condition" button. Enter the condition into the edit box, and hit OK.

    Note that the variable in question must be in the scope of the breakpoint, otherwise you won't "break".

    Viggy
    Good Job! This is great. Is it possible to configure the debugger to break when the value changes no matter what function call may be executing and bring up the call stack?

    ahoodin

  11. #11
    Join Date
    Mar 2001
    Posts
    2,529

    Re: debugger demands more???

    Additionally when I try to break on data tab with an expression, the IDE says unable to break on pBuf[100]!=0x04.

    WTH?

    ahoodin

  12. #12
    Join Date
    Feb 2002
    Posts
    4,640

    Re: debugger demands more???

    Sorry, I was swamped this past week...

    I've never played with this, but bring up the breakpoint properties dialog, and click on the "Data" tab. It looks like you can enter an "expression" (which I would guess, could also just be a variable) that will cause the debugger to break when the expression changes.

    As for the message, is "pBuf" within the scope of the breakpoint? That should work, I've used similar expressions to break when a string is a specific value (by entering pStr[0] == 'a' && pStr[1] == 'b', etc. Annoying, but it worked).

    Viggy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured