Add 'findstack' ddb command to search either the thread kernel stack
or cached stack containing the specified kernel virtual address. Discussed with: pho MFC after: 1 week
This commit is contained in:
parent
38474ef299
commit
9ab83ecbcb
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=228569
@ -140,6 +140,7 @@ static struct command db_cmds[] = {
|
||||
{ "unscript", db_unscript_cmd, CS_OWN, 0 },
|
||||
{ "capture", db_capture_cmd, CS_OWN, 0 },
|
||||
{ "textdump", db_textdump_cmd, CS_OWN, 0 },
|
||||
{ "findstack", db_findstack_cmd, 0, 0 },
|
||||
};
|
||||
struct command_table db_cmd_table = LIST_HEAD_INITIALIZER(db_cmd_table);
|
||||
|
||||
|
@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/proc.h>
|
||||
#include <sys/sysent.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/_kstack_cache.h>
|
||||
#include <vm/vm.h>
|
||||
#include <vm/vm_param.h>
|
||||
#include <vm/pmap.h>
|
||||
@ -429,3 +430,39 @@ DB_SHOW_COMMAND(proc, db_show_proc)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
db_findstack_cmd(db_expr_t addr, boolean_t have_addr,
|
||||
db_expr_t dummy3 __unused, char *dummy4 __unused)
|
||||
{
|
||||
struct proc *p;
|
||||
struct thread *td;
|
||||
struct kstack_cache_entry *ks_ce;
|
||||
vm_offset_t saddr;
|
||||
|
||||
if (have_addr)
|
||||
saddr = addr;
|
||||
else {
|
||||
db_printf("Usage: findstack <address>\n");
|
||||
return;
|
||||
}
|
||||
|
||||
for (p = LIST_FIRST(&allproc); p != NULL; p = LIST_NEXT(p, p_list)) {
|
||||
FOREACH_THREAD_IN_PROC(p, td) {
|
||||
if (td->td_kstack <= saddr && saddr < td->td_kstack +
|
||||
PAGE_SIZE * td->td_kstack_pages) {
|
||||
db_printf("Thread %p\n", td);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (ks_ce = kstack_cache; ks_ce != NULL;
|
||||
ks_ce = ks_ce->next_ks_entry) {
|
||||
if ((vm_offset_t)ks_ce <= saddr && saddr < (vm_offset_t)ks_ce +
|
||||
PAGE_SIZE * KSTACK_PAGES) {
|
||||
db_printf("Cached stack %p\n", ks_ce);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -226,6 +226,7 @@ db_cmdfcn_t db_delete_cmd;
|
||||
db_cmdfcn_t db_deletehwatch_cmd;
|
||||
db_cmdfcn_t db_deletewatch_cmd;
|
||||
db_cmdfcn_t db_examine_cmd;
|
||||
db_cmdfcn_t db_findstack_cmd;
|
||||
db_cmdfcn_t db_hwatchpoint_cmd;
|
||||
db_cmdfcn_t db_listbreak_cmd;
|
||||
db_cmdfcn_t db_scripts_cmd;
|
||||
|
Loading…
Reference in New Issue
Block a user