Print this page
9210 remove KMDB branch debugging support
9211 ::crregs could do with cr2/cr3 support
9209 ::ttrace should be able to filter by thread
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
Reviewed by: Yuri Pankov <yuripv@yuripv.net>
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/mdb/intel/kmdb/kmdb_dpi_isadep.c
+++ new/usr/src/cmd/mdb/intel/kmdb/kmdb_dpi_isadep.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
↓ open down ↓ |
13 lines elided |
↑ open up ↑ |
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 + *
25 + * Copyright 2018 Joyent, Inc.
24 26 */
25 27
26 -#pragma ident "%Z%%M% %I% %E% SMI"
27 -
28 28 /*
29 29 * Intel-specific portions of the DPI
30 30 */
31 31
32 32 #include <sys/types.h>
33 33 #include <sys/trap.h>
34 34
35 35 #include <kmdb/kmdb_dpi_impl.h>
36 36 #include <kmdb/kmdb_fault.h>
37 37 #include <kmdb/kmdb_kdi.h>
38 38 #include <mdb/mdb_err.h>
39 39 #include <mdb/mdb_debug.h>
40 40 #include <mdb/mdb_kreg.h>
41 41 #include <mdb/mdb.h>
42 42
43 43 void
44 44 kmdb_dpi_handle_fault(kreg_t trapno, kreg_t pc, kreg_t sp, int cpuid)
45 45 {
46 46 kmdb_kdi_system_claim();
47 47
48 48 mdb_dprintf(MDB_DBG_DPI, "\ndpi_handle_fault: trapno %u, pc 0x%0?p, "
49 49 "sp 0x%0?p\n", (int)trapno, pc, sp);
50 50
51 51 switch (trapno) {
52 52 case T_GPFLT:
53 53 errno = EACCES;
54 54 default:
55 55 errno = EMDB_NOMAP;
56 56 }
57 57
58 58 if (kmdb_dpi_fault_pcb != NULL) {
59 59 longjmp(*kmdb_dpi_fault_pcb, 1);
60 60 /*NOTREACHED*/
61 61 }
62 62
63 63 /* Debugger fault */
64 64 kmdb_fault(trapno, pc, sp, cpuid);
65 65 }
66 66
67 67 /*ARGSUSED*/
68 68 int
69 69 kmdb_dpi_get_register(const char *regname, kreg_t *kregp)
70 70 {
71 71 return (mdb.m_dpi->dpo_get_register(regname, kregp));
72 72 }
73 73
74 74 /*ARGSUSED*/
75 75 int
76 76 kmdb_dpi_set_register(const char *regname, kreg_t kreg)
77 77 {
78 78 return (mdb.m_dpi->dpo_set_register(regname, kreg));
79 79 }
80 80
81 81 /*
82 82 * Continue/resume handling. If the target calls kmdb_dpi_resume(), it
83 83 * expects that the world will be resumed, and that the call will return
84 84 * when the world has stopped again.
85 85 *
86 86 * For support, we have resume_return(), which is called from main() when
87 87 * the continuation has completed (when the world has stopped again).
88 88 * set_resume_exit() tells where to jump to actually restart the world.
89 89 *
90 90 * CAUTION: This routine may be called *after* mdb_destroy.
91 91 */
92 92 void
93 93 kmdb_dpi_resume_common(int cmd)
94 94 {
95 95 kreg_t pc, trapno;
96 96
97 97 ASSERT(kmdb_dpi_resume_requested == 0);
98 98
99 99 if (setjmp(kmdb_dpi_resume_pcb) == 0) {
100 100 (void) kmdb_dpi_get_register("pc", &pc);
101 101 mdb_dprintf(MDB_DBG_PROC, "Resume requested, pc is %p\n",
102 102 (void *)pc);
103 103
104 104 if (cmd != KMDB_DPI_CMD_RESUME_UNLOAD)
105 105 kmdb_dpi_resume_requested = 1;
106 106
107 107 longjmp(kmdb_dpi_entry_pcb, cmd);
108 108 /*NOTREACHED*/
109 109
110 110 } else {
111 111 (void) kmdb_dpi_get_register("pc", &pc);
112 112 (void) kmdb_dpi_get_register("trapno", &trapno);
113 113 mdb_dprintf(MDB_DBG_PROC, "Back from resume, pc: %p, "
114 114 "trapno: %u\n", (void *)pc, (int)trapno);
115 115
116 116 kmdb_dpi_resume_requested = 0;
117 117
118 118 switch (trapno) {
119 119 case T_BPTFLT:
120 120 kmdb_dpi_set_state(DPI_STATE_FAULTED,
121 121 DPI_STATE_WHY_BKPT);
122 122 break;
123 123 case T_DBGENTR:
124 124 kmdb_dpi_set_state(DPI_STATE_STOPPED, 0);
125 125 break;
126 126 default:
127 127 kmdb_dpi_set_state(DPI_STATE_FAULTED,
128 128 DPI_STATE_WHY_TRAP);
129 129 break;
130 130 }
131 131 }
132 132
133 133 mdb_dprintf(MDB_DBG_PROC, "returning from resume\n");
↓ open down ↓ |
96 lines elided |
↑ open up ↑ |
134 134 }
135 135
136 136 void
137 137 kmdb_dpi_reboot(void)
138 138 {
139 139 /*
140 140 * We're going to skip all of the niceties we employ in resume_common,
141 141 * as we don't plan to ever return.
142 142 */
143 143 longjmp(kmdb_dpi_entry_pcb, KMDB_DPI_CMD_REBOOT);
144 -}
145 -
146 -void
147 -kmdb_dpi_msr_add(const kdi_msr_t *msrs)
148 -{
149 - mdb.m_dpi->dpo_msr_add(msrs);
150 -}
151 -
152 -uint64_t
153 -kmdb_dpi_msr_get(uint_t msr)
154 -{
155 - return (mdb.m_dpi->dpo_msr_get(DPI_MASTER_CPUID, msr));
156 -}
157 -
158 -uint64_t
159 -kmdb_dpi_msr_get_by_cpu(int cpuid, uint_t msr)
160 -{
161 - return (mdb.m_dpi->dpo_msr_get(cpuid, msr));
162 144 }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX