VirtualBox

Changeset 39477 in vbox


Ignore:
Timestamp:
Nov 30, 2011 4:02:17 PM (13 years ago)
Author:
vboxsync
Message:

VMM,VBoxManage,Main: Automatic map file loading for simplifying debugging.

Location:
trunk/src/VBox
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxInternalManage.cpp

    r38526 r39477  
    142142        "         incompatible ways without warning.\n",
    143143
     144        (u64Cmd & USAGE_LOADMAP)
     145        ? "  loadmap <vmname>|<uuid> <symfile> <address> [module] [subtrahend] [segment]\n"
     146          "      This will instruct DBGF to load the given map file\n"
     147          "      during initialization.  (See also loadmap in the debugger.)\n"
     148          "\n"
     149        : "",
    144150        (u64Cmd & USAGE_LOADSYMS)
    145151        ? "  loadsyms <vmname>|<uuid> <symfile> [delta] [module] [module address]\n"
    146           "      This will instruct DBGF to load the given symbolfile\n"
     152          "      This will instruct DBGF to load the given symbol file\n"
    147153          "      during initialization.\n"
    148           "\n"
    149         : "",
    150         (u64Cmd & USAGE_UNLOADSYMS)
    151         ? "  unloadsyms <vmname>|<uuid> <symfile>\n"
    152           "      Removes <symfile> from the list of symbol files that\n"
    153           "      should be loaded during DBF initialization.\n"
    154154          "\n"
    155155        : "",
     
    511511
    512512
     513/**
     514 * Identical to the 'loadmap' command.
     515 */
     516static int CmdLoadMap(int argc, char **argv, ComPtr<IVirtualBox> aVirtualBox, ComPtr<ISession> aSession)
     517{
     518    HRESULT rc;
     519
     520    /*
     521     * Get the VM
     522     */
     523    ComPtr<IMachine> machine;
     524    CHECK_ERROR_RET(aVirtualBox, FindMachine(Bstr(argv[0]).raw(),
     525                                             machine.asOutParam()), 1);
     526
     527    /*
     528     * Parse the command.
     529     */
     530    const char *pszFilename;
     531    uint64_t    ModuleAddress = UINT64_MAX;
     532    const char *pszModule = NULL;
     533    uint64_t    offSubtrahend = 0;
     534    uint32_t    iSeg = UINT32_MAX;
     535
     536    /* filename */
     537    if (argc < 2)
     538        return errorArgument("Missing the filename argument!\n");
     539    pszFilename = argv[1];
     540
     541    /* address */
     542    if (argc < 3)
     543        return errorArgument("Missing the module address argument!\n");
     544    int irc = RTStrToUInt64Ex(argv[2], NULL, 0, &ModuleAddress);
     545    if (RT_FAILURE(irc))
     546        return errorArgument(argv[0], "Failed to read module address '%s', rc=%Rrc\n", argv[2], rc);
     547
     548    /* name (optional) */
     549    if (argc > 3)
     550        pszModule = argv[3];
     551
     552    /* subtrahend (optional) */
     553    if (argc > 4)
     554    {
     555        irc = RTStrToUInt64Ex(argv[4], NULL, 0, &offSubtrahend);
     556        if (RT_FAILURE(irc))
     557            return errorArgument(argv[0], "Failed to read subtrahend '%s', rc=%Rrc\n", argv[4], rc);
     558    }
     559
     560    /* segment (optional) */
     561    if (argc > 5)
     562    {
     563        irc = RTStrToUInt32Ex(argv[5], NULL, 0, &iSeg);
     564        if (RT_FAILURE(irc))
     565            return errorArgument(argv[0], "Failed to read segment number '%s', rc=%Rrc\n", argv[5], rc);
     566    }
     567
     568    /*
     569     * Add extra data.
     570     */
     571    Utf8Str KeyStr;
     572    HRESULT hrc = NewUniqueKey(machine, "VBoxInternal/DBGF/loadmap", KeyStr);
     573    if (SUCCEEDED(hrc))
     574        hrc = SetString(machine, "VBoxInternal/DBGF/loadmap", KeyStr.c_str(), "Filename", pszFilename);
     575    if (SUCCEEDED(hrc))
     576        hrc = SetUInt64(machine, "VBoxInternal/DBGF/loadmap", KeyStr.c_str(), "Address", ModuleAddress);
     577    if (SUCCEEDED(hrc) && pszModule != NULL)
     578        hrc = SetString(machine, "VBoxInternal/DBGF/loadmap", KeyStr.c_str(), "Name", pszModule);
     579    if (SUCCEEDED(hrc) && offSubtrahend != 0)
     580        hrc = SetUInt64(machine, "VBoxInternal/DBGF/loadmap", KeyStr.c_str(), "Subtrahend", offSubtrahend);
     581    if (SUCCEEDED(hrc) && iSeg != UINT32_MAX)
     582        hrc = SetUInt64(machine, "VBoxInternal/DBGF/loadmap", KeyStr.c_str(), "Segment", iSeg);
     583
     584    return FAILED(hrc);
     585}
     586
     587
    513588static DECLCALLBACK(void) handleVDError(void *pvUser, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va)
    514589{
     
    21082183     */
    21092184    const char *pszCmd = a->argv[0];
     2185    if (!strcmp(pszCmd, "loadmap"))
     2186        return CmdLoadMap(a->argc - 1, &a->argv[1], a->virtualBox, a->session);
    21102187    if (!strcmp(pszCmd, "loadsyms"))
    21112188        return CmdLoadSyms(a->argc - 1, &a->argv[1], a->virtualBox, a->session);
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManage.h

    r39119 r39477  
    6868#define USAGE_SHAREDFOLDER_REMOVE   RT_BIT_64(26)
    6969#define USAGE_LOADSYMS              RT_BIT_64(29)
    70 #define USAGE_UNLOADSYMS            RT_BIT_64(30)
     70#define USAGE_LOADMAP               RT_BIT_64(30)
    7171#define USAGE_SETHDUUID             RT_BIT_64(31)
    7272#define USAGE_CONVERTFROMRAW        RT_BIT_64(32)
  • trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp

    r39450 r39477  
    663663    PUVM pUVM = pConsole->mpUVM = VMR3GetUVM(pVM);
    664664    VMR3RetainUVM(pUVM);
    665     int vrc = pConsole->configConstructorInner(pVM, &alock);
     665    int vrc;
     666    try
     667    {
     668        vrc = pConsole->configConstructorInner(pVM, &alock);
     669    }
     670    catch (...)
     671    {
     672        vrc = VERR_UNEXPECTED_EXCEPTION;
     673    }
    666674    if (RT_FAILURE(vrc))
    667675    {
     
    11171125#endif
    11181126        }
    1119         /*
    1120          * Enable 3 following devices: HPET, SMC, LPC on MacOS X guests or on ICH9 chipset
    1121          */
     1127
     1128        /*
     1129         * Enable the following devices: HPET, SMC and LPC on MacOS X guests or on ICH9 chipset
     1130         */
     1131
    11221132        /*
    11231133         * High Precision Event Timer (HPET)
     
    26312641                }
    26322642            }
     2643        }
     2644
     2645        /*
     2646         * Set up the default DBGF search paths if all is cool so far.
     2647         */
     2648        {
     2649            PCFGMNODE pDbgf;
     2650            InsertConfigNode(pRoot, "DBGF", &pDbgf);
     2651
     2652            hrc = pMachine->COMGETTER(SettingsFilePath)(bstr.asOutParam());         H();
     2653            Utf8Str strSettingsPath(bstr);
     2654            bstr.setNull();
     2655            strSettingsPath.stripFilename();
     2656
     2657            char szHomeDir[RTPATH_MAX];
     2658            rc = RTPathUserHome(szHomeDir, sizeof(szHomeDir));
     2659            if (RT_FAILURE(rc))
     2660                szHomeDir[0] = '\0';
     2661
     2662            Utf8Str strPath;
     2663            strPath.append(strSettingsPath).append("/debug/;");
     2664            strPath.append(strSettingsPath).append("/;");
     2665            strPath.append(szHomeDir).append("/");
     2666
     2667            InsertConfigString(pDbgf, "Path", strPath.c_str());
    26332668        }
    26342669    }
  • trunk/src/VBox/VMM/VMMR3/DBGFAddrSpace.cpp

    r39078 r39477  
    686686 * Same as dbgfR3AsSearchEnv, except that the path is taken from the environment.
    687687 *
    688  * It the environment variable doesn't exist, the current directory is searched instead.
     688 * If the environment variable doesn't exist, the current directory is searched
     689 * instead.
    689690 *
    690691 * @returns VBox status code.
     
    705706    else
    706707        rc = dbgfR3AsSearchPath(pszFilename, ".", pfnOpen, pvUser);
     708    return rc;
     709}
     710
     711
     712/**
     713 * Same as dbgfR3AsSearchEnv, except that the path is taken from the DBGF config
     714 * (CFGM).
     715 *
     716 * Nothing is done if the CFGM variable isn't set.
     717 *
     718 * @returns VBox status code.
     719 * @param   pszFilename     The filename.
     720 * @param   pszCfgValue     The name of the config variable (under /DBGF/).
     721 * @param   pfnOpen         The open callback function.
     722 * @param   pvUser          User argument for the callback.
     723 */
     724static int dbgfR3AsSearchCfgPath(PVM pVM, const char *pszFilename, const char *pszCfgValue, PFNDBGFR3ASSEARCHOPEN pfnOpen, void *pvUser)
     725{
     726    char *pszPath;
     727    int rc = CFGMR3QueryStringAllocDef(CFGMR3GetChild(CFGMR3GetRoot(pVM), "/DBGF"), pszCfgValue, &pszPath, NULL);
     728    if (RT_FAILURE(rc))
     729        return rc;
     730    if (!pszPath)
     731        return VERR_FILE_NOT_FOUND;
     732    rc = dbgfR3AsSearchPath(pszFilename, pszPath, pfnOpen, pvUser);
     733    MMR3HeapFree(pszPath);
    707734    return rc;
    708735}
     
    762789    Data.fFlags = 0;
    763790    Data.hMod = NIL_RTDBGMOD;
    764     int rc = dbgfR3AsSearchEnvPath(pszFilename, "VBOXDBG_IMAGE_PATH", dbgfR3AsLoadImageOpen, &Data);
     791    int rc = dbgfR3AsSearchCfgPath(pVM, pszFilename, "ImagePath", dbgfR3AsLoadImageOpen, &Data);
     792    if (RT_FAILURE(rc))
     793        rc = dbgfR3AsSearchEnvPath(pszFilename, "VBOXDBG_IMAGE_PATH", dbgfR3AsLoadImageOpen, &Data);
     794    if (RT_FAILURE(rc))
     795        rc = dbgfR3AsSearchCfgPath(pVM, pszFilename, "Path", dbgfR3AsLoadImageOpen, &Data);
    765796    if (RT_FAILURE(rc))
    766797        rc = dbgfR3AsSearchEnvPath(pszFilename, "VBOXDBG_PATH", dbgfR3AsLoadImageOpen, &Data);
     
    834865    Data.fFlags = 0;
    835866    Data.hMod = NIL_RTDBGMOD;
    836     int rc = dbgfR3AsSearchEnvPath(pszFilename, "VBOXDBG_MAP_PATH", dbgfR3AsLoadMapOpen, &Data);
     867    int rc = dbgfR3AsSearchCfgPath(pVM, pszFilename, "MapPath", dbgfR3AsLoadMapOpen, &Data);
     868    if (RT_FAILURE(rc))
     869        rc = dbgfR3AsSearchEnvPath(pszFilename, "VBOXDBG_MAP_PATH", dbgfR3AsLoadMapOpen, &Data);
     870    if (RT_FAILURE(rc))
     871        rc = dbgfR3AsSearchCfgPath(pVM, pszFilename, "Path", dbgfR3AsLoadMapOpen, &Data);
    837872    if (RT_FAILURE(rc))
    838873        rc = dbgfR3AsSearchEnvPath(pszFilename, "VBOXDBG_PATH", dbgfR3AsLoadMapOpen, &Data);
  • trunk/src/VBox/VMM/VMMR3/DBGFSym.cpp

    r39078 r39477  
    262262#endif
    263263
     264    /** @todo symbol search path setup. */
     265
    264266    /*
    265267     * Check if there are 'loadsyms' commands in the configuration.
     
    324326
    325327            MMR3HeapFree(pszModule);
     328            MMR3HeapFree(pszFilename);
     329        }
     330    }
     331
     332    /*
     333     * Check if there are 'loadmap' commands in the configuration.
     334     */
     335    pNode = CFGMR3GetChild(CFGMR3GetRoot(pVM), "/DBGF/loadmap/");
     336    if (pNode)
     337    {
     338        /*
     339         * Enumerate the commands.
     340         */
     341        for (PCFGMNODE pCmdNode = CFGMR3GetFirstChild(pNode);
     342             pCmdNode;
     343             pCmdNode = CFGMR3GetNextChild(pCmdNode))
     344        {
     345            char szCmdName[128];
     346            CFGMR3GetName(pCmdNode, &szCmdName[0], sizeof(szCmdName));
     347
     348            /* File */
     349            char *pszFilename;
     350            rc = CFGMR3QueryStringAlloc(pCmdNode, "Filename", &pszFilename);
     351            AssertMsgRCReturn(rc, ("rc=%Rrc querying the 'File' attribute of '/DBGF/loadsyms/%s'!\n", rc, szCmdName), rc);
     352
     353            /* Address. */
     354            RTGCPTR GCPtrAddr;
     355            rc = CFGMR3QueryGCPtrUDef(pNode, "Address", &GCPtrAddr, 0);
     356            AssertMsgRCReturn(rc, ("rc=%Rrc querying the 'Address' attribute of '/DBGF/loadsyms/%s'!\n", rc, szCmdName), rc);
     357            DBGFADDRESS ModAddr;
     358            DBGFR3AddrFromFlat(pVM, &ModAddr, GCPtrAddr);
     359
     360            /* Name (optional) */
     361            char *pszModName;
     362            rc = CFGMR3QueryStringAllocDef(pCmdNode, "Name", &pszModName, NULL);
     363            AssertMsgRCReturn(rc, ("rc=%Rrc querying the 'Name' attribute of '/DBGF/loadsyms/%s'!\n", rc, szCmdName), rc);
     364
     365            /* Subtrahend (optional) */
     366            RTGCPTR offSubtrahend;
     367            rc = CFGMR3QueryGCPtrDef(pNode, "Subtrahend", &offSubtrahend, 0);
     368            AssertMsgRCReturn(rc, ("rc=%Rrc querying the 'Subtrahend' attribute of '/DBGF/loadsyms/%s'!\n", rc, szCmdName), rc);
     369
     370            /* Segment (optional) */
     371            uint32_t iSeg;
     372            rc = CFGMR3QueryU32Def(pNode, "Segment", &iSeg, UINT32_MAX);
     373            AssertMsgRCReturn(rc, ("rc=%Rrc querying the 'Segment' attribute of '/DBGF/loadsyms/%s'!\n", rc, szCmdName), rc);
     374
     375            /*
     376             * Execute the command.
     377             */
     378            rc = DBGFR3AsLoadMap(pVM, DBGF_AS_GLOBAL, pszFilename, pszModName, &ModAddr,
     379                                 iSeg == UINT32_MAX ? NIL_RTDBGSEGIDX : iSeg, offSubtrahend, 0 /*fFlags*/);
     380            AssertMsgRCReturn(rc, ("pszFilename=%s pszModName=%s ModAddr=%RGv offSubtrahend=%#x iSeg=%#x\n",
     381                                   pszFilename, pszModName, ModAddr.FlatPtr, offSubtrahend, iSeg), rc);
     382
     383            MMR3HeapFree(pszModName);
    326384            MMR3HeapFree(pszFilename);
    327385        }
Note: See TracChangeset for help on using the changeset viewer.

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