1 | /** @file
|
---|
2 | *
|
---|
3 | * VBox Debugger GUI.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006 InnoTek Systemberatung GmbH
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License as published by the Free Software Foundation,
|
---|
13 | * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
14 | * distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
15 | * be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * If you received this file as part of a commercial VirtualBox
|
---|
18 | * distribution, then only the terms of your commercial VirtualBox
|
---|
19 | * license agreement apply instead of the previous paragraph.
|
---|
20 | */
|
---|
21 |
|
---|
22 |
|
---|
23 | #define VBOX_COM_NO_ATL
|
---|
24 | #include <VBox/dbggui.h>
|
---|
25 | #include <VBox/vm.h>
|
---|
26 | #include <VBox/err.h>
|
---|
27 | #include <iprt/assert.h>
|
---|
28 | #include <iprt/alloc.h>
|
---|
29 |
|
---|
30 | #include "VBoxDbgGui.h"
|
---|
31 |
|
---|
32 |
|
---|
33 | /**
|
---|
34 | * Debugger GUI instance data.
|
---|
35 | */
|
---|
36 | typedef struct DBGGUI
|
---|
37 | {
|
---|
38 | /** Magic number (DBGGUI_MAGIC). */
|
---|
39 | uint32_t u32Magic;
|
---|
40 | /** Pointer to the Debugger GUI manager object. */
|
---|
41 | VBoxDbgGui *pVBoxDbgGui;
|
---|
42 | } DBGGUI;
|
---|
43 |
|
---|
44 | /** DBGGUI magic value (Elizabeth Kostova). */
|
---|
45 | #define DBGGUI_MAGIC 0x19640804
|
---|
46 |
|
---|
47 |
|
---|
48 | /**
|
---|
49 | * Creates the debugger GUI.
|
---|
50 | *
|
---|
51 | * @returns VBox status code.
|
---|
52 | * @param pSession The Virtual Box session.
|
---|
53 | * @param ppGui Where to store the pointer to the debugger instance.
|
---|
54 | */
|
---|
55 | DBGDECL(int) DBGGuiCreate(ISession *pSession, PDBGGUI *ppGui)
|
---|
56 | {
|
---|
57 | PDBGGUI pGui = (PDBGGUI)RTMemAlloc(sizeof(*pGui));
|
---|
58 | if (!pGui)
|
---|
59 | return VERR_NO_MEMORY;
|
---|
60 | pGui->u32Magic = DBGGUI_MAGIC;
|
---|
61 | pGui->pVBoxDbgGui = new VBoxDbgGui();
|
---|
62 |
|
---|
63 | int rc = pGui->pVBoxDbgGui->init(pSession);
|
---|
64 | if (VBOX_SUCCESS(rc))
|
---|
65 | {
|
---|
66 | *ppGui = pGui;
|
---|
67 | return rc;
|
---|
68 | }
|
---|
69 |
|
---|
70 | delete pGui->pVBoxDbgGui;
|
---|
71 | RTMemFree(pGui);
|
---|
72 | *ppGui = NULL;
|
---|
73 | return rc;
|
---|
74 | }
|
---|
75 |
|
---|
76 |
|
---|
77 | /**
|
---|
78 | * Destroys the debugger GUI.
|
---|
79 | *
|
---|
80 | * @returns VBox status code.
|
---|
81 | * @param pGui The instance returned by DBGGuiCreate().
|
---|
82 | */
|
---|
83 | DBGDECL(int) DBGGuiDestroy(PDBGGUI pGui)
|
---|
84 | {
|
---|
85 | /*
|
---|
86 | * Validate.
|
---|
87 | */
|
---|
88 | if (!pGui)
|
---|
89 | return VERR_INVALID_PARAMETER;
|
---|
90 | AssertMsgReturn(pGui->u32Magic == DBGGUI_MAGIC, ("u32Magic=%#x\n", pGui->u32Magic), VERR_INVALID_PARAMETER);
|
---|
91 |
|
---|
92 | /*
|
---|
93 | * Do the job.
|
---|
94 | */
|
---|
95 | pGui->u32Magic++;
|
---|
96 | delete pGui->pVBoxDbgGui;
|
---|
97 | RTMemFree(pGui);
|
---|
98 |
|
---|
99 | return VINF_SUCCESS;
|
---|
100 | }
|
---|
101 |
|
---|
102 |
|
---|
103 | /**
|
---|
104 | * Notifies the debugger GUI that the console window (or whatever) has changed
|
---|
105 | * size or position.
|
---|
106 | *
|
---|
107 | * @param pGui The instance returned by DBGGuiCreate().
|
---|
108 | * @param x The x-coordinate of the window the debugger is relative to.
|
---|
109 | * @param y The y-coordinate of the window the debugger is relative to.
|
---|
110 | * @param cx The width of the window the debugger is relative to.
|
---|
111 | * @param cy The height of the window the debugger is relative to.
|
---|
112 | */
|
---|
113 | DBGDECL(void) DBGGuiAdjustRelativePos(PDBGGUI pGui, int x, int y, unsigned cx, unsigned cy)
|
---|
114 | {
|
---|
115 | AssertReturn(pGui, (void)VERR_INVALID_PARAMETER);
|
---|
116 | AssertMsgReturn(pGui->u32Magic == DBGGUI_MAGIC, ("u32Magic=%#x\n", pGui->u32Magic), (void)VERR_INVALID_PARAMETER);
|
---|
117 | pGui->pVBoxDbgGui->adjustRelativePos(x, y, cx, cy);
|
---|
118 | }
|
---|
119 |
|
---|
120 |
|
---|
121 | /**
|
---|
122 | * Shows the default statistics window.
|
---|
123 | *
|
---|
124 | * @returns VBox status code.
|
---|
125 | * @param pGui The instance returned by DBGGuiCreate().
|
---|
126 | */
|
---|
127 | DBGDECL(int) DBGGuiShowStatistics(PDBGGUI pGui)
|
---|
128 | {
|
---|
129 | AssertReturn(pGui, VERR_INVALID_PARAMETER);
|
---|
130 | AssertMsgReturn(pGui->u32Magic == DBGGUI_MAGIC, ("u32Magic=%#x\n", pGui->u32Magic), VERR_INVALID_PARAMETER);
|
---|
131 | return pGui->pVBoxDbgGui->showStatistics();
|
---|
132 | }
|
---|
133 |
|
---|
134 |
|
---|
135 | /**
|
---|
136 | * Shows the default command line window.
|
---|
137 | *
|
---|
138 | * @returns VBox status code.
|
---|
139 | * @param pGui The instance returned by DBGGuiCreate().
|
---|
140 | */
|
---|
141 | DBGDECL(int) DBGGuiShowCommandLine(PDBGGUI pGui)
|
---|
142 | {
|
---|
143 | AssertReturn(pGui, VERR_INVALID_PARAMETER);
|
---|
144 | AssertMsgReturn(pGui->u32Magic == DBGGUI_MAGIC, ("u32Magic=%#x\n", pGui->u32Magic), VERR_INVALID_PARAMETER);
|
---|
145 | return pGui->pVBoxDbgGui->showConsole();
|
---|
146 | }
|
---|
147 |
|
---|