VirtualBox

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

Last change on this file since 50653 was 46326, checked in by vboxsync, 11 years ago

RT_STR_TUPLE

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

© 2023 Oracle
ContactPrivacy policyTerms of Use