From 933f8ee225d4ccd3db9b81312dba76ae5a50b4ea Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Fri, 25 Aug 2023 09:30:54 +0200 Subject: [PATCH 03/11] [gdb/symtab] Handle nullptr parent in parent_map::set_parent Set_parent uses m_die_range_map.set_empty, which doesn't allow parent_entry == nullptr. So it may be necessary to guard calls to set_parent with "if (parent_entry != nullptr)". Fix this by handling the parent_entry == nullptr case in set_parent. Tested on x86_64-linux. --- gdb/dwarf2/cooked-index.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h index 1c967bdbf86..f4abc7a974e 100644 --- a/gdb/dwarf2/cooked-index.h +++ b/gdb/dwarf2/cooked-index.h @@ -257,7 +257,9 @@ class parent_map void set_parent (CORE_ADDR start, CORE_ADDR end, const cooked_index_entry *parent_entry) { - m_parent_map.set_empty (start, end, (void *)parent_entry); + /* Calling set_empty with nullptr is currently not allowed. */ + if (parent_entry != nullptr) + m_parent_map.set_empty (start, end, (void *)parent_entry); } private: -- 2.35.3