diff options
author | Keith Bostic <keith.bostic@mongodb.com> | 2017-08-15 18:44:34 -0400 |
---|---|---|
committer | Alex Gorrod <alexander.gorrod@mongodb.com> | 2017-08-16 08:44:34 +1000 |
commit | 6b3485f7109878aa297256921f6807b38f7a3029 (patch) | |
tree | 11e3931e2d89873572962b661d91556e936e72a6 | |
parent | 8dbc3fc2716e4262f6f5cbfc407aad6f3bce1c8c (diff) | |
download | mongo-6b3485f7109878aa297256921f6807b38f7a3029.tar.gz |
WT-3509 Enhance __wt_illegal_value to provide a failure location (#3587)
-rw-r--r-- | src/block/block_ckpt.c | 5 | ||||
-rw-r--r-- | src/cursor/cur_join.c | 4 | ||||
-rw-r--r-- | src/include/extern.h | 2 | ||||
-rw-r--r-- | src/include/misc.h | 4 | ||||
-rw-r--r-- | src/support/err.c | 13 |
5 files changed, 19 insertions, 9 deletions
diff --git a/src/block/block_ckpt.c b/src/block/block_ckpt.c index c20a294c07b..98cc10a6de1 100644 --- a/src/block/block_ckpt.c +++ b/src/block/block_ckpt.c @@ -342,6 +342,11 @@ __ckpt_verify(WT_SESSION_IMPL *session, WT_CKPT *ckptbase) break; /* FALLTHROUGH */ default: + /* + * Don't convert to WT_ILLEGAL_VALUE, it won't compile + * on some gcc compilers because they don't understand + * FALLTHROUGH as part of a macro. + */ return ( __wt_illegal_value(session, "checkpoint array")); } diff --git a/src/cursor/cur_join.c b/src/cursor/cur_join.c index 855ad70d6e0..e3ae9dbd9f6 100644 --- a/src/cursor/cur_join.c +++ b/src/cursor/cur_join.c @@ -499,9 +499,7 @@ __curjoin_entry_in_range(WT_SESSION_IMPL *session, WT_CURSOR_JOIN_ENTRY *entry, passed = (cmp < 0); break; - default: - WT_RET(__wt_illegal_value(session, NULL)); - break; + WT_ILLEGAL_VALUE(session); } if (!passed) { diff --git a/src/include/extern.h b/src/include/extern.h index 08649dbae07..510fb185377 100644 --- a/src/include/extern.h +++ b/src/include/extern.h @@ -667,7 +667,7 @@ __wt_assert(WT_SESSION_IMPL *session, #endif WT_GCC_FUNC_DECL_ATTRIBUTE((visibility("default"))); extern int __wt_panic(WT_SESSION_IMPL *session) WT_GCC_FUNC_DECL_ATTRIBUTE((cold)) WT_GCC_FUNC_DECL_ATTRIBUTE((visibility("default"))) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); -extern int __wt_illegal_value(WT_SESSION_IMPL *session, const char *name) WT_GCC_FUNC_DECL_ATTRIBUTE((cold)) WT_GCC_FUNC_DECL_ATTRIBUTE((visibility("default"))) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); +extern int __wt_illegal_value_func(WT_SESSION_IMPL *session, const char *name, const char *file, const char *func, int line) WT_GCC_FUNC_DECL_ATTRIBUTE((cold)) WT_GCC_FUNC_DECL_ATTRIBUTE((visibility("default"))) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_inmem_unsupported_op(WT_SESSION_IMPL *session, const char *tag) WT_GCC_FUNC_DECL_ATTRIBUTE((cold)) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_object_unsupported(WT_SESSION_IMPL *session, const char *uri) WT_GCC_FUNC_DECL_ATTRIBUTE((cold)) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_bad_object_type(WT_SESSION_IMPL *session, const char *uri) WT_GCC_FUNC_DECL_ATTRIBUTE((cold)) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); diff --git a/src/include/misc.h b/src/include/misc.h index bf7d36e19ca..002d3b20270 100644 --- a/src/include/misc.h +++ b/src/include/misc.h @@ -293,6 +293,10 @@ typedef void wt_timestamp_t; __wt_page_swap_func(session, held, want, flags) #endif +/* Called on unexpected code path: locate the failure. */ +#define __wt_illegal_value(session, msg) \ + __wt_illegal_value_func(session, msg, __FILE__, __func__, __LINE__) + /* Random number generator state. */ union __wt_rand_state { uint64_t v; diff --git a/src/support/err.c b/src/support/err.c index 94ae27628c2..c6800bc33ad 100644 --- a/src/support/err.c +++ b/src/support/err.c @@ -533,17 +533,20 @@ __wt_panic(WT_SESSION_IMPL *session) } /* - * __wt_illegal_value -- + * __wt_illegal_value_func -- * A standard error message when we detect an illegal value. */ int -__wt_illegal_value(WT_SESSION_IMPL *session, const char *name) +__wt_illegal_value_func(WT_SESSION_IMPL *session, + const char *name, const char *file, const char *func, int line) WT_GCC_FUNC_ATTRIBUTE((cold)) WT_GCC_FUNC_ATTRIBUTE((visibility("default"))) { - __wt_errx(session, "%s%s%s", - name == NULL ? "" : name, name == NULL ? "" : ": ", - "encountered an illegal file format or internal value"); + __wt_errx(session, "%s%s%s: (%s, %s, %d)", + name == NULL ? "" : name, + name == NULL ? "" : ": ", + "encountered an illegal file format or internal value", + file, func, line); return (__wt_panic(session)); } |