Skip to content

Commit ea5412e

Browse files
thughescfriedt
authored andcommitted
arch: arm: cortex_m: Add debug.h header
Since #75677, it has not been possible to build with CONFIG_NULL_POINTER_EXCEPTION_DETECTION_DWT enabled since there was no declaration of z_arm_debug_enable_null_pointer_detection before its use in arch/arm/core/cortex_m/prep_c.c. This change creates an arch/arm/include/cortex_m/debug.h header that contains declarations for the functions in arch/arm/core/cortex_m/debug.c. Signed-off-by: Tom Hughes <[email protected]>
1 parent b54f438 commit ea5412e

File tree

6 files changed

+46
-10
lines changed

6 files changed

+46
-10
lines changed

arch/arm/core/cortex_m/debug.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <zephyr/kernel.h>
1414
#include <zephyr/device.h>
1515
#include <cortex_m/dwt.h>
16+
#include <cortex_m/debug.h>
1617

1718
/**
1819
* @brief Assess whether a debug monitor event should be treated as an error

arch/arm/core/cortex_m/fault.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#include <zephyr/linker/linker-defs.h>
2121
#include <zephyr/logging/log.h>
2222
#include <zephyr/sys/barrier.h>
23+
#include <cortex_m/debug.h>
24+
2325
LOG_MODULE_DECLARE(os, CONFIG_KERNEL_LOG_LEVEL);
2426

2527
#if defined(CONFIG_PRINTK) || defined(CONFIG_LOG)

arch/arm/core/cortex_m/prep_c.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <zephyr/sys/barrier.h>
2323
#include <zephyr/platform/hooks.h>
2424
#include <zephyr/arch/cache.h>
25+
#include <cortex_m/debug.h>
2526

2627
/*
2728
* GCC can detect if memcpy is passed a NULL argument, however one of

arch/arm/include/cortex_m/debug.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright (c) 2025 Google LLC
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/**
8+
* @file
9+
* @brief ARM Cortex-M debug monitor functions interface based on DWT
10+
*
11+
*/
12+
13+
#ifndef ZEPHYR_ARCH_ARM_INCLUDE_CORTEX_M_DEBUG_H_
14+
#define ZEPHYR_ARCH_ARM_INCLUDE_CORTEX_M_DEBUG_H_
15+
16+
#ifdef __cplusplus
17+
extern "C" {
18+
#endif
19+
20+
/**
21+
* @brief Assess whether a debug monitor event should be treated as an error
22+
*
23+
* This routine checks the status of a debug_monitor() exception, and
24+
* evaluates whether this needs to be considered as a processor error.
25+
*
26+
* @return true if the DM exception is a processor error, otherwise false
27+
*/
28+
bool z_arm_debug_monitor_event_error_check(void);
29+
30+
int z_arm_debug_enable_null_pointer_detection(void);
31+
32+
#ifdef __cplusplus
33+
}
34+
#endif
35+
36+
#endif /* ZEPHYR_ARCH_ARM_INCLUDE_CORTEX_M_DEBUG_H_ */

arch/arm/include/cortex_m/exception.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -261,16 +261,6 @@ static ALWAYS_INLINE void z_arm_set_fault_sp(const struct arch_esf *esf, uint32_
261261
#endif /* CONFIG_DEBUG_COREDUMP */
262262
}
263263

264-
/**
265-
* @brief Assess whether a debug monitor event should be treated as an error
266-
*
267-
* This routine checks the status of a debug_monitor() exception, and
268-
* evaluates whether this needs to be considered as a processor error.
269-
*
270-
* @return true if the DM exception is a processor error, otherwise false
271-
*/
272-
bool z_arm_debug_monitor_event_error_check(void);
273-
274264
#ifdef __cplusplus
275265
}
276266
#endif

tests/misc/test_build/testcase.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,9 @@ tests:
3636
- CONFIG_ISR_TABLES_LOCAL_DECLARATION=y
3737
- CONFIG_LTO=y
3838
- CONFIG_PICOLIBC_USE_MODULE=y
39+
buildsystem.arm.null_pointer_exception_detection_dwt:
40+
build_only: true
41+
platform_allow:
42+
- qemu_cortex_m3
43+
extra_configs:
44+
- CONFIG_NULL_POINTER_EXCEPTION_DETECTION_DWT=y

0 commit comments

Comments
 (0)