17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5154eb83fSjwadams * Common Development and Distribution License (the "License"). 6154eb83fSjwadams * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22154eb83fSjwadams * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 26*9ea7ddd8SBryan Cantrill /* 27*9ea7ddd8SBryan Cantrill * Copyright 2011 Joyent, Inc. All rights reserved. 28*9ea7ddd8SBryan Cantrill */ 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate /* 317c478bd9Sstevel@tonic-gate * Generic memory walker, used by both the genunix and libumem dmods. 327c478bd9Sstevel@tonic-gate */ 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate #include <mdb/mdb_modapi.h> 357c478bd9Sstevel@tonic-gate #include <sys/sysmacros.h> 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate #include "kgrep.h" 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate #define KGREP_FULL_MASK (~(uintmax_t)0) 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate typedef struct kgrep_data { 427c478bd9Sstevel@tonic-gate uintmax_t kg_pattern; 437c478bd9Sstevel@tonic-gate uintmax_t kg_mask; /* fancy only */ 447c478bd9Sstevel@tonic-gate uintmax_t kg_dist; /* fancy only */ 457c478bd9Sstevel@tonic-gate uintptr_t kg_minaddr; /* fancy only */ 467c478bd9Sstevel@tonic-gate uintptr_t kg_maxaddr; /* fancy only */ 477c478bd9Sstevel@tonic-gate void *kg_page; 487c478bd9Sstevel@tonic-gate size_t kg_pagesize; 497c478bd9Sstevel@tonic-gate char kg_cbtype; 507c478bd9Sstevel@tonic-gate char kg_seen; 517c478bd9Sstevel@tonic-gate } kgrep_data_t; 527c478bd9Sstevel@tonic-gate 537c478bd9Sstevel@tonic-gate #define KG_BASE 0 547c478bd9Sstevel@tonic-gate #define KG_VERBOSE 1 557c478bd9Sstevel@tonic-gate #define KG_PIPE 2 567c478bd9Sstevel@tonic-gate 577c478bd9Sstevel@tonic-gate static void 587c478bd9Sstevel@tonic-gate kgrep_cb(uintptr_t addr, uintmax_t *val, int type) 597c478bd9Sstevel@tonic-gate { 607c478bd9Sstevel@tonic-gate switch (type) { 617c478bd9Sstevel@tonic-gate case KG_BASE: 627c478bd9Sstevel@tonic-gate default: 637c478bd9Sstevel@tonic-gate mdb_printf("%p\n", addr); 647c478bd9Sstevel@tonic-gate break; 657c478bd9Sstevel@tonic-gate case KG_VERBOSE: 667c478bd9Sstevel@tonic-gate mdb_printf("%p:\t%llx\n", addr, *val); 677c478bd9Sstevel@tonic-gate break; 687c478bd9Sstevel@tonic-gate case KG_PIPE: 697c478bd9Sstevel@tonic-gate mdb_printf("%#lr\n", addr); 707c478bd9Sstevel@tonic-gate break; 717c478bd9Sstevel@tonic-gate } 727c478bd9Sstevel@tonic-gate } 737c478bd9Sstevel@tonic-gate 747c478bd9Sstevel@tonic-gate static int 757c478bd9Sstevel@tonic-gate kgrep_range_basic(uintptr_t base, uintptr_t lim, void *kg_arg) 767c478bd9Sstevel@tonic-gate { 777c478bd9Sstevel@tonic-gate kgrep_data_t *kg = kg_arg; 787c478bd9Sstevel@tonic-gate size_t pagesize = kg->kg_pagesize; 797c478bd9Sstevel@tonic-gate uintptr_t pattern = kg->kg_pattern; 807c478bd9Sstevel@tonic-gate uintptr_t *page = kg->kg_page; 817c478bd9Sstevel@tonic-gate uintptr_t *page_end = &page[pagesize / sizeof (uintptr_t)]; 827c478bd9Sstevel@tonic-gate uintptr_t *pos; 837c478bd9Sstevel@tonic-gate 847c478bd9Sstevel@tonic-gate uintptr_t addr, offset; 857c478bd9Sstevel@tonic-gate int seen = 0; 867c478bd9Sstevel@tonic-gate 877c478bd9Sstevel@tonic-gate /* 887c478bd9Sstevel@tonic-gate * page-align everything, to simplify the loop 897c478bd9Sstevel@tonic-gate */ 907c478bd9Sstevel@tonic-gate base = P2ALIGN(base, pagesize); 917c478bd9Sstevel@tonic-gate lim = P2ROUNDUP(lim, pagesize); 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gate for (addr = base; addr < lim; addr += pagesize) { 947c478bd9Sstevel@tonic-gate if (mdb_vread(page, pagesize, addr) == -1) 957c478bd9Sstevel@tonic-gate continue; 967c478bd9Sstevel@tonic-gate seen = 1; 977c478bd9Sstevel@tonic-gate 987c478bd9Sstevel@tonic-gate for (pos = page; pos < page_end; pos++) { 997c478bd9Sstevel@tonic-gate if (*pos != pattern) 1007c478bd9Sstevel@tonic-gate continue; 1017c478bd9Sstevel@tonic-gate 1027c478bd9Sstevel@tonic-gate offset = (caddr_t)pos - (caddr_t)page; 1037c478bd9Sstevel@tonic-gate kgrep_cb(addr + offset, NULL, kg->kg_cbtype); 1047c478bd9Sstevel@tonic-gate } 1057c478bd9Sstevel@tonic-gate } 1067c478bd9Sstevel@tonic-gate if (seen) 1077c478bd9Sstevel@tonic-gate kg->kg_seen = 1; 1087c478bd9Sstevel@tonic-gate 1097c478bd9Sstevel@tonic-gate return (WALK_NEXT); 1107c478bd9Sstevel@tonic-gate } 1117c478bd9Sstevel@tonic-gate 1127c478bd9Sstevel@tonic-gate /* 1137c478bd9Sstevel@tonic-gate * Full-service template -- instantiated for each supported size. We support 1147c478bd9Sstevel@tonic-gate * the following options: 1157c478bd9Sstevel@tonic-gate * 1167c478bd9Sstevel@tonic-gate * addr in [minaddr, maxaddr), and 1177c478bd9Sstevel@tonic-gate * value in [pattern, pattern + dist) OR 1187c478bd9Sstevel@tonic-gate * mask matching: (value & mask) == (pattern & mask) 1197c478bd9Sstevel@tonic-gate */ 1207c478bd9Sstevel@tonic-gate #define KGREP_FANCY_TEMPLATE(kgrep_range_fancybits, uintbits_t) \ 1217c478bd9Sstevel@tonic-gate static int \ 1227c478bd9Sstevel@tonic-gate kgrep_range_fancybits(uintptr_t base, uintptr_t lim, void *kg_arg) \ 1237c478bd9Sstevel@tonic-gate { \ 1247c478bd9Sstevel@tonic-gate kgrep_data_t *kg = kg_arg; \ 1257c478bd9Sstevel@tonic-gate \ 1267c478bd9Sstevel@tonic-gate uintbits_t pattern = kg->kg_pattern; \ 1277c478bd9Sstevel@tonic-gate uintbits_t dist = kg->kg_dist; \ 1287c478bd9Sstevel@tonic-gate uintbits_t mask = kg->kg_mask; \ 1297c478bd9Sstevel@tonic-gate uintptr_t minaddr = kg->kg_minaddr; \ 1307c478bd9Sstevel@tonic-gate uintptr_t maxaddr = kg->kg_maxaddr; \ 1317c478bd9Sstevel@tonic-gate size_t pagesize = kg->kg_pagesize; \ 1327c478bd9Sstevel@tonic-gate uintbits_t *page = (uintbits_t *)kg->kg_page; \ 1337c478bd9Sstevel@tonic-gate uintbits_t *page_end; \ 1347c478bd9Sstevel@tonic-gate uintbits_t *pos; \ 1357c478bd9Sstevel@tonic-gate uintbits_t cur; \ 1367c478bd9Sstevel@tonic-gate uintmax_t out; \ 1377c478bd9Sstevel@tonic-gate \ 1387c478bd9Sstevel@tonic-gate uintptr_t addr, size, offset; \ 1397c478bd9Sstevel@tonic-gate int seen = 0; \ 1407c478bd9Sstevel@tonic-gate \ 1417c478bd9Sstevel@tonic-gate base = P2ROUNDUP(MAX(base, minaddr), sizeof (uintbits_t)); \ 1427c478bd9Sstevel@tonic-gate \ 1437c478bd9Sstevel@tonic-gate if (maxaddr != 0 && lim > maxaddr) \ 1447c478bd9Sstevel@tonic-gate lim = maxaddr; \ 1457c478bd9Sstevel@tonic-gate \ 1467c478bd9Sstevel@tonic-gate for (addr = base; addr < lim; addr += size) { \ 1477c478bd9Sstevel@tonic-gate /* P2END(...) computes the next page boundry */ \ 1487c478bd9Sstevel@tonic-gate size = MIN(lim, P2END(addr, pagesize)) - addr; \ 1497c478bd9Sstevel@tonic-gate \ 1507c478bd9Sstevel@tonic-gate if (mdb_vread(page, size, addr) == -1) \ 1517c478bd9Sstevel@tonic-gate continue; \ 1527c478bd9Sstevel@tonic-gate \ 1537c478bd9Sstevel@tonic-gate seen = 1; \ 1547c478bd9Sstevel@tonic-gate \ 1557c478bd9Sstevel@tonic-gate page_end = &page[size / sizeof (uintbits_t)]; \ 1567c478bd9Sstevel@tonic-gate for (pos = page; pos < page_end; pos++) { \ 1577c478bd9Sstevel@tonic-gate cur = *pos; \ 1587c478bd9Sstevel@tonic-gate \ 159*9ea7ddd8SBryan Cantrill /* \ 160*9ea7ddd8SBryan Cantrill * Due to C's (surprising) integral promotion \ 161*9ea7ddd8SBryan Cantrill * rules for unsigned types smaller than an \ 162*9ea7ddd8SBryan Cantrill * int, we need to explicitly cast the result \ 163*9ea7ddd8SBryan Cantrill * of cur minus pattern, below. \ 164*9ea7ddd8SBryan Cantrill */ \ 1657c478bd9Sstevel@tonic-gate if (((cur ^ pattern) & mask) != 0 && \ 166*9ea7ddd8SBryan Cantrill (uintbits_t)(cur - pattern) >= dist) \ 1677c478bd9Sstevel@tonic-gate continue; \ 1687c478bd9Sstevel@tonic-gate \ 1697c478bd9Sstevel@tonic-gate out = cur; \ 1707c478bd9Sstevel@tonic-gate offset = (caddr_t)pos - (caddr_t)page; \ 1717c478bd9Sstevel@tonic-gate kgrep_cb(addr + offset, &out, kg->kg_cbtype); \ 1727c478bd9Sstevel@tonic-gate } \ 1737c478bd9Sstevel@tonic-gate } \ 1747c478bd9Sstevel@tonic-gate if (seen) \ 1757c478bd9Sstevel@tonic-gate kg->kg_seen = 1; \ 1767c478bd9Sstevel@tonic-gate \ 1777c478bd9Sstevel@tonic-gate return (WALK_NEXT); \ 1787c478bd9Sstevel@tonic-gate } 1797c478bd9Sstevel@tonic-gate 1807c478bd9Sstevel@tonic-gate KGREP_FANCY_TEMPLATE(kgrep_range_fancy8, uint8_t) 1817c478bd9Sstevel@tonic-gate KGREP_FANCY_TEMPLATE(kgrep_range_fancy16, uint16_t) 1827c478bd9Sstevel@tonic-gate KGREP_FANCY_TEMPLATE(kgrep_range_fancy32, uint32_t) 1837c478bd9Sstevel@tonic-gate KGREP_FANCY_TEMPLATE(kgrep_range_fancy64, uint64_t) 1847c478bd9Sstevel@tonic-gate 1857c478bd9Sstevel@tonic-gate #undef KGREP_FANCY_TEMPLATE 1867c478bd9Sstevel@tonic-gate 187154eb83fSjwadams void 188154eb83fSjwadams kgrep_help(void) 189154eb83fSjwadams { 190154eb83fSjwadams mdb_printf( 191154eb83fSjwadams "\n" 192154eb83fSjwadams "Search the entire virtual address space for a particular pattern,\n" 193154eb83fSjwadams "%<u>addr%</u>. By default, a pointer-sized search for an exact match is\n" 194154eb83fSjwadams "done.\n\n"); 195154eb83fSjwadams mdb_dec_indent(2); 196154eb83fSjwadams mdb_printf("%<b>OPTIONS%</b>\n"); 197154eb83fSjwadams mdb_inc_indent(2); 198154eb83fSjwadams mdb_printf( 199154eb83fSjwadams " -v Report the value matched at each address\n" 200154eb83fSjwadams " -a minaddr\n" 201154eb83fSjwadams " Restrict the search to addresses >= minaddr\n" 202154eb83fSjwadams " -A maxaddr\n" 203154eb83fSjwadams " Restrict the search to addresses < maxaddr\n" 204154eb83fSjwadams " -d dist\n" 205154eb83fSjwadams " Search for values in [addr, addr + dist)\n" 206154eb83fSjwadams " -m mask\n" 207154eb83fSjwadams " Search for values where (value & mask) == addr\n" 208154eb83fSjwadams " -M invmask\n" 209154eb83fSjwadams " Search for values where (value & ~invmask) == addr\n" 210154eb83fSjwadams " -s size\n" 211154eb83fSjwadams " Instead of pointer-sized values, search for size-byte values.\n" 212154eb83fSjwadams " size must be 1, 2, 4, or 8.\n"); 213154eb83fSjwadams } 214154eb83fSjwadams 2157c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 2167c478bd9Sstevel@tonic-gate int 2177c478bd9Sstevel@tonic-gate kgrep(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 2187c478bd9Sstevel@tonic-gate { 2197c478bd9Sstevel@tonic-gate uintmax_t pattern = mdb_get_dot(); 2207c478bd9Sstevel@tonic-gate uintmax_t mask = KGREP_FULL_MASK; 2217c478bd9Sstevel@tonic-gate uintmax_t invmask = 0; 2227c478bd9Sstevel@tonic-gate uintmax_t dist = 0; 2237c478bd9Sstevel@tonic-gate uintptr_t size = sizeof (uintptr_t); 2247c478bd9Sstevel@tonic-gate uintptr_t minaddr = 0; 2257c478bd9Sstevel@tonic-gate uintptr_t maxaddr = 0; 2267c478bd9Sstevel@tonic-gate size_t pagesize = kgrep_subr_pagesize(); 2277c478bd9Sstevel@tonic-gate int verbose = 0; 2287c478bd9Sstevel@tonic-gate int ret; 2297c478bd9Sstevel@tonic-gate int args = 0; 2307c478bd9Sstevel@tonic-gate 2317c478bd9Sstevel@tonic-gate kgrep_cb_func *func; 2327c478bd9Sstevel@tonic-gate kgrep_data_t kg; 2337c478bd9Sstevel@tonic-gate 2347c478bd9Sstevel@tonic-gate uintmax_t size_mask; 2357c478bd9Sstevel@tonic-gate 2367c478bd9Sstevel@tonic-gate if (mdb_getopts(argc, argv, 2377c478bd9Sstevel@tonic-gate 'a', MDB_OPT_UINTPTR, &minaddr, 2387c478bd9Sstevel@tonic-gate 'A', MDB_OPT_UINTPTR, &maxaddr, 2397c478bd9Sstevel@tonic-gate 'd', MDB_OPT_UINT64, &dist, 2407c478bd9Sstevel@tonic-gate 'm', MDB_OPT_UINT64, &mask, 2417c478bd9Sstevel@tonic-gate 'M', MDB_OPT_UINT64, &invmask, 2427c478bd9Sstevel@tonic-gate 's', MDB_OPT_UINTPTR, &size, 2437c478bd9Sstevel@tonic-gate 'v', MDB_OPT_SETBITS, B_TRUE, &verbose, NULL) != argc) 2447c478bd9Sstevel@tonic-gate return (DCMD_USAGE); 2457c478bd9Sstevel@tonic-gate 2467c478bd9Sstevel@tonic-gate if (invmask != 0) 2477c478bd9Sstevel@tonic-gate args++; 2487c478bd9Sstevel@tonic-gate if (mask != KGREP_FULL_MASK) 2497c478bd9Sstevel@tonic-gate args++; 2507c478bd9Sstevel@tonic-gate if (dist != 0) 2517c478bd9Sstevel@tonic-gate args++; 2527c478bd9Sstevel@tonic-gate 2537c478bd9Sstevel@tonic-gate if (args > 1) { 2547c478bd9Sstevel@tonic-gate mdb_warn("only one of -d, -m and -M may be specified\n"); 2557c478bd9Sstevel@tonic-gate return (DCMD_USAGE); 2567c478bd9Sstevel@tonic-gate } 2577c478bd9Sstevel@tonic-gate 2587c478bd9Sstevel@tonic-gate if (!(flags & DCMD_ADDRSPEC)) 2597c478bd9Sstevel@tonic-gate return (DCMD_USAGE); 2607c478bd9Sstevel@tonic-gate 2617c478bd9Sstevel@tonic-gate if (invmask != 0) 2627c478bd9Sstevel@tonic-gate mask = ~invmask; 2637c478bd9Sstevel@tonic-gate 2647c478bd9Sstevel@tonic-gate if (pattern & ~mask) 2657c478bd9Sstevel@tonic-gate mdb_warn("warning: pattern does not match mask\n"); 2667c478bd9Sstevel@tonic-gate 2677c478bd9Sstevel@tonic-gate if (size > sizeof (uintmax_t)) { 2687c478bd9Sstevel@tonic-gate mdb_warn("sizes greater than %d not supported\n", 2697c478bd9Sstevel@tonic-gate sizeof (uintmax_t)); 2707c478bd9Sstevel@tonic-gate return (DCMD_ERR); 2717c478bd9Sstevel@tonic-gate } 2727c478bd9Sstevel@tonic-gate 2737c478bd9Sstevel@tonic-gate if (size == 0 || (size & (size - 1)) != 0) { 2747c478bd9Sstevel@tonic-gate mdb_warn("size must be a power of 2\n"); 2757c478bd9Sstevel@tonic-gate return (DCMD_ERR); 2767c478bd9Sstevel@tonic-gate } 2777c478bd9Sstevel@tonic-gate 2787c478bd9Sstevel@tonic-gate if (size == sizeof (uintmax_t)) 2797c478bd9Sstevel@tonic-gate size_mask = KGREP_FULL_MASK; 2807c478bd9Sstevel@tonic-gate else 2817c478bd9Sstevel@tonic-gate size_mask = (1ULL << (size * NBBY)) - 1ULL; 2827c478bd9Sstevel@tonic-gate 2837c478bd9Sstevel@tonic-gate if (pattern & ~size_mask) 2847c478bd9Sstevel@tonic-gate mdb_warn("warning: pattern %llx overflows requested size " 2857c478bd9Sstevel@tonic-gate "%d (max: %llx)\n", 2867c478bd9Sstevel@tonic-gate pattern, size, size_mask); 2877c478bd9Sstevel@tonic-gate 2887c478bd9Sstevel@tonic-gate if (dist > 0 && 2897c478bd9Sstevel@tonic-gate ((dist & ~size_mask) || size_mask + 1 - dist < pattern)) { 2907c478bd9Sstevel@tonic-gate mdb_warn("pattern %llx + distance %llx overflows size\n" 2917c478bd9Sstevel@tonic-gate "%d (max: %llx)\n", pattern, dist, size, size_mask); 2927c478bd9Sstevel@tonic-gate return (DCMD_ERR); 2937c478bd9Sstevel@tonic-gate } 2947c478bd9Sstevel@tonic-gate 2957c478bd9Sstevel@tonic-gate /* 2967c478bd9Sstevel@tonic-gate * All arguments have now been validated. 2977c478bd9Sstevel@tonic-gate */ 2987c478bd9Sstevel@tonic-gate 2997c478bd9Sstevel@tonic-gate (void) memset(&kg, '\0', sizeof (kg)); 3007c478bd9Sstevel@tonic-gate kg.kg_page = mdb_alloc(pagesize, UM_SLEEP | UM_GC); 3017c478bd9Sstevel@tonic-gate kg.kg_pagesize = pagesize; 3027c478bd9Sstevel@tonic-gate kg.kg_pattern = pattern; 3037c478bd9Sstevel@tonic-gate kg.kg_mask = mask; 3047c478bd9Sstevel@tonic-gate kg.kg_dist = dist; 3057c478bd9Sstevel@tonic-gate kg.kg_minaddr = minaddr; 3067c478bd9Sstevel@tonic-gate kg.kg_maxaddr = maxaddr; 3077c478bd9Sstevel@tonic-gate 3087c478bd9Sstevel@tonic-gate if (flags & DCMD_PIPE_OUT) { 3097c478bd9Sstevel@tonic-gate verbose = 0; 3107c478bd9Sstevel@tonic-gate kg.kg_cbtype = KG_PIPE; 3117c478bd9Sstevel@tonic-gate } else if (verbose) { 3127c478bd9Sstevel@tonic-gate kg.kg_cbtype = KG_VERBOSE; 3137c478bd9Sstevel@tonic-gate } else { 3147c478bd9Sstevel@tonic-gate kg.kg_cbtype = KG_BASE; 3157c478bd9Sstevel@tonic-gate } 3167c478bd9Sstevel@tonic-gate 3177c478bd9Sstevel@tonic-gate /* 3187c478bd9Sstevel@tonic-gate * kgrep_range_basic handles the common case (no arguments) 3197c478bd9Sstevel@tonic-gate * with dispatch. 3207c478bd9Sstevel@tonic-gate */ 3217c478bd9Sstevel@tonic-gate if (size == sizeof (uintptr_t) && !verbose && mask == KGREP_FULL_MASK && 3227c478bd9Sstevel@tonic-gate dist == 0 && minaddr == 0 && maxaddr == 0) 3237c478bd9Sstevel@tonic-gate func = kgrep_range_basic; 3247c478bd9Sstevel@tonic-gate else { 3257c478bd9Sstevel@tonic-gate switch (size) { 3267c478bd9Sstevel@tonic-gate case 1: 3277c478bd9Sstevel@tonic-gate func = kgrep_range_fancy8; 3287c478bd9Sstevel@tonic-gate break; 3297c478bd9Sstevel@tonic-gate case 2: 3307c478bd9Sstevel@tonic-gate func = kgrep_range_fancy16; 3317c478bd9Sstevel@tonic-gate break; 3327c478bd9Sstevel@tonic-gate case 4: 3337c478bd9Sstevel@tonic-gate func = kgrep_range_fancy32; 3347c478bd9Sstevel@tonic-gate break; 3357c478bd9Sstevel@tonic-gate case 8: 3367c478bd9Sstevel@tonic-gate func = kgrep_range_fancy64; 3377c478bd9Sstevel@tonic-gate break; 3387c478bd9Sstevel@tonic-gate default: 3397c478bd9Sstevel@tonic-gate mdb_warn("can't happen: non-recognized kgrep size\n"); 3407c478bd9Sstevel@tonic-gate return (DCMD_ERR); 3417c478bd9Sstevel@tonic-gate } 3427c478bd9Sstevel@tonic-gate } 3437c478bd9Sstevel@tonic-gate 3447c478bd9Sstevel@tonic-gate /* 3457c478bd9Sstevel@tonic-gate * Invoke the target, which should invoke func(start, end, &kg) for 3467c478bd9Sstevel@tonic-gate * every range [start, end) of vaddrs which might have backing. 3477c478bd9Sstevel@tonic-gate * Both start and end must be multiples of kgrep_subr_pagesize(). 3487c478bd9Sstevel@tonic-gate */ 3497c478bd9Sstevel@tonic-gate ret = kgrep_subr(func, &kg); 3507c478bd9Sstevel@tonic-gate 3517c478bd9Sstevel@tonic-gate if (ret == DCMD_OK && !kg.kg_seen) 3527c478bd9Sstevel@tonic-gate mdb_warn("warning: nothing searched\n"); 3537c478bd9Sstevel@tonic-gate 3547c478bd9Sstevel@tonic-gate return (ret); 3557c478bd9Sstevel@tonic-gate } 356