@@ -67,7 +67,7 @@ struct _DebugContext {
6767 names : namegen ,
6868 crate_file : ~str ,
6969 builder : DIBuilderRef ,
70- curr_loc : ( int , int ) ,
70+ curr_loc : ( uint , uint ) ,
7171 created_files : HashMap < ~str , DIFile > ,
7272 created_functions : HashMap < ast:: node_id , DISubprogram > ,
7373 created_blocks : HashMap < ast:: node_id , DILexicalBlock > ,
@@ -82,7 +82,7 @@ pub fn mk_ctxt(llmod: ModuleRef, crate: ~str, intr: @ident_interner) -> DebugCon
8282 names : new_namegen ( intr) ,
8383 crate_file: crate ,
8484 builder : builder,
85- curr_loc : ( - 1 , - 1 ) ,
85+ curr_loc : ( 0 , 0 ) ,
8686 created_files : HashMap :: new ( ) ,
8787 created_functions : HashMap :: new ( ) ,
8888 created_blocks : HashMap :: new ( ) ,
@@ -619,9 +619,13 @@ pub fn create_local_var(bcx: block, local: @ast::local) -> DIVariable {
619619 fmt ! ( "No entry in lllocals table for %?" , local. node. id) ) ;
620620 }
621621 } ;
622+
623+ set_debug_location ( bcx, loc. line , loc. col . to_uint ( ) ) ;
622624 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) ;
624627 }
628+
625629 return var_md;
626630}
627631
@@ -668,10 +672,12 @@ pub fn create_arg(bcx: block, arg: ast::arg, sp: span) -> Option<DIVariable> {
668672 }
669673}
670674
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 ( ) ] ;
673678 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) ;
675681 }
676682}
677683
@@ -686,16 +692,14 @@ pub fn update_source_pos(bcx: block, sp: span) {
686692 let loc = cm. lookup_char_pos ( sp. lo ) ;
687693 let cx = bcx. ccx ( ) ;
688694 let mut dcx = dbg_cx ( cx) ;
689- if ( loc. line . to_int ( ) , loc. col . to_int ( ) ) == dcx. curr_loc {
690- return ;
691- }
692695
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 ;
698699 }
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 ( ) ) ;
699703}
700704
701705pub fn create_function ( fcx : fn_ctxt ) -> DISubprogram {
0 commit comments