mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
debug_irq_disable: add module to debug time spent in irq_disable
This commit is contained in:
parent
04287b4795
commit
8145c42955
@ -25,6 +25,7 @@ rsource "congure/Kconfig"
|
||||
rsource "cpp11-compat/Kconfig"
|
||||
rsource "cpp_new_delete/Kconfig"
|
||||
rsource "cxx_ctor_guards/Kconfig"
|
||||
rsource "debug_irq_disable/Kconfig"
|
||||
rsource "div/Kconfig"
|
||||
rsource "embunit/Kconfig"
|
||||
rsource "entropy_source/Kconfig"
|
||||
|
@ -65,6 +65,10 @@ ifneq (,$(filter crc32_fast,$(USEMODULE)))
|
||||
USEMODULE += checksum
|
||||
endif
|
||||
|
||||
ifneq (,$(filter debug_irq_disable,$(USEMODULE)))
|
||||
USEMODULE += fmt
|
||||
endif
|
||||
|
||||
ifneq (,$(filter eepreg,$(USEMODULE)))
|
||||
FEATURES_REQUIRED += periph_eeprom
|
||||
endif
|
||||
|
21
sys/debug_irq_disable/Kconfig
Normal file
21
sys/debug_irq_disable/Kconfig
Normal file
@ -0,0 +1,21 @@
|
||||
# Copyright (C) 2022 Benjamin Valentin
|
||||
#
|
||||
# This file is subject to the terms and conditions of the GNU Lesser
|
||||
# General Public License v2.1. See the file LICENSE in the top level
|
||||
# directory for more details.
|
||||
#
|
||||
|
||||
menuconfig MODULE_DEBUG_IRQ_DISABLE
|
||||
bool "Measure IRQ disable durations"
|
||||
depends on TEST_KCONFIG
|
||||
depends on CPU_CORE_CORTEX_M
|
||||
help
|
||||
Print time spent with IRQs disabled
|
||||
|
||||
config DEBUG_IRQ_DISABLE_THRESHOLD
|
||||
int "Suppress Threshold"
|
||||
default 1
|
||||
depends on MODULE_DEBUG_IRQ_DISABLE
|
||||
help
|
||||
Threshold (in CPU ticks) below which periods with IRQs disabled are not printed.
|
||||
Use this to prevent *a lot* of output when debugging.
|
1
sys/debug_irq_disable/Makefile
Normal file
1
sys/debug_irq_disable/Makefile
Normal file
@ -0,0 +1 @@
|
||||
include $(RIOTBASE)/Makefile.base
|
43
sys/debug_irq_disable/debug_irq_disable.c
Normal file
43
sys/debug_irq_disable/debug_irq_disable.c
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ML!PA Consulting GmbH
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup debug_irq_disable
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Helper for debug_irq_disable
|
||||
*
|
||||
* @author Benjamin Valentin <benjamin.valentin@ml-pa.com>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "fmt.h"
|
||||
|
||||
void debug_irq_disable_print(const char *file, unsigned line, uint32_t ticks)
|
||||
{
|
||||
static bool is_printing;
|
||||
|
||||
if (is_printing) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* prevent infinite recursion if stdio driver uses irq_disable() */
|
||||
is_printing = true;
|
||||
|
||||
print_str("irq disabled for ");
|
||||
print_u32_dec(ticks);
|
||||
print_str(" ticks in ");
|
||||
print_str(file);
|
||||
print_str(":");
|
||||
print_u32_dec(line);
|
||||
print_str("\n");
|
||||
|
||||
is_printing = false;
|
||||
}
|
44
sys/include/debug_irq_disable.h
Normal file
44
sys/include/debug_irq_disable.h
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ML!PA Consulting GmbH
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup debug_irq_disable IRQ Disable Debug helper
|
||||
* @ingroup sys
|
||||
* @brief Debug time spent with IRQ disabled
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
*
|
||||
* @author Benjamin Valentin <benjamin.valentin@ml-pa.com>
|
||||
*/
|
||||
|
||||
#ifndef DEBUG_IRQ_DISABLE_H
|
||||
#define DEBUG_IRQ_DISABLE_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Print time spent with IRQ disabled
|
||||
* @internal
|
||||
*
|
||||
* @param[in] file file where irq_restore() was called
|
||||
* @param[in] line line where irq_restore() was called
|
||||
* @param[in] ticks CPU ticks spent with IRQ disabled
|
||||
*/
|
||||
void debug_irq_disable_print(const char *file, unsigned line, uint32_t ticks);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif /* DEBUG_IRQ_DISABLE_H */
|
Loading…
Reference in New Issue
Block a user