1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-28 07:51:19 +01:00

debug: add DEBUG_BREAKPOINT() macro

This commit is contained in:
Benjamin Valentin 2023-03-09 13:44:51 +01:00 committed by Benjamin Valentin
parent bc517b5c47
commit b88c9c5f1f
2 changed files with 34 additions and 0 deletions

View File

@ -59,6 +59,27 @@ extern "C" {
#define DEBUG_PRINT(...) printf(__VA_ARGS__)
#endif
/**
* @def DEBUG_BREAKPOINT
*
* @brief Set a debug breakpoint
*
* When `DEVELHELP` is enabled, this traps the CPU and allows to debug the
* program with e.g. `gdb`.
* Without `DEVELHELP` this turns into a no-op.
*
* @warning If no Debugger is attached, the CPU might get stuck here
* and consume a lot of power until reset.
*
* @param val Breakpoint context for debugger, usually ignored.
*/
#ifdef DEVELHELP
#include "architecture.h"
#define DEBUG_BREAKPOINT(val) ARCHITECTURE_BREAKPOINT(val)
#else
#define DEBUG_BREAKPOINT(val) (void)0
#endif
/**
* @name Debugging defines
* @{

View File

@ -33,6 +33,19 @@
extern "C" {
#endif
/**
* @brief Set a breakpoint
* @warning If no Debugger is attached, the CPU might get stuck here
* and consume a lot of power until reset.
* @param[in] value Context value for debugger, usually ignored.
*/
#ifndef ARCHITECTURE_BREAKPOINT
/* If no breakpoint instruction is defined, busy wait for debugger
* to attach and break to ease backtrace
*/
#define ARCHITECTURE_BREAKPOINT(value) do {} while (1)
#endif
/* Provide doxygen doc centrally, instead of in every architecture_arch.h */
#ifdef DOXYGEN
/**