34 const char *
const * argv)
39 if (!strcmp(cmd,
"help"))
46 dbg <<
"debug group help:\n"
47 " list, io, alwaysflush, timestamp, exit, clear, add, view\n";
50 else if (!strcmp(argv[0],
"list"))
52 dbg <<
"list (g|l|d|a|c) [ <pattern> ]\n"
54 "Shows some or all items of a specific type.\n"
56 "The following items are supported:\n"
57 "- g: command groups\n"
58 "- l: log groups (only those encountered yet)\n"
59 "- d: log groups with descriptions (only those that have descriptions)\n"
60 "- a: asserts/crashes (only those hit yet)\n"
61 "- c: checks (only those failed yet)\n"
63 "If a pattern is specified only items matching\n"
64 "that pattern are shown. A pattern can contain\n"
65 "any character, letter, or a wildcard '*'.\n"
67 "Please note that assert, crashes, and check items have\n"
68 "their line number appended to the current file name,\n"
69 "e.g. debug.cpp(13).\n";
72 else if (!strcmp(argv[0],
"io"))
74 dbg <<
"io <I/O Class> <cmd> { <param> }]\n"
76 "Issues a I/O class command. I/O class commands are used\n"
77 "for determining where all log output should be sent. \n"
78 "Please check the list of \ref debug_ioclasses for a list\n"
79 "of existing I/O classes.\n"
81 "Each existing I/O class must accept at least the\n"
82 "following two commands: 'add' and 'remove'. Usually\n"
83 "after a class has been added it reacts to the 'help'\n"
86 "If the command is entered without any parameters a list\n"
87 "of active I/O classes is shown. Typing 'io ?' retrieves\n"
88 "a list of possible I/O classes.\n";
91 else if (!strcmp(argv[0],
"alwaysflush"))
93 dbg <<
"alwaysflush [ (+|-) ]\n\n"
94 "Enables/disables flushing after each new entry in\n"
95 "the log file (default: off).\n";
98 else if (!strcmp(argv[0],
"timestamp"))
100 dbg <<
"timestamp [ (+|-) ]\n\n"
101 "Enables/disables timestamping each log entry\n"
105 else if (!strcmp(argv[0],
"exit"))
107 dbg <<
"exit\n\nExits program immediately.\n";
110 else if (!strcmp(argv[0],
"clear"))
112 dbg <<
"clear (l|a|c)\n\n"
113 "Clears the given inclusion/exclusion list\n"
114 "(l=logs, a=asserts/crashes, c=checks).\n";
117 else if (!strcmp(argv[0],
"add"))
119 dbg <<
"add (l|a|c) (+|-) <pattern>\n"
121 "Adds a pattern to the given list (l=logs, \n"
122 "a=asserts/crashes, c=checks). By default all\n"
123 "asserts, crashes, and checks are active, all logs\n"
124 "inactive. Each item is then checked \n"
125 "against all pattern in the respective\n"
126 "list. If a match is found the active/inactive\n"
127 "state is modified accordingly (+ for active,\n"
128 "- for inactive). The final state is always\n"
132 else if (!strcmp(argv[0],
"view"))
134 dbg <<
"view [ (l|a|c) ]\n\n"
135 "Shows the active pattern for the given list\n"
136 "(l=logs, a=asserts/crashes, c=checks).\n";
141 if (!strcmp(cmd,
"list"))
143 const char *pattern=argn>=2?argv[1]:
"*";
145 switch(argn?*argv[0]:0)
150 dbg <<
"Command groups:\n";
151 for (Debug::CmdInterfaceListEntry *cur=dbg.firstCmdGroup;cur;cur=cur->next)
153 dbg << cur->group <<
"\n";
161 for (Debug::KnownLogGroupList *cur=dbg.firstLogGroup;cur;cur=cur->next)
163 (*argv[0]==
'l'||cur->descr))
165 dbg << cur->nameGroup;
167 dbg <<
" (" << cur->descr <<
")";
176 dbg << (*argv[0]==
'a'?
"Asserts/Crashes:\n":
"Checks:\n");
177 unsigned mask=*argv[0]==
'a'?Debug::FrameTypeAssert:Debug::FrameTypeCheck;
178 for (
unsigned k=0;k<Debug::FRAME_HASH_SIZE;k++)
180 for (Debug::FrameHashEntry *cur=dbg.frameHash[k];cur;cur=cur->next)
182 if (!(cur->frameType&mask))
186 wsprintf(help,
"%s(%i)",cur->fileOrGroup,cur->line);
189 dbg << help <<
" (" << cur->hits <<
" hits)";
190 if (cur->status==Debug::Skip)
199 dbg <<
"Unknown item type, see help.";
204 if (!strcmp(cmd,
"io"))
207 if (!argn||!strcmp(argv[0],
"?"))
211 dbg << (argn?
"Possible:\n":
"Active:\n");
214 for (Debug::IOFactoryListEntry *cur=dbg.firstIOFactory;cur;cur=cur->next)
220 dbg << cur->ioID <<
" (" << cur->descr <<
")\n";
222 if (normalMode&&!hadItem)
230 for (Debug::IOFactoryListEntry *cur=dbg.firstIOFactory;cur;cur=cur->next)
231 if (!strcmp(argv[0],cur->ioID))
235 dbg <<
"Unknown I/O class " << argv[0];
242 if (!strcmp(argv[1],
"add"))
246 dbg <<
"I/O class already added";
249 cur->io=cur->factory();
252 dbg <<
"I/O class factory failed";
257 if (!strcmp(argv[1],
"remove"))
271 dbg <<
"Add I/O class first";
275 cur->io->Execute(dbg,argn>1?argv[1]:
NULL,!normalMode,argn>1?argn-2:0,argv+2);
279 if (!strcmp(cmd,
"alwaysflush"))
284 dbg.alwaysFlush=
true;
286 dbg.alwaysFlush=
false;
289 dbg <<
"Always flush: " << (dbg.alwaysFlush?
"on":
"off");
291 dbg << (dbg.alwaysFlush?
"1":
"0");
295 if (!strcmp(cmd,
"timestamp"))
305 dbg <<
"Timestamp: " << (dbg.timeStamp?
"on":
"off");
307 dbg << (dbg.timeStamp?
"1":
"0");
311 if (!strcmp(cmd,
"exit"))
316 if (!strcmp(cmd,
"clear")||
323 for (
const char *p=argv[0];*p;p++)
327 case 'l': mask|=Debug::FrameTypeLog;
break;
328 case 'a': mask|=Debug::FrameTypeAssert;
break;
329 case 'c': mask|=Debug::FrameTypeCheck;
break;
337 if (!strcmp(cmd,
"clear"))
340 const char *pattern=argn<2?
"*":argv[1];
341 for (Debug::PatternListEntry **entryPtr=&dbg.firstPatternEntry;*entryPtr;)
343 if ( (((*entryPtr)->frameTypes&mask)!=0)
348 Debug::PatternListEntry *cur=*entryPtr;
354 entryPtr=&((*entryPtr)->next);
358 if (dbg.firstPatternEntry)
360 for (Debug::PatternListEntry *cur=dbg.firstPatternEntry;cur->next;cur=cur->next);
361 dbg.lastPatternEntry=cur;
364 dbg.lastPatternEntry=
NULL;
366 if (!strcmp(cmd,
"add"))
370 dbg <<
"Please specify mode and pattern";
373 dbg.AddPatternEntry(mask,*argv[1]==
'+',argv[2]);
377 if (!strcmp(cmd,
"view"))
380 for (Debug::PatternListEntry *cur=dbg.firstPatternEntry;cur;cur=cur->next)
382 if (!(cur->frameTypes&mask))
385 if (cur->frameTypes&Debug::FrameTypeLog) dbg <<
"l";
386 if (cur->frameTypes&Debug::FrameTypeAssert) dbg <<
"a";
387 if (cur->frameTypes&Debug::FrameTypeCheck) dbg <<
"c";
389 dbg << (cur->isActive?
" + ":
" - ") << cur->pattern <<
"\n";
396 for (
unsigned k=0;k<Debug::FRAME_HASH_SIZE;k++)
397 for (Debug::FrameHashEntry *cur=dbg.frameHash[k];cur;cur=cur->next)
398 cur->status=Debug::Unknown;
virtual bool Execute(class Debug &dbg, const char *cmd, CommandMode cmdmode, unsigned argn, const char *const *argv)
Execute the given command.