src/java.desktop/windows/native/libawt/windows/awt_Debug.cpp
author serb
Thu, 31 May 2018 09:24:27 -0700
changeset 50357 2e0c4b2d567b
parent 47216 71c04702a3d5
child 52744 8b066aaff367
permissions -rw-r--r--
8202051: Address compilation warnings in libawt with VS2017 Reviewed-by: prr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
50357
2e0c4b2d567b 8202051: Address compilation warnings in libawt with VS2017
serb
parents: 47216
diff changeset
     2
 * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
#include "awt.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
#include "awt_Toolkit.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#include "debug_mem.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
extern void DumpJavaStack();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#if defined(DEBUG)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
////////////////////////////////////////////////////////////////////////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
// avoid pulling in our redefinition of 'new'
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
// since we actually need to implement it here
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
#if defined(new)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
#undef new
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
void * operator new(size_t size, const char * filename, int linenumber) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    void * ptr = DMem_AllocateBlock(size, filename, linenumber);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    if (ptr == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
        throw std::bad_alloc();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    return ptr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
7772
bf119e738928 6999766: Changes to correct c/c++ language issues for use of parfait
dav
parents: 5506
diff changeset
    50
void * operator new[](size_t size, const char * filename, int linenumber) {
bf119e738928 6999766: Changes to correct c/c++ language issues for use of parfait
dav
parents: 5506
diff changeset
    51
    void * ptr = DMem_AllocateBlock(size, filename, linenumber);
bf119e738928 6999766: Changes to correct c/c++ language issues for use of parfait
dav
parents: 5506
diff changeset
    52
    if (ptr == NULL) {
bf119e738928 6999766: Changes to correct c/c++ language issues for use of parfait
dav
parents: 5506
diff changeset
    53
        throw std::bad_alloc();
bf119e738928 6999766: Changes to correct c/c++ language issues for use of parfait
dav
parents: 5506
diff changeset
    54
    }
bf119e738928 6999766: Changes to correct c/c++ language issues for use of parfait
dav
parents: 5506
diff changeset
    55
bf119e738928 6999766: Changes to correct c/c++ language issues for use of parfait
dav
parents: 5506
diff changeset
    56
    return ptr;
bf119e738928 6999766: Changes to correct c/c++ language issues for use of parfait
dav
parents: 5506
diff changeset
    57
}
bf119e738928 6999766: Changes to correct c/c++ language issues for use of parfait
dav
parents: 5506
diff changeset
    58
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
void operator delete(void *ptr, const char*, int) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    DASSERTMSG(FALSE, "This version of 'delete' should never get called!!!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
}
50357
2e0c4b2d567b 8202051: Address compilation warnings in libawt with VS2017
serb
parents: 47216
diff changeset
    62
2e0c4b2d567b 8202051: Address compilation warnings in libawt with VS2017
serb
parents: 47216
diff changeset
    63
void operator delete[](void *ptr, const char*, int) {
2e0c4b2d567b 8202051: Address compilation warnings in libawt with VS2017
serb
parents: 47216
diff changeset
    64
    DASSERTMSG(FALSE, "This version of 'delete' should never get called!!!");
2e0c4b2d567b 8202051: Address compilation warnings in libawt with VS2017
serb
parents: 47216
diff changeset
    65
}
2e0c4b2d567b 8202051: Address compilation warnings in libawt with VS2017
serb
parents: 47216
diff changeset
    66
7772
bf119e738928 6999766: Changes to correct c/c++ language issues for use of parfait
dav
parents: 5506
diff changeset
    67
void operator delete(void *ptr) throw() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    DMem_FreeBlock(ptr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
////////////////////////////////////////////////////////////////////////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
static void DumpRegion(HRGN rgn) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    DWORD size = ::GetRegionData(rgn, 0, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    char* buffer = (char *)safe_Malloc(size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    memset(buffer, 0, size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    LPRGNDATA rgndata = (LPRGNDATA)buffer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    rgndata->rdh.dwSize = sizeof(RGNDATAHEADER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    rgndata->rdh.iType = RDH_RECTANGLES;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    VERIFY(::GetRegionData(rgn, size, rgndata));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    RECT* r = (RECT*)(buffer + rgndata->rdh.dwSize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    for (DWORD i=0; i<rgndata->rdh.nCount; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        if ( !::IsRectEmpty(r) ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
            DTrace_PrintImpl("\trect %d %d %d %d\n", r->left, r->top, r->right, r->bottom);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        r++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    free(buffer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 * DTRACE print callback to dump HDC clip region bounding rectangle
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
void DumpClipRectangle(const char * file, int line, int argc, const char * fmt, va_list arglist) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    const char *msg = va_arg(arglist, const char *);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    HDC         hdc = va_arg(arglist, HDC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    RECT        r;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    DASSERT(argc == 2 && hdc != NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    DASSERT(msg != NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    ::GetClipBox(hdc, &r);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    DTrace_PrintImpl("%s: hdc=%x, %d %d %d %d\n", msg, hdc, r.left, r.top, r.right, r.bottom);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
 * DTRACE print callback to dump window's update region bounding rectangle
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
void DumpUpdateRectangle(const char * file, int line, int argc, const char * fmt, va_list arglist) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    const char *msg = va_arg(arglist, const char *);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    HWND        hwnd = va_arg(arglist, HWND);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    RECT        r;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    DASSERT(argc == 2 && ::IsWindow(hwnd));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    DASSERT(msg != NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    ::GetUpdateRect(hwnd, &r, FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    HRGN rgn = ::CreateRectRgn(0,0,1,1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    int updated = ::GetUpdateRgn(hwnd, rgn, FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    DTrace_PrintImpl("%s: hwnd=%x, %d %d %d %d\n", msg, hwnd, r.left, r.top, r.right, r.bottom);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    DumpRegion(rgn);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    DeleteObject(rgn);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
// Declare a static object to init/fini the debug code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
// specify that this static object will get constructed before
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
// any other static objects (except CRT objects) so the debug
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
// code can be used anywhere during the lifetime of the AWT dll
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
#pragma warning( disable:4073 ) // disable warning about using init_seg(lib) in non-3rd party library code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
#pragma init_seg( lib )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
static volatile AwtDebugSupport DebugSupport;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
static int report_leaks = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
AwtDebugSupport::AwtDebugSupport() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    DMem_Initialize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    DTrace_Initialize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    DAssert_SetCallback(AssertCallback);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
AwtDebugSupport::~AwtDebugSupport() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    if (report_leaks) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        DMem_ReportLeaks();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    DMem_Shutdown();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    DTrace_Shutdown();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
14883
524cf4063ab3 7180359: Assertion in awt_Win32GraphicsDevice.cpp when running specjbb in jprt
jgodinez
parents: 9035
diff changeset
   153
static jboolean isHeadless() {
524cf4063ab3 7180359: Assertion in awt_Win32GraphicsDevice.cpp when running specjbb in jprt
jgodinez
parents: 9035
diff changeset
   154
    jmethodID headlessFn;
524cf4063ab3 7180359: Assertion in awt_Win32GraphicsDevice.cpp when running specjbb in jprt
jgodinez
parents: 9035
diff changeset
   155
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
524cf4063ab3 7180359: Assertion in awt_Win32GraphicsDevice.cpp when running specjbb in jprt
jgodinez
parents: 9035
diff changeset
   156
    jclass graphicsEnvClass = env->FindClass(
524cf4063ab3 7180359: Assertion in awt_Win32GraphicsDevice.cpp when running specjbb in jprt
jgodinez
parents: 9035
diff changeset
   157
        "java/awt/GraphicsEnvironment");
524cf4063ab3 7180359: Assertion in awt_Win32GraphicsDevice.cpp when running specjbb in jprt
jgodinez
parents: 9035
diff changeset
   158
524cf4063ab3 7180359: Assertion in awt_Win32GraphicsDevice.cpp when running specjbb in jprt
jgodinez
parents: 9035
diff changeset
   159
    if (graphicsEnvClass != NULL) {
524cf4063ab3 7180359: Assertion in awt_Win32GraphicsDevice.cpp when running specjbb in jprt
jgodinez
parents: 9035
diff changeset
   160
        headlessFn = env->GetStaticMethodID(
524cf4063ab3 7180359: Assertion in awt_Win32GraphicsDevice.cpp when running specjbb in jprt
jgodinez
parents: 9035
diff changeset
   161
            graphicsEnvClass, "isHeadless", "()Z");
524cf4063ab3 7180359: Assertion in awt_Win32GraphicsDevice.cpp when running specjbb in jprt
jgodinez
parents: 9035
diff changeset
   162
        if (headlessFn != NULL) {
524cf4063ab3 7180359: Assertion in awt_Win32GraphicsDevice.cpp when running specjbb in jprt
jgodinez
parents: 9035
diff changeset
   163
            return env->CallStaticBooleanMethod(graphicsEnvClass,
524cf4063ab3 7180359: Assertion in awt_Win32GraphicsDevice.cpp when running specjbb in jprt
jgodinez
parents: 9035
diff changeset
   164
                                                headlessFn);
524cf4063ab3 7180359: Assertion in awt_Win32GraphicsDevice.cpp when running specjbb in jprt
jgodinez
parents: 9035
diff changeset
   165
        }
524cf4063ab3 7180359: Assertion in awt_Win32GraphicsDevice.cpp when running specjbb in jprt
jgodinez
parents: 9035
diff changeset
   166
    }
524cf4063ab3 7180359: Assertion in awt_Win32GraphicsDevice.cpp when running specjbb in jprt
jgodinez
parents: 9035
diff changeset
   167
    return true;
524cf4063ab3 7180359: Assertion in awt_Win32GraphicsDevice.cpp when running specjbb in jprt
jgodinez
parents: 9035
diff changeset
   168
}
524cf4063ab3 7180359: Assertion in awt_Win32GraphicsDevice.cpp when running specjbb in jprt
jgodinez
parents: 9035
diff changeset
   169
524cf4063ab3 7180359: Assertion in awt_Win32GraphicsDevice.cpp when running specjbb in jprt
jgodinez
parents: 9035
diff changeset
   170
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
void AwtDebugSupport::AssertCallback(const char * expr, const char * file, int line) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    static const int ASSERT_MSG_SIZE = 1024;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    static const char * AssertFmt =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
            "%s\r\n"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
            "File '%s', at line %d\r\n"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
            "GetLastError() is %x : %s\r\n"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
            "Do you want to break into the debugger?";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    static char assertMsg[ASSERT_MSG_SIZE+1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    DWORD   lastError = GetLastError();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    LPSTR       msgBuffer = NULL;
14883
524cf4063ab3 7180359: Assertion in awt_Win32GraphicsDevice.cpp when running specjbb in jprt
jgodinez
parents: 9035
diff changeset
   182
    int     ret = IDNO;
524cf4063ab3 7180359: Assertion in awt_Win32GraphicsDevice.cpp when running specjbb in jprt
jgodinez
parents: 9035
diff changeset
   183
    static jboolean headless = isHeadless();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER |
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
                  FORMAT_MESSAGE_FROM_SYSTEM |
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
                  FORMAT_MESSAGE_IGNORE_INSERTS,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
                  NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                  lastError,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                  MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                  (LPSTR)&msgBuffer, // it's an output parameter when allocate buffer is used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
                  0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
                  NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    if (msgBuffer == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        msgBuffer = "<Could not get GetLastError() message text>";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    // format the assertion message
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    _snprintf(assertMsg, ASSERT_MSG_SIZE, AssertFmt, expr, file, line, lastError, msgBuffer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    LocalFree(msgBuffer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    // tell the user the bad news
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    fprintf(stderr, "*********************\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    fprintf(stderr, "AWT Assertion Failure\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    fprintf(stderr, "*********************\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    fprintf(stderr, "%s\n", assertMsg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    fprintf(stderr, "*********************\n");
14883
524cf4063ab3 7180359: Assertion in awt_Win32GraphicsDevice.cpp when running specjbb in jprt
jgodinez
parents: 9035
diff changeset
   208
524cf4063ab3 7180359: Assertion in awt_Win32GraphicsDevice.cpp when running specjbb in jprt
jgodinez
parents: 9035
diff changeset
   209
    if (!headless) {
524cf4063ab3 7180359: Assertion in awt_Win32GraphicsDevice.cpp when running specjbb in jprt
jgodinez
parents: 9035
diff changeset
   210
        ret = MessageBoxA(NULL, assertMsg, "AWT Assertion Failure",
524cf4063ab3 7180359: Assertion in awt_Win32GraphicsDevice.cpp when running specjbb in jprt
jgodinez
parents: 9035
diff changeset
   211
                          MB_YESNO|MB_ICONSTOP|MB_TASKMODAL);
524cf4063ab3 7180359: Assertion in awt_Win32GraphicsDevice.cpp when running specjbb in jprt
jgodinez
parents: 9035
diff changeset
   212
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    // if clicked Yes, break into the debugger
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    if ( ret == IDYES ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        # if defined(_M_IX86)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
            _asm { int 3 };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        # else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
            DebugBreak();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        # endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    // otherwise, try to continue execution
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
void AwtDebugSupport::GenerateLeaksReport() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    report_leaks = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
#endif // DEBUG