gpt4 book ai didi

python - 如何使用 Python 从 gdb 访问 C++ 程序的变量

转载 作者:行者123 更新时间:2023-11-30 05:15:11 26 4
gpt4 key购买 nike

如何使用 Python 从 gdb 访问这些值?:

some_array_smartptr->operator[](0)->item // no errors are checked for sake of clarity

在 gdb 中,这一行工作正常,但我不知道如何在 Python 中使用它,因为我正在实现自动化测试。

请注意,vector 和 smartptr 都不是标准的,而是手动编写的。语义是一样的。

最佳答案

gdb.parse_and_eval() 应该完全按照您对实时进程调试的要求执行。

Documentation .

I'd like to iterate through some arrays an so on.

parse_and_eval 返回一个 gdb.Value。获得该值后,您可以使用任何 Value 方法进行进一步访问。

Example .

关于python - 如何使用 Python 从 gdb 访问 C++ 程序的变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43209899/

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