LLDB 为局部变量给出 "use of undeclared identifier" 错误

LLDB gives "use of undeclared identifier" error for local variable

在下面的函数中,我无法在 LLDB 中看到 'recordMap'。 for 循环打印键,recordType 设置正确,但 'p recordMap' 给出错误 "use of undeclared identifier"。我可以在 LLDB 中看到变量 'recordType' 正常,所以我在正确的范围内。当我在 LLDB 中输入 'recordMap' 时,它会自动完成,就像它在那里一样。

我已将调试和发布的优化设置为 "none"。这可能是什么!?

void MezNetworkController::showRecord( std::map<string, MezSQLData*> recordMap ) {

    for( auto item : recordMap )
        printf( " KEY: %s\n", item.first.c_str() );

    int recordType = (int) recordMap["messageType"]->intValue();
    printf( recordType );
}

下面是lldb中'image lookup -va $pc'的结果:

      Address: Mezmo[0x00015ed0] (Mezmo.__TEXT.__text + 45272)
      Summary: Mezmo`MezNetworkController::showRecord(std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, MezSQLData*, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, MezSQLData*> > >) + 780 at MezNetworkController.cpp:774
       Module: file = "/Users/paulslocum/Dropbox/_iOS/_414 Messenger_/DerivedData/414 Messenger/Build/Products/Debug-iphoneos/Mezmo.app/Mezmo", arch = "armv7"
  CompileUnit: id = {0x00000000}, file = "/Users/paulslocum/Dropbox/_iOS/_414 Messenger_/414 Messenger/MezNetworkController.cpp", language = "ISO C++:1998"
     Function: id = {0x400015fa2}, name = "showRecord", range = [0x000c2bc4-0x000c42a6)
     FuncType: id = {0x400015fa2}, decl = MezNetworkController.hpp:60, clang_type = "void (void)"
       Blocks: id = {0x400015fa2}, range = [0x000c2bc4-0x000c42a6)
    LineEntry: [0x000c2ed0-0x000c2ee6): /Users/paulslocum/Dropbox/_iOS/_414 Messenger_/414 Messenger/MezNetworkController.cpp:774:38
       Symbol: id = {0x000001f8}, range = [0x000c2bc4-0x000c42a8), name="MezNetworkController::showRecord(std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, MezSQLData*, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, MezSQLData*> > >)", mangled="_ZN20MezNetworkController10showRecordENSt3__13mapINS0_12basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEEP10MezSQLDataNS0_4lessIS7_EENS5_INS0_4pairIKS7_S9_EEEEEE"
     Variable: id = {0x400015fb6}, name = "this", type = "MezNetworkController *", location =  [sp+1068], decl = 
     Variable: id = {0x400015fc5}, name = "recordType", type = "int", location =  [sp+1028], decl = MezNetworkController.cpp:774

变量 "recordMap" 未在 'image lookup' 输出中列出;这意味着它实际上不适用于 LLDB 给定您当前的位置

这通常是编译器生成的调试信息的问题,因为它遗漏了变量。当调试器没有被告知某个变量或该变量在内存中的位置时,不幸的是它无能为力。

作为解决方法,您可以手动打印 key/value 绑定(我看到您已经在为密钥执行此操作),但我会向 clang 编译器提交一份关于缺失变量的错误报告