COSA
An Object-Oriented Platform for Arduino Programming
Debug.hh File Reference
#include "Cosa/Types.h"
#include "Cosa/IOStream.hh"
Include dependency graph for Debug.hh:
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 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(expr,true)
 
#define REGISTER(var)
 

Variables

class Debug debug
 

Detailed Description

Version
1.0

License

Copyright (C) 2015, 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.

This file is part of the Arduino Che Cosa project.

Definition in file Debug.hh.

Macro Definition Documentation

#define ASSERT (   cond)
Value:
do { \
if (UNLIKELY(!(cond))) \
debug.assert(__FILE__,__LINE__, __PRETTY_FUNCTION__, \
__PSTR(# cond)); \
} while (0)
void assert(const char *file, int line, const char *func, str_P cond)
Definition: Debug.cpp:45
class Debug debug
Definition: Debug.cpp:23
#define __PSTR(s)
Definition: Types.h:203
#define UNLIKELY(x)
Definition: Types.h:153

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 294 of file Debug.hh.

#define BREAK_IF (   cond)
Value:
do { \
if (UNLIKELY(cond)) \
debug.break_at(__FILE__,__LINE__, __PRETTY_FUNCTION__, \
__PSTR(# cond)); \
} while (0)
class Debug debug
Definition: Debug.cpp:23
void break_at(const char *file, int line, const char *func, str_P cond)
Definition: Debug.cpp:58
#define __PSTR(s)
Definition: Types.h:203
#define UNLIKELY(x)
Definition: Types.h:153

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 317 of file Debug.hh.

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

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 306 of file Debug.hh.

#define CHECK_STACK (   room)
Value:
do { \
if (UNLIKELY(!(debug.check_stack(room)))) \
debug.assert(__FILE__,__LINE__, __PRETTY_FUNCTION__, \
__PSTR("check_stack()")); \
} while (0)
bool check_stack(int room=128)
Definition: Debug.cpp:68
void assert(const char *file, int line, const char *func, str_P cond)
Definition: Debug.cpp:45
class Debug debug
Definition: Debug.cpp:23
#define __PSTR(s)
Definition: Types.h:203
#define UNLIKELY(x)
Definition: Types.h:153

Check for stack error.

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

Definition at line 328 of file Debug.hh.

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

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

Parameters
[in]deviostream device.

Definition at line 280 of file Debug.hh.

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

Print the given expression to the debug iostream.

Parameters
[in]exprexpression.

Definition at line 355 of file Debug.hh.

#define OBSERVE_IF (   cond,
  expr 
)
Value:
do { \
if (UNLIKELY(cond)) { \
debug.observe_at(__FILE__,__LINE__, __PRETTY_FUNCTION__, \
__PSTR(# expr)); \
debug.print(expr); \
} \
} while (0)
void println()
Definition: IOStream.hh:467
void print(int value, Base base=dec)
Definition: IOStream.cpp:46
void observe_at(const char *file, int line, const char *func, str_P expr)
Definition: Debug.hh:119
class Debug debug
Definition: Debug.cpp:23
#define __PSTR(s)
Definition: Types.h:203
#define UNLIKELY(x)
Definition: Types.h:153

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

Parameters
[in]condcondition.
[in]exprexpression.

Definition at line 341 of file Debug.hh.

#define REGISTER (   var)
Value:
Debug::Variable debug__ ## var(__PRETTY_FUNCTION__, \
__PSTR(#var), \
(void*) &var, \
sizeof(var));
#define __PSTR(s)
Definition: Types.h:203

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 363 of file Debug.hh.

Variable Documentation

class Debug debug

Definition at line 23 of file Debug.cpp.