Changeset 19193 in vbox
- Timestamp:
- Apr 27, 2009 2:39:31 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/DBGFSym.cpp
r19190 r19193 25 25 *******************************************************************************/ 26 26 #define LOG_GROUP LOG_GROUP_DBGF 27 #if defined(RT_OS_WINDOWS) && 0 //defined(DEBUG_bird) // enabled this is you want to debug win32 guests or the hypervisor.27 #if defined(RT_OS_WINDOWS) && 0 //defined(DEBUG_bird) // enabled this is you want to debug win32 guests, the hypervisor of EFI. 28 28 # include <Windows.h> 29 29 # define _IMAGEHLP64 … … 41 41 #include <iprt/assert.h> 42 42 43 #include <iprt/path.h> 44 #include <iprt/ctype.h> 45 #include <iprt/env.h> 46 #include <iprt/param.h> 43 47 #ifndef HAVE_DBGHELP 44 48 # include <iprt/avl.h> 45 49 # include <iprt/string.h> 46 # include <iprt/ctype.h>47 50 #endif 48 51 … … 548 551 } 549 552 553 /** 554 * Tries to open the file using the image search paths. 555 * 556 * This is currently a quick hack and the only way to specifying the path is by setting 557 * VBOXDBG_IMAGE_PATH in the environment. It uses semicolon as separator everywhere. 558 * 559 * @returns VBox status code. 560 * @param pVM The VM handle. 561 * @param pszFilename The name of the file to locate and open. 562 * @param pszFound Where to return the actual filename. 563 * @param cchFound The buffer size. 564 * @param ppFile Where to return the opened file. 565 */ 566 int dbgfR3ModuleLocateAndOpen(PVM pVM, const char *pszFilename, char *pszFound, size_t cchFound, FILE **ppFile) 567 { 568 /* Check the filename length. */ 569 size_t const cchFilename = strlen(pszFilename); 570 if (cchFilename >= cchFound) 571 return VERR_FILENAME_TOO_LONG; 572 const char *pszName = RTPathFilename(pszFilename); 573 if (!pszName) 574 return VERR_IS_A_DIRECTORY; 575 size_t const cchName = strlen(pszName); 576 577 /* 578 * Try default location first. 579 */ 580 memcpy(pszFound, pszFilename, cchFilename + 1); 581 FILE *pFile = *ppFile = fopen(pszFound, "rb"); 582 if (pFile) 583 return VINF_SUCCESS; 584 585 /* 586 * Walk the search path. 587 */ 588 const char *psz = RTEnvGet("VBOXDBG_IMAGE_PATH"); 589 if (!psz) 590 psz = "."; /* default */ 591 while (*psz) 592 { 593 /* Skip leading blanks - no directories with leading spaces, thank you. */ 594 while (RT_C_IS_BLANK(*psz)) 595 psz++; 596 597 /* Fine the end of this element. */ 598 const char *pszNext; 599 const char *pszEnd = strchr(psz, ';'); 600 if (!pszEnd) 601 pszEnd = pszNext = strchr(psz, '\0'); 602 else 603 pszNext = pszEnd + 1; 604 if (pszEnd != psz) 605 { 606 size_t const cch = pszEnd - psz; 607 if (cch + 1 + cchName < cchFound) 608 { 609 /** @todo RTPathCompose, RTPathComposeN(). This code isn't right 610 * for 'E:' on DOS systems. It may also create unwanted double slashes. */ 611 memcpy(pszFound, psz, cch); 612 pszFound[cch] = '/'; 613 memcpy(pszFound + cch + 1, pszName, cchName + 1); 614 *ppFile = pFile = fopen(pszFound, "rb"); 615 if (pFile) 616 return VINF_SUCCESS; 617 } 618 619 /** @todo do a depth search using the specified path. */ 620 } 621 622 /* advance */ 623 psz = pszNext; 624 } 625 626 /* not found */ 627 return VERR_OPEN_FAILED; 628 } 629 550 630 551 631 /** … … 578 658 * Open the load file. 579 659 */ 580 int rc = VINF_SUCCESS; 581 FILE *pFile = fopen(pszFilename, "rb"); 660 FILE *pFile; 661 char szFoundFile[RTPATH_MAX]; 662 int rc = dbgfR3ModuleLocateAndOpen(pVM, pszFilename, szFoundFile, sizeof(szFoundFile), &pFile); 582 663 if (pFile) 583 664 { … … 595 676 #ifdef HAVE_DBGHELP 596 677 /** @todo arg! checkout the inserting of modules and then loading them again.... Or just the module representation.... */ 597 DWORD64 ImageBase = SymLoadModule64(pVM, NULL, (char *)(void *) pszFilename, (char *)(void *)pszName, ModuleAddress, cbImage);678 DWORD64 ImageBase = SymLoadModule64(pVM, NULL, (char *)(void *)szFoundFile, (char *)(void *)pszName, ModuleAddress, cbImage); 598 679 if (!ImageBase) 599 680 ImageBase = SymLoadModule64(pVM, NULL, (char *)(void *)pszName, (char *)(void *)pszName, ModuleAddress, cbImage); … … 652 733 fclose(pFile); 653 734 } 654 else655 rc = VERR_OPEN_FAILED;656 735 return rc; 657 736 }
Note:
See TracChangeset
for help on using the changeset viewer.