VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/xpcom/glue/nsDebug.cpp@ 549

Last change on this file since 549 was 1, checked in by vboxsync, 55 years ago

import

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.1 KB
Line 
1/* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3 *
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/
8 *
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
12 * License.
13 *
14 * The Original Code is XPCOM
15 *
16 * The Initial Developer of the Original Code is Doug Turner <[email protected]>
17 *
18 * Portions created by the Initial Developer are Copyright (C) 2003
19 * the Initial Developer. All Rights Reserved.
20 *
21 * Contributor(s):
22 *
23 * Alternatively, the contents of this file may be used under the terms of
24 * either the GNU General Public License Version 2 or later (the "GPL"), or
25 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26 * in which case the provisions of the GPL or the LGPL are applicable instead
27 * of those above. If you wish to allow use of your version of this file only
28 * under the terms of either the GPL or the LGPL, and not to allow others to
29 * use your version of this file under the terms of the MPL, indicate your
30 * decision by deleting the provisions above and replace them with the notice
31 * and other provisions required by the GPL or the LGPL. If you do not delete
32 * the provisions above, a recipient may use your version of this file under
33 * the terms of any one of the MPL, the GPL or the LGPL.
34 *
35 * ***** END LICENSE BLOCK ***** */
36
37#include "nsXPCOM.h"
38#include "nsXPCOMPrivate.h"
39#include "nsCOMPtr.h"
40#include "nsIServiceManager.h"
41#include "nsDebug.h"
42#include "nsDebugImpl.h"
43
44static nsIDebug* gDebugObject = nsnull;
45
46static NS_METHOD FreeDebugObject(void)
47{
48 NS_IF_RELEASE(gDebugObject);
49 return NS_OK;
50}
51
52#define ENSURE_DEBUGOBJECT \
53 (gDebugObject ? PR_TRUE : (PRBool)(SetupDebugObject() != nsnull))
54
55static nsIDebug* SetupDebugObject()
56{
57 NS_GetDebug(&gDebugObject);
58 if (gDebugObject)
59 NS_RegisterXPCOMExitRoutine(FreeDebugObject, 0);
60 return gDebugObject;
61}
62
63#ifdef XPCOM_GLUE
64nsresult GlueStartupDebug()
65{
66 NS_GetDebug(&gDebugObject);
67 if (!gDebugObject)
68 return NS_ERROR_FAILURE;
69 return NS_OK;
70}
71
72void GlueShutdownDebug()
73{
74 NS_IF_RELEASE(gDebugObject);
75}
76#endif
77
78NS_COM void nsDebug::Abort(const char* aFile, PRIntn aLine)
79{
80 if (!ENSURE_DEBUGOBJECT)
81 return;
82
83 gDebugObject->Abort(aFile, aLine);
84}
85
86NS_COM void nsDebug::Break(const char* aFile, PRIntn aLine)
87{
88 if (!ENSURE_DEBUGOBJECT)
89 return;
90
91 gDebugObject->Break(aFile, aLine);
92}
93
94NS_COM void nsDebug::Warning(const char* aStr,
95 const char* aFile,
96 PRIntn aLine)
97{
98 if (!ENSURE_DEBUGOBJECT)
99 return;
100 gDebugObject->Warning(aStr, aFile, aLine);
101}
102
103NS_COM void nsDebug::Assertion(const char* aStr, const char* aExpr,
104 const char* aFile, PRIntn aLine)
105{
106 if (!ENSURE_DEBUGOBJECT)
107 return;
108 gDebugObject->Assertion(aStr, aExpr, aFile, aLine);
109}
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