/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 (c) 1996-1998 by Sun Microsystems, Inc.
* All rights reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include "kvm.h"
#include <nlist.h>
#ifdef __sparc
#else
#define STACK_BIAS 0
#endif
struct proc *tst_nextproc(void);
int tst_setproc(void);
void tst_segkp(void);
void tst_open(char *, char *, char *, int);
void tst_close(void);
void tst_segkvp(void);
char *name;
char *core;
char *swap;
int wflag;
{"free"},
{"fragtbl"},
{"freemem"},
{"allthreads"},
{"nbuckets"},
{"cputype"},
{0}
};
int
{
int c, errflg = 0;
long xx;
struct user *u;
continue;
envp -= 2;
printf("pid %d:: %d args; %d envs; %d chars (%p - %p)\n",
switch (c) {
case 'w':
wflag++;
break;
case '?':
errflg++;
}
if (errflg) {
argv[0]);
return (2);
}
if (*name == '\0')
} else
if (*core == '\0')
} else
if (*swap == '\0')
} else
return (1);
printf("ERROR: couldn't get pid\n");
break;
}
}
tst_setproc();
(void) tst_getcmd(proc, u);
}
tst_segkp();
tst_close();
return (0);
}
void
{
printf("kvm_open(%s, %s, %s, %s)\n",
"O_RDWR" : "???"));
}
void
tst_close(void)
{
int i;
printf("kvm_close()\n");
printf("ERROR: kvm_close returned %d\n", i);
}
void
{
int i;
char *t, *s;
printf("kvm_nlist([nl])\n");
printf("ERROR: kvm_nlist returned %d\n", i);
/*
* Debug:
* n_value gets filled in with st_value,
* n_type gets filled in w/ELF32_ST_TYPE(sym->st_info)
*/
case STT_NOTYPE:
t = "NOTYPE";
break;
case STT_OBJECT:
t = "OBJECT";
break;
case STT_FUNC:
t = "FUNC";
break;
case STT_SECTION:
t = "SECTION";
break;
case STT_FILE:
t = "FILE";
break;
case STT_NUM:
t = "NUM";
break;
default:
t = "???";
}
case SHN_UNDEF:
s = "UNDEF";
break;
case SHN_LORESERVE:
s = "LORESERVE";
break;
case SHN_ABS:
s = "ABS";
break;
case SHN_COMMON:
s = "COMMON";
break;
case SHN_HIRESERVE:
s = "HIRESERVE";
break;
default:
s = strbuf;
break;
}
printf("%s: %lx (%s, %s)\n",
}
}
{
ssize_t e;
int i;
char *b;
printf("ERROR: kvm_read returned %ld instead of %lu\n",
e, nbytes);
*b & 0xff, *b & 0xff);
return (e);
}
{
ssize_t e;
ssize_t i;
void *b;
printf("ERROR: kvm_write returned %ld instead of %lu\n",
e, nbytes);
printf("ERROR: malloc for readback failed\n");
else {
printf("ERROR: readback returned %ld\n", i);
printf("ERROR: write check failed!\n");
(void) free(b);
}
return (e);
}
struct proc *
{
printf("ERROR: kvm_getproc returned NULL\n");
return (proc);
}
printf("ERROR: couldn't get pid\n");
return (proc);
}
return (proc);
}
struct proc *
tst_nextproc(void)
{
printf("kvm_nextproc()\n");
printf("kvm_nextproc returned NULL\n");
return (proc);
}
/*
* p_pid is now a macro which turns into a ptr dereference;
* must do a kvm_read to get contents.
*/
printf("ERROR: couldn't get pid\n");
}
return (proc);
}
int
tst_setproc(void)
{
int i;
printf("kvm_setproc()\n");
if ((i = kvm_setproc(cookie)) != 0)
printf("ERROR: kvm_setproc returned %d\n", i);
return (i);
}
struct user *
{
register int e;
struct user *u;
printf("ERROR: couldn't get pid\n");
printf("ERROR: kvm_getu returned NULL\n");
return (u);
}
static void
safe_printf(const char *s)
{
for (p = buf; *p != '\0'; p++) {
if (!isprint(*p))
*p = ' ';
}
}
int
{
char **arg;
char **env;
int i;
char **p;
printf("ERROR: couldn't get pid\n");
return (-1);
}
printf("kvm_getcmd returned %d\n", i);
return (i);
}
printf("Args: ");
safe_printf(*p);
printf("Env: ");
safe_printf(*p);
return (0);
}
void
tst_segkp(void)
{
kthread_t t;
int i;
!= sizeof (alltp)) {
printf("ERROR: couldn't read allthread, addr 0x%lx\n",
return;
}
printf("next offset 0x%lx\n",
return;
}
printf("\tstk 0x%p sp 0x%lx tid %d next 0x%p prev 0x%p\n",
continue;
}
for (i = 0; i < 16; i++) {
if (((i + 1) % 4) == 0)
printf("\n");
}
break;
}
}