[v2,01/30] Fix bug in cooked index scanner

Message ID 20240118-submit-domain-hacks-2-v2-1-aecab29fa104@tromey.com
State New
Headers
Series Restructure symbol domains |

Commit Message

Tom Tromey Jan. 18, 2024, 8:31 p.m. UTC
  Testing this entire series pointed out that the cooked index scanner
disagrees with new_symbol about certain symbols.  In particular,
new_symbol has this comment:

    Ada and Fortran subprograms, whether marked external or
    not, are always stored as a global symbol, because we want

This patch updates the scanner to match.

I don't know why the current code does not cause failures.

It's maybe worth noting that incremental CU expansion -- creating
symtabs directly from the index -- would eliminate this sort of bug.
---
 gdb/dwarf2/read.c | 6 ++++++
 1 file changed, 6 insertions(+)
  

Patch

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 8f2b7a35f27..7b523d93e07 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -16405,6 +16405,12 @@  cooked_indexer::scan_attributes (dwarf2_per_cu_data *scanning_per_cu,
 	      || abbrev->tag == DW_TAG_enumeration_type
 	      || abbrev->tag == DW_TAG_enumerator))
 	*flags &= ~IS_STATIC;
+
+      /* Keep in sync with new_symbol.  */
+      if (abbrev->tag == DW_TAG_subprogram
+	  && (m_language == language_ada
+	      || m_language == language_fortran))
+	*flags &= ~IS_STATIC;
     }
 
   return info_ptr;