VirtualBox

source: vbox/trunk/src/VBox/Debugger/DBGCBuiltInSymbols.cpp@ 34368

Last change on this file since 34368 was 31530, checked in by vboxsync, 14 years ago

Debugger: Updated the file headers.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 26.9 KB
Line 
1/* $Id: DBGCBuiltInSymbols.cpp 31530 2010-08-10 12:24:45Z vboxsync $ */
2/** @file
3 * DBGC - Debugger Console, Built-In Symbols.
4 */
5
6/*
7 * Copyright (C) 2006-2010 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18/*******************************************************************************
19* Header Files *
20*******************************************************************************/
21#define LOG_GROUP LOG_GROUP_DBGC
22#include <VBox/dbg.h>
23#include <VBox/dbgf.h>
24#include <VBox/vm.h>
25#include <VBox/vmm.h>
26#include <VBox/mm.h>
27#include <VBox/pgm.h>
28#include <VBox/selm.h>
29#include <VBox/dis.h>
30#include <VBox/param.h>
31#include <VBox/err.h>
32#include <VBox/log.h>
33
34#include <iprt/alloc.h>
35#include <iprt/alloca.h>
36#include <iprt/string.h>
37#include <iprt/assert.h>
38#include <iprt/ctype.h>
39
40#include <stdlib.h>
41#include <stdio.h>
42
43#include "DBGCInternal.h"
44
45
46/*******************************************************************************
47* Internal Functions *
48*******************************************************************************/
49static DECLCALLBACK(int) dbgcSymGetReg(PCDBGCSYM pSymDesc, PDBGCCMDHLP pCmdHlp, DBGCVARTYPE enmType, PDBGCVAR pResult);
50static DECLCALLBACK(int) dbgcSymSetReg(PCDBGCSYM pSymDesc, PDBGCCMDHLP pCmdHlp, PCDBGCVAR pValue);
51
52
53/*******************************************************************************
54* Global Variables *
55*******************************************************************************/
56/** Register symbol uUser value.
57 * @{
58 */
59/** If set the register set is the hypervisor and not the guest one. */
60#define SYMREG_FLAGS_HYPER RT_BIT(20)
61/** If set a far conversion of the value will use the high 16 bit for the selector.
62 * If clear the low 16 bit will be used. */
63#define SYMREG_FLAGS_HIGH_SEL RT_BIT(21)
64/** The shift value to calc the size of a register symbol from the uUser value. */
65#define SYMREG_SIZE_SHIFT (24)
66/** Get the offset */
67#define SYMREG_OFFSET(uUser) (uUser & ((1 << 20) - 1))
68/** Get the size. */
69#define SYMREG_SIZE(uUser) ((uUser >> SYMREG_SIZE_SHIFT) & 0xff)
70/** 1 byte. */
71#define SYMREG_SIZE_1 ( 1 << SYMREG_SIZE_SHIFT)
72/** 2 byte. */
73#define SYMREG_SIZE_2 ( 2 << SYMREG_SIZE_SHIFT)
74/** 4 byte. */
75#define SYMREG_SIZE_4 ( 4 << SYMREG_SIZE_SHIFT)
76/** 6 byte. */
77#define SYMREG_SIZE_6 ( 6 << SYMREG_SIZE_SHIFT)
78/** 8 byte. */
79#define SYMREG_SIZE_8 ( 8 << SYMREG_SIZE_SHIFT)
80/** 10 bytes. */
81#define SYMREG_SIZE_10 (10 << SYMREG_SIZE_SHIFT)
82/** 12 byte. */
83#define SYMREG_SIZE_12 (12 << SYMREG_SIZE_SHIFT)
84/** 16 byte. */
85#define SYMREG_SIZE_16 (16 << SYMREG_SIZE_SHIFT)
86/** @} */
87
88/** Builtin Symbols.
89 * ASSUMES little endian register representation!
90 */
91static const DBGCSYM g_aSyms[] =
92{
93 { "rax", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, rax) | SYMREG_SIZE_8 },
94 { "eax", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, eax) | SYMREG_SIZE_4 },
95 { "ax", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, eax) | SYMREG_SIZE_2 },
96 { "al", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, eax) | SYMREG_SIZE_1 },
97 { "ah", dbgcSymGetReg, dbgcSymSetReg, (offsetof(CPUMCTX, eax) + 1)| SYMREG_SIZE_1 },
98
99 { "rbx", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, rbx) | SYMREG_SIZE_8 },
100 { "ebx", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, ebx) | SYMREG_SIZE_4 },
101 { "bx", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, ebx) | SYMREG_SIZE_2 },
102 { "bl", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, ebx) | SYMREG_SIZE_1 },
103 { "bh", dbgcSymGetReg, dbgcSymSetReg, (offsetof(CPUMCTX, ebx) + 1)| SYMREG_SIZE_1 },
104
105 { "rcx", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, ecx) | SYMREG_SIZE_8 },
106 { "ecx", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, ecx) | SYMREG_SIZE_4 },
107 { "cx", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, ecx) | SYMREG_SIZE_2 },
108 { "cl", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, ecx) | SYMREG_SIZE_1 },
109 { "ch", dbgcSymGetReg, dbgcSymSetReg, (offsetof(CPUMCTX, ecx) + 1)| SYMREG_SIZE_1 },
110
111 { "rdx", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, rdx) | SYMREG_SIZE_8 },
112 { "edx", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, edx) | SYMREG_SIZE_4 },
113 { "dx", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, edx) | SYMREG_SIZE_2 },
114 { "dl", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, edx) | SYMREG_SIZE_1 },
115 { "dh", dbgcSymGetReg, dbgcSymSetReg, (offsetof(CPUMCTX, edx) + 1)| SYMREG_SIZE_1 },
116
117 { "rdi", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, rdi) | SYMREG_SIZE_8 },
118 { "edi", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, edi) | SYMREG_SIZE_4 },
119 { "di", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, edi) | SYMREG_SIZE_2 },
120 { "dil", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, edi) | SYMREG_SIZE_1 },
121
122 { "rsi", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, rsi) | SYMREG_SIZE_8 },
123 { "esi", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, esi) | SYMREG_SIZE_4 },
124 { "si", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, esi) | SYMREG_SIZE_2 },
125 { "sil", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, esi) | SYMREG_SIZE_1 },
126
127 { "rbp", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, rbp) | SYMREG_SIZE_8 },
128 { "ebp", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, ebp) | SYMREG_SIZE_4 },
129 { "bp", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, ebp) | SYMREG_SIZE_2 },
130 { "bpl", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, ebp) | SYMREG_SIZE_1 },
131
132 { "rsp", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, rsp) | SYMREG_SIZE_8 },
133 { "esp", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, esp) | SYMREG_SIZE_4 },
134 { "sp", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, esp) | SYMREG_SIZE_2 },
135 { "spl", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, esp) | SYMREG_SIZE_1 },
136
137 { "r8", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, r8) | SYMREG_SIZE_8 },
138 { "r9", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, r9) | SYMREG_SIZE_8 },
139 { "r10", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, r10) | SYMREG_SIZE_8 },
140 { "r11", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, r11) | SYMREG_SIZE_8 },
141 { "r12", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, r12) | SYMREG_SIZE_8 },
142 { "r13", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, r13) | SYMREG_SIZE_8 },
143 { "r14", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, r14) | SYMREG_SIZE_8 },
144 { "r15", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, r15) | SYMREG_SIZE_8 },
145
146 { "r8d", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, r8) | SYMREG_SIZE_4 },
147 { "r9d", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, r9) | SYMREG_SIZE_4 },
148 { "r10d", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, r10) | SYMREG_SIZE_4 },
149 { "r11d", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, r11) | SYMREG_SIZE_4 },
150 { "r12d", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, r12) | SYMREG_SIZE_4 },
151 { "r13d", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, r13) | SYMREG_SIZE_4 },
152 { "r14d", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, r14) | SYMREG_SIZE_4 },
153 { "r15d", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, r15) | SYMREG_SIZE_4 },
154
155 { "r8w", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, r8) | SYMREG_SIZE_2 },
156 { "r9w", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, r9) | SYMREG_SIZE_2 },
157 { "r10w", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, r10) | SYMREG_SIZE_2 },
158 { "r11w", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, r11) | SYMREG_SIZE_2 },
159 { "r12w", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, r12) | SYMREG_SIZE_2 },
160 { "r13w", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, r13) | SYMREG_SIZE_2 },
161 { "r14w", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, r14) | SYMREG_SIZE_2 },
162 { "r15w", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, r15) | SYMREG_SIZE_2 },
163
164 { "r8b", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, r8) | SYMREG_SIZE_1 },
165 { "r9b", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, r9) | SYMREG_SIZE_1 },
166 { "r10b", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, r10) | SYMREG_SIZE_1 },
167 { "r11b", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, r11) | SYMREG_SIZE_1 },
168 { "r12b", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, r12) | SYMREG_SIZE_1 },
169 { "r13b", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, r13) | SYMREG_SIZE_1 },
170 { "r14b", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, r14) | SYMREG_SIZE_1 },
171 { "r15b", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, r15) | SYMREG_SIZE_1 },
172
173 { "rip", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, rip) | SYMREG_SIZE_8 },
174 { "eip", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, eip) | SYMREG_SIZE_4 },
175 { "ip", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, eip) | SYMREG_SIZE_2 },
176
177 { "rfl", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, rflags) | SYMREG_SIZE_8 },
178 { "rflags", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, rflags) | SYMREG_SIZE_8 },
179 { "efl", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, eflags) | SYMREG_SIZE_4 },
180 { "eflags", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, eflags) | SYMREG_SIZE_4 },
181 { "fl", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, eflags) | SYMREG_SIZE_2 },
182 { "flags", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, eflags) | SYMREG_SIZE_2 },
183
184 { "cs", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, cs) | SYMREG_SIZE_2 },
185 { "ds", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, ds) | SYMREG_SIZE_2 },
186 { "es", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, es) | SYMREG_SIZE_2 },
187 { "fs", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, fs) | SYMREG_SIZE_2 },
188 { "gs", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, gs) | SYMREG_SIZE_2 },
189 { "ss", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, ss) | SYMREG_SIZE_2 },
190
191 { "cr0", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, cr0) | SYMREG_SIZE_8 },
192 { "cr2", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, cr2) | SYMREG_SIZE_8 },
193 { "cr3", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, cr3) | SYMREG_SIZE_8 },
194 { "cr4", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, cr4) | SYMREG_SIZE_8 },
195
196 { "tr", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, tr) | SYMREG_SIZE_2 },
197 { "ldtr", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, ldtr) | SYMREG_SIZE_2 },
198
199 { "gdtr", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, gdtr) | SYMREG_SIZE_10 },
200 { "gdtr.limit", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, gdtr.cbGdt)| SYMREG_SIZE_2 },
201 { "gdtr.base", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, gdtr.pGdt)| SYMREG_SIZE_8 },
202
203 { "idtr", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, idtr) | SYMREG_SIZE_10 },
204 { "idtr.limit", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, idtr.cbIdt)| SYMREG_SIZE_2 },
205 { "idtr.base", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, idtr.pIdt)| SYMREG_SIZE_8 },
206
207 /* hypervisor */
208
209 {".eax", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, eax) | SYMREG_SIZE_4 | SYMREG_FLAGS_HYPER },
210 {".ax", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, eax) | SYMREG_SIZE_2 | SYMREG_FLAGS_HYPER },
211 {".al", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, eax) | SYMREG_SIZE_1 | SYMREG_FLAGS_HYPER },
212 {".ah", dbgcSymGetReg, dbgcSymSetReg, (offsetof(CPUMCTX, eax) + 1)| SYMREG_SIZE_1 | SYMREG_FLAGS_HYPER },
213
214 {".ebx", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, ebx) | SYMREG_SIZE_4 | SYMREG_FLAGS_HYPER },
215 {".bx", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, ebx) | SYMREG_SIZE_2 | SYMREG_FLAGS_HYPER },
216 {".bl", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, ebx) | SYMREG_SIZE_1 | SYMREG_FLAGS_HYPER },
217 {".bh", dbgcSymGetReg, dbgcSymSetReg, (offsetof(CPUMCTX, ebx) + 1)| SYMREG_SIZE_1 | SYMREG_FLAGS_HYPER },
218
219 {".ecx", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, ecx) | SYMREG_SIZE_4 | SYMREG_FLAGS_HYPER },
220 {".cx", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, ecx) | SYMREG_SIZE_2 | SYMREG_FLAGS_HYPER },
221 {".cl", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, ecx) | SYMREG_SIZE_1 | SYMREG_FLAGS_HYPER },
222 {".ch", dbgcSymGetReg, dbgcSymSetReg, (offsetof(CPUMCTX, ecx) + 1)| SYMREG_SIZE_1 | SYMREG_FLAGS_HYPER },
223
224 {".edx", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, edx) | SYMREG_SIZE_4 | SYMREG_FLAGS_HYPER },
225 {".dx", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, edx) | SYMREG_SIZE_2 | SYMREG_FLAGS_HYPER },
226 {".dl", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, edx) | SYMREG_SIZE_1 | SYMREG_FLAGS_HYPER },
227 {".dh", dbgcSymGetReg, dbgcSymSetReg, (offsetof(CPUMCTX, edx) + 1)| SYMREG_SIZE_1 | SYMREG_FLAGS_HYPER },
228
229 {".edi", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, edi) | SYMREG_SIZE_4 | SYMREG_FLAGS_HYPER },
230 {".di", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, edi) | SYMREG_SIZE_2 | SYMREG_FLAGS_HYPER },
231
232 {".esi", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, esi) | SYMREG_SIZE_4 | SYMREG_FLAGS_HYPER },
233 {".si", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, esi) | SYMREG_SIZE_2 | SYMREG_FLAGS_HYPER },
234
235 {".ebp", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, ebp) | SYMREG_SIZE_4 | SYMREG_FLAGS_HYPER },
236 {".bp", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, ebp) | SYMREG_SIZE_2 | SYMREG_FLAGS_HYPER },
237
238 {".esp", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, esp) | SYMREG_SIZE_4 | SYMREG_FLAGS_HYPER },
239 {".sp", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, esp) | SYMREG_SIZE_2 | SYMREG_FLAGS_HYPER },
240
241 {".eip", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, eip) | SYMREG_SIZE_4 | SYMREG_FLAGS_HYPER },
242 {".ip", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, eip) | SYMREG_SIZE_2 | SYMREG_FLAGS_HYPER },
243
244 {".efl", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, eflags) | SYMREG_SIZE_4 | SYMREG_FLAGS_HYPER },
245 {".eflags", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, eflags) | SYMREG_SIZE_4 | SYMREG_FLAGS_HYPER },
246 {".fl", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, eflags) | SYMREG_SIZE_2 | SYMREG_FLAGS_HYPER },
247 {".flags", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, eflags) | SYMREG_SIZE_2 | SYMREG_FLAGS_HYPER },
248
249 {".cs", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, cs) | SYMREG_SIZE_2 | SYMREG_FLAGS_HYPER },
250 {".ds", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, ds) | SYMREG_SIZE_2 | SYMREG_FLAGS_HYPER },
251 {".es", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, es) | SYMREG_SIZE_2 | SYMREG_FLAGS_HYPER },
252 {".fs", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, fs) | SYMREG_SIZE_2 | SYMREG_FLAGS_HYPER },
253 {".gs", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, gs) | SYMREG_SIZE_2 | SYMREG_FLAGS_HYPER },
254 {".ss", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, ss) | SYMREG_SIZE_2 | SYMREG_FLAGS_HYPER },
255
256 {".cr0", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, cr0) | SYMREG_SIZE_4 | SYMREG_FLAGS_HYPER },
257 {".cr2", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, cr2) | SYMREG_SIZE_4 | SYMREG_FLAGS_HYPER },
258 {".cr3", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, cr3) | SYMREG_SIZE_4 | SYMREG_FLAGS_HYPER },
259 {".cr4", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, cr4) | SYMREG_SIZE_4 | SYMREG_FLAGS_HYPER },
260
261 {".tr", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, tr) | SYMREG_SIZE_2 | SYMREG_FLAGS_HYPER },
262 {".ldtr", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, ldtr) | SYMREG_SIZE_2 | SYMREG_FLAGS_HYPER },
263
264 {".gdtr", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, gdtr) | SYMREG_SIZE_10 | SYMREG_FLAGS_HYPER },
265 {".gdtr.limit", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, gdtr.cbGdt)| SYMREG_SIZE_2| SYMREG_FLAGS_HYPER },
266 {".gdtr.base", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, gdtr.pGdt)| SYMREG_SIZE_8 | SYMREG_FLAGS_HYPER },
267
268 {".idtr", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, idtr) | SYMREG_SIZE_10 | SYMREG_FLAGS_HYPER },
269 {".idtr.limit", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, idtr.cbIdt)| SYMREG_SIZE_2| SYMREG_FLAGS_HYPER },
270 {".idtr.base", dbgcSymGetReg, dbgcSymSetReg, offsetof(CPUMCTX, idtr.pIdt)| SYMREG_SIZE_8 | SYMREG_FLAGS_HYPER },
271
272};
273
274
275
276/**
277 * Get builtin register symbol.
278 *
279 * The uUser is special for these symbol descriptors. See the SYMREG_* \#defines.
280 *
281 * @returns 0 on success.
282 * @returns VBox evaluation / parsing error code on failure.
283 * The caller does the bitching.
284 * @param pSymDesc Pointer to the symbol descriptor.
285 * @param pCmdHlp Pointer to the command callback structure.
286 * @param enmType The result type.
287 * @param pResult Where to store the result.
288 */
289static DECLCALLBACK(int) dbgcSymGetReg(PCDBGCSYM pSymDesc, PDBGCCMDHLP pCmdHlp, DBGCVARTYPE enmType, PDBGCVAR pResult)
290{
291 LogFlow(("dbgcSymSetReg: pSymDesc->pszName=%d\n", pSymDesc->pszName));
292
293 /*
294 * pVM is required.
295 */
296 PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
297 Assert(pDbgc->pVM);
298
299 /*
300 * Get the right CPU context.
301 */
302 PVMCPU pVCpu = VMMGetCpuById(pDbgc->pVM, pDbgc->idCpu);
303 PCPUMCTX pCtx;
304 int rc;
305 if (!(pSymDesc->uUser & SYMREG_FLAGS_HYPER))
306 {
307 pCtx = CPUMQueryGuestCtxPtr(pVCpu);
308 rc = VINF_SUCCESS;
309 }
310 else
311 rc = CPUMQueryHyperCtxPtr(pVCpu, &pCtx);
312 if (RT_FAILURE(rc))
313 return rc;
314
315 /*
316 * Get the value.
317 */
318 void *pvValue = (char *)pCtx + SYMREG_OFFSET(pSymDesc->uUser);
319 uint64_t u64;
320 switch (SYMREG_SIZE(pSymDesc->uUser))
321 {
322 case 1: u64 = *(uint8_t *)pvValue; break;
323 case 2: u64 = *(uint16_t *)pvValue; break;
324 case 4: u64 = *(uint32_t *)pvValue; break;
325 case 6: u64 = *(uint32_t *)pvValue | ((uint64_t)*(uint16_t *)((char *)pvValue + sizeof(uint32_t)) << 32); break;
326 case 8: u64 = *(uint64_t *)pvValue; break;
327 default:
328 return VERR_PARSE_NOT_IMPLEMENTED;
329 }
330
331 /*
332 * Construct the desired result.
333 */
334 if (enmType == DBGCVAR_TYPE_ANY)
335 enmType = DBGCVAR_TYPE_NUMBER;
336 pResult->pDesc = NULL;
337 pResult->pNext = NULL;
338 pResult->enmType = enmType;
339 pResult->enmRangeType = DBGCVAR_RANGE_NONE;
340 pResult->u64Range = 0;
341
342 switch (enmType)
343 {
344 case DBGCVAR_TYPE_GC_FLAT:
345 pResult->u.GCFlat = (RTGCPTR)u64;
346 break;
347
348 case DBGCVAR_TYPE_GC_FAR:
349 switch (SYMREG_SIZE(pSymDesc->uUser))
350 {
351 case 4:
352 if (!(pSymDesc->uUser & SYMREG_FLAGS_HIGH_SEL))
353 {
354 pResult->u.GCFar.off = (uint16_t)u64;
355 pResult->u.GCFar.sel = (uint16_t)(u64 >> 16);
356 }
357 else
358 {
359 pResult->u.GCFar.sel = (uint16_t)u64;
360 pResult->u.GCFar.off = (uint16_t)(u64 >> 16);
361 }
362 break;
363 case 6:
364 if (!(pSymDesc->uUser & SYMREG_FLAGS_HIGH_SEL))
365 {
366 pResult->u.GCFar.off = (uint32_t)u64;
367 pResult->u.GCFar.sel = (uint16_t)(u64 >> 32);
368 }
369 else
370 {
371 pResult->u.GCFar.sel = (uint32_t)u64;
372 pResult->u.GCFar.off = (uint16_t)(u64 >> 32);
373 }
374 break;
375
376 default:
377 return VERR_PARSE_BAD_RESULT_TYPE;
378 }
379 break;
380
381 case DBGCVAR_TYPE_GC_PHYS:
382 pResult->u.GCPhys = (RTGCPHYS)u64;
383 break;
384
385 case DBGCVAR_TYPE_HC_FLAT:
386 pResult->u.pvHCFlat = (void *)(uintptr_t)u64;
387 break;
388
389 case DBGCVAR_TYPE_HC_FAR:
390 switch (SYMREG_SIZE(pSymDesc->uUser))
391 {
392 case 4:
393 if (!(pSymDesc->uUser & SYMREG_FLAGS_HIGH_SEL))
394 {
395 pResult->u.HCFar.off = (uint16_t)u64;
396 pResult->u.HCFar.sel = (uint16_t)(u64 >> 16);
397 }
398 else
399 {
400 pResult->u.HCFar.sel = (uint16_t)u64;
401 pResult->u.HCFar.off = (uint16_t)(u64 >> 16);
402 }
403 break;
404 case 6:
405 if (!(pSymDesc->uUser & SYMREG_FLAGS_HIGH_SEL))
406 {
407 pResult->u.HCFar.off = (uint32_t)u64;
408 pResult->u.HCFar.sel = (uint16_t)(u64 >> 32);
409 }
410 else
411 {
412 pResult->u.HCFar.sel = (uint32_t)u64;
413 pResult->u.HCFar.off = (uint16_t)(u64 >> 32);
414 }
415 break;
416
417 default:
418 return VERR_PARSE_BAD_RESULT_TYPE;
419 }
420 break;
421
422 case DBGCVAR_TYPE_HC_PHYS:
423 pResult->u.GCPhys = (RTGCPHYS)u64;
424 break;
425
426 case DBGCVAR_TYPE_NUMBER:
427 pResult->u.u64Number = u64;
428 break;
429
430 case DBGCVAR_TYPE_STRING:
431 case DBGCVAR_TYPE_UNKNOWN:
432 default:
433 return VERR_PARSE_BAD_RESULT_TYPE;
434
435 }
436
437 return 0;
438}
439
440
441/**
442 * Set builtin register symbol.
443 *
444 * The uUser is special for these symbol descriptors. See the SYMREG_* #defines.
445 *
446 * @returns 0 on success.
447 * @returns VBox evaluation / parsing error code on failure.
448 * The caller does the bitching.
449 * @param pSymDesc Pointer to the symbol descriptor.
450 * @param pCmdHlp Pointer to the command callback structure.
451 * @param pValue The value to assign the symbol.
452 */
453static DECLCALLBACK(int) dbgcSymSetReg(PCDBGCSYM pSymDesc, PDBGCCMDHLP pCmdHlp, PCDBGCVAR pValue)
454{
455 LogFlow(("dbgcSymSetReg: pSymDesc->pszName=%d\n", pSymDesc->pszName));
456
457 /*
458 * pVM is required.
459 */
460 PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
461 Assert(pDbgc->pVM);
462
463 /*
464 * Get the right CPU context.
465 */
466 PVMCPU pVCpu = VMMGetCpuById(pDbgc->pVM, pDbgc->idCpu);
467 PCPUMCTX pCtx;
468 int rc;
469 if (!(pSymDesc->uUser & SYMREG_FLAGS_HYPER))
470 {
471 pCtx = CPUMQueryGuestCtxPtr(pVCpu);
472 rc = VINF_SUCCESS;
473 }
474 else
475 rc = CPUMQueryHyperCtxPtr(pVCpu, &pCtx);
476 if (RT_FAILURE(rc))
477 return rc;
478
479 /*
480 * Check the new value.
481 */
482 if (pValue->enmType != DBGCVAR_TYPE_NUMBER)
483 return VERR_PARSE_ARGUMENT_TYPE_MISMATCH;
484
485 /*
486 * Set the value.
487 */
488 void *pvValue = (char *)pCtx + SYMREG_OFFSET(pSymDesc->uUser);
489 switch (SYMREG_SIZE(pSymDesc->uUser))
490 {
491 case 1:
492 *(uint8_t *)pvValue = (uint8_t)pValue->u.u64Number;
493 break;
494 case 2:
495 *(uint16_t *)pvValue = (uint16_t)pValue->u.u64Number;
496 break;
497 case 4:
498 *(uint32_t *)pvValue = (uint32_t)pValue->u.u64Number;
499 break;
500 case 6:
501 *(uint32_t *)pvValue = (uint32_t)pValue->u.u64Number;
502 ((uint16_t *)pvValue)[3] = (uint16_t)(pValue->u.u64Number >> 32);
503 break;
504 case 8:
505 *(uint64_t *)pvValue = pValue->u.u64Number;
506 break;
507 default:
508 return VERR_PARSE_NOT_IMPLEMENTED;
509 }
510
511 return VINF_SUCCESS;
512}
513
514
515/**
516 * Finds a builtin symbol.
517 * @returns Pointer to symbol descriptor on success.
518 * @returns NULL on failure.
519 * @param pDbgc The debug console instance.
520 * @param pszSymbol The symbol name.
521 */
522PCDBGCSYM dbgcLookupRegisterSymbol(PDBGC pDbgc, const char *pszSymbol)
523{
524 for (unsigned iSym = 0; iSym < RT_ELEMENTS(g_aSyms); iSym++)
525 if (!strcmp(pszSymbol, g_aSyms[iSym].pszName))
526 return &g_aSyms[iSym];
527
528 /** @todo externally registered symbols. */
529 NOREF(pDbgc);
530 return NULL;
531}
532
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette