views:

181

answers:

3

There is a article in MSDN which provides the procedure: http://msdn.microsoft.com/en-us/library/aa295838(VS.60).aspx#_core_setting_a_breakpoint_when_a_register_expression_is_true

But it seems that i tis for visual studio 6 ... Actually I can not find the "Breakpoint" entry under "Edit" Menu...

Do you guys know how to do that? I want to break when EAX change to an error code so I can find the place where this error is returned..

Thanks!

A: 

Assuming you are using Visual Studio 2008, you can find it in its own Debug menu.

Gorpik
Thanks.. But could you give me a more detailed procedure?The steps in MSDN are:To break when a register expression is true1. From the Edit menu, click Breakpoints.2. Click the Data tab of the Breakpoints dialog box.3. In the Expression text box, type an expression that contains a boolean comparison operator, such as CS==0.4. In the Number Of Elements text box, type the number of bytes to monitor.5. Click OK to set the breakpoint.But I can not found the Data tab of Breakpoint window.. All I can do is add a function break or data break ...
Yingliu
A: 

You need to create a breakpoint. In the Breakpoint Windows ( Debug->Windows->Breakpoint ) right-click the BP and select condition.

In the condition-field you can just type the expression ( "eax == ebx" ).

DarthCoder
Yeah... But I need to either set a function breakpoint or data breakpoint, which will only stop when then function location is reached or the data is changed. This is not what exactly I want. I just want to stop when the eax is changed. And what is said in MSDN sounds exactly what I want ... just don't know how to do it...
Yingliu
BTW, I tried to add a data breakpoint with address=eax, but actually this breakpoint can not stop... even the content of eax is actually changed..
Yingliu
If you try out my desription you will see, that there are two radiobuttons in the dialog that opens when you select "Condition". There you can select if you want the condition to be evaluated or if you want break if the variable changes.
DarthCoder
Thanks for your reply... but I think we may have some misunderstanding.I read the breakpoint condition part in MSDN. And I think the breakpoint condition is only evaluated when the breakpoint is hit. But actually I want is to stop at the time when EAX is change to a certain value (error code). Because I have many function return this error code and I want to identity which function returns it...I know we can add a data breakpoint when a data is changed. I don't know whether we can add a breakpoint that stop when a register is changed...
Yingliu
@Yingliu: if you are saying that you want EAX checked after **every instruction**, I don't think VisualStudio will do that - you will need a lower-level debugger.
egrunin
Thanks ergunin. That's what I want ...The debugging scenario is, I've got error code like NULL_POINTER returned from server. But I have too many places return NULL_POINTER (this is a quite general error), so I have to start at out most function, manually walk through the whole call hierarchy, check return values. It is OK if it allows me to drag the instruction pointer back to step into the function which return that error code. But If not, and reproduce steps is tedious, that's quite painful.. Actually I want to check return value (EAX) <b>when function returns</b>, is that possible in VS?
Yingliu
A: 

Just to be explicit about what @DarthCoder said:

  1. First create a plain breakpoint, so there's something to edit
  2. Then Debug->Windows->Breakpoint brings up the list of breakpoints, including the one you just made
  3. Right-click on the breakpoint, pick "Condition"
  4. Enter the condition, such as eax==ebx
egrunin