Print this page
8158 Want named threads API
9857 proc manpages should have LIBRARY section
@@ -20,10 +20,11 @@
*/
/*
* 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,10 +37,16 @@
#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,21 +53,24 @@
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);
- mdb_printf("stack pointer for thread %p%s: %p\n",
- addr, (free_state ? " (TS_FREE)" : ""), sp);
+ (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,10 +116,12 @@
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,11 +207,11 @@
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
+static size_t
stacks_hash_entry(stacks_entry_t *sep)
{
size_t depth = sep->se_depth;
uintptr_t *stack = sep->se_stack;
@@ -222,11 +234,11 @@
*
* 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
+static int
stacks_entry_comp_impl(stacks_entry_t *l, stacks_entry_t *r,
uint_t forsort)
{
int idx;
@@ -296,11 +308,11 @@
return (-1);
return (0);
}
-int
+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,11 +378,11 @@
stacks_hash = NULL;
stacks_array = NULL;
}
/*ARGSUSED*/
-int
+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,11 +431,11 @@
sip->si_entries++;
return (WALK_NEXT);
}
-int
+static int
stacks_run_tlist(mdb_pipe_t *tlist, stacks_info_t *si)
{
size_t idx;
size_t found = 0;
int ret;
@@ -443,11 +455,11 @@
if (found)
return (0);
return (-1);
}
-int
+static int
stacks_run(int verbose, mdb_pipe_t *tlist)
{
stacks_info_t si;
findstack_info_t *fsip = &si.si_fsi;
size_t idx;