Release 970120
Sun Jan 19 11:46:48 1997 Alexandre Julliard <julliard@lrc.epfl.ch>
* [loader/module.c]
Fixed LoadModule() to always call the DLL initialization code.
* [windows/event.c]
Moved all the keyboard stuff to windows/keyboard.c
* [tools/build.c]
Fixed Win32 register functions.
Sat Jan 18 22:24:41 1997 David Makepeace <D.Makepeace@mailbox.uq.oz.au>
* [tools/makedep.c]
Fixed bug which causes SEGV on Solaris x86.
Fri Jan 17 18:32:27 1997 Frans van Dorsselaer <dorssel@rulhmpc49.LeidenUniv.nl>
* [controls/edit.c]
Implemented WM_UNDO, WM_CONTEXTMENU (temporary using WM_RBUTTONUP),
WM_COMMAND, WM_INITPOPUPMENU, WM_SYSKEYDOWN.
Fixed EM_SETSEL and some minor bugs (features).
Hence: fully functional undo and a win95 menu with the right mouse
button.
* [include/resources.h] [resources/TODO] [resources/sysres_??.rc]
Added a context menu for the edit control.
Translations, please ...
Fri Jan 17 08:29:52 1997 David Faure <david.faure@ifhamy.insa-lyon.fr>
* [windows/event.c]
Move EVENT_ToAscii to windows/keyboard.c (where name ToAscii)
Fixed Keypad keys 0-9 and . in EVENT_event_to_vkey.
Added 3-state handling of toggle keys (CapsLock, NumLock) in order
to make them work with any X server.
Toggle keys now generate WM_KEYDOWN and WM_KEYUP on each pressing.
* [include/keyboard.h]
Totally replaced the file (formerly containing the vkcase definitions)
by the declaration of 'extern' variables contained by event.c and used
by keyboard.c
* [windows/keyboard.c]
Started to rewrite VkKeyScan and MapVirtualKey, to make them use the
table keyc2vkey or X functions only.
ToAscii : added keypad 0-9 and . special case.
Changed toggle keys active mask from 0x80 to 0x1.
* [misc/keyboard.c]
File deleted. Contents moved to windows/keyboard.c.
* [misc/main.c]
Added putenv XKB_DISABLE to disable XKB extension (which, when
present, causes AltGr to change keyboard group instead of being a
modifier).
Tue Jan 14 22:56:43 1997 Philippe De Muyter <phdm@info.ucl.ac.be>
* [windows/event.c]
Do not assume NumLockMask is Mod2Mask, but compute it by scanning
output of XGetModifierMapping for XK_Num_Lock.
Tue Jan 14 15:49:49 1997 Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de>
* [loader/pe_*.c] [include/peexe.h] [include/resource32.h]
[debugger/*.c]
General clean up.
Changed defines/structures to match Windows NT SDK.
* [loader/main.c]
Don't crash on empty command-line.
* [windows/winpos.c]
winpos.c made win32 clean.
* [misc/ntdll.c]
Some string conversion additions.
* [files/file.c]
GetFileAttributes/GetTempFileName fixed.
* [misc/ver.c]
VerInstallFile implemented.
Mon Jan 13 15:03:11 1997 Philippe De Muyter <phdm@info.ucl.ac.be>
* [tools/build.c]: Use PREFIX also in stabs messages.
Mon Jan 13 10:40:33 1997 John Harvey <john@division.co.uk>
* [graphics/win16drv/*] [include/win16drv.h]
Many fixes and some new features.
* [graphics/x11drv/font.c] [graphics/x11drv/init.c]
[include/x11drv.h] [objects/font.c]
GetTextMetrics() moved to graphics driver.
* [if1632/gdi.spec] [misc/fontengine.c] [misc/Makefile.in]
New dummy EngineEnumerateFont, EngineRealizeFont functions.
* [include/windows.h]
TEXTFORM16 and FONTINFO16 structure definitions moved here from
include/win16drv.h
diff --git a/debugger/stabs.c b/debugger/stabs.c
index 0c1ddf1..a52c467 100644
--- a/debugger/stabs.c
+++ b/debugger/stabs.c
@@ -75,6 +75,44 @@
unsigned long n_value;
};
+/*
+ * This is used to keep track of known datatypes so that we don't redefine
+ * them over and over again. It sucks up lots of memory otherwise.
+ */
+struct known_typedef
+{
+ struct known_typedef * next;
+ char * name;
+ int ndefs;
+ struct datatype * types[0];
+};
+
+#define NR_STAB_HASH 521
+
+struct known_typedef * ktd_head[NR_STAB_HASH];
+
+static unsigned int stab_hash( const char * name )
+{
+ unsigned int hash = 0;
+ unsigned int tmp;
+ const char * p;
+
+ p = name;
+
+ while (*p)
+ {
+ hash = (hash << 4) + *p++;
+
+ if( (tmp = (hash & 0xf0000000)) )
+ {
+ hash ^= tmp >> 24;
+ }
+ hash &= ~tmp;
+ }
+ return hash % NR_STAB_HASH;
+}
+
+
static void stab_strcpy(char * dest, const char * source)
{
/*
@@ -89,6 +127,179 @@
*dest++ = '\0';
}
+#define MAX_TD_NESTING 128
+
+static
+int
+DEBUG_RegisterTypedef(const char * name, struct datatype ** types, int ndef)
+{
+ int hash;
+ struct known_typedef * ktd;
+
+ if( ndef == 1 )
+ {
+ return TRUE;
+ }
+
+ ktd = (struct known_typedef *) malloc(sizeof(struct known_typedef)
+ + ndef * sizeof(struct datatype *));
+
+ hash = stab_hash(name);
+
+ ktd->name = xstrdup(name);
+ ktd->ndefs = ndef;
+ memcpy(&ktd->types[0], types, ndef * sizeof(struct datatype *));
+ ktd->next = ktd_head[hash];
+ ktd_head[hash] = ktd;
+
+ return TRUE;
+}
+
+static
+int
+DEBUG_HandlePreviousTypedef(const char * name, const char * stab)
+{
+ int count;
+ enum debug_type expect;
+ int hash;
+ struct known_typedef * ktd;
+ char * ptr;
+ char * tc;
+ int typenum;
+
+ hash = stab_hash(name);
+
+ for(ktd = ktd_head[hash]; ktd; ktd = ktd->next)
+ {
+ if( (ktd->name[0] == name[0])
+ && (strcmp(name, ktd->name) == 0) )
+ {
+ break;
+ }
+ }
+
+ /*
+ * Didn't find it. This must be a new one.
+ */
+ if( ktd == NULL )
+ {
+ return FALSE;
+ }
+
+ /*
+ * Examine the stab to make sure it has the same number of definitions.
+ */
+ count = 0;
+ for(ptr = strchr(stab, '='); ptr; ptr = strchr(ptr+1, '='))
+ {
+ if( count >= ktd->ndefs )
+ {
+ return FALSE;
+ }
+
+ /*
+ * Make sure the types of all of the objects is consistent with
+ * what we have already parsed.
+ */
+ switch(ptr[1])
+ {
+ case '*':
+ expect = POINTER;
+ break;
+ case 's':
+ case 'u':
+ expect = STRUCT;
+ break;
+ case 'a':
+ expect = ARRAY;
+ break;
+ case '1':
+ case 'r':
+ expect = BASIC;
+ break;
+ case 'x':
+ expect = STRUCT;
+ break;
+ case 'e':
+ expect = ENUM;
+ break;
+ case 'f':
+ expect = FUNC;
+ break;
+ default:
+ fprintf(stderr, "Unknown type.\n");
+ return FALSE;
+ }
+ if( expect != DEBUG_GetType(ktd->types[count]) )
+ {
+ return FALSE;
+ }
+ count++;
+ }
+
+ if( ktd->ndefs != count )
+ {
+ return FALSE;
+ }
+
+ /*
+ * OK, this one is safe. Go through, dig out all of the type numbers,
+ * and substitute the appropriate things.
+ */
+ count = 0;
+ for(ptr = strchr(stab, '='); ptr; ptr = strchr(ptr+1, '='))
+ {
+ /*
+ * Back up until we get to a non-numeric character. This is the type
+ * number.
+ */
+ tc = ptr - 1;
+ while( *tc >= '0' && *tc <= '9' )
+ {
+ tc--;
+ }
+
+ typenum = atol(tc + 1);
+ if( num_stab_types <= typenum )
+ {
+ num_stab_types = typenum + 32;
+ stab_types = (struct datatype **) xrealloc(stab_types,
+ num_stab_types * sizeof(struct datatype *));
+ if( stab_types == NULL )
+ {
+ return FALSE;
+ }
+ }
+
+ stab_types[typenum] = ktd->types[count++];
+ }
+
+ return TRUE;
+}
+
+static int DEBUG_FreeRegisteredTypedefs()
+{
+ int count;
+ int j;
+ struct known_typedef * ktd;
+ struct known_typedef * next;
+
+ count = 0;
+ for(j=0; j < NR_STAB_HASH; j++ )
+ {
+ for(ktd = ktd_head[j]; ktd; ktd = next)
+ {
+ count++;
+ next = ktd->next;
+ free(ktd->name);
+ free(ktd);
+ }
+ ktd_head[j] = NULL;
+ }
+
+ return TRUE;
+
+}
static
int
@@ -96,21 +307,33 @@
{
int arrmax;
int arrmin;
- char * c;
+ char * c;
struct datatype * curr_type;
struct datatype * datatype;
+ struct datatype * curr_types[MAX_TD_NESTING];
char element_name[1024];
+ int ntypes = 0;
int offset;
+ const char * orig_typename;
int rtn = FALSE;
int size;
char * tc;
char * tc2;
int typenum;
- /*
- * Go from back to front. First we go through and figure out what type numbers
- * we need, and register those types. Then we go in and fill the details.
+ orig_typename = typename;
+
+ if( DEBUG_HandlePreviousTypedef(typename, ptr) == TRUE )
+ {
+ return TRUE;
+ }
+
+ /*
+ * Go from back to front. First we go through and figure out what
+ * type numbers we need, and register those types. Then we go in
+ * and fill the details.
*/
+
for( c = strchr(ptr, '='); c != NULL; c = strchr(c + 1, '=') )
{
/*
@@ -134,31 +357,47 @@
}
}
+ if( ntypes >= MAX_TD_NESTING )
+ {
+ /*
+ * If this ever happens, just bump the counter.
+ */
+ fprintf(stderr, "Typedef nesting overflow\n");
+ return FALSE;
+ }
+
switch(c[1])
{
case '*':
stab_types[typenum] = DEBUG_NewDataType(POINTER, NULL);
+ curr_types[ntypes++] = stab_types[typenum];
break;
case 's':
case 'u':
stab_types[typenum] = DEBUG_NewDataType(STRUCT, typename);
+ curr_types[ntypes++] = stab_types[typenum];
break;
case 'a':
stab_types[typenum] = DEBUG_NewDataType(ARRAY, NULL);
+ curr_types[ntypes++] = stab_types[typenum];
break;
case '1':
case 'r':
stab_types[typenum] = DEBUG_NewDataType(BASIC, typename);
+ curr_types[ntypes++] = stab_types[typenum];
break;
case 'x':
stab_strcpy(element_name, c + 3);
stab_types[typenum] = DEBUG_NewDataType(STRUCT, element_name);
+ curr_types[ntypes++] = stab_types[typenum];
break;
case 'e':
stab_types[typenum] = DEBUG_NewDataType(ENUM, NULL);
+ curr_types[ntypes++] = stab_types[typenum];
break;
case 'f':
stab_types[typenum] = DEBUG_NewDataType(FUNC, NULL);
+ curr_types[ntypes++] = stab_types[typenum];
break;
default:
fprintf(stderr, "Unknown type.\n");
@@ -166,154 +405,184 @@
typename = NULL;
}
- /*
- * OK, now take a second sweep through. Now we will be digging out the definitions
- * of the various components, and storing them in the skeletons that we have already
- * allocated. We take a right-to left search as this is much easier to parse.
- */
- for( c = strrchr(ptr, '='); c != NULL; c = strrchr(ptr, '=') )
- {
/*
- * Back up until we get to a non-numeric character. This is the type
- * number.
- */
- tc = c - 1;
- while( *tc >= '0' && *tc <= '9' )
- {
- tc--;
- }
- typenum = atol(tc + 1);
- curr_type = stab_types[typenum];
+ * Now register the type so that if we encounter it again, we will know
+ * what to do.
+ */
+ DEBUG_RegisterTypedef(orig_typename, curr_types, ntypes);
- switch(c[1])
- {
- case 'x':
- tc = c + 3;
- while( *tc != ':' )
- {
- tc ++;
- }
- tc++;
- if( *tc == '\0' )
- {
- *c = '\0';
- }
- else
- {
- strcpy(c, tc);
- }
+ /*
+ * OK, now take a second sweep through. Now we will be digging
+ * out the definitions of the various components, and storing
+ * them in the skeletons that we have already allocated. We take
+ * a right-to left search as this is much easier to parse.
+ */
+ for( c = strrchr(ptr, '='); c != NULL; c = strrchr(ptr, '=') )
+ {
+ /*
+ * Back up until we get to a non-numeric character. This is the type
+ * number.
+ */
+ tc = c - 1;
+ while( *tc >= '0' && *tc <= '9' )
+ {
+ tc--;
+ }
+ typenum = atol(tc + 1);
+ curr_type = stab_types[typenum];
+
+ switch(c[1])
+ {
+ case 'x':
+ tc = c + 3;
+ while( *tc != ':' )
+ {
+ tc ++;
+ }
+ tc++;
+ if( *tc == '\0' )
+ {
+ *c = '\0';
+ }
+ else
+ {
+ strcpy(c, tc);
+ }
+
+ break;
+ case '*':
+ case 'f':
+ tc = c + 2;
+ datatype = stab_types[strtol(tc, &tc, 10)];
+ DEBUG_SetPointerType(curr_type, datatype);
+ if( *tc == '\0' )
+ {
+ *c = '\0';
+ }
+ else
+ {
+ strcpy(c, tc);
+ }
+ break;
+ case '1':
+ case 'r':
+ /*
+ * We have already handled these above.
+ */
+ *c = '\0';
+ break;
+ case 'a':
+ tc = c + 5;
+ arrmin = strtol(tc, &tc, 10);
+ tc++;
+ arrmax = strtol(tc, &tc, 10);
+ tc++;
+ datatype = stab_types[strtol(tc, &tc, 10)];
+ if( *tc == '\0' )
+ {
+ *c = '\0';
+ }
+ else
+ {
+ strcpy(c, tc);
+ }
+
+ DEBUG_SetArrayParams(curr_type, arrmin, arrmax, datatype);
+ break;
+ case 's':
+ case 'u':
+ tc = c + 2;
+ if( DEBUG_SetStructSize(curr_type, strtol(tc, &tc, 10)) == FALSE )
+ {
+ /*
+ * We have already filled out this structure. Nothing to do,
+ * so just skip forward to the end of the definition.
+ */
+ while( tc[0] != ';' && tc[1] != ';' )
+ {
+ tc++;
+ }
+
+ tc += 2;
+
+ if( *tc == '\0' )
+ {
+ *c = '\0';
+ }
+ else
+ {
+ strcpy(c, tc + 1);
+ }
+ continue;
+ }
- break;
- case '*':
- case 'f':
- tc = c + 2;
- datatype = stab_types[strtol(tc, &tc, 10)];
- DEBUG_SetPointerType(curr_type, datatype);
- if( *tc == '\0' )
- {
- *c = '\0';
- }
- else
- {
- strcpy(c, tc);
- }
- break;
- case '1':
- case 'r':
- /*
- * We have already handled these above.
- */
- *c = '\0';
- break;
- case 'a':
- tc = c + 5;
- arrmin = strtol(tc, &tc, 10);
- tc++;
- arrmax = strtol(tc, &tc, 10);
- tc++;
- datatype = stab_types[strtol(tc, &tc, 10)];
- if( *tc == '\0' )
- {
- *c = '\0';
- }
- else
- {
- strcpy(c, tc);
- }
-
- DEBUG_SetArrayParams(curr_type, arrmin, arrmax, datatype);
- break;
- case 's':
- case 'u':
- tc = c + 2;
- DEBUG_SetStructSize(curr_type, strtol(tc, &tc, 10));
- /*
- * Now parse the individual elements of the structure/union.
- */
- while(*tc != ';')
- {
- tc2 = element_name;
- while(*tc != ':')
- {
- *tc2++ = *tc++;
- }
- tc++;
- *tc2++ = '\0';
- datatype = stab_types[strtol(tc, &tc, 10)];
- tc++;
- offset = strtol(tc, &tc, 10);
- tc++;
- size = strtol(tc, &tc, 10);
- tc++;
- DEBUG_AddStructElement(curr_type, element_name, datatype, offset, size);
- }
- if( *tc == '\0' )
- {
- *c = '\0';
- }
- else
- {
- strcpy(c, tc + 1);
- }
- break;
- case 'e':
- tc = c + 2;
- /*
- * Now parse the individual elements of the structure/union.
- */
- while(*tc != ';')
- {
- tc2 = element_name;
- while(*tc != ':')
- {
- *tc2++ = *tc++;
- }
- tc++;
- *tc2++ = '\0';
- offset = strtol(tc, &tc, 10);
- tc++;
- DEBUG_AddStructElement(curr_type, element_name, NULL, offset, 0);
- }
- if( *tc == '\0' )
- {
- *c = '\0';
- }
- else
- {
- strcpy(c, tc + 1);
- }
- break;
- default:
- fprintf(stderr, "Unknown type.\n");
- break;
- }
- }
-
- rtn = TRUE;
-
+ /*
+ * Now parse the individual elements of the structure/union.
+ */
+ while(*tc != ';')
+ {
+ tc2 = element_name;
+ while(*tc != ':')
+ {
+ *tc2++ = *tc++;
+ }
+ tc++;
+ *tc2++ = '\0';
+ datatype = stab_types[strtol(tc, &tc, 10)];
+ tc++;
+ offset = strtol(tc, &tc, 10);
+ tc++;
+ size = strtol(tc, &tc, 10);
+ tc++;
+ DEBUG_AddStructElement(curr_type, element_name, datatype, offset, size);
+ }
+ if( *tc == '\0' )
+ {
+ *c = '\0';
+ }
+ else
+ {
+ strcpy(c, tc + 1);
+ }
+ break;
+ case 'e':
+ tc = c + 2;
+ /*
+ * Now parse the individual elements of the structure/union.
+ */
+ while(*tc != ';')
+ {
+ tc2 = element_name;
+ while(*tc != ':')
+ {
+ *tc2++ = *tc++;
+ }
+ tc++;
+ *tc2++ = '\0';
+ offset = strtol(tc, &tc, 10);
+ tc++;
+ DEBUG_AddStructElement(curr_type, element_name, NULL, offset, 0);
+ }
+ if( *tc == '\0' )
+ {
+ *c = '\0';
+ }
+ else
+ {
+ strcpy(c, tc + 1);
+ }
+ break;
+ default:
+ fprintf(stderr, "Unknown type.\n");
+ break;
+ }
+ }
+
+ rtn = TRUE;
+
leave:
-
- return rtn;
+
+ return rtn;
}
@@ -676,6 +945,9 @@
num_stab_types = 0;
}
+
+ DEBUG_FreeRegisteredTypedefs();
+
return TRUE;
}