mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-25 12:00:31 +00:00
Initial import
This commit is contained in:
commit
c91b3c5006
14915 changed files with 590219 additions and 0 deletions
37
libc/log/gdb.h
Normal file
37
libc/log/gdb.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_LOG_GDB_H_
|
||||
#define COSMOPOLITAN_LIBC_LOG_GDB_H_
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/runtime/missioncritical.h"
|
||||
#include "libc/sysv/consts/nr.h"
|
||||
#include "libc/sysv/consts/w.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
extern volatile int g_gdbsync;
|
||||
|
||||
int gdbexec(const char *);
|
||||
int attachdebugger(intptr_t);
|
||||
|
||||
#define attachdebugger(CONTINUE_TO_ADDR) /* shorten backtraces */ \
|
||||
SYNCHRONIZE_DEBUGGER((attachdebugger)(CONTINUE_TO_ADDR))
|
||||
|
||||
#define SYNCHRONIZE_DEBUGGER(PID) \
|
||||
({ \
|
||||
int Rc, Pid = (PID); \
|
||||
if (Pid != -1) { \
|
||||
while ((Rc = WAIT4(Pid, NULL, WNOHANG, NULL)) == 0) { \
|
||||
if (g_gdbsync) { \
|
||||
g_gdbsync = 0; \
|
||||
if (Rc > 0) Pid = 0; \
|
||||
break; \
|
||||
} else { \
|
||||
SCHED_YIELD(); \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
Pid; \
|
||||
})
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_LOG_GDB_H_ */
|
Loading…
Add table
Add a link
Reference in a new issue