2 Copyright © 2006-2011, The AROS Development Team. All rights reserved.
6 #include <aros/config.h>
7 #include <aros/debug.h>
11 #include <proto/dos.h>
12 #include <proto/arossupport.h>
13 #include <proto/exec.h>
29 Locale_Deinitialize();
33 static void prettyprint(CONST_STRPTR str
, LONG minlen
)
36 LONG len
= strlen(str
);
38 RawPutChars(str
, len
);
40 for (i
= len
; i
< minlen
; i
++)
47 // eye-catching function name because this is what we'd see in the debugger
48 static void SNOOPY_breakpoint(void)
50 // interrupting makes only sense on "hosted" where we have a debugger
51 #if (AROS_FLAVOUR & AROS_FLAVOUR_EMULATION)
52 #if defined(__i386__) || defined(__x86_64__)
54 #elif defined(__powerpc__)
57 // TODO: other platforms
58 kprintf("[SNOOP] interrupt not supported on this platform\n");
64 void main_output(CONST_STRPTR action
, CONST_STRPTR target
, CONST_STRPTR option
, IPTR result
, BOOL canInterrupt
)
66 struct Task
*thistask
= SysBase
->ThisTask
;
67 STRPTR name
= thistask
->tc_Node
.ln_Name
;
69 if (setup
.onlyShowFails
&& result
) return;
72 if ( ! stricmp(name
, "wanderer:wanderer")) return;
73 if ( ! stricmp(name
, "new shell")) return;
74 if ( ! stricmp(name
, "newshell")) return;
75 if ( ! stricmp(name
, "boot shell")) return;
76 if ( ! stricmp(name
, "background cli")) return;
79 if (setup
.match
&& ! MatchPatternNoCase(setup
.parsedpattern
, name
))
81 // pattern doesn't fit
85 // FIXME: Can Forbid/Permit cause locks?
88 RawPutChars("SNOOP ", 7);
90 prettyprint(name
, setup
.nameLen
);
95 if (thistask
->tc_Node
.ln_Type
== NT_PROCESS
&& ((struct Process
*)thistask
)->pr_CLI
)
97 clinum
= ((struct Process
*)thistask
)->pr_TaskNum
;
100 kprintf(" [%d]", clinum
);
103 prettyprint(action
, setup
.actionLen
);
104 prettyprint(target
, setup
.targetLen
);
105 prettyprint(option
, setup
.optionLen
);
106 prettyprint(result
? MSG(MSG_OK
) : MSG(MSG_FAIL
), 0);
110 // We're calling the breakpoint function from the output function
111 // so that we don't have to check the setup parameters again.
112 // canInterrupt is for cases where a patch prints multiple lines.
113 if (canInterrupt
&& setup
.breakPoint
) SNOOPY_breakpoint();
117 void main_parsepattern(void)
121 if (!setup
.pattern
) return;
122 if (setup
.pattern
[0] == '\0') return;
124 Forbid(); // avoid that parsed pattern is used while we change it
125 setup
.parsedpattern
[0] = '\0';
126 if (ParsePatternNoCase(setup
.pattern
, setup
.parsedpattern
, PARSEDPATTERNLEN
) != -1)
134 void clean_exit(char *s
)