1 /***********************************************************************/
2 /* Open Visualization Data Explorer                                    */
3 /* (C) Copyright IBM Corp. 1989,1999                                   */
4 /* ALL RIGHTS RESERVED                                                 */
5 /* This code licensed under the                                        */
6 /*    "IBM PUBLIC LICENSE - Open Visualization Data Explorer"          */
7 /***********************************************************************/
8 
9 #include <dxconfig.h>
10 
11 #if defined(HAVE_STRING_H)
12 #include <string.h>
13 #endif
14 
15 #include <dx/dx.h>
16 #include "trace.h"
17 
18 extern void  _dxfTraceObjects(int d); /* from libdx/object.c */
19 extern void DXTraceTask(int t); /* from dpexec/task.c */
20 
21 #if 0
22 Error DXTagMemory(int n);
23 #endif
24 
25 
26 Error
m_Trace(Object * in,Object * out)27 m_Trace(Object *in, Object *out)
28 {
29     char *s;
30     int how = 1;
31 
32     if (!DXExtractString(in[0], &s)) {
33 	DXSetError(ERROR_BAD_PARAMETER, "#10200", "`trace'");
34 	return ERROR;
35     }
36     if (in[1] && !DXExtractInteger(in[1], &how)) {
37 	DXSetError(ERROR_BAD_PARAMETER, "#10010", "`how'");
38 	return ERROR;
39     }
40 
41     if (strcmp(s, "memory")==0)
42 	DXTraceAlloc(how);
43 
44 #if 0
45     else if (strcmp(s, "tag memory")==0)
46 	DXTagMemory(how);
47 #endif
48 
49     else if (strcmp(s, "objects")==0)
50 	_dxfTraceObjects(how);
51 
52     else if (strcmp(s, "tasks")==0)
53 	DXTraceTask(how);
54 
55 #if 1
56     else if (strcmp(s, "visual memory")==0)
57 	DXVisualizeMemory(how, 0);
58 #endif
59 
60 #if 0
61     else if (strcmp(s, "dump memory")==0)
62 	DXMemoryDump(how);
63 #endif
64 
65     else if (strcmp(s, "time")==0) {
66         if (how==0)
67             DXPrintTimes();
68 	DXTraceTime(how);
69     }
70 
71     else
72 	DXEnableDebug(s, how);
73 
74     return OK;
75 }
76