1#include <stdio.h> 2#include <inttypes.h> 3 4#define IP 0 5#define SP 1 6#define BSP 2 7#define CFM 3 8#define RP 4 9#define PSP 5 10#define PFS 6 11#define PREDS 7 12#define PRIUNAT 8 13#define AR_BSPSTORE 9 14#define AR_RNAT 10 15#define AR_UNAT 11 16#define AR_FPSR 12 17#define AR_LC 13 18#define AR_PFS 14 19#define GR4 16 20#define GR5 17 21#define GR6 18 22#define GR7 19 23#define BR1 20 24#define BR2 21 25#define BR3 22 26#define BR4 23 27#define BR5 24 28 29void dump_context(uint64_t *context) 30{ 31 int i, j; 32 unsigned int valid; 33 uint64_t val; 34 static char *names[] = { 35 /* 0 */ "ip", "sp", "bsp", "cfm", 36 /* 4 */ "rp", "psp", "pfs", "preds", 37 /* 8 */ "priunat", "ar.bspstore", "ar.rnat", "ar.unat", 38 /* 12 */ "ar.fpsr", "ar.lc", "ar.pfs", "(pad)", 39 /* 16 */ "gr4", "gr5", "gr6", "gr7", 40 /* 20 */ "br1", "br2", "br3", "br4", "br5" 41 }; 42 static int col1[] = { 43 IP, 44 SP, 45 BSP, 46 CFM, 47 RP, 48 PSP, 49 PFS, 50 AR_RNAT, 51 AR_UNAT, 52 AR_FPSR, 53 AR_LC, 54 AR_PFS, 55 }; 56 static int col2[] = { 57 PREDS, 58 PRIUNAT, 59 GR4, 60 GR5, 61 GR6, 62 GR7, 63 BR1, 64 BR2, 65 BR3, 66 BR4, 67 BR5, 68 }; 69 70#define NCOL1 (sizeof(col1)/sizeof(int)) 71#define NCOL2 (sizeof(col2)/sizeof(int)) 72#define NPRINT (NCOL1 > NCOL2 ? NCOL1 : NCOL2) 73 74 valid = (unsigned int)(context[0] >> 32); 75 printf(" valid_regs (%08lx):", valid); 76 for (i = 0; i <= BR5; i++) { 77 if (valid & 1) printf(" %s", names[i]); 78 valid >>= 1; 79 } 80 printf("\n"); 81 for (i = 0; i < NPRINT; i++) { 82 if (i < NCOL1) { 83 j = col1[i]; 84 val = context[j+1]; 85 printf(" %-8s %08x %08x", names[j], 86 (unsigned int)(val >> 32), 87 (unsigned int)val); 88 } 89 else 90 printf(" "); 91 if (i < NCOL2) { 92 j = col2[i]; 93 val = context[j+1]; 94 printf(" %-8s %08x %08x", names[j], 95 (unsigned int)(val >> 32), 96 (unsigned int)val); 97 } 98 putchar('\n'); 99 } 100} 101