mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-11 02:13:56 +09:00
LibCore: Implement waiting for the debugger on FreeBSD
This commit is contained in:
parent
0f75d0611f
commit
b258450fa6
Notes:
sideshowbarker
2024-07-19 16:52:38 +09:00
Author: https://github.com/ghost
Commit: b258450fa6
Pull-request: https://github.com/SerenityOS/serenity/pull/20712
Reviewed-by: https://github.com/LucasChollet
1 changed files with 9 additions and 2 deletions
|
@ -28,6 +28,9 @@ extern "C" {
|
||||||
# include <hurd.h>
|
# include <hurd.h>
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(AK_OS_FREEBSD)
|
||||||
|
# include <sys/user.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
|
@ -208,7 +211,7 @@ ErrorOr<bool> Process::is_being_debugged()
|
||||||
(void)System::munmap(waits, waits_len);
|
(void)System::munmap(waits, waits_len);
|
||||||
|
|
||||||
return traced;
|
return traced;
|
||||||
#elif defined(AK_OS_MACOS)
|
#elif defined(AK_OS_MACOS) || defined(AK_OS_FREEBSD)
|
||||||
// https://developer.apple.com/library/archive/qa/qa1361/_index.html
|
// https://developer.apple.com/library/archive/qa/qa1361/_index.html
|
||||||
int mib[4] = {};
|
int mib[4] = {};
|
||||||
struct kinfo_proc info = {};
|
struct kinfo_proc info = {};
|
||||||
|
@ -224,8 +227,12 @@ ErrorOr<bool> Process::is_being_debugged()
|
||||||
if (sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, NULL, 0) < 0)
|
if (sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, NULL, 0) < 0)
|
||||||
return Error::from_syscall("sysctl"sv, -errno);
|
return Error::from_syscall("sysctl"sv, -errno);
|
||||||
|
|
||||||
// We're being debugged if the P_TRACED flag is set.
|
// We're being debugged if the P_TRACED flag is set.
|
||||||
|
# if defined(AK_OS_MACOS)
|
||||||
return ((info.kp_proc.p_flag & P_TRACED) != 0);
|
return ((info.kp_proc.p_flag & P_TRACED) != 0);
|
||||||
|
# elif defined(AK_OS_FREEBSD)
|
||||||
|
return ((info.ki_flag & P_TRACED) != 0);
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
// FIXME: Implement this for more platforms.
|
// FIXME: Implement this for more platforms.
|
||||||
return Error::from_string_view("Platform does not support checking for debugger"sv);
|
return Error::from_string_view("Platform does not support checking for debugger"sv);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue