Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[patch-axel-57] add seL4_DebugNameThreadFmt() #26

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/api/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
* SPDX-License-Identifier: GPL-2.0-only
*/

#pragma once

#include <config.h>

#ifdef CONFIG_DEBUG_BUILD
#pragma once

#include <benchmark/benchmark_track.h>
#include <arch/api/syscall.h>
Expand Down
8 changes: 6 additions & 2 deletions libsel4/arch_include/arm/sel4/arch/syscalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -629,10 +629,14 @@ LIBSEL4_INLINE_FUNC seL4_Uint32 seL4_DebugCapIdentify(seL4_CPtr cap)
return (seL4_Uint32)cap;
}

char *strcpy(char *, const char *);
char *strncpy(char *, const char *, seL4_Word);
LIBSEL4_INLINE_FUNC void seL4_DebugNameThread(seL4_CPtr tcb, const char *name)
{
strcpy((char *)seL4_GetIPCBuffer()->msg, name);
/* IPC buffer can be used directly, otherwise buffers must not overlap. */
char *ipc_buf = (char *)seL4_GetIPCBuffer()->msg;
if (name != ipc_buf) {
strncpy(ipc_buf, name, seL4_MsgMaxLength);
}

seL4_Word unused0 = 0;
seL4_Word unused1 = 0;
Expand Down
8 changes: 6 additions & 2 deletions libsel4/arch_include/riscv/sel4/arch/syscalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -834,10 +834,14 @@ LIBSEL4_INLINE_FUNC seL4_Uint32 seL4_DebugCapIdentify(seL4_CPtr cap)
return (seL4_Uint32)cap;
}

char *strcpy(char *, const char *);
char *strncpy(char *, const char *, seL4_Word);
LIBSEL4_INLINE_FUNC void seL4_DebugNameThread(seL4_CPtr tcb, const char *name)
{
strcpy((char *)seL4_GetIPCBuffer()->msg, name);
/* IPC buffer can be used directly, otherwise buffers must not overlap. */
char *ipc_buf = (char *)seL4_GetIPCBuffer()->msg;
if (name != ipc_buf) {
strncpy(ipc_buf, name, seL4_MsgMaxLength);
}

seL4_Word unused0 = 0;
seL4_Word unused1 = 0;
Expand Down
21 changes: 21 additions & 0 deletions libsel4/include/sel4/functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,24 @@ LIBSEL4_INLINE_FUNC void seL4_SetCapReceivePath(seL4_CPtr receiveCNode, seL4_CPt
ipcbuffer->receiveDepth = receiveDepth;
}

#if CONFIG_DEBUG_BUILD

/* Making this a macro avoids requiring stdarg.h to get va_start() */
#define seL4_DebugNameThreadFmt(tcb, fmt, ...) \
do { \
char *ipc_buf = (char *)seL4_GetIPCBuffer()->msg; \
snprintf(ipc_buf, seL4_MsgMaxLength, fmt, __VA_ARGS__); \
seL4_DebugNameThread(tcb, ipc_buf); \
} while(0)

// LIBSEL4_INLINE_FUNC void seL4_DebugNameThreadFmt(seL4_CPtr tcb, const char *fmt, ...)
// {
// char *ipc_buf = (char *)seL4_GetIPCBuffer()->msg;
// va_list args;
// va_start(args, fmt);
// vsnprintf(ipc_buf, seL4_MsgMaxLength, fmt, args)
// va_end(args);
// seL4_DebugNameThread(tcb, ipc_buf);
// }

#endif /* CONFIG_DEBUG_BUILD */
8 changes: 6 additions & 2 deletions libsel4/sel4_arch_include/ia32/sel4/sel4_arch/syscalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -862,10 +862,14 @@ LIBSEL4_INLINE_FUNC seL4_Uint32 seL4_DebugCapIdentify(seL4_CPtr cap)
return (seL4_Uint32)cap;
}

char *strcpy(char *, const char *);
char *strncpy(char *, const char *, seL4_Word);
LIBSEL4_INLINE_FUNC void seL4_DebugNameThread(seL4_CPtr tcb, const char *name)
{
strcpy((char *)seL4_GetIPCBuffer()->msg, name);
/* IPC buffer can be used directly, otherwise buffers must not overlap. */
char *ipc_buf = (char *)seL4_GetIPCBuffer()->msg;
if (name != ipc_buf) {
strncpy(ipc_buf, name, seL4_MsgMaxLength);
}

seL4_Word unused0 = 0;
seL4_Word unused1 = 0;
Expand Down
9 changes: 6 additions & 3 deletions libsel4/sel4_arch_include/x86_64/sel4/sel4_arch/syscalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -658,11 +658,14 @@ LIBSEL4_INLINE_FUNC seL4_Uint32 seL4_DebugCapIdentify(seL4_CPtr cap)
#endif

#ifdef CONFIG_DEBUG_BUILD
char *strcpy(char *, const char *);
char *strncpy(char *, const char *, seL4_Word);
LIBSEL4_INLINE_FUNC void seL4_DebugNameThread(seL4_CPtr tcb, const char *name)
{

strcpy((char *)seL4_GetIPCBuffer()->msg, name);
/* IPC buffer can be used directly, otherwise buffers must not overlap. */
char *ipc_buf = (char *)seL4_GetIPCBuffer()->msg;
if (name != ipc_buf) {
strncpy(ipc_buf, name, seL4_MsgMaxLength);
}

seL4_Word unused0 = 0;
seL4_Word unused1 = 0;
Expand Down