mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-27 01:28:46 +00:00
Convert dwarf2/macro.c to new hash table
This converts dwarf2/macro.c to use the new hash table. Change-Id: I6af0d1178e2db330fe3a89d57763974145ed17c4 Co-Authored-By: Tom Tromey <tom@tromey.com> Approved-By: Tom Tromey <tom@tromey.com>
This commit is contained in:
committed by
Simon Marchi
parent
d64c62fdb4
commit
370e6d147c
@@ -35,6 +35,7 @@
|
||||
#include "macrotab.h"
|
||||
#include "complaints.h"
|
||||
#include "objfiles.h"
|
||||
#include "gdbsupport/unordered_set.h"
|
||||
|
||||
static void
|
||||
dwarf2_macro_malformed_definition_complaint (const char *arg1)
|
||||
@@ -422,7 +423,8 @@ dwarf_decode_macro_bytes (dwarf2_per_objfile *per_objfile,
|
||||
struct dwarf2_section_info *str_section,
|
||||
struct dwarf2_section_info *str_offsets_section,
|
||||
std::optional<ULONGEST> str_offsets_base,
|
||||
htab_t include_hash, struct dwarf2_cu *cu)
|
||||
gdb::unordered_set<const gdb_byte *> &include_hash,
|
||||
struct dwarf2_cu *cu)
|
||||
{
|
||||
struct objfile *objfile = per_objfile->objfile;
|
||||
enum dwarf_macro_record_type macinfo_type;
|
||||
@@ -697,7 +699,6 @@ dwarf_decode_macro_bytes (dwarf2_per_objfile *per_objfile,
|
||||
case DW_MACRO_import_sup:
|
||||
{
|
||||
LONGEST offset;
|
||||
void **slot;
|
||||
bfd *include_bfd = abfd;
|
||||
const struct dwarf2_section_info *include_section = section;
|
||||
const gdb_byte *include_mac_end = mac_end;
|
||||
@@ -719,9 +720,8 @@ dwarf_decode_macro_bytes (dwarf2_per_objfile *per_objfile,
|
||||
}
|
||||
|
||||
new_mac_ptr = include_section->buffer + offset;
|
||||
slot = htab_find_slot (include_hash, new_mac_ptr, INSERT);
|
||||
|
||||
if (*slot != NULL)
|
||||
if (!include_hash.insert (new_mac_ptr).second)
|
||||
{
|
||||
/* This has actually happened; see
|
||||
http://sourceware.org/bugzilla/show_bug.cgi?id=13568. */
|
||||
@@ -730,8 +730,6 @@ dwarf_decode_macro_bytes (dwarf2_per_objfile *per_objfile,
|
||||
}
|
||||
else
|
||||
{
|
||||
*slot = (void *) new_mac_ptr;
|
||||
|
||||
dwarf_decode_macro_bytes (per_objfile, builder, include_bfd,
|
||||
new_mac_ptr, include_mac_end,
|
||||
current_file, lh, section,
|
||||
@@ -739,7 +737,7 @@ dwarf_decode_macro_bytes (dwarf2_per_objfile *per_objfile,
|
||||
str_section, str_offsets_section,
|
||||
str_offsets_base, include_hash, cu);
|
||||
|
||||
htab_remove_elt (include_hash, (void *) new_mac_ptr);
|
||||
include_hash.erase (new_mac_ptr);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -788,7 +786,6 @@ dwarf_decode_macros (dwarf2_per_objfile *per_objfile,
|
||||
struct macro_source_file *current_file = 0;
|
||||
enum dwarf_macro_record_type macinfo_type;
|
||||
const gdb_byte *opcode_definitions[256];
|
||||
void **slot;
|
||||
|
||||
abfd = section->get_bfd_owner ();
|
||||
|
||||
@@ -933,14 +930,11 @@ dwarf_decode_macros (dwarf2_per_objfile *per_objfile,
|
||||
command-line macro definitions/undefinitions. This flag is unset when we
|
||||
reach the first DW_MACINFO_start_file entry. */
|
||||
|
||||
htab_up include_hash (htab_create_alloc (1, htab_hash_pointer,
|
||||
htab_eq_pointer,
|
||||
NULL, xcalloc, xfree));
|
||||
gdb::unordered_set<const gdb_byte *> include_hash;
|
||||
mac_ptr = section->buffer + offset;
|
||||
slot = htab_find_slot (include_hash.get (), mac_ptr, INSERT);
|
||||
*slot = (void *) mac_ptr;
|
||||
include_hash.insert (mac_ptr);
|
||||
dwarf_decode_macro_bytes (per_objfile, builder, abfd, mac_ptr, mac_end,
|
||||
current_file, lh, section, section_is_gnu, 0,
|
||||
offset_size, str_section, str_offsets_section,
|
||||
str_offsets_base, include_hash.get (), cu);
|
||||
str_offsets_base, include_hash, cu);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user