[binutils-gdb] gdb/dwarf: move dwarf2_cu::section to cu.c

Simon Marchi via Gdb-cvs <[email protected]>
Newsgroups gmane.comp.gdb.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=84c28491dfb46027418d6546dcb5f39f5ea9ad2f

commit 84c28491dfb46027418d6546dcb5f39f5ea9ad2f
Author: Simon Marchi <[email protected]>
Date:   Mon May 11 11:40:28 2026 -0400

    gdb/dwarf: move dwarf2_cu::section to cu.c
    
    Following the previous patch that moves the dwo_unit structure from
    dwarf2/read.c to dwarf2/dwo.h, dwarf2_cu::section has no reason to be
    implemented in dwarf2/read.c anymore.  Move it to dwarf2/cu.c.
    
    Change-Id: I67e2bb42d878ac18e4bf3460d75f1394477a46ce
    Approved-By: Tom Tromey <[email protected]>

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

diff --git a/gdb/dwarf2/cu.c b/gdb/dwarf2/cu.c
index c3bfd15f14a..3c89bd960d5 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 46aa0201cc6..4d797b0e29b 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -5765,19 +5765,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.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.