5 // Created by James McIlree on 8/10/12.
6 // Copyright (c) 2014 Apple. All rights reserved.
14 uint32_t flags() { return _state.flags; }
15 int capacity() { return _state.nkdbufs; }
16 int thread_map_capacity() { return _state.nkdthreads; }
18 bool is_enabled() { return !_state.nolog; }
19 bool is_initialized() { return flags() & KDBG_BUFINIT; }
20 bool is_thread_map_initialized() { return flags() & KDBG_MAPINIT; }
21 bool is_nowrap() { return flags() & KDBG_NOWRAP; }
22 bool is_freerun() { return flags() & KDBG_FREERUN; }
23 bool is_wrapped() { return flags() & KDBG_WRAPPED; }
25 bool is_lp64() { return (flags() & KDBG_LP64) > 0; }
27 bool is_range_collection_enabled() { return (flags() & KDBG_RANGECHECK) > 0; }
28 bool is_specific_value_collection_enabled() { return (flags() & KDBG_VALCHECK) > 0; }
29 bool is_filter_collection_enabled() { return (flags() & KDBG_TYPEFILTER_CHECK) > 0; }
30 bool is_inclusive_pid_collection_enabled() { return (flags() & KDBG_PIDCHECK) > 0; }
31 bool is_exclusive_pid_collection_enabled() { return (flags() & KDBG_PIDEXCLUDE) > 0; }
33 pid_t controlling_pid() { return _state.bufid; }
36 printf("KDebug State\n");
37 printf("\tBuffer is %s\n", this->is_initialized() ? "initialized" : "not initialized");
38 printf("\tCapacity is %d\n", this->capacity());
39 printf("\tRaw flags 0x%08x\n", this->flags());
40 printf("\tLogging is %s\n", this->is_enabled() ? "enabled" : "disabled");
41 printf("\tWrapping is %s\n", this->is_nowrap() ? "disabled" : "enabled");
42 printf("\tBuffer %s wrapped\n", this->is_wrapped() ? "has" : "has not");
44 // Two bits, 4 possible states:
47 // 1 0 ALL_MARKED_PIDS
48 // 0 1 ALL_UNMARKED_PIDS
53 switch (flags() & (KDBG_PIDEXCLUDE | KDBG_PIDCHECK)) {
58 style = "includes-marked-pids";
61 style = "excludes-marked-pids";
67 printf("\tCollection style is %s\n", style);
68 printf("\tCollection by range is %s\n", this->is_range_collection_enabled() ? "enabled" : "disabled");
69 printf("\tCollection by value is %s\n", this->is_specific_value_collection_enabled() ? "enabled" : "disabled");
70 printf("\tCollection by filter is %s\n", this->is_filter_collection_enabled() ? "enabled" : "disabled");
71 printf("\tThread map is %s ", this->is_thread_map_initialized() ? "initialized\n" : "not initialized\n");
72 printf("\tThread map entries %d\n", this->thread_map_capacity());
73 if (this->controlling_pid() == -1)
74 printf("\tNo controlling pid\n");
76 printf("\tControlled by pid %d\n", this->controlling_pid());