开发者

Is it able to setup a "data breakpoint" on return value

开发者 https://www.devze.com 2023-01-08 01:23 出处:网络
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 direct

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 a开发者_开发百科ll 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 ...


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: Is it possible to set a conditional breakpoint at the end of a function based on what the function is about to return?

0

精彩评论

暂无评论...
验证码 换一张
取 消