Changeset 8800 in vbox for trunk/src/VBox
- Timestamp:
- May 14, 2008 3:03:54 AM (17 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Debugger/DBGCCommands.cpp
r8155 r8800 67 67 static DECLCALLBACK(int) dbgcCmdEcho(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult); 68 68 static DECLCALLBACK(int) dbgcCmdRunScript(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult); 69 static DECLCALLBACK(int) dbgcCmdDetect(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult); 69 70 70 71 … … 167 168 { "exit", 0, 0, NULL, 0, NULL, 0, dbgcCmdQuit, "", "Exits the debugger." }, 168 169 { "format", 1, 1, &g_aArgAny[0], ELEMENTS(g_aArgAny), NULL, 0, dbgcCmdFormat, "", "Evaluates an expression and formats it." }, 170 { "detect", 0, 0, NULL, 0, NULL, 0, dbgcCmdDetect, "", "Detects or re-detects the guest os and starts the OS specific digger." }, 169 171 { "harakiri", 0, 0, NULL, 0, NULL, 0, dbgcCmdHarakiri, "", "Kills debugger process." }, 170 172 { "help", 0, ~0, &g_aArgHelp[0], ELEMENTS(g_aArgHelp), NULL, 0, dbgcCmdHelp, "[cmd/op [..]]", "Display help. For help about info items try 'info help'." }, … … 716 718 717 719 NOREF(pCmd); NOREF(pResult); NOREF(pVM); 720 return rc; 721 } 722 723 724 /** 725 * The 'detect' command. 726 * 727 * @returns VBox status. 728 * @param pCmd Pointer to the command descriptor (as registered). 729 * @param pCmdHlp Pointer to command helper functions. 730 * @param pVM Pointer to the current VM (if any). 731 * @param paArgs Pointer to (readonly) array of arguments. 732 * @param cArgs Number of arguments in the array. 733 */ 734 static DECLCALLBACK(int) dbgcCmdDetect(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult) 735 { 736 /* check that the parser did what it's supposed to do. */ 737 if (cArgs != 0) 738 return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "parser error\n"); 739 740 /* 741 * Perform the detection. 742 */ 743 char szName[64]; 744 int rc = DBGFR3OSDetect(pVM, szName, sizeof(szName)); 745 if (RT_FAILURE(rc)) 746 return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "Executing DBGFR3OSDetect()."); 747 if (rc == VINF_SUCCESS) 748 { 749 rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "Guest OS: %s\n", szName); 750 char szVersion[64]; 751 int rc2 = DBGFR3OSQueryNameAndVersion(pVM, NULL, 0, szVersion, sizeof(szVersion)); 752 if (RT_SUCCESS(rc2)) 753 rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "Version : %s\n", szVersion); 754 } 755 else 756 rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "Unable to figure out which guest OS it is, sorry.\n"); 757 NOREF(pCmd); NOREF(pResult); NOREF(paArgs); 718 758 return rc; 719 759 } -
trunk/src/VBox/Debugger/DBGConsole.cpp
r8155 r8800 158 158 159 159 #include "DBGCInternal.h" 160 #include "DBGPlugIns.h" 160 161 161 162 … … 2047 2048 rc = pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, 2048 2049 "Current VM is %08x\n" /** @todo get and print the VM name! */ 2049 "VBoxDbg> ", 2050 pDbgc->pVM); 2050 , pDbgc->pVM); 2051 2051 } 2052 2052 else 2053 2053 rc = pDbgc->CmdHlp.pfnVBoxError(&pDbgc->CmdHlp, rc, "When trying to attach to VM %p\n", pDbgc->pVM); 2054 2054 } 2055 else 2055 2056 /* 2057 * Load plugins. 2058 * This is currently hardcoded simplicity. 2059 */ 2060 if (RT_SUCCESS(rc) && pVM) 2061 { 2062 static PCDBGFOSREG s_aPlugIns[] = 2063 { 2064 //&g_DBGDiggerFreeBSD, 2065 //&g_DBGDiggerLinux, 2066 //&g_DBGDiggerOS2, 2067 &g_DBGDiggerSolaris, 2068 //&g_DBGDiggerWinNt 2069 }; 2070 2071 pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, "Loading Plugins:"); 2072 for (unsigned i = 0; i < RT_ELEMENTS(s_aPlugIns); i++) 2073 { 2074 pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, " %s", s_aPlugIns[i]->szName); 2075 rc = DBGFR3OSRegister(pVM, s_aPlugIns[i]); 2076 if (RT_FAILURE(rc) && rc != VERR_ALREADY_LOADED) 2077 pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, "->%Rrc", rc); 2078 } 2079 pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, "\n"); 2080 } 2081 2082 if (RT_SUCCESS(rc)) 2056 2083 rc = pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, 2057 2084 "VBoxDbg> "); 2058 2085 2059 2086 /* 2060 * Run the main loop.2087 * Run the debugger main loop. 2061 2088 */ 2062 2089 if (RT_SUCCESS(rc)) -
trunk/src/VBox/Debugger/Makefile.kmk
r8760 r8800 56 56 DBGCEmulateCodeView.cpp \ 57 57 DBGCOps.cpp \ 58 DBGCTcp.cpp 58 DBGCTcp.cpp \ 59 DBGPlugInSolaris.cpp 59 60 60 61 -
trunk/src/VBox/Debugger/testcase/tstDBGCStubs.cpp
r8160 r8800 282 282 return VERR_INTERNAL_ERROR; 283 283 } 284 DBGFR3DECL(int) DBGFR3MemRead(PVM pVM, PCDBGFADDRESS pAddress, void *pvBuf, size_t cbRead) 285 { 286 return VERR_INTERNAL_ERROR; 287 } 284 288 DBGFR3DECL(void) DBGFR3AddrFromPhys(PVM pVM, PDBGFADDRESS pAddress, RTGCPHYS PhysAddr) 285 289 { 286 290 } 291 DBGFR3DECL(int) DBGFR3OSRegister(PVM pVM, PCDBGFOSREG pReg) 292 { 293 return VERR_INTERNAL_ERROR; 294 } 295 DBGFR3DECL(int) DBGFR3OSDetect(PVM pVM, char *pszName, size_t cchName) 296 { 297 return VERR_INTERNAL_ERROR; 298 } 299 DBGFR3DECL(int) DBGFR3OSQueryNameAndVersion(PVM pVM, char *pszName, size_t cchName, char *pszVersion, size_t cchVersion) 300 { 301 return VERR_INTERNAL_ERROR; 302 } -
trunk/src/VBox/VMM/DBGFMem.cpp
r8155 r8800 116 116 117 117 118 /** 119 * Read guest memory. 120 * 121 * @returns VBox status code. 122 * @param pVM Pointer to the shared VM structure. 123 * @param pAddress Where to start reading. 124 * @param pvBuf Where to store the data we've read. 125 * @param cbRead The number of bytes to read. 126 */ 127 static DECLCALLBACK(int) dbgfR3MemRead(PVM pVM, PCDBGFADDRESS pAddress, void *pvBuf, size_t cbRead) 128 { 129 /* 130 * Validate the input we use, PGM does the rest. 131 */ 132 if (!DBGFR3AddrIsValid(pVM, pAddress)) 133 return VERR_INVALID_POINTER; 134 if (!VALID_PTR(pvBuf)) 135 return VERR_INVALID_POINTER; 136 if (DBGFADDRESS_IS_HMA(pAddress)) 137 return VERR_INVALID_POINTER; 138 139 /* 140 * Select DBGF worker by addressing mode. 141 */ 142 int rc; 143 PGMMODE enmMode = PGMGetGuestMode(pVM); 144 if ( enmMode == PGMMODE_REAL 145 || enmMode == PGMMODE_PROTECTED 146 || DBGFADDRESS_IS_PHYS(pAddress) ) 147 rc = PGMPhysReadGCPhys(pVM, pvBuf, pAddress->FlatPtr, cbRead); 148 else 149 rc = PGMPhysReadGCPtr(pVM, pvBuf, pAddress->FlatPtr, cbRead); 150 return rc; 151 } 152 153 154 /** 155 * Read guest memory. 156 * 157 * @returns VBox status code. 158 * @param pVM Pointer to the shared VM structure. 159 * @param pAddress Where to start reading. 160 * @param pvBuf Where to store the data we've read. 161 * @param cbRead The number of bytes to read. 162 */ 163 DBGFR3DECL(int) DBGFR3MemRead(PVM pVM, PCDBGFADDRESS pAddress, void *pvBuf, size_t cbRead) 164 { 165 PVMREQ pReq; 166 int rc = VMR3ReqCallU(pVM->pUVM, &pReq, RT_INDEFINITE_WAIT, 0, (PFNRT)dbgfR3MemRead, 4, 167 pVM, pAddress, pvBuf, cbRead); 168 if (VBOX_SUCCESS(rc)) 169 rc = pReq->iStatus; 170 VMR3ReqFree(pReq); 171 172 return rc; 173 } -
trunk/src/VBox/VMM/DBGFOS.cpp
r8797 r8800 38 38 39 39 /** 40 * EMT worker function for DBGFR3OSRegister. 41 * 42 * @returns VBox status code. 43 * @param pVM Pointer to the shared VM structure. 44 * @param pReg The registration structure. 45 */ 46 static DECLCALLBACK(int) dbgfR3OSRegister(PVM pVM, PDBGFOSREG pReg) 47 { 48 /* more validations. */ 49 for (PDBGFOS pOS = pVM->dbgf.s.pOSHead; pOS; pOS = pOS->pNext) 50 if (!strcmp(pOS->pReg->szName, pReg->szName)) 51 { 52 Log(("dbgfR3OSRegister: %s -> VERR_ALREADY_LOADED\n", pReg->szName)); 53 return VERR_ALREADY_LOADED; 54 } 55 56 /* 57 * Allocate a new structure, call the constructor and link it into the list. 58 */ 59 PDBGFOS pOS = (PDBGFOS)MMR3HeapAllocZ(pVM, MM_TAG_DBGF_OS, RT_OFFSETOF(DBGFOS, abData[pReg->cbData])); 60 AssertReturn(pOS, VERR_NO_MEMORY); 61 pOS->pReg = pReg; 62 63 int rc = pOS->pReg->pfnConstruct(pVM, pOS->abData); 64 if (RT_SUCCESS(rc)) 65 { 66 pOS->pNext = pVM->dbgf.s.pOSHead; 67 pVM->dbgf.s.pOSHead = pOS; 68 } 69 else 70 { 71 if (pOS->pReg->pfnDestruct) 72 pOS->pReg->pfnDestruct(pVM, pOS->abData); 73 MMR3HeapFree(pOS); 74 } 75 76 return VINF_SUCCESS; 77 } 78 79 80 /** 40 81 * Registers a guest OS digger. 41 82 * … … 46 87 * @param pVM Pointer to the shared VM structure. 47 88 * @param pReg The registration structure. 48 */ 49 DBGFR3DECL(int) DBGFR3OSRegister(PVM pVM, PDBGFOSREG pReg) 89 * @thread Any. 90 */ 91 DBGFR3DECL(int) DBGFR3OSRegister(PVM pVM, PCDBGFOSREG pReg) 50 92 { 51 93 /* 52 94 * Validate intput. 53 95 */ 54 VM_ASSERT_EMT_RETURN(pVM, VERR_VM_THREAD_NOT_EMT);55 96 AssertPtrReturn(pReg, VERR_INVALID_POINTER); 56 97 AssertReturn(pReg->u32Magic == DBGFOSREG_MAGIC, VERR_INVALID_MAGIC); … … 58 99 AssertReturn(!pReg->fFlags, VERR_INVALID_PARAMETER); 59 100 AssertReturn(pReg->cbData < _2G, VERR_INVALID_PARAMETER); 60 AssertReturn( !pReg->szName[0], VERR_INVALID_NAME);101 AssertReturn(pReg->szName[0], VERR_INVALID_NAME); 61 102 AssertReturn(memchr(&pReg->szName[0], '\0', sizeof(pReg->szName)), VERR_INVALID_NAME); 62 103 AssertPtrReturn(pReg->pfnConstruct, VERR_INVALID_POINTER); … … 68 109 AssertPtrReturn(pReg->pfnQueryVersion, VERR_INVALID_POINTER); 69 110 AssertPtrReturn(pReg->pfnQueryInterface, VERR_INVALID_POINTER); 70 for (PDBGFOS pOS = pVM->dbgf.s.pOSHead; pOS; pOS = pOS->pNext) 71 AssertMsgReturn(!strcmp(pOS->pReg->szName, pReg->szName), ("%s\n", pReg->szName), VERR_ALREADY_EXISTS); 72 73 /* 74 * Allocate a new structure, call the constructor and link it into the list. 75 */ 76 PDBGFOS pOS = (PDBGFOS)MMR3HeapAllocZ(pVM, MM_TAG_DBGF_OS, RT_OFFSETOF(DBGFOS, abData[pReg->cbData])); 77 AssertReturn(pOS, VERR_NO_MEMORY); 78 pOS->pReg = pReg; 79 80 int rc = pOS->pReg->pfnConstruct(pVM, pOS->abData); 111 112 /* 113 * Pass it on to the EMT. 114 */ 115 PVMREQ pReq; 116 int rc = VMR3ReqCallU(pVM->pUVM, &pReq, RT_INDEFINITE_WAIT, 0, (PFNRT)dbgfR3OSRegister, 2, pVM, pReg); 81 117 if (RT_SUCCESS(rc)) 82 { 83 pOS->pNext = pVM->dbgf.s.pOSHead; 84 pVM->dbgf.s.pOSHead = pOS; 85 } 86 else 87 { 88 if (pOS->pReg->pfnDestruct) 89 pOS->pReg->pfnDestruct(pVM, pOS->abData); 90 MMR3HeapFree(pOS); 91 } 92 93 return VINF_SUCCESS; 118 rc = pReq->iStatus; 119 VMR3ReqFree(pReq); 120 121 return rc; 94 122 } 95 123 … … 126 154 127 155 /** 128 * Detectes the guest OS and try dig out symbols and useful stuff. 129 * 130 * When called the 2nd time, symbols will be updated that if the OS 131 * is the same. 156 * EMT worker function for DBGFR3OSDetect. 132 157 * 133 158 * @returns VBox status code. … … 139 164 * @param cchName Size of the buffer. 140 165 */ 141 DBGFR3DECL(int) DBGFR3OSDetect(PVM pVM, char *pszName, size_t cchName) 142 { 143 VM_ASSERT_EMT_RETURN(pVM, VERR_VM_THREAD_NOT_EMT); 144 AssertPtrNullReturn(pszName, VERR_INVALID_POINTER); 145 166 static DECLCALLBACK(int) dbgfR3OSDetect(PVM pVM, char *pszName, size_t cchName) 167 { 146 168 /* 147 169 * Cycle thru the detection routines. 148 170 */ 149 if (pszName && cchName)150 *pszName = '\0';151 171 PDBGFOS const pOldOS = pVM->dbgf.s.pCurOS; 152 172 pVM->dbgf.s.pCurOS = NULL; … … 178 198 179 199 /** 180 * Queries the name and/or version string for the guest OS. 181 * 182 * It goes without saying that this querying is done using the current 183 * guest OS digger and not additions or user configuration. 200 * Detectes the guest OS and try dig out symbols and useful stuff. 201 * 202 * When called the 2nd time, symbols will be updated that if the OS 203 * is the same. 204 * 205 * @returns VBox status code. 206 * @retval VINF_SUCCESS if successfully detected. 207 * @retval VINF_DBGF_OS_NOT_DETCTED if we cannot figure it out. 208 * 209 * @param pVM Pointer to the shared VM structure. 210 * @param pszName Where to store the OS name. Empty string if not detected. 211 * @param cchName Size of the buffer. 212 * @thread Any. 213 */ 214 DBGFR3DECL(int) DBGFR3OSDetect(PVM pVM, char *pszName, size_t cchName) 215 { 216 AssertPtrNullReturn(pszName, VERR_INVALID_POINTER); 217 if (pszName && cchName) 218 *pszName = '\0'; 219 220 /* 221 * Pass it on to the EMT. 222 */ 223 PVMREQ pReq; 224 int rc = VMR3ReqCallU(pVM->pUVM, &pReq, RT_INDEFINITE_WAIT, 0, (PFNRT)dbgfR3OSDetect, 3, pVM, pszName, cchName); 225 if (RT_SUCCESS(rc)) 226 rc = pReq->iStatus; 227 VMR3ReqFree(pReq); 228 229 return rc; 230 } 231 232 233 /** 234 * EMT worker function for DBGFR3OSQueryNameAndVersion 184 235 * 185 236 * @returns VBox status code. … … 190 241 * @param cchVersion The size of the version buffer. 191 242 */ 192 DBGFR3DECL(int) DBGFR3OSNameAndVersion(PVM pVM, char *pszName, size_t cchName, char *pszVersion, size_t cchVersion) 193 { 194 VM_ASSERT_EMT_RETURN(pVM, VERR_VM_THREAD_NOT_EMT); 195 AssertPtrNullReturn(pszName, VERR_INVALID_POINTER); 196 AssertPtrNullReturn(pszVersion, VERR_INVALID_POINTER); 197 198 /* 199 * Initialize the output up front. 200 */ 201 if (pszName && cchName) 202 *pszName = '\0'; 203 if (pszVersion && cchVersion) 204 *pszVersion = '\0'; 205 243 static DECLCALLBACK(int) dbgfR3OSQueryNameAndVersion(PVM pVM, char *pszName, size_t cchName, char *pszVersion, size_t cchVersion) 244 { 206 245 /* 207 246 * Any known OS? … … 237 276 238 277 /** 278 * Queries the name and/or version string for the guest OS. 279 * 280 * It goes without saying that this querying is done using the current 281 * guest OS digger and not additions or user configuration. 282 * 283 * @returns VBox status code. 284 * @param pVM Pointer to the shared VM structure. 285 * @param pszName Where to store the OS name. Optional. 286 * @param cchName The size of the name buffer. 287 * @param pszVersion Where to store the version string. Optional. 288 * @param cchVersion The size of the version buffer. 289 * @thread Any. 290 */ 291 DBGFR3DECL(int) DBGFR3OSQueryNameAndVersion(PVM pVM, char *pszName, size_t cchName, char *pszVersion, size_t cchVersion) 292 { 293 AssertPtrNullReturn(pszName, VERR_INVALID_POINTER); 294 AssertPtrNullReturn(pszVersion, VERR_INVALID_POINTER); 295 296 /* 297 * Initialize the output up front. 298 */ 299 if (pszName && cchName) 300 *pszName = '\0'; 301 if (pszVersion && cchVersion) 302 *pszVersion = '\0'; 303 304 /* 305 * Pass it on to the EMT. 306 */ 307 PVMREQ pReq; 308 int rc = VMR3ReqCallU(pVM->pUVM, &pReq, RT_INDEFINITE_WAIT, 0, (PFNRT)dbgfR3OSQueryNameAndVersion, 309 5, pVM, pszName, cchName, pszVersion, cchVersion); 310 if (RT_SUCCESS(rc)) 311 rc = pReq->iStatus; 312 VMR3ReqFree(pReq); 313 314 return rc; 315 } 316 317 318 /** 319 * EMT worker for DBGFR3OSQueryInterface. 320 * 321 * @param pVM Pointer to the shared VM structure. 322 * @param enmIf The interface identifier. 323 * @param ppvIf Where to store the interface pointer on success. 324 */ 325 static DECLCALLBACK(void) dbgfR3OSQueryInterface(PVM pVM, DBGFOSINTERFACE enmIf, void **ppvIf) 326 { 327 if (pVM->dbgf.s.pCurOS) 328 { 329 *ppvIf = pVM->dbgf.s.pCurOS->pReg->pfnQueryInterface(pVM, pVM->dbgf.s.pCurOS->abData, enmIf); 330 if (*ppvIf) 331 { 332 /** @todo Create EMT wrapper for the returned interface once we've defined one... 333 * Just keep a list of wrapper together with the OS instance. */ 334 } 335 } 336 else 337 *ppvIf = NULL; 338 } 339 340 341 /** 239 342 * Query an optional digger interface. 240 343 * … … 243 346 * @param pVM Pointer to the shared VM structure. 244 347 * @param enmIf The interface identifier. 348 * @thread Any. 245 349 */ 246 350 DBGFR3DECL(void *) DBGFR3OSQueryInterface(PVM pVM, DBGFOSINTERFACE enmIf) 247 351 { 248 352 AssertMsgReturn(enmIf > DBGFOSINTERFACE_INVALID && enmIf < DBGFOSINTERFACE_END, ("%d\n", enmIf), NULL); 249 if (pVM->dbgf.s.pCurOS) 250 return pVM->dbgf.s.pCurOS->pReg->pfnQueryInterface(pVM, pVM->dbgf.s.pCurOS->abData, enmIf); 251 return NULL; 252 } 253 353 354 /* 355 * Pass it on to the EMT. 356 */ 357 void *pvIf = NULL; 358 PVMREQ pReq; 359 VMR3ReqCallVoidU(pVM->pUVM, &pReq, RT_INDEFINITE_WAIT, (PFNRT)dbgfR3OSQueryInterface, 3, pVM, enmIf, &pvIf); 360 VMR3ReqFree(pReq); 361 362 return pvIf; 363 } 364
Note:
See TracChangeset
for help on using the changeset viewer.