Arduino-Debug
On-target sketch debugger for Arduino
Debug.h File Reference
#include "Arduino.h"
Include dependency graph for Debug.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Debug
 
class  Debug::Variable
 

Macros

#define UNUSED(x)   (void) (x)
 
#define UNLIKELY(x)   __builtin_expect((x), false)
 
#define DEBUG_STREAM(dev)
 
#define ASSERT(cond)
 
#define BREAKPOINT()
 
#define BREAK_IF(cond)
 
#define CHECK_STACK(room)
 
#define OBSERVE_IF(cond, expr)
 
#define OBSERVE(expr)   OBSERVE_IF(true,expr)
 
#define REGISTER(var)
 

Typedefs

typedef const class __FlashStringHelper * str_P
 

Variables

class Debug debug
 

Detailed Description

Version
1.0

License

Copyright (C) 2015-2016, Mikael Patel

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

Definition in file Debug.h.

Macro Definition Documentation

#define ASSERT (   cond)
Value:
do { \
if (UNLIKELY(!(cond))) \
debug.assert(__FILE__,__LINE__, __PRETTY_FUNCTION__, \
F(# cond)); \
} while (0)
void assert(const char *file, int line, const char *func, str_P cond)
Definition: Debug.cpp:47
#define UNLIKELY(x)
Definition: Debug.h:29
class Debug debug
Definition: Debug.cpp:24

Assert the given condition. Calls debug handler if the assertion fails (the condition is false). Will not return if asserted.

Parameters
[in]condcondition.

Definition at line 313 of file Debug.h.

#define BREAK_IF (   cond)
Value:
do { \
if (UNLIKELY(cond)) \
debug.break_at(__FILE__,__LINE__, __PRETTY_FUNCTION__, \
F(# cond)); \
} while (0)
#define UNLIKELY(x)
Definition: Debug.h:29
void break_at(const char *file, int line, const char *func, str_P cond)
Definition: Debug.cpp:59
class Debug debug
Definition: Debug.cpp:24

Mark a conditional break point in the source code. Call the debug command handler with information about the file, line number and function name if the given condition is true.

Parameters
[in]condcondition.

Definition at line 336 of file Debug.h.

#define BREAKPOINT ( )
Value:
do { \
debug.break_at(__FILE__,__LINE__, __PRETTY_FUNCTION__, NULL); \
} while (0)
void break_at(const char *file, int line, const char *func, str_P cond)
Definition: Debug.cpp:59
class Debug debug
Definition: Debug.cpp:24

Mark a break point in the source code. Call the debug command handler with information about the file, line number and function name.

Definition at line 325 of file Debug.h.

#define CHECK_STACK (   room)
Value:
do { \
if (UNLIKELY(!(debug.check_stack(room)))) \
debug.assert(__FILE__,__LINE__, __PRETTY_FUNCTION__, \
F("check_stack()")); \
} while (0)
bool check_stack(int room=128)
Definition: Debug.cpp:69
void assert(const char *file, int line, const char *func, str_P cond)
Definition: Debug.cpp:47
#define UNLIKELY(x)
Definition: Debug.h:29
class Debug debug
Definition: Debug.cpp:24

Check for stack error.

Parameters
[in]roomrequired free space (default 128).

Definition at line 347 of file Debug.h.

#define DEBUG_STREAM (   dev)
Value:
do { \
debug.begin(&dev, __FILE__,__LINE__, __PRETTY_FUNCTION__); \
} while (0)
bool begin(Stream *dev, const char *file, int line, const char *func)
Definition: Debug.cpp:29
class Debug debug
Definition: Debug.cpp:24

Start the debug command handler with information about the file, line number and function name.

Parameters
[in]devstream device.

Definition at line 299 of file Debug.h.

#define OBSERVE (   expr)    OBSERVE_IF(true,expr)

Print the given expression to the debug stream.

Parameters
[in]exprexpression.

Definition at line 373 of file Debug.h.

#define OBSERVE_IF (   cond,
  expr 
)
Value:
do { \
if (UNLIKELY(cond)) { \
debug.observe_at(__FILE__,__LINE__, __PRETTY_FUNCTION__, \
F(# expr)); \
debug.println(expr); \
} \
} while (0)
void observe_at(const char *file, int line, const char *func, str_P expr)
Definition: Debug.cpp:78
#define UNLIKELY(x)
Definition: Debug.h:29
class Debug debug
Definition: Debug.cpp:24

Print the given expression to the debug stream if the condition is true.

Parameters
[in]condcondition.
[in]exprexpression.

Definition at line 360 of file Debug.h.

#define REGISTER (   var)
Value:
Debug::Variable debug__ ## var(__PRETTY_FUNCTION__, \
F(#var), \
(void*) &var, \
sizeof(var));

Register the given variable in the debug handler. The debug handler commands "variables" and "?var" will print information about the registered variable(s).

Parameters
[in]varvariable.

Definition at line 381 of file Debug.h.

#define UNLIKELY (   x)    __builtin_expect((x), false)

Definition at line 29 of file Debug.h.

#define UNUSED (   x)    (void) (x)

Definition at line 25 of file Debug.h.

Typedef Documentation

typedef const class __FlashStringHelper* str_P

Definition at line 32 of file Debug.h.

Variable Documentation

class Debug debug

Definition at line 24 of file Debug.cpp.