是否可以设置“数据断点”?关于返回值

发布于 2024-09-11 03:44:41 字数 239 浏览 0 评论 0原文

场景是:有很深的调用层次,每次调用都会返回HRESULT。如果发生错误,函数将返回 S_FALSE 或 S_ERROR,如果调用返回错误,调用者将直接返回错误代码。通常所有函数都会返回S_OK。 因此,当调试一个问题时,我需要做很多次试验,看看哪个调用返回!S_OK,然后更深入,继续......直到找到导致错误的最终位置。

我想知道它是否能够在返回值(eax?)上创建“数据断点”,因此当返回值更改或返回值等于某个值时,程序可以停止......

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 ...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不忘初心 2024-09-18 03:44:41

为什么不直接将返回值分配给变量,每当变量等于某个值时就在变量上设置一个断点(这称为条件断点),然后只返回变量而不是返回 S_FALSE/S_ERROR/S_OK 等?

例如:

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
}

编辑
如果您不想/无法更改代码,您可能需要查看此线程:
是否可以根据函数将要返回的内容在函数末尾设置条件断点?

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文