[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[dotgnu-pnet-commits] pnet ChangeLog engine/debugger.c engine/debugger.h
From: |
Radek Polak |
Subject: |
[dotgnu-pnet-commits] pnet ChangeLog engine/debugger.c engine/debugger.h |
Date: |
Tue, 11 Dec 2007 09:50:59 +0000 |
CVSROOT: /sources/dotgnu-pnet
Module name: pnet
Changes by: Radek Polak <radekp> 07/12/11 09:50:59
Modified files:
. : ChangeLog
engine : debugger.c debugger.h
Log message:
profiling implementation accessible from debugger
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pnet/ChangeLog?cvsroot=dotgnu-pnet&r1=1.3524&r2=1.3525
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/debugger.c?cvsroot=dotgnu-pnet&r1=1.27&r2=1.28
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/debugger.h?cvsroot=dotgnu-pnet&r1=1.7&r2=1.8
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/dotgnu-pnet/pnet/ChangeLog,v
retrieving revision 1.3524
retrieving revision 1.3525
diff -u -b -r1.3524 -r1.3525
--- ChangeLog 9 Dec 2007 21:17:20 -0000 1.3524
+++ ChangeLog 11 Dec 2007 09:50:58 -0000 1.3525
@@ -1,3 +1,9 @@
+2007-12-11 Radek Polak <address@hidden>
+
+ * engine/debugger.c: Implemented simple profiling support in debugger.
+
+ * engine/debugger.h: Definitions for profiler.
+
2007-12-09 Klaus Treichel <address@hidden>
* engine/engine.c: Move thread initialization in front of the creation
Index: engine/debugger.c
===================================================================
RCS file: /sources/dotgnu-pnet/pnet/engine/debugger.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- engine/debugger.c 7 Dec 2007 12:36:13 -0000 1.27
+++ engine/debugger.c 11 Dec 2007 09:50:58 -0000 1.28
@@ -492,7 +492,8 @@
/*
* Set user with out of memory check.
*/
-static void SetUserData(ILDebugger *debugger, void *ptr, int type, void *data)
+static void SetUserData(ILDebugger *debugger, const void *ptr, int type,
+ void *data)
{
if(!ILUserDataSet(debugger->userData, ptr, type, data))
{
@@ -503,7 +504,7 @@
/*
* Return data of given type associated with given pointer.
*/
-static void *GetUserData(ILDebugger *debugger, void *ptr, int type)
+static void *GetUserData(ILDebugger *debugger, const void *ptr, int type)
{
ILUserDataEntry *entry;
@@ -523,7 +524,7 @@
* Return id assigned to given pointer.
* If poineter has no id assigned then return and assign next free negative id.
*/
-static int GetId(ILDebugger *debugger, void *ptr, int type)
+static int GetId(ILDebugger *debugger, const void *ptr, int type)
{
int id = (int) GetUserData(debugger, ptr, type);
if(id == 0)
@@ -1998,6 +1999,102 @@
}
/*
+ * start_profiling command.
+ */
+void StartProfiling(ILDebugger *debugger, FILE *stream)
+{
+ debugger->profiling = 1;
+ DumpMessage("ok", stream);
+}
+
+/*
+ * stop_profiling command.
+ */
+void StopProfiling(ILDebugger *debugger, FILE *stream)
+{
+ debugger->profiling = 0;
+ DumpMessage("ok", stream);
+}
+
+/*
+ * clear_profiling command.
+ */
+void ClearProfiling(ILDebugger *debugger, FILE *stream)
+{
+ int size;
+ ILUserDataEntry *entry;
+ ILDebuggerThreadInfo *threadInfo;
+
+ /* Iterate userData table and clear profiling related info */
+ entry = debugger->userData->entries;
+ for(size = debugger->userData->size; size > 0; size--)
+ {
+ if(entry->type == IL_USER_DATA_METHOD_TIME ||
+ entry->type == IL_USER_DATA_METHOD_CALL_COUNT)
+ {
+ SetUserData(debugger, entry->ptr, entry->type, (void *)
0);
+ }
+ entry++;
+ }
+
+ /* Iterate all threads and clear profiling info */
+ threadInfo = debugger->dbthread;
+ while(threadInfo)
+ {
+ threadInfo->profilerLastMethod = 0;
+ threadInfo = threadInfo->next;
+ }
+
+ DumpMessage("ok", stream);
+}
+
+/*
+ * show_profiling command.
+ */
+void ShowProfiling(ILDebugger *debugger, FILE *stream)
+{
+ int size;
+ ILUserDataEntry *entry;
+ ILUInt32 time;
+ ILUInt32 count;
+ int memberId;
+
+ fputs("<Profiling>\n", stream);
+
+ /* Iterate userData table and dump profiling related info */
+ entry = debugger->userData->entries;
+ for(size = debugger->userData->size; size > 0; size--)
+ {
+ /* Case with entry->ptr==0 is valid and must be skipped */
+ if(entry->type == IL_USER_DATA_METHOD_TIME && entry->ptr != 0)
+ {
+ time = (ILUInt32) entry->data;
+ count = (ILUInt32) GetUserData(debugger, entry->ptr,
+
IL_USER_DATA_METHOD_CALL_COUNT);
+ memberId = GetId(debugger, entry->ptr,
IL_USER_DATA_MEMBER_ID);
+
+ fprintf(stream,
+ " <ProfilingEntry
MemberId=\"%d\" CallCount=\"%d\" "
+ "Time=\"%d\"", memberId, count,
time);
+
+ if(memberId >= 0)
+ {
+ fputs(" />\n", stream);
+ }
+ else
+ {
+ fputs(" >\n", stream);
+ DumpMethod(debugger, stream, (ILMethod *)
entry->ptr, 0, 4);
+ fputs(" </ProfilingEntry>\n", stream);
+ }
+ }
+ entry++;
+ }
+
+ fputs("</Profiling>", stream);
+}
+
+/*
* show_threads command.
*/
void ShowThreads(ILDebugger *debugger, FILE *stream)
@@ -2515,6 +2612,24 @@
"Remove all assembly watches that were previously set with
watch_assembly. This causes that debugger can break in any assembly again. Only
functions, that were not compiled yet are affected."
},
+ { "start_profiling",
StartProfiling,
+ "start_profiling",
+ "Start profiling.",
+ "Starts profiling execution speed and memory usage."
+ },
+
+ { "stop_profiling",
StopProfiling,
+ "stop_profiling",
+ "Stops profiling.",
+ "Stops profiling."
+ },
+
+ { "clear_profiling",
ClearProfiling,
+ "clear_profiling",
+ "Clear profiling results.",
+ "Clears all previous profiling results."
+ },
+
{ "insert_breakpoint",
InsertBreakpoint,
"insert_breakpoint [source_file] [line]",
"Break when given location is reached.",
@@ -2672,6 +2787,12 @@
"Dissassemble current function in IL."
},
+ { "show_profiling",
ShowProfiling,
+ "show_profiling",
+ "Show current profiling results.",
+ "Show current profiling results. Times are in microseconds."
+ },
+
{ "quit",
Quit,
"quit",
"Abort debugged program.",
@@ -2965,6 +3086,10 @@
ILDebugger *debugger;
ILDebuggerThreadInfo *info;
ILBreakpoint *breakpoint;
+ ILCurrTime time;
+ ILInt64 delta;
+ ILInt64 total;
+ ILUInt32 count;
/* Get debugger attached to thread's process */
debugger = _ILExecThreadProcess(thread)->debugger;
@@ -2998,6 +3123,43 @@
/* fprintf(stderr, " runType=%d breakAll=%d\n", info->runType,
debugger->breakAll); */
+ /* Update profiling info */
+ if(debugger->profiling)
+ {
+ ILGetSinceRebootTime(&time);
+
+ /* Time difference between last profiler hit and current time */
+ delta = time.nsecs;
+ delta -= info->profilerLastStopTime.nsecs;
+ delta /= 1000;
+ delta += 1000000 *
+ (time.secs -
info->profilerLastStopTime.secs);
+
+ /* Add time delta to previous hit */
+ total = (ILUInt32) GetUserData(debugger,
+
(void *) info->profilerLastMethod,
+
IL_USER_DATA_METHOD_TIME);
+ total += delta;
+ SetUserData(debugger, (void *) info->profilerLastMethod,
+
IL_USER_DATA_METHOD_TIME,
+
(void *)(ILUInt32)total);
+
+ /* Increase method call count */
+ if(offset == 0)
+ {
+ count = (ILUInt32) GetUserData(debugger, (void *)
method,
+
IL_USER_DATA_METHOD_CALL_COUNT);
+ count++;
+ SetUserData(debugger, (void *) method,
+
IL_USER_DATA_METHOD_CALL_COUNT,
+
(void *)count);
+ }
+
+ /* Record this profiler hit */
+ info->profilerLastMethod = method;
+ info->profilerLastStopTime = time;
+ }
+
if(debugger->breakAll)
{
/* Always stop when break requested (by break command) */
@@ -3128,10 +3290,15 @@
{
return IL_HOOK_ABORT;
}
- else
+
+ if(debugger->profiling)
{
- return IL_HOOK_CONTINUE;
+ /* Refresh time to not count hanging inside debugger loop */
+ ILGetSinceRebootTime(&time);
+ info->profilerLastStopTime = time;
}
+
+ return IL_HOOK_CONTINUE;
}
/*
Index: engine/debugger.h
===================================================================
RCS file: /sources/dotgnu-pnet/pnet/engine/debugger.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- engine/debugger.h 14 Jun 2007 09:05:17 -0000 1.7
+++ engine/debugger.h 11 Dec 2007 09:50:58 -0000 1.8
@@ -54,6 +54,8 @@
#define IL_USER_DATA_SOURCE_FILE_ID 2
#define IL_USER_DATA_SOURCE_FILE_IMAGE_ID 3
#define IL_USER_DATA_MEMBER_ID 4
+#define IL_USER_DATA_METHOD_CALL_COUNT 5
+#define IL_USER_DATA_METHOD_TIME 6
#define IL_USER_DATA_TABLE_INIT_SIZE 509
@@ -127,6 +129,12 @@
jit_stack_trace_t jitStackTrace;
#endif
+ /* Method where profiler stopped last time */
+ ILMethod *profilerLastMethod;
+
+ /* Previous profiler stop time */
+ ILCurrTime profilerLastStopTime;
+
int volatile runType;
ILDebuggerThreadInfo *next;
};
@@ -219,6 +227,9 @@
/* Flag used to stop all threads after break command */
int breakAll;
+ /* Nonzero to collect profiling information */
+ int profiling;
+
/* Return IL_HOOK_ABORT from hook function when this flag is set */
int volatile abort;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [dotgnu-pnet-commits] pnet ChangeLog engine/debugger.c engine/debugger.h,
Radek Polak <=