PERFORCE change 32061 for review
Peter Wemm
peter at FreeBSD.org
Thu May 29 15:14:14 PDT 2003
http://perforce.freebsd.org/chv.cgi?CH=32061
Change 32061 by peter at peter_hammer on 2003/05/29 15:13:41
s/i386/amd64/ etc.
Affected files ...
.. //depot/projects/hammer/sys/amd64/amd64/db_interface.c#3 edit
.. //depot/projects/hammer/sys/amd64/amd64/db_trace.c#2 edit
.. //depot/projects/hammer/sys/amd64/include/db_machdep.h#6 edit
Differences ...
==== //depot/projects/hammer/sys/amd64/amd64/db_interface.c#3 (text+ko) ====
@@ -72,7 +72,7 @@
* kdb_trap - field a TRACE or BPT trap
*/
int
-kdb_trap(int type, int code, struct i386_saved_state *regs)
+kdb_trap(int type, int code, struct amd64_saved_state *regs)
{
u_int ef;
volatile int ddb_mode = !(boothowto & RB_GDB);
@@ -88,7 +88,7 @@
*/
if (cons_unavail && ddb_mode) {
if (type == T_TRCTRAP) {
- regs->tf_eflags &= ~PSL_T;
+ regs->tf_rflags &= ~PSL_T;
return (1);
}
return (0);
@@ -137,7 +137,7 @@
* If in kernel mode, esp and ss are not saved, so dummy them up.
*/
if (ISPL(regs->tf_cs) == 0) {
- ddb_regs.tf_esp = (int)®s->tf_esp;
+ ddb_regs.tf_rsp = (long)®s->tf_rsp;
ddb_regs.tf_ss = rss();
}
@@ -154,24 +154,24 @@
}
db_active = 0;
- regs->tf_eip = ddb_regs.tf_eip;
- regs->tf_eflags = ddb_regs.tf_eflags;
- regs->tf_eax = ddb_regs.tf_eax;
- regs->tf_ecx = ddb_regs.tf_ecx;
- regs->tf_edx = ddb_regs.tf_edx;
- regs->tf_ebx = ddb_regs.tf_ebx;
+ regs->tf_rip = ddb_regs.tf_rip;
+ regs->tf_rflags = ddb_regs.tf_rflags;
+ regs->tf_rax = ddb_regs.tf_rax;
+ regs->tf_rcx = ddb_regs.tf_rcx;
+ regs->tf_rdx = ddb_regs.tf_rdx;
+ regs->tf_rbx = ddb_regs.tf_rbx;
/*
* If in user mode, the saved ESP and SS were valid, restore them.
*/
if (ISPL(regs->tf_cs)) {
- regs->tf_esp = ddb_regs.tf_esp;
+ regs->tf_rsp = ddb_regs.tf_rsp;
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_rbp = ddb_regs.tf_rbp;
+ regs->tf_rsi = ddb_regs.tf_rsi;
+ regs->tf_rdi = ddb_regs.tf_rdi;
regs->tf_es = ddb_regs.tf_es & 0xffff;
regs->tf_fs = ddb_regs.tf_fs & 0xffff;
regs->tf_cs = ddb_regs.tf_cs & 0xffff;
==== //depot/projects/hammer/sys/amd64/amd64/db_trace.c#2 (text+ko) ====
@@ -66,16 +66,16 @@
{ "gs", &ddb_regs.tf_gs, FCN_NULL },
#endif
{ "ss", &ddb_regs.tf_ss, FCN_NULL },
- { "eax", &ddb_regs.tf_eax, FCN_NULL },
- { "ecx", &ddb_regs.tf_ecx, FCN_NULL },
- { "edx", &ddb_regs.tf_edx, FCN_NULL },
- { "ebx", &ddb_regs.tf_ebx, FCN_NULL },
- { "esp", &ddb_regs.tf_esp, FCN_NULL },
- { "ebp", &ddb_regs.tf_ebp, FCN_NULL },
- { "esi", &ddb_regs.tf_esi, FCN_NULL },
- { "edi", &ddb_regs.tf_edi, FCN_NULL },
- { "eip", &ddb_regs.tf_eip, FCN_NULL },
- { "efl", &ddb_regs.tf_eflags, FCN_NULL },
+ { "eax", &ddb_regs.tf_rax, FCN_NULL },
+ { "ecx", &ddb_regs.tf_rcx, FCN_NULL },
+ { "edx", &ddb_regs.tf_rdx, FCN_NULL },
+ { "ebx", &ddb_regs.tf_rbx, FCN_NULL },
+ { "esp", &ddb_regs.tf_rsp, FCN_NULL },
+ { "ebp", &ddb_regs.tf_rbp, FCN_NULL },
+ { "esi", &ddb_regs.tf_rsi, FCN_NULL },
+ { "edi", &ddb_regs.tf_rdi, FCN_NULL },
+ { "eip", &ddb_regs.tf_rip, FCN_NULL },
+ { "efl", &ddb_regs.tf_rflags, FCN_NULL },
{ "dr0", NULL, db_dr0 },
{ "dr1", NULL, db_dr1 },
{ "dr2", NULL, db_dr2 },
@@ -92,8 +92,8 @@
*/
#define INKERNEL(va) (((vm_offset_t)(va)) >= USRSTACK)
-struct i386_frame {
- struct i386_frame *f_frame;
+struct amd64_frame {
+ struct amd64_frame *f_frame;
int f_retaddr;
int f_arg0;
};
@@ -103,18 +103,18 @@
#define INTERRUPT 2
#define SYSCALL 3
-static void db_nextframe(struct i386_frame **, db_addr_t *, struct proc *);
-static int db_numargs(struct i386_frame *);
+static void db_nextframe(struct amd64_frame **, db_addr_t *, struct proc *);
+static int db_numargs(struct amd64_frame *);
static void db_print_stack_entry(const char *, int, char **, int *, db_addr_t);
static void decode_syscall(int, struct proc *);
static void db_trace_one_stack(int count, boolean_t have_addr,
- struct proc *p, struct i386_frame *frame, db_addr_t callpc);
+ struct proc *p, struct amd64_frame *frame, db_addr_t callpc);
static char * watchtype_str(int type);
-int i386_set_watch(int watchnum, unsigned int watchaddr, int size, int access,
+int amd64_set_watch(int watchnum, unsigned int watchaddr, int size, int access,
struct dbreg * d);
-int i386_clr_watch(int watchnum, struct dbreg * d);
+int amd64_clr_watch(int watchnum, struct dbreg * d);
int db_md_set_watchpoint(db_expr_t addr, db_expr_t size);
int db_md_clr_watchpoint(db_expr_t addr, db_expr_t size);
void db_md_list_watchpoints(void);
@@ -125,7 +125,7 @@
*/
static int
db_numargs(fp)
- struct i386_frame *fp;
+ struct amd64_frame *fp;
{
int *argp;
int inst;
@@ -200,7 +200,7 @@
*/
static void
db_nextframe(fp, ip, p)
- struct i386_frame **fp; /* in/out */
+ struct amd64_frame **fp; /* in/out */
db_addr_t *ip; /* out */
struct proc *p; /* in */
{
@@ -237,7 +237,7 @@
*/
if (frame_type == NORMAL) {
*ip = (db_addr_t) eip;
- *fp = (struct i386_frame *) ebp;
+ *fp = (struct amd64_frame *) ebp;
return;
}
@@ -254,16 +254,16 @@
if (INKERNEL((int) tf)) {
esp = (ISPL(tf->tf_cs) == SEL_UPL) ?
- tf->tf_esp : (int)&tf->tf_esp;
- eip = tf->tf_eip;
- ebp = tf->tf_ebp;
+ tf->tf_rsp : (int)&tf->tf_rsp;
+ eip = tf->tf_rip;
+ ebp = tf->tf_rbp;
switch (frame_type) {
case TRAP:
db_printf("--- trap %#r", tf->tf_trapno);
break;
case SYSCALL:
db_printf("--- syscall");
- decode_syscall(tf->tf_eax, p);
+ decode_syscall(tf->tf_rax, p);
break;
case INTERRUPT:
db_printf("--- interrupt");
@@ -276,7 +276,7 @@
}
*ip = (db_addr_t) eip;
- *fp = (struct i386_frame *) ebp;
+ *fp = (struct amd64_frame *) ebp;
}
void
@@ -286,7 +286,7 @@
db_expr_t count;
char *modif;
{
- struct i386_frame *frame;
+ struct amd64_frame *frame;
struct proc *p;
struct pcb *pcb;
struct thread *td;
@@ -299,10 +299,10 @@
if (!have_addr) {
td = curthread;
p = td->td_proc;
- frame = (struct i386_frame *)ddb_regs.tf_ebp;
+ frame = (struct amd64_frame *)ddb_regs.tf_rbp;
if (frame == NULL)
- frame = (struct i386_frame *)(ddb_regs.tf_esp - 4);
- callpc = (db_addr_t)ddb_regs.tf_eip;
+ frame = (struct amd64_frame *)(ddb_regs.tf_rsp - 8);
+ callpc = (db_addr_t)ddb_regs.tf_rip;
} else if (!INKERNEL(addr)) {
pid = (addr % 16) + ((addr >> 4) % 16) * 10 +
((addr >> 8) % 16) * 100 + ((addr >> 12) % 16) * 1000 +
@@ -314,11 +314,11 @@
if (pid == curthread->td_proc->p_pid) {
td = curthread;
p = td->td_proc;
- frame = (struct i386_frame *)ddb_regs.tf_ebp;
+ frame = (struct amd64_frame *)ddb_regs.tf_rbp;
if (frame == NULL)
- frame = (struct i386_frame *)
- (ddb_regs.tf_esp - 4);
- callpc = (db_addr_t)ddb_regs.tf_eip;
+ frame = (struct amd64_frame *)
+ (ddb_regs.tf_rsp - 8);
+ callpc = (db_addr_t)ddb_regs.tf_rip;
} else {
/* sx_slock(&allproc_lock); */
@@ -336,15 +336,15 @@
return;
}
pcb = FIRST_THREAD_IN_PROC(p)->td_pcb; /* XXXKSE */
- frame = (struct i386_frame *)pcb->pcb_ebp;
+ frame = (struct amd64_frame *)pcb->pcb_ebp;
if (frame == NULL)
- frame = (struct i386_frame *)
- (pcb->pcb_esp - 4);
+ frame = (struct amd64_frame *)
+ (pcb->pcb_esp - 8);
callpc = (db_addr_t)pcb->pcb_eip;
}
} else {
p = NULL;
- frame = (struct i386_frame *)addr;
+ frame = (struct amd64_frame *)addr;
callpc = (db_addr_t)db_get_value((int)&frame->f_retaddr, 4, FALSE);
frame = frame->f_frame;
}
@@ -355,7 +355,7 @@
db_stack_thread(db_expr_t addr, boolean_t have_addr,
db_expr_t count, char *modif)
{
- struct i386_frame *frame;
+ struct amd64_frame *frame;
struct thread *td;
struct proc *p;
struct pcb *pcb;
@@ -376,15 +376,15 @@
return;
}
if (td == curthread) {
- frame = (struct i386_frame *)ddb_regs.tf_ebp;
+ frame = (struct amd64_frame *)ddb_regs.tf_rbp;
if (frame == NULL)
- frame = (struct i386_frame *)(ddb_regs.tf_esp - 4);
- callpc = (db_addr_t)ddb_regs.tf_eip;
+ frame = (struct amd64_frame *)(ddb_regs.tf_rsp - 8);
+ callpc = (db_addr_t)ddb_regs.tf_rip;
} else {
pcb = td->td_pcb;
- frame = (struct i386_frame *)pcb->pcb_ebp;
+ frame = (struct amd64_frame *)pcb->pcb_ebp;
if (frame == NULL)
- frame = (struct i386_frame *) (pcb->pcb_esp - 4);
+ frame = (struct amd64_frame *) (pcb->pcb_esp - 8);
callpc = (db_addr_t)pcb->pcb_eip;
}
db_trace_one_stack(count, have_addr, p, frame, callpc);
@@ -392,14 +392,14 @@
static void
db_trace_one_stack(int count, boolean_t have_addr,
- struct proc *p, struct i386_frame *frame, db_addr_t callpc)
+ struct proc *p, struct amd64_frame *frame, db_addr_t callpc)
{
int *argp;
boolean_t first;
first = TRUE;
while (count--) {
- struct i386_frame *actframe;
+ struct amd64_frame *actframe;
int narg;
const char * name;
db_expr_t offset;
@@ -429,24 +429,24 @@
instr = db_get_value(callpc, 4, FALSE);
if ((instr & 0x00ffffff) == 0x00e58955) {
/* pushl %ebp; movl %esp, %ebp */
- actframe = (struct i386_frame *)
- (ddb_regs.tf_esp - 4);
+ actframe = (struct amd64_frame *)
+ (ddb_regs.tf_rsp - 8);
} else if ((instr & 0x0000ffff) == 0x0000e589) {
/* movl %esp, %ebp */
- actframe = (struct i386_frame *)
- ddb_regs.tf_esp;
- if (ddb_regs.tf_ebp == 0) {
+ actframe = (struct amd64_frame *)
+ ddb_regs.tf_rsp;
+ if (ddb_regs.tf_rbp == 0) {
/* Fake caller's frame better. */
frame = actframe;
}
} else if ((instr & 0x000000ff) == 0x000000c3) {
/* ret */
- actframe = (struct i386_frame *)
- (ddb_regs.tf_esp - 4);
+ actframe = (struct amd64_frame *)
+ (ddb_regs.tf_rsp - 8);
} else if (offset == 0) {
/* Probably a symbol in assembler code. */
- actframe = (struct i386_frame *)
- (ddb_regs.tf_esp - 4);
+ actframe = (struct amd64_frame *)
+ (ddb_regs.tf_rsp - 8);
}
} else if (strcmp(name, "fork_trampoline") == 0) {
/*
@@ -523,7 +523,7 @@
DB_DRX_FUNC(dr7)
int
-i386_set_watch(watchnum, watchaddr, size, access, d)
+amd64_set_watch(watchnum, watchaddr, size, access, d)
int watchnum;
unsigned int watchaddr;
int size;
@@ -579,7 +579,7 @@
int
-i386_clr_watch(watchnum, d)
+amd64_clr_watch(watchnum, d)
int watchnum;
struct dbreg * d;
{
@@ -622,7 +622,7 @@
wsize = size;
if (wsize == 3)
wsize++;
- i386_set_watch(i, addr, wsize,
+ amd64_set_watch(i, addr, wsize,
DBREG_DR7_WRONLY, &d);
addr += wsize;
size -= wsize;
@@ -649,7 +649,7 @@
if (d.dr[7] & (3 << (i*2))) {
if ((DBREG_DRX((&d), i) >= addr) &&
(DBREG_DRX((&d), i) < addr+size))
- i386_clr_watch(i, &d);
+ amd64_clr_watch(i, &d);
}
}
==== //depot/projects/hammer/sys/amd64/include/db_machdep.h#6 (text+ko) ====
@@ -33,12 +33,12 @@
#include <machine/psl.h>
#include <machine/trap.h>
-#define i386_saved_state trapframe
+#define amd64_saved_state trapframe
typedef vm_offset_t db_addr_t; /* address - unsigned */
typedef long db_expr_t; /* expression - signed */
-typedef struct i386_saved_state db_regs_t;
+typedef struct amd64_saved_state db_regs_t;
extern db_regs_t ddb_regs; /* register state */
#define DDB_REGS (&ddb_regs)
@@ -48,12 +48,12 @@
#define BKPT_SIZE (1) /* size of breakpoint inst */
#define BKPT_SET(inst) (BKPT_INST)
-#define BKPT_SKIP ddb_regs.tf_eip += 1
+#define BKPT_SKIP ddb_regs.tf_rip += 1
-#define FIXUP_PC_AFTER_BREAK ddb_regs.tf_eip -= 1;
+#define FIXUP_PC_AFTER_BREAK ddb_regs.tf_rip -= 1;
-#define db_clear_single_step(regs) ((regs)->tf_eflags &= ~PSL_T)
-#define db_set_single_step(regs) ((regs)->tf_eflags |= PSL_T)
+#define db_clear_single_step(regs) ((regs)->tf_rflags &= ~PSL_T)
+#define db_set_single_step(regs) ((regs)->tf_rflags |= PSL_T)
#define IS_BREAKPOINT_TRAP(type, code) ((type) == T_BPTFLT)
/*
More information about the p4-projects
mailing list