@@ -67,7 +67,7 @@ struct _DebugContext {
67
67
names : namegen ,
68
68
crate_file : ~str ,
69
69
builder : DIBuilderRef ,
70
- curr_loc : ( int , int ) ,
70
+ curr_loc : ( uint , uint ) ,
71
71
created_files : HashMap < ~str , DIFile > ,
72
72
created_functions : HashMap < ast:: node_id , DISubprogram > ,
73
73
created_blocks : HashMap < ast:: node_id , DILexicalBlock > ,
@@ -82,7 +82,7 @@ pub fn mk_ctxt(llmod: ModuleRef, crate: ~str, intr: @ident_interner) -> DebugCon
82
82
names : new_namegen ( intr) ,
83
83
crate_file: crate ,
84
84
builder : builder,
85
- curr_loc : ( - 1 , - 1 ) ,
85
+ curr_loc : ( 0 , 0 ) ,
86
86
created_files : HashMap :: new ( ) ,
87
87
created_functions : HashMap :: new ( ) ,
88
88
created_blocks : HashMap :: new ( ) ,
@@ -619,9 +619,13 @@ pub fn create_local_var(bcx: block, local: @ast::local) -> DIVariable {
619
619
fmt ! ( "No entry in lllocals table for %?" , local. node. id) ) ;
620
620
}
621
621
} ;
622
+
623
+ set_debug_location ( bcx, loc. line , loc. col . to_uint ( ) ) ;
622
624
unsafe {
623
- llvm:: LLVMDIBuilderInsertDeclareAtEnd ( dcx. builder , llptr, var_md, bcx. llbb ) ;
625
+ let instr = llvm:: LLVMDIBuilderInsertDeclareAtEnd ( dcx. builder , llptr, var_md, bcx. llbb ) ;
626
+ llvm:: LLVMSetInstDebugLocation ( trans:: build:: B ( bcx) , instr) ;
624
627
}
628
+
625
629
return var_md;
626
630
}
627
631
@@ -668,10 +672,12 @@ pub fn create_arg(bcx: block, arg: ast::arg, sp: span) -> Option<DIVariable> {
668
672
}
669
673
}
670
674
671
- fn create_debug_loc ( line : int , col : int , scope : DIScope ) -> DILocation {
672
- let elems = ~[ C_i32 ( line as i32 ) , C_i32 ( col as i32 ) , scope, ptr:: null ( ) ] ;
675
+ fn set_debug_location ( bcx : block , line : uint , col : uint ) {
676
+ let blockmd = create_block ( bcx) ;
677
+ let elems = ~[ C_i32 ( line as i32 ) , C_i32 ( col as i32 ) , blockmd, ptr:: null ( ) ] ;
673
678
unsafe {
674
- return llvm:: LLVMMDNode ( vec:: raw:: to_ptr ( elems) , elems. len ( ) as libc:: c_uint ) ;
679
+ let dbg_loc = llvm:: LLVMMDNode ( vec:: raw:: to_ptr ( elems) , elems. len ( ) as libc:: c_uint ) ;
680
+ llvm:: LLVMSetCurrentDebugLocation ( trans:: build:: B ( bcx) , dbg_loc) ;
675
681
}
676
682
}
677
683
@@ -686,16 +692,14 @@ pub fn update_source_pos(bcx: block, sp: span) {
686
692
let loc = cm. lookup_char_pos ( sp. lo ) ;
687
693
let cx = bcx. ccx ( ) ;
688
694
let mut dcx = dbg_cx ( cx) ;
689
- if ( loc. line . to_int ( ) , loc. col . to_int ( ) ) == dcx. curr_loc {
690
- return ;
691
- }
692
695
693
- dcx. curr_loc = ( loc. line . to_int ( ) , loc. col . to_int ( ) ) ;
694
- let blockmd = create_block ( bcx) ;
695
- let dbgscope = create_debug_loc ( loc. line . to_int ( ) , loc. col . to_int ( ) , blockmd) ;
696
- unsafe {
697
- llvm:: LLVMSetCurrentDebugLocation ( trans:: build:: B ( bcx) , dbgscope) ;
696
+ let loc = ( loc. line , loc. col . to_uint ( ) ) ;
697
+ if loc == dcx. curr_loc {
698
+ return ;
698
699
}
700
+ debug ! ( "setting_location to %u %u" , loc. first( ) , loc. second( ) ) ;
701
+ dcx. curr_loc = loc;
702
+ set_debug_location ( bcx, loc. first ( ) , loc. second ( ) ) ;
699
703
}
700
704
701
705
pub fn create_function ( fcx : fn_ctxt ) -> DISubprogram {
0 commit comments