c - 给定一个指针,gdb 如何获取它的类型?

标签 c gdb

gdb 如何知道指针指向 intstruct 或任何其他数据类型?

最佳答案

来自:Examining the Symbol Table

whatis expr

Print the data type of expression expr. expr is not actually evaluated, and any side-effecting operations (such as assignments or function calls) inside it do not take place. See section Expressions.


ptype expr

ptype

Print a description of the type of expression expr. ptype differs from whatis by printing a detailed description, instead of just the name of the type. For example, for this variable declaration:

struct complex {double real; double imag;} v;

这两个命令给出了这个输出:

(gdb) whatis v
 type = struct complex
(gdb) ptype v
 type = struct complex {
    double real;
    double imag;
 }

关于c - 给定一个指针,gdb 如何获取它的类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6132922/

相关文章:

c++ - 无法解决 SIGABRT

c - 反汇编C,替换操作码

C if 语句将两个整数变量与同一个常量进行比较

c - 在阻塞 recv 调用的情况下,如果对等方系统重新启动,则调用不会来自 out recv。为什么?

c - c中的字符串指针和字符数组

c++ - gdb 调试 valgrind 未检测到的双重释放(?)

c - Eclipse CDT 中的 GDB 崩溃 : Error in `gdb' : free(): invalid next size (fast):

c - strstr() 始终返回 null

c - openssl 头文件中的 FIPS_rsa_x931_derive_ex 函数

c++ - 如何查找程序中的非法指令?