mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-16 23:57:54 +01:00
Clean up formatting and fix an & -> && bug pointed out by bde
This commit is contained in:
parent
2df511e27c
commit
d42c2de85c
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=17865
@ -23,7 +23,7 @@
|
||||
* any improvements or extensions that they make and grant Carnegie the
|
||||
* rights to redistribute these changes.
|
||||
*
|
||||
* $Id: db_interface.c,v 1.19 1996/05/03 21:00:51 phk Exp $
|
||||
* $Id: db_interface.c,v 1.20 1996/08/27 19:45:56 pst Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -35,11 +35,10 @@
|
||||
#include <sys/proc.h>
|
||||
#include <sys/reboot.h>
|
||||
|
||||
#include <machine/cons.h>
|
||||
#include <machine/md_var.h>
|
||||
#include <machine/segments.h>
|
||||
|
||||
#include <machine/cons.h> /* XXX: import cons_unavail */
|
||||
|
||||
#include <vm/vm.h>
|
||||
#include <vm/vm_param.h>
|
||||
#include <vm/pmap.h>
|
||||
@ -47,43 +46,26 @@
|
||||
#include <ddb/ddb.h>
|
||||
#include <setjmp.h>
|
||||
|
||||
static int db_active = 0;
|
||||
static jmp_buf *db_nofault = 0;
|
||||
extern jmp_buf db_jmpbuf;
|
||||
|
||||
extern void gdb_handle_exception __P((db_regs_t *, int, int));
|
||||
|
||||
db_regs_t ddb_regs;
|
||||
|
||||
static void kdbprinttrap __P((int type, int code));
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* Received keyboard interrupt sequence.
|
||||
*/
|
||||
void
|
||||
kdb_kbd_trap(regs)
|
||||
struct i386_saved_state *regs;
|
||||
{
|
||||
if (db_active == 0 && (boothowto & RB_KDB)) {
|
||||
db_printf("\n\nkernel: keyboard interrupt\n");
|
||||
kdb_trap(-1, 0, regs);
|
||||
}
|
||||
}
|
||||
#ifdef __GNUC__
|
||||
#define rss() ({u_short ss; __asm __volatile("movl %%ss,%0" : "=r" (ss)); ss;})
|
||||
#endif
|
||||
|
||||
/*
|
||||
* kdb_trap - field a TRACE or BPT trap
|
||||
*/
|
||||
|
||||
static jmp_buf *db_nofault = 0;
|
||||
|
||||
int
|
||||
kdb_trap(type, code, regs)
|
||||
int type, code;
|
||||
register struct i386_saved_state *regs;
|
||||
{
|
||||
#if 0
|
||||
if ((boothowto&RB_KDB) == 0)
|
||||
return(0);
|
||||
#endif
|
||||
int ddb_mode = !(boothowto & RB_GDB);
|
||||
|
||||
/*
|
||||
* XXX try to do nothing if the console is in graphics mode.
|
||||
@ -94,12 +76,12 @@ kdb_trap(type, code, regs)
|
||||
* our breakpoints by disarming our breakpoints and fixing up
|
||||
* %eip.
|
||||
*/
|
||||
if (cons_unavail && !(boothowto & RB_GDB)) {
|
||||
if (type == T_TRCTRAP) {
|
||||
regs->tf_eflags &= ~PSL_T;
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
if (cons_unavail && ddb_mode) {
|
||||
if (type == T_TRCTRAP) {
|
||||
regs->tf_eflags &= ~PSL_T;
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
@ -108,7 +90,7 @@ kdb_trap(type, code, regs)
|
||||
break;
|
||||
|
||||
default:
|
||||
kdbprinttrap(type, code);
|
||||
db_printf("kernel: type %d trap, code=%x\n", type, code);
|
||||
|
||||
if (db_nofault) {
|
||||
jmp_buf *no_fault = db_nofault;
|
||||
@ -117,29 +99,27 @@ kdb_trap(type, code, regs)
|
||||
}
|
||||
}
|
||||
|
||||
/* Should switch to kdb`s own stack here. */
|
||||
|
||||
/*
|
||||
* XXX We really should switch to a local stack here.
|
||||
*/
|
||||
ddb_regs = *regs;
|
||||
|
||||
/*
|
||||
* Kernel mode - esp and ss not saved, so dummy them up
|
||||
*/
|
||||
if (ISPL(regs->tf_cs) == 0) {
|
||||
/*
|
||||
* Kernel mode - esp and ss not saved
|
||||
*/
|
||||
ddb_regs.tf_esp = (int)®s->tf_esp; /* kernel stack pointer */
|
||||
#ifdef __GNUC__
|
||||
#define rss() ({u_short ss; __asm __volatile("movl %%ss,%0" : "=r" (ss)); ss;})
|
||||
#endif
|
||||
ddb_regs.tf_esp = (int)®s->tf_esp;
|
||||
ddb_regs.tf_ss = rss();
|
||||
}
|
||||
|
||||
db_active++;
|
||||
cnpollc(TRUE);
|
||||
if (boothowto & RB_GDB)
|
||||
gdb_handle_exception(&ddb_regs, type, code);
|
||||
else
|
||||
|
||||
if (ddb_mode)
|
||||
db_trap(type, code);
|
||||
else
|
||||
gdb_handle_exception(&ddb_regs, type, code);
|
||||
|
||||
cnpollc(FALSE);
|
||||
db_active--;
|
||||
|
||||
regs->tf_eip = ddb_regs.tf_eip;
|
||||
regs->tf_eflags = ddb_regs.tf_eflags;
|
||||
@ -147,45 +127,27 @@ kdb_trap(type, code, regs)
|
||||
regs->tf_ecx = ddb_regs.tf_ecx;
|
||||
regs->tf_edx = ddb_regs.tf_edx;
|
||||
regs->tf_ebx = ddb_regs.tf_ebx;
|
||||
|
||||
/*
|
||||
* If in user mode, the saved ESP and SS were valid, restore them
|
||||
*/
|
||||
if (ISPL(regs->tf_cs)) {
|
||||
/*
|
||||
* user mode - saved esp and ss valid
|
||||
*/
|
||||
regs->tf_esp = ddb_regs.tf_esp; /* user stack pointer */
|
||||
regs->tf_ss = ddb_regs.tf_ss & 0xffff; /* user stack segment */
|
||||
regs->tf_esp = ddb_regs.tf_esp;
|
||||
regs->tf_ss = ddb_regs.tf_ss & 0xffff;
|
||||
}
|
||||
|
||||
regs->tf_ebp = ddb_regs.tf_ebp;
|
||||
regs->tf_esi = ddb_regs.tf_esi;
|
||||
regs->tf_edi = ddb_regs.tf_edi;
|
||||
regs->tf_es = ddb_regs.tf_es & 0xffff;
|
||||
regs->tf_cs = ddb_regs.tf_cs & 0xffff;
|
||||
regs->tf_ds = ddb_regs.tf_ds & 0xffff;
|
||||
#if 0
|
||||
regs->tf_fs = ddb_regs.tf_fs & 0xffff;
|
||||
regs->tf_gs = ddb_regs.tf_gs & 0xffff;
|
||||
#endif
|
||||
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Print trap reason.
|
||||
*/
|
||||
static void
|
||||
kdbprinttrap(type, code)
|
||||
int type, code;
|
||||
{
|
||||
db_printf("kernel: ");
|
||||
db_printf("type %d", type);
|
||||
db_printf(" trap, code=%x\n", code);
|
||||
}
|
||||
|
||||
/*
|
||||
* Read bytes from kernel address space for debugger.
|
||||
*/
|
||||
|
||||
extern jmp_buf db_jmpbuf;
|
||||
|
||||
void
|
||||
db_read_bytes(addr, size, data)
|
||||
vm_offset_t addr;
|
||||
@ -222,21 +184,21 @@ db_write_bytes(addr, size, data)
|
||||
|
||||
db_nofault = &db_jmpbuf;
|
||||
|
||||
if (addr >= VM_MIN_KERNEL_ADDRESS &&
|
||||
addr <= (vm_offset_t)&etext)
|
||||
{
|
||||
if (addr >= VM_MIN_KERNEL_ADDRESS && addr <= (vm_offset_t)&etext) {
|
||||
|
||||
ptep0 = pmap_pte(kernel_pmap, addr);
|
||||
oldmap0 = *ptep0;
|
||||
*(int *)ptep0 |= /* INTEL_PTE_WRITE */ PG_RW;
|
||||
|
||||
addr1 = trunc_page(addr + size - 1);
|
||||
if (trunc_page(addr) != addr1) {
|
||||
/* data crosses a page boundary */
|
||||
|
||||
/* data crosses a page boundary */
|
||||
if (trunc_page(addr) != addr1) {
|
||||
ptep1 = pmap_pte(kernel_pmap, addr1);
|
||||
oldmap1 = *ptep1;
|
||||
*(int *)ptep1 |= /* INTEL_PTE_WRITE */ PG_RW;
|
||||
}
|
||||
|
||||
pmap_update();
|
||||
}
|
||||
|
||||
@ -249,15 +211,17 @@ db_write_bytes(addr, size, data)
|
||||
|
||||
if (ptep0) {
|
||||
*ptep0 = oldmap0;
|
||||
if (ptep1) {
|
||||
|
||||
if (ptep1)
|
||||
*ptep1 = oldmap1;
|
||||
}
|
||||
|
||||
pmap_update();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* XXX move this to machdep.c and allow it to be called iff any debugger is
|
||||
* XXX
|
||||
* Move this to machdep.c and allow it to be called if any debugger is
|
||||
* installed.
|
||||
*/
|
||||
void
|
||||
@ -267,17 +231,18 @@ Debugger(msg)
|
||||
static volatile u_char in_Debugger;
|
||||
|
||||
/*
|
||||
* XXX do nothing if the console is in graphics mode. This is
|
||||
* XXX
|
||||
* Do nothing if the console is in graphics mode. This is
|
||||
* OK if the call is for the debugger hotkey but not if the call
|
||||
* is a weak form of panicing.
|
||||
*/
|
||||
if (cons_unavail & !(boothowto & RB_GDB))
|
||||
return;
|
||||
if (cons_unavail && !(boothowto & RB_GDB))
|
||||
return;
|
||||
|
||||
if (!in_Debugger) {
|
||||
in_Debugger = 1;
|
||||
db_printf("Debugger(\"%s\")\n", msg);
|
||||
breakpoint();
|
||||
in_Debugger = 0;
|
||||
in_Debugger = 1;
|
||||
db_printf("Debugger(\"%s\")\n", msg);
|
||||
breakpoint();
|
||||
in_Debugger = 0;
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@
|
||||
* any improvements or extensions that they make and grant Carnegie the
|
||||
* rights to redistribute these changes.
|
||||
*
|
||||
* $Id: db_interface.c,v 1.19 1996/05/03 21:00:51 phk Exp $
|
||||
* $Id: db_interface.c,v 1.20 1996/08/27 19:45:56 pst Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -35,11 +35,10 @@
|
||||
#include <sys/proc.h>
|
||||
#include <sys/reboot.h>
|
||||
|
||||
#include <machine/cons.h>
|
||||
#include <machine/md_var.h>
|
||||
#include <machine/segments.h>
|
||||
|
||||
#include <machine/cons.h> /* XXX: import cons_unavail */
|
||||
|
||||
#include <vm/vm.h>
|
||||
#include <vm/vm_param.h>
|
||||
#include <vm/pmap.h>
|
||||
@ -47,43 +46,26 @@
|
||||
#include <ddb/ddb.h>
|
||||
#include <setjmp.h>
|
||||
|
||||
static int db_active = 0;
|
||||
static jmp_buf *db_nofault = 0;
|
||||
extern jmp_buf db_jmpbuf;
|
||||
|
||||
extern void gdb_handle_exception __P((db_regs_t *, int, int));
|
||||
|
||||
db_regs_t ddb_regs;
|
||||
|
||||
static void kdbprinttrap __P((int type, int code));
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* Received keyboard interrupt sequence.
|
||||
*/
|
||||
void
|
||||
kdb_kbd_trap(regs)
|
||||
struct i386_saved_state *regs;
|
||||
{
|
||||
if (db_active == 0 && (boothowto & RB_KDB)) {
|
||||
db_printf("\n\nkernel: keyboard interrupt\n");
|
||||
kdb_trap(-1, 0, regs);
|
||||
}
|
||||
}
|
||||
#ifdef __GNUC__
|
||||
#define rss() ({u_short ss; __asm __volatile("movl %%ss,%0" : "=r" (ss)); ss;})
|
||||
#endif
|
||||
|
||||
/*
|
||||
* kdb_trap - field a TRACE or BPT trap
|
||||
*/
|
||||
|
||||
static jmp_buf *db_nofault = 0;
|
||||
|
||||
int
|
||||
kdb_trap(type, code, regs)
|
||||
int type, code;
|
||||
register struct i386_saved_state *regs;
|
||||
{
|
||||
#if 0
|
||||
if ((boothowto&RB_KDB) == 0)
|
||||
return(0);
|
||||
#endif
|
||||
int ddb_mode = !(boothowto & RB_GDB);
|
||||
|
||||
/*
|
||||
* XXX try to do nothing if the console is in graphics mode.
|
||||
@ -94,12 +76,12 @@ kdb_trap(type, code, regs)
|
||||
* our breakpoints by disarming our breakpoints and fixing up
|
||||
* %eip.
|
||||
*/
|
||||
if (cons_unavail && !(boothowto & RB_GDB)) {
|
||||
if (type == T_TRCTRAP) {
|
||||
regs->tf_eflags &= ~PSL_T;
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
if (cons_unavail && ddb_mode) {
|
||||
if (type == T_TRCTRAP) {
|
||||
regs->tf_eflags &= ~PSL_T;
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
@ -108,7 +90,7 @@ kdb_trap(type, code, regs)
|
||||
break;
|
||||
|
||||
default:
|
||||
kdbprinttrap(type, code);
|
||||
db_printf("kernel: type %d trap, code=%x\n", type, code);
|
||||
|
||||
if (db_nofault) {
|
||||
jmp_buf *no_fault = db_nofault;
|
||||
@ -117,29 +99,27 @@ kdb_trap(type, code, regs)
|
||||
}
|
||||
}
|
||||
|
||||
/* Should switch to kdb`s own stack here. */
|
||||
|
||||
/*
|
||||
* XXX We really should switch to a local stack here.
|
||||
*/
|
||||
ddb_regs = *regs;
|
||||
|
||||
/*
|
||||
* Kernel mode - esp and ss not saved, so dummy them up
|
||||
*/
|
||||
if (ISPL(regs->tf_cs) == 0) {
|
||||
/*
|
||||
* Kernel mode - esp and ss not saved
|
||||
*/
|
||||
ddb_regs.tf_esp = (int)®s->tf_esp; /* kernel stack pointer */
|
||||
#ifdef __GNUC__
|
||||
#define rss() ({u_short ss; __asm __volatile("movl %%ss,%0" : "=r" (ss)); ss;})
|
||||
#endif
|
||||
ddb_regs.tf_esp = (int)®s->tf_esp;
|
||||
ddb_regs.tf_ss = rss();
|
||||
}
|
||||
|
||||
db_active++;
|
||||
cnpollc(TRUE);
|
||||
if (boothowto & RB_GDB)
|
||||
gdb_handle_exception(&ddb_regs, type, code);
|
||||
else
|
||||
|
||||
if (ddb_mode)
|
||||
db_trap(type, code);
|
||||
else
|
||||
gdb_handle_exception(&ddb_regs, type, code);
|
||||
|
||||
cnpollc(FALSE);
|
||||
db_active--;
|
||||
|
||||
regs->tf_eip = ddb_regs.tf_eip;
|
||||
regs->tf_eflags = ddb_regs.tf_eflags;
|
||||
@ -147,45 +127,27 @@ kdb_trap(type, code, regs)
|
||||
regs->tf_ecx = ddb_regs.tf_ecx;
|
||||
regs->tf_edx = ddb_regs.tf_edx;
|
||||
regs->tf_ebx = ddb_regs.tf_ebx;
|
||||
|
||||
/*
|
||||
* If in user mode, the saved ESP and SS were valid, restore them
|
||||
*/
|
||||
if (ISPL(regs->tf_cs)) {
|
||||
/*
|
||||
* user mode - saved esp and ss valid
|
||||
*/
|
||||
regs->tf_esp = ddb_regs.tf_esp; /* user stack pointer */
|
||||
regs->tf_ss = ddb_regs.tf_ss & 0xffff; /* user stack segment */
|
||||
regs->tf_esp = ddb_regs.tf_esp;
|
||||
regs->tf_ss = ddb_regs.tf_ss & 0xffff;
|
||||
}
|
||||
|
||||
regs->tf_ebp = ddb_regs.tf_ebp;
|
||||
regs->tf_esi = ddb_regs.tf_esi;
|
||||
regs->tf_edi = ddb_regs.tf_edi;
|
||||
regs->tf_es = ddb_regs.tf_es & 0xffff;
|
||||
regs->tf_cs = ddb_regs.tf_cs & 0xffff;
|
||||
regs->tf_ds = ddb_regs.tf_ds & 0xffff;
|
||||
#if 0
|
||||
regs->tf_fs = ddb_regs.tf_fs & 0xffff;
|
||||
regs->tf_gs = ddb_regs.tf_gs & 0xffff;
|
||||
#endif
|
||||
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Print trap reason.
|
||||
*/
|
||||
static void
|
||||
kdbprinttrap(type, code)
|
||||
int type, code;
|
||||
{
|
||||
db_printf("kernel: ");
|
||||
db_printf("type %d", type);
|
||||
db_printf(" trap, code=%x\n", code);
|
||||
}
|
||||
|
||||
/*
|
||||
* Read bytes from kernel address space for debugger.
|
||||
*/
|
||||
|
||||
extern jmp_buf db_jmpbuf;
|
||||
|
||||
void
|
||||
db_read_bytes(addr, size, data)
|
||||
vm_offset_t addr;
|
||||
@ -222,21 +184,21 @@ db_write_bytes(addr, size, data)
|
||||
|
||||
db_nofault = &db_jmpbuf;
|
||||
|
||||
if (addr >= VM_MIN_KERNEL_ADDRESS &&
|
||||
addr <= (vm_offset_t)&etext)
|
||||
{
|
||||
if (addr >= VM_MIN_KERNEL_ADDRESS && addr <= (vm_offset_t)&etext) {
|
||||
|
||||
ptep0 = pmap_pte(kernel_pmap, addr);
|
||||
oldmap0 = *ptep0;
|
||||
*(int *)ptep0 |= /* INTEL_PTE_WRITE */ PG_RW;
|
||||
|
||||
addr1 = trunc_page(addr + size - 1);
|
||||
if (trunc_page(addr) != addr1) {
|
||||
/* data crosses a page boundary */
|
||||
|
||||
/* data crosses a page boundary */
|
||||
if (trunc_page(addr) != addr1) {
|
||||
ptep1 = pmap_pte(kernel_pmap, addr1);
|
||||
oldmap1 = *ptep1;
|
||||
*(int *)ptep1 |= /* INTEL_PTE_WRITE */ PG_RW;
|
||||
}
|
||||
|
||||
pmap_update();
|
||||
}
|
||||
|
||||
@ -249,15 +211,17 @@ db_write_bytes(addr, size, data)
|
||||
|
||||
if (ptep0) {
|
||||
*ptep0 = oldmap0;
|
||||
if (ptep1) {
|
||||
|
||||
if (ptep1)
|
||||
*ptep1 = oldmap1;
|
||||
}
|
||||
|
||||
pmap_update();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* XXX move this to machdep.c and allow it to be called iff any debugger is
|
||||
* XXX
|
||||
* Move this to machdep.c and allow it to be called if any debugger is
|
||||
* installed.
|
||||
*/
|
||||
void
|
||||
@ -267,17 +231,18 @@ Debugger(msg)
|
||||
static volatile u_char in_Debugger;
|
||||
|
||||
/*
|
||||
* XXX do nothing if the console is in graphics mode. This is
|
||||
* XXX
|
||||
* Do nothing if the console is in graphics mode. This is
|
||||
* OK if the call is for the debugger hotkey but not if the call
|
||||
* is a weak form of panicing.
|
||||
*/
|
||||
if (cons_unavail & !(boothowto & RB_GDB))
|
||||
return;
|
||||
if (cons_unavail && !(boothowto & RB_GDB))
|
||||
return;
|
||||
|
||||
if (!in_Debugger) {
|
||||
in_Debugger = 1;
|
||||
db_printf("Debugger(\"%s\")\n", msg);
|
||||
breakpoint();
|
||||
in_Debugger = 0;
|
||||
in_Debugger = 1;
|
||||
db_printf("Debugger(\"%s\")\n", msg);
|
||||
breakpoint();
|
||||
in_Debugger = 0;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user