简体   繁体   English

如何在return语句中全局设置条件断点?

[英]How to set conditional breakpoint on return statement globally?

I have a code full of functions like: 我的代码充满了以下功能:

bool f_i() 
{
    if (!f_0()) {
        return false;
    }
    if (!f_1()) {
        return false;
    } 
    // ...
    if (!f_n()) {
        return false;
    } 
    return true;
}
// etc...

On some step of execution some callee can return false , and false propagates through all the callers. 在执行的某个步骤中,一些被调用者可以返回false ,而false传播通过所有调用者。 It is hard to write error messages at the moment (code is rapidly changed). 此刻很难编写错误消息(代码快速更改)。 During debugging it is excessive to have error mesages before every return false; 在调试期间,在每次return false;之前有错误消息return false; .

Is it possible to set conditional (condition: say, function return false ) breakpoint on return statment globally, using GDB ? 是否可以使用GDB在全局return语句上设置条件(条件:比如,函数返回false )断点?

On some step of execution some callee can return false 在某些执行步骤中,一些被调用者可以返回false

As I understand, you want to find the first function which returned false inside f_i() . 据我所知,你想找到第一个在f_i()返回false函数。 You can use reverse debugging for this. 您可以使用反向调试 You can: 您可以:

  1. finish current frame execution 完成当前帧执行

    (gdb) fin (gdb)fin

  2. step backwards, if return value is false 如果返回值为false ,则向后退一步

    (gdb) reverse-step (gdb)反向步骤

  3. if you need, you can continue to go backwards, deeper into false propagation calls 如果需要,您可以继续向后,更深入地进行false传播呼叫

    (gdb) reverse-fin (gdb)反向鳍
    (gdb) reverse-step (gdb)反向步骤

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM