kmdb_kvm.c revision 9d0d62ad2e60e8f742a2e723d06e88352ee6a1f3
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * CDDL HEADER START
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * The contents of this file are subject to the terms of the
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * Common Development and Distribution License (the "License").
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * You may not use this file except in compliance with the License.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * or http://www.opensolaris.org/os/licensing.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * See the License for the specific language governing permissions
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * and limitations under the License.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * When distributing Covered Code, include this CDDL HEADER in each
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * If applicable, add the following below this CDDL HEADER, with the
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * fields enclosed by brackets "[]" replaced with your own identifying
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * information: Portions Copyright [yyyy] [name of copyright owner]
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * CDDL HEADER END
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * Use is subject to license terms.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedystatic const char KMT_RTLD_NAME[] = "krtld";
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedystatic const char KMT_CTFPARENT[] = "genunix";
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedystatic mdb_list_t kmt_defbp_list; /* List of current deferred bp's */
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedystatic int kmt_defbp_lock; /* For list, running kernel holds */
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedystatic uint_t kmt_defbp_modchg_isload; /* Whether mod change is load/unload */
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedystatic struct modctl *kmt_defbp_modchg_modctl; /* modctl for defbp checking */
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedystatic uint_t kmt_defbp_num; /* Number of referenced def'd bp's */
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedystatic int kmt_defbp_bpspec; /* vespec for def'd bp activation bp */
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedytypedef struct kmt_symarg {
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy mdb_tgt_sym_f *sym_cb; /* Caller's callback function */
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy void *sym_data; /* Callback function argument */
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy uint_t sym_type; /* Symbol type/binding filter */
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy mdb_syminfo_t sym_info; /* Symbol id and table id */
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy const char *sym_obj; /* Containing object */
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedytypedef struct kmt_maparg {
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy mdb_tgt_t *map_target; /* Target used for mapping iter */
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy mdb_tgt_map_f *map_cb; /* Caller's callback function */
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy void *map_data; /* Callback function argument */
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * We only handle one flag (ALLOWIO), and we can't fail to set or clear
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * it, so we just blindly replace the t_flags version with the one
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy t->t_flags = (t->t_flags & ~MDB_TGT_F_ALLOWIO) |
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy return ("kmdb_kvm");
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedystatic const char *
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy if (kmdb_dpi_get_state(NULL) == DPI_STATE_INIT)
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy if (mdb_tgt_readsym(mdb.m_target, MDB_TGT_AS_VIRT, platform,
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy sizeof (platform), "unix", "platform") != sizeof (platform)) {
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy warn("'platform' symbol is missing from kernel\n");
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy return ("unknown");
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedykmt_uname(mdb_tgt_t *t, struct utsname *utsp)
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy return (mdb_tgt_readsym(t, MDB_TGT_AS_VIRT, utsp,
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy sizeof (struct utsname), MDB_TGT_OBJ_EXEC, "utsname"));
return (MDB_TGT_MODEL_NATIVE);
if (nbytes == 0)
ndone = 0;
while (nbytes > 0) {
addr += n;
nbytes -= n;
ndone += n;
return (ndone);
#ifdef _LP64
static ssize_t
return (nbytes);
return (nbytes);
static ssize_t
static ssize_t
static uintptr_t
mdb_var_t *v;
if (argc != 0)
return (DCMD_USAGE);
return (DCMD_ERR);
NULL);
argc -= i;
argv += i;
if (argc != 0)
return (DCMD_USAGE);
return (DCMD_ERR);
return (DCMD_OK);
return (DCMD_USAGE);
return (DCMD_ERR);
NULL);
argc -= i;
argv += i;
return (DCMD_USAGE);
STT_FUNC) {
return (DCMD_ERR);
parse_strings = 0;
argc--;
argv++;
for (i = 0; i < argc; i++) {
case MDB_TYPE_STRING:
case MDB_TYPE_IMMEDIATE:
return (DCMD_USAGE);
return (DCMD_ERR);
for (i = 0; i < argc; i++) {
quote);
return (DCMD_OK);
if (argc != 0)
return (DCMD_USAGE);
addr = 0;
return (DCMD_USAGE);
return (DCMD_OK);
mdb_var_t *v;
if (first) {
first = 0;
(int)(sizeof (void *) * NBBY),
return (DCMD_OK);
return (DCMD_USAGE);
return (DCMD_ERR);
return (DCMD_OK);
kmt_rdpcicfg },
{ NULL }
static uintmax_t
mdb_tgt_reg_t r = 0;
static kmt_module_t *
goto create_module_cleanup;
goto create_module_cleanup;
return (km);
return (NULL);
mdb_var_t *v;
const char *name;
goto found;
mdb_var_t *v;
mdb_var_t *v;
const struct kmt_seg {
kmt_maparg_t m;
m.map_target = t;
static const mdb_map_t *
return (map);
mdb_map_t m;
static const mdb_map_t *
return (NULL);
static kmt_module_t *
return (km);
return (NULL);
static const mdb_map_t *
mdb_map_t m;
return (NULL);
static ctf_file_t *
int err;
return (NULL);
return (NULL);
mdb_var_t *v;
return (NULL);
int state;
case DPI_STATE_INIT:
case DPI_STATE_STOPPED:
case DPI_STATE_FAULTED:
case DPI_STATE_LOST:
if (kmt_defbp_modchg_isload) {
if (!mdb_tgt_sespec_activate_all(t) &&
kmt_defbp_enter_debugger(void)
(void) get_fp();
kmt_defbp_lock = 0;
kmt_sync(t);
if (kmdb_kdi_get_unload_request())
int rc;
return (rc);
if (kmt_defbp_bpspec != 0) {
if (t != NULL)
kmt_defbp_bpspec = 0;
static kmt_defbp_t *
if (kmt_defbp_activate(t) < 0)
return (dbp);
if (kmt_defbp_lock)
kmt_defbp_prune(void)
kmt_defbp_destroy_all(void)
if (kmt_defbp_num == 0)
GElf_Sym s;
#ifdef __sparc
return (buf);
int rv;
return (rv);
int rv;
return (rv);
int error;
return (status);
const char *fmt;
case MDB_TGT_WA_R:
case MDB_TGT_WA_W:
case MDB_TGT_WA_X:
case DPI_WAPT_TYPE_PHYS:
case DPI_WAPT_TYPE_VIRT:
case DPI_WAPT_TYPE_IO:
return (buf);
return (status);
const char *name;
int trapnum;
return (buf);
switch (spectt) {
case KMT_TRAP_ALL:
case KMT_TRAP_NOTENUM:
int serrno;
goto wapt_dup;
goto wapt_dup;
void *data)
static uintmax_t
return (kmdb_dpi_get_master_cpuid());
NULL,
if (!kmt_defbp_lock)
int symavail;
(void) kmt_defbp_activate(t);
(void) mdb_tgt_sespec_activate_all(t);
if (argc != 0)
kmt_init_isadep(t);
kmt_destroy(t);
kmdb_kvm_startup(void)
kmdb_kvm_poststartup(void)