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 <daniel.leung@intel.com>
This commit is contained in:
Daniel Leung 2021-01-21 10:11:44 -08:00 committed by Anas Nashif
commit d3218ca515
8 changed files with 63 additions and 63 deletions

View file

@ -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)

View file

@ -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)

View file

@ -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)

View file

@ -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/``

View file

@ -64,15 +64,15 @@ enum coredump_cmd_id {
#include <arch/cpu.h>
#include <sys/byteorder.h>
#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.

View file

@ -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);

View file

@ -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 = "<ccHHBBI"
LOG_HDR_SIZE = struct.calcsize(LOG_HDR_STRUCT)
Z_COREDUMP_ARCH_HDR_ID = b'A'
COREDUMP_ARCH_HDR_ID = b'A'
LOG_ARCH_HDR_STRUCT = "<cHH"
LOG_ARCH_HDR_SIZE = struct.calcsize(LOG_ARCH_HDR_STRUCT)
Z_COREDUMP_MEM_HDR_ID = b'M'
Z_COREDUMP_MEM_HDR_VER = 1
COREDUMP_MEM_HDR_ID = b'M'
COREDUMP_MEM_HDR_VER = 1
LOG_MEM_HDR_STRUCT = "<cH"
LOG_MEM_HDR_SIZE = struct.calcsize(LOG_MEM_HDR_STRUCT)
@ -85,8 +85,8 @@ class CoredumpLogFile:
hdr = self.fd.read(LOG_MEM_HDR_SIZE)
_, hdr_ver = struct.unpack(LOG_MEM_HDR_STRUCT, hdr)
if hdr_ver != Z_COREDUMP_MEM_HDR_VER:
logger.error(f"Memory block version: {hdr_ver}, expected {Z_COREDUMP_MEM_HDR_VER}!")
if hdr_ver != COREDUMP_MEM_HDR_VER:
logger.error(f"Memory block version: {hdr_ver}, expected {COREDUMP_MEM_HDR_VER}!")
return False
# Figure out how to read the start and end addresses
@ -120,13 +120,13 @@ class CoredumpLogFile:
hdr = self.fd.read(LOG_HDR_SIZE)
id1, id2, hdr_ver, tgt_code, ptr_size, flags, reason = struct.unpack(LOG_HDR_STRUCT, hdr)
if (id1 + id2) != Z_COREDUMP_HDR_ID:
if (id1 + id2) != COREDUMP_HDR_ID:
# ID in header does not match
logger.error("Log header ID not found...")
return False
if hdr_ver != Z_COREDUMP_HDR_VER:
logger.error(f"Log version: {hdr_ver}, expected: {Z_COREDUMP_HDR_VER}!")
if hdr_ver != COREDUMP_HDR_VER:
logger.error(f"Log version: {hdr_ver}, expected: {COREDUMP_HDR_VER}!")
return False
ptr_size = 2 ** ptr_size
@ -151,11 +151,11 @@ class CoredumpLogFile:
break
self.fd.seek(-1, 1) # go back 1 byte
if section_id == Z_COREDUMP_ARCH_HDR_ID:
if section_id == COREDUMP_ARCH_HDR_ID:
if not self.parse_arch_section():
logger.error("Cannot parse architecture section")
return False
elif section_id == Z_COREDUMP_MEM_HDR_ID:
elif section_id == COREDUMP_MEM_HDR_ID:
if not self.parse_memory_section():
logger.error("Cannot parse memory section")
return False

View file

@ -27,9 +27,9 @@ static struct z_coredump_backend_api
static void dump_header(unsigned int reason)
{
struct z_coredump_hdr_t hdr = {
struct coredump_hdr_t hdr = {
.id = {'Z', 'E'},
.hdr_version = Z_COREDUMP_HDR_VER,
.hdr_version = COREDUMP_HDR_VER,
.reason = sys_cpu_to_le16(reason),
};
@ -63,11 +63,11 @@ static void dump_thread(struct k_thread *thread)
end_addr = POINTER_TO_UINT(thread) + sizeof(*thread);
z_coredump_memory_dump(POINTER_TO_UINT(thread), end_addr);
coredump_memory_dump(POINTER_TO_UINT(thread), end_addr);
end_addr = thread->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)