From 657585026a375d2cb2d06ab400f9deb487d89a17 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Sat, 17 Jun 2023 17:53:23 +0200 Subject: libc: expand psdata into a proper struct, include executable base this is very useful for debugging userland programs using the qemu gdb stub --- src/user/lib/stdlib.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/user/lib/stdlib.c') diff --git a/src/user/lib/stdlib.c b/src/user/lib/stdlib.c index 13745d1..1739230 100644 --- a/src/user/lib/stdlib.c +++ b/src/user/lib/stdlib.c @@ -16,18 +16,20 @@ const char *getprogname(void) { } void setprogname(const char *pg) { progname = pg; + setproctitle(NULL); } void setproctitle(const char *fmt, ...) { + // TODO bounds checking if (!fmt) { - strcpy(_libc_psdata, progname); + strcpy(_psdata_loc->desc, progname); return; } - sprintf(_libc_psdata, "%s: ", progname); + sprintf(_psdata_loc->desc, "%s: ", progname); va_list argp; va_start(argp, fmt); - vsnprintf(_libc_psdata + strlen(_libc_psdata), 128, fmt, argp); + vsnprintf(_psdata_loc->desc + strlen(_psdata_loc->desc), 128, fmt, argp); va_end(argp); } -- cgit v1.2.3