[23] | 1 | /* $Id: DBGFInfo.cpp 82968 2020-02-04 10:35:17Z vboxsync $ */
|
---|
[1] | 2 | /** @file
|
---|
[12677] | 3 | * DBGF - Debugger Facility, Info.
|
---|
[1] | 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[82968] | 7 | * Copyright (C) 2006-2020 Oracle Corporation
|
---|
[1] | 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
|
---|
[5999] | 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.
|
---|
[1] | 16 | */
|
---|
| 17 |
|
---|
| 18 |
|
---|
[57358] | 19 | /*********************************************************************************************************************************
|
---|
| 20 | * Header Files *
|
---|
| 21 | *********************************************************************************************************************************/
|
---|
[1] | 22 | #define LOG_GROUP LOG_GROUP_DBGF_INFO
|
---|
[35346] | 23 | #include <VBox/vmm/dbgf.h>
|
---|
[20152] | 24 |
|
---|
[35346] | 25 | #include <VBox/vmm/mm.h>
|
---|
[1] | 26 | #include "DBGFInternal.h"
|
---|
[35346] | 27 | #include <VBox/vmm/vm.h>
|
---|
[44399] | 28 | #include <VBox/vmm/uvm.h>
|
---|
[20152] | 29 | #include <VBox/err.h>
|
---|
| 30 | #include <VBox/log.h>
|
---|
[1] | 31 |
|
---|
[20152] | 32 | #include <iprt/assert.h>
|
---|
| 33 | #include <iprt/ctype.h>
|
---|
[80153] | 34 | #include <iprt/getopt.h>
|
---|
[44399] | 35 | #include <iprt/param.h>
|
---|
[1] | 36 | #include <iprt/semaphore.h>
|
---|
[20152] | 37 | #include <iprt/stream.h>
|
---|
| 38 | #include <iprt/string.h>
|
---|
[1] | 39 | #include <iprt/thread.h>
|
---|
| 40 |
|
---|
| 41 |
|
---|
[57358] | 42 | /*********************************************************************************************************************************
|
---|
| 43 | * Internal Functions *
|
---|
| 44 | *********************************************************************************************************************************/
|
---|
[1] | 45 | static DECLCALLBACK(void) dbgfR3InfoLog_Printf(PCDBGFINFOHLP pHlp, const char *pszFormat, ...);
|
---|
| 46 | static DECLCALLBACK(void) dbgfR3InfoLog_PrintfV(PCDBGFINFOHLP pHlp, const char *pszFormat, va_list args);
|
---|
| 47 | static DECLCALLBACK(void) dbgfR3InfoLogRel_Printf(PCDBGFINFOHLP pHlp, const char *pszFormat, ...);
|
---|
| 48 | static DECLCALLBACK(void) dbgfR3InfoLogRel_PrintfV(PCDBGFINFOHLP pHlp, const char *pszFormat, va_list args);
|
---|
[20152] | 49 | static DECLCALLBACK(void) dbgfR3InfoStdErr_Printf(PCDBGFINFOHLP pHlp, const char *pszFormat, ...);
|
---|
| 50 | static DECLCALLBACK(void) dbgfR3InfoStdErr_PrintfV(PCDBGFINFOHLP pHlp, const char *pszFormat, va_list args);
|
---|
[1] | 51 | static DECLCALLBACK(void) dbgfR3InfoHelp(PVM pVM, PCDBGFINFOHLP pHlp, const char *pszArgs);
|
---|
| 52 |
|
---|
| 53 |
|
---|
[57358] | 54 | /*********************************************************************************************************************************
|
---|
| 55 | * Global Variables *
|
---|
| 56 | *********************************************************************************************************************************/
|
---|
[1] | 57 | /** Logger output. */
|
---|
| 58 | static const DBGFINFOHLP g_dbgfR3InfoLogHlp =
|
---|
| 59 | {
|
---|
| 60 | dbgfR3InfoLog_Printf,
|
---|
[80156] | 61 | dbgfR3InfoLog_PrintfV,
|
---|
| 62 | DBGFR3InfoGenricGetOptError,
|
---|
[1] | 63 | };
|
---|
| 64 |
|
---|
| 65 | /** Release logger output. */
|
---|
| 66 | static const DBGFINFOHLP g_dbgfR3InfoLogRelHlp =
|
---|
| 67 | {
|
---|
| 68 | dbgfR3InfoLogRel_Printf,
|
---|
[80156] | 69 | dbgfR3InfoLogRel_PrintfV,
|
---|
| 70 | DBGFR3InfoGenricGetOptError
|
---|
[1] | 71 | };
|
---|
| 72 |
|
---|
[20152] | 73 | /** Standard error output. */
|
---|
| 74 | static const DBGFINFOHLP g_dbgfR3InfoStdErrHlp =
|
---|
| 75 | {
|
---|
| 76 | dbgfR3InfoStdErr_Printf,
|
---|
[80156] | 77 | dbgfR3InfoStdErr_PrintfV,
|
---|
| 78 | DBGFR3InfoGenricGetOptError
|
---|
[20152] | 79 | };
|
---|
[1] | 80 |
|
---|
[20152] | 81 |
|
---|
[1] | 82 | /**
|
---|
| 83 | * Initialize the info handlers.
|
---|
| 84 | *
|
---|
[55881] | 85 | * This is called first during the DBGF init process and thus does the shared
|
---|
| 86 | * critsect init.
|
---|
| 87 | *
|
---|
[1] | 88 | * @returns VBox status code.
|
---|
[44399] | 89 | * @param pUVM The user mode VM handle.
|
---|
[1] | 90 | */
|
---|
[44399] | 91 | int dbgfR3InfoInit(PUVM pUVM)
|
---|
[1] | 92 | {
|
---|
| 93 | /*
|
---|
| 94 | * Make sure we already didn't initialized in the lazy manner.
|
---|
| 95 | */
|
---|
[55881] | 96 | if (RTCritSectRwIsInitialized(&pUVM->dbgf.s.CritSect))
|
---|
[1] | 97 | return VINF_SUCCESS;
|
---|
| 98 |
|
---|
| 99 | /*
|
---|
| 100 | * Initialize the crit sect.
|
---|
| 101 | */
|
---|
[55881] | 102 | int rc = RTCritSectRwInit(&pUVM->dbgf.s.CritSect);
|
---|
[1] | 103 | AssertRCReturn(rc, rc);
|
---|
| 104 |
|
---|
| 105 | /*
|
---|
| 106 | * Register the 'info help' item.
|
---|
| 107 | */
|
---|
[44399] | 108 | rc = DBGFR3InfoRegisterInternal(pUVM->pVM, "help", "List of info items.", dbgfR3InfoHelp);
|
---|
[1] | 109 | AssertRCReturn(rc, rc);
|
---|
| 110 |
|
---|
| 111 | return VINF_SUCCESS;
|
---|
| 112 | }
|
---|
| 113 |
|
---|
| 114 |
|
---|
| 115 | /**
|
---|
| 116 | * Terminate the info handlers.
|
---|
| 117 | *
|
---|
| 118 | * @returns VBox status code.
|
---|
[44399] | 119 | * @param pUVM The user mode VM handle.
|
---|
[1] | 120 | */
|
---|
[44399] | 121 | int dbgfR3InfoTerm(PUVM pUVM)
|
---|
[1] | 122 | {
|
---|
| 123 | /*
|
---|
| 124 | * Delete the crit sect.
|
---|
| 125 | */
|
---|
[55881] | 126 | int rc = RTCritSectRwDelete(&pUVM->dbgf.s.CritSect);
|
---|
[1] | 127 | AssertRC(rc);
|
---|
| 128 | return rc;
|
---|
| 129 | }
|
---|
| 130 |
|
---|
| 131 |
|
---|
[80156] | 132 | /**
|
---|
| 133 | * @interface_method_impl{DBGFINFOHLP,pfnGetOptError}
|
---|
| 134 | */
|
---|
| 135 | VMMR3DECL(void) DBGFR3InfoGenricGetOptError(PCDBGFINFOHLP pHlp, int rc, PRTGETOPTUNION pValueUnion, PRTGETOPTSTATE pState)
|
---|
| 136 | {
|
---|
| 137 | RT_NOREF(pState);
|
---|
| 138 | char szMsg[1024];
|
---|
| 139 | RTGetOptFormatError(szMsg, sizeof(szMsg), rc, pValueUnion);
|
---|
| 140 | pHlp->pfnPrintf(pHlp, "syntax error: %s\n", szMsg);
|
---|
| 141 | }
|
---|
| 142 |
|
---|
| 143 |
|
---|
| 144 | /**
|
---|
| 145 | * @interface_method_impl{DBGFINFOHLP,pfnPrintf, Logger output.}
|
---|
| 146 | */
|
---|
[1] | 147 | static DECLCALLBACK(void) dbgfR3InfoLog_Printf(PCDBGFINFOHLP pHlp, const char *pszFormat, ...)
|
---|
| 148 | {
|
---|
[39078] | 149 | NOREF(pHlp);
|
---|
[1] | 150 | va_list args;
|
---|
| 151 | va_start(args, pszFormat);
|
---|
| 152 | RTLogPrintfV(pszFormat, args);
|
---|
| 153 | va_end(args);
|
---|
| 154 | }
|
---|
| 155 |
|
---|
[80156] | 156 |
|
---|
| 157 | /**
|
---|
| 158 | * @interface_method_impl{DBGFINFOHLP,pfnPrintfV, Logger output.}
|
---|
| 159 | */
|
---|
[1] | 160 | static DECLCALLBACK(void) dbgfR3InfoLog_PrintfV(PCDBGFINFOHLP pHlp, const char *pszFormat, va_list args)
|
---|
| 161 | {
|
---|
[39078] | 162 | NOREF(pHlp);
|
---|
[1] | 163 | RTLogPrintfV(pszFormat, args);
|
---|
| 164 | }
|
---|
| 165 |
|
---|
| 166 |
|
---|
| 167 | /**
|
---|
| 168 | * Gets the logger info helper.
|
---|
| 169 | * The returned info helper will unconditionally write all output to the log.
|
---|
| 170 | *
|
---|
| 171 | * @returns Pointer to the logger info helper.
|
---|
| 172 | */
|
---|
[12989] | 173 | VMMR3DECL(PCDBGFINFOHLP) DBGFR3InfoLogHlp(void)
|
---|
[1] | 174 | {
|
---|
| 175 | return &g_dbgfR3InfoLogHlp;
|
---|
| 176 | }
|
---|
| 177 |
|
---|
| 178 |
|
---|
[80156] | 179 | /**
|
---|
| 180 | * @interface_method_impl{DBGFINFOHLP,pfnPrintf, Release logger output.}
|
---|
| 181 | */
|
---|
[1] | 182 | static DECLCALLBACK(void) dbgfR3InfoLogRel_Printf(PCDBGFINFOHLP pHlp, const char *pszFormat, ...)
|
---|
| 183 | {
|
---|
[39078] | 184 | NOREF(pHlp);
|
---|
[1] | 185 | va_list args;
|
---|
| 186 | va_start(args, pszFormat);
|
---|
| 187 | RTLogRelPrintfV(pszFormat, args);
|
---|
| 188 | va_end(args);
|
---|
| 189 | }
|
---|
| 190 |
|
---|
[80156] | 191 |
|
---|
| 192 | /**
|
---|
| 193 | * @interface_method_impl{DBGFINFOHLP,pfnPrintfV, Release logger output.}
|
---|
| 194 | */
|
---|
[1] | 195 | static DECLCALLBACK(void) dbgfR3InfoLogRel_PrintfV(PCDBGFINFOHLP pHlp, const char *pszFormat, va_list args)
|
---|
| 196 | {
|
---|
[39078] | 197 | NOREF(pHlp);
|
---|
[1] | 198 | RTLogRelPrintfV(pszFormat, args);
|
---|
| 199 | }
|
---|
| 200 |
|
---|
| 201 |
|
---|
[80156] | 202 | /**
|
---|
| 203 | * @interface_method_impl{DBGFINFOHLP,pfnPrintf, Stdandard error output.}
|
---|
| 204 | */
|
---|
[20152] | 205 | static DECLCALLBACK(void) dbgfR3InfoStdErr_Printf(PCDBGFINFOHLP pHlp, const char *pszFormat, ...)
|
---|
| 206 | {
|
---|
[39078] | 207 | NOREF(pHlp);
|
---|
[20152] | 208 | va_list args;
|
---|
| 209 | va_start(args, pszFormat);
|
---|
| 210 | RTStrmPrintfV(g_pStdErr, pszFormat, args);
|
---|
| 211 | va_end(args);
|
---|
| 212 | }
|
---|
| 213 |
|
---|
[80156] | 214 |
|
---|
| 215 | /**
|
---|
| 216 | * @interface_method_impl{DBGFINFOHLP,pfnPrintfV, Stdandard error output.}
|
---|
| 217 | */
|
---|
[20152] | 218 | static DECLCALLBACK(void) dbgfR3InfoStdErr_PrintfV(PCDBGFINFOHLP pHlp, const char *pszFormat, va_list args)
|
---|
| 219 | {
|
---|
[39078] | 220 | NOREF(pHlp);
|
---|
[20152] | 221 | RTStrmPrintfV(g_pStdErr, pszFormat, args);
|
---|
| 222 | }
|
---|
| 223 |
|
---|
| 224 |
|
---|
[1] | 225 | /**
|
---|
| 226 | * Gets the release logger info helper.
|
---|
| 227 | * The returned info helper will unconditionally write all output to the release log.
|
---|
| 228 | *
|
---|
| 229 | * @returns Pointer to the release logger info helper.
|
---|
| 230 | */
|
---|
[12989] | 231 | VMMR3DECL(PCDBGFINFOHLP) DBGFR3InfoLogRelHlp(void)
|
---|
[1] | 232 | {
|
---|
| 233 | return &g_dbgfR3InfoLogRelHlp;
|
---|
| 234 | }
|
---|
| 235 |
|
---|
| 236 |
|
---|
| 237 | /**
|
---|
| 238 | * Handle registration worker.
|
---|
[55881] | 239 | *
|
---|
[33540] | 240 | * This allocates the structure, initializes the common fields and inserts into the list.
|
---|
[1] | 241 | * Upon successful return the we're inside the crit sect and the caller must leave it.
|
---|
| 242 | *
|
---|
| 243 | * @returns VBox status code.
|
---|
[44399] | 244 | * @param pUVM The user mode VM handle.
|
---|
[1] | 245 | * @param pszName The identifier of the info.
|
---|
| 246 | * @param pszDesc The description of the info and any arguments the handler may take.
|
---|
[2250] | 247 | * @param fFlags The flags.
|
---|
[1] | 248 | * @param ppInfo Where to store the created
|
---|
| 249 | */
|
---|
[44399] | 250 | static int dbgfR3InfoRegister(PUVM pUVM, const char *pszName, const char *pszDesc, uint32_t fFlags, PDBGFINFO *ppInfo)
|
---|
[1] | 251 | {
|
---|
| 252 | /*
|
---|
| 253 | * Validate.
|
---|
| 254 | */
|
---|
[2250] | 255 | AssertPtrReturn(pszName, VERR_INVALID_POINTER);
|
---|
| 256 | AssertReturn(*pszName, VERR_INVALID_PARAMETER);
|
---|
| 257 | AssertPtrReturn(pszDesc, VERR_INVALID_POINTER);
|
---|
[61570] | 258 | AssertMsgReturn(!(fFlags & ~(DBGFINFO_FLAGS_RUN_ON_EMT | DBGFINFO_FLAGS_ALL_EMTS)),
|
---|
| 259 | ("fFlags=%#x\n", fFlags), VERR_INVALID_FLAGS);
|
---|
[1] | 260 |
|
---|
| 261 | /*
|
---|
| 262 | * Allocate and initialize.
|
---|
| 263 | */
|
---|
| 264 | int rc;
|
---|
| 265 | size_t cchName = strlen(pszName) + 1;
|
---|
[73097] | 266 | PDBGFINFO pInfo = (PDBGFINFO)MMR3HeapAllocU(pUVM, MM_TAG_DBGF_INFO, RT_UOFFSETOF_DYN(DBGFINFO, szName[cchName]));
|
---|
[1] | 267 | if (pInfo)
|
---|
| 268 | {
|
---|
| 269 | pInfo->enmType = DBGFINFOTYPE_INVALID;
|
---|
[2250] | 270 | pInfo->fFlags = fFlags;
|
---|
[1] | 271 | pInfo->pszDesc = pszDesc;
|
---|
| 272 | pInfo->cchName = cchName - 1;
|
---|
| 273 | memcpy(pInfo->szName, pszName, cchName);
|
---|
| 274 |
|
---|
| 275 | /* lazy init */
|
---|
| 276 | rc = VINF_SUCCESS;
|
---|
[55881] | 277 | if (!RTCritSectRwIsInitialized(&pUVM->dbgf.s.CritSect))
|
---|
[44399] | 278 | rc = dbgfR3InfoInit(pUVM);
|
---|
[13816] | 279 | if (RT_SUCCESS(rc))
|
---|
[1] | 280 | {
|
---|
| 281 | /*
|
---|
| 282 | * Insert in alphabetical order.
|
---|
| 283 | */
|
---|
[55881] | 284 | rc = RTCritSectRwEnterExcl(&pUVM->dbgf.s.CritSect);
|
---|
[1] | 285 | AssertRC(rc);
|
---|
| 286 | PDBGFINFO pPrev = NULL;
|
---|
| 287 | PDBGFINFO pCur;
|
---|
[44399] | 288 | for (pCur = pUVM->dbgf.s.pInfoFirst; pCur; pPrev = pCur, pCur = pCur->pNext)
|
---|
[1] | 289 | if (strcmp(pszName, pCur->szName) < 0)
|
---|
| 290 | break;
|
---|
| 291 | pInfo->pNext = pCur;
|
---|
| 292 | if (pPrev)
|
---|
| 293 | pPrev->pNext = pInfo;
|
---|
| 294 | else
|
---|
[44399] | 295 | pUVM->dbgf.s.pInfoFirst = pInfo;
|
---|
[1] | 296 |
|
---|
| 297 | *ppInfo = pInfo;
|
---|
| 298 | return VINF_SUCCESS;
|
---|
| 299 | }
|
---|
| 300 | MMR3HeapFree(pInfo);
|
---|
| 301 | }
|
---|
| 302 | else
|
---|
| 303 | rc = VERR_NO_MEMORY;
|
---|
| 304 | return rc;
|
---|
| 305 | }
|
---|
| 306 |
|
---|
| 307 |
|
---|
| 308 | /**
|
---|
| 309 | * Register a info handler owned by a device.
|
---|
| 310 | *
|
---|
| 311 | * @returns VBox status code.
|
---|
[58122] | 312 | * @param pVM The cross context VM structure.
|
---|
[1] | 313 | * @param pszName The identifier of the info.
|
---|
| 314 | * @param pszDesc The description of the info and any arguments the handler may take.
|
---|
| 315 | * @param pfnHandler The handler function to be called to display the info.
|
---|
| 316 | * @param pDevIns The device instance owning the info.
|
---|
| 317 | */
|
---|
[44399] | 318 | VMMR3_INT_DECL(int) DBGFR3InfoRegisterDevice(PVM pVM, const char *pszName, const char *pszDesc,
|
---|
| 319 | PFNDBGFHANDLERDEV pfnHandler, PPDMDEVINS pDevIns)
|
---|
[1] | 320 | {
|
---|
| 321 | LogFlow(("DBGFR3InfoRegisterDevice: pszName=%p:{%s} pszDesc=%p:{%s} pfnHandler=%p pDevIns=%p\n",
|
---|
| 322 | pszName, pszName, pszDesc, pszDesc, pfnHandler, pDevIns));
|
---|
| 323 |
|
---|
| 324 | /*
|
---|
| 325 | * Validate the specific stuff.
|
---|
| 326 | */
|
---|
[44399] | 327 | AssertPtrReturn(pfnHandler, VERR_INVALID_POINTER);
|
---|
| 328 | AssertPtrReturn(pDevIns, VERR_INVALID_POINTER);
|
---|
[1] | 329 |
|
---|
| 330 | /*
|
---|
| 331 | * Register
|
---|
| 332 | */
|
---|
| 333 | PDBGFINFO pInfo;
|
---|
[44399] | 334 | int rc = dbgfR3InfoRegister(pVM->pUVM, pszName, pszDesc, 0, &pInfo);
|
---|
[13816] | 335 | if (RT_SUCCESS(rc))
|
---|
[1] | 336 | {
|
---|
| 337 | pInfo->enmType = DBGFINFOTYPE_DEV;
|
---|
| 338 | pInfo->u.Dev.pfnHandler = pfnHandler;
|
---|
| 339 | pInfo->u.Dev.pDevIns = pDevIns;
|
---|
[55881] | 340 | RTCritSectRwLeaveExcl(&pVM->pUVM->dbgf.s.CritSect);
|
---|
[1] | 341 | }
|
---|
| 342 |
|
---|
| 343 | return rc;
|
---|
| 344 | }
|
---|
| 345 |
|
---|
| 346 |
|
---|
| 347 | /**
|
---|
| 348 | * Register a info handler owned by a driver.
|
---|
| 349 | *
|
---|
| 350 | * @returns VBox status code.
|
---|
[58122] | 351 | * @param pVM The cross context VM structure.
|
---|
[1] | 352 | * @param pszName The identifier of the info.
|
---|
| 353 | * @param pszDesc The description of the info and any arguments the handler may take.
|
---|
| 354 | * @param pfnHandler The handler function to be called to display the info.
|
---|
| 355 | * @param pDrvIns The driver instance owning the info.
|
---|
| 356 | */
|
---|
[44399] | 357 | VMMR3_INT_DECL(int) DBGFR3InfoRegisterDriver(PVM pVM, const char *pszName, const char *pszDesc, PFNDBGFHANDLERDRV pfnHandler, PPDMDRVINS pDrvIns)
|
---|
[1] | 358 | {
|
---|
| 359 | LogFlow(("DBGFR3InfoRegisterDriver: pszName=%p:{%s} pszDesc=%p:{%s} pfnHandler=%p pDrvIns=%p\n",
|
---|
| 360 | pszName, pszName, pszDesc, pszDesc, pfnHandler, pDrvIns));
|
---|
| 361 |
|
---|
| 362 | /*
|
---|
| 363 | * Validate the specific stuff.
|
---|
| 364 | */
|
---|
[44399] | 365 | AssertPtrReturn(pfnHandler, VERR_INVALID_POINTER);
|
---|
| 366 | AssertPtrReturn(pDrvIns, VERR_INVALID_POINTER);
|
---|
[1] | 367 |
|
---|
| 368 | /*
|
---|
| 369 | * Register
|
---|
| 370 | */
|
---|
| 371 | PDBGFINFO pInfo;
|
---|
[44399] | 372 | int rc = dbgfR3InfoRegister(pVM->pUVM, pszName, pszDesc, 0, &pInfo);
|
---|
[13816] | 373 | if (RT_SUCCESS(rc))
|
---|
[1] | 374 | {
|
---|
| 375 | pInfo->enmType = DBGFINFOTYPE_DRV;
|
---|
| 376 | pInfo->u.Drv.pfnHandler = pfnHandler;
|
---|
| 377 | pInfo->u.Drv.pDrvIns = pDrvIns;
|
---|
[55881] | 378 | RTCritSectRwLeaveExcl(&pVM->pUVM->dbgf.s.CritSect);
|
---|
[1] | 379 | }
|
---|
| 380 |
|
---|
| 381 | return rc;
|
---|
| 382 | }
|
---|
| 383 |
|
---|
| 384 |
|
---|
| 385 | /**
|
---|
| 386 | * Register a info handler owned by an internal component.
|
---|
| 387 | *
|
---|
| 388 | * @returns VBox status code.
|
---|
[58122] | 389 | * @param pVM The cross context VM structure.
|
---|
[1] | 390 | * @param pszName The identifier of the info.
|
---|
| 391 | * @param pszDesc The description of the info and any arguments the handler may take.
|
---|
| 392 | * @param pfnHandler The handler function to be called to display the info.
|
---|
| 393 | */
|
---|
[44399] | 394 | VMMR3_INT_DECL(int) DBGFR3InfoRegisterInternal(PVM pVM, const char *pszName, const char *pszDesc, PFNDBGFHANDLERINT pfnHandler)
|
---|
[1] | 395 | {
|
---|
[2250] | 396 | return DBGFR3InfoRegisterInternalEx(pVM, pszName, pszDesc, pfnHandler, 0);
|
---|
| 397 | }
|
---|
[1] | 398 |
|
---|
[2250] | 399 |
|
---|
| 400 | /**
|
---|
| 401 | * Register a info handler owned by an internal component.
|
---|
| 402 | *
|
---|
| 403 | * @returns VBox status code.
|
---|
[58122] | 404 | * @param pVM The cross context VM structure.
|
---|
[2250] | 405 | * @param pszName The identifier of the info.
|
---|
| 406 | * @param pszDesc The description of the info and any arguments the handler may take.
|
---|
| 407 | * @param pfnHandler The handler function to be called to display the info.
|
---|
| 408 | * @param fFlags Flags, see the DBGFINFO_FLAGS_*.
|
---|
| 409 | */
|
---|
[44399] | 410 | VMMR3_INT_DECL(int) DBGFR3InfoRegisterInternalEx(PVM pVM, const char *pszName, const char *pszDesc,
|
---|
| 411 | PFNDBGFHANDLERINT pfnHandler, uint32_t fFlags)
|
---|
[2250] | 412 | {
|
---|
[80153] | 413 | LogFlow(("DBGFR3InfoRegisterInternalEx: pszName=%p:{%s} pszDesc=%p:{%s} pfnHandler=%p fFlags=%x\n",
|
---|
[2250] | 414 | pszName, pszName, pszDesc, pszDesc, pfnHandler, fFlags));
|
---|
| 415 |
|
---|
[1] | 416 | /*
|
---|
| 417 | * Validate the specific stuff.
|
---|
| 418 | */
|
---|
[44399] | 419 | AssertPtrReturn(pfnHandler, VERR_INVALID_POINTER);
|
---|
[1] | 420 |
|
---|
| 421 | /*
|
---|
| 422 | * Register
|
---|
| 423 | */
|
---|
| 424 | PDBGFINFO pInfo;
|
---|
[44399] | 425 | int rc = dbgfR3InfoRegister(pVM->pUVM, pszName, pszDesc, fFlags, &pInfo);
|
---|
[13816] | 426 | if (RT_SUCCESS(rc))
|
---|
[1] | 427 | {
|
---|
| 428 | pInfo->enmType = DBGFINFOTYPE_INT;
|
---|
| 429 | pInfo->u.Int.pfnHandler = pfnHandler;
|
---|
[55881] | 430 | RTCritSectRwLeaveExcl(&pVM->pUVM->dbgf.s.CritSect);
|
---|
[1] | 431 | }
|
---|
| 432 |
|
---|
| 433 | return rc;
|
---|
| 434 | }
|
---|
| 435 |
|
---|
| 436 |
|
---|
| 437 | /**
|
---|
| 438 | * Register a info handler owned by an external component.
|
---|
| 439 | *
|
---|
| 440 | * @returns VBox status code.
|
---|
[44399] | 441 | * @param pUVM The user mode VM handle.
|
---|
[1] | 442 | * @param pszName The identifier of the info.
|
---|
| 443 | * @param pszDesc The description of the info and any arguments the handler may take.
|
---|
| 444 | * @param pfnHandler The handler function to be called to display the info.
|
---|
| 445 | * @param pvUser User argument to be passed to the handler.
|
---|
| 446 | */
|
---|
[44399] | 447 | VMMR3DECL(int) DBGFR3InfoRegisterExternal(PUVM pUVM, const char *pszName, const char *pszDesc,
|
---|
| 448 | PFNDBGFHANDLEREXT pfnHandler, void *pvUser)
|
---|
[1] | 449 | {
|
---|
| 450 | LogFlow(("DBGFR3InfoRegisterExternal: pszName=%p:{%s} pszDesc=%p:{%s} pfnHandler=%p pvUser=%p\n",
|
---|
| 451 | pszName, pszName, pszDesc, pszDesc, pfnHandler, pvUser));
|
---|
| 452 |
|
---|
| 453 | /*
|
---|
| 454 | * Validate the specific stuff.
|
---|
| 455 | */
|
---|
[44399] | 456 | AssertPtrReturn(pfnHandler, VERR_INVALID_POINTER);
|
---|
| 457 | UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
|
---|
[1] | 458 |
|
---|
| 459 | /*
|
---|
| 460 | * Register
|
---|
| 461 | */
|
---|
| 462 | PDBGFINFO pInfo;
|
---|
[44399] | 463 | int rc = dbgfR3InfoRegister(pUVM, pszName, pszDesc, 0, &pInfo);
|
---|
[13816] | 464 | if (RT_SUCCESS(rc))
|
---|
[1] | 465 | {
|
---|
| 466 | pInfo->enmType = DBGFINFOTYPE_EXT;
|
---|
| 467 | pInfo->u.Ext.pfnHandler = pfnHandler;
|
---|
| 468 | pInfo->u.Ext.pvUser = pvUser;
|
---|
[55881] | 469 | RTCritSectRwLeaveExcl(&pUVM->dbgf.s.CritSect);
|
---|
[1] | 470 | }
|
---|
| 471 |
|
---|
| 472 | return rc;
|
---|
| 473 | }
|
---|
| 474 |
|
---|
| 475 |
|
---|
| 476 | /**
|
---|
[80153] | 477 | * Register a info handler owned by a device, argv style.
|
---|
| 478 | *
|
---|
| 479 | * @returns VBox status code.
|
---|
| 480 | * @param pVM The cross context VM structure.
|
---|
| 481 | * @param pszName The identifier of the info.
|
---|
| 482 | * @param pszDesc The description of the info and any arguments the handler may take.
|
---|
| 483 | * @param pfnHandler The handler function to be called to display the info.
|
---|
| 484 | * @param pDevIns The device instance owning the info.
|
---|
| 485 | */
|
---|
| 486 | VMMR3_INT_DECL(int) DBGFR3InfoRegisterDeviceArgv(PVM pVM, const char *pszName, const char *pszDesc,
|
---|
| 487 | PFNDBGFINFOARGVDEV pfnHandler, PPDMDEVINS pDevIns)
|
---|
| 488 | {
|
---|
| 489 | LogFlow(("DBGFR3InfoRegisterDeviceArgv: pszName=%p:{%s} pszDesc=%p:{%s} pfnHandler=%p pDevIns=%p\n",
|
---|
| 490 | pszName, pszName, pszDesc, pszDesc, pfnHandler, pDevIns));
|
---|
| 491 |
|
---|
| 492 | /*
|
---|
| 493 | * Validate the specific stuff.
|
---|
| 494 | */
|
---|
| 495 | AssertPtrReturn(pfnHandler, VERR_INVALID_POINTER);
|
---|
| 496 | AssertPtrReturn(pDevIns, VERR_INVALID_POINTER);
|
---|
| 497 |
|
---|
| 498 | /*
|
---|
| 499 | * Register
|
---|
| 500 | */
|
---|
| 501 | PDBGFINFO pInfo;
|
---|
| 502 | int rc = dbgfR3InfoRegister(pVM->pUVM, pszName, pszDesc, 0, &pInfo);
|
---|
| 503 | if (RT_SUCCESS(rc))
|
---|
| 504 | {
|
---|
| 505 | pInfo->enmType = DBGFINFOTYPE_DEV_ARGV;
|
---|
| 506 | pInfo->u.DevArgv.pfnHandler = pfnHandler;
|
---|
| 507 | pInfo->u.DevArgv.pDevIns = pDevIns;
|
---|
| 508 | RTCritSectRwLeaveExcl(&pVM->pUVM->dbgf.s.CritSect);
|
---|
| 509 | }
|
---|
| 510 |
|
---|
| 511 | return rc;
|
---|
| 512 | }
|
---|
| 513 |
|
---|
| 514 |
|
---|
| 515 | /**
|
---|
| 516 | * Register a info handler owned by a driver, argv style.
|
---|
| 517 | *
|
---|
| 518 | * @returns VBox status code.
|
---|
| 519 | * @param pVM The cross context VM structure.
|
---|
| 520 | * @param pszName The identifier of the info.
|
---|
| 521 | * @param pszDesc The description of the info and any arguments the handler may take.
|
---|
| 522 | * @param pfnHandler The handler function to be called to display the info.
|
---|
| 523 | * @param pDrvIns The driver instance owning the info.
|
---|
| 524 | */
|
---|
| 525 | VMMR3_INT_DECL(int) DBGFR3InfoRegisterDriverArgv(PVM pVM, const char *pszName, const char *pszDesc,
|
---|
| 526 | PFNDBGFINFOARGVDRV pfnHandler, PPDMDRVINS pDrvIns)
|
---|
| 527 | {
|
---|
| 528 | LogFlow(("DBGFR3InfoRegisterDriverArgv: pszName=%p:{%s} pszDesc=%p:{%s} pfnHandler=%p pDrvIns=%p\n",
|
---|
| 529 | pszName, pszName, pszDesc, pszDesc, pfnHandler, pDrvIns));
|
---|
| 530 |
|
---|
| 531 | /*
|
---|
| 532 | * Validate the specific stuff.
|
---|
| 533 | */
|
---|
| 534 | AssertPtrReturn(pfnHandler, VERR_INVALID_POINTER);
|
---|
| 535 | AssertPtrReturn(pDrvIns, VERR_INVALID_POINTER);
|
---|
| 536 |
|
---|
| 537 | /*
|
---|
| 538 | * Register
|
---|
| 539 | */
|
---|
| 540 | PDBGFINFO pInfo;
|
---|
| 541 | int rc = dbgfR3InfoRegister(pVM->pUVM, pszName, pszDesc, 0, &pInfo);
|
---|
| 542 | if (RT_SUCCESS(rc))
|
---|
| 543 | {
|
---|
| 544 | pInfo->enmType = DBGFINFOTYPE_DRV_ARGV;
|
---|
| 545 | pInfo->u.DrvArgv.pfnHandler = pfnHandler;
|
---|
| 546 | pInfo->u.DrvArgv.pDrvIns = pDrvIns;
|
---|
| 547 | RTCritSectRwLeaveExcl(&pVM->pUVM->dbgf.s.CritSect);
|
---|
| 548 | }
|
---|
| 549 |
|
---|
| 550 | return rc;
|
---|
| 551 | }
|
---|
| 552 |
|
---|
| 553 |
|
---|
| 554 | /**
|
---|
| 555 | * Register a info handler owned by a USB device, argv style.
|
---|
| 556 | *
|
---|
| 557 | * @returns VBox status code.
|
---|
| 558 | * @param pVM The cross context VM structure.
|
---|
| 559 | * @param pszName The identifier of the info.
|
---|
| 560 | * @param pszDesc The description of the info and any arguments the handler may take.
|
---|
| 561 | * @param pfnHandler The handler function to be called to display the info.
|
---|
| 562 | * @param pUsbIns The USB device instance owning the info.
|
---|
| 563 | */
|
---|
| 564 | VMMR3_INT_DECL(int) DBGFR3InfoRegisterUsbArgv(PVM pVM, const char *pszName, const char *pszDesc,
|
---|
| 565 | PFNDBGFINFOARGVUSB pfnHandler, PPDMUSBINS pUsbIns)
|
---|
| 566 | {
|
---|
| 567 | LogFlow(("DBGFR3InfoRegisterDriverArgv: pszName=%p:{%s} pszDesc=%p:{%s} pfnHandler=%p pUsbIns=%p\n",
|
---|
| 568 | pszName, pszName, pszDesc, pszDesc, pfnHandler, pUsbIns));
|
---|
| 569 |
|
---|
| 570 | /*
|
---|
| 571 | * Validate the specific stuff.
|
---|
| 572 | */
|
---|
| 573 | AssertPtrReturn(pfnHandler, VERR_INVALID_POINTER);
|
---|
| 574 | AssertPtrReturn(pUsbIns, VERR_INVALID_POINTER);
|
---|
| 575 |
|
---|
| 576 | /*
|
---|
| 577 | * Register
|
---|
| 578 | */
|
---|
| 579 | PDBGFINFO pInfo;
|
---|
| 580 | int rc = dbgfR3InfoRegister(pVM->pUVM, pszName, pszDesc, 0, &pInfo);
|
---|
| 581 | if (RT_SUCCESS(rc))
|
---|
| 582 | {
|
---|
| 583 | pInfo->enmType = DBGFINFOTYPE_USB_ARGV;
|
---|
| 584 | pInfo->u.UsbArgv.pfnHandler = pfnHandler;
|
---|
| 585 | pInfo->u.UsbArgv.pUsbIns = pUsbIns;
|
---|
| 586 | RTCritSectRwLeaveExcl(&pVM->pUVM->dbgf.s.CritSect);
|
---|
| 587 | }
|
---|
| 588 |
|
---|
| 589 | return rc;
|
---|
| 590 | }
|
---|
| 591 |
|
---|
| 592 |
|
---|
| 593 | /**
|
---|
| 594 | * Register a info handler owned by an internal component, argv style.
|
---|
| 595 | *
|
---|
| 596 | * @returns VBox status code.
|
---|
| 597 | * @param pVM The cross context VM structure.
|
---|
| 598 | * @param pszName The identifier of the info.
|
---|
| 599 | * @param pszDesc The description of the info and any arguments the handler may take.
|
---|
| 600 | * @param pfnHandler The handler function to be called to display the info.
|
---|
| 601 | * @param fFlags Flags, see the DBGFINFO_FLAGS_*.
|
---|
| 602 | */
|
---|
| 603 | VMMR3_INT_DECL(int) DBGFR3InfoRegisterInternalArgv(PVM pVM, const char *pszName, const char *pszDesc,
|
---|
| 604 | PFNDBGFINFOARGVINT pfnHandler, uint32_t fFlags)
|
---|
| 605 | {
|
---|
| 606 | LogFlow(("DBGFR3InfoRegisterInternalArgv: pszName=%p:{%s} pszDesc=%p:{%s} pfnHandler=%p fFlags=%x\n",
|
---|
| 607 | pszName, pszName, pszDesc, pszDesc, pfnHandler, fFlags));
|
---|
| 608 |
|
---|
| 609 | /*
|
---|
| 610 | * Validate the specific stuff.
|
---|
| 611 | */
|
---|
| 612 | AssertPtrReturn(pfnHandler, VERR_INVALID_POINTER);
|
---|
| 613 |
|
---|
| 614 | /*
|
---|
| 615 | * Register
|
---|
| 616 | */
|
---|
| 617 | PDBGFINFO pInfo;
|
---|
| 618 | int rc = dbgfR3InfoRegister(pVM->pUVM, pszName, pszDesc, fFlags, &pInfo);
|
---|
| 619 | if (RT_SUCCESS(rc))
|
---|
| 620 | {
|
---|
| 621 | pInfo->enmType = DBGFINFOTYPE_INT_ARGV;
|
---|
| 622 | pInfo->u.IntArgv.pfnHandler = pfnHandler;
|
---|
| 623 | RTCritSectRwLeaveExcl(&pVM->pUVM->dbgf.s.CritSect);
|
---|
| 624 | }
|
---|
| 625 |
|
---|
| 626 | return rc;
|
---|
| 627 | }
|
---|
| 628 |
|
---|
| 629 |
|
---|
| 630 | /**
|
---|
| 631 | * Register a info handler owned by an external component.
|
---|
| 632 | *
|
---|
| 633 | * @returns VBox status code.
|
---|
| 634 | * @param pUVM The user mode VM handle.
|
---|
| 635 | * @param pszName The identifier of the info.
|
---|
| 636 | * @param pszDesc The description of the info and any arguments the handler may take.
|
---|
| 637 | * @param pfnHandler The handler function to be called to display the info.
|
---|
| 638 | * @param pvUser User argument to be passed to the handler.
|
---|
| 639 | */
|
---|
| 640 | VMMR3DECL(int) DBGFR3InfoRegisterExternalArgv(PUVM pUVM, const char *pszName, const char *pszDesc,
|
---|
| 641 | PFNDBGFINFOARGVEXT pfnHandler, void *pvUser)
|
---|
| 642 | {
|
---|
| 643 | LogFlow(("DBGFR3InfoRegisterExternalArgv: pszName=%p:{%s} pszDesc=%p:{%s} pfnHandler=%p pvUser=%p\n",
|
---|
| 644 | pszName, pszName, pszDesc, pszDesc, pfnHandler, pvUser));
|
---|
| 645 |
|
---|
| 646 | /*
|
---|
| 647 | * Validate the specific stuff.
|
---|
| 648 | */
|
---|
| 649 | AssertPtrReturn(pfnHandler, VERR_INVALID_POINTER);
|
---|
| 650 | UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
|
---|
| 651 |
|
---|
| 652 | /*
|
---|
| 653 | * Register
|
---|
| 654 | */
|
---|
| 655 | PDBGFINFO pInfo;
|
---|
| 656 | int rc = dbgfR3InfoRegister(pUVM, pszName, pszDesc, 0, &pInfo);
|
---|
| 657 | if (RT_SUCCESS(rc))
|
---|
| 658 | {
|
---|
| 659 | pInfo->enmType = DBGFINFOTYPE_EXT_ARGV;
|
---|
| 660 | pInfo->u.ExtArgv.pfnHandler = pfnHandler;
|
---|
| 661 | pInfo->u.ExtArgv.pvUser = pvUser;
|
---|
| 662 | RTCritSectRwLeaveExcl(&pUVM->dbgf.s.CritSect);
|
---|
| 663 | }
|
---|
| 664 |
|
---|
| 665 | return rc;
|
---|
| 666 | }
|
---|
| 667 |
|
---|
| 668 |
|
---|
| 669 | /**
|
---|
[1] | 670 | * Deregister one(/all) info handler(s) owned by a device.
|
---|
| 671 | *
|
---|
| 672 | * @returns VBox status code.
|
---|
[58122] | 673 | * @param pVM The cross context VM structure.
|
---|
[1] | 674 | * @param pDevIns Device instance.
|
---|
| 675 | * @param pszName The identifier of the info. If NULL all owned by the device.
|
---|
| 676 | */
|
---|
[44399] | 677 | VMMR3_INT_DECL(int) DBGFR3InfoDeregisterDevice(PVM pVM, PPDMDEVINS pDevIns, const char *pszName)
|
---|
[1] | 678 | {
|
---|
| 679 | LogFlow(("DBGFR3InfoDeregisterDevice: pDevIns=%p pszName=%p:{%s}\n", pDevIns, pszName, pszName));
|
---|
| 680 |
|
---|
| 681 | /*
|
---|
| 682 | * Validate input.
|
---|
| 683 | */
|
---|
[44399] | 684 | AssertPtrReturn(pDevIns, VERR_INVALID_POINTER);
|
---|
| 685 | AssertPtrNullReturn(pszName, VERR_INVALID_POINTER);
|
---|
[1] | 686 | size_t cchName = pszName ? strlen(pszName) : 0;
|
---|
[44399] | 687 | PUVM pUVM = pVM->pUVM;
|
---|
[1] | 688 |
|
---|
| 689 | /*
|
---|
| 690 | * Enumerate the info handlers and free the requested entries.
|
---|
| 691 | */
|
---|
[55881] | 692 | int rc = RTCritSectRwEnterExcl(&pUVM->dbgf.s.CritSect); AssertRC(rc);
|
---|
[1] | 693 | rc = VERR_FILE_NOT_FOUND;
|
---|
| 694 | PDBGFINFO pPrev = NULL;
|
---|
[44399] | 695 | PDBGFINFO pInfo = pUVM->dbgf.s.pInfoFirst;
|
---|
[1] | 696 | if (pszName)
|
---|
| 697 | {
|
---|
| 698 | /*
|
---|
| 699 | * Free a specific one.
|
---|
| 700 | */
|
---|
| 701 | for (; pInfo; pPrev = pInfo, pInfo = pInfo->pNext)
|
---|
[80153] | 702 | if ( ( (pInfo->enmType == DBGFINFOTYPE_DEV && pInfo->u.Dev.pDevIns == pDevIns)
|
---|
| 703 | || (pInfo->enmType == DBGFINFOTYPE_DEV_ARGV && pInfo->u.DevArgv.pDevIns == pDevIns))
|
---|
| 704 | && pInfo->cchName == cchName
|
---|
| 705 | && memcmp(pInfo->szName, pszName, cchName) == 0)
|
---|
[1] | 706 | {
|
---|
| 707 | if (pPrev)
|
---|
| 708 | pPrev->pNext = pInfo->pNext;
|
---|
| 709 | else
|
---|
[44399] | 710 | pUVM->dbgf.s.pInfoFirst = pInfo->pNext;
|
---|
[1] | 711 | MMR3HeapFree(pInfo);
|
---|
| 712 | rc = VINF_SUCCESS;
|
---|
| 713 | break;
|
---|
| 714 | }
|
---|
| 715 | }
|
---|
| 716 | else
|
---|
| 717 | {
|
---|
| 718 | /*
|
---|
[44399] | 719 | * Free all owned by the device.
|
---|
[1] | 720 | */
|
---|
[68255] | 721 | while (pInfo != NULL)
|
---|
[80153] | 722 | if ( (pInfo->enmType == DBGFINFOTYPE_DEV && pInfo->u.Dev.pDevIns == pDevIns)
|
---|
| 723 | || (pInfo->enmType == DBGFINFOTYPE_DEV_ARGV && pInfo->u.DevArgv.pDevIns == pDevIns))
|
---|
[1] | 724 | {
|
---|
[68255] | 725 | PDBGFINFO volatile pFree = pInfo;
|
---|
[68256] | 726 | pInfo = pInfo->pNext;
|
---|
[1] | 727 | if (pPrev)
|
---|
[68256] | 728 | pPrev->pNext = pInfo;
|
---|
[1] | 729 | else
|
---|
[68256] | 730 | pUVM->dbgf.s.pInfoFirst = pInfo;
|
---|
[68255] | 731 | MMR3HeapFree(pFree);
|
---|
[1] | 732 | }
|
---|
[68255] | 733 | else
|
---|
| 734 | {
|
---|
| 735 | pPrev = pInfo;
|
---|
| 736 | pInfo = pInfo->pNext;
|
---|
| 737 | }
|
---|
[1] | 738 | rc = VINF_SUCCESS;
|
---|
| 739 | }
|
---|
[55881] | 740 | int rc2 = RTCritSectRwLeaveExcl(&pUVM->dbgf.s.CritSect);
|
---|
[1] | 741 | AssertRC(rc2);
|
---|
| 742 | AssertRC(rc);
|
---|
[13818] | 743 | LogFlow(("DBGFR3InfoDeregisterDevice: returns %Rrc\n", rc));
|
---|
[1] | 744 | return rc;
|
---|
| 745 | }
|
---|
| 746 |
|
---|
[80153] | 747 |
|
---|
[1] | 748 | /**
|
---|
| 749 | * Deregister one(/all) info handler(s) owned by a driver.
|
---|
| 750 | *
|
---|
| 751 | * @returns VBox status code.
|
---|
[58122] | 752 | * @param pVM The cross context VM structure.
|
---|
[1] | 753 | * @param pDrvIns Driver instance.
|
---|
| 754 | * @param pszName The identifier of the info. If NULL all owned by the driver.
|
---|
| 755 | */
|
---|
[44399] | 756 | VMMR3_INT_DECL(int) DBGFR3InfoDeregisterDriver(PVM pVM, PPDMDRVINS pDrvIns, const char *pszName)
|
---|
[1] | 757 | {
|
---|
| 758 | LogFlow(("DBGFR3InfoDeregisterDriver: pDrvIns=%p pszName=%p:{%s}\n", pDrvIns, pszName, pszName));
|
---|
| 759 |
|
---|
| 760 | /*
|
---|
| 761 | * Validate input.
|
---|
| 762 | */
|
---|
[44399] | 763 | AssertPtrReturn(pDrvIns, VERR_INVALID_POINTER);
|
---|
| 764 | AssertPtrNullReturn(pszName, VERR_INVALID_POINTER);
|
---|
[1] | 765 | size_t cchName = pszName ? strlen(pszName) : 0;
|
---|
[44399] | 766 | PUVM pUVM = pVM->pUVM;
|
---|
[1] | 767 |
|
---|
| 768 | /*
|
---|
| 769 | * Enumerate the info handlers and free the requested entries.
|
---|
| 770 | */
|
---|
[55881] | 771 | int rc = RTCritSectRwEnterExcl(&pUVM->dbgf.s.CritSect); AssertRC(rc);
|
---|
[1] | 772 | rc = VERR_FILE_NOT_FOUND;
|
---|
| 773 | PDBGFINFO pPrev = NULL;
|
---|
[44399] | 774 | PDBGFINFO pInfo = pUVM->dbgf.s.pInfoFirst;
|
---|
[1] | 775 | if (pszName)
|
---|
| 776 | {
|
---|
| 777 | /*
|
---|
| 778 | * Free a specific one.
|
---|
| 779 | */
|
---|
| 780 | for (; pInfo; pPrev = pInfo, pInfo = pInfo->pNext)
|
---|
[80153] | 781 | if ( ( (pInfo->enmType == DBGFINFOTYPE_DRV && pInfo->u.Drv.pDrvIns == pDrvIns)
|
---|
| 782 | || (pInfo->enmType == DBGFINFOTYPE_DRV_ARGV && pInfo->u.DrvArgv.pDrvIns == pDrvIns))
|
---|
| 783 | && pInfo->cchName == cchName
|
---|
| 784 | && memcmp(pInfo->szName, pszName, cchName) == 0)
|
---|
[1] | 785 | {
|
---|
| 786 | if (pPrev)
|
---|
| 787 | pPrev->pNext = pInfo->pNext;
|
---|
| 788 | else
|
---|
[44399] | 789 | pUVM->dbgf.s.pInfoFirst = pInfo->pNext;
|
---|
[1] | 790 | MMR3HeapFree(pInfo);
|
---|
| 791 | rc = VINF_SUCCESS;
|
---|
| 792 | break;
|
---|
| 793 | }
|
---|
| 794 | }
|
---|
| 795 | else
|
---|
| 796 | {
|
---|
| 797 | /*
|
---|
| 798 | * Free all owned by the driver.
|
---|
| 799 | */
|
---|
[68255] | 800 | while (pInfo != NULL)
|
---|
[80153] | 801 | if ( (pInfo->enmType == DBGFINFOTYPE_DRV && pInfo->u.Drv.pDrvIns == pDrvIns)
|
---|
| 802 | || (pInfo->enmType == DBGFINFOTYPE_DRV_ARGV && pInfo->u.DrvArgv.pDrvIns == pDrvIns))
|
---|
[1] | 803 | {
|
---|
[68255] | 804 | PDBGFINFO volatile pFree = pInfo;
|
---|
[68256] | 805 | pInfo = pInfo->pNext;
|
---|
[1] | 806 | if (pPrev)
|
---|
[68256] | 807 | pPrev->pNext = pInfo;
|
---|
[1] | 808 | else
|
---|
[68256] | 809 | pUVM->dbgf.s.pInfoFirst = pInfo;
|
---|
[68255] | 810 | MMR3HeapFree(pFree);
|
---|
[1] | 811 | }
|
---|
[68255] | 812 | else
|
---|
| 813 | {
|
---|
| 814 | pPrev = pInfo;
|
---|
| 815 | pInfo = pInfo->pNext;
|
---|
| 816 | }
|
---|
[1] | 817 | rc = VINF_SUCCESS;
|
---|
| 818 | }
|
---|
[55881] | 819 | int rc2 = RTCritSectRwLeaveExcl(&pUVM->dbgf.s.CritSect);
|
---|
[1] | 820 | AssertRC(rc2);
|
---|
| 821 | AssertRC(rc);
|
---|
[13818] | 822 | LogFlow(("DBGFR3InfoDeregisterDriver: returns %Rrc\n", rc));
|
---|
[1] | 823 | return rc;
|
---|
| 824 | }
|
---|
| 825 |
|
---|
| 826 |
|
---|
| 827 | /**
|
---|
[80153] | 828 | * Deregister one(/all) info handler(s) owned by a USB device.
|
---|
| 829 | *
|
---|
| 830 | * @returns VBox status code.
|
---|
| 831 | * @param pVM The cross context VM structure.
|
---|
| 832 | * @param pUsbIns USB device instance.
|
---|
| 833 | * @param pszName The identifier of the info. If NULL all owned by the driver.
|
---|
| 834 | */
|
---|
| 835 | VMMR3_INT_DECL(int) DBGFR3InfoDeregisterUsb(PVM pVM, PPDMUSBINS pUsbIns, const char *pszName)
|
---|
| 836 | {
|
---|
| 837 | LogFlow(("DBGFR3InfoDeregisterUsb: pUsbIns=%p pszName=%p:{%s}\n", pUsbIns, pszName, pszName));
|
---|
| 838 |
|
---|
| 839 | /*
|
---|
| 840 | * Validate input.
|
---|
| 841 | */
|
---|
| 842 | AssertPtrReturn(pUsbIns, VERR_INVALID_POINTER);
|
---|
| 843 | AssertPtrNullReturn(pszName, VERR_INVALID_POINTER);
|
---|
| 844 | size_t cchName = pszName ? strlen(pszName) : 0;
|
---|
| 845 | PUVM pUVM = pVM->pUVM;
|
---|
| 846 |
|
---|
| 847 | /*
|
---|
| 848 | * Enumerate the info handlers and free the requested entries.
|
---|
| 849 | */
|
---|
| 850 | int rc = RTCritSectRwEnterExcl(&pUVM->dbgf.s.CritSect); AssertRC(rc);
|
---|
| 851 | rc = VERR_FILE_NOT_FOUND;
|
---|
| 852 | PDBGFINFO pPrev = NULL;
|
---|
| 853 | PDBGFINFO pInfo = pUVM->dbgf.s.pInfoFirst;
|
---|
| 854 | if (pszName)
|
---|
| 855 | {
|
---|
| 856 | /*
|
---|
| 857 | * Free a specific one.
|
---|
| 858 | */
|
---|
| 859 | for (; pInfo; pPrev = pInfo, pInfo = pInfo->pNext)
|
---|
| 860 | if ( pInfo->enmType == DBGFINFOTYPE_USB_ARGV
|
---|
| 861 | && pInfo->u.UsbArgv.pUsbIns == pUsbIns
|
---|
| 862 | && pInfo->cchName == cchName
|
---|
| 863 | && memcmp(pInfo->szName, pszName, cchName) == 0)
|
---|
| 864 | {
|
---|
| 865 | if (pPrev)
|
---|
| 866 | pPrev->pNext = pInfo->pNext;
|
---|
| 867 | else
|
---|
| 868 | pUVM->dbgf.s.pInfoFirst = pInfo->pNext;
|
---|
| 869 | MMR3HeapFree(pInfo);
|
---|
| 870 | rc = VINF_SUCCESS;
|
---|
| 871 | break;
|
---|
| 872 | }
|
---|
| 873 | }
|
---|
| 874 | else
|
---|
| 875 | {
|
---|
| 876 | /*
|
---|
| 877 | * Free all owned by the driver.
|
---|
| 878 | */
|
---|
| 879 | while (pInfo != NULL)
|
---|
| 880 | if ( pInfo->enmType == DBGFINFOTYPE_USB_ARGV
|
---|
| 881 | && pInfo->u.UsbArgv.pUsbIns == pUsbIns)
|
---|
| 882 | {
|
---|
| 883 | PDBGFINFO volatile pFree = pInfo;
|
---|
| 884 | pInfo = pInfo->pNext;
|
---|
| 885 | if (pPrev)
|
---|
| 886 | pPrev->pNext = pInfo;
|
---|
| 887 | else
|
---|
| 888 | pUVM->dbgf.s.pInfoFirst = pInfo;
|
---|
| 889 | MMR3HeapFree(pFree);
|
---|
| 890 | }
|
---|
| 891 | else
|
---|
| 892 | {
|
---|
| 893 | pPrev = pInfo;
|
---|
| 894 | pInfo = pInfo->pNext;
|
---|
| 895 | }
|
---|
| 896 | rc = VINF_SUCCESS;
|
---|
| 897 | }
|
---|
| 898 | int rc2 = RTCritSectRwLeaveExcl(&pUVM->dbgf.s.CritSect);
|
---|
| 899 | AssertRC(rc2);
|
---|
| 900 | AssertRC(rc);
|
---|
| 901 | LogFlow(("DBGFR3InfoDeregisterDriver: returns %Rrc\n", rc));
|
---|
| 902 | return rc;
|
---|
| 903 | }
|
---|
| 904 |
|
---|
| 905 |
|
---|
| 906 | /**
|
---|
[1] | 907 | * Internal deregistration helper.
|
---|
| 908 | *
|
---|
| 909 | * @returns VBox status code.
|
---|
[44399] | 910 | * @param pUVM Pointer to the VM.
|
---|
[1] | 911 | * @param pszName The identifier of the info.
|
---|
[80153] | 912 | * @param enmType1 The first info owner type (old style).
|
---|
| 913 | * @param enmType2 The second info owner type (argv).
|
---|
[1] | 914 | */
|
---|
[80153] | 915 | static int dbgfR3InfoDeregister(PUVM pUVM, const char *pszName, DBGFINFOTYPE enmType1, DBGFINFOTYPE enmType2)
|
---|
[1] | 916 | {
|
---|
| 917 | /*
|
---|
| 918 | * Validate input.
|
---|
| 919 | */
|
---|
[44399] | 920 | AssertPtrReturn(pszName, VERR_INVALID_POINTER);
|
---|
[1] | 921 |
|
---|
| 922 | /*
|
---|
| 923 | * Find the info handler.
|
---|
| 924 | */
|
---|
| 925 | size_t cchName = strlen(pszName);
|
---|
[55881] | 926 | int rc = RTCritSectRwEnterExcl(&pUVM->dbgf.s.CritSect);
|
---|
[1] | 927 | AssertRC(rc);
|
---|
| 928 | rc = VERR_FILE_NOT_FOUND;
|
---|
| 929 | PDBGFINFO pPrev = NULL;
|
---|
[44399] | 930 | PDBGFINFO pInfo = pUVM->dbgf.s.pInfoFirst;
|
---|
[1] | 931 | for (; pInfo; pPrev = pInfo, pInfo = pInfo->pNext)
|
---|
[80153] | 932 | if ( pInfo->cchName == cchName
|
---|
| 933 | && memcmp(pInfo->szName, pszName, cchName) == 0
|
---|
| 934 | && (pInfo->enmType == enmType1 || pInfo->enmType == enmType2))
|
---|
[1] | 935 | {
|
---|
| 936 | if (pPrev)
|
---|
| 937 | pPrev->pNext = pInfo->pNext;
|
---|
| 938 | else
|
---|
[44399] | 939 | pUVM->dbgf.s.pInfoFirst = pInfo->pNext;
|
---|
[1] | 940 | MMR3HeapFree(pInfo);
|
---|
| 941 | rc = VINF_SUCCESS;
|
---|
| 942 | break;
|
---|
| 943 | }
|
---|
[55881] | 944 | int rc2 = RTCritSectRwLeaveExcl(&pUVM->dbgf.s.CritSect);
|
---|
[1] | 945 | AssertRC(rc2);
|
---|
| 946 | AssertRC(rc);
|
---|
[13818] | 947 | LogFlow(("dbgfR3InfoDeregister: returns %Rrc\n", rc));
|
---|
[1] | 948 | return rc;
|
---|
| 949 | }
|
---|
| 950 |
|
---|
[12663] | 951 |
|
---|
[1] | 952 | /**
|
---|
| 953 | * Deregister a info handler owned by an internal component.
|
---|
| 954 | *
|
---|
| 955 | * @returns VBox status code.
|
---|
[58122] | 956 | * @param pVM The cross context VM structure.
|
---|
[1] | 957 | * @param pszName The identifier of the info. If NULL all owned by the device.
|
---|
| 958 | */
|
---|
[44399] | 959 | VMMR3_INT_DECL(int) DBGFR3InfoDeregisterInternal(PVM pVM, const char *pszName)
|
---|
[1] | 960 | {
|
---|
| 961 | LogFlow(("DBGFR3InfoDeregisterInternal: pszName=%p:{%s}\n", pszName, pszName));
|
---|
[80153] | 962 | return dbgfR3InfoDeregister(pVM->pUVM, pszName, DBGFINFOTYPE_INT, DBGFINFOTYPE_INT_ARGV);
|
---|
[1] | 963 | }
|
---|
| 964 |
|
---|
| 965 |
|
---|
| 966 | /**
|
---|
| 967 | * Deregister a info handler owned by an external component.
|
---|
| 968 | *
|
---|
| 969 | * @returns VBox status code.
|
---|
[44399] | 970 | * @param pUVM The user mode VM handle.
|
---|
[1] | 971 | * @param pszName The identifier of the info. If NULL all owned by the device.
|
---|
| 972 | */
|
---|
[44399] | 973 | VMMR3DECL(int) DBGFR3InfoDeregisterExternal(PUVM pUVM, const char *pszName)
|
---|
[1] | 974 | {
|
---|
| 975 | LogFlow(("DBGFR3InfoDeregisterExternal: pszName=%p:{%s}\n", pszName, pszName));
|
---|
[44399] | 976 | UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
|
---|
[80153] | 977 | return dbgfR3InfoDeregister(pUVM, pszName, DBGFINFOTYPE_EXT, DBGFINFOTYPE_EXT_ARGV);
|
---|
[1] | 978 | }
|
---|
| 979 |
|
---|
| 980 |
|
---|
| 981 | /**
|
---|
[61570] | 982 | * Worker for DBGFR3InfoEx.
|
---|
[39078] | 983 | *
|
---|
[1] | 984 | * @returns VBox status code.
|
---|
[44399] | 985 | * @param pUVM The user mode VM handle.
|
---|
| 986 | * @param idCpu Which CPU to run EMT bound handlers on. VMCPUID_ANY or
|
---|
| 987 | * a valid CPU ID.
|
---|
| 988 | * @param pszName What to dump.
|
---|
| 989 | * @param pszArgs Arguments, optional.
|
---|
| 990 | * @param pHlp Output helper, optional.
|
---|
[1] | 991 | */
|
---|
[44399] | 992 | static DECLCALLBACK(int) dbgfR3Info(PUVM pUVM, VMCPUID idCpu, const char *pszName, const char *pszArgs, PCDBGFINFOHLP pHlp)
|
---|
[1] | 993 | {
|
---|
| 994 | /*
|
---|
| 995 | * Validate input.
|
---|
| 996 | */
|
---|
[38838] | 997 | AssertPtrReturn(pszName, VERR_INVALID_POINTER);
|
---|
[44399] | 998 | AssertPtrNullReturn(pszArgs, VERR_INVALID_POINTER);
|
---|
[1] | 999 | if (pHlp)
|
---|
| 1000 | {
|
---|
[44399] | 1001 | AssertPtrReturn(pHlp, VERR_INVALID_PARAMETER);
|
---|
| 1002 | AssertPtrReturn(pHlp->pfnPrintf, VERR_INVALID_PARAMETER);
|
---|
| 1003 | AssertPtrReturn(pHlp->pfnPrintfV, VERR_INVALID_PARAMETER);
|
---|
[1] | 1004 | }
|
---|
| 1005 | else
|
---|
| 1006 | pHlp = &g_dbgfR3InfoLogHlp;
|
---|
[61570] | 1007 | Assert(idCpu == NIL_VMCPUID || idCpu < pUVM->cCpus); /* if not nil, we're on that EMT already. */
|
---|
[1] | 1008 |
|
---|
| 1009 | /*
|
---|
| 1010 | * Find the info handler.
|
---|
| 1011 | */
|
---|
| 1012 | size_t cchName = strlen(pszName);
|
---|
[55881] | 1013 | int rc = RTCritSectRwEnterShared(&pUVM->dbgf.s.CritSect);
|
---|
[1] | 1014 | AssertRC(rc);
|
---|
[44399] | 1015 | PDBGFINFO pInfo = pUVM->dbgf.s.pInfoFirst;
|
---|
[1] | 1016 | for (; pInfo; pInfo = pInfo->pNext)
|
---|
| 1017 | if ( pInfo->cchName == cchName
|
---|
| 1018 | && !memcmp(pInfo->szName, pszName, cchName))
|
---|
| 1019 | break;
|
---|
| 1020 | if (pInfo)
|
---|
| 1021 | {
|
---|
| 1022 | /*
|
---|
| 1023 | * Found it.
|
---|
| 1024 | */
|
---|
[61570] | 1025 | VMCPUID idDstCpu = NIL_VMCPUID;
|
---|
| 1026 | if ((pInfo->fFlags & (DBGFINFO_FLAGS_RUN_ON_EMT | DBGFINFO_FLAGS_ALL_EMTS)) && idCpu == NIL_VMCPUID)
|
---|
| 1027 | idDstCpu = pInfo->fFlags & DBGFINFO_FLAGS_ALL_EMTS ? VMCPUID_ALL : VMCPUID_ANY;
|
---|
| 1028 |
|
---|
[1] | 1029 | rc = VINF_SUCCESS;
|
---|
[55881] | 1030 | switch (pInfo->enmType)
|
---|
[1] | 1031 | {
|
---|
| 1032 | case DBGFINFOTYPE_DEV:
|
---|
[61570] | 1033 | if (idDstCpu != NIL_VMCPUID)
|
---|
| 1034 | rc = VMR3ReqPriorityCallWaitU(pUVM, idDstCpu, (PFNRT)pInfo->u.Dev.pfnHandler, 3,
|
---|
| 1035 | pInfo->u.Dev.pDevIns, pHlp, pszArgs);
|
---|
[2250] | 1036 | else
|
---|
[55881] | 1037 | pInfo->u.Dev.pfnHandler(pInfo->u.Dev.pDevIns, pHlp, pszArgs);
|
---|
[1] | 1038 | break;
|
---|
[2250] | 1039 |
|
---|
[1] | 1040 | case DBGFINFOTYPE_DRV:
|
---|
[61570] | 1041 | if (idDstCpu != NIL_VMCPUID)
|
---|
| 1042 | rc = VMR3ReqPriorityCallWaitU(pUVM, idDstCpu, (PFNRT)pInfo->u.Drv.pfnHandler, 3,
|
---|
| 1043 | pInfo->u.Drv.pDrvIns, pHlp, pszArgs);
|
---|
[2250] | 1044 | else
|
---|
[55881] | 1045 | pInfo->u.Drv.pfnHandler(pInfo->u.Drv.pDrvIns, pHlp, pszArgs);
|
---|
[1] | 1046 | break;
|
---|
[2250] | 1047 |
|
---|
[1] | 1048 | case DBGFINFOTYPE_INT:
|
---|
[44399] | 1049 | if (RT_VALID_PTR(pUVM->pVM))
|
---|
| 1050 | {
|
---|
[61570] | 1051 | if (idDstCpu != NIL_VMCPUID)
|
---|
| 1052 | rc = VMR3ReqPriorityCallWaitU(pUVM, idDstCpu, (PFNRT)pInfo->u.Int.pfnHandler, 3,
|
---|
| 1053 | pUVM->pVM, pHlp, pszArgs);
|
---|
[44399] | 1054 | else
|
---|
[55881] | 1055 | pInfo->u.Int.pfnHandler(pUVM->pVM, pHlp, pszArgs);
|
---|
[44399] | 1056 | }
|
---|
[2250] | 1057 | else
|
---|
[44399] | 1058 | rc = VERR_INVALID_VM_HANDLE;
|
---|
[1] | 1059 | break;
|
---|
[2250] | 1060 |
|
---|
[1] | 1061 | case DBGFINFOTYPE_EXT:
|
---|
[61570] | 1062 | if (idDstCpu != NIL_VMCPUID)
|
---|
| 1063 | rc = VMR3ReqPriorityCallWaitU(pUVM, idDstCpu, (PFNRT)pInfo->u.Ext.pfnHandler, 3,
|
---|
| 1064 | pInfo->u.Ext.pvUser, pHlp, pszArgs);
|
---|
[2250] | 1065 | else
|
---|
[55881] | 1066 | pInfo->u.Ext.pfnHandler(pInfo->u.Ext.pvUser, pHlp, pszArgs);
|
---|
[1] | 1067 | break;
|
---|
[2250] | 1068 |
|
---|
[80153] | 1069 | case DBGFINFOTYPE_DEV_ARGV:
|
---|
| 1070 | case DBGFINFOTYPE_DRV_ARGV:
|
---|
| 1071 | case DBGFINFOTYPE_USB_ARGV:
|
---|
| 1072 | case DBGFINFOTYPE_INT_ARGV:
|
---|
| 1073 | case DBGFINFOTYPE_EXT_ARGV:
|
---|
| 1074 | {
|
---|
| 1075 | char **papszArgv;
|
---|
| 1076 | int cArgs;
|
---|
| 1077 | rc = RTGetOptArgvFromString(&papszArgv, &cArgs, pszArgs ? pszArgs : "", RTGETOPTARGV_CNV_QUOTE_BOURNE_SH, NULL);
|
---|
| 1078 | if (RT_SUCCESS(rc))
|
---|
| 1079 | {
|
---|
| 1080 | switch (pInfo->enmType)
|
---|
| 1081 | {
|
---|
| 1082 | case DBGFINFOTYPE_DEV_ARGV:
|
---|
| 1083 | if (idDstCpu != NIL_VMCPUID)
|
---|
| 1084 | rc = VMR3ReqPriorityCallWaitU(pUVM, idDstCpu, (PFNRT)pInfo->u.DevArgv.pfnHandler, 4,
|
---|
| 1085 | pInfo->u.DevArgv.pDevIns, pHlp, cArgs, papszArgv);
|
---|
| 1086 | else
|
---|
| 1087 | pInfo->u.DevArgv.pfnHandler(pInfo->u.DevArgv.pDevIns, pHlp, cArgs, papszArgv);
|
---|
| 1088 | break;
|
---|
| 1089 |
|
---|
| 1090 | case DBGFINFOTYPE_DRV_ARGV:
|
---|
| 1091 | if (idDstCpu != NIL_VMCPUID)
|
---|
| 1092 | rc = VMR3ReqPriorityCallWaitU(pUVM, idDstCpu, (PFNRT)pInfo->u.DrvArgv.pfnHandler, 4,
|
---|
| 1093 | pInfo->u.DrvArgv.pDrvIns, pHlp, cArgs, papszArgv);
|
---|
| 1094 | else
|
---|
| 1095 | pInfo->u.DrvArgv.pfnHandler(pInfo->u.DrvArgv.pDrvIns, pHlp, cArgs, papszArgv);
|
---|
| 1096 | break;
|
---|
| 1097 |
|
---|
| 1098 | case DBGFINFOTYPE_USB_ARGV:
|
---|
| 1099 | if (idDstCpu != NIL_VMCPUID)
|
---|
| 1100 | rc = VMR3ReqPriorityCallWaitU(pUVM, idDstCpu, (PFNRT)pInfo->u.UsbArgv.pfnHandler, 4,
|
---|
| 1101 | pInfo->u.UsbArgv.pUsbIns, pHlp, cArgs, papszArgv);
|
---|
| 1102 | else
|
---|
| 1103 | pInfo->u.UsbArgv.pfnHandler(pInfo->u.UsbArgv.pUsbIns, pHlp, cArgs, papszArgv);
|
---|
| 1104 | break;
|
---|
| 1105 |
|
---|
| 1106 | case DBGFINFOTYPE_INT_ARGV:
|
---|
| 1107 | if (RT_VALID_PTR(pUVM->pVM))
|
---|
| 1108 | {
|
---|
| 1109 | if (idDstCpu != NIL_VMCPUID)
|
---|
| 1110 | rc = VMR3ReqPriorityCallWaitU(pUVM, idDstCpu, (PFNRT)pInfo->u.IntArgv.pfnHandler, 4,
|
---|
| 1111 | pUVM->pVM, pHlp, cArgs, papszArgv);
|
---|
| 1112 | else
|
---|
| 1113 | pInfo->u.IntArgv.pfnHandler(pUVM->pVM, pHlp, cArgs, papszArgv);
|
---|
| 1114 | }
|
---|
| 1115 | else
|
---|
| 1116 | rc = VERR_INVALID_VM_HANDLE;
|
---|
| 1117 | break;
|
---|
| 1118 |
|
---|
| 1119 | case DBGFINFOTYPE_EXT_ARGV:
|
---|
| 1120 | if (idDstCpu != NIL_VMCPUID)
|
---|
| 1121 | rc = VMR3ReqPriorityCallWaitU(pUVM, idDstCpu, (PFNRT)pInfo->u.ExtArgv.pfnHandler, 4,
|
---|
| 1122 | pInfo->u.ExtArgv.pvUser, pHlp, cArgs, papszArgv);
|
---|
| 1123 | else
|
---|
| 1124 | pInfo->u.ExtArgv.pfnHandler(pInfo->u.ExtArgv.pvUser, pHlp, cArgs, papszArgv);
|
---|
| 1125 | break;
|
---|
| 1126 |
|
---|
| 1127 | default:
|
---|
| 1128 | AssertFailedBreakStmt(rc = VERR_INTERNAL_ERROR);
|
---|
| 1129 | }
|
---|
| 1130 |
|
---|
| 1131 | RTGetOptArgvFree(papszArgv);
|
---|
| 1132 | }
|
---|
| 1133 | break;
|
---|
| 1134 | }
|
---|
| 1135 |
|
---|
[1] | 1136 | default:
|
---|
[55881] | 1137 | AssertMsgFailedReturn(("Invalid info type enmType=%d\n", pInfo->enmType), VERR_IPE_NOT_REACHED_DEFAULT_CASE);
|
---|
[1] | 1138 | }
|
---|
[61570] | 1139 |
|
---|
[55881] | 1140 | int rc2 = RTCritSectRwLeaveShared(&pUVM->dbgf.s.CritSect);
|
---|
| 1141 | AssertRC(rc2);
|
---|
[1] | 1142 | }
|
---|
| 1143 | else
|
---|
| 1144 | {
|
---|
[55881] | 1145 | rc = RTCritSectRwLeaveShared(&pUVM->dbgf.s.CritSect);
|
---|
[1] | 1146 | AssertRC(rc);
|
---|
| 1147 | rc = VERR_FILE_NOT_FOUND;
|
---|
| 1148 | }
|
---|
| 1149 | return rc;
|
---|
| 1150 | }
|
---|
| 1151 |
|
---|
[61570] | 1152 |
|
---|
[38838] | 1153 | /**
|
---|
| 1154 | * Display a piece of info writing to the supplied handler.
|
---|
| 1155 | *
|
---|
| 1156 | * @returns VBox status code.
|
---|
[44399] | 1157 | * @param pUVM The user mode VM handle.
|
---|
[38838] | 1158 | * @param pszName The identifier of the info to display.
|
---|
| 1159 | * @param pszArgs Arguments to the info handler.
|
---|
| 1160 | * @param pHlp The output helper functions. If NULL the logger will be used.
|
---|
| 1161 | */
|
---|
[44399] | 1162 | VMMR3DECL(int) DBGFR3Info(PUVM pUVM, const char *pszName, const char *pszArgs, PCDBGFINFOHLP pHlp)
|
---|
[38838] | 1163 | {
|
---|
[61570] | 1164 | return DBGFR3InfoEx(pUVM, NIL_VMCPUID, pszName, pszArgs, pHlp);
|
---|
[38838] | 1165 | }
|
---|
[1] | 1166 |
|
---|
[38838] | 1167 |
|
---|
[1] | 1168 | /**
|
---|
[38838] | 1169 | * Display a piece of info writing to the supplied handler.
|
---|
| 1170 | *
|
---|
| 1171 | * @returns VBox status code.
|
---|
[44399] | 1172 | * @param pUVM The user mode VM handle.
|
---|
[39078] | 1173 | * @param idCpu The CPU to exectue the request on. Pass NIL_VMCPUID
|
---|
[61570] | 1174 | * to not involve any EMT unless necessary.
|
---|
[38838] | 1175 | * @param pszName The identifier of the info to display.
|
---|
| 1176 | * @param pszArgs Arguments to the info handler.
|
---|
| 1177 | * @param pHlp The output helper functions. If NULL the logger will be used.
|
---|
| 1178 | */
|
---|
[44399] | 1179 | VMMR3DECL(int) DBGFR3InfoEx(PUVM pUVM, VMCPUID idCpu, const char *pszName, const char *pszArgs, PCDBGFINFOHLP pHlp)
|
---|
[38838] | 1180 | {
|
---|
[61570] | 1181 | /*
|
---|
| 1182 | * Some input validation.
|
---|
| 1183 | */
|
---|
[44399] | 1184 | UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
|
---|
[61570] | 1185 | AssertReturn( idCpu != VMCPUID_ANY_QUEUE
|
---|
| 1186 | && idCpu != VMCPUID_ALL
|
---|
| 1187 | && idCpu != VMCPUID_ALL_REVERSE, VERR_INVALID_PARAMETER);
|
---|
| 1188 |
|
---|
| 1189 | /*
|
---|
| 1190 | * Run on any specific EMT?
|
---|
| 1191 | */
|
---|
[38838] | 1192 | if (idCpu == NIL_VMCPUID)
|
---|
[61570] | 1193 | return dbgfR3Info(pUVM, NIL_VMCPUID, pszName, pszArgs, pHlp);
|
---|
[44399] | 1194 | return VMR3ReqPriorityCallWaitU(pUVM, idCpu,
|
---|
| 1195 | (PFNRT)dbgfR3Info, 5, pUVM, idCpu, pszName, pszArgs, pHlp);
|
---|
[38838] | 1196 | }
|
---|
| 1197 |
|
---|
| 1198 |
|
---|
| 1199 | /**
|
---|
[20152] | 1200 | * Wrapper for DBGFR3Info that outputs to the release log.
|
---|
| 1201 | *
|
---|
| 1202 | * @returns See DBGFR3Info.
|
---|
[44399] | 1203 | * @param pUVM The user mode VM handle.
|
---|
| 1204 | * @param pszName See DBGFR3Info.
|
---|
| 1205 | * @param pszArgs See DBGFR3Info.
|
---|
[20152] | 1206 | */
|
---|
[44399] | 1207 | VMMR3DECL(int) DBGFR3InfoLogRel(PUVM pUVM, const char *pszName, const char *pszArgs)
|
---|
[20152] | 1208 | {
|
---|
[61570] | 1209 | return DBGFR3InfoEx(pUVM, NIL_VMCPUID, pszName, pszArgs, &g_dbgfR3InfoLogRelHlp);
|
---|
[20152] | 1210 | }
|
---|
| 1211 |
|
---|
| 1212 |
|
---|
| 1213 | /**
|
---|
| 1214 | * Wrapper for DBGFR3Info that outputs to standard error.
|
---|
| 1215 | *
|
---|
| 1216 | * @returns See DBGFR3Info.
|
---|
[44399] | 1217 | * @param pUVM The user mode VM handle.
|
---|
| 1218 | * @param pszName See DBGFR3Info.
|
---|
| 1219 | * @param pszArgs See DBGFR3Info.
|
---|
[20152] | 1220 | */
|
---|
[44399] | 1221 | VMMR3DECL(int) DBGFR3InfoStdErr(PUVM pUVM, const char *pszName, const char *pszArgs)
|
---|
[20152] | 1222 | {
|
---|
[61570] | 1223 | return DBGFR3InfoEx(pUVM, NIL_VMCPUID, pszName, pszArgs, &g_dbgfR3InfoStdErrHlp);
|
---|
[20152] | 1224 | }
|
---|
| 1225 |
|
---|
| 1226 |
|
---|
| 1227 | /**
|
---|
[30060] | 1228 | * Display several info items.
|
---|
| 1229 | *
|
---|
| 1230 | * This is intended used by the fatal error dump only.
|
---|
| 1231 | *
|
---|
[58126] | 1232 | * @returns VBox status code.
|
---|
[58122] | 1233 | * @param pVM The cross context VM structure.
|
---|
[30060] | 1234 | * @param pszIncludePat Simple string pattern of info items to include.
|
---|
| 1235 | * @param pszExcludePat Simple string pattern of info items to exclude.
|
---|
| 1236 | * @param pszSepFmt Item separator format string. The item name will be
|
---|
| 1237 | * given as parameter.
|
---|
| 1238 | * @param pHlp The output helper functions. If NULL the logger
|
---|
| 1239 | * will be used.
|
---|
| 1240 | *
|
---|
[58126] | 1241 | * @thread EMT
|
---|
[30060] | 1242 | */
|
---|
[44399] | 1243 | VMMR3_INT_DECL(int) DBGFR3InfoMulti(PVM pVM, const char *pszIncludePat, const char *pszExcludePat, const char *pszSepFmt,
|
---|
| 1244 | PCDBGFINFOHLP pHlp)
|
---|
[30060] | 1245 | {
|
---|
| 1246 | /*
|
---|
| 1247 | * Validate input.
|
---|
| 1248 | */
|
---|
[44399] | 1249 | PUVM pUVM = pVM->pUVM;
|
---|
[30060] | 1250 | VM_ASSERT_EMT_RETURN(pVM, VERR_VM_THREAD_NOT_EMT);
|
---|
| 1251 | AssertPtrReturn(pszIncludePat, VERR_INVALID_POINTER);
|
---|
| 1252 | AssertPtrReturn(pszExcludePat, VERR_INVALID_POINTER);
|
---|
| 1253 | if (pHlp)
|
---|
| 1254 | {
|
---|
| 1255 | AssertPtrReturn(pHlp->pfnPrintf, VERR_INVALID_POINTER);
|
---|
| 1256 | AssertPtrReturn(pHlp->pfnPrintfV, VERR_INVALID_POINTER);
|
---|
| 1257 | }
|
---|
| 1258 | else
|
---|
| 1259 | pHlp = &g_dbgfR3InfoLogHlp;
|
---|
| 1260 |
|
---|
| 1261 | size_t const cchIncludePat = strlen(pszIncludePat);
|
---|
| 1262 | size_t const cchExcludePat = strlen(pszExcludePat);
|
---|
| 1263 | const char *pszArgs = "";
|
---|
| 1264 |
|
---|
| 1265 | /*
|
---|
| 1266 | * Enumerate the info handlers and call the ones matching.
|
---|
| 1267 | * Note! We won't leave the critical section here...
|
---|
| 1268 | */
|
---|
[80153] | 1269 | char *apszArgs[2] = { NULL, NULL };
|
---|
[55881] | 1270 | int rc = RTCritSectRwEnterShared(&pUVM->dbgf.s.CritSect);
|
---|
[30060] | 1271 | AssertRC(rc);
|
---|
| 1272 | rc = VWRN_NOT_FOUND;
|
---|
[44399] | 1273 | for (PDBGFINFO pInfo = pUVM->dbgf.s.pInfoFirst; pInfo; pInfo = pInfo->pNext)
|
---|
[30060] | 1274 | {
|
---|
| 1275 | if ( RTStrSimplePatternMultiMatch(pszIncludePat, cchIncludePat, pInfo->szName, pInfo->cchName, NULL)
|
---|
| 1276 | && !RTStrSimplePatternMultiMatch(pszExcludePat, cchExcludePat, pInfo->szName, pInfo->cchName, NULL))
|
---|
| 1277 | {
|
---|
| 1278 | pHlp->pfnPrintf(pHlp, pszSepFmt, pInfo->szName);
|
---|
[61570] | 1279 |
|
---|
| 1280 | VMCPUID idDstCpu = NIL_VMCPUID;
|
---|
| 1281 | if (pInfo->fFlags & (DBGFINFO_FLAGS_RUN_ON_EMT | DBGFINFO_FLAGS_ALL_EMTS))
|
---|
| 1282 | idDstCpu = pInfo->fFlags & DBGFINFO_FLAGS_ALL_EMTS ? VMCPUID_ALL : VMCPUID_ANY;
|
---|
| 1283 |
|
---|
[30060] | 1284 | rc = VINF_SUCCESS;
|
---|
| 1285 | switch (pInfo->enmType)
|
---|
| 1286 | {
|
---|
| 1287 | case DBGFINFOTYPE_DEV:
|
---|
[61570] | 1288 | if (idDstCpu != NIL_VMCPUID)
|
---|
| 1289 | rc = VMR3ReqPriorityCallVoidWaitU(pUVM, idDstCpu, (PFNRT)pInfo->u.Dev.pfnHandler, 3,
|
---|
| 1290 | pInfo->u.Dev.pDevIns, pHlp, pszArgs);
|
---|
[30060] | 1291 | else
|
---|
| 1292 | pInfo->u.Dev.pfnHandler(pInfo->u.Dev.pDevIns, pHlp, pszArgs);
|
---|
| 1293 | break;
|
---|
| 1294 |
|
---|
| 1295 | case DBGFINFOTYPE_DRV:
|
---|
[61570] | 1296 | if (idDstCpu != NIL_VMCPUID)
|
---|
| 1297 | rc = VMR3ReqPriorityCallVoidWaitU(pUVM, idDstCpu, (PFNRT)pInfo->u.Drv.pfnHandler, 3,
|
---|
| 1298 | pInfo->u.Drv.pDrvIns, pHlp, pszArgs);
|
---|
[30060] | 1299 | else
|
---|
| 1300 | pInfo->u.Drv.pfnHandler(pInfo->u.Drv.pDrvIns, pHlp, pszArgs);
|
---|
| 1301 | break;
|
---|
| 1302 |
|
---|
| 1303 | case DBGFINFOTYPE_INT:
|
---|
[61570] | 1304 | if (idDstCpu != NIL_VMCPUID)
|
---|
| 1305 | rc = VMR3ReqPriorityCallVoidWaitU(pUVM, idDstCpu, (PFNRT)pInfo->u.Int.pfnHandler, 3,
|
---|
| 1306 | pVM, pHlp, pszArgs);
|
---|
[30060] | 1307 | else
|
---|
| 1308 | pInfo->u.Int.pfnHandler(pVM, pHlp, pszArgs);
|
---|
| 1309 | break;
|
---|
| 1310 |
|
---|
| 1311 | case DBGFINFOTYPE_EXT:
|
---|
[61570] | 1312 | if (idDstCpu != NIL_VMCPUID)
|
---|
| 1313 | rc = VMR3ReqPriorityCallVoidWaitU(pUVM, idDstCpu, (PFNRT)pInfo->u.Ext.pfnHandler, 3,
|
---|
| 1314 | pInfo->u.Ext.pvUser, pHlp, pszArgs);
|
---|
[30060] | 1315 | else
|
---|
| 1316 | pInfo->u.Ext.pfnHandler(pInfo->u.Ext.pvUser, pHlp, pszArgs);
|
---|
| 1317 | break;
|
---|
| 1318 |
|
---|
[80153] | 1319 | case DBGFINFOTYPE_DEV_ARGV:
|
---|
| 1320 | if (idDstCpu != NIL_VMCPUID)
|
---|
| 1321 | rc = VMR3ReqPriorityCallWaitU(pUVM, idDstCpu, (PFNRT)pInfo->u.DevArgv.pfnHandler, 4,
|
---|
| 1322 | pInfo->u.DevArgv.pDevIns, pHlp, 0, &apszArgs[0]);
|
---|
| 1323 | else
|
---|
| 1324 | pInfo->u.DevArgv.pfnHandler(pInfo->u.DevArgv.pDevIns, pHlp, 0, &apszArgs[0]);
|
---|
| 1325 | break;
|
---|
| 1326 |
|
---|
| 1327 | case DBGFINFOTYPE_DRV_ARGV:
|
---|
| 1328 | if (idDstCpu != NIL_VMCPUID)
|
---|
| 1329 | rc = VMR3ReqPriorityCallWaitU(pUVM, idDstCpu, (PFNRT)pInfo->u.DrvArgv.pfnHandler, 4,
|
---|
| 1330 | pInfo->u.DrvArgv.pDrvIns, pHlp, 0, &apszArgs[0]);
|
---|
| 1331 | else
|
---|
| 1332 | pInfo->u.DrvArgv.pfnHandler(pInfo->u.DrvArgv.pDrvIns, pHlp, 0, &apszArgs[0]);
|
---|
| 1333 | break;
|
---|
| 1334 |
|
---|
| 1335 | case DBGFINFOTYPE_USB_ARGV:
|
---|
| 1336 | if (idDstCpu != NIL_VMCPUID)
|
---|
| 1337 | rc = VMR3ReqPriorityCallWaitU(pUVM, idDstCpu, (PFNRT)pInfo->u.UsbArgv.pfnHandler, 4,
|
---|
| 1338 | pInfo->u.UsbArgv.pUsbIns, pHlp, 0, &apszArgs[0]);
|
---|
| 1339 | else
|
---|
| 1340 | pInfo->u.UsbArgv.pfnHandler(pInfo->u.UsbArgv.pUsbIns, pHlp, 0, &apszArgs[0]);
|
---|
| 1341 | break;
|
---|
| 1342 |
|
---|
| 1343 | case DBGFINFOTYPE_INT_ARGV:
|
---|
| 1344 | if (RT_VALID_PTR(pUVM->pVM))
|
---|
| 1345 | {
|
---|
| 1346 | if (idDstCpu != NIL_VMCPUID)
|
---|
| 1347 | rc = VMR3ReqPriorityCallWaitU(pUVM, idDstCpu, (PFNRT)pInfo->u.IntArgv.pfnHandler, 4,
|
---|
| 1348 | pUVM->pVM, pHlp, 0, &apszArgs[0]);
|
---|
| 1349 | else
|
---|
| 1350 | pInfo->u.IntArgv.pfnHandler(pUVM->pVM, pHlp, 0, &apszArgs[0]);
|
---|
| 1351 | }
|
---|
| 1352 | else
|
---|
| 1353 | rc = VERR_INVALID_VM_HANDLE;
|
---|
| 1354 | break;
|
---|
| 1355 |
|
---|
| 1356 | case DBGFINFOTYPE_EXT_ARGV:
|
---|
| 1357 | if (idDstCpu != NIL_VMCPUID)
|
---|
| 1358 | rc = VMR3ReqPriorityCallWaitU(pUVM, idDstCpu, (PFNRT)pInfo->u.ExtArgv.pfnHandler, 4,
|
---|
| 1359 | pInfo->u.ExtArgv.pvUser, pHlp, 0, &apszArgs[0]);
|
---|
| 1360 | else
|
---|
| 1361 | pInfo->u.ExtArgv.pfnHandler(pInfo->u.ExtArgv.pvUser, pHlp, 0, &apszArgs[0]);
|
---|
| 1362 | break;
|
---|
| 1363 |
|
---|
[30060] | 1364 | default:
|
---|
[39405] | 1365 | AssertMsgFailedReturn(("Invalid info type enmType=%d\n", pInfo->enmType), VERR_IPE_NOT_REACHED_DEFAULT_CASE);
|
---|
[30060] | 1366 | }
|
---|
| 1367 | }
|
---|
| 1368 | }
|
---|
[55881] | 1369 | int rc2 = RTCritSectRwLeaveShared(&pUVM->dbgf.s.CritSect);
|
---|
[30060] | 1370 | AssertRC(rc2);
|
---|
| 1371 |
|
---|
| 1372 | return rc;
|
---|
| 1373 | }
|
---|
| 1374 |
|
---|
| 1375 |
|
---|
| 1376 | /**
|
---|
[1] | 1377 | * Enumerate all the register info handlers.
|
---|
| 1378 | *
|
---|
| 1379 | * @returns VBox status code.
|
---|
[44399] | 1380 | * @param pUVM The user mode VM handle.
|
---|
[1] | 1381 | * @param pfnCallback Pointer to callback function.
|
---|
| 1382 | * @param pvUser User argument to pass to the callback.
|
---|
| 1383 | */
|
---|
[44399] | 1384 | VMMR3DECL(int) DBGFR3InfoEnum(PUVM pUVM, PFNDBGFINFOENUM pfnCallback, void *pvUser)
|
---|
[1] | 1385 | {
|
---|
| 1386 | LogFlow(("DBGFR3InfoLog: pfnCallback=%p pvUser=%p\n", pfnCallback, pvUser));
|
---|
| 1387 |
|
---|
| 1388 | /*
|
---|
| 1389 | * Validate input.
|
---|
| 1390 | */
|
---|
| 1391 | if (!pfnCallback)
|
---|
| 1392 | {
|
---|
| 1393 | AssertMsgFailed(("!pfnCallback\n"));
|
---|
| 1394 | return VERR_INVALID_PARAMETER;
|
---|
| 1395 | }
|
---|
[44399] | 1396 | UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
|
---|
[1] | 1397 |
|
---|
| 1398 | /*
|
---|
| 1399 | * Enter and enumerate.
|
---|
| 1400 | */
|
---|
[55881] | 1401 | int rc = RTCritSectRwEnterShared(&pUVM->dbgf.s.CritSect);
|
---|
[1] | 1402 | AssertRC(rc);
|
---|
| 1403 |
|
---|
| 1404 | rc = VINF_SUCCESS;
|
---|
[44399] | 1405 | for (PDBGFINFO pInfo = pUVM->dbgf.s.pInfoFirst; RT_SUCCESS(rc) && pInfo; pInfo = pInfo->pNext)
|
---|
| 1406 | rc = pfnCallback(pUVM, pInfo->szName, pInfo->pszDesc, pvUser);
|
---|
[1] | 1407 |
|
---|
| 1408 | /*
|
---|
| 1409 | * Leave and exit.
|
---|
| 1410 | */
|
---|
[55881] | 1411 | int rc2 = RTCritSectRwLeaveShared(&pUVM->dbgf.s.CritSect);
|
---|
[1] | 1412 | AssertRC(rc2);
|
---|
| 1413 |
|
---|
[13818] | 1414 | LogFlow(("DBGFR3InfoLog: returns %Rrc\n", rc));
|
---|
[1] | 1415 | return rc;
|
---|
| 1416 | }
|
---|
| 1417 |
|
---|
| 1418 |
|
---|
| 1419 | /**
|
---|
| 1420 | * Info handler, internal version.
|
---|
| 1421 | *
|
---|
[58122] | 1422 | * @param pVM The cross context VM structure.
|
---|
[1] | 1423 | * @param pHlp Callback functions for doing output.
|
---|
| 1424 | * @param pszArgs Argument string. Optional and specific to the handler.
|
---|
| 1425 | */
|
---|
| 1426 | static DECLCALLBACK(void) dbgfR3InfoHelp(PVM pVM, PCDBGFINFOHLP pHlp, const char *pszArgs)
|
---|
| 1427 | {
|
---|
| 1428 | LogFlow(("dbgfR3InfoHelp: pszArgs=%s\n", pszArgs));
|
---|
| 1429 |
|
---|
| 1430 | /*
|
---|
| 1431 | * Enter and enumerate.
|
---|
| 1432 | */
|
---|
[44399] | 1433 | PUVM pUVM = pVM->pUVM;
|
---|
[55881] | 1434 | int rc = RTCritSectRwEnterShared(&pUVM->dbgf.s.CritSect);
|
---|
[1] | 1435 | AssertRC(rc);
|
---|
| 1436 |
|
---|
| 1437 | if (pszArgs && *pszArgs)
|
---|
| 1438 | {
|
---|
[44399] | 1439 | for (PDBGFINFO pInfo = pUVM->dbgf.s.pInfoFirst; pInfo; pInfo = pInfo->pNext)
|
---|
[1] | 1440 | {
|
---|
| 1441 | const char *psz = strstr(pszArgs, pInfo->szName);
|
---|
| 1442 | if ( psz
|
---|
| 1443 | && ( psz == pszArgs
|
---|
[24009] | 1444 | || RT_C_IS_SPACE(psz[-1]))
|
---|
[1] | 1445 | && ( !psz[pInfo->cchName]
|
---|
[24009] | 1446 | || RT_C_IS_SPACE(psz[pInfo->cchName])))
|
---|
[1] | 1447 | pHlp->pfnPrintf(pHlp, "%-16s %s\n",
|
---|
| 1448 | pInfo->szName, pInfo->pszDesc);
|
---|
| 1449 | }
|
---|
| 1450 | }
|
---|
| 1451 | else
|
---|
| 1452 | {
|
---|
[44399] | 1453 | for (PDBGFINFO pInfo = pUVM->dbgf.s.pInfoFirst; pInfo; pInfo = pInfo->pNext)
|
---|
[1] | 1454 | pHlp->pfnPrintf(pHlp, "%-16s %s\n",
|
---|
| 1455 | pInfo->szName, pInfo->pszDesc);
|
---|
| 1456 | }
|
---|
| 1457 |
|
---|
| 1458 | /*
|
---|
| 1459 | * Leave and exit.
|
---|
| 1460 | */
|
---|
[55881] | 1461 | rc = RTCritSectRwLeaveShared(&pUVM->dbgf.s.CritSect);
|
---|
[1] | 1462 | AssertRC(rc);
|
---|
| 1463 | }
|
---|
| 1464 |
|
---|