VirtualBox

Changeset 39477 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Nov 30, 2011 4:02:17 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
75132
Message:

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

Location:
trunk/src/VBox/Frontends/VBoxManage
Files:
2 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)
Note: See TracChangeset for help on using the changeset viewer.

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