Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorДобрый Ээх <bukharaev@gmail.com>2017-07-25 19:14:36 +0300
committerДобрый Ээх <bukharaev@gmail.com>2017-07-26 12:51:52 +0300
commit515c44c84ea4810270b375a058d29d489a432aea (patch)
treec4279705825b9a8a7a4a52ec8109d390228084da
parentfe641df515fbaabcee41277b5528b284e333af2a (diff)
[routing] Fix CHECK in fabricbeta-931
-rw-r--r--android/jni/com/mapswithme/core/logging.cpp5
-rw-r--r--base/assert.hpp54
-rw-r--r--base/base.cpp8
-rw-r--r--iphone/Maps/Common/Statistics/fabric_logging.hpp3
-rw-r--r--iphone/Maps/Common/Statistics/fabric_logging_ios.mm16
-rw-r--r--iphone/Maps/main.mm3
-rw-r--r--routing/index_router.cpp1
7 files changed, 53 insertions, 37 deletions
diff --git a/android/jni/com/mapswithme/core/logging.cpp b/android/jni/com/mapswithme/core/logging.cpp
index 7f0a670a42..03c8e35049 100644
--- a/android/jni/com/mapswithme/core/logging.cpp
+++ b/android/jni/com/mapswithme/core/logging.cpp
@@ -53,11 +53,6 @@ void AndroidLogMessage(LogLevel level, SrcPoint const & src, std::string const &
void AndroidAssertMessage(SrcPoint const & src, std::string const & s)
{
AndroidMessage(LCRITICAL, src, s);
-#ifdef DEBUG
- assert(false);
-#else
- std::abort();
-#endif
}
void InitSystemLog()
diff --git a/base/assert.hpp b/base/assert.hpp
index d4f73c44d6..30743d32bc 100644
--- a/base/assert.hpp
+++ b/base/assert.hpp
@@ -3,6 +3,8 @@
#include "base/internal/message.hpp"
#include "base/src_point.hpp"
+#include <cassert>
+#include <cstdlib>
#include <string>
@@ -16,37 +18,47 @@ namespace my
AssertFailedFn SetAssertFunction(AssertFailedFn fn);
}
+#ifdef DEBUG
+#define ABORT_ON_ASSERT() assert(false)
+#else
+#define ABORT_ON_ASSERT() std::abort()
+#endif
+
+#define ON_ASSERT_FAILED(msg) \
+ ::my::OnAssertFailed(SRC(), msg); \
+ ABORT_ON_ASSERT();
+
// TODO: Evaluate X only once in CHECK().
#define CHECK(X, msg) do { if (X) {} else { \
- ::my::OnAssertFailed(SRC(), ::my::impl::Message("CHECK("#X")", ::my::impl::Message msg));} } while(false)
+ ON_ASSERT_FAILED(::my::impl::Message("CHECK("#X")", ::my::impl::Message msg));} } while(false)
#define CHECK_EQUAL(X, Y, msg) do { if ((X) == (Y)) {} else { \
- ::my::OnAssertFailed(SRC(), ::my::impl::Message("CHECK("#X" == "#Y")", \
- ::my::impl::Message(X, Y), \
- ::my::impl::Message msg));} } while (false)
+ ON_ASSERT_FAILED(::my::impl::Message("CHECK("#X" == "#Y")", \
+ ::my::impl::Message(X, Y), \
+ ::my::impl::Message msg));} } while (false)
#define CHECK_NOT_EQUAL(X, Y, msg) do { if ((X) != (Y)) {} else { \
- ::my::OnAssertFailed(SRC(), ::my::impl::Message("CHECK("#X" != "#Y")", \
- ::my::impl::Message(X, Y), \
- ::my::impl::Message msg));} } while (false)
+ ON_ASSERT_FAILED(::my::impl::Message("CHECK("#X" != "#Y")", \
+ ::my::impl::Message(X, Y), \
+ ::my::impl::Message msg));} } while (false)
#define CHECK_LESS(X, Y, msg) do { if ((X) < (Y)) {} else { \
- ::my::OnAssertFailed(SRC(), ::my::impl::Message("CHECK("#X" < "#Y")", \
- ::my::impl::Message(X, Y), \
- ::my::impl::Message msg));} } while (false)
+ ON_ASSERT_FAILED(::my::impl::Message("CHECK("#X" < "#Y")", \
+ ::my::impl::Message(X, Y), \
+ ::my::impl::Message msg));} } while (false)
#define CHECK_LESS_OR_EQUAL(X, Y, msg) do { if ((X) <= (Y)) {} else { \
- ::my::OnAssertFailed(SRC(), ::my::impl::Message("CHECK("#X" <= "#Y")", \
- ::my::impl::Message(X, Y), \
- ::my::impl::Message msg));} } while (false)
+ ON_ASSERT_FAILED(::my::impl::Message("CHECK("#X" <= "#Y")", \
+ ::my::impl::Message(X, Y), \
+ ::my::impl::Message msg));} } while (false)
#define CHECK_GREATER(X, Y, msg) do { if ((X) > (Y)) {} else { \
- ::my::OnAssertFailed(SRC(), ::my::impl::Message("CHECK("#X" > "#Y")", \
- ::my::impl::Message(X, Y), \
- ::my::impl::Message msg));} } while (false)
+ ON_ASSERT_FAILED(::my::impl::Message("CHECK("#X" > "#Y")", \
+ ::my::impl::Message(X, Y), \
+ ::my::impl::Message msg));} } while (false)
#define CHECK_GREATER_OR_EQUAL(X, Y, msg) do { if ((X) >= (Y)) {} else { \
- ::my::OnAssertFailed(SRC(), ::my::impl::Message("CHECK("#X" >= "#Y")", \
- ::my::impl::Message(X, Y), \
- ::my::impl::Message msg));} } while (false)
+ ON_ASSERT_FAILED(::my::impl::Message("CHECK("#X" >= "#Y")", \
+ ::my::impl::Message(X, Y), \
+ ::my::impl::Message msg));} } while (false)
#define CHECK_OR_CALL(fail, call, X, msg) do { if (X) {} else { \
if (fail) {\
- ::my::OnAssertFailed(SRC(), ::my::impl::Message(::my::impl::Message("CHECK("#X")"), \
- ::my::impl::Message msg)); \
+ ON_ASSERT_FAILED(::my::impl::Message(::my::impl::Message("CHECK("#X")"), \
+ ::my::impl::Message msg)); \
} else { \
call(); \
} } } while (false)
diff --git a/base/base.cpp b/base/base.cpp
index ab46769aa0..462296e1a2 100644
--- a/base/base.cpp
+++ b/base/base.cpp
@@ -4,8 +4,6 @@
#include "std/target_os.hpp"
-#include <cassert>
-#include <cstdlib>
#include <iostream>
namespace my
@@ -15,12 +13,6 @@ namespace my
std::cerr << "ASSERT FAILED" << std::endl
<< srcPoint.FileName() << ":" << srcPoint.Line() << std::endl
<< msg << std::endl;
-
-#ifdef DEBUG
- assert(false);
-#else
- std::abort();
-#endif
}
AssertFailedFn OnAssertFailed = &OnAssertFailedDefault;
diff --git a/iphone/Maps/Common/Statistics/fabric_logging.hpp b/iphone/Maps/Common/Statistics/fabric_logging.hpp
index a6637aae9c..0067d7d863 100644
--- a/iphone/Maps/Common/Statistics/fabric_logging.hpp
+++ b/iphone/Maps/Common/Statistics/fabric_logging.hpp
@@ -6,5 +6,6 @@
namespace platform
{
- void LogMessageFabric(my::LogLevel level, my::SrcPoint const & srcPoint, std::string const & msg);
+ void IosLogMessage(my::LogLevel level, my::SrcPoint const & srcPoint, std::string const & msg);
+ void IosAssertMessage(my::SrcPoint const & srcPoint, std::string const & msg);
}
diff --git a/iphone/Maps/Common/Statistics/fabric_logging_ios.mm b/iphone/Maps/Common/Statistics/fabric_logging_ios.mm
index 268b400a8e..a7aa08df75 100644
--- a/iphone/Maps/Common/Statistics/fabric_logging_ios.mm
+++ b/iphone/Maps/Common/Statistics/fabric_logging_ios.mm
@@ -4,9 +4,11 @@
#include "base/assert.hpp"
+#include <iostream>
+
namespace platform
{
- void LogMessageFabric(my::LogLevel level, my::SrcPoint const & srcPoint, std::string const & msg)
+void LogMessageFabric(my::LogLevel level, my::SrcPoint const & srcPoint, std::string const & msg)
{
std::string recordType;
switch (level)
@@ -22,7 +24,19 @@ namespace platform
std::string const srcString = recordType + DebugPrint(srcPoint) + " " + msg + "\n";
CLSLog(@"%@", @(srcString.c_str()));
+}
+void IosLogMessage(my::LogLevel level, my::SrcPoint const & srcPoint, std::string const & msg)
+{
+ LogMessageFabric(level, srcPoint, msg);
my::LogMessageDefault(level, srcPoint, msg);
}
+
+void IosAssertMessage(my::SrcPoint const & srcPoint, std::string const & msg)
+{
+ LogMessageFabric(my::LCRITICAL, srcPoint, msg);
+ std::cerr << "ASSERT FAILED" << std::endl
+ << srcPoint.FileName() << ":" << srcPoint.Line() << std::endl
+ << msg << std::endl;
+}
} // namespace platform
diff --git a/iphone/Maps/main.mm b/iphone/Maps/main.mm
index f1657bb25c..3d51f95b59 100644
--- a/iphone/Maps/main.mm
+++ b/iphone/Maps/main.mm
@@ -56,7 +56,8 @@ int main(int argc, char * argv[])
#ifdef MWM_LOG_TO_FILE
my::SetLogMessageFn(LogMessageFile);
#elif OMIM_PRODUCTION
- my::SetLogMessageFn(platform::LogMessageFabric);
+ my::SetLogMessageFn(platform::IosLogMessage);
+ my::SetAssertFunction(platform::IosAssertMessage);
#endif
auto & p = GetPlatform();
LOG(LINFO, ("maps.me started, detected CPU cores:", p.CpuCores()));
diff --git a/routing/index_router.cpp b/routing/index_router.cpp
index 5aed3acab0..a9562c0903 100644
--- a/routing/index_router.cpp
+++ b/routing/index_router.cpp
@@ -186,6 +186,7 @@ IRouter::ResultCode IndexRouter::CalculateRoute(Checkpoints const & checkpoints,
bool adjustToPrevRoute,
RouterDelegate const & delegate, Route & route)
{
+ CHECK(false, ("Test check"));
if (!AllMwmsHaveRoutingIndex(m_index, route))
return IRouter::ResultCode::FileTooOld;