@@ -51,7 +51,10 @@ impl<'a, 'gcc, 'tcx> DebugInfoBuilderMethods for Builder<'a, 'gcc, 'tcx> {
51
51
}
52
52
}
53
53
54
- pub fn compute_mir_scopes < ' gcc , ' tcx > (
54
+ /// Generate the `debug_context` in an MIR Body.
55
+ /// # Souce of Origin
56
+ /// Copied from `create_scope_map.rs` of rustc_codegen_llvm
57
+ fn compute_mir_scopes < ' gcc , ' tcx > (
55
58
cx : & CodegenCx < ' gcc , ' tcx > ,
56
59
instance : Instance < ' tcx > ,
57
60
mir : & Body < ' tcx > ,
@@ -81,6 +84,12 @@ pub fn compute_mir_scopes<'gcc, 'tcx>(
81
84
assert ! ( instantiated. count( ) == mir. source_scopes. len( ) ) ;
82
85
}
83
86
87
+ /// Update the `debug_context`, adding new scope to it,
88
+ /// if it's not added as is denoted in `instantiated`.
89
+ ///
90
+ /// # Souce of Origin
91
+ /// Copied from `create_scope_map.rs` of rustc_codegen_llvm
92
+ /// FIXME(tempdragon/?): Add Scope Support Here.
84
93
fn make_mir_scope < ' gcc , ' tcx > (
85
94
cx : & CodegenCx < ' gcc , ' tcx > ,
86
95
instance : Instance < ' tcx > ,
@@ -123,6 +132,39 @@ fn make_mir_scope<'gcc, 'tcx>(
123
132
}
124
133
125
134
let loc = cx. lookup_debug_loc ( scope_data. span . lo ( ) ) ;
135
+
136
+ /*
137
+ // FIXME(?): Uncommented when the scope is supported.
138
+ let file_metadata = file_metadata(cx, &loc.file);
139
+
140
+ let parent_dbg_scope = match scope_data.inlined {
141
+ Some((callee, _)) => {
142
+ // FIXME(eddyb) this would be `self.monomorphize(&callee)`
143
+ // if this is moved to `rustc_codegen_ssa::mir::debuginfo`.
144
+ let callee = cx.tcx.instantiate_and_normalize_erasing_regions(
145
+ instance.args,
146
+ ty::ParamEnv::reveal_all(),
147
+ ty::EarlyBinder::bind(callee),
148
+ );
149
+ debug_context.inlined_function_scopes.entry(callee).or_insert_with(|| {
150
+ let callee_fn_abi = cx.fn_abi_of_instance(callee, ty::List::empty());
151
+ cx.dbg_scope_fn(callee, callee_fn_abi, None)
152
+ })
153
+ }
154
+ None => parent_scope.dbg_scope,
155
+ };
156
+
157
+ let dbg_scope = unsafe {
158
+ llvm::LLVMRustDIBuilderCreateLexicalBlock(
159
+ DIB(cx),
160
+ parent_dbg_scope,
161
+ file_metadata,
162
+ loc.line,
163
+ loc.col,
164
+ )
165
+ };
166
+ */
167
+
126
168
let dbg_scope = ( ) ;
127
169
128
170
let inlined_at = scope_data. inlined . map ( |( _, callsite_span) | {
@@ -144,8 +186,13 @@ fn make_mir_scope<'gcc, 'tcx>(
144
186
instantiated. insert ( scope) ;
145
187
}
146
188
147
- /// Copied from LLVM backend
148
189
impl < ' gcc , ' tcx > CodegenCx < ' gcc , ' tcx > {
190
+ /// Look up the file, the 1-based indexing line number and column number.
191
+ /// # Argument
192
+ /// - `pos`: `BytePos`, the starting position of a piece of code
193
+ /// # Source of Origin
194
+ /// Copied from LLVM backend(with a return type from struct to tuple).
195
+ /// No need to change since you may end up something like this.
149
196
pub fn lookup_debug_loc ( & self , pos : BytePos ) -> ( Lrc < SourceFile > , u32 , u32 ) {
150
197
match self . sess ( ) . source_map ( ) . lookup_line ( pos) {
151
198
Ok ( SourceFileAndLine { sf : file, line } ) => {
@@ -216,7 +263,6 @@ impl<'gcc, 'tcx> DebugInfoMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
216
263
}
217
264
218
265
fn debuginfo_finalize ( & self ) {
219
- // TODO(antoyo): Get the debug flag/predicate to allow optional generation of debuginfo.
220
266
self . context . set_debug_info ( true )
221
267
}
222
268
0 commit comments