Add missing headers/os/drivers/KernelExport.h functions here and there.
Some int -> cpu_state cleanup on the way, and implement the B_KDEBUG_CONT and B_KDEBUG_QUIT features in our kernel debugger. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2173 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
c4df8d57df
commit
a4d52d3edf
@ -203,36 +203,57 @@ kernel_debugger_loop()
|
|||||||
{
|
{
|
||||||
int argc;
|
int argc;
|
||||||
struct debugger_command *cmd;
|
struct debugger_command *cmd;
|
||||||
|
cpu_status state;
|
||||||
|
|
||||||
disable_interrupts();
|
state = disable_interrupts();
|
||||||
|
|
||||||
dprintf("kernel debugger on cpu %d\n", smp_get_current_cpu());
|
dprintf("kernel debugger on cpu %d\n", smp_get_current_cpu());
|
||||||
debugger_on_cpu = smp_get_current_cpu();
|
debugger_on_cpu = smp_get_current_cpu();
|
||||||
|
|
||||||
|
cmd = NULL;
|
||||||
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
dprintf("kdebug> ");
|
dprintf("kdebug> ");
|
||||||
debug_read_line(line_buf[cur_line], LINE_BUF_SIZE);
|
debug_read_line(line_buf[cur_line], LINE_BUF_SIZE);
|
||||||
debug_parse_line(line_buf[cur_line], args, &argc, MAX_ARGS);
|
debug_parse_line(line_buf[cur_line], args, &argc, MAX_ARGS);
|
||||||
if (argc <= 0)
|
|
||||||
|
// We support calling last executed command again if
|
||||||
|
// B_KDEDUG_CONT was returned last time, so cmd != NULL
|
||||||
|
if (argc <= 0 && cmd == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
debugger_on_cpu = smp_get_current_cpu();
|
debugger_on_cpu = smp_get_current_cpu();
|
||||||
|
|
||||||
cmd = commands;
|
if (argc > 0) {
|
||||||
while (cmd != NULL) {
|
// search command by name
|
||||||
if (strcmp(args[0], cmd->name) == 0) {
|
cmd = commands;
|
||||||
cmd->func(argc, args);
|
while (cmd != NULL) {
|
||||||
break;
|
if (strcmp(args[0], cmd->name) == 0)
|
||||||
}
|
break;
|
||||||
cmd = cmd->next;
|
cmd = cmd->next;
|
||||||
}
|
};
|
||||||
|
};
|
||||||
|
|
||||||
if (cmd == NULL)
|
if (cmd == NULL)
|
||||||
dprintf("unknown command, enter \"help\" to get a list of all supported commands\n");
|
dprintf("unknown command, enter \"help\" to get a list of all supported commands\n");
|
||||||
|
else {
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
rc = cmd->func(argc, args);
|
||||||
|
|
||||||
|
if (rc == B_KDEBUG_QUIT)
|
||||||
|
break; // okay, exit now.
|
||||||
|
|
||||||
|
if (rc != B_KDEBUG_CONT)
|
||||||
|
cmd = NULL; // forget last command executed...
|
||||||
|
};
|
||||||
|
|
||||||
cur_line++;
|
cur_line++;
|
||||||
if (cur_line >= HISTORY_SIZE)
|
if (cur_line >= HISTORY_SIZE)
|
||||||
cur_line = 0;
|
cur_line = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
restore_interrupts(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -257,7 +278,7 @@ panic(const char *fmt, ...)
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
va_list args;
|
va_list args;
|
||||||
char temp[128];
|
char temp[128];
|
||||||
int state;
|
cpu_status state;
|
||||||
|
|
||||||
// XXX by setting kernel_startup = true, we disable
|
// XXX by setting kernel_startup = true, we disable
|
||||||
// XXX the interrupt check in semaphore code etc.
|
// XXX the interrupt check in semaphore code etc.
|
||||||
@ -304,11 +325,12 @@ dprintf(const char *fmt, ...)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char
|
char
|
||||||
dbg_putch(char c)
|
dbg_putch(char c)
|
||||||
{
|
{
|
||||||
char ret;
|
char ret;
|
||||||
int flags = disable_interrupts();
|
cpu_status state = disable_interrupts();
|
||||||
acquire_spinlock(&dbg_spinlock);
|
acquire_spinlock(&dbg_spinlock);
|
||||||
|
|
||||||
if (serial_debug_on)
|
if (serial_debug_on)
|
||||||
@ -317,7 +339,7 @@ dbg_putch(char c)
|
|||||||
ret = c;
|
ret = c;
|
||||||
|
|
||||||
release_spinlock(&dbg_spinlock);
|
release_spinlock(&dbg_spinlock);
|
||||||
restore_interrupts(flags);
|
restore_interrupts(state);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -326,21 +348,21 @@ dbg_putch(char c)
|
|||||||
void
|
void
|
||||||
dbg_puts(const char *s)
|
dbg_puts(const char *s)
|
||||||
{
|
{
|
||||||
int flags = disable_interrupts();
|
cpu_status state = disable_interrupts();
|
||||||
acquire_spinlock(&dbg_spinlock);
|
acquire_spinlock(&dbg_spinlock);
|
||||||
|
|
||||||
if (serial_debug_on)
|
if (serial_debug_on)
|
||||||
arch_dbg_con_puts(s);
|
arch_dbg_con_puts(s);
|
||||||
|
|
||||||
release_spinlock(&dbg_spinlock);
|
release_spinlock(&dbg_spinlock);
|
||||||
restore_interrupts(flags);
|
restore_interrupts(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
add_debugger_command(char *name, int (*func)(int, char **), char *desc)
|
add_debugger_command(char *name, int (*func)(int, char **), char *desc)
|
||||||
{
|
{
|
||||||
int flags;
|
cpu_status state;
|
||||||
struct debugger_command *cmd;
|
struct debugger_command *cmd;
|
||||||
|
|
||||||
cmd = (struct debugger_command *)malloc(sizeof(struct debugger_command));
|
cmd = (struct debugger_command *)malloc(sizeof(struct debugger_command));
|
||||||
@ -351,14 +373,14 @@ add_debugger_command(char *name, int (*func)(int, char **), char *desc)
|
|||||||
cmd->name = name;
|
cmd->name = name;
|
||||||
cmd->description = desc;
|
cmd->description = desc;
|
||||||
|
|
||||||
flags = disable_interrupts();
|
state = disable_interrupts();
|
||||||
acquire_spinlock(&dbg_spinlock);
|
acquire_spinlock(&dbg_spinlock);
|
||||||
|
|
||||||
cmd->next = commands;
|
cmd->next = commands;
|
||||||
commands = cmd;
|
commands = cmd;
|
||||||
|
|
||||||
release_spinlock(&dbg_spinlock);
|
release_spinlock(&dbg_spinlock);
|
||||||
restore_interrupts(flags);
|
restore_interrupts(state);
|
||||||
|
|
||||||
return B_NO_ERROR;
|
return B_NO_ERROR;
|
||||||
}
|
}
|
||||||
@ -369,9 +391,9 @@ remove_debugger_command(char * name, int (*func)(int, char **))
|
|||||||
{
|
{
|
||||||
struct debugger_command *cmd = commands;
|
struct debugger_command *cmd = commands;
|
||||||
struct debugger_command *prev = NULL;
|
struct debugger_command *prev = NULL;
|
||||||
int flags;
|
cpu_status state;
|
||||||
|
|
||||||
flags = disable_interrupts();
|
state = disable_interrupts();
|
||||||
acquire_spinlock(&dbg_spinlock);
|
acquire_spinlock(&dbg_spinlock);
|
||||||
|
|
||||||
while (cmd) {
|
while (cmd) {
|
||||||
@ -390,7 +412,7 @@ remove_debugger_command(char * name, int (*func)(int, char **))
|
|||||||
}
|
}
|
||||||
|
|
||||||
release_spinlock(&dbg_spinlock);
|
release_spinlock(&dbg_spinlock);
|
||||||
restore_interrupts(flags);
|
restore_interrupts(state);
|
||||||
|
|
||||||
if (cmd) {
|
if (cmd) {
|
||||||
free(cmd);
|
free(cmd);
|
||||||
@ -460,3 +482,12 @@ dbg_get_serial_debug()
|
|||||||
return serial_debug_on;
|
return serial_debug_on;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Wrapper(s) for BeOS R5 compatibility:
|
||||||
|
|
||||||
|
bool
|
||||||
|
set_dprintf_enabled(bool new_state)
|
||||||
|
{
|
||||||
|
return dbg_set_serial_debug(new_state);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1427,6 +1427,16 @@ setrlimit(int resource, const struct rlimit * rlp)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
thread_id
|
||||||
|
spawn_kernel_thread (thread_func function, const char *thread_name, long priority, void *arg)
|
||||||
|
{
|
||||||
|
return _create_thread(thread_name, team_get_kernel_team()->id, (addr) function, arg, (int) priority, true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
// Calls from within the kernel
|
// Calls from within the kernel
|
||||||
|
|
||||||
|
@ -193,3 +193,17 @@ error:
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
load_driver_symbols(const char * driver_name)
|
||||||
|
{
|
||||||
|
// phoudoin: currently, elf_load_kspace() keep in memory symbols list with
|
||||||
|
// the image info, and the KDL back trace utility use it.
|
||||||
|
// So we don't have anything more to do here.
|
||||||
|
// TODO: However, in the future, as we may have image symbols list
|
||||||
|
// not loaded anymore in memory, we should do something here then!!!
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user