mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-11 03:45:33 +00:00
Estimated hours taken: 5
Branches: main
Fix up some places in the trace directory where there were (potential)
mismatches between the sizes of types used to represent natural numbers.
Much of the existing code in the trace directory assumed that
sizeof(int) == sizeof(MR_Unsigned), which is not true on our 64-bit
machines. Zoltan's recent change to MR_trace_is_natural_number() broke
that assumption in a lot of places. (I committed a workaround for that
yesterday.)
This diff addresses the above problem by changing the types of many of
things that represent natural numbers from int to MR_Unsigned.
This should make the trace code more robust on 64-bit machines and
help avoid a recurrence of problems like the above.
NOTE: this change does not change slot numbers into unsigned values since
they still use negative values as sentinels. I will address slot numbers
in as part of a separate change.
trace/mercury_trace.h:
Add typedefs for MR_Unsigned for several commonly used quantities
within the trace code. For I/O action numbers we just re-use
the type MR_IoActionNum from the runtime, rather than defining
a new typedef here.
trace/mercury_trace_tables.h:
Change the type of the `match_proc_max' and `match_proc_next' fields
of the MR_MatchesInfo structure into MR_Unsigned instead of int.
trace/mercury_trace_cmd_parameter.[ch]:
Change the type of the global variables, MR_scroll_{limit,next}
and MR_num_context_lines into MR_Unsigned instead of int.
trace/mercury_trace_util.[ch]:
Restore Zoltan's change that made the type of the second argument of
MR_trace_is_natural_number() into MR_Unsigned. The places that
caused this to break on 64-bit machines have now been fixed.
Update the documentation of MR_trace_is_natural_number();
Delete MR_trace_is_unsigned() since that now duplicates
MR_trace_is_natural_number().
Add a new function MR_trace_is_nonneg_int() which is similar
to the above functions except that it stores its result in
an int. (This is needed for handling slot numbers which are
still represented using ints.)
trace/mercury_trace_cmd_developer.c:
Refactor some code so that we don't need to use -1 as a sentinel
value.
trace/mercury_trace_cmd_help.c:
Use MR_trace_is_nonneg_int() instead of MR_trace_is_natural_number()
to handle slot numbers.
runtime/mercury_trace_base.[ch]:
Change the type of the first argument of MR_trace_get_action()
from int to MR_IoActionNum.
trace/mercury_trace_alias.c:
trace/mercury_trace_cmd_backward.c:
trace/mercury_trace_cmd_breakpoint.c:
trace/mercury_trace_cmd_browsing.c:
trace/mercury_trace_cmd_dd.c:
trace/mercury_trace_cmd_exp.c:
trace/mercury_trace_cmd_forward.c:
trace/mercury_stack_trace.c:
trace/mercury_trace_internal.c:
trace/mercury_trace_spy.[ch]:
trace/mercury_trace_vars.[ch]:
Use MR_Unsigned instead of int to represent natural numbers.
145 lines
4.7 KiB
C
145 lines
4.7 KiB
C
/*
|
|
** vim: ts=4 sw=4 expandtab
|
|
*/
|
|
/*
|
|
** Copyright (C) 1998-2007 The University of Melbourne.
|
|
** This file may only be copied under the terms of the GNU Library General
|
|
** Public License - see the file COPYING.LIB in the Mercury distribution.
|
|
*/
|
|
|
|
#include "mercury_std.h"
|
|
#include "mercury_types.h"
|
|
#include "mercury_stack_trace.h" /* for MR_Context_Position */
|
|
|
|
#include "mercury_trace_cmds.h"
|
|
#include "mercury_trace_spy.h" /* for MR_SpyWhen */
|
|
|
|
/*
|
|
** Options to pass to mmc when compiling queries.
|
|
*/
|
|
|
|
extern char *MR_mmc_options;
|
|
|
|
/*
|
|
** The default print level governs whether we out reports for events at which
|
|
** we don't stop.
|
|
*/
|
|
|
|
extern MR_TracePrintLevel MR_default_print_level;
|
|
|
|
/*
|
|
** These variables say (a) whether the printing of event sequences will pause
|
|
** after each screenful of events, (b) how may events constitute a screenful
|
|
** (although we count only events, not how many lines they take up), and (c)
|
|
** how many events we have printed so far in this screenful.
|
|
*/
|
|
|
|
extern MR_bool MR_scroll_control;
|
|
extern MR_Unsigned MR_scroll_limit;
|
|
extern MR_Unsigned MR_scroll_next;
|
|
|
|
/*
|
|
** This variable controls the number of stack frame lines printed by the stack
|
|
** and nondet_stack commands if the user doesn't override it.
|
|
*/
|
|
|
|
extern int MR_stack_default_line_limit;
|
|
|
|
/*
|
|
** We echo each command just as it is executed iff this variable is MR_TRUE.
|
|
*/
|
|
|
|
extern MR_bool MR_echo_commands;
|
|
|
|
/*
|
|
** We include values of sometimes-useful types such as typeinfos in the set of
|
|
** variables whose values we collect at events for possible later printing
|
|
** only if MR_print_optionals is true.
|
|
*/
|
|
|
|
extern MR_bool MR_print_optionals;
|
|
|
|
/*
|
|
** This variable holds either the name of a file which contains a list of
|
|
** the file names of passing test case trace counts, or the name of a single
|
|
** file of passing test case trace counts.
|
|
*/
|
|
|
|
extern char *MR_dice_pass_trace_counts_file;
|
|
|
|
/*
|
|
** This variable holds either the name of a file which contains a list of
|
|
** the file names of failing test case trace counts, or the name of a single
|
|
** file of failing test case trace counts.
|
|
*/
|
|
|
|
extern char *MR_dice_fail_trace_counts_file;
|
|
|
|
/*
|
|
** MR_context_position specifies whether we print context at events,
|
|
** and if so, where.
|
|
*/
|
|
|
|
extern MR_ContextPosition MR_context_position;
|
|
|
|
/*
|
|
** MR_user_event_context specifies what context to print at user events.
|
|
*/
|
|
|
|
extern MR_UserEventContext MR_user_event_context;
|
|
|
|
/*
|
|
** MR_print_goal_paths specifies whether we print goal paths at events.
|
|
*/
|
|
|
|
extern MR_bool MR_print_goal_paths;
|
|
|
|
/*
|
|
** MR_listing_path holds the current value of the listings structure
|
|
** as defined in browser/listing.m. You need to ensure that it is initialized
|
|
** before accessing it.
|
|
*/
|
|
|
|
extern MR_Word MR_listing_path;
|
|
extern void MR_trace_listing_path_ensure_init(void);
|
|
|
|
/*
|
|
** MR_num_context_lines holds the current number of context lines to be
|
|
** printed before and after the current callee/caller's file context.
|
|
*/
|
|
|
|
extern MR_Unsigned MR_num_context_lines;
|
|
|
|
extern MR_SpyWhen MR_default_breakpoint_scope;
|
|
|
|
extern MR_TraceCmdFunc MR_trace_cmd_mmc_options;
|
|
extern MR_TraceCmdFunc MR_trace_cmd_printlevel;
|
|
extern MR_TraceCmdFunc MR_trace_cmd_scroll;
|
|
extern MR_TraceCmdFunc MR_trace_cmd_stack_default_limit;
|
|
extern MR_TraceCmdFunc MR_trace_cmd_context;
|
|
extern MR_TraceCmdFunc MR_trace_cmd_user_event_context;
|
|
extern MR_TraceCmdFunc MR_trace_cmd_goal_paths;
|
|
extern MR_TraceCmdFunc MR_trace_cmd_scope;
|
|
extern MR_TraceCmdFunc MR_trace_cmd_echo;
|
|
extern MR_TraceCmdFunc MR_trace_cmd_list_context_lines;
|
|
extern MR_TraceCmdFunc MR_trace_cmd_list_path;
|
|
extern MR_TraceCmdFunc MR_trace_cmd_push_list_dir;
|
|
extern MR_TraceCmdFunc MR_trace_cmd_pop_list_dir;
|
|
extern MR_TraceCmdFunc MR_trace_cmd_fail_trace_counts;
|
|
extern MR_TraceCmdFunc MR_trace_cmd_pass_trace_counts;
|
|
extern MR_TraceCmdFunc MR_trace_cmd_max_io_actions;
|
|
extern MR_TraceCmdFunc MR_trace_cmd_xml_browser_cmd;
|
|
extern MR_TraceCmdFunc MR_trace_cmd_xml_tmp_filename;
|
|
extern MR_TraceCmdFunc MR_trace_cmd_format;
|
|
extern MR_TraceCmdFunc MR_trace_cmd_format_param;
|
|
extern MR_TraceCmdFunc MR_trace_cmd_alias;
|
|
extern MR_TraceCmdFunc MR_trace_cmd_unalias;
|
|
|
|
extern const char *const MR_trace_printlevel_cmd_args[];
|
|
extern const char *const MR_trace_on_off_args[];
|
|
extern const char *const MR_trace_context_cmd_args[];
|
|
extern const char *const MR_trace_user_event_context_cmd_args[];
|
|
extern const char *const MR_trace_scope_cmd_args[];
|
|
extern const char *const MR_trace_format_cmd_args[];
|
|
extern const char *const MR_trace_format_param_cmd_args[];
|