2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id: rawdofmt.c 37154 2011-02-22 18:42:00Z jmcmullan $
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 adviced to to so because this is a great aid in debugging on user's side.
14 #ifndef NO_RUNTIME_DEBUG
16 #include <exec/execbase.h>
17 #include <exec/rawfmt.h>
18 #include <proto/exec.h>
23 #include "exec_debug.h"
25 const char * const ExecFlagNames
[] =
30 (char *)-1, /* Reserved bit */
43 (char *)-1, /* NoLogServer */
44 (char *)-1, /* NoLogWindow */
45 (char *)-1, /* LogFile */
46 (char *)-1, /* LogKPrintF */
47 (char *)-1, /* PermMemTrack */
49 (char *)-1, /* CyberGuardDelay */
53 (char *)-1, /* PPCStart */
56 (char *)-1, /* Reserved bit */
61 void ExecLog(struct ExecBase
*SysBase
, ULONG flags
, const char *format
, ...)
65 flags
&= SysBase
->ex_DebugFlags
;
70 VLog(SysBase
, flags
, ExecFlagNames
, format
, ap
);
75 * The following stuff is a candidate to become a public API.
76 * Currently i have no idea into what component to put it, so for now
77 * it's exec.library's private property.
78 * The main problem is that we need it very early, before debug.library
79 * and whatever else wakes up.
83 * Return a set of flags specified on the command line.
84 * Option format: <flag1>,<flags>,...,<flagN>
85 * Or: "<flag1> <flag2> ... <flagN>"
87 ULONG
ParseFlags(char *opts
, const char * const *FlagNames
)
98 while (isalpha(*opts
))
103 /* Find the end of the word */
107 /* "ALL" means all flags */
108 if (!strnicmp(opts
, "all", 3))
111 /* Decode flag name */
112 for (i
= 0; FlagNames
[i
]; i
++)
114 const char *flagName
= FlagNames
[i
];
116 if (flagName
== (char *)-1)
119 if (!strnicmp(opts
, flagName
, strlen(flagName
)))
128 /* Skip separator characters */
131 /* If we hit closing quotes or end of line, this is the end */
139 /* Next word is found */
144 /* If the string is not quoted, only single comma is allowed as a separator */
155 void VLog(struct ExecBase
*SysBase
, ULONG flags
, const char * const *FlagNames
, const char *format
, va_list args
)
159 /* Prepend tag (if known) */
160 for (i
= 0; FlagNames
[i
]; i
++)
162 if (FlagNames
[i
] == (char *)-1)
165 if (flags
& (1UL << i
))
167 RawDoFmt("[%s] ", (APTR
)&FlagNames
[i
], (VOID_FUNC
)RAWFMTFUNC_SERIAL
, NULL
);
172 /* Output the message and append a newline (in order not to bother about it every time) */
173 VNewRawDoFmt(format
, (VOID_FUNC
)RAWFMTFUNC_SERIAL
, NULL
, args
);