debug: Move away from openocd and make it generic
The exported structures that were originally introduced for OpenOCD have since then been reused for other debugger plugins, including PyOCD and Segger J-Link. Rename the Kconfig option and the implementation from openocd to debug thread info, so that it reflects the fact that this is no longer specifically tied to OpenOCD. Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
This commit is contained in:
parent
ca758c84a8
commit
d2465d6268
|
@ -1084,7 +1084,7 @@ RTOS Awareness
|
|||
|
||||
Support for Zephyr RTOS awareness is implemented in `pyOCD v0.11.0`_ and later.
|
||||
It is compatible with GDB PyOCD Debugging in Eclipse, but you must enable
|
||||
CONFIG_OPENOCD_SUPPORT=y in your application.
|
||||
CONFIG_DEBUG_THREAD_INFO=y in your application.
|
||||
|
||||
.. _cmake-details:
|
||||
|
||||
|
|
|
@ -54,6 +54,9 @@ Deprecated in this release
|
|||
* USB HID specific macros in ``<include/usb/class/usb_hid.h>`` are deprecated
|
||||
in favor of new common HID macros defined in ``<include/usb/class/hid.h>``.
|
||||
|
||||
* The ``CONFIG_OPENOCD_SUPPORT`` Kconfig option has been deprecated in favor
|
||||
of ``CONFIG_DEBUG_THREAD_INFO``.
|
||||
|
||||
==========================
|
||||
|
||||
Removed APIs in this release
|
||||
|
|
|
@ -18,7 +18,7 @@ tests:
|
|||
tracing.osawareness.openocd:
|
||||
extra_configs:
|
||||
- CONFIG_MP_NUM_CPUS=1
|
||||
- CONFIG_OPENOCD_SUPPORT=y
|
||||
- CONFIG_DEBUG_THREAD_INFO=y
|
||||
- CONFIG_SMP=n
|
||||
arch_exclude: posix xtensa
|
||||
platform_exclude: qemu_x86_64
|
||||
|
|
|
@ -20,7 +20,7 @@ ASSERT,n
|
|||
OBJECT_TRACING,n
|
||||
OVERRIDE_FRAME_POINTER_DEFAULT,y
|
||||
DEBUG_INFO,n
|
||||
OPENOCD_SUPPORT,n
|
||||
DEBUG_THREAD_INFO,n
|
||||
TRACING_CPU_STATS,n
|
||||
TRACING_CTF,n
|
||||
USE_SEGGER_RTT,n
|
||||
|
@ -76,7 +76,7 @@ NET_SOCKETS_ENABLE_DTLS,n,experimental
|
|||
NET_SOCKETS_NET_MGMT,n,experimental
|
||||
NET_SOCKETS_OFFLOAD,n,experimental
|
||||
NET_SOCKETS_SOCKOPT_TLS,n,experimental
|
||||
OPENOCD_SUPPORT,n,experimental
|
||||
DEBUG_THREAD_INFO,n,experimental
|
||||
PERFORMANCE_METRICS,n,experimental
|
||||
SHELL_TELNET_SUPPORT_COMMAND,n,experimental
|
||||
SPI_SLAVE,n,experimental
|
||||
|
|
Can't render this file because it has a wrong number of fields in line 44.
|
|
@ -1,8 +1,14 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
if(CONFIG_OPENOCD_SUPPORT)
|
||||
message(WARNING "CONFIG_OPENOCD_SUPPORT is deprecated
|
||||
Please use DEBUG_THREAD_INFO instead."
|
||||
)
|
||||
endif()
|
||||
|
||||
zephyr_sources_ifdef(
|
||||
CONFIG_OPENOCD_SUPPORT
|
||||
openocd.c
|
||||
CONFIG_DEBUG_THREAD_INFO
|
||||
thread_info.c
|
||||
)
|
||||
|
||||
zephyr_sources_ifdef(
|
||||
|
|
|
@ -332,16 +332,20 @@ config EXCEPTION_STACK_TRACE
|
|||
#
|
||||
# Miscellaneous debugging options
|
||||
#
|
||||
|
||||
config OPENOCD_SUPPORT
|
||||
bool "OpenOCD support [EXPERIMENTAL]"
|
||||
bool "OpenOCD support (DEPRECATED)"
|
||||
select DEBUG_THREAD_INFO
|
||||
help
|
||||
This is deprecated, please use DEBUG_THREAD_INFO instead.
|
||||
|
||||
config DEBUG_THREAD_INFO
|
||||
bool "Thread awareness support"
|
||||
depends on !SMP
|
||||
select THREAD_MONITOR
|
||||
select THREAD_NAME
|
||||
help
|
||||
This option exports an array of offsets to kernel structs, used by
|
||||
OpenOCD to determine the state of running threads. (This option
|
||||
selects CONFIG_THREAD_MONITOR, so all of its caveats are implied.)
|
||||
This option exports an array of offsets to kernel structs to allow
|
||||
for debugger RTOS plugins to determine the state of running threads.
|
||||
|
||||
rsource "coredump/Kconfig"
|
||||
endmenu
|
||||
|
|
|
@ -1,114 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2017 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <kernel.h>
|
||||
|
||||
#define OPENOCD_UNIMPLEMENTED 0xffffffff
|
||||
|
||||
#if defined(CONFIG_OPENOCD_SUPPORT) && defined(CONFIG_THREAD_MONITOR)
|
||||
enum {
|
||||
OPENOCD_OFFSET_VERSION,
|
||||
OPENOCD_OFFSET_K_CURR_THREAD,
|
||||
OPENOCD_OFFSET_K_THREADS,
|
||||
OPENOCD_OFFSET_T_ENTRY,
|
||||
OPENOCD_OFFSET_T_NEXT_THREAD,
|
||||
OPENOCD_OFFSET_T_STATE,
|
||||
OPENOCD_OFFSET_T_USER_OPTIONS,
|
||||
OPENOCD_OFFSET_T_PRIO,
|
||||
OPENOCD_OFFSET_T_STACK_PTR,
|
||||
OPENOCD_OFFSET_T_NAME,
|
||||
OPENOCD_OFFSET_T_ARCH,
|
||||
OPENOCD_OFFSET_T_PREEMPT_FLOAT,
|
||||
OPENOCD_OFFSET_T_COOP_FLOAT,
|
||||
};
|
||||
|
||||
#if CONFIG_MP_NUM_CPUS > 1
|
||||
#error "This code doesn't work properly with multiple CPUs enabled"
|
||||
#endif
|
||||
|
||||
/* Forward-compatibility notes: 1) Only append items to this table; otherwise
|
||||
* OpenOCD versions that expect less items will read garbage values.
|
||||
* 2) Avoid incompatible changes that affect the interpretation of existing
|
||||
* items. But if you have to do them, increment OPENOCD_OFFSET_VERSION
|
||||
* and submit a patch for OpenOCD to deal with both the old and new scheme.
|
||||
* Only version 1 is backward compatible to version 0.
|
||||
*/
|
||||
__attribute__((used, section(".openocd_dbg")))
|
||||
size_t _kernel_openocd_offsets[] = {
|
||||
/* Version 0 starts */
|
||||
[OPENOCD_OFFSET_VERSION] = 1,
|
||||
[OPENOCD_OFFSET_K_CURR_THREAD] = offsetof(struct _cpu, current),
|
||||
[OPENOCD_OFFSET_K_THREADS] = offsetof(struct z_kernel, threads),
|
||||
[OPENOCD_OFFSET_T_ENTRY] = offsetof(struct k_thread, entry),
|
||||
[OPENOCD_OFFSET_T_NEXT_THREAD] = offsetof(struct k_thread, next_thread),
|
||||
[OPENOCD_OFFSET_T_STATE] = offsetof(struct _thread_base, thread_state),
|
||||
[OPENOCD_OFFSET_T_USER_OPTIONS] = offsetof(struct _thread_base,
|
||||
user_options),
|
||||
[OPENOCD_OFFSET_T_PRIO] = offsetof(struct _thread_base, prio),
|
||||
#if defined(CONFIG_ARM64)
|
||||
[OPENOCD_OFFSET_T_STACK_PTR] = offsetof(struct k_thread,
|
||||
callee_saved.sp),
|
||||
#elif defined(CONFIG_ARM)
|
||||
[OPENOCD_OFFSET_T_STACK_PTR] = offsetof(struct k_thread,
|
||||
callee_saved.psp),
|
||||
#elif defined(CONFIG_ARC)
|
||||
[OPENOCD_OFFSET_T_STACK_PTR] = offsetof(struct k_thread,
|
||||
callee_saved.sp),
|
||||
#elif defined(CONFIG_X86)
|
||||
#if defined(CONFIG_X86_64)
|
||||
[OPENOCD_OFFSET_T_STACK_PTR] = offsetof(struct k_thread,
|
||||
callee_saved.rsp),
|
||||
#else
|
||||
[OPENOCD_OFFSET_T_STACK_PTR] = offsetof(struct k_thread,
|
||||
callee_saved.esp),
|
||||
#endif
|
||||
#elif defined(CONFIG_NIOS2)
|
||||
[OPENOCD_OFFSET_T_STACK_PTR] = offsetof(struct k_thread,
|
||||
callee_saved.sp),
|
||||
#elif defined(CONFIG_RISCV)
|
||||
[OPENOCD_OFFSET_T_STACK_PTR] = offsetof(struct k_thread,
|
||||
callee_saved.sp),
|
||||
#elif defined(CONFIG_SPARC)
|
||||
[OPENOCD_OFFSET_T_STACK_PTR] = offsetof(struct k_thread,
|
||||
callee_saved.o6),
|
||||
#else
|
||||
/* Use a special value so that OpenOCD knows that obtaining the stack
|
||||
* pointer is not possible on this particular architecture.
|
||||
*/
|
||||
#warning Please define OPENOCD_OFFSET_T_STACK_PTR for this architecture
|
||||
[OPENOCD_OFFSET_T_STACK_PTR] = OPENOCD_UNIMPLEMENTED,
|
||||
#endif
|
||||
/* Version 0 ends */
|
||||
|
||||
[OPENOCD_OFFSET_T_NAME] = offsetof(struct k_thread, name),
|
||||
[OPENOCD_OFFSET_T_ARCH] = offsetof(struct k_thread, arch),
|
||||
#if defined(CONFIG_FPU) && defined(CONFIG_FPU_SHARING) && defined(CONFIG_ARM)
|
||||
[OPENOCD_OFFSET_T_PREEMPT_FLOAT] = offsetof(struct _thread_arch,
|
||||
preempt_float),
|
||||
[OPENOCD_OFFSET_T_COOP_FLOAT] = OPENOCD_UNIMPLEMENTED,
|
||||
#elif defined(CONFIG_FPU) && defined(CONFIG_X86)
|
||||
#if defined(CONFIG_X86_64)
|
||||
[OPENOCD_OFFSET_T_PREEMPT_FLOAT] = offsetof(struct _thread_arch, sse),
|
||||
#else
|
||||
[OPENOCD_OFFSET_T_PREEMPT_FLOAT] = offsetof(struct _thread_arch,
|
||||
preempFloatReg),
|
||||
#endif
|
||||
[OPENOCD_OFFSET_T_COOP_FLOAT] = OPENOCD_UNIMPLEMENTED,
|
||||
#else
|
||||
[OPENOCD_OFFSET_T_PREEMPT_FLOAT] = OPENOCD_UNIMPLEMENTED,
|
||||
[OPENOCD_OFFSET_T_COOP_FLOAT] = OPENOCD_UNIMPLEMENTED,
|
||||
#endif
|
||||
/* Version is still 1, but existence of following elements must be
|
||||
* checked with _kernel_openocd_num_offsets.
|
||||
*/
|
||||
};
|
||||
|
||||
__attribute__((used, section(".openocd_dbg")))
|
||||
size_t _kernel_openocd_num_offsets = ARRAY_SIZE(_kernel_openocd_offsets);
|
||||
|
||||
__attribute__((used, section(".openocd_dbg")))
|
||||
uint8_t _kernel_openocd_size_t_size = (uint8_t)sizeof(size_t);
|
||||
#endif
|
122
subsys/debug/thread_info.c
Normal file
122
subsys/debug/thread_info.c
Normal file
|
@ -0,0 +1,122 @@
|
|||
/*
|
||||
* Copyright (c) 2017 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <kernel.h>
|
||||
|
||||
#define THREAD_INFO_UNIMPLEMENTED 0xffffffff
|
||||
|
||||
enum {
|
||||
THREAD_INFO_OFFSET_VERSION,
|
||||
THREAD_INFO_OFFSET_K_CURR_THREAD,
|
||||
THREAD_INFO_OFFSET_K_THREADS,
|
||||
THREAD_INFO_OFFSET_T_ENTRY,
|
||||
THREAD_INFO_OFFSET_T_NEXT_THREAD,
|
||||
THREAD_INFO_OFFSET_T_STATE,
|
||||
THREAD_INFO_OFFSET_T_USER_OPTIONS,
|
||||
THREAD_INFO_OFFSET_T_PRIO,
|
||||
THREAD_INFO_OFFSET_T_STACK_PTR,
|
||||
THREAD_INFO_OFFSET_T_NAME,
|
||||
THREAD_INFO_OFFSET_T_ARCH,
|
||||
THREAD_INFO_OFFSET_T_PREEMPT_FLOAT,
|
||||
THREAD_INFO_OFFSET_T_COOP_FLOAT,
|
||||
};
|
||||
|
||||
#if CONFIG_MP_NUM_CPUS > 1
|
||||
#error "This code doesn't work properly with multiple CPUs enabled"
|
||||
#endif
|
||||
|
||||
/* Forward-compatibility notes: 1) Only append items to this table; otherwise
|
||||
* debugger plugin versions that expect fewer items will read garbage values.
|
||||
* 2) Avoid incompatible changes that affect the interpretation of existing
|
||||
* items. But if you have to do them, increment THREAD_INFO_OFFSET_VERSION
|
||||
* and submit a patch for debugger plugins to deal with both the old and new
|
||||
* scheme.
|
||||
* Only version 1 is backward compatible to version 0.
|
||||
*/
|
||||
__attribute__((used, section(".openocd_dbg")))
|
||||
size_t _kernel_thread_info_offsets[] = {
|
||||
/* Version 0 starts */
|
||||
[THREAD_INFO_OFFSET_VERSION] = 1,
|
||||
[THREAD_INFO_OFFSET_K_CURR_THREAD] = offsetof(struct _cpu, current),
|
||||
[THREAD_INFO_OFFSET_K_THREADS] = offsetof(struct z_kernel, threads),
|
||||
[THREAD_INFO_OFFSET_T_ENTRY] = offsetof(struct k_thread, entry),
|
||||
[THREAD_INFO_OFFSET_T_NEXT_THREAD] = offsetof(struct k_thread,
|
||||
next_thread),
|
||||
[THREAD_INFO_OFFSET_T_STATE] = offsetof(struct _thread_base,
|
||||
thread_state),
|
||||
[THREAD_INFO_OFFSET_T_USER_OPTIONS] = offsetof(struct _thread_base,
|
||||
user_options),
|
||||
[THREAD_INFO_OFFSET_T_PRIO] = offsetof(struct _thread_base, prio),
|
||||
#if defined(CONFIG_ARM64)
|
||||
[THREAD_INFO_OFFSET_T_STACK_PTR] = offsetof(struct k_thread,
|
||||
callee_saved.sp),
|
||||
#elif defined(CONFIG_ARM)
|
||||
[THREAD_INFO_OFFSET_T_STACK_PTR] = offsetof(struct k_thread,
|
||||
callee_saved.psp),
|
||||
#elif defined(CONFIG_ARC)
|
||||
[THREAD_INFO_OFFSET_T_STACK_PTR] = offsetof(struct k_thread,
|
||||
callee_saved.sp),
|
||||
#elif defined(CONFIG_X86)
|
||||
#if defined(CONFIG_X86_64)
|
||||
[THREAD_INFO_OFFSET_T_STACK_PTR] = offsetof(struct k_thread,
|
||||
callee_saved.rsp),
|
||||
#else
|
||||
[THREAD_INFO_OFFSET_T_STACK_PTR] = offsetof(struct k_thread,
|
||||
callee_saved.esp),
|
||||
#endif
|
||||
#elif defined(CONFIG_NIOS2)
|
||||
[THREAD_INFO_OFFSET_T_STACK_PTR] = offsetof(struct k_thread,
|
||||
callee_saved.sp),
|
||||
#elif defined(CONFIG_RISCV)
|
||||
[THREAD_INFO_OFFSET_T_STACK_PTR] = offsetof(struct k_thread,
|
||||
callee_saved.sp),
|
||||
#elif defined(CONFIG_SPARC)
|
||||
[THREAD_INFO_OFFSET_T_STACK_PTR] = offsetof(struct k_thread,
|
||||
callee_saved.o6),
|
||||
#else
|
||||
/* Use a special value so that OpenOCD knows that obtaining the stack
|
||||
* pointer is not possible on this particular architecture.
|
||||
*/
|
||||
#warning Please define THREAD_INFO_OFFSET_T_STACK_PTR for this architecture
|
||||
[THREAD_INFO_OFFSET_T_STACK_PTR] = THREAD_INFO_UNIMPLEMENTED,
|
||||
#endif
|
||||
/* Version 0 ends */
|
||||
|
||||
[THREAD_INFO_OFFSET_T_NAME] = offsetof(struct k_thread, name),
|
||||
[THREAD_INFO_OFFSET_T_ARCH] = offsetof(struct k_thread, arch),
|
||||
#if defined(CONFIG_FPU) && defined(CONFIG_FPU_SHARING) && defined(CONFIG_ARM)
|
||||
[THREAD_INFO_OFFSET_T_PREEMPT_FLOAT] = offsetof(struct _thread_arch,
|
||||
preempt_float),
|
||||
[THREAD_INFO_OFFSET_T_COOP_FLOAT] = THREAD_INFO_UNIMPLEMENTED,
|
||||
#elif defined(CONFIG_FPU) && defined(CONFIG_X86)
|
||||
#if defined(CONFIG_X86_64)
|
||||
[THREAD_INFO_OFFSET_T_PREEMPT_FLOAT] = offsetof(struct _thread_arch,
|
||||
sse),
|
||||
#else
|
||||
[THREAD_INFO_OFFSET_T_PREEMPT_FLOAT] = offsetof(struct _thread_arch,
|
||||
preempFloatReg),
|
||||
#endif
|
||||
[THREAD_INFO_OFFSET_T_COOP_FLOAT] = THREAD_INFO_UNIMPLEMENTED,
|
||||
#else
|
||||
[THREAD_INFO_OFFSET_T_PREEMPT_FLOAT] = THREAD_INFO_UNIMPLEMENTED,
|
||||
[THREAD_INFO_OFFSET_T_COOP_FLOAT] = THREAD_INFO_UNIMPLEMENTED,
|
||||
#endif
|
||||
/* Version is still 1, but existence of following elements must be
|
||||
* checked with _kernel_thread_info_num_offsets.
|
||||
*/
|
||||
};
|
||||
extern size_t __attribute__((alias("_kernel_thread_info_offsets")))
|
||||
_kernel_openocd_offsets;
|
||||
|
||||
__attribute__((used, section(".openocd_dbg")))
|
||||
size_t _kernel_thread_info_num_offsets = ARRAY_SIZE(_kernel_thread_info_offsets);
|
||||
extern size_t __attribute__((alias("_kernel_thread_info_num_offsets")))
|
||||
_kernel_openocd_num_offsets;
|
||||
|
||||
__attribute__((used, section(".openocd_dbg")))
|
||||
uint8_t _kernel_thread_info_size_t_size = (uint8_t)sizeof(size_t);
|
||||
extern uint8_t __attribute__((alias("_kernel_thread_info_size_t_size")))
|
||||
_kernel_openocd_size_t_size;
|
Loading…
Reference in a new issue