~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/ut/ut0dbg.c

  • Committer: Brian Aker
  • Date: 2008-10-28 08:36:02 UTC
  • mfrom: (520.4.13 merge-innodb-plugin)
  • Revision ID: brian@tangent.org-20081028083602-0p3zzlhlxr5q2sqo
Merging Monty's work

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
**********************************************************************/
8
8
 
9
9
#include "univ.i"
 
10
#include "ut0dbg.h"
10
11
 
11
12
#if defined(__GNUC__) && (__GNUC__ > 2)
12
13
#else
13
14
/* This is used to eliminate compiler warnings */
14
 
ulint   ut_dbg_zero     = 0;
 
15
UNIV_INTERN ulint       ut_dbg_zero     = 0;
15
16
#endif
16
17
 
17
18
#if defined(UNIV_SYNC_DEBUG) || !defined(UT_DBG_USE_ABORT)
18
19
/* If this is set to TRUE all threads will stop into the next assertion
19
20
and assert */
20
 
ibool   ut_dbg_stop_threads     = FALSE;
 
21
UNIV_INTERN ibool       ut_dbg_stop_threads     = FALSE;
21
22
#endif
22
 
#if !defined(UT_DBG_USE_ABORT)
 
23
#ifdef __NETWARE__
 
24
/* This is set to TRUE when on NetWare there happens an InnoDB
 
25
assertion failure or other fatal error condition that requires an
 
26
immediate shutdown. */
 
27
UNIV_INTERN ibool panic_shutdown = FALSE;
 
28
#elif !defined(UT_DBG_USE_ABORT)
23
29
/* Null pointer used to generate memory trap */
24
 
 
25
 
ulint*  ut_dbg_null_ptr         = NULL;
 
30
UNIV_INTERN ulint*      ut_dbg_null_ptr         = NULL;
26
31
#endif
27
32
 
28
33
/*****************************************************************
29
34
Report a failed assertion. */
30
 
 
 
35
UNIV_INTERN
31
36
void
32
37
ut_dbg_assertion_failed(
33
38
/*====================*/
60
65
#endif
61
66
}
62
67
 
 
68
#ifdef __NETWARE__
 
69
/*****************************************************************
 
70
Shut down MySQL/InnoDB after assertion failure. */
 
71
UNIV_INTERN
 
72
void
 
73
ut_dbg_panic(void)
 
74
/*==============*/
 
75
{
 
76
        if (!panic_shutdown) {
 
77
                panic_shutdown = TRUE;
 
78
                innobase_shutdown_for_mysql();
 
79
        }
 
80
        exit(1);
 
81
}
 
82
#else /* __NETWARE__ */
63
83
# if defined(UNIV_SYNC_DEBUG) || !defined(UT_DBG_USE_ABORT)
64
84
/*****************************************************************
65
85
Stop a thread after assertion failure. */
66
 
 
 
86
UNIV_INTERN
67
87
void
68
88
ut_dbg_stop_thread(
69
89
/*===============*/
75
95
        os_thread_sleep(1000000000);
76
96
}
77
97
# endif
 
98
#endif /* __NETWARE__ */
 
99
 
 
100
#ifdef UNIV_COMPILE_TEST_FUNCS
 
101
 
 
102
#include <sys/types.h>
 
103
#include <sys/time.h>
 
104
#include <sys/resource.h>
 
105
 
 
106
#include <unistd.h>
 
107
 
 
108
#ifndef timersub
 
109
#define timersub(a, b, r)                                               \
 
110
        do {                                                            \
 
111
                (r)->tv_sec = (a)->tv_sec - (b)->tv_sec;                \
 
112
                (r)->tv_usec = (a)->tv_usec - (b)->tv_usec;             \
 
113
                if ((r)->tv_usec < 0) {                                 \
 
114
                        (r)->tv_sec--;                                  \
 
115
                        (r)->tv_usec += 1000000;                        \
 
116
                }                                                       \
 
117
        } while (0)
 
118
#endif /* timersub */
 
119
 
 
120
/***********************************************************************
 
121
Resets a speedo (records the current time in it). */
 
122
UNIV_INTERN
 
123
void
 
124
speedo_reset(
 
125
/*=========*/
 
126
        speedo_t*       speedo) /* out: speedo */
 
127
{
 
128
        gettimeofday(&speedo->tv, NULL);
 
129
 
 
130
        getrusage(RUSAGE_SELF, &speedo->ru);
 
131
}
 
132
 
 
133
/***********************************************************************
 
134
Shows the time elapsed and usage statistics since the last reset of a
 
135
speedo. */
 
136
UNIV_INTERN
 
137
void
 
138
speedo_show(
 
139
/*========*/
 
140
        const speedo_t* speedo) /* in: speedo */
 
141
{
 
142
        struct rusage   ru_now;
 
143
        struct timeval  tv_now;
 
144
        struct timeval  tv_diff;
 
145
 
 
146
        getrusage(RUSAGE_SELF, &ru_now);
 
147
 
 
148
        gettimeofday(&tv_now, NULL);
 
149
 
 
150
#define PRINT_TIMEVAL(prefix, tvp)              \
 
151
        fprintf(stderr, "%s% 5ld.%06ld sec\n",  \
 
152
                prefix, (tvp)->tv_sec, (tvp)->tv_usec)
 
153
 
 
154
        timersub(&tv_now, &speedo->tv, &tv_diff);
 
155
        PRINT_TIMEVAL("real", &tv_diff);
 
156
 
 
157
        timersub(&ru_now.ru_utime, &speedo->ru.ru_utime, &tv_diff);
 
158
        PRINT_TIMEVAL("user", &tv_diff);
 
159
 
 
160
        timersub(&ru_now.ru_stime, &speedo->ru.ru_stime, &tv_diff);
 
161
        PRINT_TIMEVAL("sys ", &tv_diff);
 
162
}
 
163
 
 
164
#endif /* UNIV_COMPILE_TEST_FUNCS */