Loading...
--- Libc/Libc-391.5.21/gen/stack_logging.c
+++ Libc/Libc-262/gen/stack_logging.c
@@ -3,20 +3,19 @@
*
* @APPLE_LICENSE_HEADER_START@
*
- * This file contains Original Code and/or Modifications of Original Code
- * as defined in and that are subject to the Apple Public Source License
- * Version 2.0 (the 'License'). You may not use this file except in
- * compliance with the License. Please obtain a copy of the License at
- * http://www.opensource.apple.com/apsl/ and read it before using this
- * file.
+ * The contents of this file constitute Original Code as defined in and
+ * are subject to the Apple Public Source License Version 1.1 (the
+ * "License"). You may not use this file except in compliance with the
+ * License. Please obtain a copy of the License at
+ * http://www.apple.com/publicsource and read it before using this file.
*
- * The Original Code and all software distributed under the License are
- * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This Original Code and all software distributed under the License are
+ * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
- * Please see the License for the specific language governing rights and
- * limitations under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
+ * License for the specific language governing rights and limitations
+ * under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
@@ -29,46 +28,32 @@
#import <pthread.h>
#import <mach/mach.h>
#include <mach/vm_statistics.h>
-#import <malloc/malloc.h>
-#import <stdlib.h>
extern void spin_lock(int *);
-static inline void *allocate_pages(unsigned) __attribute__((always_inline));
static inline void *allocate_pages(unsigned bytes) {
void *address;
if (vm_allocate(mach_task_self(), (vm_address_t *)&address, bytes,
VM_MAKE_TAG(VM_MEMORY_ANALYSIS_TOOL)| TRUE)) {
- malloc_printf("*** out of memory while stack logging\n");
- abort();
+ address = 0;
}
return (void *)address;
}
-static inline void deallocate_pages(void *, unsigned) __attribute__((always_inline));
static inline void deallocate_pages(void *ptr, unsigned bytes) {
vm_deallocate(mach_task_self(), (vm_address_t)ptr, bytes);
}
-static inline void copy_pages(const void *, void *, unsigned) __attribute__((always_inline));
static inline void copy_pages(const void *source, void *dest, unsigned bytes) {
if (vm_copy(mach_task_self(), (vm_address_t)source, bytes, (vm_address_t)dest)) memmove(dest, source, bytes);
}
/*************** Recording stack ***********/
-// The three functions below are marked as noinline to ensure consistent inlining across
-// all versions of GCC and all compiler flags. The malloc stack logging code expects
-// these functions to not be inlined.
-// For details, see <rdar://problem/4199620>.
-//
-// The performance cost of not inlining these functions is negligible, and they're only
-// called when MallocStackLogging is set anyway, so they won't affect normal usage.
-
-static __attribute__((noinline)) void *first_frame_address(void) {
-#if defined(__i386__) || defined(__x86_64__)
- return __builtin_frame_address(0);
-#elif defined(__ppc__) || defined(__ppc64__)
+static void *first_frame_address(void) {
+#if 0
+ return __builtin_frame_address(1);
+#elif defined(__ppc__)
void *addr;
#warning __builtin_frame_address IS BROKEN IN BEAKER: RADAR #2340421
__asm__ volatile("mr %0, r1" : "=r" (addr));
@@ -79,11 +64,11 @@
#endif
}
-static __attribute__((noinline)) void *next_frame_address(void *addr) {
+static void *next_frame_address(void *addr) {
void *ret;
-#if defined(__MACH__) && (defined(__i386__) || defined(__x86_64__))
- __asm__ volatile("mov (%1),%0" : "=r" (ret) : "r" (addr));
-#elif defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__))
+#if defined(__MACH__) && defined(__i386__)
+ __asm__ volatile("movl (%1),%0" : "=r" (ret) : "r" (addr));
+#elif defined(__MACH__) && defined(__ppc__)
__asm__ volatile("lwz %0,0x0(%1)" : "=r" (ret) : "b" (addr));
#elif defined(__hpux__)
__asm__ volatile("ldw 0x0(%1),%0" : "=r" (ret) : "r" (addr));
@@ -96,9 +81,9 @@
return ret;
}
-#if defined(__i386__) || defined(__x86_64__) || defined (__m68k__)
+#if defined(__i386__) || defined (__m68k__)
#define FP_LINK_OFFSET 1
-#elif defined(__ppc__) || defined(__ppc64__)
+#elif defined(__ppc__)
#define FP_LINK_OFFSET 2
#elif defined(__hppa__)
#define FP_LINK_OFFSET -5
@@ -108,7 +93,7 @@
#error ********** Unimplemented architecture
#endif
-__attribute__((noinline)) void thread_stack_pcs(vm_address_t *buffer, unsigned max, unsigned *nb) {
+void thread_stack_pcs(vm_address_t *buffer, unsigned max, unsigned *nb) {
void *addr;
addr = first_frame_address();
*nb = 0;
@@ -118,7 +103,7 @@
buffer[*nb] = *((vm_address_t *)fp_link);
(*nb)++;
addr2 = next_frame_address(addr);
-#if defined(__ppc__) || defined(__ppc64__)
+#if defined(__ppc__)
if ((unsigned)addr2 <= (unsigned)addr) break; // catch bozo frames
#endif
addr = addr2;