aboutsummaryrefslogtreecommitdiff
path: root/sys/amd64/amd64/db_trace.c
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2006-11-15 19:53:48 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2006-11-15 19:53:48 +0000
commit71f40077107a64b25895e5ae4314ce0a3677daf4 (patch)
tree69415759a476fadfe9ca3ef3653f5993298f12b1 /sys/amd64/amd64/db_trace.c
parent28c75f229dbcab5b1a1327c8a76eb5632e329cf4 (diff)
downloadsrc-71f40077107a64b25895e5ae4314ce0a3677daf4.tar.gz
src-71f40077107a64b25895e5ae4314ce0a3677daf4.zip
Various whitespace and style fixes.
Notes
Notes: svn path=/head/; revision=164303
Diffstat (limited to 'sys/amd64/amd64/db_trace.c')
-rw-r--r--sys/amd64/amd64/db_trace.c71
1 files changed, 35 insertions, 36 deletions
diff --git a/sys/amd64/amd64/db_trace.c b/sys/amd64/amd64/db_trace.c
index dd6a93a12a6e..57f6e482b7e1 100644
--- a/sys/amd64/amd64/db_trace.c
+++ b/sys/amd64/amd64/db_trace.c
@@ -202,8 +202,8 @@ static void decode_syscall(int, struct thread *);
static char * watchtype_str(int type);
int amd64_set_watch(int watchnum, unsigned long watchaddr, int size,
- int access, struct dbreg * d);
-int amd64_clr_watch(int watchnum, struct dbreg * d);
+ int access, struct dbreg *d);
+int amd64_clr_watch(int watchnum, struct dbreg *d);
/*
* Figure out how many arguments were passed into the frame at "fp".
@@ -536,11 +536,11 @@ amd64_set_watch(watchnum, watchaddr, size, access, d)
unsigned long watchaddr;
int size;
int access;
- struct dbreg * d;
+ struct dbreg *d;
{
int i;
unsigned int mask;
-
+
if (watchnum == -1) {
for (i = 0, mask = 0x3; i < 4; i++, mask <<= 2)
if ((d->dr[7] & mask) == 0)
@@ -550,7 +550,7 @@ amd64_set_watch(watchnum, watchaddr, size, access, d)
else
return (-1);
}
-
+
switch (access) {
case DBREG_DR7_EXEC:
size = 1; /* size must be 1 for an execution breakpoint */
@@ -558,9 +558,10 @@ amd64_set_watch(watchnum, watchaddr, size, access, d)
case DBREG_DR7_WRONLY:
case DBREG_DR7_RDWR:
break;
- default : return (-1);
+ default:
+ return (-1);
}
-
+
/*
* we can watch a 1, 2, or 4 byte sized location
*/
@@ -577,7 +578,7 @@ amd64_set_watch(watchnum, watchaddr, size, access, d)
d->dr[7] &= ~((0x3 << (watchnum*2)) | (0x0f << (watchnum*4+16)));
/* set drN register to the address, N=watchnum */
- DBREG_DRX(d,watchnum) = watchaddr;
+ DBREG_DRX(d, watchnum) = watchaddr;
/* enable the watchpoint */
d->dr[7] |= (0x2 << (watchnum*2)) | (mask << (watchnum*4+16));
@@ -589,15 +590,15 @@ amd64_set_watch(watchnum, watchaddr, size, access, d)
int
amd64_clr_watch(watchnum, d)
int watchnum;
- struct dbreg * d;
+ struct dbreg *d;
{
if (watchnum < 0 || watchnum >= 4)
return (-1);
-
+
d->dr[7] = d->dr[7] & ~((0x3 << (watchnum*2)) | (0x0f << (watchnum*4+16)));
- DBREG_DRX(d,watchnum) = 0;
-
+ DBREG_DRX(d, watchnum) = 0;
+
return (0);
}
@@ -607,22 +608,21 @@ db_md_set_watchpoint(addr, size)
db_expr_t addr;
db_expr_t size;
{
- int avail, wsize;
- int i;
struct dbreg d;
-
+ int avail, i, wsize;
+
fill_dbregs(NULL, &d);
-
+
avail = 0;
- for(i=0; i<4; i++) {
+ for(i = 0; i < 4; i++) {
if ((d.dr[7] & (3 << (i*2))) == 0)
avail++;
}
-
- if (avail*4 < size)
+
+ if (avail * 4 < size)
return (-1);
-
- for (i=0; i<4 && (size != 0); i++) {
+
+ for (i = 0; i < 4 && (size != 0); i++) {
if ((d.dr[7] & (3<<(i*2))) == 0) {
if (size > 4)
wsize = 4;
@@ -630,15 +630,15 @@ db_md_set_watchpoint(addr, size)
wsize = size;
if (wsize == 3)
wsize++;
- amd64_set_watch(i, addr, wsize,
+ amd64_set_watch(i, addr, wsize,
DBREG_DR7_WRONLY, &d);
addr += wsize;
size -= wsize;
}
}
-
+
set_dbregs(NULL, &d);
-
+
return(0);
}
@@ -653,22 +653,22 @@ db_md_clr_watchpoint(addr, size)
fill_dbregs(NULL, &d);
- for(i=0; i<4; i++) {
+ for(i = 0; i < 4; i++) {
if (d.dr[7] & (3 << (i*2))) {
- if ((DBREG_DRX((&d), i) >= addr) &&
+ if ((DBREG_DRX((&d), i) >= addr) &&
(DBREG_DRX((&d), i) < addr+size))
amd64_clr_watch(i, &d);
-
+
}
}
-
+
set_dbregs(NULL, &d);
-
+
return(0);
}
-static
+static
char *
watchtype_str(type)
int type;
@@ -685,30 +685,29 @@ watchtype_str(type)
void
db_md_list_watchpoints()
{
- int i;
struct dbreg d;
+ int i, len, type;
fill_dbregs(NULL, &d);
db_printf("\nhardware watchpoints:\n");
db_printf(" watch status type len address\n");
db_printf(" ----- -------- ---------- --- ----------\n");
- for (i=0; i<4; i++) {
+ for (i = 0; i < 4; i++) {
if (d.dr[7] & (0x03 << (i*2))) {
- unsigned type, len;
type = (d.dr[7] >> (16+(i*4))) & 3;
len = (d.dr[7] >> (16+(i*4)+2)) & 3;
db_printf(" %-5d %-8s %10s %3d 0x%016lx\n",
- i, "enabled", watchtype_str(type),
+ i, "enabled", watchtype_str(type),
len + 1, DBREG_DRX((&d), i));
}
else {
db_printf(" %-5d disabled\n", i);
}
}
-
+
db_printf("\ndebug register values:\n");
- for (i=0; i<8; i++) {
+ for (i = 0; i < 8; i++) {
db_printf(" dr%d 0x%016lx\n", i, DBREG_DRX((&d), i));
}
db_printf("\n");