Files
mercury/trace/mercury_trace_tables.h
Zoltan Somogyi 2bef47ce85 Extend the information we record about procedures when debugging is enabled
Estimated hours taken: 20
Branches: main (for now, after more testing, on release branch too)

Extend the information we record about procedures when debugging is enabled
to include information about the tabling transformation, if the procedure
in question is tabled. This is useful to developers in debugging the tabling
mechanism, and can be useful to general users by helping them understand the
space (and hence time) costs of tabling.

Add a new mdb command "table" that uses this information to print
programmer-selected subsets of the tables of a tabled procedure.

compiler/hlds_pred.m:
	Generalize the existing field in procedures that used to hold
	information about I/O tabling to contain information about tabling
	in general, including forms other than I/O tabling.

compiler/continuation_info.m:
compiler/code_gen.m:
compiler/stack_layout.m:
	Conform to the changes in hlds_pred.m.

compiler/layout.m:
	Provide Mercury parallels for the new data structures in
	mercury_stack_layout.h.

compiler/layout_out.m:
	Generate the new data structures in mercury_stack_layout.h.

compiler/table_gen.m:
	Generate the new data structures in hlds_pred.m.

compiler/llds_common.m:
compiler/opt_debug.m:
	Conform to the changes in layout.m

compiler/llds_out.m:
	Abstract out existing code into a new procedure to make it available
	to layout_out.m.

	Make tabling pointer variables their natural type.

compiler/modules.m:
	Fix an old bug: implicitly import table_builtin.m in .mm grades.

doc/mdb_categories:
doc/user_guide.texi:
	Document the new mdb command "table".

runtime/mercury_types.h:
	Move some type definitions here from mercury_tabling.h and
	mercury_stack_layout.h. This was necessary to avoid problems with
	circular #includes, in which a.h #includes b.h to get access to a
	definition, but b.h #includes a.h, which is prevented by the macro
	guarding against duplicate definition, which causes syntax errors
	in the rest of b.h because the rest of b.h depends on typedefs in
	a.h that occur in a.h *after* the #include of b.h.

runtime/mercury_label.h:
	Adjust the list of #includes after the change to mercury_types.h.

runtime/mercury_stack_layout.h:
	Extend the debugging data structures with constructs that describe
	the call tables, answer tables and answer blocks of tabled procedures.

	Delete typedefs that are now in mercury_types.h.

runtime/mercury_tabling.[ch]:
	Add new functions to allow lookups without insertions in hash tables
	containing ints, floats and strings.

	Add new functions to return the entire contents of these hash tables.

	Change to four-space indentation where this wasn't done previously.

runtime/mercury_grade.h:
	Increment the binary compatbility version number, partially to
	account for the change to mercury_stack_layout.h in this diff, but
	mostly to account for all the other diffs to mercury_stack_layout.h
	since the last released version.

trace/mercury_trace_tables.[ch]:
	Rename MR_print_proc_id_for_debugger as MR_print_proc_id_and_nl,
	since this better describes what the function does.

trace/mercury_trace_util.[ch]:
	Add a new function MR_trace_is_integer that reads in signed integers.

	Rename MR_trace_is_number as MR_trace_is_natural_number, since the
	former would now be ambiguous.

	Add a new function MR_trace_is_float that reads in floating point
	values.

library/string.m:
	Document that MR_trace_is_float uses the same logic as
	MR_trace_is_float.

trace/mercury_trace_browse.c:
trace/mercury_trace_vars.c:
	Update calls to MR_trace_is_number.

trace/mercury_trace_internal.c:
	Implement the new mdb command "table".

	Update calls to MR_trace_is_number and to
	MR_print_proc_id_for_debugger.

tests/debugger/print_table.{m,inp,exp}:
	New test case to test the new mdb command.

tests/debugger/Mmakefile:
	Enable the new test case.

	Disable the sensitive test cases in .mm grades.

tests/debugger/completion.exp:
	Update the expected output to include the new mdb command.

tests/debugger/mdb_command_test.inp:
	Update this automatically generated file to include the new mdb
	command.
2002-11-15 04:50:49 +00:00

174 lines
5.5 KiB
C

/*
** Copyright (C) 1998-2002 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 file contains the declarations of the tables that contain
** the identities of the debuggable modules and their procedures.
**
** Main author: Zoltan Somogyi.
*/
#ifndef MERCURY_TRACE_TABLES_H
#define MERCURY_TRACE_TABLES_H
#include "mercury_stack_layout.h"
#include "mercury_trace_completion.h"
#include <stdio.h>
/*
** MR_register_all_modules_and_procs gathers all available debugging info
** about the modules and procedures of the program into the module info table.
** If verbose is MR_TRUE, print progress and summary messages.
*/
extern void MR_register_all_modules_and_procs(FILE *fp,
MR_bool verbose);
/*
** MR_register_module_layout_real registers a module layout structure.
** It is called indirectly, through the function pointer
** MR_register_module_layout, by the module initialization code
** of modules compiled with debugging.
*/
extern void MR_register_module_layout_real(const MR_Module_Layout
*module);
/*
** MR_process_file_line_layouts searches all the module layout structures
** of the program for label layout structures corresponding to the given
** filename/linenumber combination. For all such labels, it calls the supplied
** callback function with a pointer to the label's layout structure and
** with the supplied integer callback argument.
*/
typedef void (*MR_file_line_callback)(const MR_Label_Layout *, int);
extern void MR_process_file_line_layouts(const char *file,
int line, MR_file_line_callback callback_func,
int callback_arg);
/*
** These functions print (parts of) the module info table.
**
** MR_dump_module_tables lists all procedures in all modules.
** Its output can be very big; it should be used only by developers,
** for debugging the debugger.
**
** MR_dump_module_list lists the names of all the modules,
** while MR_dump_module_procs lists the names of all the procs in the named
** module. These are intended for ordinary, non-developer users.
*/
extern void MR_dump_module_tables(FILE *fp);
extern void MR_dump_module_list(FILE *fp);
extern void MR_dump_module_procs(FILE *fp, const char *name);
/*
** A procedure specification gives some or all of
**
** the name of the module defining the procedure
** the name of the predicate or function
** the arity of the predicate or function
** the mode of the predicate or function
** whether the procedure belongs to a predicate or function
**
** A NULL pointer for the string fields, and a negative number for the other
** fields signifies the absence of information about that field, which should
** therefore be treated as a wildcard.
*/
typedef struct {
const char *MR_proc_module;
const char *MR_proc_name;
int MR_proc_arity;
int MR_proc_mode;
MR_PredFunc MR_proc_pf;
} MR_Proc_Spec;
/*
** Given a string containing the specification of a procedure in the form
**
** [`pred*'|`func*']module:name/arity-mode
**
** in which some of the five components (but not the name) may be missing,
** parse it into the more usable form of a MR_Proc_Spec. The original string
** may be overwritten in the process.
**
** Returns MR_TRUE if the string was correctly formed, and MR_FALSE otherwise.
*/
extern MR_bool MR_parse_proc_spec(char *str, MR_Proc_Spec *spec);
/*
** Search the tables for a procedure that matches the given specification.
** If no procedure matches, return NULL.
** If one procedure matches, return its layout structure,
** and set *unique to MR_TRUE.
** If more than one procedure matches, return the layout structure of one
** and set *unique to MR_FALSE.
*/
extern const MR_Proc_Layout *MR_search_for_matching_procedure(
MR_Proc_Spec *spec, MR_bool *unique);
/*
** Search the tables for procedures that matches the given specification.
** Return their layout structures in the array in the match_procs field
** of the structure. The match_proc_next field says how many matches there are,
** and the match_proc_max field says how many entries the array has allocated
** for it.
*/
typedef struct {
const MR_Proc_Layout **match_procs;
int match_proc_max;
int match_proc_next;
} MR_Matches_Info;
extern MR_Matches_Info MR_search_for_matching_procedures(MR_Proc_Spec *spec);
/*
** MR_process_matching_procedures(spec, f, data):
** For each procedure that matches the specification given by `spec',
** call `f(data, entry)', where `entry' is the entry layout for that
** procedure. The argument `data' is a `void *' which can be used
** to pass any other information needed by the function `f'.
*/
extern void MR_process_matching_procedures(MR_Proc_Spec *spec,
void f(void *, const MR_Proc_Layout *), void *data);
/*
** MR_print_proc_id_and_nl(fp, proc):
** Print the id of the procedure identified by proc, followed by a
** newline.
*/
extern void MR_print_proc_id_and_nl(FILE *fp, const MR_Proc_Layout *proc);
/*
** MR_proc_layout_stats(fp):
** Prints statistics about the proc layout structures of the program.
*/
extern void MR_proc_layout_stats(FILE *fp);
/*
** MR_label_layout_stats(fp):
** Prints statistics about the label layout structures of the program.
*/
extern void MR_label_layout_stats(FILE *fp);
/* A Readline completer for module names. */
extern MR_Completer_List *MR_trace_module_completer(const char *, size_t);
/* A Readline completer for breakpoint specifications. */
extern MR_Completer_List *MR_trace_breakpoint_completer(const char *, size_t);
#endif /* not MERCURY_TRACE_TABLES_H */