1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _MDB_KS_H 28 #define _MDB_KS_H 29 30 #pragma ident "%Z%%M% %I% %E% SMI" 31 32 #include <sys/types.h> 33 #include <sys/int_types.h> 34 #include <sys/stream.h> 35 #include <sys/vnode.h> 36 #include <sys/proc.h> 37 #include <sys/dumphdr.h> 38 #include <sys/auxv.h> 39 40 #ifdef __cplusplus 41 extern "C" { 42 #endif 43 44 /* 45 * MDB Kernel Support Interfaces: 46 * 47 * Debugger modules for kernel crash dumps can make use of these utility 48 * functions. This module also provides support for <mdb/mdb_param.h>. 49 */ 50 51 extern int mdb_vnode2path(uintptr_t, char *, size_t); 52 53 extern uintptr_t mdb_vnode2page(uintptr_t, uintptr_t); 54 55 extern uintptr_t mdb_pid2proc(pid_t, proc_t *); 56 extern char mdb_vtype2chr(vtype_t, mode_t); 57 extern uintptr_t mdb_addr2modctl(uintptr_t); 58 59 extern ssize_t mdb_read_refstr(uintptr_t, char *, size_t); 60 61 extern int mdb_name_to_major(const char *, major_t *); 62 extern const char *mdb_major_to_name(major_t); 63 64 extern int mdb_devinfo2driver(uintptr_t, char *, size_t); 65 extern int mdb_devinfo2statep(uintptr_t, char *, uintptr_t *); 66 67 extern int mdb_cpu2cpuid(uintptr_t); 68 69 /* 70 * Returns a pointer to the top of the soft state struct for the instance 71 * specified, given the address of the global soft state pointer and size 72 * of the struct. Also fills in the buffer pointed to by state_buf_p (if 73 * non-NULL) with the contents of the state struct. 74 */ 75 extern int mdb_get_soft_state_byaddr(uintptr_t, uint_t, uintptr_t *, void *, 76 size_t); 77 78 /* 79 * Returns a pointer to the top of the soft state struct for the instance 80 * specified, given the name of the global soft state pointer and size 81 * of the struct. Also fills in the buffer pointed to by state_buf_p (if 82 * non-NULL) with the contents of the state struct. 83 */ 84 extern int mdb_get_soft_state_byname(char *, uint_t, uintptr_t *, void *, 85 size_t); 86 87 /* 88 * Returns the pathname from the root devinfo node to the dip supplied. 89 * Just like ddi_pathname in sunddi.c. 90 */ 91 extern char *mdb_ddi_pathname(uintptr_t, char *, size_t); 92 93 94 /* 95 * MDB Kernel STREAMS Subsystem: 96 * 97 * Debugger modules such as ip can provide facilities for decoding private 98 * q_ptr data for STREAMS queues using this mechanism. The module first 99 * registers a set of functions which may be invoked when q->q_qinfo matches 100 * a given qinit address (such as ip`winit). The q_info function provides 101 * a way for the module to return an information string about the particular 102 * queue. The q_rnext and q_wnext functions provide a way for the generic 103 * queue walker to ask how to proceed deeper in the STREAM when q_next is 104 * NULL. This allows ip, for example, to provide access to the link-layer 105 * queues beneath the ip-client queue. 106 */ 107 108 typedef struct mdb_qops { 109 void (*q_info)(const queue_t *, char *, size_t); 110 uintptr_t (*q_rnext)(const queue_t *); 111 uintptr_t (*q_wnext)(const queue_t *); 112 } mdb_qops_t; 113 114 extern void mdb_qops_install(const mdb_qops_t *, uintptr_t); 115 extern void mdb_qops_remove(const mdb_qops_t *, uintptr_t); 116 117 extern char *mdb_qname(const queue_t *, char *, size_t); 118 extern void mdb_qinfo(const queue_t *, char *, size_t); 119 120 extern uintptr_t mdb_qrnext(const queue_t *); 121 extern uintptr_t mdb_qwnext(const queue_t *); 122 123 /* 124 * These functions, provided by mdb_ks, may be used to fill in the q_rnext 125 * and q_wnext members of mdb_qops_t, in the case where the client wishes 126 * to simply return q->q_next: 127 */ 128 extern uintptr_t mdb_qrnext_default(const queue_t *); 129 extern uintptr_t mdb_qwnext_default(const queue_t *); 130 131 /* 132 * Target-specific interfaces 133 * 134 * The existence and accessibility of the functions listed below is relied upon 135 * by the indicated targets. The targets look up and invoke these functions in 136 * mdb_ks so that dependencies on the current kernel implementation are 137 * isolated in mdb_ks. 138 */ 139 140 /* 141 * MDB KPROC Target Interface: 142 * (user processes from kernel crash dump) 143 */ 144 145 struct mdb_map; /* Private between kproc and ks */ 146 147 extern int mdb_kproc_asiter(uintptr_t, 148 void (*)(const struct mdb_map *, void *), void *); 149 extern int mdb_kproc_auxv(uintptr_t, auxv_t *); 150 extern uintptr_t mdb_kproc_as(uintptr_t); 151 extern pid_t mdb_kproc_pid(uintptr_t); 152 153 154 /* 155 * MDB KVM Target Interface: 156 * (kernel dump) 157 */ 158 159 extern void mdb_dump_print_content(dumphdr_t *, pid_t); 160 extern int mdb_dump_find_curproc(void); 161 162 /* 163 * KMDB Target Interface: 164 */ 165 #ifdef _KMDB 166 extern const mdb_modinfo_t *mdb_ks_init(void); 167 #endif 168 169 #ifdef __cplusplus 170 } 171 #endif 172 173 #endif /* _MDB_KS_H */ 174