dtinfo subdirectory DtMmdb

This commit is contained in:
Ulrich Wilkens
2013-08-28 19:16:37 +02:00
committed by Jon Trulson
parent 0be684281d
commit fbd81ef151
159 changed files with 735 additions and 588 deletions

View File

@@ -40,7 +40,7 @@ char *Exception::g_next_avail = Exception::g_temp_space;
// /////////////////////////////////////////////////////////////////
Exception::Exception()
: f_line(0), f_thrown_as_pointer(1), f_thrown(0), f_temporary(0)
: f_thrown(0), f_thrown_as_pointer(1), f_temporary(0), f_line(0)
{
PRINTF (("Constructed Exception obj @ %p\n", this));
}
@@ -76,19 +76,17 @@ Exception::operator delete (void *place)
void *
Exception::operator new (size_t size, int)
{
if (g_next_avail + size <= g_temp_space + G_TEMP_SPACE_SIZE)
{
void *p = g_next_avail;
g_next_avail += size;
PRINTF (("Allocate EXC @ %p, size = %ld\n", p, (long)size));
return (p);
}
else
if (g_next_avail + size > g_temp_space + G_TEMP_SPACE_SIZE)
{
Exceptions::error (Exceptions::f_msg_out_of_exception_memory,
Exceptions::INTERNAL_ERROR);
terminate();
}
void *p = g_next_avail;
g_next_avail += size;
PRINTF (("Allocate EXC @ %p, size = %ld\n", p, (long)size));
return (p);
}
@@ -248,8 +246,8 @@ Exception::is (const char *type, const char *this_class)
PRINTF ((" var part is <%s>\n", type));
// See if one's a pointer and the other isn't.
if (*type == '*' && !f_thrown_as_pointer ||
*type != '*' && f_thrown_as_pointer)
if ((*type == '*' && !f_thrown_as_pointer) ||
(*type != '*' && f_thrown_as_pointer))
return (0);
// Otherwise they are either both pointers or both objects/references.
return (1);

View File

@@ -162,28 +162,35 @@ Exceptions::set_error_handler (error_handler_t error_handler)
void
Exceptions::error (const char *message, error_type_t error_type)
{
static char buffer[3][100];
unsigned int bufferlen = 100;
char buffer[3][bufferlen];
static char *lines[3] = { buffer[0], buffer[1], buffer[2] };
int count = 0;
int len, count = 0;
if (error_type == INTERNAL_ERROR)
strcpy (buffer[count++], f_msg_internal_error);
else if (error_type == APPLICATION_ERROR)
strcpy (buffer[count++], f_msg_application_error);
else
strcpy (buffer[count++], f_msg_throw_message);
if (error_type == INTERNAL_ERROR) {
len = MIN(strlen(f_msg_internal_error), bufferlen - 1);
*((char *) memcpy(buffer[count++], f_msg_internal_error, len) + len) = '\0';
}
else if (error_type == APPLICATION_ERROR) {
len = MIN(strlen(f_msg_application_error), bufferlen - 1);
*((char *) memcpy(buffer[count++], f_msg_application_error,len)+len) = '\0';
}
else {
len = MIN(strlen(f_msg_throw_message), bufferlen - 1);
*((char *) memcpy(buffer[count++], f_msg_throw_message, len) + len) = '\0';
}
// Don't use fprintf because it may try to allocate memory.
if (Exception::g_current_exception != NULL)
{
sprintf (buffer[count++],
snprintf (buffer[count++], bufferlen,
" In exception thrown in file \"%s\", line %d,",
Exception::g_current_exception->f_file,
Exception::g_current_exception->f_line);
}
if (message != NULL)
sprintf (buffer[count++], " %s", message);
snprintf (buffer[count++], bufferlen, " %s", message);
// Call user print function if set, otherwise just dump lines.
if (g_error_handler != NULL)

View File

@@ -4,6 +4,9 @@
#define _Exceptions_hh_active
#undef MIN
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
#ifndef C_API
#ifndef NATIVE_EXCEPTIONS
#define NATIVE_EXCEPTIONS
@@ -48,6 +51,16 @@ extern "C" {
#endif
#endif
#ifndef UNUSED_VARIABLE
# if defined(__GNUC__)
# define UNUSED_VARIABLE(x) x __attribute__((unused))
# elif defined(__LCLINT__)
# define UNUSED_VARIABLE(x) /*@unused@*/ x
# else
# define UNUSED_VARIABLE(x) x
# endif
#endif
#endif /* NATIVE_EXCEPTIONS */
#include "terminate.hh"
@@ -130,7 +143,7 @@ extern "C" {
#define mcatch(TYPE,OBJ) \
mcatch_noarg (TYPE) \
TYPE OBJ = (TYPE) Exception::current_exception();
TYPE UNUSED_VARIABLE(OBJ) = (TYPE) Exception::current_exception();
#define end_try \
} else { \

View File

@@ -44,7 +44,7 @@ Unwind_Record Unwind_Stack::g_stack[UNWIND_STACK_SIZE];
// /////////////////////////////////////////////////////////////////
Jump_Environment::Jump_Environment()
: f_unwinding (0), f_active_exception (NULL)
: f_active_exception (NULL), f_unwinding (0)
{
PRINTF (("<%d> New Jump_Environment @ %p\n", ++g_level, this));
// Push this on to the top of the jump env stack.