use self::metadata::{file_metadata, type_metadata, TypeMap};
use self::namespace::mangled_name_of_instance;
-use self::source_loc::InternalDebugLocation::{self, UnknownLocation};
use self::type_names::compute_debuginfo_type_name;
use self::utils::{create_DIArray, is_node_local_to_unit, span_start, DIB};
use std::ffi::CString;
use rustc::ty::layout::{self, HasTyCtxt, LayoutOf, Size};
+use rustc_ast::ast;
use rustc_codegen_ssa::traits::*;
use rustc_span::symbol::Symbol;
-use rustc_span::{self, BytePos, Pos, Span};
+use rustc_span::{self, BytePos, Span};
use smallvec::SmallVec;
-use syntax::ast;
mod create_scope_map;
pub mod gdb;
pub use self::create_scope_map::compute_mir_scopes;
pub use self::metadata::create_global_var_metadata;
pub use self::metadata::extend_scope_to_file;
-pub use self::source_loc::set_source_location;
#[allow(non_upper_case_globals)]
const DW_TAG_auto_variable: c_uint = 0x100;
// names (choose between `dbg`, `debug`, `debuginfo`, `debug_info` etc.).
fn dbg_var_addr(
&mut self,
- dbg_context: &FunctionDebugContext<&'ll DIScope>,
dbg_var: &'ll DIVariable,
scope_metadata: &'ll DIScope,
variable_alloca: Self::Value,
indirect_offsets: &[Size],
span: Span,
) {
- assert!(!dbg_context.source_locations_enabled);
let cx = self.cx();
- let loc = span_start(cx, span);
-
// Convert the direct and indirect offsets to address ops.
+ // FIXME(eddyb) use `const`s instead of getting the values via FFI,
+ // the values should match the ones in the DWARF standard anyway.
let op_deref = || unsafe { llvm::LLVMRustDIBuilderCreateOpDeref() };
let op_plus_uconst = || unsafe { llvm::LLVMRustDIBuilderCreateOpPlusUconst() };
let mut addr_ops = SmallVec::<[_; 8]>::new();
}
}
- // FIXME(eddyb) maybe this information could be extracted from `var`,
+ // FIXME(eddyb) maybe this information could be extracted from `dbg_var`,
// to avoid having to pass it down in both places?
- source_loc::set_debug_location(
- self,
- InternalDebugLocation::new(scope_metadata, loc.line, loc.col.to_usize()),
- );
+ // NB: `var` doesn't seem to know about the column, so that's a limitation.
+ let dbg_loc = cx.create_debug_loc(scope_metadata, span);
unsafe {
- let debug_loc = llvm::LLVMGetCurrentDebugLocation(self.llbuilder);
// FIXME(eddyb) replace `llvm.dbg.declare` with `llvm.dbg.addr`.
- let instr = llvm::LLVMRustDIBuilderInsertDeclareAtEnd(
+ llvm::LLVMRustDIBuilderInsertDeclareAtEnd(
DIB(cx),
variable_alloca,
dbg_var,
addr_ops.as_ptr(),
addr_ops.len() as c_uint,
- debug_loc,
+ dbg_loc,
self.llbb(),
);
-
- llvm::LLVMSetInstDebugLocation(self.llbuilder, instr);
}
- source_loc::set_debug_location(self, UnknownLocation);
}
- fn set_source_location(
- &mut self,
- debug_context: &mut FunctionDebugContext<&'ll DIScope>,
- scope: &'ll DIScope,
- span: Span,
- ) {
- set_source_location(debug_context, &self, scope, span)
+ fn set_source_location(&mut self, scope: &'ll DIScope, span: Span) {
+ debug!("set_source_location: {}", self.sess().source_map().span_to_string(span));
+
+ let dbg_loc = self.cx().create_debug_loc(scope, span);
+
+ unsafe {
+ llvm::LLVMSetCurrentDebugLocation(self.llbuilder, dbg_loc);
+ }
}
fn insert_reference_to_gdb_debug_scripts_section_global(&mut self) {
gdb::insert_reference_to_gdb_debug_scripts_section_global(self)
};
let mut fn_debug_context = FunctionDebugContext {
scopes: IndexVec::from_elem(null_scope, &mir.source_scopes),
- source_locations_enabled: false,
defining_crate: def_id.krate,
};
file_metadata,
loc.line as c_uint,
type_metadata,
- self.sess().opts.optimize != config::OptLevel::No,
+ true,
DIFlags::FlagZero,
argument_index,
align.bytes() as u32,