debug.c 4.13 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
extern int _callnewh(unsigned long);

/*********************************************************************
 *		??2@YAPAXIHPBDH@Z (MSVCRTD.@)
 */
39
void * CDECL MSVCRTD_operator_new_dbg(
40 41 42 43 44
	unsigned long nSize,
	int nBlockUse,
	const char *szFileName,
	int nLine)
{
45
    void *retval = NULL;
46 47 48

    TRACE("(%lu, %d, '%s', %d) returning %p\n", nSize, nBlockUse, szFileName, nLine, retval);

49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
    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);

69 70 71 72 73 74
    if (!retval)
        _callnewh(nSize);

    return retval;
}

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


/*********************************************************************
 *		_CrtSetReportHook (MSVCRTD.@)
 */
87
void * CDECL _CrtSetReportHook(void *reportHook)
88 89 90 91 92 93 94 95
{
    return NULL;
}


/*********************************************************************
 *		_CrtSetReportMode (MSVCRTD.@)
 */
96
int CDECL _CrtSetReportMode(int reportType, int reportMode)
97 98 99 100 101
{
    return 0;
}


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

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


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

/*********************************************************************
 *		_CrtDumpMemoryLeaks (MSVCRTD.@)
 */
135
int CDECL _CrtDumpMemoryLeaks(void)
136 137 138
{
    return 0;
}
139

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


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

/*********************************************************************
 *		__p__crtBreakAlloc (MSVCRTD.@)
 */
161
int * CDECL __p__crtBreakAlloc(void)
162 163 164 165 166 167 168
{
    return &_crtBreakAlloc;
}

/*********************************************************************
 *		__p__crtDbgFlag (MSVCRTD.@)
 */
169
int * CDECL __p__crtDbgFlag(void)
170 171 172
{
    return &_crtDbgFlag;
}