[WIP] debuginfo for locals
This commit is contained in:
parent
306bf8ec1c
commit
c0aedfef96
3 changed files with 48 additions and 1 deletions
|
@ -21,6 +21,7 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>(
|
|||
|
||||
// Make FunctionBuilder
|
||||
let mut func = Function::with_name_signature(ExternalName::user(0, 0), sig);
|
||||
func.collect_debug_info();
|
||||
let mut func_ctx = FunctionBuilderContext::new();
|
||||
let mut bcx = FunctionBuilder::new(&mut func, &mut func_ctx);
|
||||
|
||||
|
|
|
@ -305,6 +305,48 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> {
|
|||
let entry = self.debug_context.dwarf.unit.get_mut(self.entry_id);
|
||||
entry.set(gimli::DW_AT_high_pc, AttributeValue::Udata(end as u64));
|
||||
|
||||
{
|
||||
let value_labels_ranges = context.build_value_labels_ranges(isa).unwrap();
|
||||
|
||||
for (value_label, value_loc_ranges) in value_labels_ranges.iter() {
|
||||
let live_ranges = RangeList(
|
||||
Some(Range::BaseAddress {
|
||||
address: Address::Symbol {
|
||||
symbol: self.symbol,
|
||||
addend: 0,
|
||||
},
|
||||
})
|
||||
.into_iter()
|
||||
.chain(
|
||||
value_loc_ranges
|
||||
.iter()
|
||||
.map(|val_loc_range| Range::OffsetPair {
|
||||
begin: u64::from(val_loc_range.start),
|
||||
end: u64::from(val_loc_range.end),
|
||||
}),
|
||||
)
|
||||
.collect(),
|
||||
);
|
||||
let live_ranges_id = self.debug_context.dwarf.unit.ranges.add(live_ranges);
|
||||
|
||||
let var_id = self
|
||||
.debug_context
|
||||
.dwarf
|
||||
.unit
|
||||
.add(self.entry_id, gimli::DW_TAG_variable);
|
||||
let var_entry = self.debug_context.dwarf.unit.get_mut(var_id);
|
||||
|
||||
var_entry.set(
|
||||
gimli::DW_AT_ranges,
|
||||
AttributeValue::RangeListRef(live_ranges_id),
|
||||
);
|
||||
var_entry.set(
|
||||
gimli::DW_AT_name,
|
||||
AttributeValue::String(format!("{:?}", value_label).into_bytes()),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
self.debug_context
|
||||
.unit_range_list
|
||||
.0
|
||||
|
|
|
@ -299,7 +299,11 @@ impl<'tcx> CPlace<'tcx> {
|
|||
pub fn to_cvalue(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> CValue<'tcx> {
|
||||
let layout = self.layout();
|
||||
match self.inner {
|
||||
CPlaceInner::Var(var) => CValue::by_val(fx.bcx.use_var(mir_var(var)), layout),
|
||||
CPlaceInner::Var(var) => {
|
||||
let val = fx.bcx.use_var(mir_var(var));
|
||||
fx.bcx.set_val_label(val, cranelift::codegen::ir::ValueLabel::from_u32(var.as_u32()));
|
||||
CValue::by_val(val, layout)
|
||||
}
|
||||
CPlaceInner::Addr(addr, extra) => {
|
||||
assert!(extra.is_none(), "unsized values are not yet supported");
|
||||
CValue::by_ref(addr, layout)
|
||||
|
|
Loading…
Reference in a new issue