Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: simon.marchi@polymtl.ca
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@polymtl.ca>
Subject: [PATCH 3/5] gdb/dwarf: add comments to debug_names::build
Date: Sat, 17 Jan 2026 01:02:33 -0500	[thread overview]
Message-ID: <20260117060335.691691-4-simon.marchi@polymtl.ca> (raw)
In-Reply-To: <20260117060335.691691-1-simon.marchi@polymtl.ca>

From: Simon Marchi <simon.marchi@polymtl.ca>

These help me follow what is going on, when following with the spec on
the side.

Change-Id: I0da0047eefd233e8f7635118d67622f07c29ce01
---
 gdb/dwarf2/index-write.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c
index d31e7b631b86..39910cd3f71c 100644
--- a/gdb/dwarf2/index-write.c
+++ b/gdb/dwarf2/index-write.c
@@ -728,33 +728,49 @@ class debug_names
 	    if (idx == 0)
 	      {
 		idx = next_abbrev++;
+
+		/* Abbrev number and tag.  */
 		m_abbrev_table.append_unsigned_leb128 (idx);
 		m_abbrev_table.append_unsigned_leb128 (entry->tag);
+
+		/* Unit index.  */
 		m_abbrev_table.append_unsigned_leb128
 		  (kind == unit_kind::cu
 		   ? DW_IDX_compile_unit
 		   : DW_IDX_type_unit);
 		m_abbrev_table.append_unsigned_leb128 (DW_FORM_udata);
+
+		/* DIE offset.  */
 		m_abbrev_table.append_unsigned_leb128 (DW_IDX_die_offset);
 		m_abbrev_table.append_unsigned_leb128 (DW_FORM_ref_addr);
+
+		/* Language.  */
 		m_abbrev_table.append_unsigned_leb128 (DW_IDX_GNU_language);
 		m_abbrev_table.append_unsigned_leb128 (DW_FORM_udata);
+
+		/* Internal linkage flag.  */
 		if (!tag_is_type (entry->tag)
 		    && (entry->flags & IS_STATIC) != 0)
 		  {
 		    m_abbrev_table.append_unsigned_leb128 (DW_IDX_GNU_internal);
 		    m_abbrev_table.append_unsigned_leb128 (DW_FORM_flag_present);
 		  }
+
+		/* Main subprogram flag.  */
 		if ((entry->flags & IS_MAIN) != 0)
 		  {
 		    m_abbrev_table.append_unsigned_leb128 (DW_IDX_GNU_main);
 		    m_abbrev_table.append_unsigned_leb128 (DW_FORM_flag_present);
 		  }
+
+		/* Linkage name flag.  */
 		if ((entry->flags & IS_LINKAGE) != 0)
 		  {
 		    m_abbrev_table.append_unsigned_leb128 (DW_IDX_GNU_linkage_name);
 		    m_abbrev_table.append_unsigned_leb128 (DW_FORM_flag_present);
 		  }
+
+		/* Parent offset.  */
 		if (parent != nullptr)
 		  {
 		    m_abbrev_table.append_unsigned_leb128 (DW_IDX_parent);
@@ -773,19 +789,23 @@ class debug_names
 		 .second);
 	    gdb_assert (offset_inserted);
 
-	    /* Write the entry to the pool.  */
+	    /* Write the entry to the pool, starting with the abbrev number.  */
 	    m_entry_pool.append_unsigned_leb128 (idx);
 
+	    /* Unit index.  */
 	    const auto it = m_cu_index_htab.find (entry->per_cu);
 	    gdb_assert (it != m_cu_index_htab.cend ());
 	    m_entry_pool.append_unsigned_leb128 (it->second);
 
+	    /* DIE offset.  */
 	    m_entry_pool.append_uint (dwarf5_offset_size (),
 				      m_dwarf5_byte_order,
 				      to_underlying (entry->die_offset));
 
+	    /* Language.  */
 	    m_entry_pool.append_unsigned_leb128 (entry->per_cu->dw_lang ());
 
+	    /* Parent offset.  */
 	    if (parent != nullptr)
 	      {
 		m_offsets_to_patch.emplace_back (m_entry_pool.size (), parent);
-- 
2.52.0


  parent reply	other threads:[~2026-01-17  6:04 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-17  6:02 [PATCH 0/5] Some semi-random DWARF cleanups simon.marchi
2026-01-17  6:02 ` [PATCH 1/5] gdb/dwarf: merge one CU/TU code path simon.marchi
2026-01-17  6:02 ` [PATCH 2/5] gdb/dwarf: move DWP htab nullptr check to lookup_dwo_unit_in_dwp simon.marchi
2026-01-17  6:02 ` simon.marchi [this message]
2026-01-17  6:02 ` [PATCH 4/5] gdb/dwarf: rename some abbrev-related things in debug_names writer simon.marchi
2026-01-17  6:02 ` [PATCH 5/5] gdb/dwarf: add unit_lists structure to index writer simon.marchi
2026-01-20 17:00   ` Tom Tromey
2026-01-20 17:33     ` Simon Marchi
2026-01-20 20:42       ` Tom Tromey
2026-01-20 21:12         ` Simon Marchi
2026-01-20 17:00 ` [PATCH 0/5] Some semi-random DWARF cleanups Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260117060335.691691-4-simon.marchi@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox