mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-15 01:13:30 +00:00
Make an mdb error message more informative.
trace/mercury_trace_internal.c:
Whe printing the "there is no such variable" message at
conditional break points, print the name of the variable.
The original message can be misread to mean that there
is nothing at *the selected path*; the new one cannot.
trace/mercury_trace_spy.c:
trace/mercury_trace_spy.h:
Add a mechanism to enable the above change.
tests/debugger/cond.exp:
Expect the updated error message.
This commit is contained in:
@@ -213,11 +213,22 @@ MR_trace_event_internal(MR_TraceCmdInfo *cmd, MR_bool interactive,
|
||||
MR_trace_listing_path_ensure_init();
|
||||
|
||||
if (MR_spy_point_cond_problem != NULL) {
|
||||
const char *cond_var_name;
|
||||
|
||||
fprintf(MR_mdb_err, "mdb: couldn't evaluate break point condition\n");
|
||||
fprintf(MR_mdb_err, " ");
|
||||
MR_print_spy_cond(MR_mdb_err, MR_spy_point_cond_bad);
|
||||
MR_print_spy_cond(MR_mdb_err, MR_spy_point_cond_bad, &cond_var_name);
|
||||
fprintf(MR_mdb_err, ".\n");
|
||||
fprintf(MR_mdb_err, "The error is: %s.\n", MR_spy_point_cond_problem);
|
||||
if (MR_streq(MR_spy_point_cond_problem, "there is no such variable") &&
|
||||
cond_var_name != NULL)
|
||||
{
|
||||
fprintf(MR_mdb_err,
|
||||
"The error is: there is no variable named %s.\n",
|
||||
cond_var_name);
|
||||
} else {
|
||||
fprintf(MR_mdb_err,
|
||||
"The error is: %s.\n", MR_spy_point_cond_problem);
|
||||
}
|
||||
MR_spy_point_cond_bad = NULL;
|
||||
MR_spy_point_cond_problem = NULL;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// vim: ts=4 sw=4 expandtab ft=c
|
||||
|
||||
// Copyright (C) 1998-2002, 2005-2008, 2011 The University of Melbourne.
|
||||
// Copyright (C) 2014-2016, 2018 The Mercury team.
|
||||
// Copyright (C) 2014-2016, 2018, 2025 The Mercury team.
|
||||
// This file is distributed under the terms specified in COPYING.LIB.
|
||||
|
||||
// This file contains code to manage spy points for both
|
||||
@@ -1076,6 +1076,7 @@ MR_print_spy_point(FILE *fp, int spy_point_num, MR_bool verbose)
|
||||
MR_SpyPoint *point;
|
||||
MR_SpyCond *cond;
|
||||
MR_TracePort port;
|
||||
const char *ignored_cond_var_name;
|
||||
|
||||
point = MR_spy_points[spy_point_num];
|
||||
fprintf(fp, "%2d: %1s %-5s %-9s ",
|
||||
@@ -1157,7 +1158,7 @@ MR_print_spy_point(FILE *fp, int spy_point_num, MR_bool verbose)
|
||||
fprintf(fp, "-p ");
|
||||
}
|
||||
|
||||
MR_print_spy_cond(fp, cond);
|
||||
MR_print_spy_cond(fp, cond, &ignored_cond_var_name);
|
||||
fprintf(fp, "\n");
|
||||
}
|
||||
|
||||
@@ -1216,24 +1217,28 @@ MR_print_spy_point(FILE *fp, int spy_point_num, MR_bool verbose)
|
||||
}
|
||||
|
||||
void
|
||||
MR_print_spy_cond(FILE *fp, MR_SpyCond *cond)
|
||||
MR_print_spy_cond(FILE *fp, MR_SpyCond *cond, const char **name)
|
||||
{
|
||||
switch (cond->MR_cond_var_spec.MR_var_spec_kind) {
|
||||
case MR_VAR_SPEC_NUMBER:
|
||||
fprintf(fp, "%" MR_INTEGER_LENGTH_MODIFIER "u",
|
||||
cond->MR_cond_var_spec.MR_var_spec_number);
|
||||
*name = NULL;
|
||||
break;
|
||||
|
||||
case MR_VAR_SPEC_NAME:
|
||||
fprintf(fp, "%s", cond->MR_cond_var_spec.MR_var_spec_name);
|
||||
*name = cond->MR_cond_var_spec.MR_var_spec_name;
|
||||
fprintf(fp, "%s", *name);
|
||||
break;
|
||||
|
||||
case MR_VAR_SPEC_HELD_NAME:
|
||||
fprintf(fp, "$%s", cond->MR_cond_var_spec.MR_var_spec_name);
|
||||
*name = cond->MR_cond_var_spec.MR_var_spec_name;
|
||||
fprintf(fp, "$%s", *name);
|
||||
break;
|
||||
|
||||
case MR_VAR_SPEC_ATTRIBUTE:
|
||||
fprintf(fp, "!%s", cond->MR_cond_var_spec.MR_var_spec_name);
|
||||
*name = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// vim: ts=4 sw=4 expandtab ft=c
|
||||
|
||||
// Copyright (C) 1998-2001, 2005-2007 The University of Melbourne.
|
||||
// Copyright (C) 2016, 2018 The Mercury team.
|
||||
// Copyright (C) 2016, 2018, 2025 The Mercury team.
|
||||
// This file is distributed under the terms specified in COPYING.LIB.
|
||||
|
||||
// This file contains the declarations of the types and functions that
|
||||
@@ -187,8 +187,11 @@ extern void MR_delete_spy_point(int point_table_slot);
|
||||
extern void MR_print_spy_point(FILE *fp, int i, MR_bool verbose);
|
||||
|
||||
// Print the given spy point condition in a user-friendly manner.
|
||||
// If the condition involves a named variable, set *name to point to that name.
|
||||
// Otherwise, set it to NULL.
|
||||
|
||||
extern void MR_print_spy_cond(FILE *fp, MR_SpyCond *cond);
|
||||
extern void MR_print_spy_cond(FILE *fp, MR_SpyCond *cond,
|
||||
const char **name);
|
||||
|
||||
// Print the set of current spy points (including those that are currently
|
||||
// disabled) to fp in a format that, when sourced by mdb, recreates those
|
||||
|
||||
Reference in New Issue
Block a user