]> git.saurik.com Git - apple/system_cmds.git/blob - KDBG/KDThreadMapEntry.hpp
82dd3db870d204a70084473bae32b45a2bf0239b
[apple/system_cmds.git] / KDBG / KDThreadMapEntry.hpp
1 //
2 // KDThreadMapEntry.hpp
3 // KDBG
4 //
5 // Created by James McIlree on 10/25/12.
6 // Copyright (c) 2014 Apple. All rights reserved.
7 //
8
9 #ifndef kdprof_KDThreadMapEntry_hpp
10 #define kdprof_KDThreadMapEntry_hpp
11
12 //
13 // This is the kd_threadmap from the kernel
14 //
15 // There is one interesting conflict I have noticed so far.
16 //
17 // The _pid field is set to 1 for kernel threads that have no user space
18 // representation. However, 1 is a valid pid, and in fact, used by launchd.
19 //
20 // A full disambiguation of entries *must* include the tid, pid, AND name:
21 //
22 // 000000000000011f 00000001 launchd
23 // 000000000000014f 00000001 launchd
24 // 0000000000000150 00000001 launchd
25 //
26 // 0000000000000110 00000001 kernel_task
27 // 0000000000000120 00000001 kernel_task
28 // 0000000000000133 00000001 kernel_task
29 //
30 template <typename SIZE>
31 class KDThreadMapEntry {
32 protected:
33 typename SIZE::ptr_t _tid;
34 int32_t _pid;
35 char _name[20]; // This is process name, not thread name!
36
37 public:
38 typename SIZE::ptr_t tid() const { return _tid; }
39 int32_t pid() const { return _pid; }
40 const char* name() const { return _name; }
41 };
42
43 #endif