【问题标题】:C struct - lldb expression failsC struct - lldb 表达式失败
【发布时间】:2018-08-27 16:19:04
【问题描述】:

除非我声明一个默认变量,否则为什么 lldb 的 expression 不能理解我的 C 结构?

struct YD_MENU {
    char menu_name[10];
    int menu_option;
};

int main() {

    return 0;
}

在 main 中添加断点...

(lldb) exp struct YD_MENU $b
error: variable has incomplete type 'struct YD_MENU'
forward declaration of 'YD_MENU'

如果我将其更改为以下...

struct YD_MENU {
    char menu_name[10];
    int menu_option;
} default_menu;

(lldb) exp struct YD_MENU $a 工作正常。

我认为这与Why can't LLDB evaluate this expression? 有关,但建议的答案不起作用。

(lldb) version
lldb-1000.0.29

【问题讨论】:

    标签: debugging lldb


    【解决方案1】:

    clang(以及 gcc)在不为“未使用的类型”发出类型信息方面相当激进。当您执行import <Cocoa/Cocoa.h> 之类的操作时,会出现很多类型,它必须这样做以保持调试信息大小合理。这就是为什么当你定义一个结构但不使用它时,lldb 看不到类型。关于类型的信息实际上是 lldb 看不到的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-06-27
      • 2017-10-14
      • 2015-05-20
      • 2018-04-24
      • 1970-01-01
      • 2012-09-16
      • 1970-01-01
      • 2022-01-21
      相关资源
      最近更新 更多