1 /*
   2  * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 #if !defined(_AWT_DEBUG_H)
  27 #define _AWT_DEBUG_H
  28 
  29 #include "debug_assert.h"
  30 #include "debug_trace.h"
  31 
  32 #if defined(DEBUG)
  33     #if defined(new)
  34         #error new has already been defined!
  35     #endif
  36     class AwtDebugSupport {
  37         public:
  38             AwtDebugSupport();
  39             ~AwtDebugSupport();
  40 
  41             static void AssertCallback(const char * expr, const char * file,
  42                                        int line);
  43             /* This method signals that the VM is exiting cleanly, and thus
  44                the debug memory manager should dump a leaks report when the
  45                VM has finished exiting. This method should not be called for
  46                termination exits (such as <CTRL>-C) */
  47             static void GenerateLeaksReport();
  48     };
  49 
  50     extern void * operator new(size_t size, const char * filename, int linenumber);
  51     extern void * operator new[](size_t size, const char * filename, int linenumber);
  52 
  53     extern void operator delete(void *ptr, const char*, int);
  54     extern void operator delete[](void *ptr, const char*, int);
  55 
  56     extern void operator delete(void *ptr) throw();
  57     extern void DumpClipRectangle(const char * file, int line, int argc, const char * fmt, va_list arglist);
  58     extern void DumpUpdateRectangle(const char * file, int line, int argc, const char * fmt, va_list arglist);
  59 
  60     #define AWT_DUMP_UPDATE_RECTANGLE(_msg, _hwnd) \
  61         _DTrace_Template(DumpUpdateRectangle, 2, "", (_msg), (_hwnd), 0, 0, 0, 0, 0, 0)
  62 
  63     #define AWT_DUMP_CLIP_RECTANGLE(_msg, _hwnd) \
  64         _DTrace_Template(DumpClipRectangle, 2, "", (_msg), (_hwnd), 0, 0, 0, 0, 0, 0)
  65 
  66     /* Use THIS_FILE when it is available. */
  67     #ifndef THIS_FILE
  68         #define THIS_FILE __FILE__
  69     #endif
  70 
  71     #define new         new(THIS_FILE, __LINE__)
  72 
  73     #define VERIFY(exp)         DASSERT(exp)
  74     #define UNIMPLEMENTED()     DASSERT(FALSE)
  75 
  76     /* Disable inlining. */
  77     #define INLINE
  78 #else
  79     #define AWT_DUMP_UPDATE_RECTANGLE(_msg, _hwnd) ((void)0)
  80     #define AWT_DUMP_CLIP_RECTANGLE(_msg, _hwnd) ((void)0)
  81 
  82     #define UNIMPLEMENTED() \
  83         SignalError(0, JAVAPKG "NullPointerException","unimplemented");
  84 
  85     /*
  86     * VERIFY macro -- assertion where expression is always evaluated
  87     * (normally used for BOOL functions).
  88     */
  89     #define VERIFY(exp) ((void)(exp))
  90 
  91     /* Enable inlining. */
  92     #define INLINE inline
  93 #endif // DEBUG
  94 
  95 #endif // _AWT_DEBUG_H