diff options
author | Simon Glass <sjg@chromium.org> | 2023-01-15 14:15:46 -0700 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2023-02-11 12:22:35 -0500 |
commit | d9044e5363bb0b32a7aff00adf47c227f78f0f32 (patch) | |
tree | 2eb15e4b7de4bb64bd2f309c8bb8e49214c8592b | |
parent | 90ad4e28e8d299395922364409c37bd7afc293e4 (diff) | |
download | u-boot-d9044e5363bb0b32a7aff00adf47c227f78f0f32.zip u-boot-d9044e5363bb0b32a7aff00adf47c227f78f0f32.tar.gz u-boot-d9044e5363bb0b32a7aff00adf47c227f78f0f32.tar.bz2 |
trace: Update the file header
It seems better to put the TEXT_BASE value in the file header rather than
in an entry record. While it is true that there is a separate base for
pre-relocation, this can be handled by using offsets in the file.
It is useful to have a version number in case we need to change the trace
format again.
Update the header to make these changes.
Signed-off-by: Simon Glass <sjg@chromium.org>
-rw-r--r-- | include/trace.h | 12 | ||||
-rw-r--r-- | lib/trace.c | 19 |
2 files changed, 14 insertions, 17 deletions
diff --git a/include/trace.h b/include/trace.h index e7aee02..2be8d81 100644 --- a/include/trace.h +++ b/include/trace.h @@ -6,6 +6,8 @@ #ifndef __TRACE_H #define __TRACE_H +/* this file is included from a tool so uses uint32_t instead of u32, etc. */ + enum { /* * This affects the granularity of our trace. We can bin function @@ -23,6 +25,8 @@ enum { * this value. */ FUNC_SITE_SIZE = 4, /* distance between function sites */ + + TRACE_VERSION = 1, }; enum trace_chunk_type { @@ -39,7 +43,11 @@ struct trace_output_func { /* A header at the start of the trace output buffer */ struct trace_output_hdr { enum trace_chunk_type type; /* Record type */ - size_t rec_count; /* Number of records */ + uint32_t version; /* Version (TRACE_VERSION) */ + uint32_t rec_count; /* Number of records */ + uint32_t spare; /* 0 */ + uint64_t text_base; /* Value of CONFIG_TEXT_BASE */ + uint64_t spare2; /* 0 */ }; /* Print statistics about traced function calls */ @@ -63,7 +71,7 @@ int trace_list_functions(void *buff, size_t buff_size, size_t *needed); enum ftrace_flags { FUNCF_EXIT = 0UL << 30, FUNCF_ENTRY = 1UL << 30, - FUNCF_TEXTBASE = 2UL << 30, + /* two more values are available */ FUNCF_TIMESTAMP_MASK = 0x3fffffff, }; diff --git a/lib/trace.c b/lib/trace.c index b9dc6d2..2e2c1be 100644 --- a/lib/trace.c +++ b/lib/trace.c @@ -118,18 +118,6 @@ static void notrace add_ftrace(void *func_ptr, void *caller, ulong flags) hdr->ftrace_count++; } -static void notrace add_textbase(void) -{ - if (hdr->ftrace_count < hdr->ftrace_size) { - struct trace_call *rec = &hdr->ftrace[hdr->ftrace_count]; - - rec->func = CONFIG_TEXT_BASE; - rec->caller = 0; - rec->flags = FUNCF_TEXTBASE; - } - hdr->ftrace_count++; -} - /** * __cyg_profile_func_enter() - record function entry * @@ -278,8 +266,11 @@ int trace_list_calls(void *buff, size_t buff_size, size_t *needed) /* Update the header */ if (output_hdr) { + memset(output_hdr, '\0', sizeof(*output_hdr)); output_hdr->rec_count = upto; output_hdr->type = TRACE_CHUNK_CALLS; + output_hdr->version = TRACE_VERSION; + output_hdr->text_base = CONFIG_TEXT_BASE; } /* Work out how must of the buffer we used */ @@ -385,10 +376,9 @@ int notrace trace_init(void *buff, size_t buff_size) /* Use any remaining space for the timed function trace */ hdr->ftrace = (struct trace_call *)(buff + needed); hdr->ftrace_size = (buff_size - needed) / sizeof(*hdr->ftrace); - add_textbase(); + hdr->depth_limit = CONFIG_TRACE_CALL_DEPTH_LIMIT; puts("trace: enabled\n"); - hdr->depth_limit = CONFIG_TRACE_CALL_DEPTH_LIMIT; trace_enabled = 1; trace_inited = 1; @@ -426,7 +416,6 @@ int notrace trace_early_init(void) /* Use any remaining space for the timed function trace */ hdr->ftrace = (struct trace_call *)((char *)hdr + needed); hdr->ftrace_size = (buff_size - needed) / sizeof(*hdr->ftrace); - add_textbase(); hdr->depth_limit = CONFIG_TRACE_EARLY_CALL_DEPTH_LIMIT; printf("trace: early enable at %08x\n", CONFIG_TRACE_EARLY_ADDR); |