【发布时间】:2019-02-06 22:48:51
【问题描述】:
在我的main() 中,堆栈上有一些变量(reader),它的类型为OggReader(一些自己的struct/class)。此变量在 Qt Creator / GDB 调试器中显示为 <not accessible>:
然后,我在这个类上调用了一些函数,这样this 应该指向这个reader 对象。但是Qt Creator/GDB没有显示this的内容:
为什么?我该如何解决这个问题?
这是 Ubuntu 16.04 上的 Qt Creator 4.0.2。
我使用带有选项-g -O0 -g3 -ggdb 的g++ 5.4.0。
我使用 gdb 7.11.1。
OggReader 类:
struct OggReader {
Page buffer_page_;
std::map<uint32_t, VorbisStream> streams_;
size_t packet_counts_;
std::shared_ptr<IReader> reader_;
ParseCallbacks& callbacks_;
OggReader(ParseCallbacks& callbacks) : packet_counts_(0), callbacks_(callbacks) {}
...
};
Page:
struct Page {
PageHeader header;
uint8_t segment_table[256]; // page_segments_num in len
uint32_t data_len;
uint8_t data[256 * 256];
...
};
PageHeader:
struct __attribute__((packed)) PageHeader {
char capture_pattern[4]; // should be "OggS"
uint8_t stream_structure_version; // should be 0
uint8_t header_type_flag; // 0x1: continued, 0x2: first (bos), 0x4: last (eos)
int64_t absolute_granule_pos; // end PCM sample position of the last packet completed on that page
uint32_t stream_serial_num;
uint32_t page_sequence_num;
uint32_t page_crc_checksum;
uint8_t page_segments_num;
};
也许__attribute__((packed)) 以某种方式混淆了 GDB?
即使我明确地这样做了
Page* dummy = &buffer_page_;
在一些Page 成员函数中,它也没有显示这个dummy ptr 的内容(它与this 的地址相同,因为buffer_page_ 从this 的零偏移开始)。
This question 是相关的,尽管我认为这与this 无关(有些人拥有struct/class),而是与标准类型(std::string 左右)有关。此外,所有给定的解决方案都没有效果,或者不适用。例如。 “加载系统 GDB 漂亮打印机”已被禁用。
【问题讨论】:
-
请指定使用的编译器/调试器版本和构建选项。
-
编译
OggReader代码的选项集是否相同?我的意思是它不是来自一些具有不同选项的静态库预构建? -
是的(项目本身叫做OggReader)。
标签: c++ gdb qt-creator