Fix --ftrace

This commit is contained in:
Justine Tunney 2024-08-29 23:51:05 -07:00
parent 6baf6cdb10
commit c2420860e6
No known key found for this signature in database
GPG key ID: BE714B4575D6E328

View file

@ -38,6 +38,7 @@
#include "libc/sysv/consts/prot.h"
static struct {
atomic_uint once;
const char *res;
char buf[PATH_MAX];
} g_comdbg;
@ -124,10 +125,11 @@ static void FindDebugBinaryInit(void) {
* @asyncsignalsafe
*/
const char *FindDebugBinary(void) {
cosmo_once(&g_comdbg.once, FindDebugBinaryInit);
return g_comdbg.res;
}
// pay startup cost to make this signal safe from the user's perspective
__attribute__((__constructor__(10))) static void FindDebugBinaryCtor(void) {
FindDebugBinaryInit();
cosmo_once(&g_comdbg.once, FindDebugBinaryInit);
}