debug.c 4.24 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/*
 * msvcrtd.dll debugging code
 *
 * Copyright (C) 2003 Adam Gundy
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 20 21 22
 */

#include "wine/debug.h"

23 24
#include "winbase.h"

25 26 27
#define  _DEBUG
#include "crtdbg.h"

28 29
WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);

30 31 32 33
int _crtAssertBusy = -1;
int _crtBreakAlloc = -1;
int _crtDbgFlag = 0;

34 35 36 37 38 39 40
#ifdef _WIN64
typedef unsigned __int64 MSVCRT_size_t;
#else
typedef unsigned long MSVCRT_size_t;
#endif

extern int _callnewh(MSVCRT_size_t);
41 42 43 44

/*********************************************************************
 *		??2@YAPAXIHPBDH@Z (MSVCRTD.@)
 */
45 46
void * CDECL MSVCRTD_operator_new_dbg(MSVCRT_size_t nSize, int nBlockUse,
                                      const char *szFileName, int nLine)
47
{
48
    void *retval = NULL;
49

50
    TRACE("(%lu, %d, '%s', %d)\n", nSize, nBlockUse, szFileName, nLine);
51

52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
    switch(_BLOCK_TYPE(nBlockUse))
    {
    case _NORMAL_BLOCK:
        break;
    case _CLIENT_BLOCK:
        FIXME("Unimplemented case for nBlockUse = _CLIENT_BLOCK\n");
        return NULL;
    case _FREE_BLOCK:
        FIXME("Native code throws an exception here\n");
    case _CRT_BLOCK:
    case _IGNORE_BLOCK:
        ERR("Not allowed nBlockUse value: %d\n", _BLOCK_TYPE(nBlockUse));
        return NULL;
    default:
        ERR("Unknown nBlockUse value: %d\n", _BLOCK_TYPE(nBlockUse));
        return NULL;
    }

    retval = HeapAlloc(GetProcessHeap(), 0, nSize);

72 73 74 75 76 77
    if (!retval)
        _callnewh(nSize);

    return retval;
}

78 79 80
/*********************************************************************
 *		_CrtSetDumpClient (MSVCRTD.@)
 */
81
void * CDECL _CrtSetDumpClient(void *dumpClient)
82 83 84 85 86 87 88 89
{
    return NULL;
}


/*********************************************************************
 *		_CrtSetReportHook (MSVCRTD.@)
 */
90
void * CDECL _CrtSetReportHook(void *reportHook)
91 92 93 94 95 96 97 98
{
    return NULL;
}


/*********************************************************************
 *		_CrtSetReportMode (MSVCRTD.@)
 */
99
int CDECL _CrtSetReportMode(int reportType, int reportMode)
100 101 102 103 104
{
    return 0;
}


105 106 107
/*********************************************************************
 *		_CrtSetBreakAlloc (MSVCRTD.@)
 */
108
int CDECL _CrtSetBreakAlloc(int new)
109 110 111 112 113 114
{
    int old = _crtBreakAlloc;
    _crtBreakAlloc = new;
    return old;
}

115 116 117
/*********************************************************************
 *		_CrtSetDbgFlag (MSVCRTD.@)
 */
118
int CDECL _CrtSetDbgFlag(int new)
119
{
120 121 122
    int old = _crtDbgFlag;
    _crtDbgFlag = new;
    return old;
123 124 125 126 127 128
}


/*********************************************************************
 *		_CrtDbgReport (MSVCRTD.@)
 */
129 130
int CDECL _CrtDbgReport(int reportType, const char *filename, int linenumber,
                        const char *moduleName, const char *format, ...)
131 132 133 134 135 136 137
{
    return 0;
}

/*********************************************************************
 *		_CrtDumpMemoryLeaks (MSVCRTD.@)
 */
138
int CDECL _CrtDumpMemoryLeaks(void)
139 140 141
{
    return 0;
}
142

143 144 145
/*********************************************************************
 *		_CrtCheckMemory (MSVCRTD.@)
 */
146
int CDECL _CrtCheckMemory(void)
147 148 149 150 151 152
{
    /* Note: maybe we could call here our heap validating functions ? */
    return TRUE;
}


153 154 155
/*********************************************************************
 *		__p__crtAssertBusy (MSVCRTD.@)
 */
156
int * CDECL __p__crtAssertBusy(void)
157 158 159 160 161 162 163
{
    return &_crtAssertBusy;
}

/*********************************************************************
 *		__p__crtBreakAlloc (MSVCRTD.@)
 */
164
int * CDECL __p__crtBreakAlloc(void)
165 166 167 168 169 170 171
{
    return &_crtBreakAlloc;
}

/*********************************************************************
 *		__p__crtDbgFlag (MSVCRTD.@)
 */
172
int * CDECL __p__crtDbgFlag(void)
173 174 175
{
    return &_crtDbgFlag;
}