[lldb-dev] SBType/SBValue determine kind

Carlo Kok ck at remobjects.com
Tue Oct 16 06:33:53 PDT 2012


Op 15-10-2012 18:52, Greg Clayton schreef:
> You can call:
>
> SBType
> SBValue::GetType();
>
> SBType will describe the type itself. We recently added an enumeration call:
>
> lldb::BasicType
> SBType::GetBasicType();
>
> This will return an enumeration that describes your type if is is a basic type (see the lldb::BasicType enumeration definition for details).


Cool. So I tried that and I get back a eBasicTypeBool for both types in 
the attached IR file. I emit it with DIBuilder and pass an DW_ATE_signed 
32bits:

!9 = metadata !{i32 786468, null, metadata !"Integer", null, i32 0, i64 
32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] [Integer] [line 
0, size 32, align 32, offset 0, enc DW_ATE_signed]



Is there something special I have to do here? (Integer is the internal 
name for this type in my language)

-------------- next part --------------
; ModuleID = 'ConsoleApplication16'

%0 = type opaque
%struct.NSConstantString = type { i32*, i32, i8*, i64 }

@__CFConstantStringClassReference = external global [0 x i32]
@.str0 = linker_private constant [17 x i8] c"What the hell %d\00", align 1
@_unnamed_cfstring_1 = private constant %struct.NSConstantString { i32* getelementptr inbounds ([0 x i32]* @__CFConstantStringClassReference, i32 0, i32 0), i32 1992, i8* getelementptr inbounds ([17 x i8]* @.str0, i32 0, i32 0), i64 16 }, section "__DATA,__cfstring"
@"\01L_OBJC_IMAGE_INFO" = internal constant [2 x i32] [i32 0, i32 16], section "__DATA, __objc_imageinfo, regular, no_dead_strip"
@llvm.used = appending global [1 x i8*] [i8* bitcast ([2 x i32]* @"\01L_OBJC_IMAGE_INFO" to i8*)], section "llvm.metadata"

define i32 @main() uwtable {
  %1 = alloca i32
  %2 = alloca i32
  call void @llvm.dbg.declare(metadata !{i32* %1}, metadata !10), !dbg !13
  call void @llvm.dbg.declare(metadata !{i32* %2}, metadata !14), !dbg !13
  store i32 0, i32* %2, !dbg !13
  store i32 0, i32* %1, !dbg !15
  br label %3, !dbg !16

; <label>:3                                       ; preds = %8, %0
  %4 = load i32* %1, !dbg !16
  %5 = icmp slt i32 %4, 5, !dbg !16
  br i1 %5, label %8, label %6, !dbg !16

; <label>:6                                       ; preds = %3
  %7 = load i32* %2, !dbg !17
  ret i32 %7, !dbg !17

; <label>:8                                       ; preds = %3
  %9 = load i32* %1, !dbg !18
  call void (%0*, ...)* @NSLog(%0* bitcast (%struct.NSConstantString* @_unnamed_cfstring_1 to %0*), i32 %9), !dbg !18
  %10 = load i32* %1, !dbg !19
  %11 = add i32 %10, 1, !dbg !19
  store i32 %11, i32* %1, !dbg !19
  br label %3, !dbg !19
                                                  ; No predecessors!
  unreachable, !dbg !17
}

declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone

declare void @NSLog(%0*, ...)

!llvm.dbg.cu = !{!0}

!0 = metadata !{i32 786449, i32 0, i32 16, metadata !"Program.pas", metadata !"C:\5CUsers\5CCarlo\5Cdocuments\5Cvisual studio 2012\5CProjects\5CConsoleApplication16\5CConsoleApplication16", metadata !"RemObjects Nougat (LLVM) 6.0.42.1102", i1 true, i1 false, metadata !"", i32 2, metadata !1, metadata !1, metadata !3, metadata !1} ; [ DW_TAG_compile_unit ] [C:\Users\Carlo\documents\visual studio 2012\Projects\ConsoleApplication16\ConsoleApplication16/Program.pas] [DW_LANG_ObjC]
!1 = metadata !{metadata !2}
!2 = metadata !{i32 0}
!3 = metadata !{metadata !4}
!4 = metadata !{metadata !5}
!5 = metadata !{i32 786478, i32 0, metadata !6, metadata !"main", metadata !"main", metadata !"", metadata !6, i32 10, metadata !7, i1 true, i1 true, i32 0, i32 0, null, i32 0, i1 false, i32 ()* @main, null, null, metadata !1, i32 10} ; [ DW_TAG_subprogram ] [line 10] [local] [def] [main]
!6 = metadata !{i32 786473, metadata !"Program.pas", metadata !"C:\5CUsers\5CCarlo\5Cdocuments\5Cvisual studio 2012\5CProjects\5CConsoleApplication16\5CConsoleApplication16", null} ; [ DW_TAG_file_type ]
!7 = metadata !{i32 786453, i32 0, metadata !"", i32 0, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !8, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
!8 = metadata !{metadata !9}
!9 = metadata !{i32 786468, null, metadata !"Integer", null, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] [Integer] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed]
!10 = metadata !{i32 786688, metadata !11, metadata !"i", metadata !6, i32 10, metadata !9, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [i] [line 10]
!11 = metadata !{i32 786443, metadata !12, i32 10, i32 1, metadata !6, i32 7} ; [ DW_TAG_lexical_block ] [C:\Users\Carlo\documents\visual studio 2012\Projects\ConsoleApplication16\ConsoleApplication16/Program.pas]
!12 = metadata !{i32 786443, metadata !5, i32 10, i32 1, metadata !6, i32 6} ; [ DW_TAG_lexical_block ] [C:\Users\Carlo\documents\visual studio 2012\Projects\ConsoleApplication16\ConsoleApplication16/Program.pas]
!13 = metadata !{i32 10, i32 1, metadata !11, null}
!14 = metadata !{i32 786688, metadata !11, metadata !"Result", metadata !6, i32 10, metadata !9, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [Result] [line 10]
!15 = metadata !{i32 11, i32 7, metadata !11, null}
!16 = metadata !{i32 12, i32 3, metadata !11, null}
!17 = metadata !{i32 16, i32 1, metadata !11, null}
!18 = metadata !{i32 13, i32 5, metadata !11, null}
!19 = metadata !{i32 14, i32 5, metadata !11, null}


More information about the lldb-dev mailing list