使用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不能正确匹配系数地址的原因是什么?是否有办法规避呢?

阅读 2.5k
1 个回答
✓ 已被采纳新手上路,请多包涵
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
宣传栏