lldb 抱怨名为 "this" 的变量
lldb complains about variable named "this"
我正在使用 Xcode/lldb 调试一些 C 代码。但是我得到这个错误
(lldb) p (int)g_list_position(start, next)
(int) [=11=] = 1
(lldb) p (int)g_list_position(start, this)
error: expected unqualified-id
error: invalid use of 'this' outside of a non-static member function
所以显然 lldb things "this" 是对 class 的引用,尽管它在 C 中是一个完全有效的 var(它的值应该是 0)。有什么方法可以在 lldb 中转义这个名字吗?
不,lldb 中的表达式求值器用一些 C++ 包装你的表达式(在源代码级别)以传递参数。我能想到的唯一建议是在 this
中获取地址指针并将其显式放入表达式中。表达式求值的目标是您可以在程序中复制一行源代码并将其作为 lldb 中的表达式执行。但这是一个行不通的极端情况——C 中的变量在 C++ 中是保留字。
我正在使用 Xcode/lldb 调试一些 C 代码。但是我得到这个错误
(lldb) p (int)g_list_position(start, next)
(int) [=11=] = 1
(lldb) p (int)g_list_position(start, this)
error: expected unqualified-id
error: invalid use of 'this' outside of a non-static member function
所以显然 lldb things "this" 是对 class 的引用,尽管它在 C 中是一个完全有效的 var(它的值应该是 0)。有什么方法可以在 lldb 中转义这个名字吗?
不,lldb 中的表达式求值器用一些 C++ 包装你的表达式(在源代码级别)以传递参数。我能想到的唯一建议是在 this
中获取地址指针并将其显式放入表达式中。表达式求值的目标是您可以在程序中复制一行源代码并将其作为 lldb 中的表达式执行。但这是一个行不通的极端情况——C 中的变量在 C++ 中是保留字。