Skip to content

Commit 98eaaed

Browse files
committed
Match unit names with cg_llvm
1 parent e48d7d2 commit 98eaaed

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/debuginfo/mod.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub(crate) struct FunctionDebugContext {
4343
}
4444

4545
impl DebugContext {
46-
pub(crate) fn new(tcx: TyCtxt<'_>, isa: &dyn TargetIsa) -> Self {
46+
pub(crate) fn new(tcx: TyCtxt<'_>, isa: &dyn TargetIsa, cgu_name: &str) -> Self {
4747
let encoding = Encoding {
4848
format: Format::Dwarf32,
4949
// FIXME this should be configurable
@@ -108,14 +108,20 @@ impl DebugContext {
108108
dwarf.unit.line_program = line_program;
109109

110110
{
111-
let name = dwarf.strings.add(name);
111+
let name = dwarf.strings.add(format!("{name}/@/{cgu_name}"));
112112
let comp_dir = dwarf.strings.add(comp_dir);
113113

114114
let root = dwarf.unit.root();
115115
let root = dwarf.unit.get_mut(root);
116116
root.set(gimli::DW_AT_producer, AttributeValue::StringRef(dwarf.strings.add(producer)));
117117
root.set(gimli::DW_AT_language, AttributeValue::Language(gimli::DW_LANG_Rust));
118118
root.set(gimli::DW_AT_name, AttributeValue::StringRef(name));
119+
120+
// This will be replaced when emitting the debuginfo. It is only
121+
// defined here to ensure that the order of the attributes matches
122+
// rustc.
123+
root.set(gimli::DW_AT_stmt_list, AttributeValue::Udata(0));
124+
119125
root.set(gimli::DW_AT_comp_dir, AttributeValue::StringRef(comp_dir));
120126
root.set(gimli::DW_AT_low_pc, AttributeValue::Address(Address::Constant(0)));
121127
}

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ impl CodegenCx {
148148
let unwind_context =
149149
UnwindContext::new(isa, matches!(backend_config.codegen_mode, CodegenMode::Aot));
150150
let debug_context = if debug_info && !tcx.sess.target.options.is_like_windows {
151-
Some(DebugContext::new(tcx, isa))
151+
Some(DebugContext::new(tcx, isa, cgu_name.as_str()))
152152
} else {
153153
None
154154
};

0 commit comments

Comments
 (0)