summaryrefslogtreecommitdiffhomepage
path: root/mixlib
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2001-07-21 22:54:44 +0000
committerJose Antonio Ortega Ruiz <jao@gnu.org>2001-07-21 22:54:44 +0000
commit19f0e186c8ee299609f8cee531b8d1db73ad8d83 (patch)
treee6f1bcccb6504b7d6fd58ca49ff47903f1ffd261 /mixlib
parenta015c1927fcf697584b19de728d27be5395b1f81 (diff)
downloadmdk-19f0e186c8ee299609f8cee531b8d1db73ad8d83.tar.gz
mdk-19f0e186c8ee299609f8cee531b8d1db73ad8d83.tar.bz2
conditional breakpoints finished
Diffstat (limited to 'mixlib')
-rw-r--r--mixlib/mix_predicate.c6
-rw-r--r--mixlib/mix_predicate_list.c14
-rw-r--r--mixlib/mix_predicate_list.h2
-rw-r--r--mixlib/mix_vm.c17
-rw-r--r--mixlib/mix_vm.h4
-rw-r--r--mixlib/mix_vm_command.c31
6 files changed, 44 insertions, 30 deletions
diff --git a/mixlib/mix_predicate.c b/mixlib/mix_predicate.c
index 544da64..38049dc 100644
--- a/mixlib/mix_predicate.c
+++ b/mixlib/mix_predicate.c
@@ -165,12 +165,12 @@ mix_predicate_get_message (const mix_predicate_t *predicate)
switch (predicate->type)
{
case MIX_PRED_REG_A:
- snprintf (BUFFER, SIZE, "Register A changed to %s%d",
+ snprintf (BUFFER, SIZE, "Register A changed to %s%ld",
mix_word_is_negative (predicate->data.regA)? "-" : "+",
mix_word_magnitude (predicate->data.regA));
break;
case MIX_PRED_REG_X:
- snprintf (BUFFER, SIZE, "Register X changed to %s%d",
+ snprintf (BUFFER, SIZE, "Register X changed to %s%ld",
mix_word_is_negative (predicate->data.regX)? "-" : "+",
mix_word_magnitude (predicate->data.regX));
break;
@@ -194,7 +194,7 @@ mix_predicate_get_message (const mix_predicate_t *predicate)
predicate->data.over ? "ON" : "OFF");
break;
case MIX_PRED_MEM:
- snprintf (BUFFER, SIZE, "Memory address %d changed to %s%d",
+ snprintf (BUFFER, SIZE, "Memory address %d changed to %s%ld",
predicate->control,
mix_word_is_negative (predicate->data.mem)? "-" : "+",
mix_word_magnitude (predicate->data.mem));
diff --git a/mixlib/mix_predicate_list.c b/mixlib/mix_predicate_list.c
index 3e4fe08..42f6ea6 100644
--- a/mixlib/mix_predicate_list.c
+++ b/mixlib/mix_predicate_list.c
@@ -85,13 +85,19 @@ mix_predicate_list_add (mix_predicate_list_t *list, mix_predicate_t *predicate)
(void)mix_predicate_eval (predicate, list->vm);
}
-void
+gboolean
mix_predicate_list_remove (mix_predicate_list_t *list,
mix_predicate_t *predicate)
{
- g_return_if_fail (list != NULL);
- g_return_if_fail (predicate != NULL);
- list->predicates = g_slist_remove (list->predicates, predicate);
+ g_return_val_if_fail (list != NULL, FALSE);
+ g_return_val_if_fail (predicate != NULL, FALSE);
+ if (g_slist_find (list->predicates, predicate))
+ {
+ list->predicates = g_slist_remove (list->predicates, predicate);
+ return TRUE;
+ }
+ else
+ return FALSE;
}
void
diff --git a/mixlib/mix_predicate_list.h b/mixlib/mix_predicate_list.h
index 416f3db..3d22028 100644
--- a/mixlib/mix_predicate_list.h
+++ b/mixlib/mix_predicate_list.h
@@ -50,7 +50,7 @@ mix_predicate_list_last_true_eval (const mix_predicate_list_t *list);
extern void
mix_predicate_list_add (mix_predicate_list_t *list, mix_predicate_t *predicate);
-extern void
+extern gboolean
mix_predicate_list_remove (mix_predicate_list_t *list,
mix_predicate_t *predicate);
diff --git a/mixlib/mix_vm.c b/mixlib/mix_vm.c
index 8929527..0e9f61b 100644
--- a/mixlib/mix_vm.c
+++ b/mixlib/mix_vm.c
@@ -601,22 +601,21 @@ mix_vm_clear_all_breakpoints (mix_vm_t *vm)
}
-gint
+gboolean
mix_vm_set_conditional_breakpoint (mix_vm_t *vm, mix_predicate_t *pred)
{
- g_return_val_if_fail (vm != NULL, MIX_VM_BP_ERROR);
- g_return_val_if_fail (pred != NULL, MIX_VM_BP_ERROR);
+ g_return_val_if_fail (vm != NULL, FALSE);
+ g_return_val_if_fail (pred != NULL, FALSE);
mix_predicate_list_add (get_pred_list_ (vm), pred);
- return MIX_VM_BP_OK;
+ return TRUE;
}
-gint
+gboolean
mix_vm_clear_conditional_breakpoint (mix_vm_t *vm, mix_predicate_t *pred)
{
- g_return_val_if_fail (vm != NULL, MIX_VM_BP_ERROR);
- g_return_val_if_fail (pred != NULL, MIX_VM_BP_ERROR);
- mix_predicate_list_remove (get_pred_list_ (vm), pred);
- return MIX_VM_BP_OK;
+ g_return_val_if_fail (vm != NULL, FALSE);
+ g_return_val_if_fail (pred != NULL, FALSE);
+ return mix_predicate_list_remove (get_pred_list_ (vm), pred);
}
const gchar *
diff --git a/mixlib/mix_vm.h b/mixlib/mix_vm.h
index 663062b..d0403cc 100644
--- a/mixlib/mix_vm.h
+++ b/mixlib/mix_vm.h
@@ -207,10 +207,10 @@ extern void
mix_vm_clear_all_breakpoints (mix_vm_t *vm);
#include "mix_predicate.h"
-extern gint
+extern gboolean
mix_vm_set_conditional_breakpoint (mix_vm_t *vm, mix_predicate_t *pred);
-extern gint
+extern gboolean
mix_vm_clear_conditional_breakpoint (mix_vm_t *vm, mix_predicate_t *pred);
extern const gchar *
diff --git a/mixlib/mix_vm_command.c b/mixlib/mix_vm_command.c
index 0dc56c5..0a3091a 100644
--- a/mixlib/mix_vm_command.c
+++ b/mixlib/mix_vm_command.c
@@ -1571,10 +1571,12 @@ cmd_cbpr_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
mix_predicate_type_t pred = get_reg_pred_ (arg);
if (pred != INVALID_REG_)
{
- mix_vm_clear_conditional_breakpoint (dis->vm, dis->preds[pred]);
- fprintf (dis->out,
- _("Conditional breakpoint on r%s change removed\n"),
- arg);
+ if (mix_vm_clear_conditional_breakpoint (dis->vm, dis->preds[pred]))
+ fprintf (dis->out,
+ _("Conditional breakpoint on r%s change removed\n"),
+ arg);
+ else
+ fprintf (dis->err, _("No breakpoint set on r%s change\n"), arg);
return TRUE;
}
else
@@ -1643,7 +1645,7 @@ cmd_sbpo_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
{
mix_vm_set_conditional_breakpoint (dis->vm, dis->preds[MIX_PRED_OVER]);
fprintf (dis->out,
- _("Conditional breakpoint on overflow toggled set.\n"));
+ _("Conditional breakpoint on overflow toggled set\n"));
}
return TRUE;
}
@@ -1655,9 +1657,12 @@ cmd_cbpo_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
fprintf (dis->err, _("Unexpected argument: %s\n"), arg);
else
{
- mix_vm_clear_conditional_breakpoint (dis->vm, dis->preds[MIX_PRED_OVER]);
- fprintf (dis->out,
- _("Conditional breakpoint on overflow toggled removed.\n"));
+ if (mix_vm_clear_conditional_breakpoint
+ (dis->vm, dis->preds[MIX_PRED_OVER]))
+ fprintf (dis->out,
+ _("Conditional breakpoint on overflow toggled removed.\n"));
+ else
+ fprintf (dis->err, _("No breakpoint set on overflow toggle\n"));
}
return TRUE;
}
@@ -1683,9 +1688,13 @@ cmd_cbpc_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
fprintf (dis->err, _("Unexpected argument: %s\n"), arg);
else
{
- mix_vm_clear_conditional_breakpoint (dis->vm, dis->preds[MIX_PRED_CMP]);
- fprintf (dis->out,
- _("Conditional breakpoint on comparison flag changed removed.\n"));
+ if (mix_vm_clear_conditional_breakpoint
+ (dis->vm, dis->preds[MIX_PRED_CMP]))
+ fprintf
+ (dis->out,
+ _("Conditional breakpoint on comparison flag changed removed.\n"));
+ else
+ fprintf (dis->err, _("No breakpoint set on comparison flag change\n"));
}
return TRUE;
}