VirtualBox

source: vbox/trunk/src/VBox/VMM/VMMR3/DBGFLog.cpp@ 39944

Last change on this file since 39944 was 39650, checked in by vboxsync, 13 years ago

DBGF,Main,VBoxManage: added target logger prefixes (release:/debug:). Implemented logger modifier methods in IMachineDebugger. Exposed these methods in VBoxManage debugvm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 6.0 KB
Line 
1/* $Id: DBGFLog.cpp 39650 2011-12-16 23:27:51Z vboxsync $ */
2/** @file
3 * DBGF - Debugger Facility, Log Manager.
4 */
5
6/*
7 * Copyright (C) 2006-2007 Oracle Corporation
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 (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18
19/*******************************************************************************
20* Header Files *
21*******************************************************************************/
22#include <VBox/vmm/vmapi.h>
23#include <VBox/vmm/vmm.h>
24#include <VBox/vmm/dbgf.h>
25#include <VBox/log.h>
26#include <VBox/err.h>
27#include <iprt/assert.h>
28#include <iprt/string.h>
29
30
31/*******************************************************************************
32* Internal Functions *
33*******************************************************************************/
34static DECLCALLBACK(int) dbgfR3LogModifyGroups(PVM pVM, const char *pszGroupSettings);
35static DECLCALLBACK(int) dbgfR3LogModifyFlags(PVM pVM, const char *pszFlagSettings);
36static DECLCALLBACK(int) dbgfR3LogModifyDestinations(PVM pVM, const char *pszDestSettings);
37
38
39/**
40 * Checkes for logger prefixes and selects the right logger.
41 *
42 * @returns Target logger.
43 * @param ppsz Pointer to the string pointer.
44 */
45static PRTLOGGER dbgfR3LogResolvedLogger(const char **ppsz)
46{
47 PRTLOGGER pLogger;
48 const char *psz = *ppsz;
49 if (!strncmp(psz, "release:", sizeof("release:") - 1))
50 {
51 *ppsz += sizeof("release:") - 1;
52 pLogger = RTLogRelDefaultInstance();
53 }
54 else
55 {
56 if (!strncmp(psz, "debug:", sizeof("debug:") - 1))
57 *ppsz += sizeof("debug:") - 1;
58 pLogger = RTLogDefaultInstance();
59 }
60 return pLogger;
61}
62
63
64/**
65 * Changes the logger group settings.
66 *
67 * @returns VBox status code.
68 * @param pVM The VM handle.
69 * @param pszGroupSettings The group settings string. (VBOX_LOG)
70 * By prefixing the string with \"release:\" the
71 * changes will be applied to the release log
72 * instead of the debug log. The prefix \"debug:\"
73 * is also recognized.
74 */
75VMMR3DECL(int) DBGFR3LogModifyGroups(PVM pVM, const char *pszGroupSettings)
76{
77 AssertPtrReturn(pVM, VERR_INVALID_POINTER);
78 AssertPtrReturn(pszGroupSettings, VERR_INVALID_POINTER);
79
80 return VMR3ReqPriorityCallWait(pVM, VMCPUID_ANY, (PFNRT)dbgfR3LogModifyGroups, 2, pVM, pszGroupSettings);
81}
82
83
84/**
85 * EMT worker for DBGFR3LogModifyGroups.
86 *
87 * @returns VBox status code.
88 * @param pVM The VM handle.
89 * @param pszGroupSettings The group settings string. (VBOX_LOG)
90 */
91static DECLCALLBACK(int) dbgfR3LogModifyGroups(PVM pVM, const char *pszGroupSettings)
92{
93 PRTLOGGER pLogger = dbgfR3LogResolvedLogger(&pszGroupSettings);
94 if (!pLogger)
95 return VINF_SUCCESS;
96
97 int rc = RTLogGroupSettings(pLogger, pszGroupSettings);
98 if (RT_SUCCESS(rc))
99 rc = VMMR3UpdateLoggers(pVM);
100 return rc;
101}
102
103
104/**
105 * Changes the logger flag settings.
106 *
107 * @returns VBox status code.
108 * @param pVM The VM handle.
109 * @param pszFlagSettings The group settings string. (VBOX_LOG_FLAGS)
110 * By prefixing the string with \"release:\" the
111 * changes will be applied to the release log
112 * instead of the debug log. The prefix \"debug:\"
113 * is also recognized.
114 */
115VMMR3DECL(int) DBGFR3LogModifyFlags(PVM pVM, const char *pszFlagSettings)
116{
117 AssertPtrReturn(pVM, VERR_INVALID_POINTER);
118 AssertPtrReturn(pszFlagSettings, VERR_INVALID_POINTER);
119
120 return VMR3ReqPriorityCallWait(pVM, VMCPUID_ANY, (PFNRT)dbgfR3LogModifyFlags, 2, pVM, pszFlagSettings);
121}
122
123
124/**
125 * EMT worker for DBGFR3LogModifyFlags.
126 *
127 * @returns VBox status code.
128 * @param pVM The VM handle.
129 * @param pszFlagSettings The group settings string. (VBOX_LOG_FLAGS)
130 */
131static DECLCALLBACK(int) dbgfR3LogModifyFlags(PVM pVM, const char *pszFlagSettings)
132{
133 PRTLOGGER pLogger = dbgfR3LogResolvedLogger(&pszFlagSettings);
134 if (!pLogger)
135 return VINF_SUCCESS;
136
137 int rc = RTLogFlags(pLogger, pszFlagSettings);
138 if (RT_SUCCESS(rc))
139 rc = VMMR3UpdateLoggers(pVM);
140 return rc;
141}
142
143
144/**
145 * Changes the logger destination settings.
146 *
147 * @returns VBox status code.
148 * @param pVM The VM handle.
149 * @param pszDestSettings The destination settings string. (VBOX_LOG_DEST)
150 * By prefixing the string with \"release:\" the
151 * changes will be applied to the release log
152 * instead of the debug log. The prefix \"debug:\"
153 * is also recognized.
154 */
155VMMR3DECL(int) DBGFR3LogModifyDestinations(PVM pVM, const char *pszDestSettings)
156{
157 AssertReturn(VALID_PTR(pVM), VERR_INVALID_POINTER);
158 AssertReturn(VALID_PTR(pszDestSettings), VERR_INVALID_POINTER);
159
160 return VMR3ReqPriorityCallWait(pVM, VMCPUID_ANY, (PFNRT)dbgfR3LogModifyDestinations, 2, pVM, pszDestSettings);
161}
162
163
164/**
165 * EMT worker for DBGFR3LogModifyFlags.
166 *
167 * @returns VBox status code.
168 * @param pVM The VM handle.
169 * @param pszDestSettings The destination settings string. (VBOX_LOG_DEST)
170 */
171static DECLCALLBACK(int) dbgfR3LogModifyDestinations(PVM pVM, const char *pszDestSettings)
172{
173 PRTLOGGER pLogger = dbgfR3LogResolvedLogger(&pszDestSettings);
174 if (!pLogger)
175 return VINF_SUCCESS;
176
177 int rc = RTLogDestinations(NULL, pszDestSettings);
178 if (RT_SUCCESS(rc))
179 rc = VMMR3UpdateLoggers(pVM);
180 return rc;
181}
182
Note: See TracBrowser for help on using the repository browser.

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