CrashLib Copyright (C) 2002 By Gregory Dietsche.
Version: 1.0b

Description:

This is compile time library which attempts to provide flexible anti-crash support for TIGCC - C language programs. It has been designed to be friendly to novice users, and to provide powerful advanced features for experienced programmers. This library can be especially useful when debugging programs.

How To Use:

Quick Start:

  1. Enable exit support. This means removing #define NO_EXIT_SUPPORT from your project.
  2. Add crash.h and crash.a to your project.
  3. #include "crash.h" after tigcclib.h
  4. Choose, or write your own HUD function to use when recovering from a crash.
  5. Immediately after variable declarations in your _main function, place this code: AntiCrashProtection(myHUDFunc); where MyHUDFunc is the previously chosen function. An example would be AntiCrashProtection(Crash_Debug_HUD);
  6. Write your program :)
  7. Before releasing your program, remove crashlib (a well written and debugged program should not need it).

What is a HUD function?

A HUD is an acronym for Heads Up Display. Normally, a HUD's are associated with games, but in this case, it is slightly different. A HUD from the point of view of CrashLib is a simple function that does not return a value which can display information in the event of a crash. All HUD functions should be declared returning void, and the parameter list should either be CRASH_RECOVERY_STATE* state, or void.

The HUD is not limited to just a graphical display. It could be a function that outputs information to the link port, or to a file for debugging. Be creative!

HUD's are run in user mode with an interrupt mask of 0.

Example HUD function prototypes:

void MyHUD(void);
void MyHUD(CRASH_RECOVERY_STATE *state);

What CrashLib Does:
CrashLib recovers all errors listed in Table 1. It also makes a backup of auto-interrupts 1,2,3,4,5,6 exception vectors, and restores them when the calling program terminates (either normally, or through a crash).

Table 1: Errors Recovered by CrashLib
Address Error
Divide by Zero
Illegal Instruction TRAPV Instruction
CHK Instruction Trace Interrupt
Privilege Violation Protected Memory Violation
Spurious Interrupt Trap #6
Trap #5 Trap #13
Trap #7 Trap #15
Trap #14

 

Data Structures

typedef struct
{
unsigned long a7; /* Registers a0-a7/d0-d7 */
unsigned long d0;
unsigned long d1;
unsigned long d2;
unsigned long d3;
unsigned long d4;
unsigned long d5;
unsigned long d6;
unsigned long d7;
unsigned long a0;
unsigned long a1;
unsigned long a2;
unsigned long a3;
unsigned long a4;
unsigned long a5;
unsigned long a6;
const unsigned char frametype; /*see the 'frame' union of this data structure*/
unsigned char crashtype; /* A Number That Corresponds With gCrashLibText */

union {

struct {
unsigned short sr; /* STATUS REGISTER */
unsigned long pc; /* PROGRAM COUNTER */
}type_else; /* Error Frame Types 1,2,4 */

struct {
unsigned short flags; /* only bits 0-4 are used */
unsigned long address; /* ACCESS ADDRESS */
unsigned short ir; /* INSTRUCTION REGISTER */
unsigned short SR; /* STATUS REGISTER */
unsigned long PC; /* PROGRAM COUNTER */
}type_zero; /* Error Frame Type 0 */

}frame;

}CRASH_RECOVERY_STATE;

LEGAL INFORMATION

The author makes no representations or warranties about the suitability of the software, either express or implied. The author shall not be liable for any damages suffered as a result of using or distributing this software. Any program that makes uses of routines from this library should explicitly state that fact in the readme.

This library is shareware. I am asking that you, the developer, sign the guest book located at my website as payment instead. The goal of this is to have an easy electronic form of the 'postcard'. Thank you in advance :)

Other Information
This library was compiled using TIGCC version 0.94 SP3.
The most current version of CrashLib and its full source code can be found at: http://calc.gregd.org/download.php?what=crashlib

Library History

04/04/2002 - Initial Beta Release
04/07/2002 - Beta 3 Released
04/08/2002 - Beta 4 Released
04/12/2002 - Beta 5 Released
04/12/2002 - Beta 6 (Release Candidate) Released
04/13/2002 - Beta 7 Small Bug fixes to Beta 6
06/14/2002 - Version 1.0 (its been rotting on my hd for a few months :)
07/17/2002 - Version 1.0a removes handling of Bus Errors -- They can't happen on the current 68k calcs...
01/18/2003 - Version 1.0b some minor code changes to work with the TIGCC version 0.94 series