- Update to 2.6.25-rc3.
[linux-flexiantxendom0-3.2.10.git] / arch / x86 / kdb / kdba_bp_32.c
1 /*
2  * Kernel Debugger Architecture Dependent Breakpoint Handling
3  *
4  * This file is subject to the terms and conditions of the GNU General Public
5  * License.  See the file "COPYING" in the main directory of this archive
6  * for more details.
7  *
8  * Copyright (c) 1999-2004 Silicon Graphics, Inc.  All Rights Reserved.
9  */
10
11 #include <linux/string.h>
12 #include <linux/kernel.h>
13 #include <linux/sched.h>
14 #include <linux/smp.h>
15 #include <linux/ptrace.h>
16 #include <linux/kdb.h>
17 #include <linux/kdbprivate.h>
18
19
20 static char *kdba_rwtypes[] = { "Instruction(Register)", "Data Write",
21                         "I/O", "Data Access"};
22
23 /*
24  * Table describing processor architecture hardware
25  * breakpoint registers.
26  */
27
28 static kdbhard_bp_t kdb_hardbreaks[KDB_MAXHARDBPT];
29
30 /*
31  * kdba_db_trap
32  *
33  *      Perform breakpoint processing upon entry to the
34  *      processor debugger fault.   Determine and print
35  *      the active breakpoint.
36  *
37  * Parameters:
38  *      regs    Exception frame containing machine register state
39  *      error   Error number passed to kdb.
40  * Outputs:
41  *      None.
42  * Returns:
43  *      KDB_DB_BPT      Standard instruction or data breakpoint encountered
44  *      KDB_DB_SS       Single Step fault ('ss' command or end of 'ssb' command)
45  *      KDB_DB_SSB      Single Step fault, caller should continue ('ssb' command)
46  *      KDB_DB_SSBPT    Single step over breakpoint
47  *      KDB_DB_NOBPT    No existing kdb breakpoint matches this debug exception
48  * Locking:
49  *      None.
50  * Remarks:
51  *      Yup, there be goto's here.
52  *
53  *      If multiple processors receive debug exceptions simultaneously,
54  *      one may be waiting at the kdb fence in kdb() while the user
55  *      issues a 'bc' command to clear the breakpoint the processor
56  *      which is waiting has already encountered.  If this is the case,
57  *      the debug registers will no longer match any entry in the
58  *      breakpoint table, and we'll return the value KDB_DB_NOBPT.
59  *      This can cause a panic in die_if_kernel().  It is safer to
60  *      disable the breakpoint (bd), go until all processors are past
61  *      the breakpoint then clear the breakpoint (bc).  This code
62  *      recognises a breakpoint even when disabled but not when it has
63  *      been cleared.
64  *
65  *      WARNING: This routine clears the debug state.  It should be called
66  *               once per debug and the result cached.
67  */
68
69 kdb_dbtrap_t
70 kdba_db_trap(struct pt_regs *regs, int error_unused)
71 {
72         kdb_machreg_t dr6;
73         kdb_machreg_t dr7;
74         int rw, reg;
75         int i;
76         kdb_dbtrap_t rv = KDB_DB_BPT;
77         kdb_bp_t *bp;
78
79         if (KDB_NULL_REGS(regs))
80                 return KDB_DB_NOBPT;
81
82         dr6 = kdba_getdr6();
83         dr7 = kdba_getdr7();
84
85         if (KDB_DEBUG(BP))
86                 kdb_printf("kdb: dr6 0x%lx dr7 0x%lx\n", dr6, dr7);
87         if (dr6 & DR6_BS) {
88                 if (KDB_STATE(SSBPT)) {
89                         if (KDB_DEBUG(BP))
90                                 kdb_printf("ssbpt\n");
91                         KDB_STATE_CLEAR(SSBPT);
92                         for(i=0,bp=kdb_breakpoints;
93                             i < KDB_MAXBPT;
94                             i++, bp++) {
95                                 if (KDB_DEBUG(BP))
96                                         kdb_printf("bp 0x%p enabled %d delayed %d global %d cpu %d\n",
97                                                    bp, bp->bp_enabled, bp->bp_delayed, bp->bp_global, bp->bp_cpu);
98                                 if (!bp->bp_enabled)
99                                         continue;
100                                 if (!bp->bp_global && bp->bp_cpu != smp_processor_id())
101                                         continue;
102                                 if (KDB_DEBUG(BP))
103                                         kdb_printf("bp for this cpu\n");
104                                 if (bp->bp_delayed) {
105                                         bp->bp_delayed = 0;
106                                         if (KDB_DEBUG(BP))
107                                                 kdb_printf("kdba_installbp\n");
108                                         kdba_installbp(regs, bp);
109                                         if (!KDB_STATE(DOING_SS)) {
110                                                 regs->flags &= ~EF_TF;
111                                                 return(KDB_DB_SSBPT);
112                                         }
113                                         break;
114                                 }
115                         }
116                         if (i == KDB_MAXBPT) {
117                                 kdb_printf("kdb: Unable to find delayed breakpoint\n");
118                         }
119                         if (!KDB_STATE(DOING_SS)) {
120                                 regs->flags &= ~EF_TF;
121                                 return(KDB_DB_NOBPT);
122                         }
123                         /* FALLTHROUGH */
124                 }
125
126                 /*
127                  * KDB_STATE_DOING_SS is set when the kernel debugger is using
128                  * the processor trap flag to single-step a processor.  If a
129                  * single step trap occurs and this flag is clear, the SS trap
130                  * will be ignored by KDB and the kernel will be allowed to deal
131                  * with it as necessary (e.g. for ptrace).
132                  */
133                 if (!KDB_STATE(DOING_SS))
134                         goto unknown;
135
136                 /* single step */
137                 rv = KDB_DB_SS;         /* Indicate single step */
138                 if (KDB_STATE(DOING_SSB)) {
139                         unsigned char instruction[2];
140
141                         kdb_id1(regs->ip);
142                         if (kdb_getarea(instruction, regs->ip) ||
143                             (instruction[0]&0xf0) == 0xe0 ||    /* short disp jumps */
144                             (instruction[0]&0xf0) == 0x70 ||    /* Misc. jumps */
145                             instruction[0]        == 0xc2 ||    /* ret */
146                             instruction[0]        == 0x9a ||    /* call */
147                             (instruction[0]&0xf8) == 0xc8 ||    /* enter, leave, iret, int, */
148                             ((instruction[0]      == 0x0f) &&
149                              ((instruction[1]&0xf0)== 0x80))
150                            ) {
151                                 /*
152                                  * End the ssb command here.
153                                  */
154                                 KDB_STATE_CLEAR(DOING_SSB);
155                                 KDB_STATE_CLEAR(DOING_SS);
156                         } else {
157                                 rv = KDB_DB_SSB; /* Indicate ssb - dismiss immediately */
158                         }
159                 } else {
160                         /*
161                          * Print current insn
162                          */
163                         kdb_printf("SS trap at ");
164                         kdb_symbol_print(regs->ip, NULL, KDB_SP_DEFAULT|KDB_SP_NEWLINE);
165                         kdb_id1(regs->ip);
166                         KDB_STATE_CLEAR(DOING_SS);
167                 }
168
169                 if (rv != KDB_DB_SSB)
170                         regs->flags &= ~EF_TF;
171         }
172
173         if (dr6 & DR6_B0) {
174                 rw = DR7_RW0(dr7);
175                 reg = 0;
176                 goto handle;
177         }
178
179         if (dr6 & DR6_B1) {
180                 rw = DR7_RW1(dr7);
181                 reg = 1;
182                 goto handle;
183         }
184
185         if (dr6 & DR6_B2) {
186                 rw = DR7_RW2(dr7);
187                 reg = 2;
188                 goto handle;
189         }
190
191         if (dr6 & DR6_B3) {
192                 rw = DR7_RW3(dr7);
193                 reg = 3;
194                 goto handle;
195         }
196
197         if (rv > 0)
198                 goto handled;
199
200         goto unknown;   /* dismiss */
201
202 handle:
203         /*
204          * Set Resume Flag
205          */
206         regs->flags |= EF_RF;
207
208         /*
209          * Determine which breakpoint was encountered.
210          */
211         for(i=0, bp=kdb_breakpoints; i<KDB_MAXBPT; i++, bp++) {
212                 if (!(bp->bp_free)
213                  && (bp->bp_global || bp->bp_cpu == smp_processor_id())
214                  && (bp->bp_hard)
215                  && (bp->bp_hard->bph_reg == reg)) {
216                         /*
217                          * Hit this breakpoint.
218                          */
219                         kdb_printf("%s breakpoint #%d at " kdb_bfd_vma_fmt "\n",
220                                   kdba_rwtypes[rw],
221                                   i, bp->bp_addr);
222
223                         /*
224                          * For an instruction breakpoint, disassemble
225                          * the current instruction.
226                          */
227                         if (rw == 0) {
228                                 kdb_id1(regs->ip);
229                         }
230
231                         goto handled;
232                 }
233         }
234
235 unknown:
236         regs->flags |= EF_RF;   /* Supress further faults */
237         rv = KDB_DB_NOBPT;      /* Cause kdb() to return */
238
239 handled:
240
241         /*
242          * Clear the pending exceptions.
243          */
244         kdba_putdr6(0);
245
246         return rv;
247 }
248
249 /*
250  * kdba_bp_trap
251  *
252  *      Perform breakpoint processing upon entry to the
253  *      processor breakpoint instruction fault.   Determine and print
254  *      the active breakpoint.
255  *
256  * Parameters:
257  *      regs    Exception frame containing machine register state
258  *      error   Error number passed to kdb.
259  * Outputs:
260  *      None.
261  * Returns:
262  *      0       Standard instruction or data breakpoint encountered
263  *      1       Single Step fault ('ss' command)
264  *      2       Single Step fault, caller should continue ('ssb' command)
265  *      3       No existing kdb breakpoint matches this debug exception
266  * Locking:
267  *      None.
268  * Remarks:
269  *
270  *      If multiple processors receive debug exceptions simultaneously,
271  *      one may be waiting at the kdb fence in kdb() while the user
272  *      issues a 'bc' command to clear the breakpoint the processor which
273  *      is waiting has already encountered.   If this is the case, the
274  *      debug registers will no longer match any entry in the breakpoint
275  *      table, and we'll return the value '3'.  This can cause a panic
276  *      in die_if_kernel().  It is safer to disable the breakpoint (bd),
277  *      'go' until all processors are past the breakpoint then clear the
278  *      breakpoint (bc).  This code recognises a breakpoint even when
279  *      disabled but not when it has been cleared.
280  *
281  *      WARNING: This routine resets the eip.  It should be called
282  *               once per breakpoint and the result cached.
283  */
284
285 kdb_dbtrap_t
286 kdba_bp_trap(struct pt_regs *regs, int error_unused)
287 {
288         int i;
289         kdb_dbtrap_t rv;
290         kdb_bp_t *bp;
291
292         if (KDB_NULL_REGS(regs))
293                 return KDB_DB_NOBPT;
294
295         /*
296          * Determine which breakpoint was encountered.
297          */
298         if (KDB_DEBUG(BP))
299                 kdb_printf("kdba_bp_trap: eip=0x%lx (not adjusted) "
300                            "eflags=0x%lx regs=0x%p esp=0x%lx\n",
301                            regs->ip, regs->flags, regs, regs->sp);
302
303         rv = KDB_DB_NOBPT;      /* Cause kdb() to return */
304
305         for(i=0, bp=kdb_breakpoints; i<KDB_MAXBPT; i++, bp++) {
306                 if (bp->bp_free)
307                         continue;
308                 if (!bp->bp_global && bp->bp_cpu != smp_processor_id())
309                         continue;
310                  if ((void *)bp->bp_addr == (void *)(regs->ip - bp->bp_adjust)) {
311                         /* Hit this breakpoint.  */
312                         regs->ip -= bp->bp_adjust;
313                         kdb_printf("Instruction(i) breakpoint #%d at 0x%lx (adjusted)\n",
314                                   i, regs->ip);
315                         kdb_id1(regs->ip);
316                         rv = KDB_DB_BPT;
317                         bp->bp_delay = 1;
318                         /* SSBPT is set when the kernel debugger must single
319                          * step a task in order to re-establish an instruction
320                          * breakpoint which uses the instruction replacement
321                          * mechanism.  It is cleared by any action that removes
322                          * the need to single-step the breakpoint.
323                          */
324                         KDB_STATE_SET(SSBPT);
325                         break;
326                 }
327         }
328
329         return rv;
330 }
331
332 /*
333  * kdba_handle_bp
334  *
335  *      Handle an instruction-breakpoint trap.  Called when re-installing
336  *      an enabled breakpoint which has has the bp_delay bit set.
337  *
338  * Parameters:
339  * Returns:
340  * Locking:
341  * Remarks:
342  *
343  * Ok, we really need to:
344  *      1) Restore the original instruction byte
345  *      2) Single Step
346  *      3) Restore breakpoint instruction
347  *      4) Continue.
348  *
349  *
350  */
351
352 static void
353 kdba_handle_bp(struct pt_regs *regs, kdb_bp_t *bp)
354 {
355         if (KDB_NULL_REGS(regs))
356                 return;
357
358         if (KDB_DEBUG(BP))
359                 kdb_printf("regs->ip = 0x%lx\n", regs->ip);
360
361         /*
362          * Setup single step
363          */
364         kdba_setsinglestep(regs);
365
366         /*
367          * Reset delay attribute
368          */
369         bp->bp_delay = 0;
370         bp->bp_delayed = 1;
371 }
372
373
374 /*
375  * kdba_bptype
376  *
377  *      Return a string describing type of breakpoint.
378  *
379  * Parameters:
380  *      bph     Pointer to hardware breakpoint description
381  * Outputs:
382  *      None.
383  * Returns:
384  *      Character string.
385  * Locking:
386  *      None.
387  * Remarks:
388  */
389
390 char *
391 kdba_bptype(kdbhard_bp_t *bph)
392 {
393         char *mode;
394
395         mode = kdba_rwtypes[bph->bph_mode];
396
397         return mode;
398 }
399
400 /*
401  * kdba_printbpreg
402  *
403  *      Print register name assigned to breakpoint
404  *
405  * Parameters:
406  *      bph     Pointer hardware breakpoint structure
407  * Outputs:
408  *      None.
409  * Returns:
410  *      None.
411  * Locking:
412  *      None.
413  * Remarks:
414  */
415
416 static void
417 kdba_printbpreg(kdbhard_bp_t *bph)
418 {
419         kdb_printf(" in dr%ld", bph->bph_reg);
420 }
421
422 /*
423  * kdba_printbp
424  *
425  *      Print string describing hardware breakpoint.
426  *
427  * Parameters:
428  *      bph     Pointer to hardware breakpoint description
429  * Outputs:
430  *      None.
431  * Returns:
432  *      None.
433  * Locking:
434  *      None.
435  * Remarks:
436  */
437
438 void
439 kdba_printbp(kdb_bp_t *bp)
440 {
441         kdb_printf("\n    is enabled");
442         if (bp->bp_hardtype) {
443                 kdba_printbpreg(bp->bp_hard);
444                 if (bp->bp_hard->bph_mode != 0) {
445                         kdb_printf(" for %d bytes",
446                                    bp->bp_hard->bph_length+1);
447                 }
448         }
449 }
450
451 /*
452  * kdba_parsebp
453  *
454  *      Parse architecture dependent portion of the
455  *      breakpoint command.
456  *
457  * Parameters:
458  *      None.
459  * Outputs:
460  *      None.
461  * Returns:
462  *      Zero for success, a kdb diagnostic for failure
463  * Locking:
464  *      None.
465  * Remarks:
466  *      for Ia32 architure, data access, data write and
467  *      I/O breakpoints are supported in addition to instruction
468  *      breakpoints.
469  *
470  *      {datar|dataw|io|inst} [length]
471  */
472
473 int
474 kdba_parsebp(int argc, const char **argv, int *nextargp, kdb_bp_t *bp)
475 {
476         int nextarg = *nextargp;
477         int diag;
478         kdbhard_bp_t *bph = &bp->bp_template;
479
480         bph->bph_mode = 0;              /* Default to instruction breakpoint */
481         bph->bph_length = 0;            /* Length must be zero for insn bp */
482         if ((argc + 1) != nextarg) {
483                 if (strnicmp(argv[nextarg], "datar", sizeof("datar")) == 0) {
484                         bph->bph_mode = 3;
485                 } else if (strnicmp(argv[nextarg], "dataw", sizeof("dataw")) == 0) {
486                         bph->bph_mode = 1;
487                 } else if (strnicmp(argv[nextarg], "io", sizeof("io")) == 0) {
488                         bph->bph_mode = 2;
489                 } else if (strnicmp(argv[nextarg], "inst", sizeof("inst")) == 0) {
490                         bph->bph_mode = 0;
491                 } else {
492                         return KDB_ARGCOUNT;
493                 }
494
495                 bph->bph_length = 3;    /* Default to 4 byte */
496
497                 nextarg++;
498
499                 if ((argc + 1) != nextarg) {
500                         unsigned long len;
501
502                         diag = kdbgetularg((char *)argv[nextarg],
503                                            &len);
504                         if (diag)
505                                 return diag;
506
507
508                         if ((len > 4) || (len == 3))
509                                 return KDB_BADLENGTH;
510
511                         bph->bph_length = len;
512                         bph->bph_length--; /* Normalize for debug register */
513                         nextarg++;
514                 }
515
516                 if ((argc + 1) != nextarg)
517                         return KDB_ARGCOUNT;
518
519                 /*
520                  * Indicate to architecture independent level that
521                  * a hardware register assignment is required to enable
522                  * this breakpoint.
523                  */
524
525                 bph->bph_free = 0;
526         } else {
527                 if (KDB_DEBUG(BP))
528                         kdb_printf("kdba_bp: no args, forcehw is %d\n", bp->bp_forcehw);
529                 if (bp->bp_forcehw) {
530                         /*
531                          * We are forced to use a hardware register for this
532                          * breakpoint because either the bph or bpha
533                          * commands were used to establish this breakpoint.
534                          */
535                         bph->bph_free = 0;
536                 } else {
537                         /*
538                          * Indicate to architecture dependent level that
539                          * the instruction replacement breakpoint technique
540                          * should be used for this breakpoint.
541                          */
542                         bph->bph_free = 1;
543                         bp->bp_adjust = 1;      /* software, int 3 is one byte */
544                 }
545         }
546
547         if (bph->bph_mode != 2 && kdba_verify_rw(bp->bp_addr, bph->bph_length+1)) {
548                 kdb_printf("Invalid address for breakpoint, ignoring bp command\n");
549                 return KDB_BADADDR;
550         }
551
552         *nextargp = nextarg;
553         return 0;
554 }
555
556 /*
557  * kdba_allocbp
558  *
559  *      Associate a hardware register with a breakpoint.
560  *
561  * Parameters:
562  *      None.
563  * Outputs:
564  *      None.
565  * Returns:
566  *      A pointer to the allocated register kdbhard_bp_t structure for
567  *      success, Null and a non-zero diagnostic for failure.
568  * Locking:
569  *      None.
570  * Remarks:
571  */
572
573 kdbhard_bp_t *
574 kdba_allocbp(kdbhard_bp_t *bph, int *diagp)
575 {
576         int i;
577         kdbhard_bp_t *newbph;
578
579         for(i=0,newbph=kdb_hardbreaks; i < KDB_MAXHARDBPT; i++, newbph++) {
580                 if (newbph->bph_free) {
581                         break;
582                 }
583         }
584
585         if (i == KDB_MAXHARDBPT) {
586                 *diagp = KDB_TOOMANYDBREGS;
587                 return NULL;
588         }
589
590         *diagp = 0;
591
592         /*
593          * Copy data from template.  Can't just copy the entire template
594          * here because the register number in kdb_hardbreaks must be
595          * preserved.
596          */
597         newbph->bph_data = bph->bph_data;
598         newbph->bph_write = bph->bph_write;
599         newbph->bph_mode = bph->bph_mode;
600         newbph->bph_length = bph->bph_length;
601
602         /*
603          * Mark entry allocated.
604          */
605         newbph->bph_free = 0;
606
607         return newbph;
608 }
609
610 /*
611  * kdba_freebp
612  *
613  *      Deallocate a hardware breakpoint
614  *
615  * Parameters:
616  *      None.
617  * Outputs:
618  *      None.
619  * Returns:
620  *      Zero for success, a kdb diagnostic for failure
621  * Locking:
622  *      None.
623  * Remarks:
624  */
625
626 void
627 kdba_freebp(kdbhard_bp_t *bph)
628 {
629         bph->bph_free = 1;
630 }
631
632 /*
633  * kdba_initbp
634  *
635  *      Initialize the breakpoint table for the hardware breakpoint
636  *      register.
637  *
638  * Parameters:
639  *      None.
640  * Outputs:
641  *      None.
642  * Returns:
643  *      Zero for success, a kdb diagnostic for failure
644  * Locking:
645  *      None.
646  * Remarks:
647  *
648  *      There is one entry per register.  On the ia32 architecture
649  *      all the registers are interchangeable, so no special allocation
650  *      criteria are required.
651  */
652
653 void
654 kdba_initbp(void)
655 {
656         int i;
657         kdbhard_bp_t *bph;
658
659         /*
660          * Clear the hardware breakpoint table
661          */
662
663         memset(kdb_hardbreaks, '\0', sizeof(kdb_hardbreaks));
664
665         for(i=0,bph=kdb_hardbreaks; i<KDB_MAXHARDBPT; i++, bph++) {
666                 bph->bph_reg = i;
667                 bph->bph_free = 1;
668         }
669 }
670
671 /*
672  * kdba_installbp
673  *
674  *      Install a breakpoint
675  *
676  * Parameters:
677  *      regs    Exception frame
678  *      bp      Breakpoint structure for the breakpoint to be installed
679  * Outputs:
680  *      None.
681  * Returns:
682  *      0 if breakpoint installed.
683  * Locking:
684  *      None.
685  * Remarks:
686  *      For hardware breakpoints, a debug register is allocated
687  *      and assigned to the breakpoint.  If no debug register is
688  *      available, a warning message is printed and the breakpoint
689  *      is disabled.
690  *
691  *      For instruction replacement breakpoints, we must single-step
692  *      over the replaced instruction at this point so we can re-install
693  *      the breakpoint instruction after the single-step.  SSBPT is set
694  *      when the breakpoint is initially hit and is cleared by any action
695  *      that removes the need for single-step over the breakpoint.
696  */
697
698 int
699 kdba_installbp(struct pt_regs *regs, kdb_bp_t *bp)
700 {
701         /*
702          * Install the breakpoint, if it is not already installed.
703          */
704
705         if (KDB_DEBUG(BP)) {
706                 kdb_printf("kdba_installbp bp_installed %d\n", bp->bp_installed);
707         }
708         if (!KDB_STATE(SSBPT))
709                 bp->bp_delay = 0;
710         if (!bp->bp_installed) {
711                 if (bp->bp_hardtype) {
712                         kdba_installdbreg(bp);
713                         bp->bp_installed = 1;
714                         if (KDB_DEBUG(BP)) {
715                                 kdb_printf("kdba_installbp hardware reg %ld at " kdb_bfd_vma_fmt "\n",
716                                            bp->bp_hard->bph_reg, bp->bp_addr);
717                         }
718                 } else if (bp->bp_delay) {
719                         if (KDB_DEBUG(BP))
720                                 kdb_printf("kdba_installbp delayed bp\n");
721                         kdba_handle_bp(regs, bp);
722                 } else {
723                         if (kdb_getarea_size(&(bp->bp_inst), bp->bp_addr, 1) ||
724                             kdb_putword(bp->bp_addr, IA32_BREAKPOINT_INSTRUCTION, 1)) {
725                                 kdb_printf("kdba_installbp failed to set software breakpoint at 0x%lx\n", bp->bp_addr);
726                                 return(1);
727                         }
728                         bp->bp_installed = 1;
729                         if (KDB_DEBUG(BP))
730                                 kdb_printf("kdba_installbp instruction 0x%x at " kdb_bfd_vma_fmt "\n",
731                                            IA32_BREAKPOINT_INSTRUCTION, bp->bp_addr);
732                 }
733         }
734         return(0);
735 }
736
737 /*
738  * kdba_removebp
739  *
740  *      Make a breakpoint ineffective.
741  *
742  * Parameters:
743  *      None.
744  * Outputs:
745  *      None.
746  * Returns:
747  *      None.
748  * Locking:
749  *      None.
750  * Remarks:
751  */
752
753 int
754 kdba_removebp(kdb_bp_t *bp)
755 {
756         /*
757          * For hardware breakpoints, remove it from the active register,
758          * for software breakpoints, restore the instruction stream.
759          */
760         if (KDB_DEBUG(BP)) {
761                 kdb_printf("kdba_removebp bp_installed %d\n", bp->bp_installed);
762         }
763         if (bp->bp_installed) {
764                 if (bp->bp_hardtype) {
765                         if (KDB_DEBUG(BP)) {
766                                 kdb_printf("kdb: removing hardware reg %ld at " kdb_bfd_vma_fmt "\n",
767                                            bp->bp_hard->bph_reg, bp->bp_addr);
768                         }
769                         kdba_removedbreg(bp);
770                 } else {
771                         if (KDB_DEBUG(BP))
772                                 kdb_printf("kdb: restoring instruction 0x%x at " kdb_bfd_vma_fmt "\n",
773                                            bp->bp_inst, bp->bp_addr);
774                         if (kdb_putword(bp->bp_addr, bp->bp_inst, 1))
775                                 return(1);
776                 }
777                 bp->bp_installed = 0;
778         }
779         return(0);
780 }