about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbjorn3 <17426603+bjorn3@users.noreply.github.com>2024-03-27 12:57:24 +0000
committerbjorn3 <17426603+bjorn3@users.noreply.github.com>2024-03-27 12:57:24 +0000
commit98eaaeda111673c617134fe2dcd3f10bb6dfc2f0 (patch)
tree372817e62646db0fcdae3f84981c8cc1d5d230f1
parente48d7d242fcf378d66d27dddea546029239bd5c6 (diff)
downloadrust-98eaaeda111673c617134fe2dcd3f10bb6dfc2f0.tar.gz
rust-98eaaeda111673c617134fe2dcd3f10bb6dfc2f0.zip
Match unit names with cg_llvm
-rw-r--r--src/debuginfo/mod.rs10
-rw-r--r--src/lib.rs2
2 files changed, 9 insertions, 3 deletions
diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs
index 2b5f472c5fc..4232018916f 100644
--- a/src/debuginfo/mod.rs
+++ b/src/debuginfo/mod.rs
@@ -43,7 +43,7 @@ pub(crate) struct FunctionDebugContext {
 }
 
 impl DebugContext {
-    pub(crate) fn new(tcx: TyCtxt<'_>, isa: &dyn TargetIsa) -> Self {
+    pub(crate) fn new(tcx: TyCtxt<'_>, isa: &dyn TargetIsa, cgu_name: &str) -> Self {
         let encoding = Encoding {
             format: Format::Dwarf32,
             // FIXME this should be configurable
@@ -108,7 +108,7 @@ impl DebugContext {
         dwarf.unit.line_program = line_program;
 
         {
-            let name = dwarf.strings.add(name);
+            let name = dwarf.strings.add(format!("{name}/@/{cgu_name}"));
             let comp_dir = dwarf.strings.add(comp_dir);
 
             let root = dwarf.unit.root();
@@ -116,6 +116,12 @@ impl DebugContext {
             root.set(gimli::DW_AT_producer, AttributeValue::StringRef(dwarf.strings.add(producer)));
             root.set(gimli::DW_AT_language, AttributeValue::Language(gimli::DW_LANG_Rust));
             root.set(gimli::DW_AT_name, AttributeValue::StringRef(name));
+
+            // This will be replaced when emitting the debuginfo. It is only
+            // defined here to ensure that the order of the attributes matches
+            // rustc.
+            root.set(gimli::DW_AT_stmt_list, AttributeValue::Udata(0));
+
             root.set(gimli::DW_AT_comp_dir, AttributeValue::StringRef(comp_dir));
             root.set(gimli::DW_AT_low_pc, AttributeValue::Address(Address::Constant(0)));
         }
diff --git a/src/lib.rs b/src/lib.rs
index a121ac75a28..d0ab64a5584 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -148,7 +148,7 @@ impl CodegenCx {
         let unwind_context =
             UnwindContext::new(isa, matches!(backend_config.codegen_mode, CodegenMode::Aot));
         let debug_context = if debug_info && !tcx.sess.target.options.is_like_windows {
-            Some(DebugContext::new(tcx, isa))
+            Some(DebugContext::new(tcx, isa, cgu_name.as_str()))
         } else {
             None
         };