2003-07-08 02:11:36 +04:00
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1998-03-28 05:44:41 +03:00
|
|
|
*
|
2003-07-08 02:11:36 +04:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
1998-03-28 05:44:41 +03:00
|
|
|
*
|
2003-07-08 02:11:36 +04:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
1999-11-06 06:43:54 +03:00
|
|
|
*
|
2003-07-08 02:11:36 +04:00
|
|
|
* The Original Code is XPCOM
|
1999-11-06 06:43:54 +03:00
|
|
|
*
|
2003-07-08 02:11:36 +04:00
|
|
|
* The Initial Developer of the Original Code is Doug Turner <dougt@meer.net>
|
|
|
|
*
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2003
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1998-03-28 05:44:41 +03:00
|
|
|
|
2003-07-08 02:11:36 +04:00
|
|
|
#include "nsXPCOM.h"
|
|
|
|
#include "nsXPCOMPrivate.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIServiceManager.h"
|
1998-03-28 05:44:41 +03:00
|
|
|
#include "nsDebug.h"
|
2003-07-08 02:11:36 +04:00
|
|
|
#include "nsDebugImpl.h"
|
2000-05-12 05:09:58 +04:00
|
|
|
|
2003-07-08 02:11:36 +04:00
|
|
|
static nsIDebug* gDebugObject = nsnull;
|
1998-12-24 01:13:47 +03:00
|
|
|
|
2003-07-08 02:11:36 +04:00
|
|
|
static NS_METHOD FreeDebugObject(void)
|
1999-12-07 02:34:48 +03:00
|
|
|
{
|
2003-07-08 02:11:36 +04:00
|
|
|
NS_IF_RELEASE(gDebugObject);
|
|
|
|
return NS_OK;
|
1999-12-07 02:34:48 +03:00
|
|
|
}
|
|
|
|
|
2003-07-08 02:11:36 +04:00
|
|
|
#define ENSURE_DEBUGOBJECT \
|
|
|
|
(gDebugObject ? PR_TRUE : (PRBool)(SetupDebugObject() != nsnull))
|
2000-10-29 02:17:53 +04:00
|
|
|
|
2003-07-08 02:11:36 +04:00
|
|
|
static nsIDebug* SetupDebugObject()
|
2000-10-29 02:17:53 +04:00
|
|
|
{
|
2003-07-08 02:11:36 +04:00
|
|
|
NS_GetDebug(&gDebugObject);
|
|
|
|
if (gDebugObject)
|
|
|
|
NS_RegisterXPCOMExitRoutine(FreeDebugObject, 0);
|
|
|
|
return gDebugObject;
|
2000-10-29 02:17:53 +04:00
|
|
|
}
|
1998-03-28 05:44:41 +03:00
|
|
|
|
2003-07-08 02:11:36 +04:00
|
|
|
#ifdef XPCOM_GLUE
|
|
|
|
nsresult GlueStartupDebug()
|
1999-10-01 01:39:31 +04:00
|
|
|
{
|
2003-07-08 02:11:36 +04:00
|
|
|
NS_GetDebug(&gDebugObject);
|
|
|
|
if (!gDebugObject)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
return NS_OK;
|
1999-12-07 02:34:48 +03:00
|
|
|
}
|
1999-10-01 01:39:31 +04:00
|
|
|
|
2003-07-08 02:11:36 +04:00
|
|
|
void GlueShutdownDebug()
|
1999-12-07 02:34:48 +03:00
|
|
|
{
|
2003-07-08 02:11:36 +04:00
|
|
|
NS_IF_RELEASE(gDebugObject);
|
1999-10-01 01:39:31 +04:00
|
|
|
}
|
2000-02-16 11:06:00 +03:00
|
|
|
#endif
|
1998-03-28 05:44:41 +03:00
|
|
|
|
2004-10-29 23:43:51 +04:00
|
|
|
NS_COM_GLUE void nsDebug::Abort(const char* aFile, PRIntn aLine)
|
2003-07-08 02:11:36 +04:00
|
|
|
{
|
|
|
|
if (!ENSURE_DEBUGOBJECT)
|
|
|
|
return;
|
|
|
|
|
|
|
|
gDebugObject->Abort(aFile, aLine);
|
|
|
|
}
|
2000-01-25 00:28:28 +03:00
|
|
|
|
2004-10-29 23:43:51 +04:00
|
|
|
NS_COM_GLUE void nsDebug::Break(const char* aFile, PRIntn aLine)
|
2003-07-08 02:11:36 +04:00
|
|
|
{
|
|
|
|
if (!ENSURE_DEBUGOBJECT)
|
|
|
|
return;
|
|
|
|
|
|
|
|
gDebugObject->Break(aFile, aLine);
|
2000-01-25 00:28:28 +03:00
|
|
|
}
|
|
|
|
|
2004-10-29 23:43:51 +04:00
|
|
|
NS_COM_GLUE void nsDebug::Warning(const char* aStr,
|
2003-07-08 02:11:36 +04:00
|
|
|
const char* aFile,
|
|
|
|
PRIntn aLine)
|
|
|
|
{
|
|
|
|
if (!ENSURE_DEBUGOBJECT)
|
|
|
|
return;
|
|
|
|
gDebugObject->Warning(aStr, aFile, aLine);
|
2000-03-05 13:14:50 +03:00
|
|
|
}
|
|
|
|
|
2004-10-29 23:43:51 +04:00
|
|
|
NS_COM_GLUE void nsDebug::Assertion(const char* aStr, const char* aExpr,
|
2003-07-08 02:11:36 +04:00
|
|
|
const char* aFile, PRIntn aLine)
|
|
|
|
{
|
|
|
|
if (!ENSURE_DEBUGOBJECT)
|
|
|
|
return;
|
|
|
|
gDebugObject->Assertion(aStr, aExpr, aFile, aLine);
|
2000-03-08 12:21:32 +03:00
|
|
|
}
|