* Added very basic possibility to set a filter for all KDL command
output using the new "filter" command. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24590 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
3bb1e6c264
commit
e77b684f9e
@ -83,6 +83,7 @@ static const uint32 kMaxDebuggerModules = sizeof(sDebuggerModules)
|
|||||||
|
|
||||||
static char sLineBuffer[HISTORY_SIZE][LINE_BUFFER_SIZE] = { "", };
|
static char sLineBuffer[HISTORY_SIZE][LINE_BUFFER_SIZE] = { "", };
|
||||||
static char sParseLine[LINE_BUFFER_SIZE];
|
static char sParseLine[LINE_BUFFER_SIZE];
|
||||||
|
static char sFilter[64];
|
||||||
static int32 sCurrentLine = 0;
|
static int32 sCurrentLine = 0;
|
||||||
|
|
||||||
#define distance(a, b) ((a) < (b) ? (b) - (a) : (a) - (b))
|
#define distance(a, b) ((a) < (b) ? (b) - (a) : (a) - (b))
|
||||||
@ -280,7 +281,7 @@ public:
|
|||||||
} else if (longestCommonPrefix > position) {
|
} else if (longestCommonPrefix > position) {
|
||||||
// multiple possible completions with longer common prefix
|
// multiple possible completions with longer common prefix
|
||||||
// -- insert the remainder of the common prefix
|
// -- insert the remainder of the common prefix
|
||||||
|
|
||||||
// check for sufficient space in the buffer
|
// check for sufficient space in the buffer
|
||||||
int32 neededSpace = longestCommonPrefix - position;
|
int32 neededSpace = longestCommonPrefix - position;
|
||||||
// also consider the terminating null char
|
// also consider the terminating null char
|
||||||
@ -516,7 +517,7 @@ read_line(char *buffer, int32 maxLength,
|
|||||||
position = 4;
|
position = 4;
|
||||||
done = true;
|
done = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* supposed to fall through */
|
/* supposed to fall through */
|
||||||
default:
|
default:
|
||||||
@ -697,6 +698,19 @@ cmd_expr(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
cmd_filter(int argc, char **argv)
|
||||||
|
{
|
||||||
|
if (argc != 2) {
|
||||||
|
sFilter[0] = '\0';
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
strlcpy(sFilter, argv[1], sizeof(sFilter));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
cmd_error(int argc, char **argv)
|
cmd_error(int argc, char **argv)
|
||||||
{
|
{
|
||||||
@ -996,6 +1010,11 @@ debug_init_post_vm(kernel_args *args)
|
|||||||
"<expression>\n"
|
"<expression>\n"
|
||||||
"Evaluates the given expression and prints the result.\n",
|
"Evaluates the given expression and prints the result.\n",
|
||||||
B_KDEBUG_DONT_PARSE_ARGUMENTS);
|
B_KDEBUG_DONT_PARSE_ARGUMENTS);
|
||||||
|
add_debugger_command_etc("filter", &cmd_filter,
|
||||||
|
"Filters output of all debugger commands",
|
||||||
|
"<pattern>\n"
|
||||||
|
"Filters out all debug output of commands that does not match the\n"
|
||||||
|
"specified pattern. If no pattern is given, it is removed\n", 0);
|
||||||
add_debugger_command_etc("error", &cmd_error,
|
add_debugger_command_etc("error", &cmd_error,
|
||||||
"Prints a human-readable description for an error code",
|
"Prints a human-readable description for an error code",
|
||||||
"<error>\n"
|
"<error>\n"
|
||||||
@ -1305,10 +1324,9 @@ dprintf_no_syslog(const char *format, ...)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Similar to dprintf() but thought to be used in the kernel
|
/*! Similar to dprintf() but thought to be used in the kernel
|
||||||
* debugger only (it doesn't lock).
|
debugger only (it doesn't lock).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
kprintf(const char *format, ...)
|
kprintf(const char *format, ...)
|
||||||
{
|
{
|
||||||
@ -1320,6 +1338,11 @@ kprintf(const char *format, ...)
|
|||||||
vsnprintf(sOutputBuffer, OUTPUT_BUFFER_SIZE, format, args);
|
vsnprintf(sOutputBuffer, OUTPUT_BUFFER_SIZE, format, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
|
if (in_command_invocation() && sFilter[0]) {
|
||||||
|
if (strstr(sOutputBuffer, sFilter) == NULL)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
flush_pending_repeats();
|
flush_pending_repeats();
|
||||||
kputs(sOutputBuffer);
|
kputs(sOutputBuffer);
|
||||||
}
|
}
|
||||||
@ -1354,7 +1377,7 @@ dump_block(const char *buffer, int size, const char *prefix)
|
|||||||
{
|
{
|
||||||
const int DUMPED_BLOCK_SIZE = 16;
|
const int DUMPED_BLOCK_SIZE = 16;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < size;) {
|
for (i = 0; i < size;) {
|
||||||
int start = i;
|
int start = i;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user