]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/kern/backtrace.h
2 * Copyright (c) 2016 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
34 #include <sys/cdefs.h>
39 * Backtrace the current thread, storing up to max_frames return addresses in
40 * bt. Returns the number of return addresses stored.
42 uint32_t backtrace(uintptr_t *bt
, uint32_t max_frames
)
43 __attribute__((noinline
));
46 * Backtrace the current thread starting at the frame pointer start_fp, storing
47 * up to max_frames return addresses in bt. Returns the number of return
50 uint32_t backtrace_frame(uintptr_t *bt
, uint32_t max_frames
, void *start_frame
)
51 __attribute__((noinline
,not_tail_called
));
54 * Backtrace the kernel stack of the context that was interrupted, storing up
55 * to max_frames return addresses in bt. Returns 0 on success, and non-zero
56 * otherwise. On success, the number of frames written is stored at the value
57 * pointed to by frames_out.
59 * Must be called from interrupt context.
61 uint32_t backtrace_interrupted(uintptr_t *bt
, uint32_t max_frames
);
64 * Backtrace the user stack of the current thread, storing up to max_frames
65 * return addresses in bt. Returns 0 on success, and non-zero otherwise. On
66 * success, the number of frames written is stored at the value pointed to by
67 * frames_out and the value pointed to by user_64_out is set true if the user
68 * space thread was running in 64-bit mode, and false otherwise.
70 * Must not be called from interrupt context or with interrupts disabled.
72 int backtrace_user(uintptr_t *bt
, uint32_t max_frames
, uint32_t *frames_out
,
76 * Backtrace the user stack of the given thread, storing up to max_frames return
77 * addresses in bt. Returns 0 on success, and non-zero otherwise. On success,
78 * the number of frames written is stored at the value pointed to by frames_out
79 * and the value pointed to by user_64_out is set true if the user space thread
80 * was running in 64-bit mode, and false otherwise.
82 * Must not be called from interrupt context or with interrupts disabled.
84 int backtrace_thread_user(void *thread
, uintptr_t *bt
, uint32_t max_frames
,
85 uint32_t *frames_out
, bool *user_64_out
);
89 #endif /* !defined(BACKTRACE_H) */