Add a debug option to Makefile, and use KAK_DEBUG define to remove debug code
This commit is contained in:
parent
6f48407f55
commit
cd8c36fc50
11
src/Makefile
11
src/Makefile
|
@ -5,6 +5,17 @@ deps := $(addprefix ., $(sources:.cc=.d))
|
||||||
CXXFLAGS += -std=c++0x -g -Wall -Wno-reorder -Wno-sign-compare
|
CXXFLAGS += -std=c++0x -g -Wall -Wno-reorder -Wno-sign-compare
|
||||||
LDFLAGS += -lmenu -lncursesw -lboost_regex
|
LDFLAGS += -lmenu -lncursesw -lboost_regex
|
||||||
|
|
||||||
|
debug ?= yes
|
||||||
|
ifeq ($(debug),yes)
|
||||||
|
CXXFLAGS += -DKAK_DEBUG
|
||||||
|
else
|
||||||
|
ifeq ($(debug),no)
|
||||||
|
CXXFLAGS += -O3
|
||||||
|
else
|
||||||
|
$(error debug should be either yes or no)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
kak : $(objects)
|
kak : $(objects)
|
||||||
$(CXX) $(LDFLAGS) $(CXXFLAGS) $(objects) -o $@
|
$(CXX) $(LDFLAGS) $(CXXFLAGS) $(objects) -o $@
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,14 @@ void on_assert_failed(const char* message);
|
||||||
#undef assert
|
#undef assert
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef KAK_DEBUG
|
||||||
#define assert(condition) \
|
#define assert(condition) \
|
||||||
if (not (condition)) \
|
if (not (condition)) \
|
||||||
on_assert_failed("assert failed \"" #condition "\" at " __FILE__ ":" TOSTRING(__LINE__))
|
on_assert_failed("assert failed \"" #condition \
|
||||||
|
"\" at " __FILE__ ":" TOSTRING(__LINE__))
|
||||||
|
#else
|
||||||
|
#define assert(condition)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#endif // assert_hh_INCLUDED
|
#endif // assert_hh_INCLUDED
|
||||||
|
|
|
@ -225,6 +225,7 @@ bool Buffer::redo()
|
||||||
|
|
||||||
void Buffer::check_invariant() const
|
void Buffer::check_invariant() const
|
||||||
{
|
{
|
||||||
|
#ifdef KAK_DEBUG
|
||||||
ByteCount start = 0;
|
ByteCount start = 0;
|
||||||
assert(not m_lines.empty());
|
assert(not m_lines.empty());
|
||||||
for (auto& line : m_lines)
|
for (auto& line : m_lines)
|
||||||
|
@ -234,6 +235,7 @@ void Buffer::check_invariant() const
|
||||||
assert(line.content.back() == '\n');
|
assert(line.content.back() == '\n');
|
||||||
start += line.length();
|
start += line.length();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::do_insert(const BufferIterator& pos, const String& content)
|
void Buffer::do_insert(const BufferIterator& pos, const String& content)
|
||||||
|
|
|
@ -27,11 +27,6 @@
|
||||||
namespace Kakoune
|
namespace Kakoune
|
||||||
{
|
{
|
||||||
|
|
||||||
using namespace std::placeholders;
|
|
||||||
|
|
||||||
// berk
|
|
||||||
extern bool quit_requested;
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -376,6 +376,7 @@ bool Editor::redo()
|
||||||
|
|
||||||
void Editor::check_invariant() const
|
void Editor::check_invariant() const
|
||||||
{
|
{
|
||||||
|
#ifdef KAK_DEBUG
|
||||||
assert(not m_selections.empty());
|
assert(not m_selections.empty());
|
||||||
m_selections.check_invariant();
|
m_selections.check_invariant();
|
||||||
|
|
||||||
|
@ -383,6 +384,7 @@ void Editor::check_invariant() const
|
||||||
compare_selections);
|
compare_selections);
|
||||||
assert(std::is_sorted(m_selections.begin(), it, compare_selections));
|
assert(std::is_sorted(m_selections.begin(), it, compare_selections));
|
||||||
assert(std::is_sorted(it, m_selections.end(), compare_selections));
|
assert(std::is_sorted(it, m_selections.end(), compare_selections));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Editor::begin_edition()
|
void Editor::begin_edition()
|
||||||
|
|
|
@ -48,9 +48,11 @@ bool ParametersParser::has_option(const String& name) const
|
||||||
|
|
||||||
const String& ParametersParser::option_value(const String& name) const
|
const String& ParametersParser::option_value(const String& name) const
|
||||||
{
|
{
|
||||||
|
#ifdef KAK_DEBUG
|
||||||
auto it = m_options.find(name);
|
auto it = m_options.find(name);
|
||||||
assert(it != m_options.end());
|
assert(it != m_options.end());
|
||||||
assert(it->second == true);
|
assert(it->second == true);
|
||||||
|
#endif
|
||||||
|
|
||||||
for (size_t i = 0; i < m_params.size(); ++i)
|
for (size_t i = 0; i < m_params.size(); ++i)
|
||||||
{
|
{
|
||||||
|
|
|
@ -26,10 +26,12 @@ BufferIterator Range::end() const
|
||||||
|
|
||||||
void Range::check_invariant() const
|
void Range::check_invariant() const
|
||||||
{
|
{
|
||||||
|
#ifdef KAK_DEBUG
|
||||||
assert(m_first.is_valid());
|
assert(m_first.is_valid());
|
||||||
assert(m_last.is_valid());
|
assert(m_last.is_valid());
|
||||||
assert(utf8::is_character_start(m_first));
|
assert(utf8::is_character_start(m_first));
|
||||||
assert(utf8::is_character_start(m_last));
|
assert(utf8::is_character_start(m_last));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void avoid_eol(BufferIterator& it)
|
static void avoid_eol(BufferIterator& it)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user