c - 如何在gdb中获取结构的基本数据类型

标签 c gdb

在 gdb 中有什么方法可以获取结构的基本数据类型?

假设以下结构

typedef struct _trial
{
        int i;
        double j;
}trial_t;

在 gdb 中

(gdb) whatis trial_t
type = struct _trial
(gdb) whatis _trial
No symbol "_trial" in current context.
(gdb)

任何解决方法?

我知道这适用于简单的 typedef

typedef unsigned char BYTE; 
BYTE var;  
(gdb)whatis var 
type = BYTE 
(gdb)whatis BYTE 
BYTE = unsigned char 

最佳答案

你可能需要ptype

ptype accepts the same arguments as whatis, but prints a detailed description of the type, instead of just the name of the type.

(gdb) ptype struct _trial

甚至:

(gdb) ptype trial_t

Contrary to whatis, ptype always unrolls any typedefs in its argument declaration

关于c - 如何在gdb中获取结构的基本数据类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11976218/

相关文章:

c - 每次调试时变量的地址都会改变吗

c - 错误: No such file or directory

克隆系统调用从其关联函数返回后退出

debugging - CLion 中的 J-Link GDB 调试

linux - 如何在 QEMU 上的 GDB 中单步执行 ARM 程序集?

c++ - 使用 -O3 时确定段错误的原因?

c++ - 为什么没有更多地使用clang?

c++ - OpenCV 与 cv::FAST 有问题

c - 表达式 "+ + a"是什么意思?

c - 需要帮助来理解 C 中的结构