|
|
1.1.1.2 ! root 1: /* 1.1 root 2: * Mach Operating System 3: * Copyright (c) 1991,1990,1989 Carnegie Mellon University 4: * All Rights Reserved. 1.1.1.2 ! root 5: * 1.1 root 6: * Permission to use, copy, modify and distribute this software and its 7: * documentation is hereby granted, provided that both the copyright 8: * notice and this permission notice appear in all copies of the 9: * software, derivative works or modified versions, and any portions 10: * thereof, and that both notices appear in supporting documentation. 1.1.1.2 ! root 11: * 1.1 root 12: * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 13: * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR 14: * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 1.1.1.2 ! root 15: * 1.1 root 16: * Carnegie Mellon requests users of this software to return to 1.1.1.2 ! root 17: * 1.1 root 18: * Software Distribution Coordinator or [email protected] 19: * School of Computer Science 20: * Carnegie Mellon University 21: * Pittsburgh PA 15213-3890 1.1.1.2 ! root 22: * 1.1 root 23: * any improvements or extensions that they make and grant Carnegie Mellon 24: * the rights to redistribute these changes. 25: */ 26: 27: #include "mach_kdb.h" 28: #if MACH_KDB 29: 30: #include <mach_debug.h> 31: 32: #if MACH_DEBUG 33: 34: #include <mach/mach_types.h> /* vm_address_t */ 35: #include <mach/std_types.h> /* pointer_t */ 36: #include <mach/vm_param.h> 37: #include <vm/vm_map.h> 38: #include <vm/vm_kern.h> 39: #include <kern/host.h> 40: #include <kern/task.h> 41: #include <ddb/db_sym.h> 42: 43: 44: 45: /* 46: * Loads a symbol table for an external file into the kernel debugger. 47: * The symbol table data is an array of characters. It is assumed that 48: * the caller and the kernel debugger agree on its format. 49: */ 50: kern_return_t 51: host_load_symbol_table(host, task, name, symtab, symtab_count) 52: host_t host; 53: task_t task; 54: char * name; 55: pointer_t symtab; 56: unsigned int symtab_count; 57: { 58: kern_return_t result; 59: vm_offset_t symtab_start; 60: vm_offset_t symtab_end; 61: vm_map_t map; 62: vm_map_copy_t symtab_copy_object; 63: 64: if (host == HOST_NULL) 65: return (KERN_INVALID_ARGUMENT); 66: 67: /* 68: * Copy the symbol table array into the kernel. 69: * We make a copy of the copy object, and clear 70: * the old one, so that returning error will not 71: * deallocate the data twice. 72: */ 73: symtab_copy_object = (vm_map_copy_t) symtab; 74: result = vm_map_copyout( 75: kernel_map, 76: &symtab_start, 77: vm_map_copy_copy(symtab_copy_object)); 78: if (result != KERN_SUCCESS) 79: return (result); 80: 81: symtab_end = symtab_start + symtab_count; 82: 83: /* 84: * Add the symbol table. 85: * Do not keep a reference for the task map. XXX 86: */ 87: if (task == TASK_NULL) 88: map = VM_MAP_NULL; 89: else 90: map = task->map; 91: if (!X_db_sym_init((char *)symtab_start, 92: (char *)symtab_end, 93: name, 94: (char *)map)) 95: { 96: /* 97: * Not enough room for symbol table - failure. 98: */ 99: (void) vm_deallocate(kernel_map, 100: symtab_start, 101: symtab_count); 102: return (KERN_FAILURE); 103: } 104: 105: /* 106: * Wire down the symbol table 107: */ 108: (void) vm_map_pageable(kernel_map, 109: symtab_start, 110: round_page(symtab_end), 111: VM_PROT_READ|VM_PROT_WRITE); 112: 113: /* 114: * Discard the original copy object 115: */ 116: vm_map_copy_discard(symtab_copy_object); 117: 118: return (KERN_SUCCESS); 119: } 120: 121: #endif /* MACH_DEBUG */ 122: 1.1.1.2 ! root 123: #endif /* MACH_KDB */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.