[go: up one dir, main page]

Menu

[897c37]: / lpvm / fatal.c  Maximize  Restore  History

Download this file

108 lines (92 with data), 2.7 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
/*
** $Id: fatal.c,v 1.3 2012/06/10 13:08:19 dredd Exp $
**
** $Source: /cvsroot/swlpc/swlpc/lpvm/fatal.c,v $
** $Revision: 1.3 $
** $Date: 2012/06/10 13:08:19 $
** $State: Exp $
**
** Author: Mike McGaughey & Geoff Wong, 1993-1998
** geoff.wong@gmail.com
**
** See the file "Copying" distributed with this file.
*/
#include <stdlib.h>
#include "fatal.h"
#include "error.h"
/*
** Should be fixed to abort the stack machine execution
** and return an error to the calling program.
*/
void fatal(const char *fmt,...)
{
static int in_fatal = 0;
/* Prevent double fatal. */
va_list args;
if (in_fatal)
{
va_start(args, fmt);
(void) fprintf(errstream, "FATAL: recursed\n");
fclose(errstream);
abort();
}
in_fatal = 1;
outputbt();
va_start(args, fmt);
(void) vfprintf(errstream, fmt, args);
va_end(args);
#if 0
if (errstream && current_object)
{
fprintf(errstream, fmt, args);
fprintf(errstream, "Current object was %s\n", current_object->name);
fprintf(errstream, "Dump of variables:\n");
if (current_object)
{
int p;
for (p = 0; p < current_object->num_variables; p++)
{
Val *v;
#if 1
fprintf(errstream, "%20s: ",
currentO->global_table[p]->u.string);
v = (&currentO->variables[p]);
#endif
if (v == 0)
{
fprintf(errstream, "<NULL>");
continue;
}
switch (v->type)
{
case T_NUMBER:
fprintf(errstream, "%d", v->u.number);
break;
case T_REAL:
fprintf(errstream, "%f", v->u.real);
break;
case T_STRING:
fprintf(errstream, "\"%s\"", v->u.string);
break;
case T_POINTER:
fprintf(errstream, "Array(you want me to print it?");
break;
case T_OBJECT:
fprintf(errstream, "OBJ(%s)", v->u.ob->name);
break;
default:
fprintf(errstream, "<INVALID TYPE>\n");
return;
}
fprintf(errstream, "\n");
}
}
}
#endif
#if 0
ipc_remove(); /* Shut down the ipc communication. */
#endif
fclose(errstream);
abort();
/*forced_ */ exit(0);
}