From: Fred Fish Date: Sun, 24 Mar 1996 00:22:50 +0000 (+0000) Subject: * os9kread.c (os9k_process_one_symbol): Note nonportable X-Git-Tag: gdb-4_18~9021 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4cfb23a94c8cd4aac096c54ee7f8fe28cdc5f525;p=external%2Fbinutils.git * os9kread.c (os9k_process_one_symbol): Note nonportable assumption that an int can hold a char *. * bcache.h (struct hashlink): Wrap data[] inside union with double to force longest alignment. (BCACHE_DATA): New macro to access data[]. (BCACHE_ALIGNMENT): New macro to get offset to data[]. * bcache.c (lookup_cache, bcache): Use BCACHE_DATA to get address of cached data. Use BCACHE_ALIGNMENT to compute amount of space to allocate for each hashlink struct. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index b156178..f8c73d4 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,16 @@ +Sat Mar 23 17:24:28 1996 Fred Fish + + * os9kread.c (os9k_process_one_symbol): Note nonportable + assumption that an int can hold a char *. + + * bcache.h (struct hashlink): Wrap data[] inside union with + double to force longest alignment. + (BCACHE_DATA): New macro to access data[]. + (BCACHE_ALIGNMENT): New macro to get offset to data[]. + * bcache.c (lookup_cache, bcache): Use BCACHE_DATA to get + address of cached data. Use BCACHE_ALIGNMENT to compute + amount of space to allocate for each hashlink struct. + Sat Mar 23 17:10:56 1996 Fred Fish * configure, testsuite/configure, testsuite/gdb.base/configure, diff --git a/gdb/bcache.c b/gdb/bcache.c index af80afb..c47893b 100644 --- a/gdb/bcache.c +++ b/gdb/bcache.c @@ -21,6 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "defs.h" #include "obstack.h" #include "bcache.h" +#include "gdb_string.h" /* For memcpy declaration */ /* FIXME: Incredibly simplistic hash generator. Probably way too expensive (consider long strings) and unlikely to have good distribution across hash @@ -67,9 +68,9 @@ lookup_cache (bytes, count, hashval, bcachep) linkp = hashtablep[hashval]; while (linkp != NULL) { - if (memcmp (linkp -> data, bytes, count) == 0) + if (memcmp (BCACHE_DATA (linkp), bytes, count) == 0) { - location = linkp -> data; + location = BCACHE_DATA (linkp); break; } linkp = linkp -> next; @@ -115,17 +116,17 @@ bcache (bytes, count, bcachep) { *hashtablepp = (struct hashlink **) obstack_alloc (&bcachep->cache, BCACHE_HASHSIZE * sizeof (struct hashlink *)); - bcachep -> cache_bytes += sizeof (struct hashlink *); + bcachep -> cache_bytes += BCACHE_HASHSIZE * sizeof (struct hashlink *); memset (*hashtablepp, 0, BCACHE_HASHSIZE * sizeof (struct hashlink *)); } linkpp = &(*hashtablepp)[hashval]; newlink = (struct hashlink *) - obstack_alloc (&bcachep->cache, sizeof (struct hashlink *) + count); - bcachep -> cache_bytes += sizeof (struct hashlink *) + count; - memcpy (newlink -> data, bytes, count); + obstack_alloc (&bcachep->cache, BCACHE_DATA_ALIGNMENT + count); + bcachep -> cache_bytes += BCACHE_DATA_ALIGNMENT + count; + memcpy (BCACHE_DATA (newlink), bytes, count); newlink -> next = *linkpp; *linkpp = newlink; - location = newlink -> data; + location = BCACHE_DATA (newlink); } } return (location); diff --git a/gdb/bcache.h b/gdb/bcache.h index e389c8e..1e6d25a 100644 --- a/gdb/bcache.h +++ b/gdb/bcache.h @@ -25,11 +25,30 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #define BCACHE_HASHSIZE (1 << BCACHE_HASHLENGTH) #define BCACHE_MAXLENGTH 128 +/* Note that the user data is stored in data[]. Since it can be any type, + it needs to have the same alignment as the most strict alignment of + any type on the host machine. So do it the same way obstack does. */ + struct hashlink { struct hashlink *next; - char data[1]; + union { + char data[1]; + double dummy; + } d; }; +/* BCACHE_DATA is used to get the address of the cached data. */ + +#define BCACHE_DATA(p) ((p)->d.data) + +/* BCACHE_DATA_ALIGNMENT is used to get the offset of the start of + cached data within the hashlink struct. This value, plus the + size of the cached data, is the amount of space to allocate for + a hashlink struct to hold the next pointer and the data. */ + +#define BCACHE_DATA_ALIGNMENT \ + (((char *) &BCACHE_DATA((struct hashlink*) 0) - (char *) 0)) + struct bcache { struct obstack cache; struct hashlink **indextable[BCACHE_MAXLENGTH]; diff --git a/gdb/os9kread.c b/gdb/os9kread.c index 2de2922..edef8bc 100644 --- a/gdb/os9kread.c +++ b/gdb/os9kread.c @@ -1528,9 +1528,10 @@ os9k_process_one_symbol (type, desc, valu, name, section_offsets, objfile) case N_SYM_SLINE: /* This type of "symbol" really just records one line-number -- core-address correspondence. - Enter it in the line list for this symbol table. */ + Enter it in the line list for this symbol table. */ /* Relocate for dynamic loading and for ELF acc fn-relative syms. */ valu += ANOFFSET (section_offsets, SECT_OFF_TEXT); + /* FIXME: loses if sizeof (char *) > sizeof (int) */ record_line (current_subfile, (int)name, valu); break;