[3/8] gdb/dwarf: move dwarf2_cu::section to cu.c

Message ID 20260316232042.368080-4-simon.marchi@polymtl.ca
State New
Headers
Series Handle foreign type units in .debug_names |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 fail Patch failed to apply
linaro-tcwg-bot/tcwg_gdb_build--master-arm fail Patch failed to apply

Commit Message

Simon Marchi March 16, 2026, 11:19 p.m. UTC
  From: Simon Marchi <simon.marchi@efficios.com>

Following the previous patch that moves the dwo_unit structure from
dwarf2/read.c to dwarf2/read.h, dwarf2_cu::section has no reason to be
implemented in dwarf2/read.c anymore.  Move it to dwarf2/cu.c.

Change-Id: I67e2bb42d878ac18e4bf3460d75f1394477a46ce
---
 gdb/dwarf2/cu.c   | 11 +++++++++++
 gdb/dwarf2/read.c | 14 +-------------
 2 files changed, 12 insertions(+), 13 deletions(-)
  

Patch

diff --git a/gdb/dwarf2/cu.c b/gdb/dwarf2/cu.c
index c3bfd15f14a1..3c89bd960d56 100644
--- a/gdb/dwarf2/cu.c
+++ b/gdb/dwarf2/cu.c
@@ -58,6 +58,17 @@  dwarf2_cu::dwarf2_cu (dwarf2_per_cu *per_cu, dwarf2_per_objfile *per_objfile)
 
 /* See cu.h.  */
 
+const dwarf2_section_info &
+dwarf2_cu::section () const
+{
+  if (this->dwo_unit != nullptr)
+    return *this->dwo_unit->section;
+  else
+    return *this->per_cu->section ();
+}
+
+/* See cu.h.  */
+
 struct type *
 dwarf2_cu::addr_sized_int_type (bool unsigned_p) const
 {
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index c13ea6c1622f..3a0602b4ac08 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -5806,19 +5806,7 @@  read_file_scope (struct die_info *die, struct dwarf2_cu *cu)
     }
 }
 
-/* See cu.h.
-
-   This function is defined in this file (instead of cu.c) because it needs
-   to see the definition of struct dwo_unit.  */
-
-const dwarf2_section_info &
-dwarf2_cu::section () const
-{
-  if (this->dwo_unit != nullptr)
-    return *this->dwo_unit->section;
-  else
-    return *this->per_cu->section ();
-}
+/* See cu.h.  */
 
 /* See cu.h.