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