Enabled debug mode when PlatformIO builds in debug

This commit is contained in:
Benoit Blanchon
2020-03-20 17:22:34 +01:00
parent 9cb0ddb5e7
commit 5b812522fa
6 changed files with 19 additions and 9 deletions

View File

@ -7,7 +7,7 @@ project(ArduinoJson)
enable_testing()
add_definitions(-DARDUINOJSON_DEBUG)
add_definitions(-DARDUINOJSON_DEBUG=1)
if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
add_compile_options(-g -O0)
endif()

View File

@ -1,6 +1,6 @@
# CAUTION: this file is invoked by https://github.com/google/oss-fuzz
CXXFLAGS += -I../../src -DARDUINOJSON_DEBUG
CXXFLAGS += -I../../src -DARDUINOJSON_DEBUG=1
all: \
$(OUT)/json_fuzzer \

View File

@ -4,7 +4,9 @@
#pragma once
#ifndef ARDUINOJSON_DEBUG
#include "ArduinoJson/Configuration.hpp"
#if ARDUINOJSON_DEBUG
#ifdef __clang__
#pragma clang system_header
#elif defined __GNUC__
@ -12,8 +14,6 @@
#endif
#endif
#include "ArduinoJson/Namespace.hpp"
#include "ArduinoJson/Array/ArrayRef.hpp"
#include "ArduinoJson/Object/ObjectRef.hpp"
#include "ArduinoJson/Variant/VariantRef.hpp"

View File

@ -210,3 +210,11 @@
#ifndef ARDUINOJSON_STRING_BUFFER_SIZE
#define ARDUINOJSON_STRING_BUFFER_SIZE 32
#endif
#ifndef ARDUINOJSON_DEBUG
#ifdef __PLATFORMIO_BUILD_DEBUG__
#define ARDUINOJSON_DEBUG 1
#else
#define ARDUINOJSON_DEBUG 0
#endif
#endif

View File

@ -12,7 +12,7 @@ template <typename TReader>
class Latch {
public:
Latch(TReader reader) : _reader(reader), _loaded(false) {
#ifdef ARDUINOJSON_DEBUG
#if ARDUINOJSON_DEBUG
_ended = false;
#endif
}
@ -36,7 +36,7 @@ class Latch {
void load() {
ARDUINOJSON_ASSERT(!_ended);
int c = _reader.read();
#ifdef ARDUINOJSON_DEBUG
#if ARDUINOJSON_DEBUG
if (c <= 0)
_ended = true;
#endif
@ -47,7 +47,7 @@ class Latch {
TReader _reader;
char _current;
bool _loaded;
#ifdef ARDUINOJSON_DEBUG
#if ARDUINOJSON_DEBUG
bool _ended;
#endif
};

View File

@ -4,7 +4,9 @@
#pragma once
#ifdef ARDUINOJSON_DEBUG
#include <ArduinoJson/Configuration.hpp>
#if ARDUINOJSON_DEBUG
#include <assert.h>
#define ARDUINOJSON_ASSERT(X) assert(X)
#else