尝试打印矢量时lldb断言失败

时间:2013-02-25 12:46:15

标签: c++ clang lldb

我收到错误

  
    

lldb:/home/hannes/.llvm/llvm/tools/clang/lib/AST/RecordLayoutBuilder.cpp:2271:intint64_t :: RecordLayoutBuilder :: updateExternalFieldOffset(const clang :: FieldDecl *,uint64_t):断言`ExternalFieldOffsets .find(Field)!= ExternalFieldOffsets.end()&& “字段没有外部偏移”'失败。     中止(核心倾销)

  

当我尝试打印vector<string>时。有谁知道为什么会这样,以及如何解决它?等效在gdb中运行得很好(有很多原因我宁愿使用/ 使用lldb而不是gdb)。

我正在使用llvm,clang和lldb trunk运行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)

1 个答案:

答案 0 :(得分:0)

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