C++ improvements
This commit is contained in:
parent
e6d71bf34e
commit
357e46e7c9
8 changed files with 104 additions and 96 deletions
|
@ -1,3 +1,27 @@
|
|||
2000-06-05 Daniel Berlin <dan@cgsoftware.com>
|
||||
|
||||
* c-exp.y (yylex): template handling fixes.
|
||||
|
||||
2000-06-03 Daniel Berlin <dan@cgsoftware.com>
|
||||
|
||||
* symtab.h (VTBL_PREFIX_P): Add newer g++ vtbl prefix to prefix list.
|
||||
|
||||
* symtab.c (lookup_partial_symbol): Change to stop forcing linear searches
|
||||
on C++ when we fail the binary search, by doing the binary search right.
|
||||
|
||||
2000-05-30 Daniel Berlin <dan@cgsoftware.com>
|
||||
|
||||
* buildsym.c (hashname): Change to use hash function from bcache.c/.h
|
||||
|
||||
* bcache.c (hash): Change to newer hash function.
|
||||
|
||||
* bcache.h (hash): Prototype for hash function
|
||||
|
||||
* dwarf2read.c (TYPE_HASH_SIZE): New define for controlling size
|
||||
of type hash.
|
||||
(dwarf2_cached_types): New variable that is the cached types.
|
||||
(tag_type_to_type): Do the actual caching of types here.
|
||||
|
||||
2000-06-05 Mark Kettenis <kettenis@gnu.org>
|
||||
|
||||
* acconfig.h, configure.in, i386bsd.c (HAVE_STRUCT_REG_R_FS):
|
||||
|
|
41
gdb/bcache.c
41
gdb/bcache.c
|
@ -28,42 +28,25 @@
|
|||
#include "bcache.h"
|
||||
#include "gdb_string.h" /* For memcpy declaration */
|
||||
|
||||
|
||||
/* The old hash function was stolen from SDBM. This is what DB 3.0 uses now,
|
||||
* and is better than the old one.
|
||||
*/
|
||||
|
||||
/* The hash function. */
|
||||
|
||||
unsigned long
|
||||
hash(void *addr, int length)
|
||||
{
|
||||
/* If it's a short string, hash on every character. Otherwise, sample
|
||||
characters from throughout the string. */
|
||||
if (length <= 64)
|
||||
const unsigned char *k, *e;
|
||||
unsigned long h;
|
||||
|
||||
k = (const unsigned char *)addr;
|
||||
e = k+length;
|
||||
for (h=0; k< e;++k)
|
||||
{
|
||||
char *byte = addr;
|
||||
unsigned long h = 0;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < length; i++)
|
||||
h = h * 65793 ^ (h >> (sizeof (h) * 8 - 6)) ^ byte[i];
|
||||
|
||||
return h;
|
||||
h *=16777619;
|
||||
h ^= *k;
|
||||
}
|
||||
else
|
||||
{
|
||||
char *byte = addr;
|
||||
int n, i;
|
||||
unsigned long h = 0;
|
||||
|
||||
for (n = i = 0; n < 64; n++)
|
||||
{
|
||||
h = h * 65793 + (h >> (sizeof (h) * 8 - 6)) + byte[i];
|
||||
i = h % length;
|
||||
return (h);
|
||||
}
|
||||
|
||||
return h;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Growing the bcache's hash table. */
|
||||
|
||||
|
|
|
@ -125,5 +125,6 @@ extern void free_bcache (struct bcache *bcache);
|
|||
kind of data BCACHE holds. Statistics are printed using
|
||||
`printf_filtered' and its ilk. */
|
||||
extern void print_bcache_statistics (struct bcache *bcache, char *type);
|
||||
|
||||
/* The hash function */
|
||||
extern unsigned long hash(void *addr, int length);
|
||||
#endif /* BCACHE_H */
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include "gdb_string.h"
|
||||
#include "expression.h" /* For "enum exp_opcode" used by... */
|
||||
#include "language.h" /* For "longest_local_hex_string_custom" */
|
||||
|
||||
#include "bcache.h"
|
||||
/* Ask buildsym.h to define the vars it normally declares `extern'. */
|
||||
#define EXTERN
|
||||
/**/
|
||||
|
@ -1055,33 +1055,13 @@ push_context (int desc, CORE_ADDR valu)
|
|||
return new;
|
||||
}
|
||||
|
||||
|
||||
/* Compute a small integer hash code for the given name. */
|
||||
|
||||
int
|
||||
hashname (char *name)
|
||||
{
|
||||
register char *p = name;
|
||||
register int total = p[0];
|
||||
register int c;
|
||||
|
||||
c = p[1];
|
||||
total += c << 2;
|
||||
if (c)
|
||||
{
|
||||
c = p[2];
|
||||
total += c << 4;
|
||||
if (c)
|
||||
{
|
||||
total += p[3] << 6;
|
||||
}
|
||||
}
|
||||
|
||||
/* Ensure result is positive. */
|
||||
if (total < 0)
|
||||
{
|
||||
total += (1000 << 6);
|
||||
}
|
||||
return (total % HASHSIZE);
|
||||
return (hash(name,strlen(name)) % HASHSIZE);
|
||||
}
|
||||
|
||||
|
||||
|
|
22
gdb/c-exp.y
22
gdb/c-exp.y
|
@ -1432,8 +1432,6 @@ yylex ()
|
|||
FIXME: This mishandles `print $a<4&&$a>3'. */
|
||||
|
||||
if (c == '<')
|
||||
{
|
||||
if (hp_som_som_object_present)
|
||||
{
|
||||
/* Scan ahead to get rest of the template specification. Note
|
||||
that we look ahead only when the '<' adjoins non-whitespace
|
||||
|
@ -1445,26 +1443,6 @@ yylex ()
|
|||
namelen = p - tokstart;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
int i = namelen;
|
||||
int nesting_level = 1;
|
||||
while (tokstart[++i])
|
||||
{
|
||||
if (tokstart[i] == '<')
|
||||
nesting_level++;
|
||||
else if (tokstart[i] == '>')
|
||||
{
|
||||
if (--nesting_level == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (tokstart[i] == '>')
|
||||
namelen = i;
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
c = tokstart[++namelen];
|
||||
}
|
||||
|
||||
|
|
|
@ -35,9 +35,10 @@
|
|||
#include "buildsym.h"
|
||||
#include "demangle.h"
|
||||
#include "expression.h"
|
||||
|
||||
#include "language.h"
|
||||
#include "complaints.h"
|
||||
|
||||
#include "bcache.h"
|
||||
#include <fcntl.h>
|
||||
#include "gdb_string.h"
|
||||
#include <sys/types.h>
|
||||
|
@ -267,6 +268,11 @@ static struct abbrev_info *dwarf2_abbrevs[ABBREV_HASH_SIZE];
|
|||
|
||||
static struct die_info *die_ref_table[REF_HASH_SIZE];
|
||||
|
||||
#ifndef TYPE_HASH_SIZE
|
||||
#define TYPE_HASH_SIZE 4096
|
||||
#endif
|
||||
static struct type *dwarf2_cached_types[TYPE_HASH_SIZE];
|
||||
|
||||
/* Obstack for allocating temporary storage used during symbol reading. */
|
||||
static struct obstack dwarf2_tmp_obstack;
|
||||
|
||||
|
@ -4447,9 +4453,40 @@ tag_type_to_type (die, objfile)
|
|||
{
|
||||
return die->type;
|
||||
}
|
||||
else
|
||||
{
|
||||
struct attribute *attr;
|
||||
attr = dwarf_attr (die, DW_AT_name);
|
||||
if (attr && DW_STRING (attr))
|
||||
{
|
||||
char *attrname=DW_STRING (attr);
|
||||
unsigned long hashval=hash(attrname, strlen(attrname)) % TYPE_HASH_SIZE;
|
||||
|
||||
if (dwarf2_cached_types[hashval] != NULL)
|
||||
{
|
||||
const char *nameoftype;
|
||||
nameoftype = TYPE_NAME(dwarf2_cached_types[hashval]) == NULL ? TYPE_TAG_NAME(dwarf2_cached_types[hashval]) : TYPE_NAME(dwarf2_cached_types[hashval]);
|
||||
if (strcmp(attrname, nameoftype) == 0)
|
||||
{
|
||||
die->type=dwarf2_cached_types[hashval];
|
||||
}
|
||||
else
|
||||
{
|
||||
read_type_die (die, objfile);
|
||||
dwarf2_cached_types[hashval] = die->type;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
read_type_die (die, objfile);
|
||||
dwarf2_cached_types[hashval] = die->type;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
read_type_die (die, objfile);
|
||||
}
|
||||
|
||||
if (!die->type)
|
||||
{
|
||||
dump_die (die);
|
||||
|
|
14
gdb/symtab.c
14
gdb/symtab.c
|
@ -965,6 +965,7 @@ lookup_partial_symbol (pst, name, global, namespace)
|
|||
int global;
|
||||
namespace_enum namespace;
|
||||
{
|
||||
struct partial_symbol *temp;
|
||||
struct partial_symbol **start, **psym;
|
||||
struct partial_symbol **top, **bottom, **center;
|
||||
int length = (global ? pst->n_global_syms : pst->n_static_syms);
|
||||
|
@ -974,7 +975,6 @@ lookup_partial_symbol (pst, name, global, namespace)
|
|||
{
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
start = (global ?
|
||||
pst->objfile->global_psymbols.list + pst->globals_offset :
|
||||
pst->objfile->static_psymbols.list + pst->statics_offset);
|
||||
|
@ -996,9 +996,7 @@ lookup_partial_symbol (pst, name, global, namespace)
|
|||
if (!(center < top))
|
||||
abort ();
|
||||
if (!do_linear_search
|
||||
&& (SYMBOL_LANGUAGE (*center) == language_cplus
|
||||
|| SYMBOL_LANGUAGE (*center) == language_java
|
||||
))
|
||||
&& (SYMBOL_LANGUAGE (*center) == language_java))
|
||||
{
|
||||
do_linear_search = 1;
|
||||
}
|
||||
|
@ -1013,7 +1011,11 @@ lookup_partial_symbol (pst, name, global, namespace)
|
|||
}
|
||||
if (!(top == bottom))
|
||||
abort ();
|
||||
while (STREQ (SYMBOL_NAME (*top), name))
|
||||
|
||||
/* djb - 2000-06-03 - Use SYMBOL_MATCHES_NAME, not a strcmp, so
|
||||
we don't have to force a linear search on C++. Probably holds true
|
||||
for JAVA as well, no way to check.*/
|
||||
while (SYMBOL_MATCHES_NAME (*top,name))
|
||||
{
|
||||
if (SYMBOL_NAMESPACE (*top) == namespace)
|
||||
{
|
||||
|
@ -4018,6 +4020,7 @@ functions_info (regexp, from_tty)
|
|||
symtab_symbol_info (regexp, FUNCTIONS_NAMESPACE, from_tty);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
types_info (regexp, from_tty)
|
||||
char *regexp;
|
||||
|
@ -4664,6 +4667,7 @@ _initialize_symtab ()
|
|||
add_info ("functions", functions_info,
|
||||
"All function names, or those matching REGEXP.");
|
||||
|
||||
|
||||
/* FIXME: This command has at least the following problems:
|
||||
1. It prints builtin types (in a very strange and confusing fashion).
|
||||
2. It doesn't print right, e.g. with
|
||||
|
|
|
@ -1059,10 +1059,11 @@ struct partial_symtab
|
|||
style, using thunks (where '$' is really CPLUS_MARKER). */
|
||||
|
||||
#define VTBL_PREFIX_P(NAME) \
|
||||
((NAME)[0] == '_' \
|
||||
(((NAME)[0] == '_' \
|
||||
&& (((NAME)[1] == 'V' && (NAME)[2] == 'T') \
|
||||
|| ((NAME)[1] == 'v' && (NAME)[2] == 't')) \
|
||||
&& is_cplus_marker ((NAME)[3]))
|
||||
&& is_cplus_marker ((NAME)[3])) || ((NAME)[0]=='_' && (NAME)[1]=='_' \
|
||||
&& (NAME)[2]=='v' && (NAME)[3]=='t' && (NAME)[4]=='_'))
|
||||
|
||||
/* Macro that yields non-zero value iff NAME is the prefix for C++ destructor
|
||||
names. Note that this macro is g++ specific (FIXME). */
|
||||
|
|
Loading…
Reference in a new issue