[binutils-gdb] gdb/dwarf: make some fields of dwarf2_per_cu private

Simon Marchi simark@sourceware.org
Mon Oct 27 19:27:34 GMT 2025


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=dbfbbbc97422f8ff8757130f4963e579d9ce0072

commit dbfbbbc97422f8ff8757130f4963e579d9ce0072
Author: Simon Marchi <simon.marchi@efficios.com>
Date:   Mon Oct 27 15:12:24 2025 -0400

    gdb/dwarf: make some fields of dwarf2_per_cu private
    
    The comments on these fields mention that they should be private, but we
    can't.  I think this comes from the time where dwarf2_per_cu was and had
    to remain POD.  I don't think it's relevant anymore, there are other
    private fields anyway.  Make them private.
    
    Change-Id: I1915ea531f42d685f68ff547833816906f79cd58
    Approved-By: Tom Tromey <tom@tromey.com>

Diff:
---
 gdb/dwarf2/read.h | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h
index f0d46f6acc6..d0d8f1a3a0e 100644
--- a/gdb/dwarf2/read.h
+++ b/gdb/dwarf2/read.h
@@ -187,12 +187,11 @@ public:
      any of the current compilation units are processed.  */
   packed<bool, 1> queued;
 
-  /* True if HEADER has been read in.
-
-     Don't access this field directly.  It should be private, but we can't make
-     it private at the moment.  */
+private:
+  /* True if HEADER has been read in.  */
   mutable packed<bool, 1> m_header_read_in;
 
+public:
   /* True if we've tried to read the file table.  There will be no
      point in trying to read it again next time.  */
   packed<bool, 1> files_read;
@@ -229,15 +228,14 @@ public:
   /* Backlink to the owner of this.  */
   dwarf2_per_bfd *per_bfd;
 
+private:
   /* DWARF header of this unit.  Note that dwarf2_cu reads its own version of
      the header, which may differ from this one, since it may pass
      rch_kind::TYPE to read_unit_head, whereas for dwarf2_per_cu we always pass
-     ruh_kind::COMPILE.
-
-     Don't access this field directly, use the get_header method instead.  It
-     should be private, but we can't make it private at the moment.  */
+     ruh_kind::COMPILE.  */
   mutable unit_head m_header;
 
+public:
   /* The file and directory for this CU.  This is cached so that we
      don't need to re-examine the DWO in some situations.  This may be
      nullptr, depending on the CU; for example a partial unit won't


More information about the Gdb-cvs mailing list