0

我得到错误

lldb: /home/hannes/.llvm/llvm/tools/clang/lib/AST/RecordLayoutBuilder.cpp:2271: uint64_t ::RecordLayoutBuilder::updateExternalFieldOffset(const clang::FieldDecl *, uint64_t): 断言`ExternalFieldOffsets.find( Field) != ExternalFieldOffsets.end() && "Field does not have an external offset"' 失败。中止(核心转储)

当我尝试打印vector<string>. 有谁知道为什么会发生这种情况,以及如何解决?等效的在 gdb 中工作得很好(有很多原因我宁愿使用/必须使用 lldb 而不是 gdb)。

我正在运行带有 llvm、clang 和 lldb 主干的 Ubuntu 12.10。

程序、构建指令和 lldb 命令序列:

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using std::for_each;
using std::begin;
using std::end;

int main() {
    std::vector<std::string> vec{"Hello","World","!"};
    for_each(begin(vec),end(vec),[](const std::string& s) {
    std::cout << s << " ";
      });
    std::cout << std::endl;
    return 0;
}

clang++ -g -c -std=c++11 main.cpp
clang++ -std=c++11 main.o -o test

lldb test 
Current executable set to 'test' (x86_64).
(lldb) break -n main
invalid command 'breakpoint -n'
(lldb) breat set -n main
error: 'breat' is not a valid command.
(lldb) break set -n main
Breakpoint 1: where = test`main + 26 at main.cpp:5, address = 0x0000000000400aea
(lldb) run
Process 24489 launched: '/home/hannes/Documents/Programming/CXX/test/test' (x86_64)
Process 24489 stopped
* thread #1: tid = 0x5fa9, 0x0000000000400aea test`main + 26 at main.cpp:5, stop reason = breakpoint 1.1
    frame #0: 0x0000000000400aea test`main + 26 at main.cpp:5
   2    #include <string>
   3    
   4    int main() {
-> 5        std::vector<std::string> vec{"Hello","World","!"};
   6        return 0;
   7    }
n
Process 24489 stopped
* thread #1: tid = 0x5fa9, 0x0000000000400c72 test`main + 418 at main.cpp:6, stop reason = step over
    frame #0: 0x0000000000400c72 test`main + 418 at main.cpp:6
   3    
   4    int main() {
   5        std::vector<std::string> vec{"Hello","World","!"};
-> 6        return 0;
   7    }
frame variable
lldb: /home/hannes/.llvm/llvm/tools/clang/lib/AST/RecordLayoutBuilder.cpp:2271: uint64_t <anonymous namespace>::RecordLayoutBuilder::updateExternalFieldOffset(const clang::FieldDecl *, uint64_t): Assertion `ExternalFieldOffsets.find(Field) != ExternalFieldOffsets.end() && "Field does not have an external offset"' failed.
Aborted (core dumped)

调试级别 10 的日志输出:

Logging from function (<frame object at 0x3172f20>, '/usr/lib/python2.7/dist-packages/lldb/formatters/cpp/gnu_libstdcpp.py', 141, '__init__', ['\t\tlogger = lldb.formatters.Logger.Logger()\n'], 0)
Providing synthetic children for a map named vec
Logging from function (<frame object at 0x3170d10>, '/usr/lib/python2.7/dist-packages/lldb/formatters/cpp/gnu_libstdcpp.py', 214, 'update', ['\t\tlogger = lldb.formatters.Logger.Logger()\n'], 0)
4

1 回答 1

0

如果你说帧变量--raw,会发生同样的事情吗?此命令旨在转储您的矢量禁用数据格式化程序。在特定情况下,您将获得(假设没有崩溃)向量的内存布局,而不是您存储在那里的字符串的打印输出。我主要是想弄清楚数据格式化程序是否参与了这个问题。

于 2013-02-26T05:55:29.043 回答