DebugServer2
Loading...
Searching...
No Matches
ProcStat.h
1//
2// Copyright (c) 2015, Jakub Klama <jakub@ixsystems.com>
3// All rights reserved.
4//
5// This source code is licensed under the University of Illinois/NCSA Open
6// Source License found in the LICENSE file in the root directory of this
7// source tree. An additional grant of patent rights can be found in the
8// PATENTS file in the same directory.
9//
10
11#pragma once
12
13#include "DebugServer2/Support/POSIX/ELFSupport.h"
14#include "DebugServer2/Types.h"
15
16#include <cstdio>
17#include <dirent.h>
18#include <fcntl.h>
19#include <functional>
20#include <sys/proc.h>
21#include <sys/stat.h>
22#include <unistd.h>
23
24namespace ds2 {
25namespace Host {
26namespace FreeBSD {
27
29
30enum ProcState {
31 kProcStateDead = 0,
32 kProcStateRunning = SRUN,
33 kProcStateSleeping = SSLEEP,
34 kProcStateWaiting = SWAIT,
35 kProcStateLock = SLOCK,
36 kProcStateStopped = SSTOP,
37 kProcStateZombie = SZOMB
38};
39
40class ProcStat {
41public:
42 static bool GetProcessInfo(ProcessId pid, ProcessInfo &info);
43 static bool GetProcessMap(pid_t pid, std::vector<ds2::MemoryRegionInfo> &map);
44 static bool GetThreadState(pid_t pid, pid_t tid, int &state, int &cpu);
45 static bool EnumerateAuxiliaryVector(
46 pid_t pid,
47 std::function<void(ELFSupport::AuxiliaryVectorEntry const &)> const &cb);
48 static void
49 EnumerateProcesses(bool allUsers, UserId const &uid,
50 std::function<void(pid_t pid, uid_t uid)> const &cb);
51 static void EnumerateThreads(pid_t pid,
52 std::function<void(pid_t tid)> const &cb);
53 static std::string GetThreadName(ProcessId pid, ThreadId tid);
54 static std::string GetExecutablePath(ProcessId pid);
55};
56} // namespace FreeBSD
57} // namespace Host
58} // namespace ds2
Definition ProcStat.h:40
Definition ELFSupport.h:18
Definition Types.h:263
Definition ELFSupport.h:20