Cleaned up assert logging.

This commit is contained in:
Pedro Pinto committed 2017-11-01 17:05:05 +00:00
1 parent d4f49279e1
commit 5dc43562e5
20 files changed
+74 -29

No files matched your search

+1
View File
@@ -2,6 +2,7 @@
#include "lib/quickbus/quickbus.h"
#include "lib/config/config.h"
#include "lib/logging/logging.h"
#include "lib/utils/bts_assert.h"
#include "../public/ServiceContext.h"
#include "../public/Result.h"
+1
View File
@@ -1,6 +1,7 @@
#include "ApiServerInterop.h"
#include "lib/quickbus/quickbus.h"
#include "lib/logging/logging.h"
#include "lib/utils/bts_assert.h"
namespace bts {
namespace api {
+2
View File
@@ -1,3 +1,5 @@
#include "lib/utils/windows_wrapper.h"
#include "ConfigDownloader.h"
#include <stdio.h>
+1
View File
@@ -1,5 +1,6 @@
#include "HTTPServer.h"
#include "lib/utils/bts_assert.h"
using boost::asio::ip::tcp;
+2
View File
@@ -1,5 +1,7 @@
#pragma once
#include "lib/utils/windows_wrapper.h"
#include <stdint.h>
#include <array>
#include <limits>
+4 -5
View File
@@ -2,7 +2,6 @@
#include "MsgPacking.h"
#include "LogRec.h"
#include "lib/utils/bts_assert.h"
#include <thread>
#include <atomic>
@@ -38,7 +37,7 @@ public:
void enqueue (Subsystem subsystem,Level lv, const char*file, int line,
const char *msg_template, Args&&... msg_args)
{
bts_assert(_active);
assert(_active);
lock();
if (lv.ordinal >= _filter[subsystem.ordinal].ordinal) {
if (_wcursor == _write_q->size())
@@ -123,7 +122,7 @@ public:
void mark_inactive()
{
lock();
bts_assert(_active);
assert(_active);
_active=false;
unlock();
}
@@ -131,8 +130,8 @@ public:
~Logger()
{
#ifndef WIN32
bts_assert(!_active);
bts_assert(_wcursor == 0);
assert(!_active);
assert(_wcursor == 0);
#endif
}
+2
View File
@@ -4,6 +4,8 @@
#include "lib/utils/bts_chrono.h"
#include "Logger.h"
#include "lib/os/os.h"
#include "lib/utils/bts_assert.h"
#include <thread>
#include <mutex>
#include <atomic>
+1
View File
@@ -4,6 +4,7 @@
#include "lib/os/os.h"
#include "lib/utils/datetime.h"
#include "lib/utils/file_utils.h"
#include "lib/utils/bts_assert.h"
#include <fmt/ostream.h>
#include <fstream>
+1 -6
View File
@@ -991,11 +991,6 @@ BTS_EXPORT std::string host_ip (std::string const &src_interface_name)
return default_ip;
}
BTS_EXPORT void debug_break()
{
DEBUG_BREAK();
}
BTS_EXPORT void set_thread_name(std::string const&n)
{set_thread_name(n.c_str());}
@@ -1027,7 +1022,7 @@ BTS_EXPORT void set_thread_name(const char* name)
RaiseException(MS_VC_EXCEPTION, 0, sizeof(info)/sizeof(ULONG_PTR), (ULONG_PTR*)&info);
#ifdef _MSC_VER
}
__except(EXCEPTION_EXECUTE_HANDLER)
__except(EXCEPTION_EXECUTE_HANDLER)
{
}
#endif
-1
View File
@@ -72,7 +72,6 @@ BTS_EXPORT std::string username();
BTS_EXPORT char* strncpy(char* dest, const char* src, size_t count);
BTS_EXPORT void setenv(const char* name, const char* value);
BTS_EXPORT void debug_break();
BTS_EXPORT void set_thread_name(std::string const&);
BTS_EXPORT void set_thread_name(const char* name);
+1
View File
@@ -4,6 +4,7 @@
#include "lib/quickbus/routing/Router.h"
#include "lib/quickbus/routing/NodeID.h"
#include "lib/logging/logging.h"
#include "lib/utils/bts_assert.h"
namespace bts {
namespace qbus {
@@ -4,6 +4,7 @@
#include "lib/utils/PBUtils.h"
#include "lib/utils/datetime.h"
#include "lib/logging/logging.h"
#include "lib/utils/bts_assert.h"
#include "lib/quickbus/routing/Router.h"
#include "lib/quickbus/network/endpoint_description.h"
@@ -4,6 +4,7 @@
#include "lib/quickbus/network/QBConnection.h"
#include "lib/logging/logging.h"
#include "lib/quickbus/network/endpoint_description.h"
#include "lib/utils/bts_assert.h"
#include "lib/config/protos/quickbus_cfg.pb.h"
+1
View File
@@ -5,6 +5,7 @@
#include "lib/quickbus/rpc/rpc_utils.h"
#include "lib/quickbus/core/Advertisement.h"
#include "lib/logging/logging.h"
#include "lib/utils/bts_assert.h"
#include <unordered_map>
#include <atomic>
-1
View File
@@ -2,7 +2,6 @@
#pragma once
#include "lib/utils/bts_no_copy.h"
#include "lib/utils/bts_assert.h"
#include "lib/utils/bts_export.h"
#include <functional>
+1
View File
@@ -1,6 +1,7 @@
#include "HTTPStream.h"
#include "lib/logging/logging.h"
#include "lib/utils/defer.h"
#include "lib/utils/bts_assert.h"
#include <boost/tokenizer.hpp>
#include <boost/lexical_cast.hpp>
+1
View File
@@ -5,6 +5,7 @@
#include "lib/utils/SharedMemory.h"
#include "lib/utils/bts_array_size.h"
#include "lib/logging/logging.h"
#include "lib/utils/bts_assert.h"
#include "lib/os/os.h"
#include "lib/config/config.h"
+10 -4
View File
@@ -1,5 +1,9 @@
#pragma once
#include <iostream>
#include <csignal>
#include "lib/logging/logging.h"
#include "lib/utils/bts_debugger.h"
#ifdef _WIN32
#define TERMINATE ::_exit(-1);
@@ -7,10 +11,12 @@
#define TERMINATE abort ();
#endif
#define bts_assert_msg(EXP, msg) do { \
if (!(EXP)) { \
std::cerr << "Assert failure: " << __FILE__ << ":" << __LINE__ << " Exp: " << #EXP << std::endl; \
TERMINATE; \
#define bts_assert_msg(EXP, msg) do { \
if (!(EXP)) { \
LOG(Assert,Fatal, "Assert failure: {} {}",std::string(#EXP),std::string(msg) ); \
if (is_debugger_present()) \
debug_break(); \
TERMINATE; \
}} while(0)
#define bts_assert(EXP) bts_assert_msg(EXP, "")
+41 -11
View File
@@ -1,16 +1,46 @@
#ifndef BTS_DEBUGGER_H_
#define BTS_DEBUGGER_H_
#pragma once
#include "../os/os.h"
#include <csignal>
#include <sys/stat.h>
#include <fcntl.h>
#include "windows_wrapper.h"
#ifdef _WIN32
#define DEBUG_BREAK() do { if (IsDebuggerPresent()) __debugbreak(); } while(0)
#else
//#include <sys/ptrace.h>
//#include <signal.h>
// #define DEBUG_BREAK() do { if (ptrace(PTRACE_TRACEME, 0, NULL, 0) == -1) raise(SIGTRAP); } while(0)
#define DEBUG_BREAK()
#endif
inline bool is_debugger_present()
{
#ifdef WIN32
return IsDebuggerPresent();
#else
char buf[1024];
int debugger_present = 0;
int status_fd = open("/proc/self/status", O_RDONLY);
if (status_fd == -1)
return 0;
ssize_t num_read = read(status_fd, buf, sizeof(buf)-1);
if (num_read > 0)
{
static const char TracerPid[] = "TracerPid:";
char *tracer_pid;
buf[num_read] = 0;
tracer_pid = strstr(buf, TracerPid);
if (tracer_pid)
debugger_present = !!atoi(tracer_pid + sizeof(TracerPid) - 1);
}
return debugger_present;
#endif
}
inline void debug_break()
{
#ifdef _WIN32
__debugbreak();
#else
std::raise(SIGINT);
#endif
}
+2 -1
View File
@@ -5,6 +5,7 @@
#include <memory>
#include <double-conversion/double-conversion.h>
namespace bts {
inline int f_toa (float n,char*buffer, size_t buffer_size,int pad=0)
{
static double_conversion::DoubleToStringConverter const &c =
@@ -39,4 +40,4 @@ inline int f_toa (float n,char*buffer, size_t buffer_size,int pad=0)
return pad;
}
}
}