推荐 最新
抠香糖

使用lldb调试阵列时,设置的lower bound为何无效?

编译一个系数不从0开始的阵列: my_arr : ARRAY [1..100] OF REAL; my_arr[1] := 5.0; 声明阵列并赋值的IR代码如下: %my_arr = alloca [100 x float], align 4, !dbg !21 call void @llvm.dbg.declare(metadata [100 x float]* %my_arr, metadata !14, metadata !DIExpression()), !dbg !21 %0 = getelementptr inbounds [100 x float], [100 x float]* %my_arr, i32 0, i32 0, !dbg !23 store float 5.000000e+00, float* %0, align 4, !dbg !23 ... !14 = !DILocalVariable(name: "my_arr", arg: 1, scope: !10, file: !1, line: 8, type: !15) !15 = !DIDerivedType(tag: DW_TAG_typedef, name: "a", file: !1, baseType: !16) !16 = !DICompositeType(tag: DW_TAG_array_type, baseType: !17, size: 3200, elements: !18) !17 = !DIBasicType(name: "float", size: 32, encoding: DW_ATE_float) !18 = !{!19} !19 = !DISubrange(count: 100, lowerBound: 1) 使用gdb对elf文件进行调试时,可以正确输出 "my_arr[1]" 的值: (gdb) print my_arr[0] $1 = 1.34668156e+34 (gdb) print my_arr[1] $2 = 5 但在使用lldb调试同一个elf文件时,定义的 "lowerBound: 1" 无效: (lldb) print my_arr[0] (float) $0 = 5 (lldb) print my_arr[1] (float) $1 = -3.90663904E-16 造成lldb不能正确匹配系数地址的原因是什么?是否有办法规避呢?

8
1
0
浏览量458
001

Clang libtooling 中 VarDecl 节点对于 string 类型显示为 invalid 的调试与解决?

我用llvm libtooling编程,代码里解析一个cpp文件,遍历var,打印ast节点信息,如下第二段代码,string类型ast是invalid,int类型ast节点是正确的为什么呢。被解析的cpp code包含string头文件了,第三段代码 bool Visitor::VisitVarDecl(VarDecl *VD) { SourceLocation srcLoc = VD->getLocation(); if (srcMgr.isInSystemHeader(srcMgr.getExpansionLoc(VD->getBeginLoc()))) { return true; } if (srcMgr.getFileCharacteristic(srcLoc) == SrcMgr::C_System || srcMgr.getFileCharacteristic(srcLoc) == SrcMgr::C_ExternCSystem) { return true; } VD->dump(); return true; } ''' ''' VarDecl 0x55d65df37a68 col:14 invalid s2 'std::string':'std::__cxx11::basic_string, std::allocator >' VarDecl 0x55d65df37b18 col:9 invalid s1 'std::string':'std::__cxx11::basic_string, std::allocator >' VarDecl 0x55d65df37ba8 col:9 invalid s3 'std::string':'std::__cxx11::basic_string, std::allocator >' VarDecl 0x55bda4199000 col:6 a 'int' cinit `-IntegerLiteral 0x55bda4199068 "col:10" (col:10) 'int' 1 ''' ''' #include "e.h" #include #include using namespace std; int main(int argc, const char *argv[]){ std::string s2 = "abc"; string s1 = func(); string s3 = "a"; int a = 1; int b = func2(); int64_t c = 2; return 0; } why VD->dump() show string invalid vartype? but int type show no invalid 没尝试,无解决思路

0
1
0
浏览量136