PERFORCE change 32063 for review

Peter Wemm peter at FreeBSD.org
Thu May 29 15:35:42 PDT 2003


http://perforce.freebsd.org/chv.cgi?CH=32063

Change 32063 by peter at peter_hammer on 2003/05/29 15:35:17

	Make this compile.  No way is it usable yet, especially since there
	is no setjmp/longjmp yet.  The stack trace stuff needs to be updated
	too, even with -fno-omit-frame-pointer, because it has the 32 bit
	prologue instructions compiled in.  And so on.

Affected files ...

.. //depot/projects/hammer/sys/amd64/amd64/db_interface.c#4 edit
.. //depot/projects/hammer/sys/amd64/amd64/db_trace.c#3 edit

Differences ...

==== //depot/projects/hammer/sys/amd64/amd64/db_interface.c#4 (text+ko) ====

@@ -74,7 +74,7 @@
 int
 kdb_trap(int type, int code, struct amd64_saved_state *regs)
 {
-	u_int ef;
+	u_long ef;
 	volatile int ddb_mode = !(boothowto & RB_GDB);
 
 	/*
@@ -94,7 +94,7 @@
 	    return (0);
 	}
 
-	ef = read_eflags();
+	ef = read_rflags();
 	disable_intr();
 
 	switch (type) {
@@ -172,12 +172,16 @@
 	regs->tf_rbp    = ddb_regs.tf_rbp;
 	regs->tf_rsi    = ddb_regs.tf_rsi;
 	regs->tf_rdi    = ddb_regs.tf_rdi;
+#if 0
 	regs->tf_es     = ddb_regs.tf_es & 0xffff;
 	regs->tf_fs     = ddb_regs.tf_fs & 0xffff;
+#endif
 	regs->tf_cs     = ddb_regs.tf_cs & 0xffff;
+#if 0
 	regs->tf_ds     = ddb_regs.tf_ds & 0xffff;
+#endif
 
-	write_eflags(ef);
+	write_rflags(ef);
 
 	return (1);
 }
@@ -231,8 +235,8 @@
 		    *ptep1 |= PG_RW;
 	    	}
 	    } else {
-		addr1 = trunc_4mpage(addr + size - 1);
-		if (trunc_4mpage(addr) != addr1) {
+		addr1 = trunc_2mpage(addr + size - 1);
+		if (trunc_2mpage(addr) != addr1) {
 		    ptep1 = pmap_pte_quick(kernel_pmap, addr1);
 		    oldmap1 = *ptep1;
 		    *ptep1 |= PG_RW;
@@ -289,5 +293,7 @@
 db_show_mdpcpu(struct pcpu *pc)
 {
 
+#if 0
 	db_printf("currentldt   = 0x%x\n", pc->pc_currentldt);
+#endif
 }

==== //depot/projects/hammer/sys/amd64/amd64/db_trace.c#3 (text+ko) ====

@@ -45,6 +45,7 @@
 #include <ddb/db_sym.h>
 #include <ddb/db_variables.h>
 
+#if 0
 db_varfcn_t db_dr0;
 db_varfcn_t db_dr1;
 db_varfcn_t db_dr2;
@@ -53,29 +54,31 @@
 db_varfcn_t db_dr5;
 db_varfcn_t db_dr6;
 db_varfcn_t db_dr7;
+#endif
 
 /*
  * Machine register set.
  */
 struct db_variable db_regs[] = {
 	{ "cs",		&ddb_regs.tf_cs,     FCN_NULL },
+#if 0
 	{ "ds",		&ddb_regs.tf_ds,     FCN_NULL },
 	{ "es",		&ddb_regs.tf_es,     FCN_NULL },
 	{ "fs",		&ddb_regs.tf_fs,     FCN_NULL },
-#if 0
 	{ "gs",		&ddb_regs.tf_gs,     FCN_NULL },
 #endif
 	{ "ss",		&ddb_regs.tf_ss,     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 },
+	{ "rax",	&ddb_regs.tf_rax,    FCN_NULL },
+	{ "rcx",	&ddb_regs.tf_rcx,    FCN_NULL },
+	{ "rdx",	&ddb_regs.tf_rdx,    FCN_NULL },
+	{ "rbx",	&ddb_regs.tf_rbx,    FCN_NULL },
+	{ "rsp",	&ddb_regs.tf_rsp,    FCN_NULL },
+	{ "rbp",	&ddb_regs.tf_rbp,    FCN_NULL },
+	{ "rsi",	&ddb_regs.tf_rsi,    FCN_NULL },
+	{ "rdi",	&ddb_regs.tf_rdi,    FCN_NULL },
+	{ "rip",	&ddb_regs.tf_rip,    FCN_NULL },
+	{ "rfl",	&ddb_regs.tf_rflags, FCN_NULL },
+#if 0
 	{ "dr0",	NULL,		     db_dr0 },
 	{ "dr1",	NULL,		     db_dr1 },
 	{ "dr2",	NULL,		     db_dr2 },
@@ -84,6 +87,7 @@
 	{ "dr5",	NULL,		     db_dr5 },
 	{ "dr6",	NULL,		     db_dr6 },
 	{ "dr7",	NULL,		     db_dr7 },
+#endif
 };
 struct db_variable *db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]);
 
@@ -95,7 +99,7 @@
 struct amd64_frame {
 	struct amd64_frame	*f_frame;
 	int			f_retaddr;
-	int			f_arg0;
+	long			f_arg0;
 };
 
 #define NORMAL		0
@@ -105,12 +109,13 @@
 
 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 db_print_stack_entry(const char *, int, char **, long *, 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 amd64_frame *frame, db_addr_t callpc);
 
 
+#if 0
 static char * watchtype_str(int type);
 int  amd64_set_watch(int watchnum, unsigned int watchaddr, int size, int access,
 		    struct dbreg * d);
@@ -118,6 +123,7 @@
 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);
+#endif
 
 
 /*
@@ -127,20 +133,20 @@
 db_numargs(fp)
 	struct amd64_frame *fp;
 {
-	int	*argp;
+	long	*argp;
 	int	inst;
 	int	args;
 
-	argp = (int *)db_get_value((int)&fp->f_retaddr, 4, FALSE);
+	argp = (long *)db_get_value((long)&fp->f_retaddr, 4, FALSE);
 	/*
 	 * XXX etext is wrong for LKMs.  We should attempt to interpret
 	 * the instruction at the return address in all cases.  This
 	 * may require better fault handling.
 	 */
-	if (argp < (int *)btext || argp >= (int *)etext) {
+	if (argp < (long *)btext || argp >= (long *)etext) {
 		args = 5;
 	} else {
-		inst = db_get_value((int)argp, 4, FALSE);
+		inst = db_get_value((long)argp, 4, FALSE);
 		if ((inst & 0xff) == 0x59)	/* popl %ecx */
 			args = 1;
 		else if ((inst & 0xffff) == 0xc483)	/* addl $Ibs, %esp */
@@ -156,14 +162,14 @@
 	const char *name;
 	int narg;
 	char **argnp;
-	int *argp;
+	long *argp;
 	db_addr_t callpc;
 {
 	db_printf("%s(", name);
 	while (narg) {
 		if (argnp)
 			db_printf("%s=", *argnp++);
-		db_printf("%r", db_get_value((int)argp, 4, FALSE));
+		db_printf("%lr", (long)db_get_value((long)argp, 4, FALSE));
 		argp++;
 		if (--narg != 0)
 			db_printf(",");
@@ -206,19 +212,19 @@
 {
 	struct trapframe *tf;
 	int frame_type;
-	int eip, esp, ebp;
+	long rip, rsp, rbp;
 	db_expr_t offset;
 	c_db_sym_t sym;
 	const char *name;
 
-	eip = db_get_value((int) &(*fp)->f_retaddr, 4, FALSE);
-	ebp = db_get_value((int) &(*fp)->f_frame, 4, FALSE);
+	rip = db_get_value((long) &(*fp)->f_retaddr, 4, FALSE);
+	rbp = db_get_value((long) &(*fp)->f_frame, 4, FALSE);
 
 	/*
 	 * Figure out frame type.
 	 */
 	frame_type = NORMAL;
-	sym = db_search_symbol(eip, DB_STGY_ANY, &offset);
+	sym = db_search_symbol(rip, DB_STGY_ANY, &offset);
 	db_symbol_values(sym, &name, NULL);
 	if (name != NULL) {
 		if (strcmp(name, "calltrap") == 0 ||
@@ -236,30 +242,30 @@
 	 * Normal frames need no special processing.
 	 */
 	if (frame_type == NORMAL) {
-		*ip = (db_addr_t) eip;
-		*fp = (struct amd64_frame *) ebp;
+		*ip = (db_addr_t) rip;
+		*fp = (struct amd64_frame *) rbp;
 		return;
 	}
 
-	db_print_stack_entry(name, 0, 0, 0, eip);
+	db_print_stack_entry(name, 0, 0, 0, rip);
 
 	/*
 	 * Point to base of trapframe which is just above the
 	 * current frame.
 	 */
 	if (frame_type == INTERRUPT)
-		tf = (struct trapframe *)((int)*fp + 12);
+		tf = (struct trapframe *)((long)*fp + 12);
 	else
-		tf = (struct trapframe *)((int)*fp + 8);
+		tf = (struct trapframe *)((long)*fp + 8);
 
-	if (INKERNEL((int) tf)) {
-		esp = (ISPL(tf->tf_cs) == SEL_UPL) ?
-		    tf->tf_rsp : (int)&tf->tf_rsp;
-		eip = tf->tf_rip;
-		ebp = tf->tf_rbp;
+	if (INKERNEL((long) tf)) {
+		rsp = (ISPL(tf->tf_cs) == SEL_UPL) ?
+		    tf->tf_rsp : (long)&tf->tf_rsp;
+		rip = tf->tf_rip;
+		rbp = tf->tf_rbp;
 		switch (frame_type) {
 		case TRAP:
-			db_printf("--- trap %#r", tf->tf_trapno);
+			db_printf("--- trap %#lr", tf->tf_trapno);
 			break;
 		case SYSCALL:
 			db_printf("--- syscall");
@@ -271,12 +277,12 @@
 		default:
 			panic("The moon has moved again.");
 		}
-		db_printf(", eip = %#r, esp = %#r, ebp = %#r ---\n", eip,
-		    esp, ebp);
+		db_printf(", rip = %#lr, rsp = %#lr, rbp = %#lr ---\n", rip,
+		    rsp, rbp);
 	}
 
-	*ip = (db_addr_t) eip;
-	*fp = (struct amd64_frame *) ebp;
+	*ip = (db_addr_t) rip;
+	*fp = (struct amd64_frame *) rbp;
 }
 
 void
@@ -336,16 +342,16 @@
 				return;
 			}
 			pcb = FIRST_THREAD_IN_PROC(p)->td_pcb;	/* XXXKSE */
-			frame = (struct amd64_frame *)pcb->pcb_ebp;
+			frame = (struct amd64_frame *)pcb->pcb_rbp;
 			if (frame == NULL)
 				frame = (struct amd64_frame *)
-				    (pcb->pcb_esp - 8);
-			callpc = (db_addr_t)pcb->pcb_eip;
+				    (pcb->pcb_rsp - 8);
+			callpc = (db_addr_t)pcb->pcb_rip;
 		}
 	} else {
 		p = NULL;
 		frame = (struct amd64_frame *)addr;
-		callpc = (db_addr_t)db_get_value((int)&frame->f_retaddr, 4, FALSE);
+		callpc = (db_addr_t)db_get_value((long)&frame->f_retaddr, 4, FALSE);
 		frame = frame->f_frame;
 	}
 	db_trace_one_stack(count, have_addr, p, frame, callpc);
@@ -382,10 +388,10 @@
 		callpc = (db_addr_t)ddb_regs.tf_rip;
 	} else {
 		pcb = td->td_pcb;
-		frame = (struct amd64_frame *)pcb->pcb_ebp;
+		frame = (struct amd64_frame *)pcb->pcb_rbp;
 		if (frame == NULL)
-			frame = (struct amd64_frame *) (pcb->pcb_esp - 8);
-		callpc = (db_addr_t)pcb->pcb_eip;
+			frame = (struct amd64_frame *) (pcb->pcb_rsp - 8);
+		callpc = (db_addr_t)pcb->pcb_rip;
 	}
 	db_trace_one_stack(count, have_addr, p, frame, callpc);
 }
@@ -394,7 +400,7 @@
 db_trace_one_stack(int count, boolean_t have_addr,
 		struct proc *p, struct amd64_frame *frame, db_addr_t callpc)
 {
-	int *argp;
+	long *argp;
 	boolean_t first;
 
 	first = TRUE;
@@ -472,19 +478,19 @@
 		if (actframe != frame) {
 			/* `frame' belongs to caller. */
 			callpc = (db_addr_t)
-			    db_get_value((int)&actframe->f_retaddr, 4, FALSE);
+			    db_get_value((long)&actframe->f_retaddr, 4, FALSE);
 			continue;
 		}
 
 		db_nextframe(&frame, &callpc, p);
 
-		if (INKERNEL((int) callpc) && !INKERNEL((int) frame)) {
+		if (INKERNEL((long) callpc) && !INKERNEL((long) frame)) {
 			sym = db_search_symbol(callpc, DB_STGY_ANY, &offset);
 			db_symbol_values(sym, &name, NULL);
 			db_print_stack_entry(name, 0, 0, 0, callpc);
 			break;
 		}
-		if (!INKERNEL((int) frame)) {
+		if (!INKERNEL((long) frame)) {
 			break;
 		}
 	}
@@ -495,10 +501,11 @@
 {
 	register_t ebp;
 
-	__asm __volatile("movl %%ebp,%0" : "=r" (ebp));
+	__asm __volatile("movq %%rbp,%0" : "=r" (ebp));
 	db_stack_trace_cmd(ebp, 1, -1, NULL);
 }
 
+#if 0
 #define DB_DRX_FUNC(reg)		\
 int					\
 db_ ## reg (vp, valuep, op)		\
@@ -706,4 +713,4 @@
 	db_printf("\n");
 }
 
-
+#endif


More information about the p4-projects mailing list