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/amd64/amd64/db_interface.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) 1991,1990 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
   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 the
   24  * rights to redistribute these changes.
   25  */
   26 
   27 #include <sys/cdefs.h>
   28 __FBSDID("$FreeBSD: releng/12.0/sys/amd64/amd64/db_interface.c 331252 2018-03-20 17:43:50Z kib $");
   29 
   30 /*
   31  * Interface to new debugger.
   32  */
   33 
   34 #include <sys/param.h>
   35 #include <sys/systm.h>
   36 #include <sys/kdb.h>
   37 #include <sys/pcpu.h>
   38 
   39 #include <machine/cpufunc.h>
   40 #include <machine/md_var.h>
   41 #include <machine/specialreg.h>
   42 
   43 #include <ddb/ddb.h>
   44 
   45 /*
   46  * Read bytes from kernel address space for debugger.
   47  */
   48 int
   49 db_read_bytes(vm_offset_t addr, size_t size, char *data)
   50 {
   51         jmp_buf jb;
   52         void *prev_jb;
   53         char *src;
   54         int ret;
   55 
   56         prev_jb = kdb_jmpbuf(jb);
   57         ret = setjmp(jb);
   58         if (ret == 0) {
   59                 src = (char *)addr;
   60                 while (size-- > 0)
   61                         *data++ = *src++;
   62         }
   63         (void)kdb_jmpbuf(prev_jb);
   64         return (ret);
   65 }
   66 
   67 /*
   68  * Write bytes to kernel address space for debugger.
   69  * We need to disable write protection temporarily so we can write
   70  * things (such as break points) that might be in write-protected
   71  * memory.
   72  */
   73 int
   74 db_write_bytes(vm_offset_t addr, size_t size, char *data)
   75 {
   76         jmp_buf jb;
   77         void *prev_jb;
   78         char *dst;
   79         bool old_wp;
   80         int ret;
   81 
   82         old_wp = false;
   83         prev_jb = kdb_jmpbuf(jb);
   84         ret = setjmp(jb);
   85         if (ret == 0) {
   86                 old_wp = disable_wp();
   87                 dst = (char *)addr;
   88                 while (size-- > 0)
   89                         *dst++ = *data++;
   90         }
   91         restore_wp(old_wp);
   92         (void)kdb_jmpbuf(prev_jb);
   93         return (ret);
   94 }
   95 
   96 void
   97 db_show_mdpcpu(struct pcpu *pc)
   98 {
   99 
  100         db_printf("curpmap      = %p\n", pc->pc_curpmap);
  101         db_printf("tssp         = %p\n", pc->pc_tssp);
  102         db_printf("commontssp   = %p\n", pc->pc_commontssp);
  103         db_printf("rsp0         = 0x%lx\n", pc->pc_rsp0);
  104         db_printf("gs32p        = %p\n", pc->pc_gs32p);
  105         db_printf("ldt          = %p\n", pc->pc_ldt);
  106         db_printf("tss          = %p\n", pc->pc_tss);
  107 }

Cache object: a7ef2561ec1ac5663cf3937f57ec632c


[ 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.