The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/ddb/db_ext_symtab.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /* 
    2  * Mach Operating System
    3  * Copyright (c) 1993,1992,1991,1990,1989 Carnegie Mellon University
    4  * All Rights Reserved.
    5  * 
    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.
   11  * 
   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.
   15  * 
   16  * Carnegie Mellon requests users of this software to return to
   17  * 
   18  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
   19  *  School of Computer Science
   20  *  Carnegie Mellon University
   21  *  Pittsburgh PA 15213-3890
   22  * 
   23  * any improvements or extensions that they make and grant Carnegie Mellon
   24  * the rights to redistribute these changes.
   25  */
   26 
   27 /*
   28  * HISTORY
   29  * $Log:        db_ext_symtab.c,v $
   30  * Revision 2.6  93/11/17  16:22:11  dbg
   31  *      Added ANSI function prototypes.
   32  *      [93/10/11            dbg]
   33  * 
   34  * Revision 2.5  92/08/03  17:31:11  jfriedl
   35  *      removed silly prototypes
   36  *      [92/08/02            jfriedl]
   37  * 
   38  * Revision 2.4  92/05/21  17:07:00  jfriedl
   39  *      tried prototypes.
   40  *      [92/05/20            jfriedl]
   41  * 
   42  * Revision 2.3  92/01/03  20:02:41  dbg
   43  *      Don't deallocate symbol-table twice if error in loading symbol
   44  *      table.
   45  *      [91/11/29            dbg]
   46  * 
   47  * Revision 2.2  91/07/31  17:30:05  dbg
   48  *      Created.
   49  *      [91/07/30  16:43:20  dbg]
   50  * 
   51  */
   52 #include <mach_debug.h>
   53 
   54 #if     MACH_DEBUG
   55 
   56 #include <mach/mach_types.h>    /* vm_address_t */
   57 #include <mach/std_types.h>     /* pointer_t */
   58 #include <mach/vm_param.h>
   59 #include <vm/vm_map.h>
   60 #include <vm/vm_kern.h>
   61 #include <vm/vm_user.h>
   62 #include <kern/host.h>
   63 #include <kern/task.h>
   64 #include <ddb/db_sym.h>
   65 
   66 
   67 
   68 /*
   69  *      Loads a symbol table for an external file into the kernel debugger.
   70  *      The symbol table data is an array of characters.  It is assumed that
   71  *      the caller and the kernel debugger agree on its format.
   72  */
   73 kern_return_t
   74 host_load_symbol_table(
   75         host_t          host,
   76         task_t          task,
   77         char *          name,
   78         pointer_t       symtab,
   79         natural_t       symtab_count)
   80 {
   81         kern_return_t   result;
   82         vm_offset_t     symtab_start;
   83         vm_offset_t     symtab_end;
   84         vm_map_t        map;
   85         vm_map_copy_t   symtab_copy_object;
   86 
   87         if (host == HOST_NULL)
   88             return KERN_INVALID_ARGUMENT;
   89 
   90         /*
   91          * Copy the symbol table array into the kernel.
   92          * We make a copy of the copy object, and clear
   93          * the old one, so that returning error will not
   94          * deallocate the data twice.
   95          */
   96         symtab_copy_object = (vm_map_copy_t) symtab;
   97         result = vm_map_copyout(
   98                         kernel_map,
   99                         &symtab_start,
  100                         vm_map_copy_copy(symtab_copy_object));
  101         if (result != KERN_SUCCESS)
  102             return result;
  103 
  104         symtab_end = symtab_start + symtab_count;
  105 
  106         /*
  107          * Add the symbol table.
  108          * Do not keep a reference for the task map.    XXX
  109          */
  110         if (task == TASK_NULL)
  111             map = VM_MAP_NULL;
  112         else
  113             map = task->map;
  114         if (!X_db_sym_init((char *)symtab_start,
  115                         (char *)symtab_end,
  116                         name,
  117                         (char *)map))
  118         {
  119             /*
  120              * Not enough room for symbol table - failure.
  121              */
  122             (void) vm_deallocate(kernel_map,
  123                         symtab_start,
  124                         symtab_count);
  125             return KERN_FAILURE;
  126         }
  127 
  128         /*
  129          * Wire down the symbol table
  130          */
  131         (void) vm_map_pageable(kernel_map,
  132                 symtab_start,
  133                 round_page(symtab_end),
  134                 VM_PROT_READ|VM_PROT_WRITE);
  135 
  136         /*
  137          * Discard the original copy object
  138          */
  139         vm_map_copy_discard(symtab_copy_object);
  140 
  141         return KERN_SUCCESS;
  142 }
  143 
  144 #endif  /* MACH_DEBUG */

Cache object: 5c31c550b1b5d06ca97228d4d30b8b48


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.