Fix management of watched expressions.

[GB.DEBUG]
* BUG: Fix comparison routine of watched expressions.
* BUG: Initialize the stack context correctly when checking watched expressions.
This commit is contained in:
gambas 2021-06-01 18:14:54 +02:00
parent e4dffc8ae8
commit e3af76ce15

View file

@ -772,6 +772,26 @@ static void debug_info()
fprintf(_out, "\n"); fprintf(_out, "\n");
} }
static void set_info(STACK_CONTEXT *context)
{
if (context)
{
DEBUG_info.bp = context->bp;
DEBUG_info.pp = context->pp;
DEBUG_info.fp = context->fp;
DEBUG_info.op = context->op;
DEBUG_info.cp = context->cp;
}
else
{
DEBUG_info.bp = BP;
DEBUG_info.pp = PP;
DEBUG_info.fp = FP;
DEBUG_info.op = OP;
DEBUG_info.cp = CP;
}
}
static void command_frame(char *cmd) static void command_frame(char *cmd)
{ {
int i; int i;
@ -795,27 +815,12 @@ static void command_frame(char *cmd)
frame--; frame--;
if (!frame) if (!frame)
{
DEBUG_info.bp = context->bp;
DEBUG_info.pp = context->pp;
DEBUG_info.fp = context->fp;
DEBUG_info.op = context->op;
DEBUG_info.cp = context->cp;
break; break;
} }
} }
} }
}
if (!context)
{
DEBUG_info.bp = BP;
DEBUG_info.pp = PP;
DEBUG_info.fp = FP;
DEBUG_info.op = OP;
DEBUG_info.cp = CP;
}
set_info(context);
debug_info(); debug_info();
} }
@ -938,6 +943,7 @@ static int add_watch(int id, EXPRESSION *expr, VALUE *value)
DEBUG_WATCH *watch = (DEBUG_WATCH *)GB.Add(&_watches); DEBUG_WATCH *watch = (DEBUG_WATCH *)GB.Add(&_watches);
watch->id = id; watch->id = id;
watch->expr = expr; watch->expr = expr;
if (value)
watch->value = *value; watch->value = *value;
return GB.Count(_watches) - 1; return GB.Count(_watches) - 1;
} }
@ -1325,10 +1331,10 @@ static bool compare_values(VALUE *a, VALUE *b)
&&__DATE, &&__STRING, &&__STRING, &&__POINTER, &&__VARIANT, &&__FUNCTION, &&__CLASS, &&__NULL &&__DATE, &&__STRING, &&__STRING, &&__POINTER, &&__VARIANT, &&__FUNCTION, &&__CLASS, &&__NULL
}; };
/*void *vjump[] = { void *vjump[] = {
__VOID, __VBOOLEAN, __VBYTE, __VSHORT, __VINTEGER, __VLONG, __VSINGLE, __VFLOAT, &&__VOID, &&__VBOOLEAN, &&__VBYTE, &&__VSHORT, &&__VINTEGER, &&__VLONG, &&__VSINGLE, &&__VFLOAT,
__VDATE, __VSTRING, __VSTRING, __VPOINTER, __VOID, __VOID, __VOID, __VOID &&__VDATE, &&__VSTRING, &&__VSTRING, &&__VPOINTER, &&__VOID, &&__VOID, &&__VOID, &&__VOID
};*/ };
if (a->type != b->type) if (a->type != b->type)
return TRUE; return TRUE;
@ -1369,11 +1375,26 @@ __CLASS:
__FUNCTION: __FUNCTION:
return a->_function.class != b->_function.class || a->_function.object != b->_function.object || a->_function.index != b->_function.index; return a->_function.class != b->_function.class || a->_function.object != b->_function.object || a->_function.index != b->_function.index;
__VARIANT: __VARIANT:
return a->_variant.vtype != b->_variant.vtype || a->_variant.value.data != b->_variant.value.data; if (a->_variant.vtype != b->_variant.vtype)
return TRUE;
if (TYPE_is_object(a->_variant.vtype))
goto __VOBJECT;
else
goto *vjump[a->_variant.vtype];
__VBOOLEAN: return a->_variant.value._boolean != b->_variant.value._boolean;
__VBYTE: return a->_variant.value._byte != b->_variant.value._byte;
__VSHORT: return a->_variant.value._short != b->_variant.value._short;
__VINTEGER: return a->_variant.value._integer != b->_variant.value._integer;
__VDATE: __VLONG: return a->_variant.value._long != b->_variant.value._long;
__VSINGLE: return a->_variant.value._single!= b->_variant.value._single;
__VFLOAT: return a->_variant.value._float != b->_variant.value._float;
__VPOINTER: __VOBJECT: __VSTRING: return a->_variant.value._string != b->_variant.value._string;
} }
bool DEBUG_check_watches(void) bool DEBUG_check_watches(void)
{ {
int i; int i;
@ -1384,6 +1405,8 @@ bool DEBUG_check_watches(void)
ERROR_INFO save_last = { 0 }; ERROR_INFO save_last = { 0 };
DEBUG_INFO save_debug; DEBUG_INFO save_debug;
set_info(NULL);
GB_DEBUG.SaveError(&save_error, &save_last); GB_DEBUG.SaveError(&save_error, &save_last);
save_debug = DEBUG_info; save_debug = DEBUG_info;