mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-17 23:05:21 +00:00
Estimated hours taken: 2 Branches: main The runtime had two different conventions for naming types. One convention, used mostly in the debugger-related modules, added underscores between capitalized words; example: MR_Label_Layout. The other convention, used in most modules, used capitalized words without underscores (e.g. MR_TypeInfo). This diff standardizes on the second convention. It has no algorithmic changes, only renames of types. runtime/*.[ch]: trace/*.[ch]: compiler/*.m: library/*.m: mdbcomp/*.m: Effect the change described above. The only substantive change is that runtime/mercury_stack_layout.h used to define *two* types for trace levels: MR_TraceLevel and MR_Trace_Level, and this diff standardizes on just one (they had equivalent definitions). runtime/mercury_bootstrap.h: Add a #define from the old name to the new for all the changed type names that the installed compiler can put into .c files. We can delete these #defines some time after this diff has bootstrapped. slice/.mgnuc_opts: Restore the --no-mercury-stdlib-dir option, without which the slice directory won't compile after this change (because it looks for type names in the installed runtime header files, which define the old versions of type names).
153 lines
5.7 KiB
C
153 lines
5.7 KiB
C
/*
|
|
** vim: ts=4 sw=4 expandtab
|
|
*/
|
|
/*
|
|
** Copyright (C) 1998-2006 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.
|
|
*/
|
|
|
|
/*
|
|
** This module implements the mdb commands in the "table_io" category.
|
|
**
|
|
** The structure of these files is:
|
|
**
|
|
** - all the #includes
|
|
** - local macros and declarations of local static functions
|
|
** - one function for each command in the category
|
|
** - any auxiliary functions
|
|
** - any command argument strings
|
|
** - option processing functions.
|
|
*/
|
|
|
|
#include "mercury_std.h"
|
|
#include "mercury_getopt.h"
|
|
|
|
#include "mercury_trace_internal.h"
|
|
#include "mercury_trace_cmds.h"
|
|
#include "mercury_trace_cmd_table_io.h"
|
|
|
|
/****************************************************************************/
|
|
|
|
static void MR_print_unsigned_var(FILE *fp, const char *var,
|
|
MR_Unsigned value);
|
|
|
|
/****************************************************************************/
|
|
|
|
MR_Next
|
|
MR_trace_cmd_table_io(char **words, int word_count, MR_TraceCmdInfo *cmd,
|
|
MR_EventInfo *event_info, MR_Code **jumpaddr)
|
|
{
|
|
if (word_count == 1) {
|
|
if (! MR_io_tabling_allowed) {
|
|
fprintf(MR_mdb_err,
|
|
"This executable wasn't prepared for I/O tabling.\n");
|
|
return KEEP_INTERACTING;
|
|
}
|
|
|
|
if (MR_io_tabling_phase == MR_IO_TABLING_BEFORE) {
|
|
fprintf(MR_mdb_out, "I/O tabling has not yet started.\n");
|
|
} else if (MR_io_tabling_phase == MR_IO_TABLING_DURING) {
|
|
fprintf(MR_mdb_out, "I/O tabling has started.\n");
|
|
} else if (MR_io_tabling_phase == MR_IO_TABLING_AFTER) {
|
|
fprintf(MR_mdb_out, "I/O tabling has stopped.\n");
|
|
} else {
|
|
MR_fatal_error("I/O tabling in impossible phase.\n");
|
|
}
|
|
} else if (word_count == 2 &&
|
|
(MR_streq(words[1], "start") || MR_streq(words[1], "begin")))
|
|
{
|
|
if (! MR_io_tabling_allowed) {
|
|
fprintf(MR_mdb_err,
|
|
"This executable wasn't prepared for I/O tabling.\n");
|
|
return KEEP_INTERACTING;
|
|
}
|
|
|
|
if (MR_io_tabling_phase == MR_IO_TABLING_BEFORE) {
|
|
MR_io_tabling_phase = MR_IO_TABLING_DURING;
|
|
MR_io_tabling_start = MR_io_tabling_counter;
|
|
MR_io_tabling_end = MR_IO_ACTION_MAX;
|
|
MR_io_tabling_start_event_num = event_info->MR_event_number;
|
|
#ifdef MR_DEBUG_RETRY
|
|
MR_io_tabling_debug = MR_TRUE;
|
|
#endif
|
|
fprintf(MR_mdb_out, "I/O tabling started.\n");
|
|
} else if (MR_io_tabling_phase == MR_IO_TABLING_DURING) {
|
|
fprintf(MR_mdb_out, "I/O tabling has already started.\n");
|
|
} else if (MR_io_tabling_phase == MR_IO_TABLING_AFTER) {
|
|
fprintf(MR_mdb_out, "I/O tabling has already stopped.\n");
|
|
} else {
|
|
MR_fatal_error("I/O tabling in impossible phase.\n");
|
|
}
|
|
} else if (word_count == 2 &&
|
|
(MR_streq(words[1], "stop") || MR_streq(words[1], "end")))
|
|
{
|
|
if (! MR_io_tabling_allowed) {
|
|
fprintf(MR_mdb_err,
|
|
"This executable wasn't prepared for I/O tabling.\n");
|
|
return KEEP_INTERACTING;
|
|
}
|
|
|
|
if (MR_io_tabling_phase == MR_IO_TABLING_BEFORE) {
|
|
fprintf(MR_mdb_out, "I/O tabling has not yet started.\n");
|
|
} else if (MR_io_tabling_phase == MR_IO_TABLING_DURING) {
|
|
MR_io_tabling_phase = MR_IO_TABLING_AFTER;
|
|
MR_io_tabling_end = MR_io_tabling_counter_hwm;
|
|
MR_io_tabling_stop_event_num = event_info->MR_event_number;
|
|
fprintf(MR_mdb_out, "I/O tabling stopped.\n");
|
|
} else if (MR_io_tabling_phase == MR_IO_TABLING_AFTER) {
|
|
fprintf(MR_mdb_out, "I/O tabling has already stopped.\n");
|
|
} else {
|
|
MR_fatal_error("I/O tabling in impossible phase.\n");
|
|
}
|
|
} else if (word_count == 2 && MR_streq(words[1], "stats")) {
|
|
if (! MR_io_tabling_allowed) {
|
|
fprintf(MR_mdb_err,
|
|
"This executable wasn't prepared for I/O tabling.\n");
|
|
return KEEP_INTERACTING;
|
|
}
|
|
|
|
fprintf(MR_mdb_out, "phase = %d\n", MR_io_tabling_phase);
|
|
MR_print_unsigned_var(MR_mdb_out, "counter", MR_io_tabling_counter);
|
|
MR_print_unsigned_var(MR_mdb_out, "hwm", MR_io_tabling_counter_hwm);
|
|
MR_print_unsigned_var(MR_mdb_out, "start", MR_io_tabling_start);
|
|
MR_print_unsigned_var(MR_mdb_out, "end", MR_io_tabling_end);
|
|
} else if (word_count == 2 && MR_streq(words[1], "allow")) {
|
|
/*
|
|
** The "table_io allow" command allows the programmer to give
|
|
** the command "table_io start" even in grades in which there
|
|
** is no guarantee that all I/O primitives are tabled. It is
|
|
** for developers only, because if it is used on programs in
|
|
** which some but not all I/O primitives are tabled, the
|
|
** results of turning on I/O tabling can be weird.
|
|
*/
|
|
|
|
MR_io_tabling_allowed = MR_TRUE;
|
|
} else {
|
|
MR_trace_usage_cur_cmd();
|
|
}
|
|
|
|
return KEEP_INTERACTING;
|
|
}
|
|
|
|
/****************************************************************************/
|
|
|
|
static void
|
|
MR_print_unsigned_var(FILE *fp, const char *var, MR_Unsigned value)
|
|
{
|
|
fprintf(fp, "%s = %" MR_INTEGER_LENGTH_MODIFIER "u\n", var, value);
|
|
}
|
|
|
|
/****************************************************************************/
|
|
|
|
/*
|
|
** "table_io allow" is deliberately not documented as it is developer only.
|
|
** "table_io begin" and "table_io end" are deliberately not documented in an
|
|
** effort to encourage consistent use of start/stop.
|
|
*/
|
|
|
|
const char *const MR_trace_table_io_cmd_args[] =
|
|
{ "stats", "start", "stop", NULL };
|
|
|
|
/****************************************************************************/
|