Changeset 14837


Ignore:
Timestamp:
Jun 22, 2011, 6:16:41 AM (8 years ago)
Author:
gb
Message:

Try to show ARM fp state in the kernel debugger.
(Trying to find the vfp state in the ucontext is a bit of an adventure,
and I'm not sure that that state contains a valid FPSCR value.)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/lisp-kernel/lisp-debug.c

    r14619 r14837  
    10561056}
    10571057
     1058#ifdef ARM
     1059#ifdef LINUX
     1060
     1061/* This stuff is buried in kernel headers.  Why ? */
     1062
     1063/* The uc_regspace field of a ucontext can contain coprocessor
     1064   info in structures whose first word is one of these magic
     1065   values; the structure list is terminated by something that's
     1066   not one of these magic values.
     1067
     1068   Good thinking! That'll make the mechanism easy to extend!
     1069   (In practice, a word of 0 seems to terminate the structure
     1070   list.)
     1071*/
     1072#define VFP_MAGIC               0x56465001
     1073#define IWMMXT_MAGIC            0x12ef842a
     1074#define CRUNCH_MAGIC            0x5065cf03
     1075
     1076
     1077struct user_vfp {
     1078        unsigned long long fpregs[32];
     1079        unsigned long fpscr;
     1080};
     1081
     1082struct user_vfp *
     1083find_vfp_info(ExceptionInformation *xp)
     1084{
     1085  char *p = (char *)(xp->uc_regspace);
     1086  unsigned *q, magic;
     1087
     1088  while (1) {
     1089    q = (unsigned *)p;                       
     1090    magic = *q;
     1091    if (magic == VFP_MAGIC) {
     1092      return (struct user_vfp *)(q+2);
     1093    }
     1094    if ((magic == CRUNCH_MAGIC) ||
     1095        (magic == IWMMXT_MAGIC)) {
     1096      p += q[1];
     1097    }
     1098    else {
     1099      return NULL;
     1100    }
     1101  }
     1102}
     1103
     1104#endif
     1105#endif
     1106
    10581107debug_command_return
    10591108debug_show_fpu(ExceptionInformation *xp, siginfo_t *info, int arg)
     
    11431192#endif
    11441193#endif
    1145 
     1194#ifdef ARM
     1195#ifdef LINUX
     1196  struct user_vfp *vfp = find_vfp_info(xp);
     1197 
     1198  if (vfp != NULL) {
     1199    float *fp = (float *)vfp;
     1200    double *dp = (double *)vfp;
     1201    unsigned *up = (unsigned *)vfp;
     1202    unsigned long long *llp = (unsigned long long *)vfp;
     1203    int dn,fn;
     1204
     1205    for (dn=0,fn=0;dn<16;dn++) {
     1206      fprintf(dbgout, "s%02d = %10e (0x%08x)        s%02d = %10e (0x%08x)\n",fn,fp[fn],up[fn],fn+1,fp[fn+1],up[fn+1]);
     1207      fn+=2;
     1208      fprintf(dbgout, "d%02d = %10e (0x%015llx)\n",dn,dp[dn],llp[dn]);
     1209    }
     1210    fprintf(dbgout, "FPSCR = 0x%08x\n", vfp->fpscr);
     1211  }
     1212#endif
     1213#endif
    11461214  return debug_continue;
    11471215}
Note: See TracChangeset for help on using the changeset viewer.