gpt4 book ai didi

embedded - GDB 脚本到 MOCK

转载 作者:行者123 更新时间:2023-12-02 05:10:17 26 4
gpt4 key购买 nike

我正在尝试使用 GDB 模拟一个函数(用于单元测试父函数)。一种方法是在您打算模拟的函数中设置一个断点并使用 GDB return 命令。

但是,当使用 GDB call 命令时,我无法执行相同的操作。

(gdb) b secret_checkBreakpoint 1 at 0x80483ba: file ut_gdb.c, line 6.(gdb) startTemporary breakpoint 2 at 0x804843c: file ut_gdb.c, line 34.Starting program: ut.binTemporary breakpoint 2, main () at ut_gdb.c:3434          int res = 0;(gdb) bt#0  main () at ut_gdb.c:34(gdb) call fact(3)Breakpoint 1, secret_check (check_type=1) at ut_gdb.c:66               if(check_type == 0){The program being debugged stopped while in a function called from GDB.Evaluation of the expression containing the function(fact) will be abandoned.When the function is done executing, GDB will silently stop.(gdb) bt#0  secret_check (check_type=1) at ut_gdb.c:6#1  0x080483ff in fact (n=3) at ut_gdb.c:19#2  #3  main () at ut_gdb.c:34

这是 GDB 的限制吗?

最佳答案

我希望如此。限制可能是 GDB 不能同时在两个断点处停止(并且能够从两个断点处继续)。 GDB 必须维护有关程序停止的当前点的信息,以便能够继续。为了支持您正在尝试做的事情,它需要维护一堆“继续”状态,并具有某种能力让您指定要从哪个状态继续。

关于embedded - GDB 脚本到 MOCK,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6269038/

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