X-Git-Url: https://git.saurik.com/apple/libpthread.git/blobdiff_plain/45deb508575711c47d78d19e326a9a26e43e63e0..c1f56ec94c29e576da2d6d7164bee1bdb2f02471:/include/pthread/stack_np.h diff --git a/include/pthread/stack_np.h b/include/pthread/stack_np.h new file mode 100644 index 0000000..9b5f513 --- /dev/null +++ b/include/pthread/stack_np.h @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2018 Apple Inc. All rights reserved. + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ + +#ifndef __PTHREAD_STACK_NP__ +#define __PTHREAD_STACK_NP__ + +#include +#include +#include +#include +#include +#include + +OS_ASSUME_NONNULL_BEGIN + +/*! @header + * Low-level API to introspect thread stacks. + */ + +__BEGIN_DECLS + +/*! + * @function pthread_stack_frame_decode_np + * + * @abstract + * Decodes the return address and the next stack frame address + * from the given stack frame address. + * + * @discussion + * Validation of the frame address is not performed by this function. + * The caller is responsible for making sure the frame address is valid, + * for example using pthread_get_stackaddr_np() and pthread_get_stacksize_np(). + * + * @param frame_addr + * A valid stack frame address such as __builtin_frame_address(0) or the return + * value of a previous call to pthread_stack_frame_decode_np(). + * + * @param return_addr + * An optional out paramter that will be filled with the return address stored + * at the specified stack frame. + * + * @returns + * This returns the next frame address stored at the specified stack frame. + */ +__OSX_AVAILABLE(10.14) __IOS_AVAILABLE(12.0) +__TVOS_AVAILABLE(12.0) __WATCHOS_AVAILABLE(5.0) +uintptr_t +pthread_stack_frame_decode_np(uintptr_t frame_addr, + uintptr_t *_Nullable return_addr); + +__END_DECLS + +OS_ASSUME_NONNULL_END + +#endif // __PTHREAD_STACK_NP__