[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[dotgnu-pnet-commits] pnet ChangeLog engine/debugger.c
From: |
Radek Polak |
Subject: |
[dotgnu-pnet-commits] pnet ChangeLog engine/debugger.c |
Date: |
Sun, 30 Dec 2007 00:09:44 +0000 |
CVSROOT: /sources/dotgnu-pnet
Module name: pnet
Changes by: Radek Polak <radekp> 07/12/30 00:09:43
Modified files:
. : ChangeLog
engine : debugger.c
Log message:
implemented locals and functions parameters in debugger with CVM engine
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pnet/ChangeLog?cvsroot=dotgnu-pnet&r1=1.3529&r2=1.3530
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/debugger.c?cvsroot=dotgnu-pnet&r1=1.30&r2=1.31
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/dotgnu-pnet/pnet/ChangeLog,v
retrieving revision 1.3529
retrieving revision 1.3530
diff -u -b -r1.3529 -r1.3530
--- ChangeLog 26 Dec 2007 15:35:09 -0000 1.3529
+++ ChangeLog 30 Dec 2007 00:09:43 -0000 1.3530
@@ -1,3 +1,8 @@
+2007-12-30 Radek Polak <address@hidden>
+
+ * engine/debugger.c: Implemented local variables and function parameters
+ for CVM coder.
+
2007-12-26 Klaus Treichel <address@hidden>
* engine/jitc.c: Fix a bug in AdjustMixedBinary when checking for
pointer
Index: engine/debugger.c
===================================================================
RCS file: /sources/dotgnu-pnet/pnet/engine/debugger.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -b -r1.30 -r1.31
--- engine/debugger.c 20 Dec 2007 13:29:28 -0000 1.30
+++ engine/debugger.c 30 Dec 2007 00:09:43 -0000 1.31
@@ -1632,24 +1632,106 @@
return result;
}
+static void UpdateThis(ILExecThread *thread, ILMethod *method, void *addr,
+ ILUInt32 *paramDebugIndex)
+{
+ ILType *type;
+
+ type = ILType_FromClass(ILMethod_Owner(method));
+ DebuggerHelper_AddLocal(thread, "this", type, addr);
+ (*paramDebugIndex)++;
+}
+
+static void UpdatePram(ILExecThread *thread, ILMethod *method,
+ ILUInt32 *currentParam, ILUInt32
offset, void *addr,
+ ILUInt32 *paramDebugIndex, ILType
*paramSignature,
+ ILDebugContext *dbgc)
+{
+ ILType *type;
+ const char *name = 0;
+
+ type = ILTypeGetParam(paramSignature, *currentParam);
+ if(dbgc)
+ {
+ name = ILDebugGetVarName(dbgc, ILMethod_Token(method), offset,
+
(*paramDebugIndex) | 0x80000000);
+ }
+ if(ILType_IsComplex(type) && ILType_Kind(type) == IL_TYPE_COMPLEX_BYREF)
+ {
+ DebuggerHelper_AddLocal(thread, name, ILType_Ref(type),
+
*((void **)(addr)));
+ }
+ else
+ {
+ DebuggerHelper_AddLocal(thread, name, type, addr);
+ }
+ (*currentParam)++;
+ (*paramDebugIndex)++;
+}
+
+static void UpdateLocal(ILExecThread *thread, ILMethod *method,
+ ILUInt32 *currentLocal,
ILUInt32 offset, void *addr,
+ ILType *localSignature,
ILDebugContext *dbgc)
+{
+ ILType *type;
+ const char *name = 0;
+
+ type = ILTypeGetLocal(localSignature, *currentLocal);
+ if(dbgc)
+ {
+ name = ILDebugGetVarName(dbgc, ILMethod_Token(method), offset,
+
*currentLocal);
+ }
+ if(name || dbgc == 0)
+ {
+ DebuggerHelper_AddLocal(thread, name, type, addr);
+ }
+ (*currentLocal)++;
+}
+
+/*
+ * Get the size of a type in stack words, taking float expansion into account.
+ * TODO: this function is already defined in cvmc.c but there is no way how
+ * to include it now.
+ */
+static ILUInt32 GetStackTypeSize(ILExecProcess *process, ILType *type)
+{
+ ILUInt32 size;
+ if(type == ILType_Float32 || type == ILType_Float64)
+ {
+ return CVM_WORDS_PER_NATIVE_FLOAT;
+ }
+ else
+ {
+ size = _ILSizeOfTypeLocked(process, type);
+ }
+ return (size + sizeof(CVMWord) - 1) / sizeof(CVMWord);
+}
+
/*
* Update locals in DebuggerHelper class.
*/
static void UpdateLocals(FILE *stream, ILExecThread *thread, ILMethod *method,
ILUInt32 offset)
{
-#ifdef IL_USE_JIT
ILMethodCode code;
ILType *localSignature;
ILType *paramSignature;
ILUInt32 currentLocal;
ILUInt32 currentParam;
ILUInt32 paramDebugIndex;
+ ILDebugContext *dbgc = 0;
+ ILType *type;
+
+#ifdef IL_USE_JIT
ILUInt32 i;
ILLocalWatch *watch;
- ILType *type;
- const char *name = 0;
- ILDebugContext *dbgc = 0;
+#else
+ CVMWord *p;
+ int hasThis;
+ ILUInt32 numParams;
+ ILUInt32 numLocals;
+#endif
/* Clear locals in helper class */
DebuggerHelper_ClearLocals(thread);
@@ -1678,7 +1760,8 @@
/* Get the symbol debug information */
if((dbgc = ILDebugCreate(ILProgramItem_Image(method))) == 0)
{
- ILDbOutOfMemory();
+ DumpOutOfMemoryError(stream);
+ return;
}
}
@@ -1686,6 +1769,8 @@
currentLocal = 0;
currentParam = 1;
paramDebugIndex = 0;
+
+#if IL_USE_JIT
for(i = 0; i < thread->numWatches; i++)
{
watch = &(thread->watchStack[i]);
@@ -1698,47 +1783,60 @@
if(watch->type == IL_LOCAL_WATCH_TYPE_LOCAL_VAR)
{
- type = ILTypeGetLocal(localSignature, currentLocal);
- if(dbgc)
+ UpdateLocal(thread, method, ¤tLocal, offset,
watch->addr,
+
localSignature, dbgc);
+ }
+ else if(watch->type == IL_LOCAL_WATCH_TYPE_PARAM)
{
- name = ILDebugGetVarName(dbgc,
ILMethod_Token(method), offset,
-
currentLocal);
+ UpdatePram(thread, method, ¤tParam, offset,
watch->addr,
+
¶mDebugIndex, paramSignature, dbgc);
}
- if(name || dbgc == 0)
+ else if(watch->type == IL_LOCAL_WATCH_TYPE_THIS)
{
- DebuggerHelper_AddLocal(thread, name, type,
watch->addr);
+ UpdateThis(thread, method, watch->addr,
¶mDebugIndex);
}
- currentLocal++;
}
- else if(watch->type == IL_LOCAL_WATCH_TYPE_PARAM)
- {
- type = ILTypeGetParam(paramSignature, currentParam);
- if(dbgc)
+#else
+ p = thread->frame;
+ hasThis = ILType_HasThis(paramSignature);
+
+ /* Handle the "this" parameter as necessary */
+ if(hasThis)
{
- name = ILDebugGetVarName(dbgc,
ILMethod_Token(method), offset,
-
paramDebugIndex | 0x80000000);
+ UpdateThis(thread, method, (void *) p++, ¶mDebugIndex);
}
- if(ILType_IsComplex(type) &&
-
ILType_Kind(type) == IL_TYPE_COMPLEX_BYREF)
+
+ /* Regular arguments */
+ numParams = ILTypeNumParams(paramSignature);
+
+ while(currentParam <= numParams)
{
- DebuggerHelper_AddLocal(thread, name,
ILType_Ref(type),
-
*((void **)(watch->addr)));
+ type = ILTypeGetEnumType(ILTypeGetParam(paramSignature,
currentParam));
+
+ UpdatePram(thread, method, ¤tParam, offset, (void *) p,
+
¶mDebugIndex, paramSignature, dbgc);
+
+ p += GetStackTypeSize(ILExecThreadGetProcess(thread), type);
}
- else
+
+ /* Local variables */
+ if(localSignature != 0)
{
- DebuggerHelper_AddLocal(thread, name, type,
watch->addr);
- }
- currentParam++;
- paramDebugIndex++;
- }
- else if(watch->type == IL_LOCAL_WATCH_TYPE_THIS)
+ numLocals = ILTypeNumLocals(localSignature);
+ while(currentLocal < numLocals)
{
- type = ILType_FromClass(ILMethod_Owner(method));
- DebuggerHelper_AddLocal(thread, "this", type,
watch->addr);
- paramDebugIndex++;
+ type = ILTypeGetEnumType(ILTypeGetLocal(localSignature,
+
currentLocal));
+
+ UpdateLocal(thread, method, ¤tLocal, offset,
(void *) p,
+
localSignature, dbgc);
+
+ p += GetStackTypeSize(ILExecThreadGetProcess(thread),
type);
}
}
+#endif // IL_USE_JIT
+
if(dbgc)
{
ILDebugDestroy(dbgc);
@@ -1747,8 +1845,6 @@
/* Update method's owner type */
type = ILType_FromClass(ILMethod_Owner(method));
DebuggerHelper_SetMethodOwner(thread, type);
-
-#endif
}
/*
@@ -1756,18 +1852,6 @@
*/
void ShowLocals(ILDebugger *debugger, FILE *stream)
{
-#ifdef IL_USE_CVM
- CVMWord *p;
- ILExecThread *thread = debugger->dbthread->execThread;
- fputs("<LocalVariables>\n", stream);
- for(p = thread->frame; p < thread->stackTop; p++)
- {
- fprintf(stream, " <LocalVariable Value=\"%d\" />\n",
p->intValue);
- }
- fputs("</LocalVariables>",stream);
-#endif
-
-#ifdef IL_USE_JIT
char *str;
/* Update locals in DebuggerHelper class */
@@ -1790,7 +1874,6 @@
{
DumpOutOfMemoryError(stream);
}
-#endif // IL_USE_JIT
}
/*