summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAlexander Nozdrin <alik@sun.com>2009-09-10 11:40:57 +0400
committerAlexander Nozdrin <alik@sun.com>2009-09-10 11:40:57 +0400
commit96c88435144750e647f28edb341a171ae049f1bf (patch)
treef332b397551f70643c53f9145deb685070a683a9 /include
parentd92b2238f9eb4a29be421d7da6fbe0f37a74bf51 (diff)
downloadmariadb-git-96c88435144750e647f28edb341a171ae049f1bf.tar.gz
A patch for Bug#45118 (mysqld.exe crashed in debug mode
on Windows in dbug.c) -- part 2: a patch for the DBUG subsystem to detect misuse of DBUG_ENTER / DBUG_RETURN macros. 5.1 version.
Diffstat (limited to 'include')
-rw-r--r--include/my_dbug.h51
1 files changed, 47 insertions, 4 deletions
diff --git a/include/my_dbug.h b/include/my_dbug.h
index a77e439b5db..71dc34791dc 100644
--- a/include/my_dbug.h
+++ b/include/my_dbug.h
@@ -16,6 +16,29 @@
#ifndef _dbug_h
#define _dbug_h
+#if defined(__cplusplus) && !defined(DBUG_OFF)
+class Dbug_violation_helper
+{
+public:
+ inline Dbug_violation_helper() :
+ _entered(TRUE)
+ { }
+
+ inline ~Dbug_violation_helper()
+ {
+ assert(!_entered);
+ }
+
+ inline void leave()
+ {
+ _entered= FALSE;
+ }
+
+private:
+ bool _entered;
+};
+#endif /* C++ */
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -47,11 +70,31 @@ extern void _db_lock_file_(void);
extern void _db_unlock_file_(void);
extern FILE *_db_fp_(void);
-#define DBUG_ENTER(a) const char *_db_func_, *_db_file_; uint _db_level_; \
- char **_db_framep_; \
- _db_enter_ (a,__FILE__,__LINE__,&_db_func_,&_db_file_,&_db_level_, \
- &_db_framep_)
+#ifdef __cplusplus
+
+#define DBUG_ENTER(a) \
+ const char *_db_func_, *_db_file_; \
+ uint _db_level_; \
+ char **_db_framep_; \
+ Dbug_violation_helper dbug_violation_helper; \
+ _db_enter_ (a, __FILE__, __LINE__, &_db_func_, &_db_file_, \
+ &_db_level_, &_db_framep_)
+#define DBUG_VIOLATION_HELPER_LEAVE dbug_violation_helper.leave()
+
+#else /* C */
+
+#define DBUG_ENTER(a) \
+ const char *_db_func_, *_db_file_; \
+ uint _db_level_; \
+ char **_db_framep_; \
+ _db_enter_ (a, __FILE__, __LINE__, &_db_func_, &_db_file_, \
+ &_db_level_, &_db_framep_)
+#define DBUG_VIOLATION_HELPER_LEAVE do { } while(0)
+
+#endif /* C++ */
+
#define DBUG_LEAVE \
+ DBUG_VIOLATION_HELPER_LEAVE; \
_db_return_ (__LINE__, &_db_func_, &_db_file_, &_db_level_)
#define DBUG_RETURN(a1) do {DBUG_LEAVE; return(a1);} while(0)
#define DBUG_VOID_RETURN do {DBUG_LEAVE; return;} while(0)