gpt4 book ai didi

c - GDB 函数参数条件中断

转载 作者:太空狗 更新时间:2023-10-29 16:38:35 24 4
gpt4 key购买 nike

我想在函数参数大于特定值时设置断点。下面的虚拟代码:

int main(void)
{
uint64_t num = 123456;
uint64_t x = 847534;

uint64_t other = (num*x) - (x/num);

.... other stuff here (multithreaded stuff)

calc(other);
}

void calc(uint64_t size)
{
...do some stuff with size
}

我尝试通过以下方式设置断点:

(gdb) b calc if size == 852479

但它不知道大小是多少,因为它是我猜测的一个参数。如果参数等于某个数字,我将如何中断。中断对该函数的所有调用不是一个选项,因为它在多线程环境中被调用了十亿次。

最佳答案

gdb 提示:

break "file.c":100 if (size=852479)

break "file.c":100 if (size>852479)

这里我假设您想要第 100 行的条件断点并且您的 src 文件是 file.c

即,如果您想在调用 calc 的行上打断,那么那将是第 100 行 - 适当修改(您还必须将 size 替换为 other 在这种情况下)

如果您使用了行号。那是 calc 函数中的第一个语句之一,那么您将坚持使用 size

关于c - GDB 函数参数条件中断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26892091/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com