Skip to content

Commit

Permalink
Implemented a new "search -T" option, which is identical to the
Browse files Browse the repository at this point in the history
"search -t" option, except that the search is restricted to the
kernel stacks of active tasks.
(atomlin@redhat.com)
  • Loading branch information
Dave Anderson committed Oct 17, 2017
1 parent 2b93c03 commit 30950ba
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
3 changes: 2 additions & 1 deletion help.c
Expand Up @@ -2862,7 +2862,7 @@ NULL
char *help_search[] = {
"search",
"search memory",
"[-s start] [ -[kKV] | -u | -p | -t ] [-e end | -l length] [-m mask]\n"
"[-s start] [ -[kKV] | -u | -p | -t | -T ] [-e end | -l length] [-m mask]\n"
" [-x count] -[cwh] [value | (expression) | symbol | string] ...",
" This command searches for a given value within a range of user virtual, kernel",
" virtual, or physical memory space. If no end nor length value is entered, ",
Expand Down Expand Up @@ -2893,6 +2893,7 @@ char *help_search[] = {
" -t Search only the kernel stack pages of every task. If one or more",
" matches are found in a task's kernel stack, precede the output",
" with a task-identifying header.",
" -T Same as -t, except only the active task(s) are considered.",
" -e end Stop the search at this hexadecimal user or kernel virtual",
" address, kernel symbol, or physical address. The end address",
" must be appropriate for the memory type specified.",
Expand Down
30 changes: 20 additions & 10 deletions memory.c
Expand Up @@ -13882,7 +13882,7 @@ cmd_search(void)
ulong value, mask, len;
ulong uvaddr_start, uvaddr_end;
ulong kvaddr_start, kvaddr_end, range_end;
int sflag, Kflag, Vflag, pflag, tflag;
int sflag, Kflag, Vflag, pflag, Tflag, tflag;
struct searchinfo searchinfo;
struct syment *sp;
struct node_table *nt;
Expand All @@ -13896,7 +13896,7 @@ cmd_search(void)

context = max = 0;
start = end = 0;
value = mask = sflag = pflag = Kflag = Vflag = memtype = len = tflag = 0;
value = mask = sflag = pflag = Kflag = Vflag = memtype = len = Tflag = tflag = 0;
kvaddr_start = kvaddr_end = 0;
uvaddr_start = UNINITIALIZED;
uvaddr_end = COMMON_VADDR_SPACE() ? (ulong)(-1) : machdep->kvbase;
Expand Down Expand Up @@ -13933,7 +13933,7 @@ cmd_search(void)

searchinfo.mode = SEARCH_ULONG; /* default search */

while ((c = getopt(argcnt, args, "tl:ukKVps:e:v:m:hwcx:")) != EOF) {
while ((c = getopt(argcnt, args, "Ttl:ukKVps:e:v:m:hwcx:")) != EOF) {
switch(c)
{
case 'u':
Expand Down Expand Up @@ -14038,12 +14038,19 @@ cmd_search(void)
context = dtoi(optarg, FAULT_ON_ERROR, NULL);
break;

case 'T':
case 't':
if (XEN_HYPER_MODE())
error(FATAL,
"-t option is not applicable to the "
"Xen hypervisor\n");
tflag++;
"-%c option is not applicable to the "
"Xen hypervisor\n", c);
if (c == 'T')
Tflag++;
else if (c == 't')
tflag++;
if (tflag && Tflag)
error(FATAL,
"-t and -T options are mutually exclusive\n");
break;

default:
Expand All @@ -14052,10 +14059,11 @@ cmd_search(void)
}
}

if (tflag && (memtype || start || end || len))
if ((tflag || Tflag) && (memtype || start || end || len))
error(FATAL,
"-t option cannot be used with other "
"memory-selection options\n");
"-%c option cannot be used with other "
"memory-selection options\n",
tflag ? 't' : 'T');

if (XEN_HYPER_MODE()) {
memtype = KVADDR;
Expand Down Expand Up @@ -14328,10 +14336,12 @@ cmd_search(void)
break;
}

if (tflag) {
if (tflag || Tflag) {
searchinfo.tasks_found = 0;
tc = FIRST_CONTEXT();
for (i = 0; i < RUNNING_TASKS(); i++, tc++) {
if (Tflag && !is_task_active(tc->task))
continue;
searchinfo.vaddr_start = GET_STACKBASE(tc->task);
searchinfo.vaddr_end = GET_STACKTOP(tc->task);
searchinfo.task_context = tc;
Expand Down

0 comments on commit 30950ba

Please sign in to comment.