Loading...
--- xnu/xnu-12377.121.6/bsd/sys/kdebug_kernel.h
+++ xnu/xnu-6153.11.26/bsd/sys/kdebug_kernel.h
@@ -33,7 +33,6 @@
#include <mach/clock_types.h>
#include <stdbool.h>
#include <stdint.h>
-#include <stddef.h>
#include <sys/cdefs.h>
__BEGIN_DECLS
@@ -133,21 +132,6 @@
bool kdebug_using_continuous_time(void);
/*
- * Convert an absolute time to a kdebug timestamp.
- */
-extern uint64_t kdebug_timestamp_from_absolute(uint64_t abstime);
-
-/*
- * Convert a continuous time to a kdebug timestamp.
- */
-extern uint64_t kdebug_timestamp_from_continuous(uint64_t conttime);
-
-/*
- * Capture a kdebug timestamp for the current time.
- */
-extern uint64_t kdebug_timestamp(void);
-
-/*
* Returns true if kdebug will log an event with the provided debugid, and
* false otherwise.
*/
@@ -161,64 +145,31 @@
uint32_t kdebug_commpage_state(void);
-#pragma mark - Coprocessor/IOP tracing
+#pragma mark - IOP tracing
+
+/*
+ * Definitions to support IOP tracing.
+ */
typedef enum {
- /* Trace is now enabled. */
+ /* Trace is now enabled; no arguments. */
KD_CALLBACK_KDEBUG_ENABLED,
- /*
- * Trace is being disabled, but events are still accepted for the duration
- * of the callback.
- */
+ /* Trace is now disabled; no arguments. */
KD_CALLBACK_KDEBUG_DISABLED,
/*
- * Request the latest events from the IOP and block until complete. Any
- * events that occur prior to this callback being called may be dropped by
- * the trace system.
+ * Request the latest entries from the IOP and block until complete; no
+ * arguments.
*/
KD_CALLBACK_SYNC_FLUSH,
/*
- * The typefilter is being used.
- *
- * A read-only pointer to the typefilter is provided as the argument, valid
- * only in the callback.
+ * The typefilter is enabled; a read-only pointer to the typefilter is
+ * provided, valid only while in the callback.
*/
KD_CALLBACK_TYPEFILTER_CHANGED,
- /*
- * The coprocessor should emit data that snapshots the current state of the
- * system.
- */
- KD_CALLBACK_SNAPSHOT_STATE,
} kd_callback_type;
-__options_decl(kdebug_coproc_flags_t, uint32_t, {
- /*
- * Event timestamps from this coprocessor are in the continuous timebase.
- */
- KDCP_CONTINUOUS_TIME = 0x001,
-});
-
-typedef void (*kd_callback_fn)(void *context, kd_callback_type reason,
+typedef void (*kd_callback_fn) (void *context, kd_callback_type reason,
void *arg);
-
-/*
- * Register a coprocessor for participation in tracing.
- *
- * The `callback` function will be called with the provided `context` when
- * necessary, according to the `kd_callback_type`s.
- *
- * The positive core ID is returned on success, or -1 on failure.
- */
-int kdebug_register_coproc(const char *name, kdebug_coproc_flags_t flags,
- kd_callback_fn callback, void *context);
-
-void kernel_debug_enter(uint32_t coreid, uint32_t debugid, uint64_t timestamp,
- uintptr_t arg1, uintptr_t arg2, uintptr_t arg3, uintptr_t arg4,
- uintptr_t threadid);
-
-/*
- * Legacy definitions for the prior IOP tracing.
- */
struct kd_callback {
kd_callback_fn func;
@@ -226,10 +177,30 @@
/* name of IOP, NUL-terminated */
char iop_name[8];
};
+
typedef struct kd_callback kd_callback_t;
-__kpi_deprecated("use kdebug_register_coproc instead")
+/*
+ * Registers an IOP for participation in tracing.
+ *
+ * The registered callback function will be called with the
+ * supplied context as the first argument, followed by a
+ * kd_callback_type and an associated void* argument.
+ *
+ * The return value is a nonzero coreid that shall be used in
+ * kernel_debug_enter() to refer to your IOP. If the allocation
+ * failed, then 0 will be returned.
+ *
+ * Caveats:
+ * Note that not all callback calls will indicate a change in
+ * state (e.g. disabling trace twice would send two disable
+ * notifications).
+ */
int kernel_debug_register_callback(kd_callback_t callback);
+
+void kernel_debug_enter(uint32_t coreid, uint32_t debugid, uint64_t timestamp,
+ uintptr_t arg1, uintptr_t arg2, uintptr_t arg3, uintptr_t arg4,
+ uintptr_t threadid);
#pragma mark - internals
@@ -297,7 +268,7 @@
do { \
if (KDBG_IMPROBABLE(kdebug_enable & ~KDEBUG_ENABLE_PPT)) { \
kernel_debug_flags((x), (uintptr_t)(a), (uintptr_t)(b), \
- (uintptr_t)(c), (uintptr_t)(d), KDBG_NON_PROCESS); \
+ (uintptr_t)(c), (uintptr_t)(d), KDBG_FLAG_NOPROCFILT); \
} \
} while (0)
#else /* (KDEBUG_LEVEL >= KDEBUG_LEVEL_IST) */
@@ -328,9 +299,15 @@
} \
} while (0)
+#define KERNEL_DEBUG_EARLY(x, a, b, c, d) \
+ do { \
+ kernel_debug_early((uint32_t)(x), (uintptr_t)(a), (uintptr_t)(b), \
+ (uintptr_t)(c), (uintptr_t)(d)); \
+ } while (0)
#else /* (KDEBUG_LEVEL >= KDEBUG_LEVEL_STANDARD) */
#define KERNEL_DEBUG_CONSTANT(x, a, b, c, d, e) do {} while (0)
#define KERNEL_DEBUG_CONSTANT1(x, a, b, c, d, e) do {} while (0)
+#define KERNEL_DEBUG_EARLY(x, a, b, c, d) do {} while (0)
#endif /* (KDEBUG_LEVEL >= KDEBUG_LEVEL_STANDARD) */
/*
@@ -352,7 +329,6 @@
(uintptr_t)(d), 0); \
} \
} while (0)
-
#define KERNEL_DEBUG_CONSTANT_IST1(x, a, b, c, d, e) \
do { \
if (KDBG_IMPROBABLE(kdebug_enable)) { \
@@ -360,17 +336,9 @@
(uintptr_t)(d), (uintptr_t)(e)); \
} \
} while (0)
-
-#define KERNEL_DEBUG_EARLY(x, a, b, c, d) \
- do { \
- kernel_debug_early((uint32_t)(x), (uintptr_t)(a), (uintptr_t)(b), \
- (uintptr_t)(c), (uintptr_t)(d)); \
- } while (0)
-
#else /* (KDEBUG_LEVEL >= KDEBUG_LEVEL_IST) */
#define KERNEL_DEBUG_CONSTANT_IST(type, x, a, b, c, d, e) do {} while (0)
#define KERNEL_DEBUG_CONSTANT_IST1(x, a, b, c, d, e) do {} while (0)
-#define KERNEL_DEBUG_EARLY(x, a, b, c, d) do {} while (0)
#endif /* (KDEBUG_LEVEL >= KDEBUG_LEVEL_IST) */
#if NO_KDEBUG
@@ -420,13 +388,11 @@
void kernel_debug1(uint32_t debugid, uintptr_t arg1, uintptr_t arg2,
uintptr_t arg3, uintptr_t arg4, uintptr_t arg5);
-__options_decl(kdebug_emit_flags_t, uint64_t, {
- KDBG_FILTER_ONLY = 0x01,
- KDBG_NON_PROCESS = 0x02,
-});
+#define KDBG_FLAG_FILTERED 0x01
+#define KDBG_FLAG_NOPROCFILT 0x02
void kernel_debug_flags(uint32_t debugid, uintptr_t arg1, uintptr_t arg2,
- uintptr_t arg3, uintptr_t arg4, kdebug_emit_flags_t flags);
+ uintptr_t arg3, uintptr_t arg4, uint64_t flags);
void kernel_debug_filtered(uint32_t debugid, uintptr_t arg1, uintptr_t arg2,
uintptr_t arg3, uintptr_t arg4);
@@ -434,9 +400,6 @@
#pragma mark - xnu API
#ifdef XNU_KERNEL_PRIVATE
-
-void kdebug_startup(void);
-
/* Used in early boot to log events. */
void kernel_debug_early(uint32_t debugid, uintptr_t arg1, uintptr_t arg2,
uintptr_t arg3, uintptr_t arg4);
@@ -447,58 +410,30 @@
/* Only used by ktrace to reset kdebug. ktrace_lock must be held. */
extern void kdebug_reset(void);
-void kdbg_dump_trace_to_file(const char *, bool reenable);
-
-enum kdebug_opts {
- KDOPT_WRAPPING = 0x1,
- KDOPT_ATBOOT = 0x2,
-};
-
-enum kdebug_mode {
- KDEBUG_MODE_TRACE = 0x1, /* General purpose tracing.*/
- KDEBUG_MODE_TRIAGE = 0x2, /* Collect more information to triage failures / gain insight into in-kernel operations of a thread.*/
-};
-
-
-int kdbg_bootstrap(bool early_trace, int mode);
-void kdebug_init(unsigned int n_events, char *filterdesc,
- enum kdebug_opts opts);
+void kdbg_dump_trace_to_file(const char *);
+void kdebug_init(unsigned int n_events, char *filterdesc, bool wrapping);
void kdebug_trace_start(unsigned int n_events, const char *filterdesc,
- enum kdebug_opts opts);
-uint64_t kdebug_wake(void);
+ bool wrapping, bool at_wake);
void kdebug_free_early_buf(void);
-
+void release_storage_unit(int cpu, uint32_t storage_unit);
+bool allocate_storage_unit(int cpu);
struct proc;
void kdbg_trace_data(struct proc *proc, long *arg_pid, long *arg_uniqueid);
-
-__options_decl(kdebug_vfs_lookup_flags_t, uint32_t, {
- KDBG_VFSLKUP_LOOKUP = 0x01,
- KDBG_VFSLKUP_NOPROCFILT = 0x02,
-});
+void kdbg_trace_string(struct proc *proc, long *arg1, long *arg2, long *arg3,
+ long *arg4);
+
#define KDBG_VFS_LOOKUP_FLAG_LOOKUP 0x01
#define KDBG_VFS_LOOKUP_FLAG_NOPROCFILT 0x02
-void kdebug_vfs_lookup(const char *path_words, size_t path_len, void *vnp,
- kdebug_vfs_lookup_flags_t flags);
-
-void ktriage_extract(uint64_t thread_id, void *buf, uint32_t bufsz);
+void kdebug_vfs_lookup(long *dbg_parms, int dbg_namelen, void *dp,
+ uint32_t flags);
#endif /* XNU_KERNEL_PRIVATE */
#ifdef KERNEL_PRIVATE
-typedef struct ktriage_strings {
- int num_strings;
- const char **strings;
-} ktriage_strings_t;
-
-int ktriage_register_subsystem_strings(uint8_t subsystem, ktriage_strings_t *subsystem_strings);
-int ktriage_unregister_subsystem_strings(uint8_t subsystem);
-
-void ktriage_record(uint64_t thread_id, uint64_t debugid, uintptr_t arg);
-
#define NUMPARMS 23
-void kdebug_lookup_gen_events(long *path_words, int path_len, void *vnp,
+void kdebug_lookup_gen_events(long *dbg_parms, int dbg_namelen, void *dp,
bool lookup);
#pragma mark - EnergyTracing