From d3218ca515ce6d622ad0c33c64a2f09ec2d469fc Mon Sep 17 00:00:00 2001 From: Daniel Leung Date: Thu, 21 Jan 2021 10:11:44 -0800 Subject: [PATCH] debug: coredump: remove z_ prefix for stuff used outside subsys This removes the z_ prefix those (functions, enums, etc.) that are being used outside the coredump subsys. This aligns better with the naming convention. Signed-off-by: Daniel Leung --- arch/arm/core/aarch32/cortex_m/coredump.c | 8 ++--- arch/x86/core/ia32/coredump.c | 8 ++--- arch/x86/core/intel64/coredump.c | 8 ++--- doc/guides/flash_debug/coredump.rst | 4 +-- include/debug/coredump.h | 44 +++++++++++------------ kernel/fatal.c | 2 +- scripts/coredump/parser/log_parser.py | 24 ++++++------- subsys/debug/coredump/coredump_core.c | 28 +++++++-------- 8 files changed, 63 insertions(+), 63 deletions(-) diff --git a/arch/arm/core/aarch32/cortex_m/coredump.c b/arch/arm/core/aarch32/cortex_m/coredump.c index 58255e0327d..53567f349d2 100644 --- a/arch/arm/core/aarch32/cortex_m/coredump.c +++ b/arch/arm/core/aarch32/cortex_m/coredump.c @@ -33,8 +33,8 @@ static struct arm_arch_block arch_blk; void arch_coredump_info_dump(const z_arch_esf_t *esf) { - struct z_coredump_arch_hdr_t hdr = { - .id = Z_COREDUMP_ARCH_HDR_ID, + struct coredump_arch_hdr_t hdr = { + .id = COREDUMP_ARCH_HDR_ID, .hdr_version = ARCH_HDR_VER, .num_bytes = sizeof(arch_blk), }; @@ -65,8 +65,8 @@ void arch_coredump_info_dump(const z_arch_esf_t *esf) arch_blk.r.sp = z_arm_coredump_fault_sp; /* Send for output */ - z_coredump_buffer_output((uint8_t *)&hdr, sizeof(hdr)); - z_coredump_buffer_output((uint8_t *)&arch_blk, sizeof(arch_blk)); + coredump_buffer_output((uint8_t *)&hdr, sizeof(hdr)); + coredump_buffer_output((uint8_t *)&arch_blk, sizeof(arch_blk)); } uint16_t arch_coredump_tgt_code_get(void) diff --git a/arch/x86/core/ia32/coredump.c b/arch/x86/core/ia32/coredump.c index bc60ce020f4..5c67047c55a 100644 --- a/arch/x86/core/ia32/coredump.c +++ b/arch/x86/core/ia32/coredump.c @@ -36,8 +36,8 @@ static struct x86_arch_block arch_blk; void arch_coredump_info_dump(const z_arch_esf_t *esf) { - struct z_coredump_arch_hdr_t hdr = { - .id = Z_COREDUMP_ARCH_HDR_ID, + struct coredump_arch_hdr_t hdr = { + .id = COREDUMP_ARCH_HDR_ID, .hdr_version = ARCH_HDR_VER, .num_bytes = sizeof(arch_blk), }; @@ -72,8 +72,8 @@ void arch_coredump_info_dump(const z_arch_esf_t *esf) arch_blk.r.cs = esf->cs & 0xFFFFU; /* Send for output */ - z_coredump_buffer_output((uint8_t *)&hdr, sizeof(hdr)); - z_coredump_buffer_output((uint8_t *)&arch_blk, sizeof(arch_blk)); + coredump_buffer_output((uint8_t *)&hdr, sizeof(hdr)); + coredump_buffer_output((uint8_t *)&arch_blk, sizeof(arch_blk)); } uint16_t arch_coredump_tgt_code_get(void) diff --git a/arch/x86/core/intel64/coredump.c b/arch/x86/core/intel64/coredump.c index 42837792a80..3405e0dfbad 100644 --- a/arch/x86/core/intel64/coredump.c +++ b/arch/x86/core/intel64/coredump.c @@ -48,8 +48,8 @@ static struct x86_64_arch_block arch_blk; void arch_coredump_info_dump(const z_arch_esf_t *esf) { - struct z_coredump_arch_hdr_t hdr = { - .id = Z_COREDUMP_ARCH_HDR_ID, + struct coredump_arch_hdr_t hdr = { + .id = COREDUMP_ARCH_HDR_ID, .hdr_version = ARCH_HDR_VER, .num_bytes = sizeof(arch_blk), }; @@ -98,8 +98,8 @@ void arch_coredump_info_dump(const z_arch_esf_t *esf) #endif /* Send for output */ - z_coredump_buffer_output((uint8_t *)&hdr, sizeof(hdr)); - z_coredump_buffer_output((uint8_t *)&arch_blk, sizeof(arch_blk)); + coredump_buffer_output((uint8_t *)&hdr, sizeof(hdr)); + coredump_buffer_output((uint8_t *)&arch_blk, sizeof(arch_blk)); } uint16_t arch_coredump_tgt_code_get(void) diff --git a/doc/guides/flash_debug/coredump.rst b/doc/guides/flash_debug/coredump.rst index a1c1c97550d..56930ea34a1 100644 --- a/doc/guides/flash_debug/coredump.rst +++ b/doc/guides/flash_debug/coredump.rst @@ -310,12 +310,12 @@ The architecture-specific block is target specific and requires new dumping routine and parser for new targets. To add a new target, the following needs to be done: -#. Add a new target code to the ``enum z_coredump_tgt_code`` in +#. Add a new target code to the ``enum coredump_tgt_code`` in :zephyr_file:`include/debug/coredump.h`. #. Implement :c:func:`arch_coredump_tgt_code_get` simply to return the newly introducted target code. #. Implement :c:func:`arch_coredump_info_dump` to construct - a target architecture block and call :c:func:`z_coredump_buffer_output` + a target architecture block and call :c:func:`coredump_buffer_output` to output the block to core dump backend. #. Add a parser to the core dump GDB stub scripts under ``scripts/coredump/gdbstubs/`` diff --git a/include/debug/coredump.h b/include/debug/coredump.h index 2ea49a25f23..628af94945b 100644 --- a/include/debug/coredump.h +++ b/include/debug/coredump.h @@ -64,15 +64,15 @@ enum coredump_cmd_id { #include #include -#define Z_COREDUMP_HDR_VER 1 +#define COREDUMP_HDR_VER 1 -#define Z_COREDUMP_ARCH_HDR_ID 'A' +#define COREDUMP_ARCH_HDR_ID 'A' -#define Z_COREDUMP_MEM_HDR_ID 'M' -#define Z_COREDUMP_MEM_HDR_VER 1 +#define COREDUMP_MEM_HDR_ID 'M' +#define COREDUMP_MEM_HDR_VER 1 /* Target code */ -enum z_coredump_tgt_code { +enum coredump_tgt_code { COREDUMP_TGT_UNKNOWN = 0, COREDUMP_TGT_X86, COREDUMP_TGT_X86_64, @@ -80,7 +80,7 @@ enum z_coredump_tgt_code { }; /* Coredump header */ -struct z_coredump_hdr_t { +struct coredump_hdr_t { /* 'Z', 'E' */ char id[2]; @@ -100,8 +100,8 @@ struct z_coredump_hdr_t { } __packed; /* Architecture-specific block header */ -struct z_coredump_arch_hdr_t { - /* Z_COREDUMP_ARCH_HDR_ID */ +struct coredump_arch_hdr_t { + /* COREDUMP_ARCH_HDR_ID */ char id; /* Header version */ @@ -112,8 +112,8 @@ struct z_coredump_arch_hdr_t { } __packed; /* Memory block header */ -struct z_coredump_mem_hdr_t { - /* Z_COREDUMP_MEM_HDR_ID */ +struct coredump_mem_hdr_t { + /* COREDUMP_MEM_HDR_ID */ char id; /* Header version */ @@ -126,26 +126,26 @@ struct z_coredump_mem_hdr_t { uintptr_t end; } __packed; -void z_coredump(unsigned int reason, const z_arch_esf_t *esf, - struct k_thread *thread); -void z_coredump_memory_dump(uintptr_t start_addr, uintptr_t end_addr); -void z_coredump_buffer_output(uint8_t *buf, size_t buflen); +void coredump(unsigned int reason, const z_arch_esf_t *esf, + struct k_thread *thread); +void coredump_memory_dump(uintptr_t start_addr, uintptr_t end_addr); +void coredump_buffer_output(uint8_t *buf, size_t buflen); int coredump_query(enum coredump_query_id query_id, void *arg); int coredump_cmd(enum coredump_cmd_id cmd_id, void *arg); #else -void z_coredump(unsigned int reason, const z_arch_esf_t *esf, - struct k_thread *thread) +void coredump(unsigned int reason, const z_arch_esf_t *esf, + struct k_thread *thread) { } -void z_coredump_memory_dump(uintptr_t start_addr, uintptr_t end_addr) +void coredump_memory_dump(uintptr_t start_addr, uintptr_t end_addr) { } -void z_coredump_buffer_output(uint8_t *buf, size_t buflen) +void coredump_buffer_output(uint8_t *buf, size_t buflen) { } @@ -168,7 +168,7 @@ int coredump_cmd(enum coredump_cmd_id query_id, void *arg) */ /** - * @fn void z_coredump(unsigned int reason, const z_arch_esf_t *esf, struct k_thread *thread); + * @fn void coredump(unsigned int reason, const z_arch_esf_t *esf, struct k_thread *thread); * @brief Perform coredump. * * Normally, this is called inside z_fatal_error() to generate coredump @@ -181,15 +181,15 @@ int coredump_cmd(enum coredump_cmd_id query_id, void *arg) */ /** - * @fn void z_coredump_memory_dump(uintptr_t start_addr, uintptr_t end_addr); + * @fn void coredump_memory_dump(uintptr_t start_addr, uintptr_t end_addr); * @brief Dump memory region * * @param start_addr Start address of memory region to be dumped - * @param emd_addr End address of memory region to be dumped + * @param end_addr End address of memory region to be dumped */ /** - * @fn int z_coredump_buffer_output(uint8_t *buf, size_t buflen); + * @fn int coredump_buffer_output(uint8_t *buf, size_t buflen); * @brief Output the buffer via coredump * * This outputs the buffer of byte array to the coredump backend. diff --git a/kernel/fatal.c b/kernel/fatal.c index a31e0f163df..e73608a3bb1 100644 --- a/kernel/fatal.c +++ b/kernel/fatal.c @@ -121,7 +121,7 @@ void z_fatal_error(unsigned int reason, const z_arch_esf_t *esf) LOG_ERR("Current thread: %p (%s)", thread, log_strdup(thread_name_get(thread))); - z_coredump(reason, esf, thread); + coredump(reason, esf, thread); k_sys_fatal_error_handler(reason, esf); diff --git a/scripts/coredump/parser/log_parser.py b/scripts/coredump/parser/log_parser.py index d6568e1d0e1..119cd668e6a 100644 --- a/scripts/coredump/parser/log_parser.py +++ b/scripts/coredump/parser/log_parser.py @@ -9,17 +9,17 @@ import struct # Note: keep sync with C code -Z_COREDUMP_HDR_ID = b'ZE' -Z_COREDUMP_HDR_VER = 1 +COREDUMP_HDR_ID = b'ZE' +COREDUMP_HDR_VER = 1 LOG_HDR_STRUCT = "stack_info.start + thread->stack_info.size; - z_coredump_memory_dump(thread->stack_info.start, end_addr); + coredump_memory_dump(thread->stack_info.start, end_addr); #endif } @@ -84,15 +84,15 @@ void process_memory_region_list(void) break; } - z_coredump_memory_dump(r->start, r->end); + coredump_memory_dump(r->start, r->end); idx++; } #endif } -void z_coredump(unsigned int reason, const z_arch_esf_t *esf, - struct k_thread *thread) +void coredump(unsigned int reason, const z_arch_esf_t *esf, + struct k_thread *thread) { z_coredump_start(); @@ -121,7 +121,7 @@ void z_coredump_end(void) backend_api->end(); } -void z_coredump_buffer_output(uint8_t *buf, size_t buflen) +void coredump_buffer_output(uint8_t *buf, size_t buflen) { if ((buf == NULL) || (buflen == 0)) { /* Invalid buffer, skip */ @@ -131,9 +131,9 @@ void z_coredump_buffer_output(uint8_t *buf, size_t buflen) backend_api->buffer_output(buf, buflen); } -void z_coredump_memory_dump(uintptr_t start_addr, uintptr_t end_addr) +void coredump_memory_dump(uintptr_t start_addr, uintptr_t end_addr) { - struct z_coredump_mem_hdr_t m; + struct coredump_mem_hdr_t m; size_t len; if ((start_addr == POINTER_TO_UINT(NULL)) || @@ -147,8 +147,8 @@ void z_coredump_memory_dump(uintptr_t start_addr, uintptr_t end_addr) len = end_addr - start_addr; - m.id = Z_COREDUMP_MEM_HDR_ID; - m.hdr_version = Z_COREDUMP_MEM_HDR_VER; + m.id = COREDUMP_MEM_HDR_ID; + m.hdr_version = COREDUMP_MEM_HDR_VER; if (sizeof(uintptr_t) == 8) { m.start = sys_cpu_to_le64(start_addr); @@ -158,9 +158,9 @@ void z_coredump_memory_dump(uintptr_t start_addr, uintptr_t end_addr) m.end = sys_cpu_to_le32(end_addr); } - z_coredump_buffer_output((uint8_t *)&m, sizeof(m)); + coredump_buffer_output((uint8_t *)&m, sizeof(m)); - z_coredump_buffer_output((uint8_t *)start_addr, len); + coredump_buffer_output((uint8_t *)start_addr, len); } int coredump_query(enum coredump_query_id query_id, void *arg)