VirtualBox

Changeset 34902 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Dec 9, 2010 4:16:51 PM (14 years ago)
Author:
vboxsync
Message:

IMachineDebugger::dumpGuestCore: Added DBGFR3CoreWrite interface.

Location:
trunk/src/VBox
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Debugger/DBGCCommands.cpp

    r32313 r34902  
    21122112        return DBGCCmdHlpFail(pCmdHlp, pCmd, "Missing file path.\n");
    21132113
    2114     int rc = DBGFR3CoreWrite(pVM, pszDumpPath);
     2114    int rc = DBGFR3CoreWrite(pVM, pszDumpPath, true /*fReplaceFile*/);
    21152115    if (RT_FAILURE(rc))
    21162116        return DBGCCmdHlpFail(pCmdHlp, pCmd, "DBGFR3WriteCore failed. rc=%Rrc\n", rc);
  • trunk/src/VBox/Debugger/testcase/tstDBGCStubs.cpp

    r32313 r34902  
    237237}
    238238
    239 VMMR3DECL(int) DBGFR3CoreWrite(PVM pVM, const char *pszDumpPath)
     239VMMR3DECL(int) DBGFR3CoreWrite(PVM pVM, const char *pszFilename, bool fReplaceFile)
    240240{
    241241    return VERR_INTERNAL_ERROR;
  • trunk/src/VBox/Devices/VMMDev/VMMDev.cpp

    r34534 r34902  
    581581                     */
    582582                    PVM pVM = PDMDevHlpGetVM(pDevIns);
    583                     pRequestHeader->rc = DBGFR3CoreWrite(pVM, szCorePath);
     583                    pRequestHeader->rc = DBGFR3CoreWrite(pVM, szCorePath, true /*fReplaceFile*/);
    584584                }
    585585                else
  • trunk/src/VBox/Main/MachineDebuggerImpl.cpp

    r31698 r34902  
    718718
    719719/**
    720  * Set the new patch manager enabled flag.
    721  *
    722  * @returns COM status code
    723  * @param   new patch manager enabled flag
     720 * Injects an NMI.
     721 *
     722 * @returns COM status code
    724723 */
    725724STDMETHODIMP MachineDebugger::InjectNMI()
     
    738737
    739738    return S_OK;
     739}
     740
     741/**
     742 * Triggers a guest core dump.
     743 *
     744 * @returns COM status code
     745 * @param
     746 */
     747STDMETHODIMP MachineDebugger::DumpGuestCore(IN_BSTR a_bstrFilename)
     748{
     749    CheckComArgStrNotEmptyOrNull(a_bstrFilename);
     750    Utf8Str strFilename(a_bstrFilename);
     751
     752    AutoCaller autoCaller(this);
     753    HRESULT hrc = autoCaller.rc();
     754    if (SUCCEEDED(hrc))
     755    {
     756        AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     757        Console::SafeVMPtr ptrVM(mParent);
     758        hrc = ptrVM.rc();
     759        if (SUCCEEDED(hrc))
     760        {
     761            int vrc = DBGFR3CoreWrite(ptrVM, strFilename.c_str(), false /*fReplaceFile*/);
     762            if (RT_SUCCESS(vrc))
     763                hrc = S_OK;
     764            else
     765                hrc = setError(E_FAIL, tr("DBGFR3CoreWrite failed with %Rrc"), vrc);
     766        }
     767    }
     768
     769    return hrc;
    740770}
    741771
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r34899 r34902  
    1187511875  <interface
    1187611876    name="IMachineDebugger" extends="$unknown"
    11877     uuid="b0b2a2dd-0627-4502-91c2-ddc5e77609e0"
     11877    uuid="373a5f51-67c1-4a31-be43-1e29ebe8ef85"
    1187811878    wsmap="suppress"
    1187911879    >
     
    1191511915        Inject an NMI into a running VT-x/AMD-V VM.
    1191611916      </desc>
     11917    </method>
     11918
     11919    <method name="dumpGuestCore">
     11920      <desc>
     11921        Takes a core dump of the guest.
     11922
     11923        See include/VBox/dbgfcorefmt.h for details on the file format.
     11924      </desc>
     11925      <param name="filename" type="wstring" dir="in">
     11926        <desc>
     11927          The name of the output file.  The file must not exist.
     11928        </desc>
     11929      </param>
    1191711930    </method>
    1191811931
  • trunk/src/VBox/Main/include/MachineDebuggerImpl.h

    r31698 r34902  
    7373    STDMETHOD(COMGETTER(VM)) (LONG64 *aVm);
    7474    STDMETHOD(InjectNMI)();
     75    STDMETHOD(DumpGuestCore)(IN_BSTR a_bstrFilename);
    7576
    7677    // IMachineDebugger methods
  • trunk/src/VBox/VMM/DBGFCoreWrite.cpp

    r34197 r34902  
    6767#include "../Runtime/include/internal/ldrELF64.h"
    6868
     69
    6970/*******************************************************************************
    7071*   Defined Constants And Macros                                               *
     
    7677#define DBGFLOG_NAME           "DBGFCoreWrite"
    7778
     79
     80/*******************************************************************************
     81*   Global Variables                                                           *
     82*******************************************************************************/
    7883static const int s_NoteAlign  = 8;
    7984static const int s_cbNoteName = 16;
     
    8489
    8590
    86 /**
    87  * DBGFCOREDATA: Core data.
    88  */
    89 typedef struct
    90 {
    91     const char *pszDumpPath;    /* File path to dump the core into. */
    92 } DBGFCOREDATA, *PDBGFCOREDATA;
     91/*******************************************************************************
     92*   Structures and Typedefs                                                    *
     93*******************************************************************************/
     94/**
     95 * Guest core writer data.
     96 *
     97 * Used to pass parameters from DBGFR3CoreWrite to dbgfR3CoreWriteRendezvous.
     98 */
     99typedef struct DBGFCOREDATA
     100{
     101    /** The name of the file to write the file to. */
     102    const char *pszFilename;
     103    /** Whether to replace (/overwrite) any existing file. */
     104    bool        fReplaceFile;
     105} DBGFCOREDATA;
     106/** Pointer to the guest core writer data.  */
     107typedef DBGFCOREDATA *PDBGFCOREDATA;
     108
     109
    93110
    94111/**
     
    299316 * @returns VBox status code
    300317 * @param   pVM                 The VM handle.
    301  * @param   pDbgfData           The core dump parameters.
    302318 * @param   hFile               The file to write to.  Caller closes this.
    303319 */
    304 static int dbgfR3CoreWriteWorker(PVM pVM, PDBGFCOREDATA pDbgfData, RTFILE hFile)
     320static int dbgfR3CoreWriteWorker(PVM pVM, RTFILE hFile)
    305321{
    306322    /*
     
    487503 * @return VBox status code.
    488504 */
    489 static DECLCALLBACK(VBOXSTRICTRC) dbgfR3CoreWrite(PVM pVM, PVMCPU pVCpu, void *pvData)
     505static DECLCALLBACK(VBOXSTRICTRC) dbgfR3CoreWriteRendezvous(PVM pVM, PVMCPU pVCpu, void *pvData)
    490506{
    491507    /*
     
    501517     * Create the core file.
    502518     */
    503     RTFILE hFile;
    504     int rc = RTFileOpen(&hFile, pDbgfData->pszDumpPath, RTFILE_O_WRITE | RTFILE_O_CREATE_REPLACE | RTFILE_O_DENY_WRITE);
     519    uint32_t fFlags = (pDbgfData->fReplaceFile ? RTFILE_O_CREATE_REPLACE : RTFILE_O_CREATE)
     520                    | RTFILE_O_WRITE
     521                    | RTFILE_O_DENY_ALL
     522                    | (0600 << RTFILE_O_CREATE_MODE_SHIFT);
     523    RTFILE   hFile;
     524    int rc = RTFileOpen(&hFile, pDbgfData->pszFilename, fFlags);
    505525    if (RT_SUCCESS(rc))
    506526    {
    507         rc = dbgfR3CoreWriteWorker(pVM, pDbgfData, hFile);
     527        rc = dbgfR3CoreWriteWorker(pVM, hFile);
    508528        RTFileClose(hFile);
    509529    }
    510530    else
    511         LogRel((DBGFLOG_NAME ": RTFileOpen failed for '%s' rc=%Rrc\n", pDbgfData->pszDumpPath, rc));
     531        LogRel((DBGFLOG_NAME ": RTFileOpen failed for '%s' rc=%Rrc\n", pDbgfData->pszFilename, rc));
    512532    return rc;
    513533}
     
    517537 * Write core dump of the guest.
    518538 *
    519  * @return VBox status code.
     539 * @returns VBox status code.
    520540 * @param   pVM                 The VM handle.
    521  * @param   pszDumpPath         The path of the file to dump into, cannot be
    522  *                              NULL.
    523  *
    524  * @remarks The VM must be suspended before calling this function.
    525  */
    526 VMMR3DECL(int) DBGFR3CoreWrite(PVM pVM, const char *pszDumpPath)
     541 * @param   pszFilename         The name of the file to which the guest core
     542 *                              dump should be written.
     543 * @param   fReplaceFile        Whether to replace the file or not.
     544 *
     545 * @remarks The VM should be suspended before calling this function or DMA may
     546 *          interfer with the state.
     547 */
     548VMMR3DECL(int) DBGFR3CoreWrite(PVM pVM, const char *pszFilename, bool fReplaceFile)
    527549{
    528550    VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
    529     AssertReturn(pszDumpPath, VERR_INVALID_HANDLE);
     551    AssertReturn(pszFilename, VERR_INVALID_HANDLE);
    530552
    531553    /*
     
    536558    DBGFCOREDATA CoreData;
    537559    RT_ZERO(CoreData);
    538     CoreData.pszDumpPath = pszDumpPath;
    539 
    540     int rc = VMMR3EmtRendezvous(pVM, VMMEMTRENDEZVOUS_FLAGS_TYPE_ONCE, dbgfR3CoreWrite, &CoreData);
     560    CoreData.pszFilename  = pszFilename;
     561    CoreData.fReplaceFile = fReplaceFile;
     562
     563    int rc = VMMR3EmtRendezvous(pVM, VMMEMTRENDEZVOUS_FLAGS_TYPE_ONCE, dbgfR3CoreWriteRendezvous, &CoreData);
    541564    if (RT_SUCCESS(rc))
    542         LogRel((DBGFLOG_NAME ": Successfully wrote guest core dump %s\n", pszDumpPath));
     565        LogRel((DBGFLOG_NAME ": Successfully wrote guest core dump '%s'\n", pszFilename));
    543566    else
    544         LogRel((DBGFLOG_NAME ": Failed to write guest core dump %s. rc=%Rrc\n", pszDumpPath, rc));
     567        LogRel((DBGFLOG_NAME ": Failed to write guest core dump '%s'. rc=%Rrc\n", pszFilename, rc));
    545568    return rc;
    546569}
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