VBoxDbg.cpp revision 677833bc953b6cb418c701facbdcf4aa18d6c44e
0N/A/** @file
3909N/A *
0N/A * VBox Debugger GUI.
0N/A */
0N/A
0N/A/*
2362N/A * Copyright (C) 2006 InnoTek Systemberatung GmbH
0N/A *
2362N/A * This file is part of VirtualBox Open Source Edition (OSE), as
0N/A * available from http://www.virtualbox.org. This file is free software;
0N/A * you can redistribute it and/or modify it under the terms of the GNU
0N/A * General Public License as published by the Free Software Foundation,
0N/A * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
0N/A * distribution. VirtualBox OSE is distributed in the hope that it will
0N/A * be useful, but WITHOUT ANY WARRANTY of any kind.
0N/A *
0N/A * If you received this file as part of a commercial VirtualBox
0N/A * distribution, then only the terms of your commercial VirtualBox
0N/A * license agreement apply instead of the previous paragraph.
0N/A */
2362N/A
2362N/A
2362N/A#define VBOX_COM_NO_ATL
0N/A#include <VBox/dbggui.h>
0N/A#include <VBox/vm.h>
0N/A#include <VBox/err.h>
0N/A#include <iprt/assert.h>
0N/A#include <iprt/alloc.h>
0N/A
0N/A#include "VBoxDbgGui.h"
0N/A
0N/A
0N/A/**
0N/A * Debugger GUI instance data.
0N/A */
0N/Atypedef struct DBGGUI
0N/A{
0N/A /** Magic number (DBGGUI_MAGIC). */
0N/A uint32_t u32Magic;
0N/A /** Pointer to the Debugger GUI manager object. */
0N/A VBoxDbgGui *pVBoxDbgGui;
0N/A} DBGGUI;
0N/A
0N/A/** DBGGUI magic value (Elizabeth Kostova). */
0N/A#define DBGGUI_MAGIC 0x19640804
0N/A
0N/A
0N/A/**
0N/A * Creates the debugger GUI.
0N/A *
0N/A * @returns VBox status code.
0N/A * @param pSession The Virtual Box session.
0N/A * @param ppGui Where to store the pointer to the debugger instance.
0N/A */
0N/ADBGDECL(int) DBGGuiCreate(ISession *pSession, PDBGGUI *ppGui)
0N/A{
0N/A PDBGGUI pGui = (PDBGGUI)RTMemAlloc(sizeof(*pGui));
0N/A if (!pGui)
0N/A return VERR_NO_MEMORY;
0N/A pGui->u32Magic = DBGGUI_MAGIC;
0N/A pGui->pVBoxDbgGui = new VBoxDbgGui();
0N/A
0N/A int rc = pGui->pVBoxDbgGui->init(pSession);
0N/A if (VBOX_SUCCESS(rc))
0N/A {
0N/A *ppGui = pGui;
0N/A return rc;
0N/A }
0N/A
0N/A delete pGui->pVBoxDbgGui;
0N/A RTMemFree(pGui);
0N/A *ppGui = NULL;
0N/A return rc;
0N/A}
0N/A
0N/A
0N/A/**
0N/A * Destroys the debugger GUI.
0N/A *
0N/A * @returns VBox status code.
0N/A * @param pGui The instance returned by DBGGuiCreate().
0N/A */
0N/ADBGDECL(int) DBGGuiDestroy(PDBGGUI pGui)
0N/A{
0N/A /*
0N/A * Validate.
0N/A */
0N/A if (!pGui)
0N/A return VERR_INVALID_PARAMETER;
0N/A AssertMsgReturn(pGui->u32Magic == DBGGUI_MAGIC, ("u32Magic=%#x\n", pGui->u32Magic), VERR_INVALID_PARAMETER);
0N/A
0N/A /*
0N/A * Do the job.
0N/A */
0N/A pGui->u32Magic++;
0N/A delete pGui->pVBoxDbgGui;
0N/A RTMemFree(pGui);
0N/A
0N/A return VINF_SUCCESS;
0N/A}
0N/A
0N/A
0N/A/**
0N/A * Notifies the debugger GUI that the console window (or whatever) has changed
0N/A * size or position.
0N/A *
0N/A * @param pGui The instance returned by DBGGuiCreate().
0N/A * @param x The x-coordinate of the window the debugger is relative to.
0N/A * @param y The y-coordinate of the window the debugger is relative to.
0N/A * @param cx The width of the window the debugger is relative to.
0N/A * @param cy The height of the window the debugger is relative to.
0N/A */
0N/ADBGDECL(void) DBGGuiAdjustRelativePos(PDBGGUI pGui, int x, int y, unsigned cx, unsigned cy)
0N/A{
0N/A AssertReturn(pGui, (void)VERR_INVALID_PARAMETER);
0N/A AssertMsgReturn(pGui->u32Magic == DBGGUI_MAGIC, ("u32Magic=%#x\n", pGui->u32Magic), (void)VERR_INVALID_PARAMETER);
0N/A pGui->pVBoxDbgGui->adjustRelativePos(x, y, cx, cy);
0N/A}
0N/A
0N/A
0N/A/**
0N/A * Shows the default statistics window.
0N/A *
0N/A * @returns VBox status code.
0N/A * @param pGui The instance returned by DBGGuiCreate().
0N/A */
0N/ADBGDECL(int) DBGGuiShowStatistics(PDBGGUI pGui)
0N/A{
0N/A AssertReturn(pGui, VERR_INVALID_PARAMETER);
0N/A AssertMsgReturn(pGui->u32Magic == DBGGUI_MAGIC, ("u32Magic=%#x\n", pGui->u32Magic), VERR_INVALID_PARAMETER);
0N/A return pGui->pVBoxDbgGui->showStatistics();
0N/A}
0N/A
0N/A
0N/A/**
0N/A * Shows the default command line window.
0N/A *
0N/A * @returns VBox status code.
0N/A * @param pGui The instance returned by DBGGuiCreate().
0N/A */
0N/ADBGDECL(int) DBGGuiShowCommandLine(PDBGGUI pGui)
0N/A{
0N/A AssertReturn(pGui, VERR_INVALID_PARAMETER);
0N/A AssertMsgReturn(pGui->u32Magic == DBGGUI_MAGIC, ("u32Magic=%#x\n", pGui->u32Magic), VERR_INVALID_PARAMETER);
0N/A return pGui->pVBoxDbgGui->showConsole();
0N/A}
0N/A
0N/A