* Removed the DEBUG_DEBUGGER_COMMANDS define again, and followed Ingo's

suggestion by adding a "faults" command that now sets the
  gInvokeCommandDirectly variable as wished.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28382 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2008-10-30 16:29:37 +00:00
parent 082466120e
commit 6179ce7957
3 changed files with 29 additions and 11 deletions

View File

@ -313,6 +313,23 @@ cmd_wc(int argc, char** argv)
}
static int
cmd_faults(int argc, char** argv)
{
if (argc > 2) {
print_debugger_command_usage(argv[0]);
return B_KDEBUG_ERROR;
}
if (argc == 2)
gInvokeCommandDirectly = parse_expression(argv[1]) == 0;
kprintf("Fault handling is %s%s.\n", argc == 2 ? "now " : "",
gInvokeCommandDirectly ? "off" : "on");
return 0;
}
// #pragma mark -
@ -347,6 +364,10 @@ debug_builtin_commands_init()
"Prints a human-readable description for the given numeric error\n"
"code.\n"
" <error> - The numeric error code.\n", 0);
add_debugger_command_etc("faults", &cmd_faults, "Toggles fault handling "
"for debugger commands",
"[0|1]\n"
"Toggles fault handling on (1) or off (0).\n", 0);
add_debugger_command_etc("head", &cmd_head,
"Prints only the first lines of output from another command",
"<maxLines>\n"

View File

@ -24,23 +24,22 @@
#include "debug_variables.h"
#define DEBUG_DEBUGGER_COMMANDS 0
// Turns off the "FAULT" message to get a stack crawl
// of the failing debugger command.
#define INVOKE_COMMAND_FAULT 1
#define INVOKE_COMMAND_ERROR 2
static const int32 kMaxInvokeCommandDepth = 5;
static const int32 kOutputBufferSize = 1024;
bool gInvokeCommandDirectly = false;
static spinlock sSpinlock = B_SPINLOCK_INITIALIZER;
static struct debugger_command *sCommands;
static jmp_buf sInvokeCommandEnv[kMaxInvokeCommandDepth];
static int32 sInvokeCommandLevel = 0;
static bool sInvokeCommandDirectly = false;
static bool sInCommand = false;
static char sOutputBuffers[MAX_DEBUGGER_COMMAND_PIPE_LENGTH][kOutputBufferSize];
static debugger_command_pipe* sCurrentPipe;
@ -276,7 +275,7 @@ invoke_debugger_command(struct debugger_command *command, int argc, char** argv)
// Invoking the command directly might be useful when debugging debugger
// commands.
if (sInvokeCommandDirectly)
if (gInvokeCommandDirectly)
return command->func(argc, argv);
sInCommand = true;
@ -284,13 +283,11 @@ invoke_debugger_command(struct debugger_command *command, int argc, char** argv)
switch (setjmp(sInvokeCommandEnv[sInvokeCommandLevel++])) {
case 0:
int result;
#if DEBUG_DEBUGGER_COMMANDS
thread->fault_handler = (addr_t)&&error;
// Fake goto to trick the compiler not to optimize the code at the
// label away.
if (!thread)
goto error;
#endif
result = command->func(argc, argv);
@ -299,12 +296,11 @@ invoke_debugger_command(struct debugger_command *command, int argc, char** argv)
sInCommand = false;
return result;
#if DEBUG_DEBUGGER_COMMANDS
error:
// jump to INVOKE_COMMAND_FAULT case, cleaning up the stack
longjmp(sInvokeCommandEnv[--sInvokeCommandLevel],
INVOKE_COMMAND_FAULT);
#endif
case INVOKE_COMMAND_FAULT:
{
debug_page_fault_info* info = debug_get_page_fault_info();
@ -337,7 +333,7 @@ invoke_debugger_command(struct debugger_command *command, int argc, char** argv)
void
abort_debugger_command()
{
if (!sInvokeCommandDirectly && sInvokeCommandLevel > 0) {
if (!gInvokeCommandDirectly && sInvokeCommandLevel > 0) {
longjmp(sInvokeCommandEnv[--sInvokeCommandLevel],
INVOKE_COMMAND_ERROR);
}

View File

@ -36,6 +36,7 @@ typedef struct debugger_command_pipe {
bool broken;
} debugger_command_pipe;
extern bool gInvokeCommandDirectly;
#ifdef __cplusplus
extern "C" {