diff --git a/tests/debugger/cond.exp b/tests/debugger/cond.exp index 4a482e1ce..bdd156804 100644 --- a/tests/debugger/cond.exp +++ b/tests/debugger/cond.exp @@ -106,14 +106,16 @@ mdb> condition Y^1^2 = 1 Y ^1^2 = 1 mdb> continue mdb: couldn't evaluate break point condition -Y ^1^2 = 1: there is no such variable. + Y ^1^2 = 1. +The error is: there is no variable named Y. E15: C15 CALL pred cond.r/2-0 (det) mdb> condition -p Y^1^2 = 1 0: + stop interface pred cond.r/2-0 (det) -p Y ^1^2 = 1 mdb> continue mdb: couldn't evaluate break point condition -Y ^1^2 = 1: there is no such variable. + Y ^1^2 = 1. +The error is: there is no variable named Y. E16: C16 CALL pred cond.r/2-0 (det) mdb> delete * 0: E stop interface pred cond.r/2-0 (det) @@ -159,7 +161,8 @@ mdb> condition X^4 = 1 X ^4 = 1 mdb> continue mdb: couldn't evaluate break point condition -X ^4 = 1: the path 4 does not exist. + X ^4 = 1. +The error is: the path 4 does not exist. E22: C21 CALL pred cond.r/2-0 (det) mdb> print r(1, _) diff --git a/trace/mercury_trace_internal.c b/trace/mercury_trace_internal.c index 3b21e4191..635c59cea 100644 --- a/trace/mercury_trace_internal.c +++ b/trace/mercury_trace_internal.c @@ -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; } diff --git a/trace/mercury_trace_spy.c b/trace/mercury_trace_spy.c index a59ea8184..6d5a976c8 100644 --- a/trace/mercury_trace_spy.c +++ b/trace/mercury_trace_spy.c @@ -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; } diff --git a/trace/mercury_trace_spy.h b/trace/mercury_trace_spy.h index 025e92d97..f9c23457b 100644 --- a/trace/mercury_trace_spy.h +++ b/trace/mercury_trace_spy.h @@ -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