【问题标题】:how to put a breakpoint inside a function if it's called through a specific function如果通过特定函数调用断点,如何在函数中放置断点
【发布时间】:2016-05-04 05:51:12
【问题描述】:

有3个功能:f1、f2、f3:

void f1()
{
   f3();
}

void f2()
{
   f3();
}

void f3()
{
   ....
}

我想在 f3 中的某处放置一个断点,但前提是 f3 是从 f1 调用的。

【问题讨论】:

标签: debugging gdb breakpoints conditional-breakpoint


【解决方案1】:

解决方案包括设置条件断点。 f3 的调用由int boolean 标识

代码:

#include <stdio.h>

int boolean =0;

void f3()
{

}

void f2()
{
    boolean = 1;
    f3();
}

void f1()
{
    boolean = 0;
    f3();
}


int main()
{

    f2();
    f1();
    f2();
    f1();   

    return 0;
}

仅当您来自 f2 时,才在 gdb 中设置 f3 中断

(gdb)b f3 if boolean==1

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多