aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2/index-write.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2022-04-21 07:28:56 -0600
committerTom Tromey <tromey@adacore.com>2022-04-29 13:16:44 -0600
commit446fcb446f57dbb33728c3dbd5f092bca3ba3547 (patch)
tree96b019204ce93ee7ab663b235543c80e5d946ac6 /gdb/dwarf2/index-write.c
parent225170409b47bc96b62b2ecfcc0d9d5ae1ef8949 (diff)
downloadbinutils-446fcb446f57dbb33728c3dbd5f092bca3ba3547.zip
binutils-446fcb446f57dbb33728c3dbd5f092bca3ba3547.tar.gz
binutils-446fcb446f57dbb33728c3dbd5f092bca3ba3547.tar.bz2
Fix .debug_names regression with new indexer
At AdaCore, we run the internal gdb test suite in several modes, including one using the .debug_names index. This caught a regression caused by the new DWARF indexer. First, the psymtabs-based .debug_names generator was completely wrong. However, to avoid making the rewrite series even bigger (fixing the writer will also require rewriting the .debug_names reader), it attempted to preserve the weirdness. However, this was not done properly. For example the old writer did this: - case STRUCT_DOMAIN: - return DW_TAG_structure_type; The new code, instead, simply preserves the actual DWARF tag -- but this makes future lookups fail, because the .debug_names reader only looks for DW_TAG_structure_type. This patch attempts to revert to the old behavior in the writer.
Diffstat (limited to 'gdb/dwarf2/index-write.c')
-rw-r--r--gdb/dwarf2/index-write.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c
index 3d1c78d..e27c2b5 100644
--- a/gdb/dwarf2/index-write.c
+++ b/gdb/dwarf2/index-write.c
@@ -37,6 +37,7 @@
#include "gdbcmd.h"
#include "objfiles.h"
#include "ada-lang.h"
+#include "dwarf2/tag.h"
#include <algorithm>
#include <cmath>
@@ -569,7 +570,18 @@ public:
const auto it = m_cu_index_htab.find (entry->per_cu);
gdb_assert (it != m_cu_index_htab.cend ());
const char *name = entry->full_name (&m_string_obstack);
- insert (entry->tag, name, it->second, (entry->flags & IS_STATIC) != 0,
+
+ /* This is incorrect but it mirrors gdb's historical behavior; and
+ because the current .debug_names generation is also incorrect,
+ it seems better to follow what was done before, rather than
+ introduce a mismatch between the newer and older gdb. */
+ dwarf_tag tag = entry->tag;
+ if (tag != DW_TAG_typedef && tag_is_type (tag))
+ tag = DW_TAG_structure_type;
+ else if (tag == DW_TAG_enumerator || tag == DW_TAG_constant)
+ tag = DW_TAG_variable;
+
+ insert (tag, name, it->second, (entry->flags & IS_STATIC) != 0,
entry->per_cu->is_debug_types ? unit_kind::tu : unit_kind::cu,
entry->per_cu->lang);
}