diff --git a/core/arch/arm/kernel/trace_ext.c b/core/arch/arm/kernel/trace_ext.c index 78b87a90eba..35fe8af6c59 100644 --- a/core/arch/arm/kernel/trace_ext.c +++ b/core/arch/arm/kernel/trace_ext.c @@ -31,7 +31,7 @@ #include #include -const char trace_ext_prefix[] = "TEE-CORE"; +const char trace_ext_prefix[] = "TC"; int trace_level = TRACE_LEVEL; static unsigned int puts_lock = SPINLOCK_UNLOCK; diff --git a/lib/libutils/ext/trace.c b/lib/libutils/ext/trace.c index 59e58ce0cd6..cc3ebc4e532 100644 --- a/lib/libutils/ext/trace.c +++ b/lib/libutils/ext/trace.c @@ -51,15 +51,20 @@ int trace_get_level(void) return trace_level; } -static const char *trace_level_to_string(int level, bool level_ok) +static char trace_level_to_string(int level, bool level_ok) { - static const char lvl_strs[][9] = { - "UNKNOWN:", "ERROR: ", "INFO: ", "DEBUG: ", - "FLOW: " }; + /* + * U = Unused + * E = Error + * I = Information + * D = Debug + * F = Flow + */ + static const char lvl_strs[] = { 'U', 'E', 'I', 'D', 'F' }; int l = 0; if (!level_ok) - return "MESSAGE:"; + return 'M'; if ((level >= TRACE_MIN) && (level <= TRACE_MAX)) l = level; @@ -67,6 +72,20 @@ static const char *trace_level_to_string(int level, bool level_ok) return lvl_strs[l]; } +static int print_thread_id(char *buf, size_t bs, int thread_id) +{ +#if CFG_NUM_THREADS > 9 + int num_thread_digits = 2; +#else + int num_thread_digits = 1; +#endif + + if (thread_id >= 0) + return snprintk(buf, bs, "%0*d ", num_thread_digits, thread_id); + else + return snprintk(buf, bs, "%*s ", num_thread_digits, ""); +} + /* Format trace of user ta. Inline with kernel ta */ void trace_printf(const char *function, int line, int level, bool level_ok, const char *fmt, ...) @@ -80,47 +99,44 @@ void trace_printf(const char *function, int line, int level, bool level_ok, if (level_ok && level > trace_level) return; - res = snprintk(buf, sizeof(buf), "%s ", + /* Print the type of message */ + res = snprintk(buf, sizeof(buf), "%c/", trace_level_to_string(level, level_ok)); if (res < 0) return; boffs += res; + /* Print the location, i.e., TEE core or TA */ + res = snprintk(buf + boffs, sizeof(buf) - boffs, "%s:", + trace_ext_prefix); + if (res < 0) + return; + boffs += res; + + /* Print the Thread ID */ if (level_ok && !(BIT(level) & CFG_MSG_LONG_PREFIX_MASK)) thread_id = -1; else thread_id = trace_ext_get_thread_id(); - if (thread_id >= 0) { - res = snprintk(buf + boffs, sizeof(buf) - boffs, "[0x%x] ", - thread_id); - if (res < 0) - return; - boffs += res; - } + res = print_thread_id(buf + boffs, sizeof(buf) - boffs, thread_id); - res = snprintk(buf + boffs, sizeof(buf) - boffs, "%s:", - trace_ext_prefix); if (res < 0) return; boffs += res; + /* Print the function and line */ if (level_ok && !(BIT(level) & CFG_MSG_LONG_PREFIX_MASK)) function = NULL; if (function) { - res = snprintk(buf + boffs, sizeof(buf) - boffs, "%s:%d:", + res = snprintk(buf + boffs, sizeof(buf) - boffs, "%s:%d ", function, line); if (res < 0) return; boffs += res; } - res = snprintk(buf + boffs, sizeof(buf) - boffs, " "); - if (res < 0) - return; - boffs += res; - va_start(ap, fmt); res = vsnprintk(buf + boffs, sizeof(buf) - boffs, fmt, ap); va_end(ap); diff --git a/scripts/symbolize.py b/scripts/symbolize.py index 89538f7d0b7..77f842f703f 100755 --- a/scripts/symbolize.py +++ b/scripts/symbolize.py @@ -35,10 +35,13 @@ import sys TA_UUID_RE = re.compile(r'Status of TA (?P[0-9a-f\-]+)') -TA_INFO_RE = re.compile(': arch: (?P\w+) ' +TA_INFO_RE = re.compile(' arch: (?P\w+) ' 'load address: (?P0x[0-9a-f]+)') CALL_STACK_RE = re.compile('Call stack:') -STACK_ADDR_RE = re.compile(r': (?P0x[0-9a-f]+)') + +# This gets the address from lines looking like this: +# E/TC:0 0x001044a8 +STACK_ADDR_RE = re.compile(r'[UEIDFM]/T[AC]:.*(?P0x[0-9a-f]+)') ABORT_ADDR_RE = re.compile('-abort at address (?P0x[0-9a-f]+)') REGION_RE = re.compile('region [0-9]+: va (?P0x[0-9a-f]+) ' 'pa 0x[0-9a-f]+ size (?P0x[0-9a-f]+)') diff --git a/ta/arch/arm/user_ta_header.c b/ta/arch/arm/user_ta_header.c index b256fa90193..958736a8891 100644 --- a/ta/arch/arm/user_ta_header.c +++ b/ta/arch/arm/user_ta_header.c @@ -33,11 +33,7 @@ int trace_level = TRACE_LEVEL; -#ifdef TA_LOG_PREFIX -const char trace_ext_prefix[] = TA_LOG_PREFIX; -#else -const char trace_ext_prefix[] = "USER-TA"; -#endif +const char trace_ext_prefix[] = "TA"; #ifndef TA_VERSION #define TA_VERSION "Undefined version"