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_trace.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/5.3/sys/amd64/amd64/db_trace.c 132482 2004-07-21 05:07:09Z marcel $");
   29 
   30 #include <sys/param.h>
   31 #include <sys/systm.h>
   32 #include <sys/kdb.h>
   33 #include <sys/proc.h>
   34 #include <sys/sysent.h>
   35 
   36 #include <machine/cpu.h>
   37 #include <machine/md_var.h>
   38 #include <machine/pcb.h>
   39 #include <machine/reg.h>
   40 
   41 #include <vm/vm.h>
   42 #include <vm/vm_param.h>
   43 #include <vm/pmap.h>
   44 
   45 #include <ddb/ddb.h>
   46 #include <ddb/db_access.h>
   47 #include <ddb/db_sym.h>
   48 #include <ddb/db_variables.h>
   49 
   50 static db_varfcn_t db_dr0;
   51 static db_varfcn_t db_dr1;
   52 static db_varfcn_t db_dr2;
   53 static db_varfcn_t db_dr3;
   54 static db_varfcn_t db_dr4;
   55 static db_varfcn_t db_dr5;
   56 static db_varfcn_t db_dr6;
   57 static db_varfcn_t db_dr7;
   58 static db_varfcn_t db_frame;
   59 static db_varfcn_t db_rsp;
   60 static db_varfcn_t db_ss;
   61 
   62 /*
   63  * Machine register set.
   64  */
   65 #define DB_OFFSET(x)    (db_expr_t *)offsetof(struct trapframe, x)
   66 struct db_variable db_regs[] = {
   67         { "cs",         DB_OFFSET(tf_cs),       db_frame },
   68 #if 0
   69         { "ds",         DB_OFFSET(tf_ds),       db_frame },
   70         { "es",         DB_OFFSET(tf_es),       db_frame },
   71         { "fs",         DB_OFFSET(tf_fs),       db_frame },
   72         { "gs",         DB_OFFSET(tf_gs),       db_frame },
   73 #endif
   74         { "ss",         NULL,                   db_ss },
   75         { "rax",        DB_OFFSET(tf_rax),      db_frame },
   76         { "rcx",        DB_OFFSET(tf_rcx),      db_frame },
   77         { "rdx",        DB_OFFSET(tf_rdx),      db_frame },
   78         { "rbx",        DB_OFFSET(tf_rbx),      db_frame },
   79         { "rsp",        NULL,                   db_rsp },
   80         { "rbp",        DB_OFFSET(tf_rbp),      db_frame },
   81         { "rsi",        DB_OFFSET(tf_rsi),      db_frame },
   82         { "rdi",        DB_OFFSET(tf_rdi),      db_frame },
   83         { "r8",         DB_OFFSET(tf_r8),       db_frame },
   84         { "r9",         DB_OFFSET(tf_r9),       db_frame },
   85         { "r10",        DB_OFFSET(tf_r10),      db_frame },
   86         { "r11",        DB_OFFSET(tf_r11),      db_frame },
   87         { "r12",        DB_OFFSET(tf_r12),      db_frame },
   88         { "r13",        DB_OFFSET(tf_r13),      db_frame },
   89         { "r14",        DB_OFFSET(tf_r14),      db_frame },
   90         { "r15",        DB_OFFSET(tf_r15),      db_frame },
   91         { "rip",        DB_OFFSET(tf_rip),      db_frame },
   92         { "rflags",     DB_OFFSET(tf_rflags),   db_frame },
   93         { "dr0",        NULL,                   db_dr0 },
   94         { "dr1",        NULL,                   db_dr1 },
   95         { "dr2",        NULL,                   db_dr2 },
   96         { "dr3",        NULL,                   db_dr3 },
   97         { "dr4",        NULL,                   db_dr4 },
   98         { "dr5",        NULL,                   db_dr5 },
   99         { "dr6",        NULL,                   db_dr6 },
  100         { "dr7",        NULL,                   db_dr7 },
  101 };
  102 struct db_variable *db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]);
  103 
  104 #define DB_DRX_FUNC(reg)                \
  105 static int                              \
  106 db_ ## reg (vp, valuep, op)             \
  107         struct db_variable *vp;         \
  108         db_expr_t * valuep;             \
  109         int op;                         \
  110 {                                       \
  111         if (op == DB_VAR_GET)           \
  112                 *valuep = r ## reg ();  \
  113         else                            \
  114                 load_ ## reg (*valuep); \
  115         return (1);                     \
  116 }
  117 
  118 DB_DRX_FUNC(dr0)
  119 DB_DRX_FUNC(dr1)
  120 DB_DRX_FUNC(dr2)
  121 DB_DRX_FUNC(dr3)
  122 DB_DRX_FUNC(dr4)
  123 DB_DRX_FUNC(dr5)
  124 DB_DRX_FUNC(dr6)
  125 DB_DRX_FUNC(dr7)
  126 
  127 static __inline long
  128 get_rsp(struct trapframe *tf)
  129 {
  130         return ((ISPL(tf->tf_cs)) ? tf->tf_rsp :
  131             (db_expr_t)tf + offsetof(struct trapframe, tf_rsp));
  132 }
  133 
  134 static int
  135 db_frame(struct db_variable *vp, db_expr_t *valuep, int op)
  136 {
  137         long *reg;
  138 
  139         if (kdb_frame == NULL)
  140                 return (0);
  141 
  142         reg = (long *)((uintptr_t)kdb_frame + (db_expr_t)vp->valuep);
  143         if (op == DB_VAR_GET)
  144                 *valuep = *reg;
  145         else
  146                 *reg = *valuep;
  147         return (1);
  148 }
  149 
  150 static int
  151 db_rsp(struct db_variable *vp, db_expr_t *valuep, int op)
  152 {
  153 
  154         if (kdb_frame == NULL)
  155                 return (0);
  156 
  157         if (op == DB_VAR_GET)
  158                 *valuep = get_rsp(kdb_frame);
  159         else if (ISPL(kdb_frame->tf_cs))
  160                 kdb_frame->tf_rsp = *valuep;
  161         return (1);
  162 }
  163 
  164 static int
  165 db_ss(struct db_variable *vp, db_expr_t *valuep, int op)
  166 {
  167 
  168         if (kdb_frame == NULL)
  169                 return (0);
  170 
  171         if (op == DB_VAR_GET)
  172                 *valuep = (ISPL(kdb_frame->tf_cs)) ? kdb_frame->tf_ss : rss();
  173         else if (ISPL(kdb_frame->tf_cs))
  174                 kdb_frame->tf_ss = *valuep;
  175         return (1);
  176 }
  177 
  178 /*
  179  * Stack trace.
  180  */
  181 #define INKERNEL(va)    (((vm_offset_t)(va)) >= USRSTACK)
  182 
  183 struct amd64_frame {
  184         struct amd64_frame      *f_frame;
  185         long                    f_retaddr;
  186         long                    f_arg0;
  187 };
  188 
  189 #define NORMAL          0
  190 #define TRAP            1
  191 #define INTERRUPT       2
  192 #define SYSCALL         3
  193 
  194 static void db_nextframe(struct amd64_frame **, db_addr_t *, struct thread *);
  195 static int db_numargs(struct amd64_frame *);
  196 static void db_print_stack_entry(const char *, int, char **, long *, db_addr_t);
  197 static void decode_syscall(int, struct thread *);
  198 
  199 static char * watchtype_str(int type);
  200 int  amd64_set_watch(int watchnum, unsigned int watchaddr, int size, int access,
  201                     struct dbreg * d);
  202 int  amd64_clr_watch(int watchnum, struct dbreg * d);
  203 int  db_md_set_watchpoint(db_expr_t addr, db_expr_t size);
  204 int  db_md_clr_watchpoint(db_expr_t addr, db_expr_t size);
  205 void db_md_list_watchpoints(void);
  206 
  207 /*
  208  * Figure out how many arguments were passed into the frame at "fp".
  209  */
  210 static int
  211 db_numargs(fp)
  212         struct amd64_frame *fp;
  213 {
  214 #if 1
  215         return (0);     /* regparm, needs dwarf2 info */
  216 #else
  217         long    *argp;
  218         int     inst;
  219         int     args;
  220 
  221         argp = (long *)db_get_value((long)&fp->f_retaddr, 8, FALSE);
  222         /*
  223          * XXX etext is wrong for LKMs.  We should attempt to interpret
  224          * the instruction at the return address in all cases.  This
  225          * may require better fault handling.
  226          */
  227         if (argp < (long *)btext || argp >= (long *)etext) {
  228                 args = 5;
  229         } else {
  230                 inst = db_get_value((long)argp, 4, FALSE);
  231                 if ((inst & 0xff) == 0x59)      /* popl %ecx */
  232                         args = 1;
  233                 else if ((inst & 0xffff) == 0xc483)     /* addl $Ibs, %esp */
  234                         args = ((inst >> 16) & 0xff) / 4;
  235                 else
  236                         args = 5;
  237         }
  238         return (args);
  239 #endif
  240 }
  241 
  242 static void
  243 db_print_stack_entry(name, narg, argnp, argp, callpc)
  244         const char *name;
  245         int narg;
  246         char **argnp;
  247         long *argp;
  248         db_addr_t callpc;
  249 {
  250         db_printf("%s(", name);
  251 #if 0
  252         while (narg) {
  253                 if (argnp)
  254                         db_printf("%s=", *argnp++);
  255                 db_printf("%lr", (long)db_get_value((long)argp, 8, FALSE));
  256                 argp++;
  257                 if (--narg != 0)
  258                         db_printf(",");
  259         }
  260 #endif
  261         db_printf(") at ");
  262         db_printsym(callpc, DB_STGY_PROC);
  263         db_printf("\n");
  264 }
  265 
  266 static void
  267 decode_syscall(int number, struct thread *td)
  268 {
  269         struct proc *p;
  270         c_db_sym_t sym;
  271         db_expr_t diff;
  272         sy_call_t *f;
  273         const char *symname;
  274 
  275         db_printf(" (%d", number);
  276         p = (td != NULL) ? td->td_proc : NULL;
  277         if (p != NULL && 0 <= number && number < p->p_sysent->sv_size) {
  278                 f = p->p_sysent->sv_table[number].sy_call;
  279                 sym = db_search_symbol((db_addr_t)f, DB_STGY_ANY, &diff);
  280                 if (sym != DB_SYM_NULL && diff == 0) {
  281                         db_symbol_values(sym, &symname, NULL);
  282                         db_printf(", %s, %s", p->p_sysent->sv_name, symname);
  283                 }
  284         }
  285         db_printf(")");
  286 }
  287 
  288 /*
  289  * Figure out the next frame up in the call stack.
  290  */
  291 static void
  292 db_nextframe(struct amd64_frame **fp, db_addr_t *ip, struct thread *td)
  293 {
  294         struct trapframe *tf;
  295         int frame_type;
  296         long rip, rsp, rbp;
  297         db_expr_t offset;
  298         c_db_sym_t sym;
  299         const char *name;
  300 
  301         rip = db_get_value((long) &(*fp)->f_retaddr, 8, FALSE);
  302         rbp = db_get_value((long) &(*fp)->f_frame, 8, FALSE);
  303 
  304         /*
  305          * Figure out frame type.
  306          */
  307         frame_type = NORMAL;
  308         sym = db_search_symbol(rip, DB_STGY_ANY, &offset);
  309         db_symbol_values(sym, &name, NULL);
  310         if (name != NULL) {
  311                 if (strcmp(name, "calltrap") == 0 ||
  312                     strcmp(name, "fork_trampoline") == 0)
  313                         frame_type = TRAP;
  314                 else if (strncmp(name, "Xatpic_intr", 11) == 0 ||
  315                     strncmp(name, "Xatpic_fastintr", 15) == 0 ||
  316                     strncmp(name, "Xapic_isr", 9) == 0)
  317                         frame_type = INTERRUPT;
  318                 else if (strcmp(name, "Xfast_syscall") == 0)
  319                         frame_type = SYSCALL;
  320         }
  321 
  322         /*
  323          * Normal frames need no special processing.
  324          */
  325         if (frame_type == NORMAL) {
  326                 *ip = (db_addr_t) rip;
  327                 *fp = (struct amd64_frame *) rbp;
  328                 return;
  329         }
  330 
  331         db_print_stack_entry(name, 0, 0, 0, rip);
  332 
  333         /*
  334          * Point to base of trapframe which is just above the
  335          * current frame.
  336          */
  337         tf = (struct trapframe *)((long)*fp + 16);
  338 
  339         if (INKERNEL((long) tf)) {
  340                 rsp = get_rsp(tf);
  341                 rip = tf->tf_rip;
  342                 rbp = tf->tf_rbp;
  343                 switch (frame_type) {
  344                 case TRAP:
  345                         db_printf("--- trap %#lr", tf->tf_trapno);
  346                         break;
  347                 case SYSCALL:
  348                         db_printf("--- syscall");
  349                         decode_syscall(tf->tf_rax, td);
  350                         break;
  351                 case INTERRUPT:
  352                         db_printf("--- interrupt");
  353                         break;
  354                 default:
  355                         panic("The moon has moved again.");
  356                 }
  357                 db_printf(", rip = %#lr, rsp = %#lr, rbp = %#lr ---\n", rip,
  358                     rsp, rbp);
  359         }
  360 
  361         *ip = (db_addr_t) rip;
  362         *fp = (struct amd64_frame *) rbp;
  363 }
  364 
  365 static int
  366 db_backtrace(struct thread *td, struct trapframe *tf,
  367     struct amd64_frame *frame, db_addr_t pc, int count)
  368 {
  369         struct amd64_frame *actframe;
  370 #define MAXNARG 16
  371         char *argnames[MAXNARG], **argnp = NULL;
  372         const char *name;
  373         long *argp;
  374         db_expr_t offset;
  375         c_db_sym_t sym;
  376         int narg;
  377         boolean_t first;
  378 
  379         if (count == -1)
  380                 count = 1024;
  381 
  382         first = TRUE;
  383         while (count--) {
  384                 sym = db_search_symbol(pc, DB_STGY_ANY, &offset);
  385                 db_symbol_values(sym, &name, NULL);
  386 
  387                 /*
  388                  * Attempt to determine a (possibly fake) frame that gives
  389                  * the caller's pc.  It may differ from `frame' if the
  390                  * current function never sets up a standard frame or hasn't
  391                  * set one up yet or has just discarded one.  The last two
  392                  * cases can be guessed fairly reliably for code generated
  393                  * by gcc.  The first case is too much trouble to handle in
  394                  * general because the amount of junk on the stack depends
  395                  * on the pc (the special handling of "calltrap", etc. in
  396                  * db_nextframe() works because the `next' pc is special).
  397                  */
  398                 actframe = frame;
  399                 if (first) {
  400                         if (tf != NULL) {
  401                                 int instr;
  402 
  403                                 instr = db_get_value(pc, 4, FALSE);
  404                                 if ((instr & 0xffffffff) == 0xe5894855) {
  405                                         /* pushq %rbp; movq %rsp, %rbp */
  406                                         actframe = (void *)(get_rsp(tf) - 8);
  407                                 } else if ((instr & 0xffffff) == 0xe58948) {
  408                                         /* movq %rsp, %rbp */
  409                                         actframe = (void *)get_rsp(tf);
  410                                         if (tf->tf_rbp == 0) {
  411                                                 /* Fake frame better. */
  412                                                 frame = actframe;
  413                                         }
  414                                 } else if ((instr & 0xff) == 0xc3) {
  415                                         /* ret */
  416                                         actframe = (void *)(get_rsp(tf) - 8);
  417                                 } else if (offset == 0) {
  418                                         /* Probably an assembler symbol. */
  419                                         actframe = (void *)(get_rsp(tf) - 8);
  420                                 }
  421                         } else if (strcmp(name, "fork_trampoline") == 0) {
  422                                 /*
  423                                  * Don't try to walk back on a stack for a
  424                                  * process that hasn't actually been run yet.
  425                                  */
  426                                 db_print_stack_entry(name, 0, 0, 0, pc);
  427                                 break;
  428                         }
  429                         first = FALSE;
  430                 }
  431 
  432                 argp = &actframe->f_arg0;
  433                 narg = MAXNARG;
  434                 if (sym != NULL && db_sym_numargs(sym, &narg, argnames)) {
  435                         argnp = argnames;
  436                 } else {
  437                         narg = db_numargs(frame);
  438                 }
  439 
  440                 db_print_stack_entry(name, narg, argnp, argp, pc);
  441 
  442                 if (actframe != frame) {
  443                         /* `frame' belongs to caller. */
  444                         pc = (db_addr_t)
  445                             db_get_value((long)&actframe->f_retaddr, 8, FALSE);
  446                         continue;
  447                 }
  448 
  449                 db_nextframe(&frame, &pc, td);
  450 
  451                 if (INKERNEL((long)pc) && !INKERNEL((long)frame)) {
  452                         sym = db_search_symbol(pc, DB_STGY_ANY, &offset);
  453                         db_symbol_values(sym, &name, NULL);
  454                         db_print_stack_entry(name, 0, 0, 0, pc);
  455                         break;
  456                 }
  457                 if (!INKERNEL((long) frame)) {
  458                         break;
  459                 }
  460         }
  461 
  462         return (0);
  463 }
  464 
  465 void
  466 db_trace_self(void)
  467 {
  468         struct amd64_frame *frame;
  469         db_addr_t callpc;
  470         register_t rbp;
  471 
  472         __asm __volatile("movq %%rbp,%0" : "=r" (rbp));
  473         frame = (struct amd64_frame *)rbp;
  474         callpc = (db_addr_t)db_get_value((long)&frame->f_retaddr, 8, FALSE);
  475         frame = frame->f_frame;
  476         db_backtrace(curthread, NULL, frame, callpc, -1);
  477 }
  478 
  479 int
  480 db_trace_thread(struct thread *thr, int count)
  481 {
  482         struct pcb *ctx;
  483 
  484         ctx = kdb_thr_ctx(thr);
  485         return (db_backtrace(thr, NULL, (struct amd64_frame *)ctx->pcb_rbp,
  486                     ctx->pcb_rip, count));
  487 }
  488 
  489 int
  490 amd64_set_watch(watchnum, watchaddr, size, access, d)
  491         int watchnum;
  492         unsigned int watchaddr;
  493         int size;
  494         int access;
  495         struct dbreg * d;
  496 {
  497         int i;
  498         unsigned int mask;
  499         
  500         if (watchnum == -1) {
  501                 for (i = 0, mask = 0x3; i < 4; i++, mask <<= 2)
  502                         if ((d->dr[7] & mask) == 0)
  503                                 break;
  504                 if (i < 4)
  505                         watchnum = i;
  506                 else
  507                         return (-1);
  508         }
  509         
  510         switch (access) {
  511         case DBREG_DR7_EXEC:
  512                 size = 1; /* size must be 1 for an execution breakpoint */
  513                 /* fall through */
  514         case DBREG_DR7_WRONLY:
  515         case DBREG_DR7_RDWR:
  516                 break;
  517         default : return (-1);
  518         }
  519         
  520         /*
  521          * we can watch a 1, 2, or 4 byte sized location
  522          */
  523         switch (size) {
  524         case 1  : mask = 0x00; break;
  525         case 2  : mask = 0x01 << 2; break;
  526         case 4  : mask = 0x03 << 2; break;
  527         default : return (-1);
  528         }
  529 
  530         mask |= access;
  531 
  532         /* clear the bits we are about to affect */
  533         d->dr[7] &= ~((0x3 << (watchnum*2)) | (0x0f << (watchnum*4+16)));
  534 
  535         /* set drN register to the address, N=watchnum */
  536         DBREG_DRX(d,watchnum) = watchaddr;
  537 
  538         /* enable the watchpoint */
  539         d->dr[7] |= (0x2 << (watchnum*2)) | (mask << (watchnum*4+16));
  540 
  541         return (watchnum);
  542 }
  543 
  544 
  545 int
  546 amd64_clr_watch(watchnum, d)
  547         int watchnum;
  548         struct dbreg * d;
  549 {
  550 
  551         if (watchnum < 0 || watchnum >= 4)
  552                 return (-1);
  553         
  554         d->dr[7] = d->dr[7] & ~((0x3 << (watchnum*2)) | (0x0f << (watchnum*4+16)));
  555         DBREG_DRX(d,watchnum) = 0;
  556         
  557         return (0);
  558 }
  559 
  560 
  561 int
  562 db_md_set_watchpoint(addr, size)
  563         db_expr_t addr;
  564         db_expr_t size;
  565 {
  566         int avail, wsize;
  567         int i;
  568         struct dbreg d;
  569         
  570         fill_dbregs(NULL, &d);
  571         
  572         avail = 0;
  573         for(i=0; i<4; i++) {
  574                 if ((d.dr[7] & (3 << (i*2))) == 0)
  575                         avail++;
  576         }
  577         
  578         if (avail*4 < size)
  579                 return (-1);
  580         
  581         for (i=0; i<4 && (size != 0); i++) {
  582                 if ((d.dr[7] & (3<<(i*2))) == 0) {
  583                         if (size > 4)
  584                                 wsize = 4;
  585                         else
  586                                 wsize = size;
  587                         if (wsize == 3)
  588                                 wsize++;
  589                         amd64_set_watch(i, addr, wsize, 
  590                                        DBREG_DR7_WRONLY, &d);
  591                         addr += wsize;
  592                         size -= wsize;
  593                 }
  594         }
  595         
  596         set_dbregs(NULL, &d);
  597         
  598         return(0);
  599 }
  600 
  601 
  602 int
  603 db_md_clr_watchpoint(addr, size)
  604         db_expr_t addr;
  605         db_expr_t size;
  606 {
  607         int i;
  608         struct dbreg d;
  609 
  610         fill_dbregs(NULL, &d);
  611 
  612         for(i=0; i<4; i++) {
  613                 if (d.dr[7] & (3 << (i*2))) {
  614                         if ((DBREG_DRX((&d), i) >= addr) && 
  615                             (DBREG_DRX((&d), i) < addr+size))
  616                                 amd64_clr_watch(i, &d);
  617                         
  618                 }
  619         }
  620         
  621         set_dbregs(NULL, &d);
  622         
  623         return(0);
  624 }
  625 
  626 
  627 static 
  628 char *
  629 watchtype_str(type)
  630         int type;
  631 {
  632         switch (type) {
  633                 case DBREG_DR7_EXEC   : return "execute";    break;
  634                 case DBREG_DR7_RDWR   : return "read/write"; break;
  635                 case DBREG_DR7_WRONLY : return "write";      break;
  636                 default               : return "invalid";    break;
  637         }
  638 }
  639 
  640 
  641 void
  642 db_md_list_watchpoints()
  643 {
  644         int i;
  645         struct dbreg d;
  646 
  647         fill_dbregs(NULL, &d);
  648 
  649         db_printf("\nhardware watchpoints:\n");
  650         db_printf("  watch    status        type  len     address\n");
  651         db_printf("  -----  --------  ----------  ---  ----------\n");
  652         for (i=0; i<4; i++) {
  653                 if (d.dr[7] & (0x03 << (i*2))) {
  654                         unsigned type, len;
  655                         type = (d.dr[7] >> (16+(i*4))) & 3;
  656                         len =  (d.dr[7] >> (16+(i*4)+2)) & 3;
  657                         db_printf("  %-5d  %-8s  %10s  %3d  0x%016lx\n",
  658                                   i, "enabled", watchtype_str(type), 
  659                                   len + 1, DBREG_DRX((&d), i));
  660                 }
  661                 else {
  662                         db_printf("  %-5d  disabled\n", i);
  663                 }
  664         }
  665         
  666         db_printf("\ndebug register values:\n");
  667         for (i=0; i<8; i++) {
  668                 db_printf("  dr%d 0x%016lx\n", i, DBREG_DRX((&d), i));
  669         }
  670         db_printf("\n");
  671 }

Cache object: 8ca3b287cc08d9996c4da06214e44441


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