error.cpp 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /****************************************************************************
  2. * dcc project error messages
  3. * (C) Cristina Cifuentes
  4. ***************************************************************************/
  5. #include "dcc.h"
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. //#ifndef __UNIX__
  9. #if 1
  10. #include <stdarg.h>
  11. #else
  12. #include <varargs.h>
  13. #endif
  14. static const char *errorMessage[] = {
  15. "Invalid option -%c\n", /* INVALID_ARG */
  16. "Invalid instruction %02X at location %06lX\n", /* INVALID_OPCODE */
  17. "Don't understand 80386 instruction %02X at location %06lX\n",
  18. /* INVALID_386OP */
  19. "Segment override with no memory operand at location %06lX\n",
  20. /* FUNNY_SEGOVR */
  21. "REP prefix without a string instruction at location %06lX\n",/* FUNNY_REP */
  22. "Cannot open %s\n", /* CANNOT_OPEN */
  23. "Error while reading %s\n", /* CANNOT_READ */
  24. "malloc of %ld bytes failed\n", /* MALLOC_FAILED */
  25. "Don't understand new EXE format\n", /* NEWEXE_FORMAT */
  26. "Failed to find a BB for jump to %ld in proc %s\n", /* NO_BB */
  27. "Basic Block is a synthetic jump\n", /* INVALID_SYNTHETIC_BB */
  28. "Failed to find a BB for interval\n", /* INVALID_INT_BB */
  29. "Instruction at location %06lX goes beyond loaded image\n",
  30. /* IP_OUT_OF_RANGE*/
  31. "Definition not found for condition code usage at opcode %d\n",
  32. /* DEF_NOT_FOUND */
  33. "JX use, definition not supported at opcode #%d\n", /* JX_NOT_DEF */
  34. "Def - use not supported. Def op = %d, use op = %d.\n", /* NOT_DEF_USE */
  35. "Failed to construct repeat..until() condition.\n", /* REPEAT_FAIL */
  36. "Failed to construct while() condition.\n", /* WHILE_FAIL */
  37. };
  38. /****************************************************************************
  39. fatalError: displays error message and exits the program.
  40. ****************************************************************************/
  41. void fatalError(Int errId, ...)
  42. { va_list args;
  43. //#ifdef __UNIX__ /* ultrix */
  44. #if 0
  45. Int errId;
  46. va_start(args);
  47. errId = va_arg(args, Int);
  48. #else
  49. va_start(args, errId);
  50. #endif
  51. if (errId == USAGE)
  52. fprintf(stderr,"Usage: dcc [-a1a2cmpsvVi][-o asmfile] DOS_executable\n");
  53. else {
  54. fprintf(stderr, "dcc: ");
  55. vfprintf(stderr, errorMessage[errId - 1], args);
  56. }
  57. va_end(args);
  58. exit((int)errId);
  59. }
  60. /****************************************************************************
  61. reportError: reports the warning/error and continues with the program.
  62. ****************************************************************************/
  63. void reportError(Int errId, ...)
  64. { va_list args;
  65. //#ifdef __UNIX__ /* ultrix */
  66. #if 0
  67. Int errId;
  68. va_start(args);
  69. errId = va_arg(args, Int);
  70. #else /* msdos or windows*/
  71. va_start(args, errId);
  72. #endif
  73. fprintf(stderr, "dcc: ");
  74. vfprintf(stderr, errorMessage[errId - 1], args);
  75. va_end(args);
  76. }