* Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_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
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
- *
+ *
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ 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
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* 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.
- *
+ *
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#include <mach/mach_types.h>
#include <mach/thread_status.h>
#include <i386/thread.h>
-int kdp_dump_trap(int type, x86_saved_state64_t *regs);
+int kdp_dump_trap(int type, x86_saved_state64_t *regs);
-static const x86_state_hdr_t thread_flavor_array [] = {
+static const x86_state_hdr_t thread_flavor_array[] = {
{x86_THREAD_STATE64, x86_THREAD_STATE64_COUNT}
};
unsigned int i;
uint64_t tstate_size = 0;
- for (i = 0; i < sizeof(thread_flavor_array)/sizeof(thread_flavor_array[0]); i++)
+ for (i = 0; i < sizeof(thread_flavor_array) / sizeof(thread_flavor_array[0]); i++) {
tstate_size += sizeof(x86_state_hdr_t) +
(thread_flavor_array[i].count * sizeof(int));
+ }
*tstate_count = 1;
*ptstate_size = sizeof(struct thread_command) + tstate_size;
void
kern_collectth_state(thread_t thread, void *buffer, uint64_t size, void ** iter)
{
- size_t hoffset;
- uint64_t tstate_size, tstate_count;
- unsigned int i;
- struct thread_command *tc;
-
+ size_t hoffset;
+ uint64_t tstate_size, tstate_count;
+ unsigned int i;
+ struct thread_command *tc;
+
*iter = NULL;
/*
* Fill in thread command structure.
*/
hoffset = 0;
-
- if (hoffset + sizeof(struct thread_command) > size)
+
+ if (hoffset + sizeof(struct thread_command) > size) {
return;
+ }
kern_collectth_state_size(&tstate_count, &tstate_size);
tc = (struct thread_command *) ((uintptr_t)buffer + hoffset);
* the appropriate thread state struct for each
* thread state flavor.
*/
- for (i = 0; i < sizeof(thread_flavor_array)/sizeof(thread_flavor_array[0]); i++) {
-
- if (hoffset + sizeof(x86_state_hdr_t) > size)
+ for (i = 0; i < sizeof(thread_flavor_array) / sizeof(thread_flavor_array[0]); i++) {
+ if (hoffset + sizeof(x86_state_hdr_t) > size) {
return;
+ }
*(x86_state_hdr_t *)((uintptr_t)buffer + hoffset) =
thread_flavor_array[i];
hoffset += sizeof(x86_state_hdr_t);
- if (hoffset + thread_flavor_array[i].count*sizeof(int) > size)
+ if (hoffset + thread_flavor_array[i].count * sizeof(int) > size) {
return;
+ }
/* Locate and obtain the non-volatile register context
* for this kernel thread. This should ideally be
tstate->cs = cpstate->isf.cs;
tstate->fs = cpstate->fs;
tstate->gs = cpstate->gs;
- } else if ((kstack = thread->kernel_stack) != 0){
+ } else if ((kstack = thread->kernel_stack) != 0) {
struct x86_kernel_state *iks = STACK_IKS(kstack);
tstate->rbx = iks->k_rbx;
tstate->rsp = iks->k_rsp;
} else {
void *tstate = (void *)((uintptr_t)buffer + hoffset);
- bzero(tstate, thread_flavor_array[i].count*sizeof(int));
+ bzero(tstate, thread_flavor_array[i].count * sizeof(int));
}
- hoffset += thread_flavor_array[i].count*sizeof(int);
+ hoffset += thread_flavor_array[i].count * sizeof(int);
}
}
int
kdp_dump_trap(
int type,
- __unused x86_saved_state64_t *saved_state)
+ __unused x86_saved_state64_t *saved_state)
{
- printf ("An unexpected trap (type %d) occurred during the system dump, terminating.\n", type);
- kdp_send_crashdump_pkt (KDP_EOF, NULL, 0, ((void *) 0));
+ printf("An unexpected trap (type %d) occurred during the system dump, terminating.\n", type);
+ kdp_send_crashdump_pkt(KDP_EOF, NULL, 0, ((void *) 0));
abort_panic_transfer();
kdp_flag &= ~KDP_PANIC_DUMP_ENABLED;
kdp_flag &= ~PANIC_CORE_ON_NMI;
kdp_reset();
kdp_raise_exception(EXC_BAD_ACCESS, 0, 0, kdp.saved_state);
- return( 0 );
+ return 0;
+}
+
+/*
+ * kdp_core_start_addr
+ *
+ * return the address where the kernel core file starts
+ *
+ */
+vm_map_offset_t
+kdp_core_start_addr()
+{
+ return VM_MIN_KERNEL_AND_KEXT_ADDRESS;
}