1 | /* $Id: DBGPlugInOS2.cpp 104607 2024-05-13 16:06:17Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * DBGPlugInOS2 - Debugger and Guest OS Digger Plugin For OS/2.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2009-2023 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | */
|
---|
27 |
|
---|
28 |
|
---|
29 | /*********************************************************************************************************************************
|
---|
30 | * Header Files *
|
---|
31 | *********************************************************************************************************************************/
|
---|
32 | #define LOG_GROUP LOG_GROUP_DBGF /// @todo add new log group.
|
---|
33 | #include "DBGPlugIns.h"
|
---|
34 | #include <VBox/vmm/vmmr3vtable.h>
|
---|
35 | #include <VBox/err.h>
|
---|
36 | #include <VBox/param.h>
|
---|
37 | #include <iprt/string.h>
|
---|
38 | #include <iprt/mem.h>
|
---|
39 | #include <iprt/stream.h>
|
---|
40 |
|
---|
41 |
|
---|
42 | /*********************************************************************************************************************************
|
---|
43 | * Structures and Typedefs *
|
---|
44 | *********************************************************************************************************************************/
|
---|
45 |
|
---|
46 | typedef enum DBGDIGGEROS2VER
|
---|
47 | {
|
---|
48 | DBGDIGGEROS2VER_UNKNOWN,
|
---|
49 | DBGDIGGEROS2VER_1_x,
|
---|
50 | DBGDIGGEROS2VER_2_x,
|
---|
51 | DBGDIGGEROS2VER_3_0,
|
---|
52 | DBGDIGGEROS2VER_4_0,
|
---|
53 | DBGDIGGEROS2VER_4_5
|
---|
54 | } DBGDIGGEROS2VER;
|
---|
55 |
|
---|
56 | /**
|
---|
57 | * OS/2 guest OS digger instance data.
|
---|
58 | */
|
---|
59 | typedef struct DBGDIGGEROS2
|
---|
60 | {
|
---|
61 | /** The user-mode VM handle for use in info handlers. */
|
---|
62 | PUVM pUVM;
|
---|
63 | /** The VMM function table for use in info handlers. */
|
---|
64 | PCVMMR3VTABLE pVMM;
|
---|
65 |
|
---|
66 | /** Whether the information is valid or not.
|
---|
67 | * (For fending off illegal interface method calls.) */
|
---|
68 | bool fValid;
|
---|
69 | /** 32-bit (true) or 16-bit (false) */
|
---|
70 | bool f32Bit;
|
---|
71 |
|
---|
72 | /** The OS/2 guest version. */
|
---|
73 | DBGDIGGEROS2VER enmVer;
|
---|
74 | uint8_t OS2MajorVersion;
|
---|
75 | uint8_t OS2MinorVersion;
|
---|
76 |
|
---|
77 | /** Guest's Global Info Segment selector. */
|
---|
78 | uint16_t selGis;
|
---|
79 | /** The 16:16 address of the LIS. */
|
---|
80 | RTFAR32 Lis;
|
---|
81 |
|
---|
82 | /** The kernel virtual address (excluding DOSMVDMINSTDATA & DOSSWAPINSTDATA). */
|
---|
83 | uint32_t uKernelAddr;
|
---|
84 | /** The kernel size. */
|
---|
85 | uint32_t cbKernel;
|
---|
86 |
|
---|
87 | } DBGDIGGEROS2;
|
---|
88 | /** Pointer to the OS/2 guest OS digger instance data. */
|
---|
89 | typedef DBGDIGGEROS2 *PDBGDIGGEROS2;
|
---|
90 |
|
---|
91 | /**
|
---|
92 | * 32-bit OS/2 loader module table entry.
|
---|
93 | */
|
---|
94 | typedef struct LDRMTE
|
---|
95 | {
|
---|
96 | uint16_t mte_flags2;
|
---|
97 | uint16_t mte_handle;
|
---|
98 | uint32_t mte_swapmte; /**< Pointer to LDRSMTE. */
|
---|
99 | uint32_t mte_link; /**< Pointer to next LDRMTE. */
|
---|
100 | uint32_t mte_flags1;
|
---|
101 | uint32_t mte_impmodcnt;
|
---|
102 | uint16_t mte_sfn;
|
---|
103 | uint16_t mte_usecnt;
|
---|
104 | char mte_modname[8];
|
---|
105 | uint32_t mte_RAS; /**< added later */
|
---|
106 | uint32_t mte_modver; /**< added even later. */
|
---|
107 | } LDRMTE;
|
---|
108 | /** @name LDRMTE::mte_flag2 values
|
---|
109 | * @{ */
|
---|
110 | #define MTEFORMATMASK UINT16_C(0x0003)
|
---|
111 | #define MTEFORMATR1 UINT16_C(0x0000)
|
---|
112 | #define MTEFORMATNE UINT16_C(0x0001)
|
---|
113 | #define MTEFORMATLX UINT16_C(0x0002)
|
---|
114 | #define MTEFORMATR2 UINT16_C(0x0003)
|
---|
115 | #define MTESYSTEMDLL UINT16_C(0x0004)
|
---|
116 | #define MTELOADORATTACH UINT16_C(0x0008)
|
---|
117 | #define MTECIRCLEREF UINT16_C(0x0010)
|
---|
118 | #define MTEFREEFIXUPS UINT16_C(0x0020) /* had different meaning earlier */
|
---|
119 | #define MTEPRELOADED UINT16_C(0x0040)
|
---|
120 | #define MTEGETMTEDONE UINT16_C(0x0080)
|
---|
121 | #define MTEPACKSEGDONE UINT16_C(0x0100)
|
---|
122 | #define MTE20LIELIST UINT16_C(0x0200)
|
---|
123 | #define MTESYSPROCESSED UINT16_C(0x0400)
|
---|
124 | #define MTEPSDMOD UINT16_C(0x0800)
|
---|
125 | #define MTEDLLONEXTLST UINT16_C(0x1000)
|
---|
126 | #define MTEPDUMPCIRCREF UINT16_C(0x2000)
|
---|
127 | /** @} */
|
---|
128 | /** @name LDRMTE::mte_flag1 values
|
---|
129 | * @{ */
|
---|
130 | #define MTE1_NOAUTODS UINT32_C(0x00000000)
|
---|
131 | #define MTE1_SOLO UINT32_C(0x00000001)
|
---|
132 | #define MTE1_INSTANCEDS UINT32_C(0x00000002)
|
---|
133 | #define MTE1_INSTLIBINIT UINT32_C(0x00000004)
|
---|
134 | #define MTE1_GINISETUP UINT32_C(0x00000008)
|
---|
135 | #define MTE1_NOINTERNFIXUPS UINT32_C(0x00000010)
|
---|
136 | #define MTE1_NOEXTERNFIXUPS UINT32_C(0x00000020)
|
---|
137 | #define MTE1_CLASS_ALL UINT32_C(0x00000000)
|
---|
138 | #define MTE1_CLASS_PROGRAM UINT32_C(0x00000040)
|
---|
139 | #define MTE1_CLASS_GLOBAL UINT32_C(0x00000080)
|
---|
140 | #define MTE1_CLASS_SPECIFIC UINT32_C(0x000000c0)
|
---|
141 | #define MTE1_CLASS_MASK UINT32_C(0x000000c0)
|
---|
142 | #define MTE1_MTEPROCESSED UINT32_C(0x00000100)
|
---|
143 | #define MTE1_USED UINT32_C(0x00000200)
|
---|
144 | #define MTE1_DOSLIB UINT32_C(0x00000400)
|
---|
145 | #define MTE1_DOSMOD UINT32_C(0x00000800) /**< The OS/2 kernel (DOSCALLS).*/
|
---|
146 | #define MTE1_MEDIAFIXED UINT32_C(0x00001000)
|
---|
147 | #define MTE1_LDRINVALID UINT32_C(0x00002000)
|
---|
148 | #define MTE1_PROGRAMMOD UINT32_C(0x00000000)
|
---|
149 | #define MTE1_DEVDRVMOD UINT32_C(0x00004000)
|
---|
150 | #define MTE1_LIBRARYMOD UINT32_C(0x00008000)
|
---|
151 | #define MTE1_VDDMOD UINT32_C(0x00010000)
|
---|
152 | #define MTE1_MVDMMOD UINT32_C(0x00020000)
|
---|
153 | #define MTE1_INGRAPH UINT32_C(0x00040000)
|
---|
154 | #define MTE1_GINIDONE UINT32_C(0x00080000)
|
---|
155 | #define MTE1_ADDRALLOCED UINT32_C(0x00100000)
|
---|
156 | #define MTE1_FSDMOD UINT32_C(0x00200000)
|
---|
157 | #define MTE1_FSHMOD UINT32_C(0x00400000)
|
---|
158 | #define MTE1_LONGNAMES UINT32_C(0x00800000)
|
---|
159 | #define MTE1_MEDIACONTIG UINT32_C(0x01000000)
|
---|
160 | #define MTE1_MEDIA16M UINT32_C(0x02000000)
|
---|
161 | #define MTE1_SWAPONLOAD UINT32_C(0x04000000)
|
---|
162 | #define MTE1_PORTHOLE UINT32_C(0x08000000)
|
---|
163 | #define MTE1_MODPROT UINT32_C(0x10000000)
|
---|
164 | #define MTE1_NEWMOD UINT32_C(0x20000000)
|
---|
165 | #define MTE1_DLLTERM UINT32_C(0x40000000)
|
---|
166 | #define MTE1_SYMLOADED UINT32_C(0x80000000)
|
---|
167 | /** @} */
|
---|
168 |
|
---|
169 |
|
---|
170 | /**
|
---|
171 | * 32-bit OS/2 swappable module table entry.
|
---|
172 | */
|
---|
173 | typedef struct LDRSMTE
|
---|
174 | {
|
---|
175 | uint32_t smte_mpages; /**< 0x00: module page count. */
|
---|
176 | uint32_t smte_startobj; /**< 0x04: Entrypoint segment number. */
|
---|
177 | uint32_t smte_eip; /**< 0x08: Entrypoint offset value. */
|
---|
178 | uint32_t smte_stackobj; /**< 0x0c: Stack segment number. */
|
---|
179 | uint32_t smte_esp; /**< 0x10: Stack offset value*/
|
---|
180 | uint32_t smte_pageshift; /**< 0x14: Page shift value. */
|
---|
181 | uint32_t smte_fixupsize; /**< 0x18: Size of the fixup section. */
|
---|
182 | uint32_t smte_objtab; /**< 0x1c: Pointer to LDROTE array. */
|
---|
183 | uint32_t smte_objcnt; /**< 0x20: Number of segments. */
|
---|
184 | uint32_t smte_objmap; /**< 0x20: Address of the object page map. */
|
---|
185 | uint32_t smte_itermap; /**< 0x20: File offset of the iterated data map*/
|
---|
186 | uint32_t smte_rsrctab; /**< 0x20: Pointer to resource table? */
|
---|
187 | uint32_t smte_rsrccnt; /**< 0x30: Number of resource table entries. */
|
---|
188 | uint32_t smte_restab; /**< 0x30: Pointer to the resident name table. */
|
---|
189 | uint32_t smte_enttab; /**< 0x30: Possibly entry point table address, if not file offset. */
|
---|
190 | uint32_t smte_fpagetab; /**< 0x30 */
|
---|
191 | uint32_t smte_frectab; /**< 0x40 */
|
---|
192 | uint32_t smte_impmod; /**< 0x44 */
|
---|
193 | uint32_t smte_impproc; /**< 0x48 */
|
---|
194 | uint32_t smte_datapage; /**< 0x4c */
|
---|
195 | uint32_t smte_nrestab; /**< 0x50 */
|
---|
196 | uint32_t smte_cbnrestab; /**< 0x54 */
|
---|
197 | uint32_t smte_autods; /**< 0x58 */
|
---|
198 | uint32_t smte_debuginfo; /**< 0x5c */
|
---|
199 | uint32_t smte_debuglen; /**< 0x60 */
|
---|
200 | uint32_t smte_heapsize; /**< 0x64 */
|
---|
201 | uint32_t smte_path; /**< 0x68 Address of full name string. */
|
---|
202 | uint16_t smte_semcount; /**< 0x6c */
|
---|
203 | uint16_t smte_semowner; /**< 0x6e */
|
---|
204 | uint32_t smte_pfilecache; /**< 0x70: Address of cached data if replace-module is used. */
|
---|
205 | uint32_t smte_stacksize; /**< 0x74: Stack size for .exe thread 1. */
|
---|
206 | uint16_t smte_alignshift; /**< 0x78: */
|
---|
207 | uint16_t smte_NEexpver; /**< 0x7a: */
|
---|
208 | uint16_t smte_pathlen; /**< 0x7c: Length of smte_path */
|
---|
209 | uint16_t smte_NEexetype; /**< 0x7e: */
|
---|
210 | uint16_t smte_csegpack; /**< 0x80: */
|
---|
211 | uint8_t smte_major_os; /**< 0x82: added later to lie about OS version */
|
---|
212 | uint8_t smte_minor_os; /**< 0x83: added later to lie about OS version */
|
---|
213 | } LDRSMTE;
|
---|
214 | AssertCompileSize(LDRSMTE, 0x84);
|
---|
215 |
|
---|
216 | typedef struct LDROTE
|
---|
217 | {
|
---|
218 | uint32_t ote_size;
|
---|
219 | uint32_t ote_base;
|
---|
220 | uint32_t ote_flags;
|
---|
221 | uint32_t ote_pagemap;
|
---|
222 | uint32_t ote_mapsize;
|
---|
223 | union
|
---|
224 | {
|
---|
225 | uint32_t ote_vddaddr;
|
---|
226 | uint32_t ote_krnaddr;
|
---|
227 | struct
|
---|
228 | {
|
---|
229 | uint16_t ote_selector;
|
---|
230 | uint16_t ote_handle;
|
---|
231 | } s;
|
---|
232 | };
|
---|
233 | } LDROTE;
|
---|
234 | AssertCompileSize(LDROTE, 24);
|
---|
235 |
|
---|
236 |
|
---|
237 | /**
|
---|
238 | * 32-bit system anchor block segment header.
|
---|
239 | */
|
---|
240 | typedef struct SAS
|
---|
241 | {
|
---|
242 | uint8_t SAS_signature[4];
|
---|
243 | uint16_t SAS_tables_data; /**< Offset to SASTABLES. */
|
---|
244 | uint16_t SAS_flat_sel; /**< 32-bit kernel DS (flat). */
|
---|
245 | uint16_t SAS_config_data; /**< Offset to SASCONFIG. */
|
---|
246 | uint16_t SAS_dd_data; /**< Offset to SASDD. */
|
---|
247 | uint16_t SAS_vm_data; /**< Offset to SASVM. */
|
---|
248 | uint16_t SAS_task_data; /**< Offset to SASTASK. */
|
---|
249 | uint16_t SAS_RAS_data; /**< Offset to SASRAS. */
|
---|
250 | uint16_t SAS_file_data; /**< Offset to SASFILE. */
|
---|
251 | uint16_t SAS_info_data; /**< Offset to SASINFO. */
|
---|
252 | uint16_t SAS_mp_data; /**< Offset to SASMP. SMP only. */
|
---|
253 | } SAS;
|
---|
254 | #define SAS_SIGNATURE "SAS "
|
---|
255 |
|
---|
256 | typedef struct SASTABLES
|
---|
257 | {
|
---|
258 | uint16_t SAS_tbl_GDT;
|
---|
259 | uint16_t SAS_tbl_LDT;
|
---|
260 | uint16_t SAS_tbl_IDT;
|
---|
261 | uint16_t SAS_tbl_GDTPOOL;
|
---|
262 | } SASTABLES;
|
---|
263 |
|
---|
264 | typedef struct SASCONFIG
|
---|
265 | {
|
---|
266 | uint16_t SAS_config_table;
|
---|
267 | } SASCONFIG;
|
---|
268 |
|
---|
269 | typedef struct SASDD
|
---|
270 | {
|
---|
271 | uint16_t SAS_dd_bimodal_chain;
|
---|
272 | uint16_t SAS_dd_real_chain;
|
---|
273 | uint16_t SAS_dd_DPB_segment;
|
---|
274 | uint16_t SAS_dd_CDA_anchor_p;
|
---|
275 | uint16_t SAS_dd_CDA_anchor_r;
|
---|
276 | uint16_t SAS_dd_FSC;
|
---|
277 | } SASDD;
|
---|
278 |
|
---|
279 | typedef struct SASVM
|
---|
280 | {
|
---|
281 | uint32_t SAS_vm_arena;
|
---|
282 | uint32_t SAS_vm_object;
|
---|
283 | uint32_t SAS_vm_context;
|
---|
284 | uint32_t SAS_vm_krnl_mte; /**< Flat address of kernel MTE. */
|
---|
285 | uint32_t SAS_vm_glbl_mte; /**< Flat address of global MTE list head pointer variable. */
|
---|
286 | uint32_t SAS_vm_pft;
|
---|
287 | uint32_t SAS_vm_prt;
|
---|
288 | uint32_t SAS_vm_swap;
|
---|
289 | uint32_t SAS_vm_idle_head;
|
---|
290 | uint32_t SAS_vm_free_head;
|
---|
291 | uint32_t SAS_vm_heap_info;
|
---|
292 | uint32_t SAS_vm_all_mte; /**< Flat address of global MTE list head pointer variable. */
|
---|
293 | } SASVM;
|
---|
294 |
|
---|
295 |
|
---|
296 | #pragma pack(1)
|
---|
297 | typedef struct SASTASK
|
---|
298 | {
|
---|
299 | uint16_t SAS_task_PTDA; /**< Current PTDA selector. */
|
---|
300 | uint32_t SAS_task_ptdaptrs; /**< Flat address of process tree root. */
|
---|
301 | uint32_t SAS_task_threadptrs; /**< Flat address array of thread pointer array. */
|
---|
302 | uint32_t SAS_task_tasknumber; /**< Flat address of the TaskNumber variable. */
|
---|
303 | uint32_t SAS_task_threadcount; /**< Flat address of the ThreadCount variable. */
|
---|
304 | } SASTASK;
|
---|
305 | #pragma pack()
|
---|
306 |
|
---|
307 |
|
---|
308 | #pragma pack(1)
|
---|
309 | typedef struct SASRAS
|
---|
310 | {
|
---|
311 | uint16_t SAS_RAS_STDA_p;
|
---|
312 | uint16_t SAS_RAS_STDA_r;
|
---|
313 | uint16_t SAS_RAS_event_mask;
|
---|
314 | uint32_t SAS_RAS_Perf_Buff;
|
---|
315 | } SASRAS;
|
---|
316 | #pragma pack()
|
---|
317 |
|
---|
318 | typedef struct SASFILE
|
---|
319 | {
|
---|
320 | uint32_t SAS_file_MFT; /**< Handle. */
|
---|
321 | uint16_t SAS_file_SFT; /**< Selector. */
|
---|
322 | uint16_t SAS_file_VPB; /**< Selector. */
|
---|
323 | uint16_t SAS_file_CDS; /**< Selector. */
|
---|
324 | uint16_t SAS_file_buffers; /**< Selector. */
|
---|
325 | } SASFILE;
|
---|
326 |
|
---|
327 | #pragma pack(1)
|
---|
328 | typedef struct SASINFO
|
---|
329 | {
|
---|
330 | uint16_t SAS_info_global; /**< GIS selector. */
|
---|
331 | uint32_t SAS_info_local; /**< 16:16 address of LIS for current task. */
|
---|
332 | uint32_t SAS_info_localRM;
|
---|
333 | uint16_t SAS_info_CDIB; /**< Selector. */
|
---|
334 | } SASINFO;
|
---|
335 | #pragma pack()
|
---|
336 |
|
---|
337 | typedef struct SASMP
|
---|
338 | {
|
---|
339 | uint32_t SAS_mp_PCBFirst; /**< Flat address of PCB head. */
|
---|
340 | uint32_t SAS_mp_pLockHandles; /**< Flat address of lock handles. */
|
---|
341 | uint32_t SAS_mp_cProcessors; /**< Flat address of CPU count variable. */
|
---|
342 | uint32_t SAS_mp_pIPCInfo; /**< Flat address of IPC info pointer variable. */
|
---|
343 | uint32_t SAS_mp_pIPCHistory; /**< Flat address of IPC history pointer. */
|
---|
344 | uint32_t SAS_mp_IPCHistoryIdx; /**< Flat address of IPC history index variable. */
|
---|
345 | uint32_t SAS_mp_pFirstPSA; /**< Flat address of PSA. Added later. */
|
---|
346 | uint32_t SAS_mp_pPSAPages; /**< Flat address of PSA pages. */
|
---|
347 | } SASMP;
|
---|
348 |
|
---|
349 |
|
---|
350 | typedef struct OS2GIS
|
---|
351 | {
|
---|
352 | uint32_t time;
|
---|
353 | uint32_t msecs;
|
---|
354 | uint8_t hour;
|
---|
355 | uint8_t minutes;
|
---|
356 | uint8_t seconds;
|
---|
357 | uint8_t hundredths;
|
---|
358 | int16_t timezone;
|
---|
359 | uint16_t cusecTimerInterval;
|
---|
360 | uint8_t day;
|
---|
361 | uint8_t month;
|
---|
362 | uint16_t year;
|
---|
363 | uint8_t weekday;
|
---|
364 | uint8_t uchMajorVersion;
|
---|
365 | uint8_t uchMinorVersion;
|
---|
366 | uint8_t chRevisionLetter;
|
---|
367 | uint8_t sgCurrent;
|
---|
368 | uint8_t sgMax;
|
---|
369 | uint8_t cHugeShift;
|
---|
370 | uint8_t fProtectModeOnly;
|
---|
371 | uint16_t pidForeground;
|
---|
372 | uint8_t fDynamicSched;
|
---|
373 | uint8_t csecMaxWait;
|
---|
374 | uint16_t cmsecMinSlice;
|
---|
375 | uint16_t cmsecMaxSlice;
|
---|
376 | uint16_t bootdrive;
|
---|
377 | uint8_t amecRAS[32];
|
---|
378 | uint8_t csgWindowableVioMax;
|
---|
379 | uint8_t csgPMMax;
|
---|
380 | uint16_t SIS_Syslog;
|
---|
381 | uint16_t SIS_MMIOBase;
|
---|
382 | uint16_t SIS_MMIOAddr;
|
---|
383 | uint8_t SIS_MaxVDMs;
|
---|
384 | uint8_t SIS_Reserved;
|
---|
385 | } OS2GIS;
|
---|
386 |
|
---|
387 | typedef struct OS2LIS
|
---|
388 | {
|
---|
389 | uint16_t pidCurrent;
|
---|
390 | uint16_t pidParent;
|
---|
391 | uint16_t prtyCurrent;
|
---|
392 | uint16_t tidCurrent;
|
---|
393 | uint16_t sgCurrent;
|
---|
394 | uint8_t rfProcStatus;
|
---|
395 | uint8_t bReserved1;
|
---|
396 | uint16_t fForeground;
|
---|
397 | uint8_t typeProcess;
|
---|
398 | uint8_t bReserved2;
|
---|
399 | uint16_t selEnvironment;
|
---|
400 | uint16_t offCmdLine;
|
---|
401 | uint16_t cbDataSegment;
|
---|
402 | uint16_t cbStack;
|
---|
403 | uint16_t cbHeap;
|
---|
404 | uint16_t hmod;
|
---|
405 | uint16_t selDS;
|
---|
406 | } OS2LIS;
|
---|
407 |
|
---|
408 |
|
---|
409 | /*********************************************************************************************************************************
|
---|
410 | * Defined Constants And Macros *
|
---|
411 | *********************************************************************************************************************************/
|
---|
412 | /** The 'SAS ' signature. */
|
---|
413 | #define DIG_OS2_SAS_SIG RT_MAKE_U32_FROM_U8('S','A','S',' ')
|
---|
414 |
|
---|
415 | /** OS/2Warp on little endian ASCII systems. */
|
---|
416 | #define DIG_OS2_MOD_TAG UINT64_C(0x43532f3257617270)
|
---|
417 |
|
---|
418 |
|
---|
419 | /*********************************************************************************************************************************
|
---|
420 | * Internal Functions *
|
---|
421 | *********************************************************************************************************************************/
|
---|
422 | static DECLCALLBACK(int) dbgDiggerOS2Init(PUVM pUVM, PCVMMR3VTABLE pVMM, void *pvData);
|
---|
423 |
|
---|
424 |
|
---|
425 | static int dbgDiggerOS2DisplaySelectorAndInfoEx(PDBGDIGGEROS2 pThis, PCDBGFINFOHLP pHlp, uint16_t uSel, uint32_t off,
|
---|
426 | int cchWidth, const char *pszMessage, PDBGFSELINFO pSelInfo)
|
---|
427 | {
|
---|
428 | RT_ZERO(*pSelInfo);
|
---|
429 | int rc = pThis->pVMM->pfnDBGFR3SelQueryInfo(pThis->pUVM, 0 /*idCpu*/, uSel, DBGFSELQI_FLAGS_DT_GUEST, pSelInfo);
|
---|
430 | if (RT_SUCCESS(rc))
|
---|
431 | {
|
---|
432 | if (off == UINT32_MAX)
|
---|
433 | pHlp->pfnPrintf(pHlp, "%*s: %#06x (%RGv LB %#RX64 flags=%#x)\n",
|
---|
434 | cchWidth, pszMessage, uSel, pSelInfo->GCPtrBase, pSelInfo->cbLimit, pSelInfo->fFlags);
|
---|
435 | else
|
---|
436 | pHlp->pfnPrintf(pHlp, "%*s: %04x:%04x (%RGv LB %#RX64 flags=%#x)\n",
|
---|
437 | cchWidth, pszMessage, uSel, off, pSelInfo->GCPtrBase + off, pSelInfo->cbLimit - off, pSelInfo->fFlags);
|
---|
438 | }
|
---|
439 | else if (off == UINT32_MAX)
|
---|
440 | pHlp->pfnPrintf(pHlp, "%*s: %#06x (%Rrc)\n", cchWidth, pszMessage, uSel, rc);
|
---|
441 | else
|
---|
442 | pHlp->pfnPrintf(pHlp, "%*s: %04x:%04x (%Rrc)\n", cchWidth, pszMessage, uSel, off, rc);
|
---|
443 | return rc;
|
---|
444 | }
|
---|
445 |
|
---|
446 | DECLINLINE(int) dbgDiggerOS2DisplaySelectorAndInfo(PDBGDIGGEROS2 pThis, PCDBGFINFOHLP pHlp, uint16_t uSel, uint32_t off,
|
---|
447 | int cchWidth, const char *pszMessage)
|
---|
448 | {
|
---|
449 | DBGFSELINFO SelInfo;
|
---|
450 | return dbgDiggerOS2DisplaySelectorAndInfoEx(pThis, pHlp, uSel, off, cchWidth, pszMessage, &SelInfo);
|
---|
451 | }
|
---|
452 |
|
---|
453 |
|
---|
454 | /**
|
---|
455 | * @callback_method_impl{FNDBGFHANDLEREXT,
|
---|
456 | * Display the OS/2 system anchor segment}
|
---|
457 | */
|
---|
458 | static DECLCALLBACK(void) dbgDiggerOS2InfoSas(void *pvUser, PCDBGFINFOHLP pHlp, const char *pszArgs)
|
---|
459 | {
|
---|
460 | RT_NOREF(pszArgs);
|
---|
461 | PDBGDIGGEROS2 const pThis = (PDBGDIGGEROS2)pvUser;
|
---|
462 | PUVM const pUVM = pThis->pUVM;
|
---|
463 | PCVMMR3VTABLE const pVMM = pThis->pVMM;
|
---|
464 |
|
---|
465 | DBGFSELINFO SelInfo;
|
---|
466 | int rc = pVMM->pfnDBGFR3SelQueryInfo(pUVM, 0 /*idCpu*/, 0x70, DBGFSELQI_FLAGS_DT_GUEST, &SelInfo);
|
---|
467 | if (RT_FAILURE(rc))
|
---|
468 | {
|
---|
469 | pHlp->pfnPrintf(pHlp, "DBGFR3SelQueryInfo failed on selector 0x70: %Rrc\n", rc);
|
---|
470 | return;
|
---|
471 | }
|
---|
472 | pHlp->pfnPrintf(pHlp, "Selector 0x70: %RGv LB %#RX64 (flags %#x)\n",
|
---|
473 | SelInfo.GCPtrBase, (uint64_t)SelInfo.cbLimit, SelInfo.fFlags);
|
---|
474 |
|
---|
475 | /*
|
---|
476 | * The SAS header.
|
---|
477 | */
|
---|
478 | union
|
---|
479 | {
|
---|
480 | SAS Sas;
|
---|
481 | uint16_t au16Sas[sizeof(SAS) / sizeof(uint16_t)];
|
---|
482 | };
|
---|
483 | DBGFADDRESS Addr;
|
---|
484 | rc = pVMM->pfnDBGFR3MemRead(pUVM, 0 /*idCpu*/, pVMM->pfnDBGFR3AddrFromFlat(pUVM, &Addr, SelInfo.GCPtrBase),
|
---|
485 | &Sas, sizeof(Sas));
|
---|
486 | if (RT_FAILURE(rc))
|
---|
487 | {
|
---|
488 | pHlp->pfnPrintf(pHlp, "Failed to read SAS header: %Rrc\n", rc);
|
---|
489 | return;
|
---|
490 | }
|
---|
491 | if (memcmp(&Sas.SAS_signature[0], SAS_SIGNATURE, sizeof(Sas.SAS_signature)) != 0)
|
---|
492 | {
|
---|
493 | pHlp->pfnPrintf(pHlp, "Invalid SAS signature: %#x %#x %#x %#x (expected %#x %#x %#x %#x)\n",
|
---|
494 | Sas.SAS_signature[0], Sas.SAS_signature[1], Sas.SAS_signature[2], Sas.SAS_signature[3],
|
---|
495 | SAS_SIGNATURE[0], SAS_SIGNATURE[1], SAS_SIGNATURE[2], SAS_SIGNATURE[3]);
|
---|
496 | return;
|
---|
497 | }
|
---|
498 | dbgDiggerOS2DisplaySelectorAndInfo(pThis, pHlp, Sas.SAS_flat_sel, UINT32_MAX, 15, "Flat kernel DS");
|
---|
499 | pHlp->pfnPrintf(pHlp, "SAS_tables_data: %#06x (%#RGv)\n", Sas.SAS_tables_data, SelInfo.GCPtrBase + Sas.SAS_tables_data);
|
---|
500 | pHlp->pfnPrintf(pHlp, "SAS_config_data: %#06x (%#RGv)\n", Sas.SAS_config_data, SelInfo.GCPtrBase + Sas.SAS_config_data);
|
---|
501 | pHlp->pfnPrintf(pHlp, " SAS_dd_data: %#06x (%#RGv)\n", Sas.SAS_dd_data, SelInfo.GCPtrBase + Sas.SAS_dd_data);
|
---|
502 | pHlp->pfnPrintf(pHlp, " SAS_vm_data: %#06x (%#RGv)\n", Sas.SAS_vm_data, SelInfo.GCPtrBase + Sas.SAS_vm_data);
|
---|
503 | pHlp->pfnPrintf(pHlp, " SAS_task_data: %#06x (%#RGv)\n", Sas.SAS_task_data, SelInfo.GCPtrBase + Sas.SAS_task_data);
|
---|
504 | pHlp->pfnPrintf(pHlp, " SAS_RAS_data: %#06x (%#RGv)\n", Sas.SAS_RAS_data, SelInfo.GCPtrBase + Sas.SAS_RAS_data);
|
---|
505 | pHlp->pfnPrintf(pHlp, " SAS_file_data: %#06x (%#RGv)\n", Sas.SAS_file_data, SelInfo.GCPtrBase + Sas.SAS_file_data);
|
---|
506 | pHlp->pfnPrintf(pHlp, " SAS_info_data: %#06x (%#RGv)\n", Sas.SAS_info_data, SelInfo.GCPtrBase + Sas.SAS_info_data);
|
---|
507 | bool fIncludeMP = true;
|
---|
508 | if (Sas.SAS_mp_data < sizeof(Sas))
|
---|
509 | fIncludeMP = false;
|
---|
510 | else
|
---|
511 | for (unsigned i = 2; i < RT_ELEMENTS(au16Sas) - 1; i++)
|
---|
512 | if (au16Sas[i] < sizeof(SAS))
|
---|
513 | {
|
---|
514 | fIncludeMP = false;
|
---|
515 | break;
|
---|
516 | }
|
---|
517 | if (fIncludeMP)
|
---|
518 | pHlp->pfnPrintf(pHlp, " SAS_mp_data: %#06x (%#RGv)\n", Sas.SAS_mp_data, SelInfo.GCPtrBase + Sas.SAS_mp_data);
|
---|
519 |
|
---|
520 | /* shared databuf */
|
---|
521 | union
|
---|
522 | {
|
---|
523 | SASINFO Info;
|
---|
524 | } u;
|
---|
525 |
|
---|
526 | /*
|
---|
527 | * Info data.
|
---|
528 | */
|
---|
529 | rc = pVMM->pfnDBGFR3MemRead(pUVM, 0 /*idCpu*/,
|
---|
530 | pVMM->pfnDBGFR3AddrFromFlat(pUVM, &Addr, SelInfo.GCPtrBase + Sas.SAS_info_data),
|
---|
531 | &u.Info, sizeof(u.Info));
|
---|
532 | if (RT_SUCCESS(rc))
|
---|
533 | {
|
---|
534 | pHlp->pfnPrintf(pHlp, "SASINFO:\n");
|
---|
535 | dbgDiggerOS2DisplaySelectorAndInfo(pThis, pHlp, u.Info.SAS_info_global, UINT32_MAX, 28, "Global info segment");
|
---|
536 | pHlp->pfnPrintf(pHlp, "%28s: %#010x\n", "Local info segment", u.Info.SAS_info_local);
|
---|
537 | pHlp->pfnPrintf(pHlp, "%28s: %#010x\n", "Local info segment (RM)", u.Info.SAS_info_localRM);
|
---|
538 | dbgDiggerOS2DisplaySelectorAndInfo(pThis, pHlp, u.Info.SAS_info_CDIB, UINT32_MAX, 28, "SAS_info_CDIB");
|
---|
539 | }
|
---|
540 | else
|
---|
541 | pHlp->pfnPrintf(pHlp, "Failed to read SAS info data: %Rrc\n", rc);
|
---|
542 |
|
---|
543 | /** @todo more */
|
---|
544 | }
|
---|
545 |
|
---|
546 |
|
---|
547 | /**
|
---|
548 | * @callback_method_impl{FNDBGFHANDLEREXT,
|
---|
549 | * Display the OS/2 global info segment}
|
---|
550 | */
|
---|
551 | static DECLCALLBACK(void) dbgDiggerOS2InfoGis(void *pvUser, PCDBGFINFOHLP pHlp, const char *pszArgs)
|
---|
552 | {
|
---|
553 | RT_NOREF(pszArgs);
|
---|
554 | PDBGDIGGEROS2 const pThis = (PDBGDIGGEROS2)pvUser;
|
---|
555 | PUVM const pUVM = pThis->pUVM;
|
---|
556 | PCVMMR3VTABLE const pVMM = pThis->pVMM;
|
---|
557 |
|
---|
558 | DBGFSELINFO SelInfo;
|
---|
559 | int rc = dbgDiggerOS2DisplaySelectorAndInfoEx(pThis, pHlp, pThis->selGis, UINT32_MAX, 0, "Global info segment", &SelInfo);
|
---|
560 | if (RT_FAILURE(rc))
|
---|
561 | return;
|
---|
562 |
|
---|
563 | /*
|
---|
564 | * Read the GIS.
|
---|
565 | */
|
---|
566 | DBGFADDRESS Addr;
|
---|
567 | OS2GIS Gis;
|
---|
568 | RT_ZERO(Gis);
|
---|
569 | rc = pVMM->pfnDBGFR3MemRead(pUVM, 0 /*idCpu*/, pVMM->pfnDBGFR3AddrFromFlat(pUVM, &Addr, SelInfo.GCPtrBase), &Gis,
|
---|
570 | RT_MIN(sizeof(Gis), SelInfo.cbLimit + 1));
|
---|
571 | if (RT_FAILURE(rc))
|
---|
572 | {
|
---|
573 | pHlp->pfnPrintf(pHlp, "Failed to read GIS: %Rrc\n", rc);
|
---|
574 | return;
|
---|
575 | }
|
---|
576 | pHlp->pfnPrintf(pHlp, " time: %#010x\n", Gis.time);
|
---|
577 | pHlp->pfnPrintf(pHlp, " msecs: %#010x\n", Gis.msecs);
|
---|
578 | pHlp->pfnPrintf(pHlp, " timestamp: %04u-%02u-%02u %02u:%02u:%02u.%02u\n",
|
---|
579 | Gis.year, Gis.month, Gis.day, Gis.hour, Gis.minutes, Gis.seconds, Gis.hundredths);
|
---|
580 | pHlp->pfnPrintf(pHlp, " timezone: %+2d (min delta)\n", (int)Gis.timezone);
|
---|
581 | pHlp->pfnPrintf(pHlp, " weekday: %u\n", Gis.weekday);
|
---|
582 | pHlp->pfnPrintf(pHlp, " cusecTimerInterval: %u\n", Gis.cusecTimerInterval);
|
---|
583 | pHlp->pfnPrintf(pHlp, " version: %u.%u\n", Gis.uchMajorVersion, Gis.uchMinorVersion);
|
---|
584 | pHlp->pfnPrintf(pHlp, " revision: %#04x (%c)\n", Gis.chRevisionLetter, Gis.chRevisionLetter);
|
---|
585 | pHlp->pfnPrintf(pHlp, " current screen grp: %#04x (%u)\n", Gis.sgCurrent, Gis.sgCurrent);
|
---|
586 | pHlp->pfnPrintf(pHlp, " max screen groups: %#04x (%u)\n", Gis.sgMax, Gis.sgMax);
|
---|
587 | pHlp->pfnPrintf(pHlp, "csgWindowableVioMax: %#x (%u)\n", Gis.csgWindowableVioMax, Gis.csgWindowableVioMax);
|
---|
588 | pHlp->pfnPrintf(pHlp, " csgPMMax: %#x (%u)\n", Gis.csgPMMax, Gis.csgPMMax);
|
---|
589 | pHlp->pfnPrintf(pHlp, " cHugeShift: %#04x\n", Gis.cHugeShift);
|
---|
590 | pHlp->pfnPrintf(pHlp, " fProtectModeOnly: %d\n", Gis.fProtectModeOnly);
|
---|
591 | pHlp->pfnPrintf(pHlp, " pidForeground: %#04x (%u)\n", Gis.pidForeground, Gis.pidForeground);
|
---|
592 | pHlp->pfnPrintf(pHlp, " fDynamicSched: %u\n", Gis.fDynamicSched);
|
---|
593 | pHlp->pfnPrintf(pHlp, " csecMaxWait: %u\n", Gis.csecMaxWait);
|
---|
594 | pHlp->pfnPrintf(pHlp, " cmsecMinSlice: %u\n", Gis.cmsecMinSlice);
|
---|
595 | pHlp->pfnPrintf(pHlp, " cmsecMaxSlice: %u\n", Gis.cmsecMaxSlice);
|
---|
596 | pHlp->pfnPrintf(pHlp, " bootdrive: %#x\n", Gis.bootdrive);
|
---|
597 | pHlp->pfnPrintf(pHlp, " amecRAS: %.32Rhxs\n", &Gis.amecRAS[0]);
|
---|
598 | pHlp->pfnPrintf(pHlp, " SIS_Syslog: %#06x (%u)\n", Gis.SIS_Syslog, Gis.SIS_Syslog);
|
---|
599 | pHlp->pfnPrintf(pHlp, " SIS_MMIOBase: %#06x\n", Gis.SIS_MMIOBase);
|
---|
600 | pHlp->pfnPrintf(pHlp, " SIS_MMIOAddr: %#06x\n", Gis.SIS_MMIOAddr);
|
---|
601 | pHlp->pfnPrintf(pHlp, " SIS_MaxVDMs: %#04x (%u)\n", Gis.SIS_MaxVDMs, Gis.SIS_MaxVDMs);
|
---|
602 | pHlp->pfnPrintf(pHlp, " SIS_Reserved: %#04x\n", Gis.SIS_Reserved);
|
---|
603 | }
|
---|
604 |
|
---|
605 |
|
---|
606 | /**
|
---|
607 | * @callback_method_impl{FNDBGFHANDLEREXT,
|
---|
608 | * Display the OS/2 local info segment}
|
---|
609 | */
|
---|
610 | static DECLCALLBACK(void) dbgDiggerOS2InfoLis(void *pvUser, PCDBGFINFOHLP pHlp, const char *pszArgs)
|
---|
611 | {
|
---|
612 | RT_NOREF(pszArgs);
|
---|
613 | PDBGDIGGEROS2 const pThis = (PDBGDIGGEROS2)pvUser;
|
---|
614 | PUVM const pUVM = pThis->pUVM;
|
---|
615 | PCVMMR3VTABLE const pVMM = pThis->pVMM;
|
---|
616 |
|
---|
617 | DBGFSELINFO SelInfo;
|
---|
618 | int rc = dbgDiggerOS2DisplaySelectorAndInfoEx(pThis, pHlp, pThis->Lis.sel, pThis->Lis.off, 19, "Local info segment", &SelInfo);
|
---|
619 | if (RT_FAILURE(rc))
|
---|
620 | return;
|
---|
621 |
|
---|
622 | /*
|
---|
623 | * Read the LIS.
|
---|
624 | */
|
---|
625 | DBGFADDRESS Addr;
|
---|
626 | OS2LIS Lis;
|
---|
627 | RT_ZERO(Lis);
|
---|
628 | rc = pVMM->pfnDBGFR3MemRead(pUVM, 0 /*idCpu*/, pVMM->pfnDBGFR3AddrFromFlat(pUVM, &Addr, SelInfo.GCPtrBase + pThis->Lis.off),
|
---|
629 | &Lis, sizeof(Lis));
|
---|
630 | if (RT_FAILURE(rc))
|
---|
631 | {
|
---|
632 | pHlp->pfnPrintf(pHlp, "Failed to read LIS: %Rrc\n", rc);
|
---|
633 | return;
|
---|
634 | }
|
---|
635 | pHlp->pfnPrintf(pHlp, " pidCurrent: %#06x (%u)\n", Lis.pidCurrent, Lis.pidCurrent);
|
---|
636 | pHlp->pfnPrintf(pHlp, " pidParent: %#06x (%u)\n", Lis.pidParent, Lis.pidParent);
|
---|
637 | pHlp->pfnPrintf(pHlp, " prtyCurrent: %#06x (%u)\n", Lis.prtyCurrent, Lis.prtyCurrent);
|
---|
638 | pHlp->pfnPrintf(pHlp, " tidCurrent: %#06x (%u)\n", Lis.tidCurrent, Lis.tidCurrent);
|
---|
639 | pHlp->pfnPrintf(pHlp, " sgCurrent: %#06x (%u)\n", Lis.sgCurrent, Lis.sgCurrent);
|
---|
640 | pHlp->pfnPrintf(pHlp, " rfProcStatus: %#04x\n", Lis.rfProcStatus);
|
---|
641 | if (Lis.bReserved1)
|
---|
642 | pHlp->pfnPrintf(pHlp, " bReserved1: %#04x\n", Lis.bReserved1);
|
---|
643 | pHlp->pfnPrintf(pHlp, " fForeground: %#04x (%u)\n", Lis.fForeground, Lis.fForeground);
|
---|
644 | pHlp->pfnPrintf(pHlp, " typeProcess: %#04x (%u)\n", Lis.typeProcess, Lis.typeProcess);
|
---|
645 | if (Lis.bReserved2)
|
---|
646 | pHlp->pfnPrintf(pHlp, " bReserved2: %#04x\n", Lis.bReserved2);
|
---|
647 | dbgDiggerOS2DisplaySelectorAndInfo(pThis, pHlp, Lis.selEnvironment, UINT32_MAX, 19, "selEnvironment");
|
---|
648 | pHlp->pfnPrintf(pHlp, " offCmdLine: %#06x (%u)\n", Lis.offCmdLine, Lis.offCmdLine);
|
---|
649 | pHlp->pfnPrintf(pHlp, " cbDataSegment: %#06x (%u)\n", Lis.cbDataSegment, Lis.cbDataSegment);
|
---|
650 | pHlp->pfnPrintf(pHlp, " cbStack: %#06x (%u)\n", Lis.cbStack, Lis.cbStack);
|
---|
651 | pHlp->pfnPrintf(pHlp, " cbHeap: %#06x (%u)\n", Lis.cbHeap, Lis.cbHeap);
|
---|
652 | pHlp->pfnPrintf(pHlp, " hmod: %#06x\n", Lis.hmod); /** @todo look up the name*/
|
---|
653 | dbgDiggerOS2DisplaySelectorAndInfo(pThis, pHlp, Lis.selDS, UINT32_MAX, 19, "selDS");
|
---|
654 | }
|
---|
655 |
|
---|
656 |
|
---|
657 | /**
|
---|
658 | * @callback_method_impl{FNDBGFHANDLEREXT,
|
---|
659 | * Display the OS/2 panic message}
|
---|
660 | */
|
---|
661 | static DECLCALLBACK(void) dbgDiggerOS2InfoPanic(void *pvUser, PCDBGFINFOHLP pHlp, const char *pszArgs)
|
---|
662 | {
|
---|
663 | RT_NOREF(pszArgs);
|
---|
664 | PDBGDIGGEROS2 const pThis = (PDBGDIGGEROS2)pvUser;
|
---|
665 | PUVM const pUVM = pThis->pUVM;
|
---|
666 | PCVMMR3VTABLE const pVMM = pThis->pVMM;
|
---|
667 |
|
---|
668 | DBGFADDRESS HitAddr;
|
---|
669 | int rc = pVMM->pfnDBGFR3MemScan(pUVM, 0 /*idCpu*/, pVMM->pfnDBGFR3AddrFromFlat(pUVM, &HitAddr, pThis->uKernelAddr),
|
---|
670 | pThis->cbKernel, 1, RT_STR_TUPLE("Exception in module:"), &HitAddr);
|
---|
671 | if (RT_FAILURE(rc))
|
---|
672 | rc = pVMM->pfnDBGFR3MemScan(pUVM, 0 /*idCpu&*/, pVMM->pfnDBGFR3AddrFromFlat(pUVM, &HitAddr, pThis->uKernelAddr),
|
---|
673 | pThis->cbKernel, 1, RT_STR_TUPLE("Exception in device driver:"), &HitAddr);
|
---|
674 | /** @todo support pre-2001 kernels w/o the module/drivce name. */
|
---|
675 | if (RT_SUCCESS(rc))
|
---|
676 | {
|
---|
677 | char szMsg[728 + 1];
|
---|
678 | RT_ZERO(szMsg);
|
---|
679 | rc = pVMM->pfnDBGFR3MemRead(pUVM, 0, &HitAddr, szMsg, sizeof(szMsg) - 1);
|
---|
680 | if (szMsg[0] != '\0')
|
---|
681 | {
|
---|
682 | RTStrPurgeEncoding(szMsg);
|
---|
683 | char *psz = szMsg;
|
---|
684 | while (*psz != '\0')
|
---|
685 | {
|
---|
686 | char *pszEol = strchr(psz, '\r');
|
---|
687 | if (pszEol)
|
---|
688 | *pszEol = '\0';
|
---|
689 | pHlp->pfnPrintf(pHlp, "%s\n", psz);
|
---|
690 | if (!pszEol)
|
---|
691 | break;
|
---|
692 | psz = ++pszEol;
|
---|
693 | if (*psz == '\n')
|
---|
694 | psz++;
|
---|
695 | }
|
---|
696 | }
|
---|
697 | else
|
---|
698 | pHlp->pfnPrintf(pHlp, "DBGFR3MemRead -> %Rrc\n", rc);
|
---|
699 | }
|
---|
700 | else
|
---|
701 | pHlp->pfnPrintf(pHlp, "Unable to locate OS/2 panic message. (%Rrc)\n", rc);
|
---|
702 | }
|
---|
703 |
|
---|
704 |
|
---|
705 |
|
---|
706 | /**
|
---|
707 | * @copydoc DBGFOSREG::pfnStackUnwindAssist
|
---|
708 | */
|
---|
709 | static DECLCALLBACK(int) dbgDiggerOS2StackUnwindAssist(PUVM pUVM, PCVMMR3VTABLE pVMM, void *pvData, VMCPUID idCpu,
|
---|
710 | PDBGFSTACKFRAME pFrame, PRTDBGUNWINDSTATE pState, PCCPUMCTX pInitialCtx,
|
---|
711 | RTDBGAS hAs, uint64_t *puScratch)
|
---|
712 | {
|
---|
713 | RT_NOREF(pUVM, pVMM, pvData, idCpu, pFrame, pState, pInitialCtx, hAs, puScratch);
|
---|
714 | return VINF_SUCCESS;
|
---|
715 | }
|
---|
716 |
|
---|
717 |
|
---|
718 | /**
|
---|
719 | * @copydoc DBGFOSREG::pfnQueryInterface
|
---|
720 | */
|
---|
721 | static DECLCALLBACK(void *) dbgDiggerOS2QueryInterface(PUVM pUVM, PCVMMR3VTABLE pVMM, void *pvData, DBGFOSINTERFACE enmIf)
|
---|
722 | {
|
---|
723 | RT_NOREF(pUVM, pVMM, pvData, enmIf);
|
---|
724 | return NULL;
|
---|
725 | }
|
---|
726 |
|
---|
727 |
|
---|
728 | /**
|
---|
729 | * @copydoc DBGFOSREG::pfnQueryVersion
|
---|
730 | */
|
---|
731 | static DECLCALLBACK(int) dbgDiggerOS2QueryVersion(PUVM pUVM, PCVMMR3VTABLE pVMM, void *pvData,
|
---|
732 | char *pszVersion, size_t cchVersion)
|
---|
733 | {
|
---|
734 | PDBGDIGGEROS2 pThis = (PDBGDIGGEROS2)pvData;
|
---|
735 | RT_NOREF(pUVM, pVMM);
|
---|
736 | Assert(pThis->fValid);
|
---|
737 |
|
---|
738 | char *achOS2ProductType[32];
|
---|
739 | char *pszOS2ProductType = (char *)achOS2ProductType;
|
---|
740 |
|
---|
741 | if (pThis->OS2MajorVersion == 10)
|
---|
742 | {
|
---|
743 | RTStrPrintf(pszOS2ProductType, sizeof(achOS2ProductType), "OS/2 1.%02d", pThis->OS2MinorVersion);
|
---|
744 | pThis->enmVer = DBGDIGGEROS2VER_1_x;
|
---|
745 | }
|
---|
746 | else if (pThis->OS2MajorVersion == 20)
|
---|
747 | {
|
---|
748 | if (pThis->OS2MinorVersion < 30)
|
---|
749 | {
|
---|
750 | RTStrPrintf(pszOS2ProductType, sizeof(achOS2ProductType), "OS/2 2.%02d", pThis->OS2MinorVersion);
|
---|
751 | pThis->enmVer = DBGDIGGEROS2VER_2_x;
|
---|
752 | }
|
---|
753 | else if (pThis->OS2MinorVersion < 40)
|
---|
754 | {
|
---|
755 | RTStrPrintf(pszOS2ProductType, sizeof(achOS2ProductType), "OS/2 Warp");
|
---|
756 | pThis->enmVer = DBGDIGGEROS2VER_3_0;
|
---|
757 | }
|
---|
758 | else if (pThis->OS2MinorVersion == 40)
|
---|
759 | {
|
---|
760 | RTStrPrintf(pszOS2ProductType, sizeof(achOS2ProductType), "OS/2 Warp 4");
|
---|
761 | pThis->enmVer = DBGDIGGEROS2VER_4_0;
|
---|
762 | }
|
---|
763 | else
|
---|
764 | {
|
---|
765 | RTStrPrintf(pszOS2ProductType, sizeof(achOS2ProductType), "OS/2 Warp %d.%d",
|
---|
766 | pThis->OS2MinorVersion / 10, pThis->OS2MinorVersion % 10);
|
---|
767 | pThis->enmVer = DBGDIGGEROS2VER_4_5;
|
---|
768 | }
|
---|
769 | }
|
---|
770 | RTStrPrintf(pszVersion, cchVersion, "%u.%u (%s)", pThis->OS2MajorVersion, pThis->OS2MinorVersion, pszOS2ProductType);
|
---|
771 | return VINF_SUCCESS;
|
---|
772 | }
|
---|
773 |
|
---|
774 |
|
---|
775 | /**
|
---|
776 | * @copydoc DBGFOSREG::pfnTerm
|
---|
777 | */
|
---|
778 | static DECLCALLBACK(void) dbgDiggerOS2Term(PUVM pUVM, PCVMMR3VTABLE pVMM, void *pvData)
|
---|
779 | {
|
---|
780 | PDBGDIGGEROS2 pThis = (PDBGDIGGEROS2)pvData;
|
---|
781 | Assert(pThis->fValid);
|
---|
782 |
|
---|
783 | pVMM->pfnDBGFR3InfoDeregisterExternal(pUVM, "sas");
|
---|
784 | pVMM->pfnDBGFR3InfoDeregisterExternal(pUVM, "gis");
|
---|
785 | pVMM->pfnDBGFR3InfoDeregisterExternal(pUVM, "lis");
|
---|
786 | pVMM->pfnDBGFR3InfoDeregisterExternal(pUVM, "panic");
|
---|
787 |
|
---|
788 | pThis->fValid = false;
|
---|
789 | }
|
---|
790 |
|
---|
791 |
|
---|
792 | /**
|
---|
793 | * @copydoc DBGFOSREG::pfnRefresh
|
---|
794 | */
|
---|
795 | static DECLCALLBACK(int) dbgDiggerOS2Refresh(PUVM pUVM, PCVMMR3VTABLE pVMM, void *pvData)
|
---|
796 | {
|
---|
797 | PDBGDIGGEROS2 pThis = (PDBGDIGGEROS2)pvData;
|
---|
798 | NOREF(pThis);
|
---|
799 | Assert(pThis->fValid);
|
---|
800 |
|
---|
801 | /*
|
---|
802 | * For now we'll flush and reload everything.
|
---|
803 | */
|
---|
804 | RTDBGAS hDbgAs = pVMM->pfnDBGFR3AsResolveAndRetain(pUVM, DBGF_AS_KERNEL);
|
---|
805 | if (hDbgAs != NIL_RTDBGAS)
|
---|
806 | {
|
---|
807 | uint32_t iMod = RTDbgAsModuleCount(hDbgAs);
|
---|
808 | while (iMod-- > 0)
|
---|
809 | {
|
---|
810 | RTDBGMOD hMod = RTDbgAsModuleByIndex(hDbgAs, iMod);
|
---|
811 | if (hMod != NIL_RTDBGMOD)
|
---|
812 | {
|
---|
813 | if (RTDbgModGetTag(hMod) == DIG_OS2_MOD_TAG)
|
---|
814 | {
|
---|
815 | int rc = RTDbgAsModuleUnlink(hDbgAs, hMod);
|
---|
816 | AssertRC(rc);
|
---|
817 | }
|
---|
818 | RTDbgModRelease(hMod);
|
---|
819 | }
|
---|
820 | }
|
---|
821 | RTDbgAsRelease(hDbgAs);
|
---|
822 | }
|
---|
823 |
|
---|
824 | dbgDiggerOS2Term(pUVM, pVMM, pvData);
|
---|
825 | return dbgDiggerOS2Init(pUVM, pVMM, pvData);
|
---|
826 | }
|
---|
827 |
|
---|
828 |
|
---|
829 | /** Buffer shared by dbgdiggerOS2ProcessModule and dbgDiggerOS2Init.*/
|
---|
830 | typedef union DBGDIGGEROS2BUF
|
---|
831 | {
|
---|
832 | uint8_t au8[0x2000];
|
---|
833 | uint16_t au16[0x2000/2];
|
---|
834 | uint32_t au32[0x2000/4];
|
---|
835 | RTUTF16 wsz[0x2000/2];
|
---|
836 | char ach[0x2000];
|
---|
837 | LDROTE aOtes[0x2000 / sizeof(LDROTE)];
|
---|
838 | SAS sas;
|
---|
839 | SASVM sasvm;
|
---|
840 | LDRMTE mte;
|
---|
841 | LDRSMTE smte;
|
---|
842 | LDROTE ote;
|
---|
843 | } DBGDIGGEROS2BUF;
|
---|
844 |
|
---|
845 | /** Arguments dbgdiggerOS2ProcessModule passes to the module open callback. */
|
---|
846 | typedef struct
|
---|
847 | {
|
---|
848 | const char *pszModPath;
|
---|
849 | const char *pszModName;
|
---|
850 | LDRMTE const *pMte;
|
---|
851 | LDRSMTE const *pSwapMte;
|
---|
852 | } DBGDIGGEROS2OPEN;
|
---|
853 |
|
---|
854 |
|
---|
855 | /**
|
---|
856 | * @callback_method_impl{FNRTDBGCFGOPEN, Debug image/image searching callback.}
|
---|
857 | */
|
---|
858 | static DECLCALLBACK(int) dbgdiggerOs2OpenModule(RTDBGCFG hDbgCfg, const char *pszFilename, void *pvUser1, void *pvUser2)
|
---|
859 | {
|
---|
860 | DBGDIGGEROS2OPEN *pArgs = (DBGDIGGEROS2OPEN *)pvUser1;
|
---|
861 |
|
---|
862 | RTDBGMOD hDbgMod = NIL_RTDBGMOD;
|
---|
863 | int rc = RTDbgModCreateFromImage(&hDbgMod, pszFilename, pArgs->pszModName, RTLDRARCH_WHATEVER, hDbgCfg);
|
---|
864 | if (RT_SUCCESS(rc))
|
---|
865 | {
|
---|
866 | /** @todo Do some info matching before using it? */
|
---|
867 |
|
---|
868 | *(PRTDBGMOD)pvUser2 = hDbgMod;
|
---|
869 | return VINF_CALLBACK_RETURN;
|
---|
870 | }
|
---|
871 | LogRel(("DbgDiggerOs2: dbgdiggerOs2OpenModule: %Rrc - %s\n", rc, pszFilename));
|
---|
872 | return rc;
|
---|
873 | }
|
---|
874 |
|
---|
875 |
|
---|
876 | static void dbgdiggerOS2ProcessModule(PUVM pUVM, PCVMMR3VTABLE pVMM, PDBGDIGGEROS2 pThis, DBGDIGGEROS2BUF *pBuf,
|
---|
877 | const char *pszCacheSubDir, RTDBGAS hAs, RTDBGCFG hDbgCfg)
|
---|
878 | {
|
---|
879 | RT_NOREF(pThis);
|
---|
880 |
|
---|
881 | /*
|
---|
882 | * Save the MTE.
|
---|
883 | */
|
---|
884 | static const char * const s_apszMteFmts[4] = { "Reserved1", "NE", "LX", "Reserved2" };
|
---|
885 | LDRMTE const Mte = pBuf->mte;
|
---|
886 | if ((Mte.mte_flags2 & MTEFORMATMASK) != MTEFORMATLX)
|
---|
887 | {
|
---|
888 | LogRel(("DbgDiggerOs2: MTE format not implemented: %s (%d)\n",
|
---|
889 | s_apszMteFmts[(Mte.mte_flags2 & MTEFORMATMASK)], Mte.mte_flags2 & MTEFORMATMASK));
|
---|
890 | return;
|
---|
891 | }
|
---|
892 |
|
---|
893 | /*
|
---|
894 | * Don't load program modules into the global address spaces.
|
---|
895 | */
|
---|
896 | if ((Mte.mte_flags1 & MTE1_CLASS_MASK) == MTE1_CLASS_PROGRAM)
|
---|
897 | {
|
---|
898 | LogRel(("DbgDiggerOs2: Program module, skipping.\n"));
|
---|
899 | return;
|
---|
900 | }
|
---|
901 |
|
---|
902 | /*
|
---|
903 | * Try read the swappable MTE. Save it too.
|
---|
904 | */
|
---|
905 | DBGFADDRESS Addr;
|
---|
906 | int rc = pVMM->pfnDBGFR3MemRead(pUVM, 0 /*idCpu*/, pVMM->pfnDBGFR3AddrFromFlat(pUVM, &Addr, Mte.mte_swapmte),
|
---|
907 | &pBuf->smte, sizeof(pBuf->smte));
|
---|
908 | if (RT_FAILURE(rc))
|
---|
909 | {
|
---|
910 | LogRel(("DbgDiggerOs2: Error reading swap mte @ %RX32: %Rrc\n", Mte.mte_swapmte, rc));
|
---|
911 | return;
|
---|
912 | }
|
---|
913 | LDRSMTE const SwapMte = pBuf->smte;
|
---|
914 |
|
---|
915 | /* Ignore empty modules or modules with too many segments. */
|
---|
916 | if (SwapMte.smte_objcnt == 0 || SwapMte.smte_objcnt > RT_ELEMENTS(pBuf->aOtes))
|
---|
917 | {
|
---|
918 | LogRel(("DbgDiggerOs2: Skipping: smte_objcnt= %#RX32\n", SwapMte.smte_objcnt));
|
---|
919 | return;
|
---|
920 | }
|
---|
921 |
|
---|
922 | /*
|
---|
923 | * Try read the path name, falling back on module name.
|
---|
924 | */
|
---|
925 | char szModPath[260];
|
---|
926 | rc = VERR_READ_ERROR;
|
---|
927 | if (SwapMte.smte_path != 0 && SwapMte.smte_pathlen > 0)
|
---|
928 | {
|
---|
929 | uint32_t cbToRead = RT_MIN(SwapMte.smte_path, sizeof(szModPath) - 1);
|
---|
930 | rc = pVMM->pfnDBGFR3MemRead(pUVM, 0 /*idCpu*/, pVMM->pfnDBGFR3AddrFromFlat(pUVM, &Addr, SwapMte.smte_path),
|
---|
931 | szModPath, cbToRead);
|
---|
932 | szModPath[cbToRead] = '\0';
|
---|
933 | }
|
---|
934 | if (RT_FAILURE(rc))
|
---|
935 | {
|
---|
936 | memcpy(szModPath, Mte.mte_modname, sizeof(Mte.mte_modname));
|
---|
937 | szModPath[sizeof(Mte.mte_modname)] = '\0';
|
---|
938 | RTStrStripR(szModPath);
|
---|
939 | }
|
---|
940 | LogRel(("DbgDiggerOS2: szModPath='%s'\n", szModPath));
|
---|
941 |
|
---|
942 | /*
|
---|
943 | * Sanitize the module name.
|
---|
944 | */
|
---|
945 | char szModName[16];
|
---|
946 | memcpy(szModName, Mte.mte_modname, sizeof(Mte.mte_modname));
|
---|
947 | szModName[sizeof(Mte.mte_modname)] = '\0';
|
---|
948 | RTStrStripR(szModName);
|
---|
949 |
|
---|
950 | /*
|
---|
951 | * Read the object table into the buffer.
|
---|
952 | */
|
---|
953 | rc = pVMM->pfnDBGFR3MemRead(pUVM, 0 /*idCpu*/, pVMM->pfnDBGFR3AddrFromFlat(pUVM, &Addr, SwapMte.smte_objtab),
|
---|
954 | &pBuf->aOtes[0], sizeof(pBuf->aOtes[0]) * SwapMte.smte_objcnt);
|
---|
955 | if (RT_FAILURE(rc))
|
---|
956 | {
|
---|
957 | LogRel(("DbgDiggerOs2: Error reading object table @ %#RX32 LB %#zx: %Rrc\n",
|
---|
958 | SwapMte.smte_objtab, sizeof(pBuf->aOtes[0]) * SwapMte.smte_objcnt, rc));
|
---|
959 | return;
|
---|
960 | }
|
---|
961 | for (uint32_t i = 0; i < SwapMte.smte_objcnt; i++)
|
---|
962 | {
|
---|
963 | LogRel(("DbgDiggerOs2: seg%u: %RX32 LB %#x\n", i, pBuf->aOtes[i].ote_base, pBuf->aOtes[i].ote_size));
|
---|
964 | /** @todo validate it. */
|
---|
965 | }
|
---|
966 |
|
---|
967 | /*
|
---|
968 | * If it is the kernel, take down the general address range so we can easily search
|
---|
969 | * it all in one go when looking for panic messages and such.
|
---|
970 | */
|
---|
971 | if (Mte.mte_flags1 & MTE1_DOSMOD)
|
---|
972 | {
|
---|
973 | uint32_t uMax = 0;
|
---|
974 | uint32_t uMin = UINT32_MAX;
|
---|
975 | for (uint32_t i = 0; i < SwapMte.smte_objcnt; i++)
|
---|
976 | if (pBuf->aOtes[i].ote_base > _512M)
|
---|
977 | {
|
---|
978 | if (pBuf->aOtes[i].ote_base < uMin)
|
---|
979 | uMin = pBuf->aOtes[i].ote_base;
|
---|
980 | uint32_t uTmp = pBuf->aOtes[i].ote_base + pBuf->aOtes[i].ote_size;
|
---|
981 | if (uTmp > uMax)
|
---|
982 | uMax = uTmp;
|
---|
983 | }
|
---|
984 | if (uMax != 0)
|
---|
985 | {
|
---|
986 | pThis->uKernelAddr = uMin;
|
---|
987 | pThis->cbKernel = uMax - uMin;
|
---|
988 | LogRel(("DbgDiggerOs2: High kernel range: %#RX32 LB %#RX32 (%#RX32)\n", uMin, pThis->cbKernel, uMax));
|
---|
989 | }
|
---|
990 | }
|
---|
991 |
|
---|
992 | /*
|
---|
993 | * No need to continue without an address space (shouldn't happen).
|
---|
994 | */
|
---|
995 | if (hAs == NIL_RTDBGAS)
|
---|
996 | return;
|
---|
997 |
|
---|
998 | /*
|
---|
999 | * Try find a debug file for this module.
|
---|
1000 | */
|
---|
1001 | RTDBGMOD hDbgMod = NIL_RTDBGMOD;
|
---|
1002 | if (hDbgCfg != NIL_RTDBGCFG)
|
---|
1003 | {
|
---|
1004 | DBGDIGGEROS2OPEN Args = { szModPath, szModName, &Mte, &SwapMte };
|
---|
1005 | RTDbgCfgOpenEx(hDbgCfg, szModPath, pszCacheSubDir, NULL,
|
---|
1006 | RT_OPSYS_OS2 | RTDBGCFG_O_CASE_INSENSITIVE | RTDBGCFG_O_EXECUTABLE_IMAGE
|
---|
1007 | | RTDBGCFG_O_RECURSIVE | RTDBGCFG_O_NO_SYSTEM_PATHS,
|
---|
1008 | dbgdiggerOs2OpenModule, &Args, &hDbgMod);
|
---|
1009 | }
|
---|
1010 |
|
---|
1011 | /*
|
---|
1012 | * Fallback is a simple module into which we insert sections.
|
---|
1013 | */
|
---|
1014 | uint32_t cSegments = SwapMte.smte_objcnt;
|
---|
1015 | if (hDbgMod == NIL_RTDBGMOD)
|
---|
1016 | {
|
---|
1017 | rc = RTDbgModCreate(&hDbgMod, szModName, 0 /*cbSeg*/, 0 /*fFlags*/);
|
---|
1018 | if (RT_SUCCESS(rc))
|
---|
1019 | {
|
---|
1020 | uint32_t uRva = 0;
|
---|
1021 | for (uint32_t i = 0; i < SwapMte.smte_objcnt; i++)
|
---|
1022 | {
|
---|
1023 | char szSegNm[16];
|
---|
1024 | RTStrPrintf(szSegNm, sizeof(szSegNm), "seg%u", i);
|
---|
1025 | rc = RTDbgModSegmentAdd(hDbgMod, uRva, pBuf->aOtes[i].ote_size, szSegNm, 0 /*fFlags*/, NULL);
|
---|
1026 | if (RT_FAILURE(rc))
|
---|
1027 | {
|
---|
1028 | LogRel(("DbgDiggerOs2: RTDbgModSegmentAdd failed (i=%u, ote_size=%#x): %Rrc\n",
|
---|
1029 | i, pBuf->aOtes[i].ote_size, rc));
|
---|
1030 | cSegments = i;
|
---|
1031 | break;
|
---|
1032 | }
|
---|
1033 | uRva += RT_ALIGN_32(pBuf->aOtes[i].ote_size, _4K);
|
---|
1034 | }
|
---|
1035 | }
|
---|
1036 | else
|
---|
1037 | {
|
---|
1038 | LogRel(("DbgDiggerOs2: RTDbgModCreate failed: %Rrc\n", rc));
|
---|
1039 | return;
|
---|
1040 | }
|
---|
1041 | }
|
---|
1042 |
|
---|
1043 | /*
|
---|
1044 | * Tag the module and link its segments.
|
---|
1045 | */
|
---|
1046 | rc = RTDbgModSetTag(hDbgMod, DIG_OS2_MOD_TAG);
|
---|
1047 | if (RT_SUCCESS(rc))
|
---|
1048 | {
|
---|
1049 | for (uint32_t i = 0; i < cSegments; i++)
|
---|
1050 | if (pBuf->aOtes[i].ote_base != 0)
|
---|
1051 | {
|
---|
1052 | rc = RTDbgAsModuleLinkSeg(hAs, hDbgMod, i, pBuf->aOtes[i].ote_base, RTDBGASLINK_FLAGS_REPLACE /*fFlags*/);
|
---|
1053 | if (RT_FAILURE(rc))
|
---|
1054 | LogRel(("DbgDiggerOs2: RTDbgAsModuleLinkSeg failed (i=%u, ote_base=%#x): %Rrc\n",
|
---|
1055 | i, pBuf->aOtes[i].ote_base, rc));
|
---|
1056 | }
|
---|
1057 | }
|
---|
1058 | else
|
---|
1059 | LogRel(("DbgDiggerOs2: RTDbgModSetTag failed: %Rrc\n", rc));
|
---|
1060 | RTDbgModRelease(hDbgMod);
|
---|
1061 | }
|
---|
1062 |
|
---|
1063 |
|
---|
1064 | /**
|
---|
1065 | * @copydoc DBGFOSREG::pfnInit
|
---|
1066 | */
|
---|
1067 | static DECLCALLBACK(int) dbgDiggerOS2Init(PUVM pUVM, PCVMMR3VTABLE pVMM, void *pvData)
|
---|
1068 | {
|
---|
1069 | PDBGDIGGEROS2 pThis = (PDBGDIGGEROS2)pvData;
|
---|
1070 | Assert(!pThis->fValid);
|
---|
1071 |
|
---|
1072 | DBGDIGGEROS2BUF uBuf;
|
---|
1073 | DBGFADDRESS Addr;
|
---|
1074 | int rc;
|
---|
1075 |
|
---|
1076 | /*
|
---|
1077 | * Determine the OS/2 version.
|
---|
1078 | */
|
---|
1079 | /* Version info is at GIS:15h (major/minor/revision). */
|
---|
1080 | rc = pVMM->pfnDBGFR3AddrFromSelOff(pUVM, 0 /*idCpu*/, &Addr, pThis->selGis, 0x15);
|
---|
1081 | if (RT_FAILURE(rc))
|
---|
1082 | return VERR_NOT_SUPPORTED;
|
---|
1083 | rc = pVMM->pfnDBGFR3MemRead(pUVM, 0 /*idCpu*/, &Addr, uBuf.au32, sizeof(uint32_t));
|
---|
1084 | if (RT_FAILURE(rc))
|
---|
1085 | return VERR_NOT_SUPPORTED;
|
---|
1086 |
|
---|
1087 | pThis->OS2MajorVersion = uBuf.au8[0];
|
---|
1088 | pThis->OS2MinorVersion = uBuf.au8[1];
|
---|
1089 |
|
---|
1090 | pThis->fValid = true;
|
---|
1091 |
|
---|
1092 | /*
|
---|
1093 | * Try use SAS to find the module list.
|
---|
1094 | */
|
---|
1095 | rc = pVMM->pfnDBGFR3AddrFromSelOff(pUVM, 0 /*idCpu*/, &Addr, 0x70, 0x00);
|
---|
1096 | if (RT_SUCCESS(rc))
|
---|
1097 | {
|
---|
1098 | rc = pVMM->pfnDBGFR3MemRead(pUVM, 0 /*idCpu*/, &Addr, &uBuf.sas, sizeof(uBuf.sas));
|
---|
1099 | if (RT_SUCCESS(rc))
|
---|
1100 | {
|
---|
1101 | rc = pVMM->pfnDBGFR3AddrFromSelOff(pUVM, 0 /*idCpu*/, &Addr, 0x70, uBuf.sas.SAS_vm_data);
|
---|
1102 | if (RT_SUCCESS(rc))
|
---|
1103 | rc = pVMM->pfnDBGFR3MemRead(pUVM, 0 /*idCpu*/, &Addr, &uBuf.sasvm, sizeof(uBuf.sasvm));
|
---|
1104 | if (RT_SUCCESS(rc))
|
---|
1105 | {
|
---|
1106 | /*
|
---|
1107 | * Work the module list.
|
---|
1108 | */
|
---|
1109 | rc = pVMM->pfnDBGFR3MemRead(pUVM, 0 /*idCpu*/, pVMM->pfnDBGFR3AddrFromFlat(pUVM, &Addr, uBuf.sasvm.SAS_vm_all_mte),
|
---|
1110 | &uBuf.au32[0], sizeof(uBuf.au32[0]));
|
---|
1111 | if (RT_SUCCESS(rc))
|
---|
1112 | {
|
---|
1113 | uint32_t uOs2Krnl = UINT32_MAX;
|
---|
1114 | RTDBGCFG hDbgCfg = pVMM->pfnDBGFR3AsGetConfig(pUVM); /* (don't release this) */
|
---|
1115 | RTDBGAS hAs = pVMM->pfnDBGFR3AsResolveAndRetain(pUVM, DBGF_AS_GLOBAL);
|
---|
1116 |
|
---|
1117 | char szCacheSubDir[24];
|
---|
1118 | RTStrPrintf(szCacheSubDir, sizeof(szCacheSubDir), "os2-%u.%u", pThis->OS2MajorVersion, pThis->OS2MinorVersion);
|
---|
1119 |
|
---|
1120 | pVMM->pfnDBGFR3AddrFromFlat(pUVM, &Addr, uBuf.au32[0]);
|
---|
1121 | while (Addr.FlatPtr != 0 && Addr.FlatPtr != UINT32_MAX)
|
---|
1122 | {
|
---|
1123 | rc = pVMM->pfnDBGFR3MemRead(pUVM, 0 /*idCpu*/, &Addr, &uBuf.mte, sizeof(uBuf.mte));
|
---|
1124 | if (RT_FAILURE(rc))
|
---|
1125 | break;
|
---|
1126 | LogRel(("DbgDiggerOs2: Module @ %#010RX32: %.8s %#x %#x\n", (uint32_t)Addr.FlatPtr,
|
---|
1127 | uBuf.mte.mte_modname, uBuf.mte.mte_flags1, uBuf.mte.mte_flags2));
|
---|
1128 | if (uBuf.mte.mte_flags1 & MTE1_DOSMOD)
|
---|
1129 | uOs2Krnl = (uint32_t)Addr.FlatPtr;
|
---|
1130 |
|
---|
1131 | pVMM->pfnDBGFR3AddrFromFlat(pUVM, &Addr, uBuf.mte.mte_link);
|
---|
1132 | dbgdiggerOS2ProcessModule(pUVM, pVMM, pThis, &uBuf, szCacheSubDir, hAs, hDbgCfg);
|
---|
1133 | }
|
---|
1134 |
|
---|
1135 | /* Load the kernel again. To make sure we didn't drop any segments due
|
---|
1136 | to overlap/conflicts/whatever. */
|
---|
1137 | if (uOs2Krnl != UINT32_MAX)
|
---|
1138 | {
|
---|
1139 | rc = pVMM->pfnDBGFR3MemRead(pUVM, 0 /*idCpu*/, pVMM->pfnDBGFR3AddrFromFlat(pUVM, &Addr, uOs2Krnl),
|
---|
1140 | &uBuf.mte, sizeof(uBuf.mte));
|
---|
1141 | if (RT_SUCCESS(rc))
|
---|
1142 | {
|
---|
1143 | LogRel(("DbgDiggerOs2: Module @ %#010RX32: %.8s %#x %#x [again]\n", (uint32_t)Addr.FlatPtr,
|
---|
1144 | uBuf.mte.mte_modname, uBuf.mte.mte_flags1, uBuf.mte.mte_flags2));
|
---|
1145 | dbgdiggerOS2ProcessModule(pUVM, pVMM, pThis, &uBuf, szCacheSubDir, hAs, hDbgCfg);
|
---|
1146 | }
|
---|
1147 | }
|
---|
1148 |
|
---|
1149 | RTDbgAsRelease(hAs);
|
---|
1150 | }
|
---|
1151 | }
|
---|
1152 | }
|
---|
1153 | }
|
---|
1154 |
|
---|
1155 | /*
|
---|
1156 | * Register info handlers.
|
---|
1157 | */
|
---|
1158 | pVMM->pfnDBGFR3InfoRegisterExternal(pUVM, "sas", "Dumps the OS/2 system anchor block (SAS).", dbgDiggerOS2InfoSas, pThis);
|
---|
1159 | pVMM->pfnDBGFR3InfoRegisterExternal(pUVM, "gis", "Dumps the OS/2 global info segment (GIS).", dbgDiggerOS2InfoGis, pThis);
|
---|
1160 | pVMM->pfnDBGFR3InfoRegisterExternal(pUVM, "lis", "Dumps the OS/2 local info segment (current process).", dbgDiggerOS2InfoLis, pThis);
|
---|
1161 | pVMM->pfnDBGFR3InfoRegisterExternal(pUVM, "panic", "Dumps the OS/2 system panic message.", dbgDiggerOS2InfoPanic, pThis);
|
---|
1162 |
|
---|
1163 | return VINF_SUCCESS;
|
---|
1164 | }
|
---|
1165 |
|
---|
1166 |
|
---|
1167 | /**
|
---|
1168 | * @copydoc DBGFOSREG::pfnProbe
|
---|
1169 | */
|
---|
1170 | static DECLCALLBACK(bool) dbgDiggerOS2Probe(PUVM pUVM, PCVMMR3VTABLE pVMM, void *pvData)
|
---|
1171 | {
|
---|
1172 | PDBGDIGGEROS2 pThis = (PDBGDIGGEROS2)pvData;
|
---|
1173 | DBGFADDRESS Addr;
|
---|
1174 | int rc;
|
---|
1175 | uint16_t offInfo;
|
---|
1176 | union
|
---|
1177 | {
|
---|
1178 | uint8_t au8[8192];
|
---|
1179 | uint16_t au16[8192/2];
|
---|
1180 | uint32_t au32[8192/4];
|
---|
1181 | RTUTF16 wsz[8192/2];
|
---|
1182 | } u;
|
---|
1183 |
|
---|
1184 | /*
|
---|
1185 | * If the DWORD at 70:0 is 'SAS ' it's quite unlikely that this wouldn't be OS/2.
|
---|
1186 | * Note: The SAS layout is similar between 16-bit and 32-bit OS/2, but not identical.
|
---|
1187 | * 32-bit OS/2 will have the flat kernel data selector at SAS:06. The selector is 168h
|
---|
1188 | * or similar. For 16-bit OS/2 the field contains a table offset into the SAS which will
|
---|
1189 | * be much smaller. Fun fact: The global infoseg selector in the SAS is bimodal in 16-bit
|
---|
1190 | * OS/2 and will work in real mode as well.
|
---|
1191 | */
|
---|
1192 | do {
|
---|
1193 | rc = pVMM->pfnDBGFR3AddrFromSelOff(pUVM, 0 /*idCpu*/, &Addr, 0x70, 0x00);
|
---|
1194 | if (RT_FAILURE(rc))
|
---|
1195 | break;
|
---|
1196 | rc = pVMM->pfnDBGFR3MemRead(pUVM, 0 /*idCpu*/, &Addr, u.au32, 256);
|
---|
1197 | if (RT_FAILURE(rc))
|
---|
1198 | break;
|
---|
1199 | if (u.au32[0] != DIG_OS2_SAS_SIG)
|
---|
1200 | break;
|
---|
1201 |
|
---|
1202 | /* This sure looks like OS/2, but a bit of paranoia won't hurt. */
|
---|
1203 | if (u.au16[2] >= u.au16[4])
|
---|
1204 | break;
|
---|
1205 |
|
---|
1206 | /* If 4th word is bigger than 5th, it's the flat kernel mode selector. */
|
---|
1207 | if (u.au16[3] > u.au16[4])
|
---|
1208 | pThis->f32Bit = true;
|
---|
1209 |
|
---|
1210 | /* Offset into info table is either at SAS:14h or SAS:16h. */
|
---|
1211 | if (pThis->f32Bit)
|
---|
1212 | offInfo = u.au16[0x14/2];
|
---|
1213 | else
|
---|
1214 | offInfo = u.au16[0x16/2];
|
---|
1215 |
|
---|
1216 | /* The global infoseg selector is the first entry in the info table. */
|
---|
1217 | SASINFO const *pInfo = (SASINFO const *)&u.au8[offInfo];
|
---|
1218 | pThis->selGis = pInfo->SAS_info_global;
|
---|
1219 | pThis->Lis.sel = RT_HI_U16(pInfo->SAS_info_local);
|
---|
1220 | pThis->Lis.off = RT_LO_U16(pInfo->SAS_info_local);
|
---|
1221 | return true;
|
---|
1222 | } while (0);
|
---|
1223 |
|
---|
1224 | return false;
|
---|
1225 | }
|
---|
1226 |
|
---|
1227 |
|
---|
1228 | /**
|
---|
1229 | * @copydoc DBGFOSREG::pfnDestruct
|
---|
1230 | */
|
---|
1231 | static DECLCALLBACK(void) dbgDiggerOS2Destruct(PUVM pUVM, PCVMMR3VTABLE pVMM, void *pvData)
|
---|
1232 | {
|
---|
1233 | RT_NOREF(pUVM, pVMM, pvData);
|
---|
1234 | }
|
---|
1235 |
|
---|
1236 |
|
---|
1237 | /**
|
---|
1238 | * @copydoc DBGFOSREG::pfnConstruct
|
---|
1239 | */
|
---|
1240 | static DECLCALLBACK(int) dbgDiggerOS2Construct(PUVM pUVM, PCVMMR3VTABLE pVMM, void *pvData)
|
---|
1241 | {
|
---|
1242 | PDBGDIGGEROS2 pThis = (PDBGDIGGEROS2)pvData;
|
---|
1243 | pThis->fValid = false;
|
---|
1244 | pThis->f32Bit = false;
|
---|
1245 | pThis->enmVer = DBGDIGGEROS2VER_UNKNOWN;
|
---|
1246 | pThis->pUVM = pUVM;
|
---|
1247 | pThis->pVMM = pVMM;
|
---|
1248 | return VINF_SUCCESS;
|
---|
1249 | }
|
---|
1250 |
|
---|
1251 |
|
---|
1252 | const DBGFOSREG g_DBGDiggerOS2 =
|
---|
1253 | {
|
---|
1254 | /* .u32Magic = */ DBGFOSREG_MAGIC,
|
---|
1255 | /* .fFlags = */ 0,
|
---|
1256 | /* .cbData = */ sizeof(DBGDIGGEROS2),
|
---|
1257 | /* .szName = */ "OS/2",
|
---|
1258 | /* .pfnConstruct = */ dbgDiggerOS2Construct,
|
---|
1259 | /* .pfnDestruct = */ dbgDiggerOS2Destruct,
|
---|
1260 | /* .pfnProbe = */ dbgDiggerOS2Probe,
|
---|
1261 | /* .pfnInit = */ dbgDiggerOS2Init,
|
---|
1262 | /* .pfnRefresh = */ dbgDiggerOS2Refresh,
|
---|
1263 | /* .pfnTerm = */ dbgDiggerOS2Term,
|
---|
1264 | /* .pfnQueryVersion = */ dbgDiggerOS2QueryVersion,
|
---|
1265 | /* .pfnQueryInterface = */ dbgDiggerOS2QueryInterface,
|
---|
1266 | /* .pfnStackUnwindAssist = */ dbgDiggerOS2StackUnwindAssist,
|
---|
1267 | /* .u32EndMagic = */ DBGFOSREG_MAGIC
|
---|
1268 | };
|
---|