/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1992-2012 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* David Korn <dgk@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
#define FORMAT "region=%(region)p method=%(method)s flags=%(flags)s size=%(size)d segments=%(segments)d busy=(%(busy_size)d,%(busy_blocks)d,%(busy_max)d) free=(%(free_size)d,%(free_blocks)d,%(free_max)d)"
static const char usage[] =
"[-?\n@(#)$Id: vmstate (AT&T Research) 2010-04-08 $\n]"
"[+NAME?vmstate - list the calling process vmalloc region state]"
"[+DESCRIPTION?When invoked as a shell builtin, \bvmstate\b lists the "
"calling process \bvmalloc\b(3) state for all regions.]"
"[f:format?List the ids specified by \aformat\a. \aformat\a follows "
"\bprintf\b(3) conventions, except that \bsfio\b(3) inline ids are used "
"instead of arguments: "
"%[-+]][\awidth\a[.\aprecis\a[.\abase\a]]]]]](\aid\a)\achar\a. The "
"{"
"[+method?The vmalloc method name.]"
"[+flags?The vmalloc method flags.]"
"[+size?The total region size.]"
"[+segments?The number of segments in the region.]"
"[+busy_size?The total busy block size.]"
"[+busy_blocks?The number of busy blocks.]"
"[+busy_max?The maximum busy block size.]"
"[+free_size?The total free block size.]"
"[+free_blocks?The number of free blocks.]"
"[+free_max?The maximum free block size.]"
"}"
"[+SEE ALSO?\bvmalloc\b(3)]"
;
#include <cmd.h>
#include <vmalloc.h>
#include <sfdisc.h>
typedef struct State_s
{
char* format;
unsigned int regions;
} State_t;
/*
* sfkeyprintf() lookup
* handle==0 for heading
*/
static int
{
register char* s;
else if (streq(s, "region"))
else if (streq(s, "segments"))
else if (streq(s, "busy_size"))
else if (streq(s, "busy_blocks"))
else if (streq(s, "busy_max"))
else if (streq(s, "flags"))
{
#ifdef VM_TRUST
s = strcopy(s, "TRUST|");
#endif
s = strcopy(s, "TRACE|");
s = strcopy(s, "DBCHECK|");
s = strcopy(s, "DBABORT|");
if (s > *ps)
*(s - 1) = 0;
else
strcpy(s, "0");
}
else if (streq(s, "free_size"))
else if (streq(s, "free_blocks"))
else if (streq(s, "free_max"))
else if (streq(s, "format"))
else if (streq(s, "method"))
{
*ps = "best";
*ps = "pool";
*ps = "last";
*ps = "debug";
*ps = "profile";
else
*ps = "UNKNOWN";
}
else
{
return 0;
}
return 1;
}
static int
{
{
}
return 0;
}
int
{
register int i;
for (;;)
{
{
case 'f':
continue;
case '?':
break;
case ':':
break;
}
break;
}
/*
* the walk must do no allocations because it locks the regions
*/
/*
* now we can compute and list the state of each region
*/
{
}
return 0;
}