* sim/ucsim/cmd.src/error.cc, sim/ucsim/cmd.src/errorcl.h,
[fw/sdcc] / sim / ucsim / sim.src / mem.cc
index 7d9a780fdc15ff321c9e40a6e739a28eeca0aa30..de49f02e679d4d4d3a874f11f24433863d75ded1 100644 (file)
@@ -41,6 +41,7 @@
 
 // cmd
 #include "newcmdcl.h"
+#include "cmdutil.h"
 
 // local
 #include "memcl.h"
@@ -1375,62 +1376,60 @@ cl_decoder_list::compare(void *key1, void *key2)
  */
 
 /* All of memory errors */
-ERROR_CLASS_DEF_PARENT_ON(err_error, mem, "memory",
-                         error_class_base, ERROR_ON);
+
+class cl_error_class *cl_error_mem::error_mem_class;
 
 cl_error_mem::cl_error_mem(class cl_memory *amem, t_addr aaddr)
 {
   mem= amem;
   addr= aaddr;
-  classification= &error_mem_class;
+  if (NULL == error_mem_class)
+    error_mem_class= new cl_error_class(err_error, "memory", classification, ERROR_OFF);
+  classification= error_mem_class;
 }
 
 /* Invalid address in memory access */
-ERROR_CLASS_DEF_PARENT(err_error,
-                      mem_invalid_address,
-                      "invalid_address",
-                      error_mem_class);
+
+class cl_error_class *cl_error_mem_invalid_address::error_mem_invalid_address_class;
 
 cl_error_mem_invalid_address::
 cl_error_mem_invalid_address(class cl_memory *amem, t_addr aaddr):
   cl_error_mem(amem, aaddr)
 {
-  classification= &error_mem_invalid_address_class;
+  if (NULL == error_mem_invalid_address_class)
+    error_mem_invalid_address_class= new cl_error_class(err_error, "invalid_address", classification);
+  classification= error_mem_invalid_address_class;
 }
 
 void
 cl_error_mem_invalid_address::print(class cl_commander *c)
 {
-  c->dd_printf(get_type_name());
-  c->dd_printf(": invalid address ", get_type_name());
-  c->dd_printf(mem->addr_format, addr);
-  c->dd_printf(" in memory ");
-  c->dd_printf(mem->get_name());
-  c->dd_printf(".\n");
+  FILE *f= c->get_out();
+  cmd_fprintf(f, "%s: invalid address ", get_type_name());
+  cmd_fprintf(f, mem->addr_format, addr);
+  cmd_fprintf(f, " in memory %s.\n", mem->get_name());
 }
 
 /* Non-decoded address space access */
-ERROR_CLASS_DEF_PARENT(err_error,
-                      mem_non_decoded,
-                      "non_decoded",
-                      error_mem_class);
+
+class cl_error_class *cl_error_mem_non_decoded::error_mem_non_decoded_class;
 
 cl_error_mem_non_decoded::
 cl_error_mem_non_decoded(class cl_memory *amem, t_addr aaddr):
   cl_error_mem(amem, aaddr)
 {
-  classification= &error_mem_non_decoded_class;
+  if (NULL == error_mem_non_decoded_class)
+    error_mem_non_decoded_class= new cl_error_class(err_error, "non_decoded", classification);
+  classification= error_mem_non_decoded_class;
 }
 
 void
 cl_error_mem_non_decoded::print(class cl_commander *c)
 {
-  c->dd_printf(get_type_name());
-  c->dd_printf(": access of non-decoded address ");
-  c->dd_printf(mem->addr_format, addr);
-  c->dd_printf(" in memory ");
-  c->dd_printf(mem->get_name());
-  c->dd_printf(".\n");
+  FILE *f= c->get_out();
+  cmd_fprintf(f, "%s: access of non-decoded address ", get_type_name());
+  cmd_fprintf(f, mem->addr_format, addr);
+  cmd_fprintf(f, " in memory %s.\n", mem->get_name());
 }