mirror of
https://github.com/google/sandboxed-api.git
synced 2024-03-22 13:11:30 +08:00
Pretty-print ptrace event name on WIFSTOPPED.
PiperOrigin-RevId: 368688417 Change-Id: I4368268f1b05148213010768a6d4eaa87211ea45
This commit is contained in:
parent
c15b5cb123
commit
d5bd1cb38f
|
@ -440,7 +440,8 @@ void Monitor::MainLoop(sigset_t* sset) {
|
|||
} else if (WIFSTOPPED(status)) {
|
||||
VLOG(2) << "PID: " << ret
|
||||
<< " received signal: " << util::GetSignalName(WSTOPSIG(status))
|
||||
<< " with event: " << __WPTRACEEVENT(status);
|
||||
<< " with event: "
|
||||
<< util::GetPtraceEventName(__WPTRACEEVENT(status));
|
||||
StateProcessStopped(ret, status);
|
||||
} else if (WIFCONTINUED(status)) {
|
||||
VLOG(2) << "PID: " << ret << " is being continued";
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <bits/local_lim.h>
|
||||
#include <sched.h>
|
||||
#include <spawn.h>
|
||||
#include <sys/ptrace.h>
|
||||
#include <sys/resource.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/uio.h>
|
||||
|
@ -283,6 +284,33 @@ std::string GetRlimitName(int resource) {
|
|||
}
|
||||
}
|
||||
|
||||
std::string GetPtraceEventName(int event) {
|
||||
#if !defined(PTRACE_EVENT_STOP)
|
||||
#define PTRACE_EVENT_STOP 128
|
||||
#endif
|
||||
|
||||
switch (event) {
|
||||
case PTRACE_EVENT_FORK:
|
||||
return "PTRACE_EVENT_FORK";
|
||||
case PTRACE_EVENT_VFORK:
|
||||
return "PTRACE_EVENT_VFORK";
|
||||
case PTRACE_EVENT_CLONE:
|
||||
return "PTRACE_EVENT_CLONE";
|
||||
case PTRACE_EVENT_EXEC:
|
||||
return "PTRACE_EVENT_EXEC";
|
||||
case PTRACE_EVENT_VFORK_DONE:
|
||||
return "PTRACE_EVENT_VFORK_DONE";
|
||||
case PTRACE_EVENT_EXIT:
|
||||
return "PTRACE_EVENT_EXIT";
|
||||
case PTRACE_EVENT_SECCOMP:
|
||||
return "PTRACE_EVENT_SECCOMP";
|
||||
case PTRACE_EVENT_STOP:
|
||||
return "PTRACE_EVENT_STOP";
|
||||
default:
|
||||
return absl::StrCat("UNKNOWN: ", event);
|
||||
}
|
||||
}
|
||||
|
||||
absl::StatusOr<std::string> ReadCPathFromPid(pid_t pid, uintptr_t ptr) {
|
||||
std::string path(PATH_MAX, '\0');
|
||||
iovec local_iov[] = {{&path[0], path.size()}};
|
||||
|
|
|
@ -71,6 +71,9 @@ std::string GetSignalName(int signo);
|
|||
// Returns rlimit resource name
|
||||
std::string GetRlimitName(int resource);
|
||||
|
||||
// Returns ptrace event name
|
||||
std::string GetPtraceEventName(int event);
|
||||
|
||||
// Reads a path string (NUL-terminated, shorter than PATH_MAX) from another
|
||||
// process memory
|
||||
absl::StatusOr<std::string> ReadCPathFromPid(pid_t pid, uintptr_t ptr);
|
||||
|
|
Loading…
Reference in New Issue
Block a user