[LibOS] Print exec name alongside PID in the logs

This commit is contained in:
Michał Kowalczyk
2020-07-30 03:17:28 +02:00
parent 3255f8f138
commit 47d19bda95
2 changed files with 7 additions and 6 deletions
-3
View File
@@ -64,9 +64,6 @@ void debug_puts (const char * str);
void debug_putch (int ch);
void debug_vprintf (const char * fmt, va_list ap) __attribute__((format (printf, 1, 0)));
#define VMID_PREFIX "[P%05u] "
#define TID_PREFIX "[%-6u] "
#define NOID_PREFIX "[ ] "
#define debug(fmt, ...) \
do { \
if (debug_handle) \
+7 -3
View File
@@ -103,12 +103,16 @@ void debug_setprefix(shim_tcb_t* tcb) {
struct debug_buf* buf = tcb->debug_buf;
buf->start = buf->end = 0;
const char* exec = PAL_CB(executable);
for (const char* it = exec; *it; it++)
if (*it == ':' || *it == '/')
exec = it + 1;
if (tcb->tid && !is_internal_tid(tcb->tid))
fprintfmt(debug_fputch, NULL, buf, TID_PREFIX, tcb->tid);
fprintfmt(debug_fputch, NULL, buf, "[%u:%s] ", tcb->tid, exec);
else if (cur_process.vmid)
fprintfmt(debug_fputch, NULL, buf, VMID_PREFIX, cur_process.vmid & 0xFFFF);
fprintfmt(debug_fputch, NULL, buf, "[P%u:%s] ", cur_process.vmid & 0xFFFF, exec);
else
fprintfmt(debug_fputch, NULL, buf, NOID_PREFIX);
fprintfmt(debug_fputch, NULL, buf, "[%s] ", exec);
buf->start = buf->end;
}