1

我需要从 TRACE32 脚本检查函数的返回值。

阅读文档,我看到了一种可能的解决方案,即读取程序计数器(IP)寄存器,然后在 PC 指向的地址执行指令后从那里获取值。

是否有任何其他函数直接返回函数返回的值?

4

1 回答 1

1

每个函数通常都有一个名为“return”的伪变量。您可以在窗口中看到sYmbol.Browse.Var \\*\*\<myfunc>\*(其中myfunc是您的函数的名称)

您可以使用 PRACTICE 函数获取任何变量的值Var.VALUE(<variable>)

所以你得到函数myfunc()的返回值

GO sYmbol.EXIT(myfunc)   // go to return statement of myfunc
PRINT Var.VALUE(return)  // get the return value

如果您想进行模块测试,另一种方法可能对您感兴趣:
因此,您只想int func3(int a, int b)使用随机参数(例如 5 和 3)调用函数并获取返回值。在这种情况下,请执行以下操作:

Var.NEWLOCAL \x        // create artificial variable on the PRACTICE stack
Var.Set \x=func3(5,3)  // execute func3() with arguments 5 and 3 on your CPU
PRINT Var.VALUE(\x)    // get the return value
于 2015-08-21T09:55:22.500 回答