File: memory.h

package info (click to toggle)
wxwidgets3.0 3.0.5.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 120,464 kB
  • sloc: cpp: 896,633; makefile: 52,303; ansic: 21,971; sh: 5,713; python: 2,940; xml: 1,534; perl: 264; javascript: 33
file content (223 lines) | stat: -rw-r--r-- 7,423 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
/////////////////////////////////////////////////////////////////////////////
// Name:        memory.h
// Purpose:     interface of wxDebugContext
// Author:      wxWidgets team
// Licence:     wxWindows licence
/////////////////////////////////////////////////////////////////////////////


/**
    @class wxDebugContext

    A class for performing various debugging and memory tracing operations.

    Full functionality (such as printing out objects currently allocated) is
    only present in a debugging build of wxWidgets, i.e. if the __WXDEBUG__
    symbol is defined. wxDebugContext and related functions and macros can be
    compiled out by setting wxUSE_DEBUG_CONTEXT to 0 is setup.h

    @library{wxbase}
    @category{debugging}

    @see @ref overview_debugging
*/
class wxDebugContext
{
public:
    /**
        Checks the memory blocks for errors, starting from the currently set
        checkpoint.

        @return Returns the number of errors, so a value of zero represents
                success. Returns -1 if an error was detected that prevents
                further checking.
    */
    static int Check(bool checkAll = false);

    /**
        Performs a memory dump from the currently set checkpoint, writing to the
        current debug stream. Calls the @b Dump member function for each wxObject
        derived instance.

        @return @true if the function succeeded, @false otherwise.
    */
    static bool Dump();

    /**
        Returns @true if the memory allocator checks all previous memory blocks for
        errors.

        By default, this is @false since it slows down execution considerably.

        @see SetCheckPrevious()
    */
    static bool GetCheckPrevious();

    /**
        Returns @true if debug mode is on.

        If debug mode is on, the wxObject new and delete operators store or use
        information about memory allocation. Otherwise, a straight malloc and
        free will be performed by these operators.

        @see SetDebugMode()
    */
    static bool GetDebugMode();

    /**
        Gets the debug level (default 1).

        The debug level is used by the wxTraceLevel function and the WXTRACELEVEL
        macro to specify how detailed the trace information is; setting a
        different level will only have an effect if trace statements in the
        application specify a value other than one.

        @deprecated
        This is obsolete, replaced by wxLog functionality.

        @see SetLevel()
    */
    static int GetLevel();

    /**
        Prints a list of the classes declared in this application, giving derivation
        and whether instances of this class can be dynamically created.

        @see PrintStatistics()
    */
    static bool PrintClasses();

    /**
        Performs a statistics analysis from the currently set checkpoint, writing
        to the current debug stream. The number of object and non-object
        allocations is printed, together with the total size.

        @param detailed
            If @true, the function will also print how many objects of each class
            have been allocated, and the space taken by these class instances.

        @see PrintStatistics()
    */
    static bool PrintStatistics(bool detailed = true);

    /**
        Tells the memory allocator to check all previous memory blocks for errors.
        By default, this is @false since it slows down execution considerably.

        @see GetCheckPrevious()
    */
    static void SetCheckPrevious(bool check);

    /**
        Sets the current checkpoint: Dump and PrintStatistics operations will
        be performed from this point on. This allows you to ignore allocations
        that have been performed up to this point.

        @param all
            If @true, the checkpoint is reset to include all memory allocations
            since the program started.
    */
    static void SetCheckpoint(bool all = false);

    /**
        Sets the debug mode on or off.

        If debug mode is on, the wxObject new and delete operators store or use
        information about memory allocation. Otherwise, a straight malloc and free
        will be performed by these operators.

        By default, debug mode is on if __WXDEBUG__ is defined. If the application
        uses this function, it should make sure that all object memory allocated
        is deallocated with the same value of debug mode. Otherwise, the delete
        operator might try to look for memory information that does not exist.

        @see GetDebugMode()
    */
    static void SetDebugMode(bool debug);

    /**
        Sets the debug level (default 1).

        The debug level is used by the wxTraceLevel function and the WXTRACELEVEL
        macro to specify how detailed the trace information is; setting
        a different level will only have an effect if trace statements in the
        application specify a value other than one.

        @deprecated
        This is obsolete, replaced by wxLog functionality.

        @see GetLevel()
    */
    static void SetLevel(int level);

    /**
        Installs a function to be called at the end of wxWidgets shutdown.
        It will be called after all files with global instances of
        wxDebugContextDumpDelayCounter have run their destructors.

        The shutdown function must be take no parameters and return nothing.
    */
    static void SetShutdownNotifyFunction(wxShutdownNotifyFunction func);
};



// ============================================================================
// Global functions/macros
// ============================================================================

/** @addtogroup group_funcmacro_log */
//@{

/**
    @deprecated Use one of the wxLogTrace() functions or one of the
                wxVLogTrace() functions instead.

    Calls wxTrace() with printf-style variable argument syntax. Output is
    directed to the current output stream (see wxDebugContext).

    @header{wx/memory.h}
*/
#define WXTRACE(format, ...)

/**
    @deprecated Use one of the wxLogTrace() functions or one of the
                wxVLogTrace() functions instead.

    Calls wxTraceLevel with printf-style variable argument syntax. Output is
    directed to the current output stream (see wxDebugContext). The first
    argument should be the level at which this information is appropriate. It
    will only be output if the level returned by wxDebugContext::GetLevel is
    equal to or greater than this value.

    @header{wx/memory.h}
*/
#define WXTRACELEVEL(level, format, ...)

/**
    @deprecated Use one of the wxLogTrace() functions or one of the
                wxVLogTrace() functions instead.

    Takes printf-style variable argument syntax. Output is directed to the
    current output stream (see wxDebugContext).

    @header{wx/memory.h}
*/
void wxTrace(const wxString& format, ...);

/**
    @deprecated Use one of the wxLogTrace() functions or one of the
                wxVLogTrace() functions instead.

    Takes @e printf() style variable argument syntax. Output is directed to the
    current output stream (see wxDebugContext). The first argument should be
    the level at which this information is appropriate. It will only be output
    if the level returned by wxDebugContext::GetLevel() is equal to or greater
    than this value.

    @header{wx/memory.h}
*/
void wxTraceLevel(int level, const wxString& format, ...);

//@}