You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2014/02/07 03:20:22 UTC

[3/3] git commit: Added a function that captures the stack trace when a pure virtual method is called.

Added a function that captures the stack trace when a pure virtual
method is called.

Review: https://reviews.apache.org/r/17221


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/b42c25b9
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/b42c25b9
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/b42c25b9

Branch: refs/heads/master
Commit: b42c25b92422ad22daafa1fa82b49e028a9e275d
Parents: cf56aa1
Author: Jiang Yan Xu <ya...@jxu.me>
Authored: Thu Feb 6 18:03:01 2014 -0800
Committer: Benjamin Mahler <bm...@twitter.com>
Committed: Thu Feb 6 18:09:27 2014 -0800

----------------------------------------------------------------------
 src/logging/logging.cpp | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/b42c25b9/src/logging/logging.cpp
----------------------------------------------------------------------
diff --git a/src/logging/logging.cpp b/src/logging/logging.cpp
index 6e71e5e..a46a3f1 100644
--- a/src/logging/logging.cpp
+++ b/src/logging/logging.cpp
@@ -39,6 +39,23 @@ using process::Once;
 
 using std::string;
 
+// Captures the stack trace and exits when a pure virtual method is
+// called.
+// This interface is part of C++ ABI.
+//   -Linux c++abi:
+//    http://refspecs.linuxbase.org/cxxabi-1.83.html#vcall
+//      "This routine will only be called if the user calls a
+//       non-overridden pure virtual function, which has undefined
+//       behavior according to the C++ Standard".
+//   -OSX libc++abi:
+//    http://libcxxabi.llvm.org/spec.html
+// This usage has been tested on Linux & OSX and on gcc & clang.
+extern "C" void __cxa_pure_virtual()
+{
+  RAW_LOG(FATAL, "Pure virtual method called");
+}
+
+
 namespace mesos {
 namespace internal {
 namespace logging {