mirror of
https://github.com/holub/mame
synced 2025-06-10 06:47:18 +03:00
detect attached debugger on OSX before generating trace/breakpoint trap
This commit is contained in:
parent
31ffaa7819
commit
1ef11ac752
@ -11,6 +11,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
#include <sys/sysctl.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
@ -92,13 +93,22 @@ void osd_free_executable(void *ptr, size_t size)
|
|||||||
|
|
||||||
void osd_break_into_debugger(const char *message)
|
void osd_break_into_debugger(const char *message)
|
||||||
{
|
{
|
||||||
#ifdef MAME_DEBUG
|
pid_t const mypid = getpid();
|
||||||
|
int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, int(mypid) };
|
||||||
|
struct kinfo_proc info;
|
||||||
|
info.kp_proc.p_flag = 0;
|
||||||
|
std::size_t infosz = sizeof(info);
|
||||||
|
sysctl(mib, ARRAY_LENGTH(mib), &info, &infosz, nullptr, 0);
|
||||||
|
if (info.kp_proc.p_flag & P_TRACED)
|
||||||
|
{
|
||||||
printf("MAME exception: %s\n", message);
|
printf("MAME exception: %s\n", message);
|
||||||
printf("Attempting to fall into debugger\n");
|
printf("Attempting to fall into debugger\n");
|
||||||
kill(getpid(), SIGTRAP);
|
kill(mypid, SIGTRAP);
|
||||||
#else
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
printf("Ignoring MAME exception: %s\n", message);
|
printf("Ignoring MAME exception: %s\n", message);
|
||||||
#endif
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user