diff options
author | dzwdz | 2023-06-17 17:53:23 +0200 |
---|---|---|
committer | dzwdz | 2023-06-17 17:53:23 +0200 |
commit | 657585026a375d2cb2d06ab400f9deb487d89a17 (patch) | |
tree | f777a03d136405128d1ea5b947101d863f3e81de /src/user/lib/stdlib.c | |
parent | 84fa0102c6906252999967925f32098ab6d5a259 (diff) |
libc: expand psdata into a proper struct, include executable base
this is very useful for debugging userland programs using the qemu gdb stub
Diffstat (limited to 'src/user/lib/stdlib.c')
-rw-r--r-- | src/user/lib/stdlib.c | 8 |
1 files changed, 5 insertions, 3 deletions
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); } |