wine/debugger/hash.c
Alexandre Julliard f0b2354c71 Release 0.4.3
Tue Sep 28 19:59:21 1993  David Metcalfe

	* [windows/win.c]
	Implemented support for windows with no borders.  Added
 	GetParent(), GetDlgCtrlID(), GetWindowText() and
	GetWindowTextLength() functions.

	* [misc/xt.c]
	Added processing of WM_GETTEXT and WM_GETTEXTLENGTH messages
	to DefWindowProc and Implemented MessageBeep().

	* [windows/syscolor.c]
	Added preliminary system color support.

	* [controls/button1.c]
	Mods to new button control and integration with Wine.

Tue Sep 28 19:59:21 1993  Johannes Ruscheinski

	* [controls/button1.c]
	New button control using GDI functions.
	
Tue Sep 28 19:59:21 1993  Eric Youngdale

	* [debugger/*]
	Added debugging capabilities to Wine

Sat Sep 25 13:22:50 1993  Alexandre Julliard  (julliard@di.epfl.ch)

	* [objects/region.c]
	Bug fix

Fri Sep 24 07:35:11 1993  Bob Amstadt  (bob at pooh)

	* [tools/build.c]
	Changed the entry point code to reduce the standard entry
	point size from 22 bytes to 10 bytes.  This leaves about
	4000 free entry points instead of the 800 in version 0.4.2.

	* [loader/resource.c]
	Rewrote functions to allow loading of resources from any
	DLL.

	* [loader/wine.c] [include/wine.h]
	Added functions GetFilenameFromInstance() and GetFileInfo()
	to search for a loaded file based on its instance handle.
	Added a field in struct w_files to make searching by an instance
	handle faster.

Tue Sep 21 09:57:01 1993  miguel@roxanne.nuclecu.unam.mx (Miguel de Icaza)

	* [misc/profile.c]
	Implementation of .INI file handling

Mon Sep 20 10:54:32 1993  David Metcalfe

	* [misc/profile.c.old]
	Implementation of .INI file handling

Mon Sep 20 10:54:32 1993  John Brezak

	* [controls/WinButton.c]
	Bug fix with call to XtVaSetValues.

Mon Sep 20 10:54:32 1993  Alexandre Julliard

	* [windows/win.c]
	Quick patch to get colormaps to work with button widget.

Mon Sep 20 02:42:54 1993    (yngvi@hafro.is)

	* misc/keyboard.c: 
	Ifdefed out some bogus Ansi<->Oem conversion functions

	* misc/lstr.c: 
	New file with string functions like lstr* IsChar* *Ansi* 

Wed Sep 15 20:35:10 1993  John Brezak

	* [loader/signal.c]
	Additional changes to support NetBSD.

Wed Sep 15 22:19:22 1993  Martin Ayotte

	* [windows/graphics.c]
	Added FrameRect function

Tue Sep 14 13:54:45 1993  Alexandre Julliard

	* [objects/color.c] [objects/palette.c]
	Preliminary support for private color map.

	* [windows/class.c]
	Implemented CS_CLASSDC style.

	* [windows/dce.c]
	Moved DCEs to USER heap.
	Implemented class and window DCs.

	* [windows/event.c]
	Implemented CS_DBLCLKS style.

	* [windows/graphics.c]
	Bug fix in SetPixel().

	* [windows/win.c]	
	Implemented CS_OWNDC style.
	Implemented Get/SetWindowLong().

	* [controls/menu.c] [windows/class.c] [windows/clipping.c] 
	  [windows/dce.c] [windows/message.c] [windows/win.c]	
	Moved windows from global heap to USER heap.
1993-09-29 12:21:49 +00:00

177 lines
3.8 KiB
C

/*
* File hash.c - generate hash tables for Wine debugger symbols
*
* Copyright (C) 1993, Eric Youngdale.
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <neexe.h>
#include <segmem.h>
#include <prototypes.h>
#include <wine.h>
struct name_hash{
struct name_hash * next;
unsigned int * address;
char * name;
};
#define NR_NAME_HASH 128
static struct name_hash * name_hash_table[NR_NAME_HASH] = {0,};
static unsigned int name_hash(const char * name){
unsigned int hash = 0;
const char * p;
p = name;
while (*p) hash = (hash << 15) + (hash << 3) + (hash >> 3) + *p++;
return hash % NR_NAME_HASH;
}
void add_hash(char * name, unsigned int * address){
struct name_hash * new;
int hash;
new = (struct name_hash *) malloc(sizeof(struct name_hash));
new->address = address;
new->name = strdup(name);
new->next = NULL;
hash = name_hash(name);
/* Now insert into the hash table */
new->next = name_hash_table[hash];
name_hash_table[hash] = new;
}
unsigned int * find_hash(char * name){
char buffer[256];
struct name_hash * nh;
for(nh = name_hash_table[name_hash(name)]; nh; nh = nh->next)
if(strcmp(nh->name, name) == 0) return nh->address;
if(name[0] != '_'){
buffer[0] = '_';
strcpy(buffer+1, name);
for(nh = name_hash_table[name_hash(buffer)]; nh; nh = nh->next)
if(strcmp(nh->name, buffer) == 0) return nh->address;
};
return (unsigned int *) 0xffffffff;
}
static char name_buffer[256];
char * find_nearest_symbol(unsigned int * address){
struct name_hash * nearest;
struct name_hash start;
struct name_hash * nh;
int i;
nearest = &start;
start.address = (unsigned int *) 0;
for(i=0; i<NR_NAME_HASH; i++) {
for(nh = name_hash_table[i]; nh; nh = nh->next)
if(nh->address <= address && nh->address > nearest->address)
nearest = nh;
};
if((unsigned int) nearest->address == 0) return NULL;
sprintf(name_buffer, "%s+0x%x", nearest->name, ((unsigned int) address) -
((unsigned int) nearest->address));
return name_buffer;
}
void
read_symboltable(char * filename){
FILE * symbolfile;
unsigned int addr;
int nargs;
char type;
char * cpnt;
char buffer[256];
char name[256];
symbolfile = fopen(filename, "r");
if(!symbolfile) {
fprintf(stderr,"Unable to open symbol table %s\n", filename);
return;
};
fprintf(stderr,"Reading symbols from file %s\n", filename);
while (1)
{
fgets(buffer, sizeof(buffer), symbolfile);
if (feof(symbolfile)) break;
/* Strip any text after a # sign (i.e. comments) */
cpnt = buffer;
while(*cpnt){
if(*cpnt == '#') {*cpnt = 0; break; };
cpnt++;
};
/* Quietly ignore any lines that have just whitespace */
cpnt = buffer;
while(*cpnt){
if(*cpnt != ' ' && *cpnt != '\t') break;
cpnt++;
};
if (!(*cpnt) || *cpnt == '\n') {
continue;
};
nargs = sscanf(buffer, "%x %c %s", &addr, &type, name);
add_hash(name, (unsigned int *) addr);
};
fclose(symbolfile);
}
/* Load the entry points from the dynamic linking into the hash tables.
* This does not work yet - something needs to be added before it scans the
* tables correctly
*/
void
load_entrypoints(){
char buffer[256];
char * cpnt;
int j, ordinal, len;
unsigned int address;
struct w_files * wpnt;
for(wpnt = wine_files; wpnt; wpnt = wpnt->next){
cpnt = wpnt->nrname_table;
while(1==1){
if( ((int) cpnt) - ((int)wpnt->nrname_table) >
wpnt->ne_header->nrname_tab_length) break;
len = *cpnt++;
strncpy(buffer, cpnt, len);
buffer[len] = 0;
ordinal = *((unsigned short *) (cpnt + len));
j = GetEntryPointFromOrdinal(wpnt, ordinal);
address = j & 0xffff;
j = j >> 16;
address |= (wpnt->selector_table[j].selector) << 16;
fprintf(stderr,"%s -> %x\n", buffer, address);
add_hash(buffer, (unsigned int *) address);
cpnt += len + 2;
};
};
return;
}