summaryrefslogtreecommitdiff
path: root/src/user/lib/stdlib.c
diff options
context:
space:
mode:
authordzwdz2023-06-17 17:53:23 +0200
committerdzwdz2023-06-17 17:53:23 +0200
commit657585026a375d2cb2d06ab400f9deb487d89a17 (patch)
treef777a03d136405128d1ea5b947101d863f3e81de /src/user/lib/stdlib.c
parent84fa0102c6906252999967925f32098ab6d5a259 (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.c8
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);
}