2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
5 Desc: Runtime debugging support
10 * You can #define this in order to omit the whole code. Perhaps ROM-based systems
11 * will want to do this.
12 * However it's not advised to do so because this is a great aid in debugging
15 #ifndef NO_RUNTIME_DEBUG
17 #include <exec/execbase.h>
18 #include <exec/rawfmt.h>
19 #include <proto/exec.h>
24 #include "exec_debug.h"
26 const char * const ExecFlagNames
[] =
31 (char *)-1, /* Reserved bit */
44 (char *)-1, /* NoLogServer */
45 (char *)-1, /* NoLogWindow */
46 (char *)-1, /* LogFile */
47 (char *)-1, /* LogKPrintF */
48 (char *)-1, /* PermMemTrack */
50 (char *)-1, /* CyberGuardDelay */
54 (char *)-1, /* PPCStart */
57 (char *)-1, /* Reserved bit */
62 void ExecLog(struct ExecBase
*SysBase
, ULONG flags
, const char *format
, ...)
66 flags
&= SysBase
->ex_DebugFlags
;
71 VLog(SysBase
, flags
, ExecFlagNames
, format
, ap
);
76 * The following stuff is a candidate to become a public API.
77 * Currently i have no idea into what component to put it, so for now
78 * it's exec.library's private property.
79 * The main problem is that we need it very early, before debug.library
80 * and whatever else wakes up.
84 * Return a set of flags specified on the command line.
85 * Option format: <flag1>,<flags>,...,<flagN>
86 * Or: "<flag1> <flag2> ... <flagN>"
88 ULONG
ParseFlags(char *opts
, const char * const *FlagNames
)
99 while (isalpha(*opts
))
104 /* Find the end of the word */
108 /* "ALL" means all flags */
109 if (!strnicmp(opts
, "all", 3))
112 /* Decode flag name */
113 for (i
= 0; FlagNames
[i
]; i
++)
115 const char *flagName
= FlagNames
[i
];
117 if (flagName
== (char *)-1)
120 if (!strnicmp(opts
, flagName
, strlen(flagName
)))
129 /* Skip separator characters */
132 /* If we hit closing quotes or end of line, this is the end */
140 /* Next word is found */
145 /* If the string is not quoted, only single comma is allowed as a separator */
156 void VLog(struct ExecBase
*SysBase
, ULONG flags
, const char * const *FlagNames
, const char *format
, va_list args
)
160 /* Prepend tag (if known) */
161 for (i
= 0; FlagNames
[i
]; i
++)
163 if (FlagNames
[i
] == (char *)-1)
166 if (flags
& (1UL << i
))
168 RawDoFmt("[%s] ", (APTR
)&FlagNames
[i
], (VOID_FUNC
)RAWFMTFUNC_SERIAL
, NULL
);
173 /* Output the message and append a newline (in order not to bother about it every time) */
174 VNewRawDoFmt(format
, (VOID_FUNC
)RAWFMTFUNC_SERIAL
, NULL
, args
);