From 326ca4ee5776a676c6b6a7913321107e2a3c73e2 Mon Sep 17 00:00:00 2001 From: Jeff Law Date: Wed, 15 Oct 1997 04:11:06 +0000 Subject: [PATCH] Bring over from r5900 branch. --- gdb/ChangeLog | 4 ++++ gdb/stabsread.c | 32 ++++++++++++++++++++++++++------ 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index b9b6a8168a1..393c14778db 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +Tue Oct 14 22:13:27 1997 Dawn Perchik + + * stabsread.c: Make ref_map entries dynamically allocated. + Thu Oct 9 12:37:57 1997 Frank Ch. Eigler * printcmd.c (print_address_symbolic, address_info): Mask diff --git a/gdb/stabsread.c b/gdb/stabsread.c index e8b0844ebb9..c998810fe72 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -1145,15 +1145,27 @@ resolve_reference (p) return sym; } + +#define MAX_CHUNK_REFS 100 +#define REF_CHUNK_SIZE \ + MAX_CHUNK_REFS * sizeof (struct ref_map_s) +#define REF_MAP_SIZE(ref_chunk) \ + ref_chunk * REF_CHUNK_SIZE + /* Structure for storing pointers to reference definitions for fast lookup during "process_later". */ -#define MAX_REFS 100 /* FIXME! Change to use heap. */ static struct ref_map_s { char *stabs; CORE_ADDR value; struct symbol *sym; -} ref_map[MAX_REFS]; +} *ref_map; + +/* Ptr to free cell in chunk's linked list. */ +static int ref_count = 0; + +/* Number of chunks malloced. */ +static int ref_chunk = 0; /* Initialize our list of references. This should be called before any symbol table is read. @@ -1161,12 +1173,12 @@ static struct ref_map_s need to add something to disambiguate the refids. Or, it might be OK to leave as is, as long as we read and process an object's symbol table all at once. */ -static int ref_count = 0; /* Ptr to free cell in linked list. */ + static void ref_init () { ref_count = 0; - memset (ref_map, 0, MAX_REFS * sizeof (struct ref_map_s)); + ref_chunk = 0; } /* Create array of pointers mapping refids to symbols and stab strings. @@ -1184,8 +1196,16 @@ ref_add (refnum, sym, stabs, value) ref_init (); if (refnum >= ref_count) ref_count = refnum + 1; - if (ref_count > MAX_REFS) - error ("no more free slots in chain\n"); + if (ref_count > ref_chunk * MAX_CHUNK_REFS) + { + int new_slots = ref_count - ref_chunk * MAX_CHUNK_REFS; + int new_chunks = new_slots / MAX_CHUNK_REFS + 1; + ref_map = realloc (ref_map, REF_MAP_SIZE(ref_chunk + new_chunks)); + if (!ref_map) + error ("no more free slots in chain\n"); + memset (ref_map + REF_MAP_SIZE(ref_chunk), 0, new_chunks * REF_CHUNK_SIZE); + ref_chunk += new_chunks; + } ref_map[refnum].stabs = stabs; ref_map[refnum].sym = sym; ref_map[refnum].value = value; -- 2.30.2