8158 Want named threads API
[unleashed.git] / usr / src / cmd / mdb / common / mdb / mdb_kb_kvm.c
blob48b6e1ec9322183c71a8f981f45c777ea7cb8c69
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
27 * Copyright (c) 2013, Joyent, Inc. All rights reserved.
31 * The default KVM backend, which simply calls directly into libkvm for all
32 * operations.
35 #include <mdb/mdb_kb.h>
36 #include <mdb/mdb_target_impl.h>
38 #include <fcntl.h>
39 #include <dlfcn.h>
40 #include <kvm.h>
42 /*ARGSUSED*/
43 static mdb_io_t *
44 libkvm_sym_io(void *kvm, const char *ignored)
46 mdb_io_t *io;
47 const char *symfile = kvm_namelist(kvm);
49 if ((io = mdb_fdio_create_path(NULL, symfile, O_RDONLY, 0)) == NULL)
50 mdb_warn("failed to open %s", symfile);
52 return (io);
55 mdb_kb_ops_t *
56 libkvm_kb_ops(void)
58 static mdb_kb_ops_t ops = {
59 .kb_open = (void *(*)())kvm_open,
60 .kb_close = (int (*)())kvm_close,
61 .kb_sym_io = libkvm_sym_io,
62 .kb_kread = (ssize_t (*)())kvm_kread,
63 .kb_kwrite = (ssize_t (*)())kvm_kwrite,
64 .kb_aread = (ssize_t (*)())kvm_aread,
65 .kb_awrite = (ssize_t (*)())kvm_awrite,
66 .kb_pread = (ssize_t (*)())kvm_pread,
67 .kb_pwrite = (ssize_t (*)())kvm_pwrite,
68 .kb_getmregs = (int (*)())mdb_tgt_notsup,
69 .kb_vtop = (uint64_t (*)())kvm_physaddr,
71 return (&ops);