arrow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From w...@apache.org
Subject arrow git commit: ARROW-1401: [C++] Add ARROW_EXTRA_ERROR_CONTEXT option
Date Tue, 05 Sep 2017 16:18:54 GMT
Repository: arrow
Updated Branches:
  refs/heads/master 338a187a9 -> ab328ec85


ARROW-1401: [C++] Add ARROW_EXTRA_ERROR_CONTEXT option

This can be enabled in release or debug builds. The result is slightly longer compile times
and larger binaries. The resulting error messages are effectively a crude stack trace, see:

```
Out of memory:
/home/wesm/code/arrow/cpp/src/arrow/builder.cc:281 code: Reserve(length)
/home/wesm/code/arrow/cpp/src/arrow/builder.cc:250 code: ArrayBuilder::Resize(capacity)
ArrayBuilder::Resize
```

We may be able to do better with glog, but this should help for debugging

Author: Wes McKinney <wes.mckinney@twosigma.com>

Closes #1042 from wesm/ARROW-1401 and squashes the following commits:

9d6f4d31 [Wes McKinney] Do not call constructor directly
a0731022 [Wes McKinney] Add to Travis CI
ca6291f2 [Wes McKinney] Add ARROW_EXTRA_ERROR_CONTEXT option with file/line numbers/code


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

Branch: refs/heads/master
Commit: ab328ec85b275deff9a7a821a1d8f6e9db5d3292
Parents: 338a187
Author: Wes McKinney <wes.mckinney@twosigma.com>
Authored: Tue Sep 5 12:18:47 2017 -0400
Committer: Wes McKinney <wes.mckinney@twosigma.com>
Committed: Tue Sep 5 12:18:47 2017 -0400

----------------------------------------------------------------------
 ci/travis_before_script_cpp.sh |  3 ++-
 cpp/CMakeLists.txt             |  8 ++++++++
 cpp/src/arrow/status.h         | 22 ++++++++++++++++++++++
 3 files changed, 32 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/arrow/blob/ab328ec8/ci/travis_before_script_cpp.sh
----------------------------------------------------------------------
diff --git a/ci/travis_before_script_cpp.sh b/ci/travis_before_script_cpp.sh
index 7418b76..a613957 100755
--- a/ci/travis_before_script_cpp.sh
+++ b/ci/travis_before_script_cpp.sh
@@ -61,7 +61,8 @@ pushd $ARROW_CPP_BUILD_DIR
 CMAKE_COMMON_FLAGS="\
 -DARROW_BUILD_BENCHMARKS=ON \
 -DCMAKE_INSTALL_PREFIX=$ARROW_CPP_INSTALL \
--DARROW_NO_DEPRECATED_API=ON"
+-DARROW_NO_DEPRECATED_API=ON \
+-DARROW_EXTRA_ERROR_CONTEXT=ON"
 CMAKE_LINUX_FLAGS=""
 CMAKE_OSX_FLAGS=""
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/ab328ec8/cpp/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt
index f25cc62..9f9d71b 100644
--- a/cpp/CMakeLists.txt
+++ b/cpp/CMakeLists.txt
@@ -94,6 +94,10 @@ if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
     "Exclude deprecated APIs from build"
     OFF)
 
+  option(ARROW_EXTRA_ERROR_CONTEXT
+    "Compile with extra error context (line numbers, code)"
+    OFF)
+
   option(ARROW_IPC
     "Build the Arrow IPC extensions"
     ON)
@@ -221,6 +225,10 @@ if (ARROW_NO_DEPRECATED_API)
   add_definitions(-DARROW_NO_DEPRECATED_API)
 endif()
 
+if (ARROW_EXTRA_ERROR_CONTEXT)
+  add_definitions(-DARROW_EXTRA_ERROR_CONTEXT)
+endif()
+
 include(SetupCxxFlags)
 
 ############################################################

http://git-wip-us.apache.org/repos/asf/arrow/blob/ab328ec8/cpp/src/arrow/status.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/status.h b/cpp/src/arrow/status.h
index ece83ac..0cb0fb1 100644
--- a/cpp/src/arrow/status.h
+++ b/cpp/src/arrow/status.h
@@ -19,6 +19,10 @@
 #include <iosfwd>
 #include <string>
 
+#ifdef ARROW_EXTRA_ERROR_CONTEXT
+#include <sstream>
+#endif
+
 #include "arrow/util/macros.h"
 #include "arrow/util/visibility.h"
 
@@ -45,6 +49,22 @@
 
 namespace arrow {
 
+#ifdef ARROW_EXTRA_ERROR_CONTEXT
+
+#define RETURN_NOT_OK(s)                        \
+  do {                                          \
+    Status _s = (s);                            \
+    if (ARROW_PREDICT_FALSE(!_s.ok())) {        \
+      std::stringstream ss;                     \
+      ss << __FILE__ << ":" << __LINE__         \
+         << " code: " << #s                     \
+         << "\n" << _s.message();               \
+      return Status(_s.code(), ss.str());       \
+    }                                           \
+  } while (0)
+
+#else
+
 #define RETURN_NOT_OK(s)                 \
   do {                                   \
     Status _s = (s);                     \
@@ -53,6 +73,8 @@ namespace arrow {
     }                                    \
   } while (0)
 
+#endif // ARROW_EXTRA_ERROR_CONTEXT
+
 #define RETURN_NOT_OK_ELSE(s, else_) \
   do {                               \
     Status _s = (s);                 \


Mime
View raw message