C++ 强制转换指向lldb中类型的指针
我想调试第三方c++库,是否可以将指针强制转换为可打印类型 我试过了C++ 强制转换指向lldb中类型的指针,c++,pointers,casting,lldb,C++,Pointers,Casting,Lldb,我想调试第三方c++库,是否可以将指针强制转换为可打印类型 我试过了 (lldb) expr static_cast<AGInfo*>(0x0000002fcdccc060) 有办法吗 感谢lldb使用clang作为其表达式解析器,因此它只做了一些修改,就相当严格地遵守了C++的要求。clang不允许您执行源代码中尝试的操作: > cat foo.cpp struct Something { int first; int second; }; int main()
(lldb) expr static_cast<AGInfo*>(0x0000002fcdccc060)
有办法吗
感谢lldb使用clang作为其表达式解析器,因此它只做了一些修改,就相当严格地遵守了C++的要求。clang不允许您执行源代码中尝试的操作:
> cat foo.cpp
struct Something
{
int first;
int second;
};
int
main()
{
Something mySomething = {10, 30};
long ptr_val = (long) &mySomething;
Something *some_ptr = static_cast<Something *>(ptr_val);
return some_ptr->first;
}
> clang++ -g -O0 -o foo foo.cpp
foo.cpp:12:25: error: cannot cast from type 'long' to pointer type 'Something *'
Something *some_ptr = static_cast<Something *>(ptr_val);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
在实际源代码中编译,并将在lldb表达式解析器中工作
> cat foo.cpp
struct Something
{
int first;
int second;
};
int
main()
{
Something mySomething = {10, 30};
long ptr_val = (long) &mySomething;
Something *some_ptr = static_cast<Something *>(ptr_val);
return some_ptr->first;
}
> clang++ -g -O0 -o foo foo.cpp
foo.cpp:12:25: error: cannot cast from type 'long' to pointer type 'Something *'
Something *some_ptr = static_cast<Something *>(ptr_val);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Something *some_ptr = (Something *) ptr_val;