VirtualBox

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

Last change on this file was 98103, checked in by vboxsync, 16 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 6.5 KB
Line 
1/* $Id: DBGFLog.cpp 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * DBGF - Debugger Facility, Log Manager.
4 */
5
6/*
7 * Copyright (C) 2006-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28
29/*********************************************************************************************************************************
30* Header Files *
31*********************************************************************************************************************************/
32#define LOG_GROUP LOG_GROUP_DBGF
33#include <VBox/vmm/vmapi.h>
34#include <VBox/vmm/vmm.h>
35#include <VBox/vmm/dbgf.h>
36#include <VBox/vmm/uvm.h>
37#include <VBox/vmm/vm.h>
38#include <VBox/log.h>
39#include <VBox/err.h>
40#include <iprt/assert.h>
41#include <iprt/param.h>
42#include <iprt/string.h>
43
44
45/**
46 * Checkes for logger prefixes and selects the right logger.
47 *
48 * @returns Target logger.
49 * @param ppsz Pointer to the string pointer.
50 */
51static PRTLOGGER dbgfR3LogResolvedLogger(const char **ppsz)
52{
53 PRTLOGGER pLogger;
54 const char *psz = *ppsz;
55 if (!strncmp(psz, RT_STR_TUPLE("release:")))
56 {
57 *ppsz += sizeof("release:") - 1;
58 pLogger = RTLogRelGetDefaultInstance();
59 }
60 else
61 {
62 if (!strncmp(psz, RT_STR_TUPLE("debug:")))
63 *ppsz += sizeof("debug:") - 1;
64 pLogger = RTLogDefaultInstance();
65 }
66 return pLogger;
67}
68
69
70/**
71 * EMT worker for DBGFR3LogModifyGroups.
72 *
73 * @returns VBox status code.
74 * @param pUVM The user mode VM handle.
75 * @param pszGroupSettings The group settings string. (VBOX_LOG)
76 */
77static DECLCALLBACK(int) dbgfR3LogModifyGroups(PUVM pUVM, const char *pszGroupSettings)
78{
79 PRTLOGGER pLogger = dbgfR3LogResolvedLogger(&pszGroupSettings);
80 if (!pLogger)
81 return VINF_SUCCESS;
82
83 int rc = RTLogGroupSettings(pLogger, pszGroupSettings);
84 if (RT_SUCCESS(rc) && pUVM->pVM)
85 {
86 VM_ASSERT_VALID_EXT_RETURN(pUVM->pVM, VERR_INVALID_VM_HANDLE);
87 rc = VMMR3UpdateLoggers(pUVM->pVM);
88 }
89 return rc;
90}
91
92
93/**
94 * Changes the logger group settings.
95 *
96 * @returns VBox status code.
97 * @param pUVM The user mode VM handle.
98 * @param pszGroupSettings The group settings string. (VBOX_LOG)
99 * By prefixing the string with \"release:\" the
100 * changes will be applied to the release log
101 * instead of the debug log. The prefix \"debug:\"
102 * is also recognized.
103 */
104VMMR3DECL(int) DBGFR3LogModifyGroups(PUVM pUVM, const char *pszGroupSettings)
105{
106 UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
107 AssertPtrReturn(pszGroupSettings, VERR_INVALID_POINTER);
108
109 return VMR3ReqPriorityCallWaitU(pUVM, VMCPUID_ANY, (PFNRT)dbgfR3LogModifyGroups, 2, pUVM, pszGroupSettings);
110}
111
112
113/**
114 * EMT worker for DBGFR3LogModifyFlags.
115 *
116 * @returns VBox status code.
117 * @param pUVM The user mode VM handle.
118 * @param pszFlagSettings The group settings string. (VBOX_LOG_FLAGS)
119 */
120static DECLCALLBACK(int) dbgfR3LogModifyFlags(PUVM pUVM, const char *pszFlagSettings)
121{
122 PRTLOGGER pLogger = dbgfR3LogResolvedLogger(&pszFlagSettings);
123 if (!pLogger)
124 return VINF_SUCCESS;
125
126 int rc = RTLogFlags(pLogger, pszFlagSettings);
127 if (RT_SUCCESS(rc) && pUVM->pVM)
128 {
129 VM_ASSERT_VALID_EXT_RETURN(pUVM->pVM, VERR_INVALID_VM_HANDLE);
130 rc = VMMR3UpdateLoggers(pUVM->pVM);
131 }
132 return rc;
133}
134
135
136/**
137 * Changes the logger flag settings.
138 *
139 * @returns VBox status code.
140 * @param pUVM The user mode VM handle.
141 * @param pszFlagSettings The group settings string. (VBOX_LOG_FLAGS)
142 * By prefixing the string with \"release:\" the
143 * changes will be applied to the release log
144 * instead of the debug log. The prefix \"debug:\"
145 * is also recognized.
146 */
147VMMR3DECL(int) DBGFR3LogModifyFlags(PUVM pUVM, const char *pszFlagSettings)
148{
149 UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
150 AssertPtrReturn(pszFlagSettings, VERR_INVALID_POINTER);
151
152 return VMR3ReqPriorityCallWaitU(pUVM, VMCPUID_ANY, (PFNRT)dbgfR3LogModifyFlags, 2, pUVM, pszFlagSettings);
153}
154
155
156/**
157 * EMT worker for DBGFR3LogModifyFlags.
158 *
159 * @returns VBox status code.
160 * @param pUVM The user mode VM handle.
161 * @param pszDestSettings The destination settings string. (VBOX_LOG_DEST)
162 */
163static DECLCALLBACK(int) dbgfR3LogModifyDestinations(PUVM pUVM, const char *pszDestSettings)
164{
165 PRTLOGGER pLogger = dbgfR3LogResolvedLogger(&pszDestSettings);
166 if (!pLogger)
167 return VINF_SUCCESS;
168
169 int rc = RTLogDestinations(NULL, pszDestSettings);
170 if (RT_SUCCESS(rc) && pUVM->pVM)
171 {
172 VM_ASSERT_VALID_EXT_RETURN(pUVM->pVM, VERR_INVALID_VM_HANDLE);
173 rc = VMMR3UpdateLoggers(pUVM->pVM);
174 }
175 return rc;
176}
177
178
179/**
180 * Changes the logger destination settings.
181 *
182 * @returns VBox status code.
183 * @param pUVM The user mode VM handle.
184 * @param pszDestSettings The destination settings string. (VBOX_LOG_DEST)
185 * By prefixing the string with \"release:\" the
186 * changes will be applied to the release log
187 * instead of the debug log. The prefix \"debug:\"
188 * is also recognized.
189 */
190VMMR3DECL(int) DBGFR3LogModifyDestinations(PUVM pUVM, const char *pszDestSettings)
191{
192 UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
193 AssertPtrReturn(pszDestSettings, VERR_INVALID_POINTER);
194
195 return VMR3ReqPriorityCallWaitU(pUVM, VMCPUID_ANY, (PFNRT)dbgfR3LogModifyDestinations, 2, pUVM, pszDestSettings);
196}
197
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use