home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 13 / AACD13.ISO / AACD / System / Sysmon / src / AlertDump.c next >
C/C++ Source or Header  |  2000-05-30  |  27KB  |  759 lines

  1. /*
  2. **    $RCSfile: AlertDump.c,v $
  3. **    $Filename: AlertDump.c $
  4. **    $Revision: 1.2 $
  5. **    $Date: 2000/05/01 19:48:21 $
  6. **
  7. **    sysmon.library support command AlertDump (version 1.2)
  8. **    
  9. **    (C) Copyright 1999-2000 by Etienne Vogt
  10. */
  11.  
  12. #include <exec/alerts.h>
  13. #include <mmu/alerts.h>
  14. #include <dos/dos.h>
  15. #include <workbench/startup.h>
  16. #define __USE_SYSBASE
  17. #include <proto/exec.h>
  18. #include <proto/dos.h>
  19. #include <exec/execbase.h>
  20. #include <string.h>
  21. #include <stdlib.h>
  22. #include "sysmon.h"
  23.  
  24. #ifndef AFF_68060
  25. #define    AFB_68060    7
  26. #define AFF_68060    (1L<<7)
  27. #endif
  28.  
  29. ULONG __saveds main(void);
  30. static void cleanexit(ULONG rc);
  31. static STRPTR alerttype(ULONG alertnum);
  32. static STRPTR alertsub(ULONG alertnum);
  33. static STRPTR alertgen(ULONG alertnum);
  34. static STRPTR alertobj(ULONG alertnum);
  35. static STRPTR alertname(ULONG alertnum);
  36. static char *cpustr(UWORD cpuflags);
  37.  
  38. static UBYTE version[] = "$VER: AlertDump 1.2 (30.4.2000)";
  39. static UBYTE template[] = "CLEAR/S";
  40.  
  41. #define    OPT_CLEAR    0
  42. #define    OPTMAX        1
  43.  
  44. struct ExecBase *SysBase;
  45. struct DosLibrary *DOSBase;
  46. static struct WBStartup *wbmsg;
  47. static struct RDArgs *myrda;
  48. struct SysmonBase *SysmonBase;
  49.  
  50. ULONG __saveds main(void)    /* No startup code */
  51. {
  52.   struct Process *myproc;
  53.   struct LastGuru *lastguru;
  54.   LONG opts[OPTMAX];
  55.  
  56.   SysBase = *(struct ExecBase **)4;
  57.   DOSBase = NULL;
  58.   SysmonBase = NULL;
  59.   wbmsg = NULL;
  60.   myrda = NULL;
  61.  
  62.   myproc = (struct Process *)FindTask(NULL);
  63.   if ((DOSBase = (struct DosLibrary *)OpenLibrary("dos.library",36)) == NULL)
  64.   { Alert(AT_Recovery|AG_OpenLib|AO_DOSLib);
  65.     return 100;
  66.   }
  67.  
  68.   if (!(myproc->pr_CLI))        /* If started from WB, exit cleanly */
  69.   { WaitPort(&(myproc->pr_MsgPort));
  70.     wbmsg = (struct WBStartup *)GetMsg(&(myproc->pr_MsgPort));
  71.     cleanexit(20);
  72.   }
  73.  
  74.   if ((SysmonBase = (struct SysmonBase *)OpenLibrary("sysmon.library",1)) == NULL)
  75.   { PutStr("AlertDump: couldn't open sysmon.library V1+\n");
  76.     cleanexit(20);
  77.   }
  78.  
  79.   memset((char *)opts, 0, sizeof(opts));
  80.   if ((myrda = ReadArgs(template, opts, NULL)) == NULL)
  81.   { PrintFault(IoErr(),NULL);
  82.     cleanexit(20);
  83.   }
  84.  
  85.   if ((lastguru = SysmonBase->sb_LastGuru) && lastguru->lg_Sig == (ULONG)'HELP')
  86.   { UWORD cpu = SysBase->AttnFlags;
  87.  
  88.     Printf("\n%s Alert %s\n", alerttype(lastguru->lg_AlertNum), cpustr(cpu));
  89.     Printf(" Guru Meditation: %08lx  %s\n", lastguru->lg_AlertNum, alertname(lastguru->lg_AlertNum));
  90.     Printf(" Current Task   : %08lx  %.32s\n", lastguru->lg_AlertAddr, lastguru->lg_TaskName);
  91.     Printf(" SubSystem      : %s\n", alertsub(lastguru->lg_AlertNum));
  92.     Printf(" General Error  : %s\n", alertgen(lastguru->lg_AlertNum));
  93.     Printf(" Alert Object   : %s\n", alertobj(lastguru->lg_AlertNum));
  94.  
  95.     PutStr("\nInteger registers\n");
  96.     Printf(" D0-D7 = %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",lastguru->lg_DataRegs[0],lastguru->lg_DataRegs[1],lastguru->lg_DataRegs[2],lastguru->lg_DataRegs[3],lastguru->lg_DataRegs[4],lastguru->lg_DataRegs[5],lastguru->lg_DataRegs[6],lastguru->lg_DataRegs[7]);
  97.     Printf(" A0-A7 = %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",lastguru->lg_AddrRegs[0],lastguru->lg_AddrRegs[1],lastguru->lg_AddrRegs[2],lastguru->lg_AddrRegs[3],lastguru->lg_AddrRegs[4],lastguru->lg_AddrRegs[5],lastguru->lg_AddrRegs[6],lastguru->lg_AddrRegs[7]);
  98.     Printf(" PC = %08lx, SR = %04lx\n",lastguru->lg_PC,(LONG)lastguru->lg_SR);
  99.  
  100.     if (SysmonBase->sb_Flags & SBFF_FPU)
  101.     { PutStr("\nFloating Point registers\n");
  102.       Printf(" FP0-FP1 = %08lx%08lx%08lx %08lx%08lx%08lx\n",lastguru->lg_FloatRegs[0],lastguru->lg_FloatRegs[1],lastguru->lg_FloatRegs[2],lastguru->lg_FloatRegs[3],lastguru->lg_FloatRegs[4],lastguru->lg_FloatRegs[5]);
  103.       Printf(" FP2-FP3 = %08lx%08lx%08lx %08lx%08lx%08lx\n",lastguru->lg_FloatRegs[6],lastguru->lg_FloatRegs[7],lastguru->lg_FloatRegs[8],lastguru->lg_FloatRegs[9],lastguru->lg_FloatRegs[10],lastguru->lg_FloatRegs[11]);
  104.       Printf(" FP4-FP5 = %08lx%08lx%08lx %08lx%08lx%08lx\n",lastguru->lg_FloatRegs[12],lastguru->lg_FloatRegs[13],lastguru->lg_FloatRegs[14],lastguru->lg_FloatRegs[15],lastguru->lg_FloatRegs[16],lastguru->lg_FloatRegs[17]);
  105.       Printf(" FP6-FP7 = %08lx%08lx%08lx %08lx%08lx%08lx\n",lastguru->lg_FloatRegs[18],lastguru->lg_FloatRegs[19],lastguru->lg_FloatRegs[20],lastguru->lg_FloatRegs[21],lastguru->lg_FloatRegs[22],lastguru->lg_FloatRegs[23]);
  106.       Printf(" FPCR = %08lx, FPSR = %08lx, FPIAR = %08lx\n",lastguru->lg_FPCR,lastguru->lg_FPSR,lastguru->lg_FPIAR);
  107.     }
  108.  
  109.     PutStr("\nSystem registers\n");
  110.     Printf(" USP = %08lx, ",lastguru->lg_USP);
  111.     if ((cpu & AFF_68020) && (cpu & AFF_68060) == 0)
  112.     { Printf("ISP = %08lx, MSP = %08lx\n",lastguru->lg_SSP,lastguru->lg_MSP);
  113.     }
  114.     else
  115.     { Printf("SSP = %08lx\n",lastguru->lg_SSP);
  116.     }
  117.     if (cpu & AFF_68010)
  118.     { Printf(" VBR = %08lx, SFC = %08lx, DFC = %08lx\n",lastguru->lg_VBR,lastguru->lg_SFC,lastguru->lg_DFC);
  119.       if (cpu & AFF_68020)
  120.       { Printf(" CACR = %08lx",lastguru->lg_CACR);
  121.     if ((cpu & AFF_68040) == 0) Printf(", CAAR = %08lx",lastguru->lg_CAAR);
  122.     PutStr("\n");
  123.     if (cpu & AFF_68030)
  124.     { if (cpu & AFF_68040)
  125.       { Printf(" ITT0 = %08lx, ITT1 = %08lx, DTT0 = %08lx, DTT1 = %08lx\n",lastguru->lg_ITT0,lastguru->lg_ITT1,lastguru->lg_DTT0,lastguru->lg_DTT1);
  126.         Printf(" TC = %08lx, URP = %08lx, SRP = %08lx\n",lastguru->lg_TC,lastguru->lg_URP,lastguru->lg_SRP);
  127.       }
  128.       else
  129.       { Printf(" TT0 = %08lx, TT1 = %08lx\n",lastguru->lg_ITT0,lastguru->lg_ITT1);
  130.         Printf(" TC = %08lx, CRP = %08lx%08lx, SRP = %08lx%08lx\n",lastguru->lg_TC,lastguru->lg_DTT0,lastguru->lg_DTT1,lastguru->lg_URP,lastguru->lg_SRP);
  131.       }
  132.       if (cpu & AFF_68060) Printf(" PCR = %08lx, BUSCR = %08lx\n",lastguru->lg_MSP,lastguru->lg_MMUSR);
  133.       else if (cpu & AFF_68040) Printf(" MMUSR = %08lx\n",lastguru->lg_MMUSR);
  134.       else Printf(" MMUSR = %04lx\n",lastguru->lg_MMUSR >> 16);
  135.     }
  136.       }
  137.     }
  138.  
  139.     if (opts[OPT_CLEAR]) lastguru->lg_Sig = 0;
  140.   }
  141.   else PutStr("No LastGuru data available\n");
  142.  
  143.   cleanexit(0);
  144. }
  145.  
  146. static void cleanexit(ULONG rc)
  147. {
  148.   if (myrda) FreeArgs(myrda);
  149.   if (DOSBase) CloseLibrary((struct Library *)DOSBase);
  150.   if (SysmonBase) CloseLibrary((struct Library *)SysmonBase);
  151.   if (wbmsg)
  152.   { Forbid();
  153.     ReplyMsg((struct Message *)wbmsg);
  154.   }
  155.   Exit(rc);
  156. }
  157.  
  158. static STRPTR alerttype(ULONG alertnum)
  159. { if (alertnum & AT_DeadEnd) return "DeadEnd";
  160.   else return "Recoverable";
  161. }
  162.  
  163. static STRPTR alertsub(ULONG alertnum)
  164. { switch (alertnum & 0x7f000000)
  165.   { case AN_ExecLib:
  166.       return "exec.library";
  167.     case AN_GraphicsLib:
  168.       return "graphics.library";
  169.     case AN_LayersLib:
  170.       return "layers.library";
  171.     case AN_Intuition:
  172.       return "intuition.library";
  173.     case AN_MathLib:
  174.       return "math*.library";
  175.     case 0x06000000:
  176.       return "clist.library (obsolete)";
  177.     case AN_DOSLib:
  178.       return "dos.library";
  179.     case AN_RAMLib:
  180.       return "ramlib";
  181.     case AN_IconLib:
  182.       return "icon.library";
  183.     case AN_ExpansionLib:
  184.       return "expansion.library";
  185.     case AN_DiskfontLib:
  186.       return "diskfont.library";
  187.     case AN_AudioDev:
  188.       return "audio.device";
  189.     case AN_ConsoleDev:
  190.       return "console.device";
  191.     case AN_GamePortDev:
  192.       return "gameport.device";
  193.     case AN_KeyboardDev:
  194.       return "keyboard.device";
  195.     case AN_TrackDiskDev:
  196.       return "trackdisk.device";
  197.     case AN_TimerDev:
  198.       return "timer.device";
  199.     case AN_CIARsrc:
  200.       return "cia.resource";
  201.     case AN_DiskRsrc:
  202.       return "disk.resource";
  203.     case AN_MiscRsrc:
  204.       return "misc.resource";
  205.     case AN_BootStrap:
  206.       return "strap";
  207.     case AN_Workbench:
  208.       return "Workbench";
  209.     case AN_DiskCopy:
  210.       return "DiskCopy";
  211.     case AN_GadTools:
  212.       return "gadtools.library";
  213.     case AN_UtilityLib:
  214.       return "utility.library";
  215.     case AN_Unknown:
  216.       return "Unknown";
  217.     case AN_MMULib:
  218.       return "mmu.library";
  219.     case 0x40000000:
  220.       return "sysmon.library";
  221.     case 0x50000000:
  222.       return "vdisk.device";
  223.     case 0x70000000:
  224.       return "ErrorLogD";
  225.     default:
  226.       return "N/A";
  227.   }
  228. }
  229.  
  230. static STRPTR alertobj(ULONG alertnum)
  231. { switch (alertnum & 0x0000ffff)
  232.   { case AO_ExecLib:
  233.       return "exec.library";
  234.     case AO_GraphicsLib:
  235.       return "graphics.library";
  236.     case AO_LayersLib:
  237.       return "layers.library";
  238.     case AO_Intuition:
  239.       return "intuition.library";
  240.     case AO_MathLib:
  241.       return "math*.library";
  242.     case 0x00008006:
  243.       return "clist.library (obsolete)";
  244.     case AO_DOSLib:
  245.       return "dos.library";
  246.     case AO_RAMLib:
  247.       return "ramlib";
  248.     case AO_IconLib:
  249.       return "icon.library";
  250.     case AO_ExpansionLib:
  251.       return "expansion.library";
  252.     case AO_DiskfontLib:
  253.       return "diskfont.library";
  254.     case AO_AudioDev:
  255.       return "audio.device";
  256.     case AO_ConsoleDev:
  257.       return "console.device";
  258.     case AO_GamePortDev:
  259.       return "gameport.device";
  260.     case AO_KeyboardDev:
  261.       return "keyboard.device";
  262.     case AO_TrackDiskDev:
  263.       return "trackdisk.device";
  264.     case AO_TimerDev:
  265.       return "timer.device";
  266.     case AO_CIARsrc:
  267.       return "cia.resource";
  268.     case AO_DiskRsrc:
  269.       return "disk.resource";
  270.     case AO_MiscRsrc:
  271.       return "misc.resource";
  272.     case AO_BootStrap:
  273.       return "strap";
  274.     case AO_Workbench:
  275.       return "Workbench";
  276.     case AO_DiskCopy:
  277.       return "DiskCopy";
  278.     case AO_GadTools:
  279.       return "gadtools.library";
  280.     case AO_UtilityLib:
  281.       return "utility.library";
  282.     case AO_Unknown:
  283.       return "Unknown";
  284.     case 0x0000803e:
  285.       return "mmu.library";
  286.     case 0x00008040:
  287.       return "sysmon.library";
  288.     case 0x00008050:
  289.       return "vdisk.device";
  290.     case 0x00008070:
  291.       return "ErrorLogD";
  292.     default:
  293.       return "N/A";
  294.   }
  295. }
  296.  
  297. static STRPTR alertgen(ULONG alertnum)
  298. { switch (alertnum & 0x00ff0000)
  299.   { case AG_NoMemory:
  300.       return "Not enough memory";
  301.     case AG_MakeLib:
  302.       return "Library initialization failure";
  303.     case AG_OpenLib:
  304.       return "OpenLibrary() failure";
  305.     case AG_OpenDev:
  306.       return "OpenDevice() failure";
  307.     case AG_OpenRes:
  308.       return "OpenResource() failure";
  309.     case AG_IOError:
  310.       return "I/O error";
  311.     case AG_NoSignal:
  312.       return "No signal available";
  313.     case AG_BadParm:
  314.       return "Bad parameter(s) to function";
  315.     case AG_CloseLib:
  316.       return "Mismatched or too many CloseLibrary()";
  317.     case AG_CloseDev:
  318.       return "Mismatched or too many CloseDevice()";
  319.     case AG_ProcCreate:
  320.       return "Process creation failed";
  321.     default:
  322.       return "N/A";
  323.   }
  324. }
  325.  
  326. static STRPTR alertname(ULONG alertnum)
  327. { ULONG num = alertnum & 0x7fffffff;
  328.  
  329.   if ((num >= 0x00000010 && num < 0x00000018) || num == 0x0000003B || num == 0x0000003E || num == 0x0000003F)
  330.     return "ACPU_Reserved (Reserved CPU vector)";
  331.   if (num >= 0x00000040 && num < 0x000000FF) return "ACPU_User (Quick interrupt vector)";
  332.  
  333.   switch (num)
  334.   { case 0x00000001:        /* CPU Exception alerts */
  335.       return "ACPU_Reset (System reset or shutdown)";
  336.     case 0x00000002:
  337.       return "ACPU_BusErr (Bus or access error)";
  338.     case 0x00000003:
  339.       return "ACPU_AddressErr (Odd address error)";
  340.     case 0x00000004:
  341.       return "ACPU_InstErr (Illegal instruction)";
  342.     case 0x00000005:
  343.       return "ACPU_DivZero (Division by zero)";
  344.     case 0x00000006:
  345.       return "ACPU_CHK (CHK instruction exception)";
  346.     case 0x00000007:
  347.       return "ACPU_TRAPV (TRAPcc instruction exception)";
  348.     case 0x00000008:
  349.       return "ACPU_PrivErr (Privilege violation)";
  350.     case 0x00000009:
  351.       return "ACPU_Trace (Trace exception)";
  352.     case 0x0000000A:
  353.       return "ACPU_LineA (Unimplemented line 1010 instruction)";
  354.     case 0x0000000B:
  355.       return "ACPU_LineF (Unimplemented line 1111 instruction)";
  356.     case 0x0000000C:
  357.       return "ACPU_EmulInt (Emulation mode interrupt)";
  358.     case 0x0000000D:
  359.       return "ACPU_CoproErr (Coprocessor protocol violation)";
  360.     case 0x0000000E:
  361.       return "ACPU_Format (Stack frame format error)";
  362.     case 0x0000000F:
  363.       return "ACPU_UnInitInt (Uninitialized interrupt)";
  364.     case 0x00000018:
  365.       return "ACPU_Spurious (Spurious interrupt error)";
  366.     case 0x00000019:
  367.       return "ACPU_AutoVec1 (AutoVector Level 1 interrupt)";
  368.     case 0x0000001A:
  369.       return "ACPU_AutoVec2 (AutoVector Level 2 interrupt)";
  370.     case 0x0000001B:
  371.       return "ACPU_AutoVec3 (AutoVector Level 3 interrupt)";
  372.     case 0x0000001C:
  373.       return "ACPU_AutoVec4 (AutoVector Level 4 interrupt)";
  374.     case 0x0000001D:
  375.       return "ACPU_AutoVec5 (AutoVector Level 5 interrupt)";
  376.     case 0x0000001E:
  377.       return "ACPU_AutoVec6 (AutoVector Level 6 interrupt)";
  378.     case 0x0000001F:
  379.       return "ACPU_AutoVec7 (AutoVector Level 7 interrupt)";
  380.     case 0x00000020:
  381.       return "ACPU_Trap0 (TRAP #0 exception)";
  382.     case 0x00000021:
  383.       return "ACPU_Trap1 (TRAP #1 exception)";
  384.     case 0x00000022:
  385.       return "ACPU_Trap2 (TRAP #2 exception)";
  386.     case 0x00000023:
  387.       return "ACPU_Trap3 (TRAP #3 exception)";
  388.     case 0x00000024:
  389.       return "ACPU_Trap4 (TRAP #4 exception)";
  390.     case 0x00000025:
  391.       return "ACPU_Trap5 (TRAP #5 exception)";
  392.     case 0x00000026:
  393.       return "ACPU_Trap6 (TRAP #6 exception)";
  394.     case 0x00000027:
  395.       return "ACPU_Trap7 (TRAP #7 exception)";
  396.     case 0x00000028:
  397.       return "ACPU_Trap8 (TRAP #8 exception)";
  398.     case 0x00000029:
  399.       return "ACPU_Trap9 (TRAP #9 exception)";
  400.     case 0x0000002A:
  401.       return "ACPU_TrapA (TRAP #A exception)";
  402.     case 0x0000002B:
  403.       return "ACPU_TrapB (TRAP #B exception)";
  404.     case 0x0000002C:
  405.       return "ACPU_TrapC (TRAP #C exception)";
  406.     case 0x0000002D:
  407.       return "ACPU_TrapD (TRAP #D exception)";
  408.     case 0x0000002E:
  409.       return "ACPU_TrapE (TRAP #E exception)";
  410.     case 0x0000002F:
  411.       return "ACPU_TrapF (TRAP #F exception)";
  412.     case 0x00000030:        /* FPU exceptions */
  413.       return "AFPU_BSUnord (Branch or Set on unordered condition)";
  414.     case 0x00000031:
  415.       return "AFPU_Inexact (Inexact result)";
  416.     case 0x00000032:
  417.       return "AFPU_FDivZero (Floating-point division by zero)";
  418.     case 0x00000033:
  419.       return "AFPU_Underflow (Floating-point underflow)";
  420.     case 0x00000034:
  421.       return "AFPU_Operand (Operand error)";
  422.     case 0x00000035:
  423.       return "AFPU_Overflow (Floating-point overflow)";
  424.     case 0x00000036:
  425.       return "AFPU_SNaN (Signaling NaN)";
  426.     case 0x00000037:
  427.       return "AFPU_UnDType (Unimplemented FP data type)";
  428.     case 0x00000038:        /* MMU exceptions */
  429.       return "AMMU_Config (Configuration error)";
  430.     case 0x00000039:
  431.       return "AMMU_IllOp (Illegal operation)";
  432.     case 0x0000003A:
  433.       return "AMMU_AccessErr (Access level violation)";
  434.     case 0x0000003C:
  435.       return "ACPU_UnEffAddr (Unimplemented effective address)";
  436.     case 0x0000003D:
  437.       return "ACPU_UnIntInst (Unimplemented integer instruction)";
  438.     
  439.     case 0x01000001:        /* exec.library alerts */
  440.       return "AN_ExcptVect (Bad CPU exception vectors checksum)";
  441.     case 0x01000002:
  442.       return "AN_BaseChkSum (Bad ExecBase checksum)";
  443.     case 0x01000003:
  444.       return "AN_LibChkSum (Bad library jumptable checksum)";
  445.     case 0x01000004:
  446.       return "AN_LibMem (No memory for ExecBase structure)";
  447.     case 0x01000005:
  448.       return "AN_MemCorrupt (Corrupted memory list)";
  449.     case 0x01000006:
  450.       return "AN_IntrMem (No memory for interrupt servers)";
  451.     case 0x01000007:
  452.       return "AN_InitAPtr (InitStruct() with a 24bit address)";
  453.     case 0x01000008:
  454.       return "AN_SemCorrupt (Illegal semaphore state)";
  455.     case 0x01000009:
  456.       return "AN_FreeTwice (Freeing memory already freed)";
  457.     case 0x0100000A:
  458.       if (alertnum & AT_DeadEnd) return "AN_BogusExcpt (Illegal CPU exception taken)";
  459.       else return "AN_UnInitExcpt (Uninitialized task exception)";
  460.     case 0x0100000B:
  461.       return "AN_IOUsedTwice (Pending IORequest reused)";
  462.     case 0x0100000C:
  463.       return "AN_MemoryInsane (Sanity check on memory list failed)";
  464.     case 0x0100000D:
  465.       return "AN_IOAfterClose (Closed IORequest reused)";
  466.     case 0x0100000E:
  467.       return "AN_StackProbe (Stack out of range)";
  468.     case 0x0100000F:
  469.       return "AN_BadFreeAddr (Memory header not located)";
  470.     case 0x01000010:
  471.       return "AN_BadSemaphore (Obsolete semaphore structure used)";
  472.     case 0x010000FF:
  473.       return "AN_UnQuickIntr (Uninitialized quick interrupt)";
  474.     case 0x01000011:        /* PoolMem alerts */
  475.       return "AN_MemHeadInsane (MemHeader Insane)";
  476.     case 0x01000012:
  477.       return "AN_InvDelHeader (Invalid DeleteHeader, internal)";
  478.     case 0x01000013:
  479.       return "AN_IllScratch (Scratch Entry Illegal)";
  480.     case 0x01000014:
  481.       return "AN_UnordPools (Memory Pools Unordered)";
  482.     case 0x01000015:
  483.       return "AN_AllocUnder (AllocMem Underflow)";
  484.     case 0x01000016:
  485.       return "AN_FreeOver (FreeMem Overflow)";
  486.  
  487.     case 0x02010000:        /* graphics.library alerts */
  488.       return "AN_GfxNoMem (No memory for graphics.library)";
  489.     case 0x02010001:
  490.       return "AN_GfxNoMemMspc (No memory for MonitorSpec)";
  491.     case 0x02010002:
  492.       return "AN_CopInstr (No memory for Copperlist)";
  493.     case 0x02000003:
  494.       return "AN_CopListOver (Copperlist overload)";
  495.     case 0x02000004:
  496.       return "AN_CopIListOver (Intermediate Copperlist overload)";
  497.     case 0x02010005:
  498.       return "AN_CopListHead (No memory for Copperlist head)";
  499.     case 0x02010006:
  500.       return "AN_LongFrame (No memory for long-frame Copperlist)";
  501.     case 0x02010007:
  502.       return "AN_ShortFrame (No memory for short-frame Copperlist)";
  503.     case 0x02010008:
  504.       return "AN_FloodFill (No memory for Flood Fill)";
  505.     case 0x02010009:
  506.       return "AN_TextTmpRas (No memory for Text TmpRas)";
  507.     case 0x0201000A:
  508.       return "AN_BltBitMap (No memory for BltBitMap)";
  509.     case 0x0201000B:
  510.       return "AN_RegionMemory (No memory for Region)";
  511.     case 0x0200000C:
  512.       return "AN_GfxNewError (Illegal node type for GfxNew)";
  513.     case 0x0200000D:
  514.       return "AN_GfxFreeError (Bad ExtendedNode for GfxFree)";
  515.     case 0x02000030:
  516.       return "AN_MakeVPort (No memory for MakeVPort)";
  517.     case 0x02000401:
  518.       return "AN_ObsoleteFont (Obsolete font description)";
  519.     case 0x02011234:
  520.       return "AN_GfxNoLCM (Emergency memory not available)";
  521.  
  522.     case 0x03010000:        /* layers.library alerts */
  523.       return "AN_LayersNoMem (No memory for layers.library)";
  524.  
  525.     case 0x04000001:        /* intuition.library alerts */
  526.       return "AN_GadgetType (Unknown gadget type)";
  527.     case 0x04010002:
  528.       return "AN_CreatePort (No memory for CreatePort)";
  529.     case 0x04010003:
  530.       return "AN_ItemAlloc (No memory for MenuItem plane)";
  531.     case 0x04010004:
  532.       return "AN_SubAlloc (No memory for SubItem plane)";
  533.     case 0x04010005:
  534.       return "AN_PlaneAlloc (No memory for plane)";
  535.     case 0x04000006:
  536.       return "AN_ItemBoxTop (Item box in negative region)";
  537.     case 0x04010007:
  538.       return "AN_OpenScreen (No memory for OpenScreen)";
  539.     case 0x04010008:
  540.       return "AN_OpenScrnRast (No memory for raster in OpenScreen)";
  541.     case 0x04000009:
  542.       return "AN_SysScrnType (Unknown sys screen type)";
  543.     case 0x0401000A:
  544.       return "AN_AddSWGadget (No memory to add gadget)";
  545.     case 0x0401000B:
  546.       return "AN_OpenWindow (No memory for OpenWindow)";
  547.     case 0x0400000C:
  548.       return "AN_BadState (Bad State entering Intuition)";
  549.     case 0x0400000D:
  550.       return "AN_BadMessage (Bad Message received by IDCMP)";
  551.     case 0x0400000E:
  552.       return "AN_WeirdEcho (Weird echo on deferred action)";
  553.     case 0x0400000F:
  554.       return "AN_NoConsole (Couldn't open console.device)";
  555.     case 0x04000010:
  556.       return "AN_NoISem (Intuition skipped obtaining a sem)";
  557.     case 0x04000011:
  558.       return "AN_ISemOrder (Intuition obtained a sem in bad order)";
  559.  
  560.     case 0x07000000:        /* dos.library alerts */
  561.       return "AN_Startup (Error initializing DOS)";
  562.     case 0x07010001:
  563.       return "AN_StartMem (No memory at DOS startup)";
  564.     case 0x07000002:
  565.       return "AN_EndTask (Task could not be terminated)";
  566.     case 0x07000003:
  567.       return "AN_QPktFail (Invalid link from DosPacket to Message)";
  568.     case 0x07000004:
  569.       return "AN_AsyncPkt (Unexpected packet received)";
  570.     case 0x07000005:
  571.       return "AN_FreeVec (Incorrect length in FreeVec)";
  572.     case 0x07000006:
  573.       return "AN_DiskBlkSeq (Disk block sequence error)";
  574.     case 0x07000007:
  575.       return "AN_BitMap (Defective bitmap)";
  576.     case 0x07000008:
  577.       return "AN_KeyFree (Block already free)";
  578.     case 0x07000009:
  579.       return "AN_BadChkSum (Invalid block checksum)";
  580.     case 0x0700000A:
  581.       return "AN_DiskError (Disk error)";
  582.     case 0x0700000B:
  583.       return "AN_KeyRange (Block number outside valid range)";
  584.     case 0x0700000C:
  585.       return "AN_BadOverlay (Error in overlay supervisor)";
  586.     case 0x0700000D:
  587.       return "AN_BadInitFunc (Invalid shell initialization packet)";
  588.     case 0x0700000E:
  589.       return "AN_FileReclosed (FileHandle closed more than once)";
  590.  
  591.     case 0x08000001:        /* ramlib alerts */
  592.       return "AN_BadSegList (Overlay in shared library)";
  593.  
  594.     case 0x0A000001:        /* expansion.library alerts */
  595.       return "AN_BadExpansionFree (Expansion slot already free)";
  596.  
  597.     case 0x11000001:        /* console.device alerts */
  598.       return "AN_NoWindow (Can't open initial window)";
  599.  
  600.     case 0x14000001:        /* trackdisk.device alerts */
  601.       return "AN_TDCalibSeek (Seek error during calibration)";
  602.     case 0x14000002:
  603.       return "AN_TDDelay (Timer error while waiting)";
  604.  
  605.     case 0x15000001:        /* timer.device alerts */
  606.       return "AN_TMBadReq (Invalid timerequest)";
  607.     case 0x15000002:
  608.       return "AN_TMBadSupply (No ticks from power supply)";
  609.  
  610.     case 0x21000001:        /* disk.resource alerts */
  611.       return "AN_DRHasDisk (Unit already active)";
  612.     case 0x21000002:
  613.       return "AN_DRIntNoAct (Interrupt without an active unit)";
  614.  
  615.     case 0x30000001:        /* strap alerts */
  616.       return "AN_BootError (Boot code returned an error)";
  617.  
  618.     case 0x31000001:        /* Workbench alerts */
  619.       if (alertnum & AT_DeadEnd) return "AN_NoFonts (Unable to open default font)";
  620.       else return "AN_WBBadStartupMsg1 (Bad StartupMsg returned)";
  621.     case 0x31000002:
  622.       return "AN_WBBadStartupMsg2 (Bad StartupMsg returned)";
  623.     case 0x31000003:
  624.       return "AN_WBBadIOMsg (Unrecognized internal message)";
  625.     case 0x31010004:
  626.       return "AN_WBInitPotionAllocDrawer";
  627.     case 0x31010005:
  628.       return "AN_WBCreateWBMenusCreateMenus1";
  629.     case 0x31010006:
  630.       return "AN_WBCreateWBMenusCreateMenus2";
  631.     case 0x31010007:
  632.       return "AN_WBLayoutWBMenusLayoutMenus";
  633.     case 0x31010008:
  634.       return "AN_WBAddToolMenuItem";
  635.     case 0x31010009:
  636.       return "AN_WBReLayoutToolMenu";
  637.     case 0x3101000A:
  638.       return "AN_WBInitTimer";
  639.     case 0x3101000B:
  640.       return "AN_WBInitLayerDemon";
  641.     case 0x3101000C:
  642.       return "AN_WBInitWBGels";
  643.     case 0x3101000D:
  644.       return "AN_WBInitScreenAndWindows1";
  645.     case 0x3101000E:
  646.       return "AN_WBInitScreenAndWindows2";
  647.     case 0x3101000F:
  648.       return "AN_WBInitScreenAndWindows3";
  649.     case 0x31010010:
  650.       return "AN_WBMAlloc";
  651.  
  652.     case 0x3e090001:    /* mmu.library alerts */
  653.       return "AN_ContextOpen (Context still in use at Expunge())";
  654.     case 0x3e018005:
  655.       return "AN_BadFreePool (Internal memory pool is damaged)";
  656.     case 0x3e018001:
  657.       return "AN_NoPoolMem (No memory to build internal pool)";
  658.     case 0x3e018002:
  659.       return "AN_NoContext (No memory to build the context)";
  660.     case 0x3e000002:
  661.       return "AN_MMUInit (MMU Init vector failed)";
  662.     case 0x3e000003:
  663.       return "AN_IllegalTT (Illegal Transparent Translation mode)";
  664.     case 0x3e000004:
  665.       return "AN_IllegalMMU (MMU table layout not supported)";
  666.     case 0x3e000005:
  667.       return "AN_BadContext (Context contains unaligned mappings)";
  668.     case 0x3e000006:
  669.       return "AN_BadTable (MMU table has been damaged)";
  670.     case 0x3e000007:
  671.       return "AN_FreeActive (Attempt to release an active context)";
  672.     case 0x3e000008:
  673.       return "AN_MapHole (Mapping contains undefined areas)";
  674.     case 0x3e000009:
  675.       return "AN_Phase (Unexpected context change required)";
  676.     case 0x3e00000a:
  677.       return "AN_BuildError (Lower tree level built failed)";
  678.     case 0x3e00000b:
  679.       return "AN_ConfigBroken (MMU config parameters invalid)";
  680.     case 0x3e00000c:
  681.       return "AN_NoRoot (No valid root pointer for context)";
  682.     case 0x3e00000d:
  683.       return "AN_NoCatcher (No catcher port for exceptions)";
  684.     case 0x3e00000e:
  685.       return "AN_ExcptBusy (Attempt to release a busy exception)";
  686.     case 0x3e00000f:
  687.       return "AN_NotCaller (Bad message hook release attempt)";
  688.     case 0x3e000073:
  689.       return "AN_QueueDaemon (Invalid reply from exception daemon)";
  690.     case 0x3e000010:
  691.       return "AN_LineWB (Unhandled line writeback fault)";
  692.     case 0x3e000011:
  693.       return "AN_LineRB (Unhandled line fetch fault)";
  694.     case 0x3e000012:
  695.       return "AN_GhostMovem (Invalid movem fault detected)";
  696.     case 0x3e000013:
  697.       return "AN_CheckMMU (CheckMMU couldn't repair test page)";
  698.     case 0x3e000014:
  699.       return "AN_BadDMA (Bad DMA transfer initiated)";
  700.     case 0x3e000015:
  701.       return "AN_PostSetup (Memory layout changed after setup)";
  702.     case 0x3e000016:
  703.       return "AN_NoMapMem (Free non-RemapSize() aligned memory)";
  704.  
  705.     case 0x40000001:        /* sysmon.library alerts */
  706.       return "AN_smNoTaskInfo (No TaskInfo structure found)";
  707.     case 0x40010002:
  708.       return "AN_smNoTIMem (No memory for TaskInfo at startup)";
  709.     case 0x40010003:
  710.       return "AN_smSysLogBuf (No memory for syslog buffers)";
  711.     case 0x40000004:
  712.       return "AN_BadSysLogMsg (Bad SysLogMsg received by server)";
  713.     case 0x40010005:
  714.       return "AN_smNoLastGuru (No memory for LastGuru buffer)";
  715.     case 0x40010006:
  716.       return "AN_smNoAlertMem (No memory for alert.hook module)";
  717.     case 0x40000007:
  718.       return "AN_smSuperTaskSwitch (TaskSwitch in Supervisor mode)";
  719.  
  720.     case 0x50010001:        /* vdisk.device alerts */
  721.       return "AN_VDRootMem (No memory for root structure)";
  722.     case 0x50010002:
  723.       return "AN_VDUnitMem (No memory for unit structure)";
  724.     case 0x50010003:
  725.       return "AN_VDReAlloc (Memory reallocation failed)";
  726.     case 0x50010004:
  727.       return "AN_VDAllocAbs (AllocAbs failed in AllocReverse)";
  728.     case 0x50000005:
  729.       return "AN_VDBadStartup (Error in Unit Startup)";
  730.     case 0x50010006:
  731.       return "AN_VDBadRootLoc (Root Structure in bad memory)";
  732.  
  733.     case 0x70000001:        /* ErrorLogD alerts */
  734.       return "AN_elBadMessage (Unexpected message at HellGate)";
  735.     case 0x700B0002:
  736.       return "AN_elLoggerFail (Couldn't start logger process)";
  737.     case 0x70000003:
  738.       return "AN_elNoHellGate (Couldn't find HellGate semaphore)";
  739.     case 0x70000004:
  740.       return "AN_elBadEvilLst (Evil List is corrupted)";
  741.     case 0x70000005:
  742.       return "AN_elNoDoomNode (Couldn't find DoomNode)";
  743.  
  744.     default:
  745.       if (num & 0x00008000) return "(Generic alert)";
  746.       else return "(Unknown alert code)";
  747.   }
  748. }
  749.  
  750. static char *cpustr(UWORD cpuflags)
  751. {
  752.   if (cpuflags & AFF_68060) return "68060";
  753.   else if (cpuflags & AFF_68040) return "68040";
  754.   else if (cpuflags & AFF_68030) return "68030";
  755.   else if (cpuflags & AFF_68020) return "68020";
  756.   else if (cpuflags & AFF_68010) return "68010";
  757.   else return "68000";
  758. }
  759.