diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/amd64/amd64/db_trace.c | 20 | ||||
-rw-r--r-- | sys/amd64/amd64/machdep.c | 78 | ||||
-rw-r--r-- | sys/amd64/include/reg.h | 15 | ||||
-rw-r--r-- | sys/i386/i386/db_trace.c | 20 | ||||
-rw-r--r-- | sys/i386/i386/machdep.c | 78 | ||||
-rw-r--r-- | sys/i386/include/reg.h | 15 |
6 files changed, 110 insertions, 116 deletions
diff --git a/sys/amd64/amd64/db_trace.c b/sys/amd64/amd64/db_trace.c index 211cea0..1134964 100644 --- a/sys/amd64/amd64/db_trace.c +++ b/sys/amd64/amd64/db_trace.c @@ -487,7 +487,7 @@ i386_set_watch(watchnum, watchaddr, size, access, d) if (watchnum == -1) { for (i = 0, mask = 0x3; i < 4; i++, mask <<= 2) - if ((d->dr7 & mask) == 0) + if ((d->dr[7] & mask) == 0) break; if (i < 4) watchnum = i; @@ -518,13 +518,13 @@ i386_set_watch(watchnum, watchaddr, size, access, d) mask |= access; /* clear the bits we are about to affect */ - d->dr7 &= ~((0x3 << (watchnum*2)) | (0x0f << (watchnum*4+16))); + d->dr[7] &= ~((0x3 << (watchnum*2)) | (0x0f << (watchnum*4+16))); /* set drN register to the address, N=watchnum */ DBREG_DRX(d,watchnum) = watchaddr; /* enable the watchpoint */ - d->dr7 |= (0x2 << (watchnum*2)) | (mask << (watchnum*4+16)); + d->dr[7] |= (0x2 << (watchnum*2)) | (mask << (watchnum*4+16)); return (watchnum); } @@ -539,7 +539,7 @@ i386_clr_watch(watchnum, d) if (watchnum < 0 || watchnum >= 4) return (-1); - d->dr7 = d->dr7 & ~((0x3 << (watchnum*2)) | (0x0f << (watchnum*4+16))); + d->dr[7] = d->dr[7] & ~((0x3 << (watchnum*2)) | (0x0f << (watchnum*4+16))); DBREG_DRX(d,watchnum) = 0; return (0); @@ -559,7 +559,7 @@ db_md_set_watchpoint(addr, size) avail = 0; for(i=0; i<4; i++) { - if ((d.dr7 & (3 << (i*2))) == 0) + if ((d.dr[7] & (3 << (i*2))) == 0) avail++; } @@ -567,7 +567,7 @@ db_md_set_watchpoint(addr, size) return (-1); for (i=0; i<4 && (size != 0); i++) { - if ((d.dr7 & (3<<(i*2))) == 0) { + if ((d.dr[7] & (3<<(i*2))) == 0) { if (size > 4) wsize = 4; else @@ -598,7 +598,7 @@ db_md_clr_watchpoint(addr, size) fill_dbregs(NULL, &d); for(i=0; i<4; i++) { - if (d.dr7 & (3 << (i*2))) { + if (d.dr[7] & (3 << (i*2))) { if ((DBREG_DRX((&d), i) >= addr) && (DBREG_DRX((&d), i) < addr+size)) i386_clr_watch(i, &d); @@ -638,10 +638,10 @@ db_md_list_watchpoints() db_printf(" watch status type len address\n"); db_printf(" ----- -------- ---------- --- ----------\n"); for (i=0; i<4; i++) { - if (d.dr7 & (0x03 << (i*2))) { + if (d.dr[7] & (0x03 << (i*2))) { unsigned type, len; - type = (d.dr7 >> (16+(i*4))) & 3; - len = (d.dr7 >> (16+(i*4)+2)) & 3; + type = (d.dr[7] >> (16+(i*4))) & 3; + len = (d.dr[7] >> (16+(i*4)+2)) & 3; db_printf(" %-5d %-8s %10s %3d 0x%08x\n", i, "enabled", watchtype_str(type), len+1, DBREG_DRX((&d),i)); diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c index 380ddee..ac63d20 100644 --- a/sys/amd64/amd64/machdep.c +++ b/sys/amd64/amd64/machdep.c @@ -2267,24 +2267,24 @@ fill_dbregs(struct thread *td, struct dbreg *dbregs) struct pcb *pcb; if (td == NULL) { - dbregs->dr0 = rdr0(); - dbregs->dr1 = rdr1(); - dbregs->dr2 = rdr2(); - dbregs->dr3 = rdr3(); - dbregs->dr4 = rdr4(); - dbregs->dr5 = rdr5(); - dbregs->dr6 = rdr6(); - dbregs->dr7 = rdr7(); + dbregs->dr[0] = rdr0(); + dbregs->dr[1] = rdr1(); + dbregs->dr[2] = rdr2(); + dbregs->dr[3] = rdr3(); + dbregs->dr[4] = rdr4(); + dbregs->dr[5] = rdr5(); + dbregs->dr[6] = rdr6(); + dbregs->dr[7] = rdr7(); } else { pcb = td->td_pcb; - dbregs->dr0 = pcb->pcb_dr0; - dbregs->dr1 = pcb->pcb_dr1; - dbregs->dr2 = pcb->pcb_dr2; - dbregs->dr3 = pcb->pcb_dr3; - dbregs->dr4 = 0; - dbregs->dr5 = 0; - dbregs->dr6 = pcb->pcb_dr6; - dbregs->dr7 = pcb->pcb_dr7; + dbregs->dr[0] = pcb->pcb_dr0; + dbregs->dr[1] = pcb->pcb_dr1; + dbregs->dr[2] = pcb->pcb_dr2; + dbregs->dr[3] = pcb->pcb_dr3; + dbregs->dr[4] = 0; + dbregs->dr[5] = 0; + dbregs->dr[6] = pcb->pcb_dr6; + dbregs->dr[7] = pcb->pcb_dr7; } return (0); } @@ -2297,14 +2297,14 @@ set_dbregs(struct thread *td, struct dbreg *dbregs) u_int32_t mask1, mask2; if (td == NULL) { - load_dr0(dbregs->dr0); - load_dr1(dbregs->dr1); - load_dr2(dbregs->dr2); - load_dr3(dbregs->dr3); - load_dr4(dbregs->dr4); - load_dr5(dbregs->dr5); - load_dr6(dbregs->dr6); - load_dr7(dbregs->dr7); + load_dr0(dbregs->dr[0]); + load_dr1(dbregs->dr[1]); + load_dr2(dbregs->dr[2]); + load_dr3(dbregs->dr[3]); + load_dr4(dbregs->dr[4]); + load_dr5(dbregs->dr[5]); + load_dr6(dbregs->dr[6]); + load_dr7(dbregs->dr[7]); } else { /* * Don't let an illegal value for dr7 get set. Specifically, @@ -2314,7 +2314,7 @@ set_dbregs(struct thread *td, struct dbreg *dbregs) */ for (i = 0, mask1 = 0x3<<16, mask2 = 0x2<<16; i < 8; i++, mask1 <<= 2, mask2 <<= 2) - if ((dbregs->dr7 & mask1) == mask2) + if ((dbregs->dr[7] & mask1) == mask2) return (EINVAL); pcb = td->td_pcb; @@ -2335,37 +2335,37 @@ set_dbregs(struct thread *td, struct dbreg *dbregs) */ if (suser(td) != 0) { - if (dbregs->dr7 & 0x3) { + if (dbregs->dr[7] & 0x3) { /* dr0 is enabled */ - if (dbregs->dr0 >= VM_MAXUSER_ADDRESS) + if (dbregs->dr[0] >= VM_MAXUSER_ADDRESS) return (EINVAL); } - if (dbregs->dr7 & (0x3<<2)) { + if (dbregs->dr[7] & (0x3<<2)) { /* dr1 is enabled */ - if (dbregs->dr1 >= VM_MAXUSER_ADDRESS) + if (dbregs->dr[1] >= VM_MAXUSER_ADDRESS) return (EINVAL); } - if (dbregs->dr7 & (0x3<<4)) { + if (dbregs->dr[7] & (0x3<<4)) { /* dr2 is enabled */ - if (dbregs->dr2 >= VM_MAXUSER_ADDRESS) + if (dbregs->dr[2] >= VM_MAXUSER_ADDRESS) return (EINVAL); } - if (dbregs->dr7 & (0x3<<6)) { + if (dbregs->dr[7] & (0x3<<6)) { /* dr3 is enabled */ - if (dbregs->dr3 >= VM_MAXUSER_ADDRESS) + if (dbregs->dr[3] >= VM_MAXUSER_ADDRESS) return (EINVAL); } } - pcb->pcb_dr0 = dbregs->dr0; - pcb->pcb_dr1 = dbregs->dr1; - pcb->pcb_dr2 = dbregs->dr2; - pcb->pcb_dr3 = dbregs->dr3; - pcb->pcb_dr6 = dbregs->dr6; - pcb->pcb_dr7 = dbregs->dr7; + pcb->pcb_dr0 = dbregs->dr[0]; + pcb->pcb_dr1 = dbregs->dr[1]; + pcb->pcb_dr2 = dbregs->dr[2]; + pcb->pcb_dr3 = dbregs->dr[3]; + pcb->pcb_dr6 = dbregs->dr[6]; + pcb->pcb_dr7 = dbregs->dr[7]; pcb->pcb_flags |= PCB_DBREGS; } diff --git a/sys/amd64/include/reg.h b/sys/amd64/include/reg.h index a900a9d..848c8fe 100644 --- a/sys/amd64/include/reg.h +++ b/sys/amd64/include/reg.h @@ -122,20 +122,17 @@ struct fpreg { * Register set accessible via /proc/$pid/dbregs. */ struct dbreg { - unsigned int dr0; /* debug address register 0 */ - unsigned int dr1; /* debug address register 1 */ - unsigned int dr2; /* debug address register 2 */ - unsigned int dr3; /* debug address register 3 */ - unsigned int dr4; /* reserved */ - unsigned int dr5; /* reserved */ - unsigned int dr6; /* debug status register */ - unsigned int dr7; /* debug control register */ + unsigned int dr[8]; /* debug registers */ + /* Index 0-3: debug address registers */ + /* Index 4-5: reserved */ + /* Index 6: debug status */ + /* Index 7: debug control */ }; #define DBREG_DR7_EXEC 0x00 /* break on execute */ #define DBREG_DR7_WRONLY 0x01 /* break on write */ #define DBREG_DR7_RDWR 0x03 /* break on read or write */ -#define DBREG_DRX(d,x) ((&d->dr0)[x]) /* reference dr0 - dr7 by +#define DBREG_DRX(d,x) (d->dr[(x)]) /* reference dr0 - dr7 by register number */ diff --git a/sys/i386/i386/db_trace.c b/sys/i386/i386/db_trace.c index 211cea0..1134964 100644 --- a/sys/i386/i386/db_trace.c +++ b/sys/i386/i386/db_trace.c @@ -487,7 +487,7 @@ i386_set_watch(watchnum, watchaddr, size, access, d) if (watchnum == -1) { for (i = 0, mask = 0x3; i < 4; i++, mask <<= 2) - if ((d->dr7 & mask) == 0) + if ((d->dr[7] & mask) == 0) break; if (i < 4) watchnum = i; @@ -518,13 +518,13 @@ i386_set_watch(watchnum, watchaddr, size, access, d) mask |= access; /* clear the bits we are about to affect */ - d->dr7 &= ~((0x3 << (watchnum*2)) | (0x0f << (watchnum*4+16))); + d->dr[7] &= ~((0x3 << (watchnum*2)) | (0x0f << (watchnum*4+16))); /* set drN register to the address, N=watchnum */ DBREG_DRX(d,watchnum) = watchaddr; /* enable the watchpoint */ - d->dr7 |= (0x2 << (watchnum*2)) | (mask << (watchnum*4+16)); + d->dr[7] |= (0x2 << (watchnum*2)) | (mask << (watchnum*4+16)); return (watchnum); } @@ -539,7 +539,7 @@ i386_clr_watch(watchnum, d) if (watchnum < 0 || watchnum >= 4) return (-1); - d->dr7 = d->dr7 & ~((0x3 << (watchnum*2)) | (0x0f << (watchnum*4+16))); + d->dr[7] = d->dr[7] & ~((0x3 << (watchnum*2)) | (0x0f << (watchnum*4+16))); DBREG_DRX(d,watchnum) = 0; return (0); @@ -559,7 +559,7 @@ db_md_set_watchpoint(addr, size) avail = 0; for(i=0; i<4; i++) { - if ((d.dr7 & (3 << (i*2))) == 0) + if ((d.dr[7] & (3 << (i*2))) == 0) avail++; } @@ -567,7 +567,7 @@ db_md_set_watchpoint(addr, size) return (-1); for (i=0; i<4 && (size != 0); i++) { - if ((d.dr7 & (3<<(i*2))) == 0) { + if ((d.dr[7] & (3<<(i*2))) == 0) { if (size > 4) wsize = 4; else @@ -598,7 +598,7 @@ db_md_clr_watchpoint(addr, size) fill_dbregs(NULL, &d); for(i=0; i<4; i++) { - if (d.dr7 & (3 << (i*2))) { + if (d.dr[7] & (3 << (i*2))) { if ((DBREG_DRX((&d), i) >= addr) && (DBREG_DRX((&d), i) < addr+size)) i386_clr_watch(i, &d); @@ -638,10 +638,10 @@ db_md_list_watchpoints() db_printf(" watch status type len address\n"); db_printf(" ----- -------- ---------- --- ----------\n"); for (i=0; i<4; i++) { - if (d.dr7 & (0x03 << (i*2))) { + if (d.dr[7] & (0x03 << (i*2))) { unsigned type, len; - type = (d.dr7 >> (16+(i*4))) & 3; - len = (d.dr7 >> (16+(i*4)+2)) & 3; + type = (d.dr[7] >> (16+(i*4))) & 3; + len = (d.dr[7] >> (16+(i*4)+2)) & 3; db_printf(" %-5d %-8s %10s %3d 0x%08x\n", i, "enabled", watchtype_str(type), len+1, DBREG_DRX((&d),i)); diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c index 380ddee..ac63d20 100644 --- a/sys/i386/i386/machdep.c +++ b/sys/i386/i386/machdep.c @@ -2267,24 +2267,24 @@ fill_dbregs(struct thread *td, struct dbreg *dbregs) struct pcb *pcb; if (td == NULL) { - dbregs->dr0 = rdr0(); - dbregs->dr1 = rdr1(); - dbregs->dr2 = rdr2(); - dbregs->dr3 = rdr3(); - dbregs->dr4 = rdr4(); - dbregs->dr5 = rdr5(); - dbregs->dr6 = rdr6(); - dbregs->dr7 = rdr7(); + dbregs->dr[0] = rdr0(); + dbregs->dr[1] = rdr1(); + dbregs->dr[2] = rdr2(); + dbregs->dr[3] = rdr3(); + dbregs->dr[4] = rdr4(); + dbregs->dr[5] = rdr5(); + dbregs->dr[6] = rdr6(); + dbregs->dr[7] = rdr7(); } else { pcb = td->td_pcb; - dbregs->dr0 = pcb->pcb_dr0; - dbregs->dr1 = pcb->pcb_dr1; - dbregs->dr2 = pcb->pcb_dr2; - dbregs->dr3 = pcb->pcb_dr3; - dbregs->dr4 = 0; - dbregs->dr5 = 0; - dbregs->dr6 = pcb->pcb_dr6; - dbregs->dr7 = pcb->pcb_dr7; + dbregs->dr[0] = pcb->pcb_dr0; + dbregs->dr[1] = pcb->pcb_dr1; + dbregs->dr[2] = pcb->pcb_dr2; + dbregs->dr[3] = pcb->pcb_dr3; + dbregs->dr[4] = 0; + dbregs->dr[5] = 0; + dbregs->dr[6] = pcb->pcb_dr6; + dbregs->dr[7] = pcb->pcb_dr7; } return (0); } @@ -2297,14 +2297,14 @@ set_dbregs(struct thread *td, struct dbreg *dbregs) u_int32_t mask1, mask2; if (td == NULL) { - load_dr0(dbregs->dr0); - load_dr1(dbregs->dr1); - load_dr2(dbregs->dr2); - load_dr3(dbregs->dr3); - load_dr4(dbregs->dr4); - load_dr5(dbregs->dr5); - load_dr6(dbregs->dr6); - load_dr7(dbregs->dr7); + load_dr0(dbregs->dr[0]); + load_dr1(dbregs->dr[1]); + load_dr2(dbregs->dr[2]); + load_dr3(dbregs->dr[3]); + load_dr4(dbregs->dr[4]); + load_dr5(dbregs->dr[5]); + load_dr6(dbregs->dr[6]); + load_dr7(dbregs->dr[7]); } else { /* * Don't let an illegal value for dr7 get set. Specifically, @@ -2314,7 +2314,7 @@ set_dbregs(struct thread *td, struct dbreg *dbregs) */ for (i = 0, mask1 = 0x3<<16, mask2 = 0x2<<16; i < 8; i++, mask1 <<= 2, mask2 <<= 2) - if ((dbregs->dr7 & mask1) == mask2) + if ((dbregs->dr[7] & mask1) == mask2) return (EINVAL); pcb = td->td_pcb; @@ -2335,37 +2335,37 @@ set_dbregs(struct thread *td, struct dbreg *dbregs) */ if (suser(td) != 0) { - if (dbregs->dr7 & 0x3) { + if (dbregs->dr[7] & 0x3) { /* dr0 is enabled */ - if (dbregs->dr0 >= VM_MAXUSER_ADDRESS) + if (dbregs->dr[0] >= VM_MAXUSER_ADDRESS) return (EINVAL); } - if (dbregs->dr7 & (0x3<<2)) { + if (dbregs->dr[7] & (0x3<<2)) { /* dr1 is enabled */ - if (dbregs->dr1 >= VM_MAXUSER_ADDRESS) + if (dbregs->dr[1] >= VM_MAXUSER_ADDRESS) return (EINVAL); } - if (dbregs->dr7 & (0x3<<4)) { + if (dbregs->dr[7] & (0x3<<4)) { /* dr2 is enabled */ - if (dbregs->dr2 >= VM_MAXUSER_ADDRESS) + if (dbregs->dr[2] >= VM_MAXUSER_ADDRESS) return (EINVAL); } - if (dbregs->dr7 & (0x3<<6)) { + if (dbregs->dr[7] & (0x3<<6)) { /* dr3 is enabled */ - if (dbregs->dr3 >= VM_MAXUSER_ADDRESS) + if (dbregs->dr[3] >= VM_MAXUSER_ADDRESS) return (EINVAL); } } - pcb->pcb_dr0 = dbregs->dr0; - pcb->pcb_dr1 = dbregs->dr1; - pcb->pcb_dr2 = dbregs->dr2; - pcb->pcb_dr3 = dbregs->dr3; - pcb->pcb_dr6 = dbregs->dr6; - pcb->pcb_dr7 = dbregs->dr7; + pcb->pcb_dr0 = dbregs->dr[0]; + pcb->pcb_dr1 = dbregs->dr[1]; + pcb->pcb_dr2 = dbregs->dr[2]; + pcb->pcb_dr3 = dbregs->dr[3]; + pcb->pcb_dr6 = dbregs->dr[6]; + pcb->pcb_dr7 = dbregs->dr[7]; pcb->pcb_flags |= PCB_DBREGS; } diff --git a/sys/i386/include/reg.h b/sys/i386/include/reg.h index a900a9d..848c8fe 100644 --- a/sys/i386/include/reg.h +++ b/sys/i386/include/reg.h @@ -122,20 +122,17 @@ struct fpreg { * Register set accessible via /proc/$pid/dbregs. */ struct dbreg { - unsigned int dr0; /* debug address register 0 */ - unsigned int dr1; /* debug address register 1 */ - unsigned int dr2; /* debug address register 2 */ - unsigned int dr3; /* debug address register 3 */ - unsigned int dr4; /* reserved */ - unsigned int dr5; /* reserved */ - unsigned int dr6; /* debug status register */ - unsigned int dr7; /* debug control register */ + unsigned int dr[8]; /* debug registers */ + /* Index 0-3: debug address registers */ + /* Index 4-5: reserved */ + /* Index 6: debug status */ + /* Index 7: debug control */ }; #define DBREG_DR7_EXEC 0x00 /* break on execute */ #define DBREG_DR7_WRONLY 0x01 /* break on write */ #define DBREG_DR7_RDWR 0x03 /* break on read or write */ -#define DBREG_DRX(d,x) ((&d->dr0)[x]) /* reference dr0 - dr7 by +#define DBREG_DRX(d,x) (d->dr[(x)]) /* reference dr0 - dr7 by register number */ |