Emit DW_AT_frame_base debuginfo attribute
This commit is contained in:
parent
cfd7325f20
commit
09ec683ae7
@ -8,10 +8,10 @@
|
||||
use cranelift_codegen::ir::Endianness;
|
||||
use cranelift_codegen::isa::TargetIsa;
|
||||
use gimli::write::{
|
||||
Address, AttributeValue, DwarfUnit, FileId, LineProgram, LineString, Range, RangeList,
|
||||
UnitEntryId,
|
||||
Address, AttributeValue, DwarfUnit, Expression, FileId, LineProgram, LineString, Range,
|
||||
RangeList, UnitEntryId,
|
||||
};
|
||||
use gimli::{Encoding, Format, LineEncoding, RunTimeEndian};
|
||||
use gimli::{AArch64, Encoding, Format, LineEncoding, Register, RiscV, RunTimeEndian, X86_64};
|
||||
use indexmap::IndexSet;
|
||||
use rustc_session::Session;
|
||||
|
||||
@ -28,6 +28,7 @@ pub(crate) struct DebugContext {
|
||||
|
||||
dwarf: DwarfUnit,
|
||||
unit_range_list: RangeList,
|
||||
stack_pointer_register: Register,
|
||||
|
||||
should_remap_filepaths: bool,
|
||||
}
|
||||
@ -60,6 +61,15 @@ pub(crate) fn new(tcx: TyCtxt<'_>, isa: &dyn TargetIsa) -> Self {
|
||||
Endianness::Big => RunTimeEndian::Big,
|
||||
};
|
||||
|
||||
let stack_pointer_register = match isa.triple().architecture {
|
||||
target_lexicon::Architecture::Aarch64(_) => AArch64::SP,
|
||||
target_lexicon::Architecture::Riscv64(_) => RiscV::SP,
|
||||
target_lexicon::Architecture::X86_64 | target_lexicon::Architecture::X86_64h => {
|
||||
X86_64::RSP
|
||||
}
|
||||
_ => Register(u16::MAX),
|
||||
};
|
||||
|
||||
let mut dwarf = DwarfUnit::new(encoding);
|
||||
|
||||
let should_remap_filepaths = tcx.sess.should_prefer_remapped_for_codegen();
|
||||
@ -111,6 +121,7 @@ pub(crate) fn new(tcx: TyCtxt<'_>, isa: &dyn TargetIsa) -> Self {
|
||||
endian,
|
||||
dwarf,
|
||||
unit_range_list: RangeList(Vec::new()),
|
||||
stack_pointer_register,
|
||||
should_remap_filepaths,
|
||||
}
|
||||
}
|
||||
@ -135,6 +146,10 @@ pub(crate) fn define_function(
|
||||
entry.set(gimli::DW_AT_name, AttributeValue::StringRef(name_id));
|
||||
entry.set(gimli::DW_AT_linkage_name, AttributeValue::StringRef(name_id));
|
||||
|
||||
let mut frame_base_expr = Expression::new();
|
||||
frame_base_expr.op_reg(self.stack_pointer_register);
|
||||
entry.set(gimli::DW_AT_frame_base, AttributeValue::Exprloc(frame_base_expr));
|
||||
|
||||
entry.set(gimli::DW_AT_decl_file, AttributeValue::FileIndex(Some(file_id)));
|
||||
entry.set(gimli::DW_AT_decl_line, AttributeValue::Udata(line));
|
||||
entry.set(gimli::DW_AT_decl_column, AttributeValue::Udata(column));
|
||||
|
Loading…
Reference in New Issue
Block a user