Date: Sun, 13 Jun 2004 21:35:48 GMT From: Marcel Moolenaar <marcel@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 54862 for review Message-ID: <200406132135.i5DLZmGa066968@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=54862 Change 54862 by marcel@marcel_nfs on 2004/06/13 21:34:57 Flip ia64 over from working on the trapframe to working on the PCB. A new function, called unw_create_from_pcb, has been added to start a backtrace given a PCB. The previous unw_create has been renamed to unw_create_from_frame. unw_create_from_pcb is not entirely correct yet, but I wanted to get this submitted first. Affected files ... .. //depot/projects/gdb/sys/ia64/ia64/db_interface.c#8 edit .. //depot/projects/gdb/sys/ia64/ia64/db_trace.c#3 edit .. //depot/projects/gdb/sys/ia64/ia64/dump_machdep.c#3 edit .. //depot/projects/gdb/sys/ia64/ia64/interrupt.c#5 edit .. //depot/projects/gdb/sys/ia64/ia64/trap.c#10 edit .. //depot/projects/gdb/sys/ia64/ia64/unwind.c#4 edit .. //depot/projects/gdb/sys/ia64/include/db_machdep.h#4 edit .. //depot/projects/gdb/sys/ia64/include/kdb.h#4 edit .. //depot/projects/gdb/sys/ia64/include/unwind.h#2 edit Differences ... ==== //depot/projects/gdb/sys/ia64/ia64/db_interface.c#8 (text+ko) ==== @@ -45,6 +45,7 @@ #include <vm/vm.h> #include <machine/db_machdep.h> +#include <machine/frame.h> #include <machine/mutex.h> #include <machine/setjmp.h> @@ -62,196 +63,217 @@ #define SLOT_MASK ((1ULL << SLOT_BITS) - 1ULL) #define SLOT_SHIFT(i) (TMPL_BITS+((i)<<3)+(i)) -static int db_get_rse_reg(struct db_variable *vp, db_expr_t *valuep, int op); -static int db_get_ip_reg(struct db_variable *vp, db_expr_t *valuep, int op); +static db_varfcn_t db_frame; +static db_varfcn_t db_getrse; +static db_varfcn_t db_getip; +#define DB_OFFSET(x) (db_expr_t *)offsetof(struct trapframe, x) struct db_variable db_regs[] = { - /* Misc control/app registers */ -#define DB_MISC_REGS 13 /* make sure this is correct */ + {"ip", NULL, db_getip}, + {"cr.ifs", DB_OFFSET(tf_special.cfm), db_frame}, + {"cr.ifa", DB_OFFSET(tf_special.ifa), db_frame}, + {"ar.bspstore", DB_OFFSET(tf_special.bspstore), db_frame}, + {"ndirty", DB_OFFSET(tf_special.ndirty), db_frame}, + {"rp", DB_OFFSET(tf_special.rp), db_frame}, + {"ar.pfs", DB_OFFSET(tf_special.pfs), db_frame}, + {"psr", DB_OFFSET(tf_special.psr), db_frame}, + {"cr.isr", DB_OFFSET(tf_special.isr), db_frame}, + {"pr", DB_OFFSET(tf_special.pr), db_frame}, + {"ar.rsc", DB_OFFSET(tf_special.rsc), db_frame}, + {"ar.rnat", DB_OFFSET(tf_special.rnat), db_frame}, + {"ar.unat", DB_OFFSET(tf_special.unat), db_frame}, + {"ar.fpsr", DB_OFFSET(tf_special.fpsr), db_frame}, + {"gp", DB_OFFSET(tf_special.gp), db_frame}, + {"sp", DB_OFFSET(tf_special.sp), db_frame}, + {"tp", DB_OFFSET(tf_special.tp), db_frame}, + {"b6", DB_OFFSET(tf_scratch.br6), db_frame}, + {"b7", DB_OFFSET(tf_scratch.br7), db_frame}, + {"r2", DB_OFFSET(tf_scratch.gr2), db_frame}, + {"r3", DB_OFFSET(tf_scratch.gr3), db_frame}, + {"r8", DB_OFFSET(tf_scratch.gr8), db_frame}, + {"r9", DB_OFFSET(tf_scratch.gr9), db_frame}, + {"r10", DB_OFFSET(tf_scratch.gr10), db_frame}, + {"r11", DB_OFFSET(tf_scratch.gr11), db_frame}, + {"r14", DB_OFFSET(tf_scratch.gr14), db_frame}, + {"r15", DB_OFFSET(tf_scratch.gr15), db_frame}, + {"r16", DB_OFFSET(tf_scratch.gr16), db_frame}, + {"r17", DB_OFFSET(tf_scratch.gr17), db_frame}, + {"r18", DB_OFFSET(tf_scratch.gr18), db_frame}, + {"r19", DB_OFFSET(tf_scratch.gr19), db_frame}, + {"r20", DB_OFFSET(tf_scratch.gr20), db_frame}, + {"r21", DB_OFFSET(tf_scratch.gr21), db_frame}, + {"r22", DB_OFFSET(tf_scratch.gr22), db_frame}, + {"r23", DB_OFFSET(tf_scratch.gr23), db_frame}, + {"r24", DB_OFFSET(tf_scratch.gr24), db_frame}, + {"r25", DB_OFFSET(tf_scratch.gr25), db_frame}, + {"r26", DB_OFFSET(tf_scratch.gr26), db_frame}, + {"r27", DB_OFFSET(tf_scratch.gr27), db_frame}, + {"r28", DB_OFFSET(tf_scratch.gr28), db_frame}, + {"r29", DB_OFFSET(tf_scratch.gr29), db_frame}, + {"r30", DB_OFFSET(tf_scratch.gr30), db_frame}, + {"r31", DB_OFFSET(tf_scratch.gr31), db_frame}, + {"r32", (db_expr_t*)0, db_getrse}, + {"r33", (db_expr_t*)1, db_getrse}, + {"r34", (db_expr_t*)2, db_getrse}, + {"r35", (db_expr_t*)3, db_getrse}, + {"r36", (db_expr_t*)4, db_getrse}, + {"r37", (db_expr_t*)5, db_getrse}, + {"r38", (db_expr_t*)6, db_getrse}, + {"r39", (db_expr_t*)7, db_getrse}, + {"r40", (db_expr_t*)8, db_getrse}, + {"r41", (db_expr_t*)9, db_getrse}, + {"r42", (db_expr_t*)10, db_getrse}, + {"r43", (db_expr_t*)11, db_getrse}, + {"r44", (db_expr_t*)12, db_getrse}, + {"r45", (db_expr_t*)13, db_getrse}, + {"r46", (db_expr_t*)14, db_getrse}, + {"r47", (db_expr_t*)15, db_getrse}, + {"r48", (db_expr_t*)16, db_getrse}, + {"r49", (db_expr_t*)17, db_getrse}, + {"r50", (db_expr_t*)18, db_getrse}, + {"r51", (db_expr_t*)19, db_getrse}, + {"r52", (db_expr_t*)20, db_getrse}, + {"r53", (db_expr_t*)21, db_getrse}, + {"r54", (db_expr_t*)22, db_getrse}, + {"r55", (db_expr_t*)23, db_getrse}, + {"r56", (db_expr_t*)24, db_getrse}, + {"r57", (db_expr_t*)25, db_getrse}, + {"r58", (db_expr_t*)26, db_getrse}, + {"r59", (db_expr_t*)27, db_getrse}, + {"r60", (db_expr_t*)28, db_getrse}, + {"r61", (db_expr_t*)29, db_getrse}, + {"r62", (db_expr_t*)30, db_getrse}, + {"r63", (db_expr_t*)31, db_getrse}, + {"r64", (db_expr_t*)32, db_getrse}, + {"r65", (db_expr_t*)33, db_getrse}, + {"r66", (db_expr_t*)34, db_getrse}, + {"r67", (db_expr_t*)35, db_getrse}, + {"r68", (db_expr_t*)36, db_getrse}, + {"r69", (db_expr_t*)37, db_getrse}, + {"r70", (db_expr_t*)38, db_getrse}, + {"r71", (db_expr_t*)39, db_getrse}, + {"r72", (db_expr_t*)40, db_getrse}, + {"r73", (db_expr_t*)41, db_getrse}, + {"r74", (db_expr_t*)42, db_getrse}, + {"r75", (db_expr_t*)43, db_getrse}, + {"r76", (db_expr_t*)44, db_getrse}, + {"r77", (db_expr_t*)45, db_getrse}, + {"r78", (db_expr_t*)46, db_getrse}, + {"r79", (db_expr_t*)47, db_getrse}, + {"r80", (db_expr_t*)48, db_getrse}, + {"r81", (db_expr_t*)49, db_getrse}, + {"r82", (db_expr_t*)50, db_getrse}, + {"r83", (db_expr_t*)51, db_getrse}, + {"r84", (db_expr_t*)52, db_getrse}, + {"r85", (db_expr_t*)53, db_getrse}, + {"r86", (db_expr_t*)54, db_getrse}, + {"r87", (db_expr_t*)55, db_getrse}, + {"r88", (db_expr_t*)56, db_getrse}, + {"r89", (db_expr_t*)57, db_getrse}, + {"r90", (db_expr_t*)58, db_getrse}, + {"r91", (db_expr_t*)59, db_getrse}, + {"r92", (db_expr_t*)60, db_getrse}, + {"r93", (db_expr_t*)61, db_getrse}, + {"r94", (db_expr_t*)62, db_getrse}, + {"r95", (db_expr_t*)63, db_getrse}, + {"r96", (db_expr_t*)64, db_getrse}, + {"r97", (db_expr_t*)65, db_getrse}, + {"r98", (db_expr_t*)66, db_getrse}, + {"r99", (db_expr_t*)67, db_getrse}, + {"r100", (db_expr_t*)68, db_getrse}, + {"r101", (db_expr_t*)69, db_getrse}, + {"r102", (db_expr_t*)70, db_getrse}, + {"r103", (db_expr_t*)71, db_getrse}, + {"r104", (db_expr_t*)72, db_getrse}, + {"r105", (db_expr_t*)73, db_getrse}, + {"r106", (db_expr_t*)74, db_getrse}, + {"r107", (db_expr_t*)75, db_getrse}, + {"r108", (db_expr_t*)76, db_getrse}, + {"r109", (db_expr_t*)77, db_getrse}, + {"r110", (db_expr_t*)78, db_getrse}, + {"r111", (db_expr_t*)79, db_getrse}, + {"r112", (db_expr_t*)80, db_getrse}, + {"r113", (db_expr_t*)81, db_getrse}, + {"r114", (db_expr_t*)82, db_getrse}, + {"r115", (db_expr_t*)83, db_getrse}, + {"r116", (db_expr_t*)84, db_getrse}, + {"r117", (db_expr_t*)85, db_getrse}, + {"r118", (db_expr_t*)86, db_getrse}, + {"r119", (db_expr_t*)87, db_getrse}, + {"r120", (db_expr_t*)88, db_getrse}, + {"r121", (db_expr_t*)89, db_getrse}, + {"r122", (db_expr_t*)90, db_getrse}, + {"r123", (db_expr_t*)91, db_getrse}, + {"r124", (db_expr_t*)92, db_getrse}, + {"r125", (db_expr_t*)93, db_getrse}, + {"r126", (db_expr_t*)94, db_getrse}, + {"r127", (db_expr_t*)95, db_getrse}, +}; +struct db_variable *db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]); - {"ip", NULL, db_get_ip_reg}, - {"psr", (db_expr_t*) &ddb_regs.tf_special.psr, FCN_NULL}, - {"cr.isr", (db_expr_t*) &ddb_regs.tf_special.isr, FCN_NULL}, - {"cr.ifa", (db_expr_t*) &ddb_regs.tf_special.ifa, FCN_NULL}, - {"pr", (db_expr_t*) &ddb_regs.tf_special.pr, FCN_NULL}, - {"ar.rsc", (db_expr_t*) &ddb_regs.tf_special.rsc, FCN_NULL}, - {"ar.pfs", (db_expr_t*) &ddb_regs.tf_special.pfs, FCN_NULL}, - {"cr.ifs", (db_expr_t*) &ddb_regs.tf_special.cfm, FCN_NULL}, - {"ar.bspstore", (db_expr_t*) &ddb_regs.tf_special.bspstore, FCN_NULL}, - {"ndirty", (db_expr_t*) &ddb_regs.tf_special.ndirty, FCN_NULL}, - {"ar.rnat", (db_expr_t*) &ddb_regs.tf_special.rnat, FCN_NULL}, - {"ar.unat", (db_expr_t*) &ddb_regs.tf_special.unat, FCN_NULL}, - {"ar.fpsr", (db_expr_t*) &ddb_regs.tf_special.fpsr, FCN_NULL}, +static int +db_frame(struct db_variable *vp, db_expr_t *valuep, int op) +{ + uint64_t *reg; - /* Branch registers */ - {"rp", (db_expr_t*) &ddb_regs.tf_special.rp, FCN_NULL}, - /* b1, b2, b3, b4, b5 are preserved */ - {"b6", (db_expr_t*) &ddb_regs.tf_scratch.br6, FCN_NULL}, - {"b7", (db_expr_t*) &ddb_regs.tf_scratch.br7, FCN_NULL}, - - /* Static registers */ - {"gp", (db_expr_t*) &ddb_regs.tf_special.gp, FCN_NULL}, - {"r2", (db_expr_t*) &ddb_regs.tf_scratch.gr2, FCN_NULL}, - {"r3", (db_expr_t*) &ddb_regs.tf_scratch.gr3, FCN_NULL}, - {"r8", (db_expr_t*) &ddb_regs.tf_scratch.gr8, FCN_NULL}, - {"r9", (db_expr_t*) &ddb_regs.tf_scratch.gr9, FCN_NULL}, - {"r10", (db_expr_t*) &ddb_regs.tf_scratch.gr10, FCN_NULL}, - {"r11", (db_expr_t*) &ddb_regs.tf_scratch.gr11, FCN_NULL}, - {"sp", (db_expr_t*) &ddb_regs.tf_special.sp, FCN_NULL}, - {"tp", (db_expr_t*) &ddb_regs.tf_special.tp, FCN_NULL}, - {"r14", (db_expr_t*) &ddb_regs.tf_scratch.gr14, FCN_NULL}, - {"r15", (db_expr_t*) &ddb_regs.tf_scratch.gr15, FCN_NULL}, - {"r16", (db_expr_t*) &ddb_regs.tf_scratch.gr16, FCN_NULL}, - {"r17", (db_expr_t*) &ddb_regs.tf_scratch.gr17, FCN_NULL}, - {"r18", (db_expr_t*) &ddb_regs.tf_scratch.gr18, FCN_NULL}, - {"r19", (db_expr_t*) &ddb_regs.tf_scratch.gr19, FCN_NULL}, - {"r20", (db_expr_t*) &ddb_regs.tf_scratch.gr20, FCN_NULL}, - {"r21", (db_expr_t*) &ddb_regs.tf_scratch.gr21, FCN_NULL}, - {"r22", (db_expr_t*) &ddb_regs.tf_scratch.gr22, FCN_NULL}, - {"r23", (db_expr_t*) &ddb_regs.tf_scratch.gr23, FCN_NULL}, - {"r24", (db_expr_t*) &ddb_regs.tf_scratch.gr24, FCN_NULL}, - {"r25", (db_expr_t*) &ddb_regs.tf_scratch.gr25, FCN_NULL}, - {"r26", (db_expr_t*) &ddb_regs.tf_scratch.gr26, FCN_NULL}, - {"r27", (db_expr_t*) &ddb_regs.tf_scratch.gr27, FCN_NULL}, - {"r28", (db_expr_t*) &ddb_regs.tf_scratch.gr28, FCN_NULL}, - {"r29", (db_expr_t*) &ddb_regs.tf_scratch.gr29, FCN_NULL}, - {"r30", (db_expr_t*) &ddb_regs.tf_scratch.gr30, FCN_NULL}, - {"r31", (db_expr_t*) &ddb_regs.tf_scratch.gr31, FCN_NULL}, - - /* Stacked registers */ - {"r32", (db_expr_t*) 32, db_get_rse_reg}, - {"r33", (db_expr_t*) 33, db_get_rse_reg}, - {"r34", (db_expr_t*) 34, db_get_rse_reg}, - {"r35", (db_expr_t*) 35, db_get_rse_reg}, - {"r36", (db_expr_t*) 36, db_get_rse_reg}, - {"r37", (db_expr_t*) 37, db_get_rse_reg}, - {"r38", (db_expr_t*) 38, db_get_rse_reg}, - {"r39", (db_expr_t*) 39, db_get_rse_reg}, - {"r40", (db_expr_t*) 40, db_get_rse_reg}, - {"r41", (db_expr_t*) 41, db_get_rse_reg}, - {"r42", (db_expr_t*) 42, db_get_rse_reg}, - {"r43", (db_expr_t*) 43, db_get_rse_reg}, - {"r44", (db_expr_t*) 44, db_get_rse_reg}, - {"r45", (db_expr_t*) 45, db_get_rse_reg}, - {"r46", (db_expr_t*) 46, db_get_rse_reg}, - {"r47", (db_expr_t*) 47, db_get_rse_reg}, - {"r48", (db_expr_t*) 48, db_get_rse_reg}, - {"r49", (db_expr_t*) 49, db_get_rse_reg}, - {"r50", (db_expr_t*) 50, db_get_rse_reg}, - {"r51", (db_expr_t*) 51, db_get_rse_reg}, - {"r52", (db_expr_t*) 52, db_get_rse_reg}, - {"r53", (db_expr_t*) 53, db_get_rse_reg}, - {"r54", (db_expr_t*) 54, db_get_rse_reg}, - {"r55", (db_expr_t*) 55, db_get_rse_reg}, - {"r56", (db_expr_t*) 56, db_get_rse_reg}, - {"r57", (db_expr_t*) 57, db_get_rse_reg}, - {"r58", (db_expr_t*) 58, db_get_rse_reg}, - {"r59", (db_expr_t*) 59, db_get_rse_reg}, - {"r60", (db_expr_t*) 60, db_get_rse_reg}, - {"r61", (db_expr_t*) 61, db_get_rse_reg}, - {"r62", (db_expr_t*) 62, db_get_rse_reg}, - {"r63", (db_expr_t*) 63, db_get_rse_reg}, - {"r64", (db_expr_t*) 64, db_get_rse_reg}, - {"r65", (db_expr_t*) 65, db_get_rse_reg}, - {"r66", (db_expr_t*) 66, db_get_rse_reg}, - {"r67", (db_expr_t*) 67, db_get_rse_reg}, - {"r68", (db_expr_t*) 68, db_get_rse_reg}, - {"r69", (db_expr_t*) 69, db_get_rse_reg}, - {"r70", (db_expr_t*) 70, db_get_rse_reg}, - {"r71", (db_expr_t*) 71, db_get_rse_reg}, - {"r72", (db_expr_t*) 72, db_get_rse_reg}, - {"r73", (db_expr_t*) 73, db_get_rse_reg}, - {"r74", (db_expr_t*) 74, db_get_rse_reg}, - {"r75", (db_expr_t*) 75, db_get_rse_reg}, - {"r76", (db_expr_t*) 76, db_get_rse_reg}, - {"r77", (db_expr_t*) 77, db_get_rse_reg}, - {"r78", (db_expr_t*) 78, db_get_rse_reg}, - {"r79", (db_expr_t*) 79, db_get_rse_reg}, - {"r80", (db_expr_t*) 80, db_get_rse_reg}, - {"r81", (db_expr_t*) 81, db_get_rse_reg}, - {"r82", (db_expr_t*) 82, db_get_rse_reg}, - {"r83", (db_expr_t*) 83, db_get_rse_reg}, - {"r84", (db_expr_t*) 84, db_get_rse_reg}, - {"r85", (db_expr_t*) 85, db_get_rse_reg}, - {"r86", (db_expr_t*) 86, db_get_rse_reg}, - {"r87", (db_expr_t*) 87, db_get_rse_reg}, - {"r88", (db_expr_t*) 88, db_get_rse_reg}, - {"r89", (db_expr_t*) 89, db_get_rse_reg}, - {"r90", (db_expr_t*) 90, db_get_rse_reg}, - {"r91", (db_expr_t*) 91, db_get_rse_reg}, - {"r92", (db_expr_t*) 92, db_get_rse_reg}, - {"r93", (db_expr_t*) 93, db_get_rse_reg}, - {"r94", (db_expr_t*) 94, db_get_rse_reg}, - {"r95", (db_expr_t*) 95, db_get_rse_reg}, - {"r96", (db_expr_t*) 96, db_get_rse_reg}, - {"r97", (db_expr_t*) 97, db_get_rse_reg}, - {"r98", (db_expr_t*) 98, db_get_rse_reg}, - {"r99", (db_expr_t*) 99, db_get_rse_reg}, - {"r100", (db_expr_t*) 100, db_get_rse_reg}, - {"r101", (db_expr_t*) 101, db_get_rse_reg}, - {"r102", (db_expr_t*) 102, db_get_rse_reg}, - {"r103", (db_expr_t*) 103, db_get_rse_reg}, - {"r104", (db_expr_t*) 104, db_get_rse_reg}, - {"r105", (db_expr_t*) 105, db_get_rse_reg}, - {"r106", (db_expr_t*) 106, db_get_rse_reg}, - {"r107", (db_expr_t*) 107, db_get_rse_reg}, - {"r108", (db_expr_t*) 108, db_get_rse_reg}, - {"r109", (db_expr_t*) 109, db_get_rse_reg}, - {"r110", (db_expr_t*) 110, db_get_rse_reg}, - {"r111", (db_expr_t*) 111, db_get_rse_reg}, - {"r112", (db_expr_t*) 112, db_get_rse_reg}, - {"r113", (db_expr_t*) 113, db_get_rse_reg}, - {"r114", (db_expr_t*) 114, db_get_rse_reg}, - {"r115", (db_expr_t*) 115, db_get_rse_reg}, - {"r116", (db_expr_t*) 116, db_get_rse_reg}, - {"r117", (db_expr_t*) 117, db_get_rse_reg}, - {"r118", (db_expr_t*) 118, db_get_rse_reg}, - {"r119", (db_expr_t*) 119, db_get_rse_reg}, - {"r120", (db_expr_t*) 120, db_get_rse_reg}, - {"r121", (db_expr_t*) 121, db_get_rse_reg}, - {"r122", (db_expr_t*) 122, db_get_rse_reg}, - {"r123", (db_expr_t*) 123, db_get_rse_reg}, - {"r124", (db_expr_t*) 124, db_get_rse_reg}, - {"r125", (db_expr_t*) 125, db_get_rse_reg}, - {"r126", (db_expr_t*) 126, db_get_rse_reg}, - {"r127", (db_expr_t*) 127, db_get_rse_reg}, -}; -struct db_variable *db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]); + if (kdb_frame == NULL) + return (0); + reg = (uint64_t*)((uintptr_t)kdb_frame + (uintptr_t)vp->valuep); + if (op == DB_VAR_GET) + *valuep = *reg; + else + *reg = *valuep; + return (1); +} static int -db_get_rse_reg(struct db_variable *vp, db_expr_t *valuep, int op) +db_getrse(struct db_variable *vp, db_expr_t *valuep, int op) { u_int64_t *reg; uint64_t bsp; int nats, regno, sof; - bsp = ddb_regs.tf_special.bspstore + ddb_regs.tf_special.ndirty; - regno = (db_expr_t)vp->valuep - 32; - sof = (int)(ddb_regs.tf_special.cfm & 0x7f); - nats = (sof - regno + 63 - ((int)(bsp >> 3) & 0x3f)) / 63; + if (kdb_frame == NULL) + return (0); - reg = (void*)(bsp - ((sof - regno + nats) << 3)); + regno = (int)(intptr_t)valuep; + bsp = kdb_frame->tf_special.bspstore + kdb_frame->tf_special.ndirty; + sof = (int)(kdb_frame->tf_special.cfm & 0x7f); - if (regno < sof) { - if (op == DB_VAR_GET) - *valuep = *reg; - else - *reg = *valuep; - } else { - if (op == DB_VAR_GET) - *valuep = 0xdeadbeefdeadbeef; - } + if (regno >= sof) + return (0); - return (0); + nats = (sof - regno + 63 - ((int)(bsp >> 3) & 0x3f)) / 63; + reg = (void*)(bsp - ((sof - regno + nats) << 3)); + if (op == DB_VAR_GET) + *valuep = *reg; + else + *reg = *valuep; + return (1); } static int -db_get_ip_reg(struct db_variable *vp, db_expr_t *valuep, int op) +db_getip(struct db_variable *vp, db_expr_t *valuep, int op) { - /* Read only */ - if (op == DB_VAR_GET) - *valuep = PC_REGS(DDB_REGS); - return 0; + u_long iip, slot; + + if (kdb_frame == NULL) + return (0); + + if (op == DB_VAR_GET) { + iip = kdb_frame->tf_special.iip; + slot = (kdb_frame->tf_special.psr >> 41) & 3; + *valuep = iip + slot; + } else { + iip = *valuep & ~0xf; + slot = *valuep & 0xf; + if (slot > 2) + return (0); + kdb_frame->tf_special.iip = iip; + kdb_frame->tf_special.psr &= ~IA64_PSR_RI; + kdb_frame->tf_special.psr |= slot << 41; + } + return (1); } /* @@ -298,41 +320,6 @@ return (ret); } -u_long -db_register_value(db_regs_t *regs, int regno) -{ - uint64_t *rsp; - uint64_t bsp; - int nats, sof; - - if (regno == 0) - return (0); - if (regno == 1) - return (regs->tf_special.gp); - if (regno >= 2 && regno <= 3) - return ((®s->tf_scratch.gr2)[regno - 2]); - if (regno >= 8 && regno <= 11) - return ((®s->tf_scratch.gr8)[regno - 8]); - if (regno == 12) - return (regs->tf_special.sp); - if (regno == 13) - return (regs->tf_special.tp); - if (regno >= 14 && regno <= 31) - return ((®s->tf_scratch.gr14)[regno - 14]); - - sof = (int)(regs->tf_special.cfm & 0x7f); - if (regno >= 32 && regno < sof + 32) { - bsp = regs->tf_special.bspstore + regs->tf_special.ndirty; - regno -= 32; - nats = (sof - regno + 63 - ((int)(bsp >> 3) & 0x3f)) / 63; - rsp = (void*)(bsp - ((sof - regno + nats) << 3)); - return (*rsp); - } - - db_printf(" **** STRANGE REGISTER NUMBER %d **** ", regno); - return (0); -} - void db_bkpt_write(db_addr_t addr, BKPT_INST_TYPE *storage) { @@ -375,10 +362,13 @@ db_bkpt_skip(void) { - ddb_regs.tf_special.psr += IA64_PSR_RI_1; - if ((ddb_regs.tf_special.psr & IA64_PSR_RI) > IA64_PSR_RI_2) { - ddb_regs.tf_special.psr &= ~IA64_PSR_RI; - ddb_regs.tf_special.iip += 16; + if (kdb_frame == NULL) + return; + + kdb_frame->tf_special.psr += IA64_PSR_RI_1; + if ((kdb_frame->tf_special.psr & IA64_PSR_RI) > IA64_PSR_RI_2) { + kdb_frame->tf_special.psr &= ~IA64_PSR_RI; + kdb_frame->tf_special.iip += 16; } } ==== //depot/projects/gdb/sys/ia64/ia64/db_trace.c#3 (text+ko) ==== @@ -1,4 +1,5 @@ /*- + * Copyright (c) 2003, 2004 Marcel Moolenaar * Copyright (c) 2000-2001 Doug Rabson * All rights reserved. * @@ -31,6 +32,8 @@ #include <sys/proc.h> #include <machine/db_machdep.h> +#include <machine/frame.h> +#include <machine/pcb.h> #include <machine/unwind.h> #include <machine/vmparam.h> @@ -40,22 +43,22 @@ #include <ddb/db_variables.h> #include <ddb/db_output.h> - 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); static int -db_backtrace(struct thread *td, struct trapframe *tf, int count) +db_backtrace(struct thread *td, struct pcb *pcb, int count) { struct unw_regstate rs; + struct trapframe *tf; const char *name; db_expr_t offset; uint64_t bsp, cfm, ip, pfs, reg, sp; c_db_sym_t sym; int args, error, i; - error = unw_create(&rs, tf); + error = unw_create_from_pcb(&rs, pcb); while (!error && count--) { error = unw_get_cfm(&rs, &cfm); if (!error) @@ -114,7 +117,7 @@ /* XXX ask if we should unwind across the trapframe. */ db_printf("--- trapframe at %p\n", tf); unw_delete(&rs); - error = unw_create(&rs, tf); + error = unw_create_from_frame(&rs, tf); } unw_delete(&rs); @@ -132,21 +135,25 @@ db_printf("Thread %d not found\n", (int)addr); return; } - db_backtrace(td, td->td_last_frame, count); + db_trace_thread(td, count); } void db_trace_self(void) { + struct pcb pcb; - db_backtrace(curthread, NULL, -1); + savectx(&pcb); + db_backtrace(curthread, &pcb, -1); } int db_trace_thread(struct thread *td, int count) { + struct pcb *ctx; - return (db_backtrace(td, td->td_last_frame, count)); + ctx = kdb_thr_ctx(td); + return (db_backtrace(td, ctx, count)); } int ==== //depot/projects/gdb/sys/ia64/ia64/dump_machdep.c#3 (text+ko) ==== @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002-2004 Marcel Moolenaar + * Copyright (c) 2002 Marcel Moolenaar * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,8 +32,6 @@ #include <sys/cons.h> #include <sys/kernel.h> #include <sys/kerneldump.h> -#include <sys/proc.h> -#include <sys/procfs.h> #include <vm/vm.h> #include <vm/pmap.h> #include <machine/bootinfo.h> @@ -54,13 +52,8 @@ typedef int callback_t(EFI_MEMORY_DESCRIPTOR*, int, void*); -extern int osreldate; - static struct kerneldumpheader kdh; static off_t dumplo, fileofs; -static char notenm[] = "FreeBSD"; -static size_t notesz; -static int nthreads; /* Handle buffered writes. */ static char buffer[DEV_BSIZE]; @@ -124,88 +117,10 @@ error = di->dumper(di->priv, buffer, 0, dumplo, DEV_BSIZE); dumplo += DEV_BSIZE; - fragsz = 0; return (error); } static int -note_size(uint64_t *sz) -{ - struct proc *p; - struct thread *t; - - nthreads = 0; - LIST_FOREACH(p, &allproc, p_list) { - FOREACH_THREAD_IN_PROC(p, t) { - nthreads++; - } - } - notesz = sizeof(Elf_Note) + sizeof(notenm) + sizeof(prstatus_t); - notesz *= nthreads; - *sz = MD_ALIGN(notesz); - return (1); -} - -static int -note_hdr(struct dumperinfo *di) -{ - Elf64_Phdr phdr; - int error; - - bzero(&phdr, sizeof(phdr)); - phdr.p_type = PT_NOTE; - phdr.p_offset = fileofs; - phdr.p_filesz = notesz; - - error = buf_write(di, (char*)&phdr, sizeof(phdr)); - fileofs += MD_ALIGN(notesz); - return (error); -} - -static int -note_data(struct dumperinfo *di) -{ - prstatus_t pr; - Elf_Note note; - struct proc *p; - struct thread *t; - int error; - - note.n_namesz = sizeof(notenm); - note.n_descsz = sizeof(pr); - note.n_type = NT_PRSTATUS; - error = 0; - LIST_FOREACH(p, &allproc, p_list) { - FOREACH_THREAD_IN_PROC(p, t) { - error = buf_write(di, (char*)¬e, sizeof(note)); - if (error) - return (error); - error = buf_write(di, notenm, sizeof(notenm)); - if (error) - return (error); - pr.pr_version = PRSTATUS_VERSION; - pr.pr_statussz = sizeof(prstatus_t); - pr.pr_gregsetsz = sizeof(gregset_t); - pr.pr_fpregsetsz = sizeof(fpregset_t); - pr.pr_osreldate = osreldate; - pr.pr_cursig = 0; - pr.pr_pid = t->td_tid; - if (t->td_last_frame != NULL) - t->td_frame = t->td_last_frame; - fill_regs(t, &pr.pr_reg); - error = buf_write(di, (char*)&pr, sizeof(pr)); - if (error) - return (error); - } - } - error = buf_flush(di); - if (error) - return (error); - dumplo += MD_ALIGN(notesz) - DEV_ALIGN(notesz); - return (0); -} - -static int cb_dumpdata(EFI_MEMORY_DESCRIPTOR *mdp, int seqnr, void *arg) { struct dumperinfo *di = (struct dumperinfo*)arg; @@ -220,7 +135,7 @@ pgs = mdp->NumberOfPages; pa = IA64_PHYS_TO_RR7(mdp->PhysicalStart); - printf(" chunk %d: %ld pages ", seqnr + 1, (long)pgs); + printf(" chunk %d: %ld pages ", seqnr, (long)pgs); while (pgs) { sz = (pgs > (DFLTPHYS >> EFI_PAGE_SHIFT)) @@ -324,7 +239,7 @@ ehdr.e_ident[EI_DATA] = ELFDATA2MSB; #endif ehdr.e_ident[EI_VERSION] = EV_CURRENT; - ehdr.e_ident[EI_OSABI] = ELFOSABI_FREEBSD; + ehdr.e_ident[EI_OSABI] = ELFOSABI_STANDALONE; /* XXX big picture? */ ehdr.e_type = ET_CORE; ehdr.e_machine = EM_IA_64; ehdr.e_phoff = sizeof(ehdr); @@ -334,8 +249,8 @@ ehdr.e_shentsize = sizeof(Elf64_Shdr); /* Calculate dump size. */ - ehdr.e_phnum = note_size(&dumpsize); - ehdr.e_phnum += foreach_chunk(cb_size, &dumpsize); + dumpsize = 0L; + ehdr.e_phnum = foreach_chunk(cb_size, &dumpsize); hdrsz = ehdr.e_phoff + ehdr.e_phnum * ehdr.e_phentsize; fileofs = MD_ALIGN(hdrsz); dumpsize += fileofs; @@ -351,8 +266,8 @@ mkdumpheader(&kdh, KERNELDUMP_IA64_VERSION, dumpsize, di->blocksize); - printf("Dumping %llu MB (%d memory chunks; %d threads)\n", - (long long)dumpsize >> 20, ehdr.e_phnum - 1, nthreads); + printf("Dumping %llu MB (%d chunks)\n", (long long)dumpsize >> 20, + ehdr.e_phnum); /* Dump leader */ error = di->dumper(di->priv, &kdh, 0, dumplo, sizeof(kdh)); @@ -365,10 +280,6 @@ if (error) goto fail; - /* Dump note header. */ - error = note_hdr(di); - if (error < 0) - goto fail; /* Dump program headers */ error = foreach_chunk(cb_dumphdr, di); if (error < 0) @@ -377,17 +288,13 @@ /* * All headers are written using blocked I/O, so we know the - * current offset is (still) block aligned. Skip the alignment + * current offset is (still) block aligned. Skip the alignement * in the file to have the segment contents aligned at page * boundary. We cannot use MD_ALIGN on dumplo, because we don't * care and may very well be unaligned within the dump device. */ dumplo += hdrgap; - /* Dump note segment. */ - error = note_data(di); - if (error < 0) - goto fail; /* Dump memory chunks (updates dumplo) */ error = foreach_chunk(cb_dumpdata, di); if (error < 0) ==== //depot/projects/gdb/sys/ia64/ia64/interrupt.c#5 (text+ko) ==== @@ -136,7 +136,6 @@ ia64_set_fpsr(IA64_FPSR_DEFAULT); td = curthread; - td->td_last_frame = tf; atomic_add_int(&td->td_intr_nesting_level, 1); /* ==== //depot/projects/gdb/sys/ia64/ia64/trap.c#10 (text+ko) ==== @@ -358,7 +358,6 @@ atomic_add_int(&cnt.v_trap, 1); td = curthread; - td->td_last_frame = tf; p = td->td_proc; ucode = 0; @@ -903,7 +902,6 @@ td = curthread; td->td_frame = tf; - td->td_last_frame = tf; p = td->td_proc; sticks = td->td_sticks; ==== //depot/projects/gdb/sys/ia64/ia64/unwind.c#4 (text+ko) ==== @@ -35,6 +35,7 @@ #include <sys/queue.h> #include <machine/frame.h> +#include <machine/pcb.h> #include <machine/unwind.h> #include <uwx.h> @@ -246,12 +247,13 @@ } int -unw_create(struct unw_regstate *rs, struct trapframe *tf) +unw_create_from_frame(struct unw_regstate *rs, struct trapframe *tf) { uint64_t bsp; int nats, sof, uwxerr; rs->frame = tf; + rs->pcb = NULL; rs->env = uwx_init(); if (rs->env == NULL) return (ENOMEM); @@ -270,6 +272,34 @@ return ((uwxerr) ? EINVAL : 0); /* XXX */ } +int +unw_create_from_pcb(struct unw_regstate *rs, struct pcb *pcb) +{ + uint64_t bsp; + int nats, sof, uwxerr; + + rs->frame = NULL; + rs->pcb = pcb; + rs->env = uwx_init(); + if (rs->env == NULL) + return (ENOMEM); + + uwxerr = uwx_register_callbacks(rs->env, (intptr_t)rs, + unw_cb_copyin, unw_cb_lookup); + if (uwxerr) + return (EINVAL); /* XXX */ + + bsp = pcb->pcb_special.bspstore; + sof = (int)(pcb->pcb_special.pfs & 0x7f); + nats = (sof + 63 - ((int)(bsp >> 3) & 0x3f)) / 63; + + uwxerr = uwx_init_context(rs->env, pcb->pcb_special.rp, + pcb->pcb_special.sp, bsp - ((sof + nats) << 3), + pcb->pcb_special.pfs); + + return ((uwxerr) ? EINVAL : 0); /* XXX */ +} + void unw_delete(struct unw_regstate *rs) { ==== //depot/projects/gdb/sys/ia64/include/db_machdep.h#4 (text+ko) ==== @@ -1,55 +1,51 @@ -/* $FreeBSD: src/sys/ia64/include/db_machdep.h,v 1.9 2003/05/16 21:26:41 marcel Exp $ */ -/* $NetBSD: db_machdep.h,v 1.6 1997/09/06 02:02:25 thorpej Exp $ */ - /* - * Copyright (c) 1995 Carnegie-Mellon University. + * Copyright (c) 2004 Marcel Moolenaar * All rights reserved. * - * Author: Chris G. Demetriou + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. + * $FreeBSD: src/sys/ia64/include/db_machdep.h,v 1.9 2003/05/16 21:26:41 marcel Exp $ */ #ifndef _MACHINE_DB_MACHDEP_H_ #define _MACHINE_DB_MACHDEP_H_ -/* - * Machine-dependent defines for new kernel debugger. - */ +#include <machine/ia64_cpu.h> + +/* We define some of our own commands. */ +#define DB_MACHINE_COMMANDS + +/* We use Elf64 symbols in DDB. */ +#define DB_ELFSIZE 64 -#include <sys/param.h> -#include <vm/vm.h> -#include <machine/frame.h> -#include <machine/ia64_cpu.h> +/* Pretty arbitrary. */ +#define DB_SMALL_VALUE_MAX 0x7fffffff +#define DB_SMALL_VALUE_MIN (-0x400001) typedef vm_offset_t db_addr_t; /* address - unsigned */ typedef long db_expr_t; /* expression - signed */ -typedef struct trapframe db_regs_t; -extern db_regs_t ddb_regs; /* register state */ -#define DDB_REGS (&ddb_regs) +#define PC_REGS() ((db_addr_t)kdb_thrctx->pcb_special.rp) -#define PC_REGS(regs) ((db_addr_t)(regs)->tf_special.iip + \ - (((regs)->tf_special.psr >> 41) & 3)) - #define BKPT_WRITE(addr, storage) db_bkpt_write(addr, storage) #define BKPT_CLEAR(addr, storage) db_bkpt_clear(addr, storage) #define BKPT_SKIP db_bkpt_skip() @@ -59,8 +55,8 @@ void db_bkpt_clear(db_addr_t, uint64_t *storage); void db_bkpt_skip(void); -#define db_set_single_step(regs) regs->tf_special.psr |= IA64_PSR_SS -#define db_clear_single_step(regs) regs->tf_special.psr &= ~IA64_PSR_SS +#define db_clear_single_step kdb_cpu_clear_singlestep +#define db_set_single_step kdb_cpu_set_singlestep #define IS_BREAKPOINT_TRAP(type, code) (type == IA64_VEC_BREAK) #define IS_WATCHPOINT_TRAP(type, code) 0 @@ -77,26 +73,4 @@ #define next_instr_address(v, b) ((db_addr_t) ((b) ? (v) : ((v) + 4))) -u_long db_register_value(db_regs_t *, int); - -uint64_t *db_rse_current_frame(void); -uint64_t *db_rse_previous_frame(uint64_t *bsp, int sof); -uint64_t *db_rse_register_address(uint64_t *bsp, int regno); - -/* - * Pretty arbitrary - */ -#define DB_SMALL_VALUE_MAX 0x7fffffff -#define DB_SMALL_VALUE_MIN (-0x400001) - -/* - * We define some of our own commands. - */ -#define DB_MACHINE_COMMANDS - -/* - * We use Elf64 symbols in DDB. - */ -#define DB_ELFSIZE 64 - #endif /* _MACHINE_DB_MACHDEP_H_ */ ==== //depot/projects/gdb/sys/ia64/include/kdb.h#4 (text+ko) ==== @@ -29,7 +29,9 @@ #ifndef _MACHINE_KDB_H_ #define _MACHINE_KDB_H_ +#include <machine/cpufunc.h> #include <machine/frame.h> +#include <machine/ia64_cpu.h> static __inline void kdb_cpu_clear_singlestep(void) ==== //depot/projects/gdb/sys/ia64/include/unwind.h#2 (text+ko) ==== @@ -29,15 +29,19 @@ #ifndef _MACHINE_UNWIND_H_ #define _MACHINE_UNWIND_H_ +struct pcb; +struct trapframe; struct uwx_env; >>> TRUNCATED FOR MAIL (1000 lines) <<<
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200406132135.i5DLZmGa066968>