/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright (c) 2013, Joyent, Inc. All rights reserved.
*/
#include <stdio.h>
#include <stdio_ext.h>
#include <stdlib.h>
#include <unistd.h>
#include <ctype.h>
#include <fcntl.h>
#include <strings.h>
#include <dirent.h>
#include <errno.h>
#include <sys/int_fmtio.h>
#include <libproc.h>
typedef struct look_arg {
int pflags;
const char *lwps;
int count;
} look_arg_t;
static int look(char *);
static char *prflags(int);
static char *prwhy(int);
static char *prwhat(int, int);
static void dumpregs(const prgregset_t, int);
#endif
static char *command;
#define LWPFLAGS \
#define PROCFLAGS \
int
{
int rc = 0;
int errflg = 0;
int opt;
command++;
else
/* options */
switch (opt) {
case 'r': /* show registers */
rflag = 1;
break;
default:
errflg = 1;
break;
}
}
"usage:\t%s [-r] { pid | core }[/lwps] ...\n", command);
return (2);
}
/*
* Make sure we'll have enough file descriptors to handle a target
* that has many many mappings.
*/
}
while (argc-- > 0)
return (rc);
}
static int
{
int gcode;
int gcode2;
int flags;
return (0);
}
return (1);
}
return (0);
}
(void) printf("core '%s' of %d:\t%.70s\n",
} else {
(void) printf("%d:\t%.70s\n",
}
(void) printf("\n");
if (fltbits)
#else
#error "fix me: MAXSIG out of bounds"
#endif
(void) printf("\tsigtrace = 0x%.8x 0x%.8x 0x%.8x\n\t %s\n",
(void) printf(
"\tentryset = "
"0x%.8x 0x%.8x 0x%.8x 0x%.8x\n"
"\t "
"0x%.8x 0x%.8x 0x%.8x 0x%.8x\n",
(void) printf(
"\texitset = "
"0x%.8x 0x%.8x 0x%.8x 0x%.8x\n"
"\t "
"0x%.8x 0x%.8x 0x%.8x 0x%.8x\n",
#else
#error "fix me: MAXSIG out of bounds"
#endif
(void) printf("\tsigpend = 0x%.8x,0x%.8x,0x%.8x\n",
(void) printf("No matching lwps found");
(void) printf("\n");
return (0);
}
static int
{
return (0);
}
static int
{
int flags;
int cursig;
return (0);
return (lwplook_zombie(pip));
/*
* PR_PCINVAL is just noise if the lwp is not stopped.
* Don't bother reporting it unless the lwp is stopped.
*/
if (!(flags & PR_STOPPED))
flags &= ~PR_PCINVAL;
(void) printf("|");
(void) printf("ASLEEP");
}
uint_t i;
(void) printf(" %s(",
for (i = 0; i < psp->pr_nsysarg; i++) {
if (i != 0)
(void) printf(",");
}
(void) printf(")");
}
}
(void) printf("\n");
if (flags & PR_STOPPED) {
(void) printf(" what = %s",
(void) printf("\n");
}
#else
#error "fix me: MAXSIG out of bounds"
#endif
(void) printf("\tsigmask = 0x%.8x,0x%.8x,0x%.8x\n",
(void) printf("\tlwppend = 0x%.8x,0x%.8x,0x%.8x\n",
if (cursig)
(void) printf("\tcursig = %s\n",
char t[64];
(void) printf("\tspymaster = pid %d, \"%s\" at %s\n",
}
if (rflag) {
/*
* If we're SPARC/32-bit, see if we can get extra
* register state for this lwp. If it's a v8plus
* program, print the 64-bit register values.
*/
else
#endif /* __sparc && _ILP32 */
} else
(void) printf("\tNot stopped, can't show registers\n");
}
return (0);
}
static char *
{
if (arg == 0)
return ("0");
else
*str = '\0';
/*
* Display the semi-permanent lwp flags first.
*/
if (arg & PR_STOPPED)
#if 0 /* displayed elsewhere */
#endif
if (arg & PR_PCINVAL)
if (arg & PR_NOSIGCHLD)
if (arg & PR_WAITPID)
if (*str == '|')
str++;
return (str);
}
static char *
{
char *str;
switch (why) {
case PR_REQUESTED:
str = "PR_REQUESTED";
break;
case PR_SIGNALLED:
str = "PR_SIGNALLED";
break;
case PR_SYSENTRY:
str = "PR_SYSENTRY";
break;
case PR_SYSEXIT:
str = "PR_SYSEXIT";
break;
case PR_JOBCONTROL:
str = "PR_JOBCONTROL";
break;
case PR_FAULTED:
str = "PR_FAULTED";
break;
case PR_SUSPENDED:
str = "PR_SUSPENDED";
break;
default:
break;
}
return (str);
}
static char *
{
char *str;
switch (why) {
case PR_SIGNALLED:
case PR_JOBCONTROL:
break;
case PR_SYSENTRY:
case PR_SYSEXIT:
break;
case PR_FAULTED:
break;
default:
break;
}
return (str);
}
#if defined(__sparc)
" %g0", " %g1", " %g2", " %g3", " %g4", " %g5", " %g6", " %g7",
" %o0", " %o1", " %o2", " %o3", " %o4", " %o5", " %sp", " %o7",
" %l0", " %l1", " %l2", " %l3", " %l4", " %l5", " %l6", " %l7",
" %i0", " %i1", " %i2", " %i3", " %i4", " %i5", " %fp", " %i7",
#ifdef __sparcv9
"%ccr", " %pc", "%npc", " %y", "%asi", "%fprs"
#else
"%psr", " %pc", "%npc", " %y", "%wim", "%tbr"
#endif
};
#endif /* __sparc */
#if defined(__amd64)
"%r15", "%r14", "%r13", "%r12", "%r11", "%r10", " %r9", " %r8",
"%rdi", "%rsi", "%rbp", "%rbx", "%rdx", "%rcx", "%rax", "%trapno",
"%err", "%rip", " %cs", "%rfl", "%rsp", " %ss", " %fs", " %gs",
" %es", " %ds", "%fsbase", "%gsbase"
};
" %gs", " %fs", " %es", " %ds", "%edi", "%esi", "%ebp", "%esp",
"%ebx", "%edx", "%ecx", "%eax", "%trapno", "%err", "%eip", " %cs",
"%efl", "%uesp", " %ss"
};
/* XX64 Do we want to expose this through libproc */
void
{
}
" %gs", " %fs", " %es", " %ds", "%edi", "%esi", "%ebp", "%esp",
"%ebx", "%edx", "%ecx", "%eax", "%trapno", "%err", "%eip", " %cs",
"%efl", "%uesp", " %ss"
};
#endif /* __i386 */
static void
{
int i;
for (i = 0; i < NPRGREG32; i++) {
(void) printf(" %s = 0x%.8X",
if ((i+1) % 4 == 0)
(void) putchar('\n');
}
if (i % 4 != 0)
(void) putchar('\n');
}
#endif
static void
{
int i;
if (!is64) {
return;
}
#endif
for (i = 0; i < NPRGREG; i++) {
(void) printf(" %s = 0x%.*lX",
if ((i+1) % cols == 0)
(void) putchar('\n');
}
if (i % cols != 0)
(void) putchar('\n');
}
static void
{
return;
}
(void) putchar('\n');
}
(void) putchar('\n');
}
(void) printf(" %s = 0x%.8lX",
(void) putchar('\n');
}
(void) putchar('\n');
}
#endif /* __sparc && _ILP32 */