views:

15

answers:

1

The scenario is: there is a deep call hierarchy and each call will return HRESULT. If something bad happens, function will return S_FALSE or S_ERROR, and if a call return error, the caller will directly return the error code. normally all function will return S_OK. So when debug an issue, I need to do many trials, see which call returns !S_OK, and go deeper, and go on... until I found the ultimate place which cause a error.

I am wondering is it able to create a "data breakpoint" on return value (eax?) So when return value changed or return value equal to some value, the program can stop ...

A: 

Why not just assign the return value to a variable, set a break on the variable whenever it equals a certain value (this is known as a conditional breakpoint), and just return the variable instead of returning S_FALSE/S_ERROR/S_OK,etc.?

ex:

public long yourFunc() {
    long ret = S_OK;

    if (someCondition) {
        ret = S_ERROR;
    }
    return ret; // set a conditional breakpoint here, and put in
                // a condition where ret != S_OK
}

EDIT
If you don't want to/can't change the code, you may want to check out this thread: http://stackoverflow.com/questions/1378594/is-it-possible-to-set-a-conditional-breakpoint-at-the-end-of-a-function-based-on

dcp
Because there is a deep call hierarchy, for example,ret = some_other_function();if some_other_function return error, I have to repeat this process again. If there is a recursive function dealing with a tree-like data structure, I have to repeat many times ... So I am asking is there anything like data breakpoint on return value :)
superb
I don't understand why you would have to repeat the process many times if recursion is used. The conditional breakpoint would fire as soon as the condition was met, regardless of how deep you were in the recursive descent. Anyway, if you don't want to change your code I posted a related link in my edit which may help. Good luck :).
dcp
the problem is that in the method it does not return at a single place, many piece of code seems like:hr = some_call(...);if (FAILED(hr)) return hr;So conditional breakpoint won't work ....I will check the link you posted ..
superb