Print this page
8158 Want named threads API
9857 proc manpages should have LIBRARY section
*** 20,29 ****
--- 20,30 ----
*/
/*
* Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ * Copyright 2018 Joyent, Inc.
*/
#include <mdb/mdb_modapi.h>
#include <mdb/mdb_ctf.h>
*** 36,45 ****
--- 37,52 ----
#include "findstack.h"
#include "thread.h"
#include "sobj.h"
+ /*
+ * Parts of this file are shared between targets, but this section is only
+ * used for KVM and KMDB.
+ */
+ #ifdef _KERNEL
+
int findstack_debug_on = 0;
/*
* "sp" is a kernel VA.
*/
*** 46,66 ****
static int
print_stack(uintptr_t sp, uintptr_t pc, uintptr_t addr,
int argc, const mdb_arg_t *argv, int free_state)
{
int showargs = 0, count, err;
count = mdb_getopts(argc, argv,
'v', MDB_OPT_SETBITS, TRUE, &showargs, NULL);
argc -= count;
argv += count;
if (argc > 1 || (argc == 1 && argv->a_type != MDB_TYPE_STRING))
return (DCMD_USAGE);
! mdb_printf("stack pointer for thread %p%s: %p\n",
! addr, (free_state ? " (TS_FREE)" : ""), sp);
if (pc != 0)
mdb_printf("[ %0?lr %a() ]\n", sp, pc);
mdb_inc_indent(2);
mdb_set_dot(sp);
--- 53,76 ----
static int
print_stack(uintptr_t sp, uintptr_t pc, uintptr_t addr,
int argc, const mdb_arg_t *argv, int free_state)
{
int showargs = 0, count, err;
+ char tdesc[128] = "";
count = mdb_getopts(argc, argv,
'v', MDB_OPT_SETBITS, TRUE, &showargs, NULL);
argc -= count;
argv += count;
if (argc > 1 || (argc == 1 && argv->a_type != MDB_TYPE_STRING))
return (DCMD_USAGE);
! (void) thread_getdesc(addr, B_TRUE, tdesc, sizeof (tdesc));
!
! mdb_printf("stack pointer for thread %p%s (%s): %p\n",
! addr, (free_state ? " (TS_FREE)" : ""), tdesc, sp);
if (pc != 0)
mdb_printf("[ %0?lr %a() ]\n", sp, pc);
mdb_inc_indent(2);
mdb_set_dot(sp);
*** 106,115 ****
--- 116,127 ----
findstack_debug_on ? "on" : "off");
return (DCMD_OK);
}
+ #endif /* _KERNEL */
+
static void
uppercase(char *p)
{
for (; *p != '\0'; p++) {
if (*p >= 'a' && *p <= 'z')
*** 195,205 ****
static uint_t stacks_state = STACKS_STATE_CLEAN;
static stacks_entry_t **stacks_hash;
static stacks_entry_t **stacks_array;
static size_t stacks_array_size;
! size_t
stacks_hash_entry(stacks_entry_t *sep)
{
size_t depth = sep->se_depth;
uintptr_t *stack = sep->se_stack;
--- 207,217 ----
static uint_t stacks_state = STACKS_STATE_CLEAN;
static stacks_entry_t **stacks_hash;
static stacks_entry_t **stacks_array;
static size_t stacks_array_size;
! static size_t
stacks_hash_entry(stacks_entry_t *sep)
{
size_t depth = sep->se_depth;
uintptr_t *stack = sep->se_stack;
*** 222,232 ****
*
* The equality test is independent of se_count, and doesn't care about
* relative ordering, so we don't do the extra work of looking up symbols
* for the stack addresses.
*/
! int
stacks_entry_comp_impl(stacks_entry_t *l, stacks_entry_t *r,
uint_t forsort)
{
int idx;
--- 234,244 ----
*
* The equality test is independent of se_count, and doesn't care about
* relative ordering, so we don't do the extra work of looking up symbols
* for the stack addresses.
*/
! static int
stacks_entry_comp_impl(stacks_entry_t *l, stacks_entry_t *r,
uint_t forsort)
{
int idx;
*** 296,306 ****
return (-1);
return (0);
}
! int
stacks_entry_comp(const void *l_arg, const void *r_arg)
{
stacks_entry_t * const *lp = l_arg;
stacks_entry_t * const *rp = r_arg;
--- 308,318 ----
return (-1);
return (0);
}
! static int
stacks_entry_comp(const void *l_arg, const void *r_arg)
{
stacks_entry_t * const *lp = l_arg;
stacks_entry_t * const *rp = r_arg;
*** 366,376 ****
stacks_hash = NULL;
stacks_array = NULL;
}
/*ARGSUSED*/
! int
stacks_thread_cb(uintptr_t addr, const void *ignored, void *cbarg)
{
stacks_info_t *sip = cbarg;
findstack_info_t *fsip = &sip->si_fsi;
--- 378,388 ----
stacks_hash = NULL;
stacks_array = NULL;
}
/*ARGSUSED*/
! static int
stacks_thread_cb(uintptr_t addr, const void *ignored, void *cbarg)
{
stacks_info_t *sip = cbarg;
findstack_info_t *fsip = &sip->si_fsi;
*** 419,429 ****
sip->si_entries++;
return (WALK_NEXT);
}
! int
stacks_run_tlist(mdb_pipe_t *tlist, stacks_info_t *si)
{
size_t idx;
size_t found = 0;
int ret;
--- 431,441 ----
sip->si_entries++;
return (WALK_NEXT);
}
! static int
stacks_run_tlist(mdb_pipe_t *tlist, stacks_info_t *si)
{
size_t idx;
size_t found = 0;
int ret;
*** 443,453 ****
if (found)
return (0);
return (-1);
}
! int
stacks_run(int verbose, mdb_pipe_t *tlist)
{
stacks_info_t si;
findstack_info_t *fsip = &si.si_fsi;
size_t idx;
--- 455,465 ----
if (found)
return (0);
return (-1);
}
! static int
stacks_run(int verbose, mdb_pipe_t *tlist)
{
stacks_info_t si;
findstack_info_t *fsip = &si.si_fsi;
size_t idx;