Files
mercury/compiler/layout.m
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

227 lines
7.2 KiB
Mathematica

%-----------------------------------------------------------------------------%
% Copyright (C) 2001-2002 The University of Melbourne.
% This file may only be copied under the terms of the GNU General
% Public License - see the file COPYING in the Mercury distribution.
%-----------------------------------------------------------------------------%
%
% Definitions of Mercury types for representing layout structures within
% the compiler. Layout structures are generated by the compiler, and are
% used by the parts of the runtime system that need to look at the stacks
% (and sometimes the registers) and make sense of their contents. The parts
% of the runtime system that need to do this include exception handling,
% the debugger, the deep profiler and (eventually) the accurate garbage
% collector.
%
% When output by layout_out.m, values of most these types will correspond
% to the C types defined in runtime/mercury_stack_layout.h or
% runtime/mercury_deep_profiling.h; the documentation of those types
% can be found there. The names of the C types are listed next to the
% function symbol whose arguments represent their contents.
%
% The code to generate values of these types is in stack_layout.m and
% deep_profiling.m.
%
% This module should be, but as yet isn't, independent of whether we are
% compiling to LLDS or MLDS.
%
% Author: zs.
%-----------------------------------------------------------------------------%
:- module ll_backend__layout.
:- interface.
:- import_module parse_tree__prog_data.
:- import_module hlds__hlds_goal, hlds__hlds_pred.
:- import_module ll_backend__llds.
:- import_module backend_libs__rtti.
:- import_module libs__trace_params.
:- import_module bool, std_util, list, assoc_list.
:- type layout_data
---> label_layout_data( % defines MR_Label_Layout
label :: label,
proc_layout_name :: layout_name,
maybe_port :: maybe(trace_port),
maybe_is_hidden :: maybe(bool),
maybe_goal_path :: maybe(int), % offset
maybe_var_info :: maybe(label_var_info)
)
; proc_layout_data( % defines MR_Proc_Layout
proc_label,
proc_layout_stack_traversal,
maybe_proc_id_and_exec_trace
)
; module_layout_data( % defines MR_Module_Layout
module_name :: module_name,
string_table_size :: int,
string_table :: string,
proc_layout_names :: list(layout_name),
file_layouts :: list(file_layout_data),
trace_level :: trace_level,
suppressed_events :: int
)
; closure_proc_id_data( % defines MR_Closure_Id
caller_proc_label :: proc_label,
caller_closure_seq_no :: int,
closure_proc_label :: proc_label,
closure_module_name :: module_name,
closure_file_name :: string,
closure_line_number :: int,
closure_goal_path :: string
)
; proc_static_data( % defines MR_ProcStatic
proc_static_id :: rtti_proc_label,
proc_static_file_name :: string,
proc_static_line_number :: int,
proc_is_in_interface :: bool,
call_site_statics :: list(call_site_static_data)
)
; table_io_decl_data(
table_io_decl_proc_ptr :: rtti_proc_label,
table_io_decl_kind :: proc_layout_kind,
table_io_decl_num_ptis :: int,
table_io_decl_ptis :: rval,
% pseudo-typeinfos for headvars
table_io_decl_type_params :: rval
)
; table_gen_data(
table_gen_proc_ptr :: rtti_proc_label,
table_gen_num_inputs :: int,
table_gen_num_outputs :: int,
table_gen_steps :: list(table_trie_step),
table_gen_ptis :: rval,
% pseudo-typeinfos for headvars
table_gen_type_params :: rval
).
:- type call_site_static_data % defines MR_CallSiteStatic
---> normal_call(
normal_callee :: rtti_proc_label,
normal_type_subst :: string,
normal_file_name :: string,
normal_line_number :: int,
normal_goal_path :: goal_path
)
; special_call(
special_file_name :: string,
special_line_number :: int,
special_goal_path :: goal_path
)
; higher_order_call(
higher_order_file_name :: string,
ho_line_number :: int,
ho_goal_path :: goal_path
)
; method_call(
method_file_name :: string,
method_line_number :: int,
method_goal_path :: goal_path
)
; callback(
callback_file_name :: string,
callback_line_number :: int,
callback_goal_path :: goal_path
).
:- type label_var_info
---> label_var_info( % part of MR_Label_Layout
encoded_var_count :: int,
locns_types :: rval,
var_nums :: rval,
type_params :: rval
).
:- type proc_layout_stack_traversal % defines MR_Stack_Traversal
---> proc_layout_stack_traversal(
entry_label :: maybe(label),
% The proc entry label; will be
% `no' if we don't have static
% code addresses.
succip_slot :: maybe(int),
stack_slot_count :: int,
detism :: determinism
).
:- type maybe_proc_id_and_exec_trace
---> no_proc_id
; proc_id_only
; proc_id_and_exec_trace(proc_layout_exec_trace).
:- type proc_layout_exec_trace % defines MR_Exec_Trace
---> proc_layout_exec_trace(
call_label_layout :: layout_name,
proc_body :: maybe(rval),
maybe_table_info :: maybe(layout_name),
head_var_nums :: list(int),
% The variable numbers of the
% head variables, including the
% ones added by the compiler,
% in order. The length of the
% list must be the same as the
% procedure's arity.
var_names :: list(int),
% Each variable name is an
% offset into the module's
% string table.
max_var_num :: int,
max_r_num :: int,
maybe_from_full_slot :: maybe(int),
maybe_io_seq_slot :: maybe(int),
maybe_trail_slot :: maybe(int),
maybe_maxfr_slot :: maybe(int),
eval_method :: eval_method,
maybe_call_table_slot :: maybe(int)
).
:- type file_layout_data
---> file_layout_data(
file_name :: string,
line_no_label_list :: assoc_list(int, layout_name)
).
%-----------------------------------------------------------------------------%
:- type layout_name
---> label_layout(label, label_vars)
; proc_layout(proc_label, proc_layout_kind)
% A proc layout structure for stack tracing, accurate gc
% and/or execution tracing.
; proc_layout_head_var_nums(proc_label)
% A vector of variable numbers, containing the numbers of the
% procedure's head variables, including the ones generated by
% the compiler.
; proc_layout_var_names(proc_label)
% A vector of variable names (represented as offsets into
% the string table) for a procedure layout structure.
; table_io_decl(rtti_proc_label)
; table_gen_info(rtti_proc_label)
; table_gen_enum_params(rtti_proc_label)
; table_gen_steps(rtti_proc_label)
; closure_proc_id(proc_label, int, proc_label)
; file_layout(module_name, int)
; file_layout_line_number_vector(module_name, int)
; file_layout_label_layout_vector(module_name, int)
; module_layout_string_table(module_name)
; module_layout_file_vector(module_name)
; module_layout_proc_vector(module_name)
; module_layout(module_name)
; proc_static(rtti_proc_label)
; proc_static_call_sites(rtti_proc_label).
:- type label_vars
---> label_has_var_info
; label_has_no_var_info.
:- type proc_layout_kind
---> proc_layout_traversal
; proc_layout_proc_id(proc_layout_user_or_compiler)
; proc_layout_exec_trace(proc_layout_user_or_compiler).
:- type proc_layout_user_or_compiler
---> user
; compiler.
%-----------------------------------------------------------------------------%