~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Brian Aker
  • Date: 2009-02-10 00:14:40 UTC
  • Revision ID: brian@tangent.org-20090210001440-qjg8eofh3h93064b
Adding Multi-threaded Scheduler into the system.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*****************************************************************************
2
 
 
3
 
Copyright (C) 1994, 2009, Innobase Oy. All Rights Reserved.
4
 
 
5
 
This program is free software; you can redistribute it and/or modify it under
6
 
the terms of the GNU General Public License as published by the Free Software
7
 
Foundation; version 2 of the License.
8
 
 
9
 
This program is distributed in the hope that it will be useful, but WITHOUT
10
 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
 
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
 
 
13
 
You should have received a copy of the GNU General Public License along with
14
 
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15
 
St, Fifth Floor, Boston, MA 02110-1301 USA
16
 
 
17
 
*****************************************************************************/
18
 
 
19
 
/*****************************************************************//**
20
 
@file ut/ut0dbg.c
 
1
/*********************************************************************
21
2
Debug utilities for Innobase.
22
3
 
 
4
(c) 1994, 1995 Innobase Oy
 
5
 
23
6
Created 1/30/1994 Heikki Tuuri
24
7
**********************************************************************/
25
8
 
28
11
 
29
12
#if defined(__GNUC__) && (__GNUC__ > 2)
30
13
#else
31
 
/** This is used to eliminate compiler warnings */
 
14
/* This is used to eliminate compiler warnings */
32
15
UNIV_INTERN ulint       ut_dbg_zero     = 0;
33
16
#endif
34
17
 
35
18
#if defined(UNIV_SYNC_DEBUG) || !defined(UT_DBG_USE_ABORT)
36
 
/** If this is set to TRUE by ut_dbg_assertion_failed(), all threads
37
 
will stop at the next ut_a() or ut_ad(). */
 
19
/* If this is set to TRUE all threads will stop into the next assertion
 
20
and assert */
38
21
UNIV_INTERN ibool       ut_dbg_stop_threads     = FALSE;
39
22
#endif
40
 
#ifndef UT_DBG_USE_ABORT
41
 
/** A null pointer that will be dereferenced to trigger a memory trap */
 
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)
 
29
/* Null pointer used to generate memory trap */
42
30
UNIV_INTERN ulint*      ut_dbg_null_ptr         = NULL;
43
31
#endif
44
32
 
45
 
/*************************************************************//**
 
33
/*****************************************************************
46
34
Report a failed assertion. */
47
 
#ifdef __cplusplus
48
 
extern "C"
49
 
#endif
50
35
UNIV_INTERN
51
36
void
52
37
ut_dbg_assertion_failed(
53
38
/*====================*/
54
 
        const char* expr,       /*!< in: the failed assertion (optional) */
55
 
        const char* file,       /*!< in: source file containing the assertion */
56
 
        ulint line)             /*!< in: line number of the assertion */
 
39
        const char* expr,       /* in: the failed assertion (optional) */
 
40
        const char* file,       /* in: source file containing the assertion */
 
41
        ulint line)             /* in: line number of the assertion */
57
42
{
58
43
        ut_print_timestamp(stderr);
59
 
#ifdef UNIV_HOTBACKUP
60
 
        fprintf(stderr, "  InnoDB: Assertion failure in file %s line %lu\n",
61
 
                file, line);
62
 
#else /* UNIV_HOTBACKUP */
63
44
        fprintf(stderr,
64
45
                "  InnoDB: Assertion failure in thread %lu"
65
46
                " in file %s line %lu\n",
66
47
                os_thread_pf(os_thread_get_curr_id()), file, line);
67
 
#endif /* UNIV_HOTBACKUP */
68
48
        if (expr) {
69
49
                fprintf(stderr,
70
50
                        "InnoDB: Failing assertion: %s\n", expr);
77
57
              " or crashes, even\n"
78
58
              "InnoDB: immediately after the mysqld startup, there may be\n"
79
59
              "InnoDB: corruption in the InnoDB tablespace. Please refer to\n"
80
 
              "InnoDB: " REFMAN "forcing-recovery.html\n"
 
60
              "InnoDB: http://dev.mysql.com/doc/refman/5.1/en/"
 
61
              "forcing-recovery.html\n"
81
62
              "InnoDB: about forcing recovery.\n", stderr);
82
63
#if defined(UNIV_SYNC_DEBUG) || !defined(UT_DBG_USE_ABORT)
83
64
        ut_dbg_stop_threads = TRUE;
84
65
#endif
85
66
}
86
67
 
87
 
#if defined(UNIV_SYNC_DEBUG) || !defined(UT_DBG_USE_ABORT)
88
 
/*************************************************************//**
 
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__ */
 
83
# if defined(UNIV_SYNC_DEBUG) || !defined(UT_DBG_USE_ABORT)
 
84
/*****************************************************************
89
85
Stop a thread after assertion failure. */
90
86
UNIV_INTERN
91
87
void
94
90
        const char*     file,
95
91
        ulint           line)
96
92
{
97
 
#ifndef UNIV_HOTBACKUP
98
93
        fprintf(stderr, "InnoDB: Thread %lu stopped in file %s line %lu\n",
99
94
                os_thread_pf(os_thread_get_curr_id()), file, line);
100
95
        os_thread_sleep(1000000000);
101
 
#endif /* !UNIV_HOTBACKUP */
102
96
}
103
 
#endif
 
97
# endif
 
98
#endif /* __NETWARE__ */
104
99
 
105
100
#ifdef UNIV_COMPILE_TEST_FUNCS
106
101
 
122
117
        } while (0)
123
118
#endif /* timersub */
124
119
 
125
 
/*******************************************************************//**
 
120
/***********************************************************************
126
121
Resets a speedo (records the current time in it). */
127
122
UNIV_INTERN
128
123
void
129
124
speedo_reset(
130
125
/*=========*/
131
 
        speedo_t*       speedo) /*!< out: speedo */
 
126
        speedo_t*       speedo) /* out: speedo */
132
127
{
133
128
        gettimeofday(&speedo->tv, NULL);
134
129
 
135
130
        getrusage(RUSAGE_SELF, &speedo->ru);
136
131
}
137
132
 
138
 
/*******************************************************************//**
 
133
/***********************************************************************
139
134
Shows the time elapsed and usage statistics since the last reset of a
140
135
speedo. */
141
136
UNIV_INTERN
142
137
void
143
138
speedo_show(
144
139
/*========*/
145
 
        const speedo_t* speedo) /*!< in: speedo */
 
140
        const speedo_t* speedo) /* in: speedo */
146
141
{
147
142
        struct rusage   ru_now;
148
143
        struct timeval  tv_now;