64 unsigned argn,
const char *
const * argv)
69 if (!strcmp(cmd,
"help"))
76 dbg <<
"profile group help:\n"
77 " result, caller, clear, add, view\n";
80 else if (!strcmp(argv[0],
"result"))
83 "Shows the list of available result functions and their\n"
84 "optional parameters.\n"
86 "result <res_func_name> [ <arg1> .. <argN> ]\n\n"
87 "Adds the given result function to be executed on program\n"
90 else if (!strcmp(argv[0],
"caller"))
92 dbg <<
"caller [ (+|-) ]\n\n"
93 "Enables/disables recording of caller information while\n"
94 "performing function level profiling. Turned off by default\n"
95 "since CPU hit is non-zero.\n";
97 else if (!strcmp(argv[0],
"clear"))
100 "Clears the profile inclusion/exclusion list.\n";
103 else if (!strcmp(argv[0],
"add"))
105 dbg <<
"add (+|-) <pattern>\n"
107 "Adds a pattern to the profile list. By default all\n"
108 "profile ranges are disabled. Each new range is then checked\n"
109 "against all pattern in this list. If a match is found the\n"
110 "active/inactive state is modified accordingly (+ for active,\n"
111 "- for inactive). The final state is always the last match.";
114 else if (!strcmp(argv[0],
"view"))
117 "Shows the active pattern list.\n";
124 if (!strcmp(cmd,
"result"))
128 for (
unsigned k=0;k<numResIf;k++)
130 dbg << resIf[k].name;
131 if ((resIf[k].arg&&*resIf[k].arg)||!normalMode)
132 dbg <<
"\n " << resIf[k].arg;
138 for (
unsigned k=0;k<numResIf;k++)
139 if (!strcmp(argv[0],resIf[k].name))
143 dbg <<
"Unknown result function\n";
150 dbg <<
"Could not add result function\n";
156 resFunc[numResFunc-1]=newIf;
158 dbg <<
"Result function " << argv[0] <<
" added\n";
165 if (!strcmp(cmd,
"caller"))
171 ProfileFuncLevelTracer::recordCaller=
true;
173 ProfileFuncLevelTracer::recordCaller=
false;
176 dbg <<
"Record caller: " << (ProfileFuncLevelTracer::recordCaller?
"on":
"off");
178 dbg << (ProfileFuncLevelTracer::recordCaller?
"1":
"0");
185 if (!strcmp(cmd,
"clear"))
188 const char *pattern=argn<1?
"*":argv[0];
189 for (Profile::PatternListEntry **entryPtr=&Profile::firstPatternEntry;*entryPtr;)
191 if (Profile::SimpleMatch((*entryPtr)->pattern,pattern))
194 Profile::PatternListEntry *cur=*entryPtr;
200 entryPtr=&((*entryPtr)->next);
204 if (Profile::firstPatternEntry)
206 for (Profile::PatternListEntry *cur=Profile::firstPatternEntry;cur->next;cur=cur->next);
207 Profile::lastPatternEntry=cur;
210 Profile::lastPatternEntry=
NULL;
215 if (!strcmp(cmd,
"add"))
219 dbg <<
"Please specify mode and pattern";
223 Profile::PatternListEntry *cur=(Profile::PatternListEntry *)
228 cur->isActive=*argv[0]==
'+';
230 strcpy(cur->pattern,argv[1]);
233 if (Profile::lastPatternEntry)
234 Profile::lastPatternEntry->next=cur;
236 Profile::firstPatternEntry=cur;
237 Profile::lastPatternEntry=cur;
243 if (!strcmp(cmd,
"view"))
246 for (Profile::PatternListEntry *cur=Profile::firstPatternEntry;cur;cur=cur->next)
247 dbg << (cur->isActive?
"+ ":
"- ") << cur->pattern <<
"\n";
virtual bool Execute(class Debug &dbg, const char *cmd, CommandMode cmdmode, unsigned argn, const char *const *argv)
Execute the given command.