Commit Graph

13 Commits

Author SHA1 Message Date
Zoltan Somogyi
e9323be958 Improve an mdb error message.
trace/mercury_trace_spy.c:
    When the user wants to put a breakpoint on a line in a file,
    but there is no event exactly on the given line number,
    mdb used to tell the user just that fact. This diff makes
    mdb more helpful, by printing the nearest line numbers before
    and after the given line number that *do* have events on which
    breakpoints can be put.

    The mismatch can come for several reasons, with the most common
    probably being that textually, a switch arm for e.g X being f
    starts with the X = f unification goal, but switch detection
    *deletes* that unification from the switch arm, so the event
    for entry into that arm is actually on the line for the *next* goal.

trace/mercury_trace_tables.[ch]:
    Provide the info needed by mercury_trace_spy.c.

    Change the interface of MR_process_file_line_layouts to make it
    self-contained, i.e. returning counts of matches, instead of
    merely *adding* to preexisting counts. This is simpler, since
    the only caller of that function needs no running tally.

tests/debugger/breakpoints.inp:
    Extend this test to test the possible error messages we now generate.

tests/debugger/breakpoints.exp:
tests/debugger/breakpoints.exp2:
    Update the expected outputs in both debug and non-debug grades.
2020-08-08 04:22:44 +10:00
Zoltan Somogyi
fbfb5385fa Print more specific errors when creating an mdb breakpoint fails.
trace/mercury_trace_spy.c:
    When giving a command such as

        mdb> break badfilename.m:42

    and the debugger has no information about any file named "badfilename.m",
    print an error message that says just that. If the file exists but the
    line number doesn't, say that. Previously, the error message didn't tell
    the user whether it was the filename or the line number that was in error.

trace/mercury_trace_tables.[ch]:
    Collect the information that mercury_trace_spy.c needs for its new task.

tests/debugger/breakpoints.{inp,exp,exp2}:
    Add a test of both kinds of bad breakpoint specification to this test case.
2014-10-24 02:04:14 +11:00
Zoltan Somogyi
9bdc5db590 Try to work around the Snow Leopard linker's performance problem with
Estimated hours taken: 20
Branches: main

Try to work around the Snow Leopard linker's performance problem with
debug grade object files by greatly reducing the number of symbols needed
to represent the debugger's data structures.

Specifically, this diff groups all label layouts in a module, each of which
previously had its own named global variable, into only a few (one to four)
global variables, each of which is an array. References to the old global
variables are replaced by references to slots in these arrays.

This same treatment could also be applied to other layout structures. However,
most layouts are label layouts, so doing just label layouts gets most of the
available benefit.

When the library and compiler are compiled in grade asm_fast.gc.debug,
this diff leads to about a 1.5% increase in the size of their generated C
source files (from 338 to 343 Mb), but a more significant reduction (about 17%)
in the size of the corresponding object files (from 155 to 128 Mb). This leads
to an overall reduction in disk requirements from 493 to 471 Mb (about 4.5%).
Since we generate the same code and data as before, with the data just being
arranged differently, the decrease in object file sizes is coming from the
reduction in relocation information, the information processed by the linker.
This should speed up the linker.

compiler/layout.m:
	Make the change described above. We now define up to four arrays:
	one each for label layouts with and without information about
	variables, one for the layout structures of user events,
	and one for the variable number lists of user events.

compiler/layout_out.m:
	Generate the new arrays that the module being compiled needs.

	Use purpose-specific types instead of booleans.

compiler/trace_gen.m:
	Use a new field in foreign_proc_code instructions to record the
	identity of any labels whose layout structures we want to refer to,
	even though layout structures have not been generated yet. The labels
	will be looked up in a map (generated together with the layout
	structures) by llds_out.m.

compiler/llds.m:
	Add this extra field to foreign_proc_code instructions.

	Add the map (which is actually in two parts) to the c_file type,
	which is the data structure representing the entire LLDS.

	Also add to the c_file type some other data structures that previously
	we used to hand around alongside it. Some of these data structures
	used to conmingle layout structures that we now separate.

compiler/stack_layout.m:
	Generate array slots instead of separate structures for label layouts.
	Return the different arrays separately.

compiler/llds_out.m:
	Order the output of layout structures to require fewer forward
	declarations. The forward declarations of the few arrays holding the
	label layout structures replace a lot of the declarations previously
	needed.

	Include the information needed by layout_out.m in the llds_out_info,
	and conform to the changes above.

	As a side-effect of all these changes, we now generate proc layout
	structures in the same order as the procedures' appearence in the HLDS,
	which is the same as their order in the source code, modulo any
	procedures added by the compiler itself (for lambdas, unification
	predicates, etc).

compiler/code_info.m:
compiler/dupelim.m:
compiler/dup_proc.m:
compiler/exprn_aux.m:
compiler/frameopt.m:
compiler/global_data.m:
compiler/ite_gen.m:
compiler/jumpopt.m:
compiler/livemap.m:
compiler/llds_to_x86_64.m:
compiler/mercury_compile_llds_back_end.m:
compiler/middle_rec.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/pragma_c_gen.m:
compiler/proc_gen.m:
compiler/reassign.m:
compiler/use_local_vars.m:
	Conform to the changes above.

runtime/mercury_goto.h:
	Add the macros used by the new code in layout_out.m and llds_out.m.
	We need new macros because the old ones assumed that the
	C preprocessor can construct the address of a label's layout structure
	from the name of the label, which is obviously no longer possible.

	Make even existing families of macros handle in bulk up to 10 labels,
	up from the previous 8.

runtime/mercury_stack_layout.h:
	Add macros for use by the new code in layout.m.

tests/debugger/*.{inp,exp}:
tests/debugger/declarative/*.{inp,exp}:
	Update these test cases to account for the new (and better) order
	of proc layout structures. Where inputs changed, this was to ensure
	that we still select the same procedures from lists of procedures,
	e.g. to put a breakpoint on.
2009-10-21 06:36:37 +00:00
Zoltan Somogyi
8576975c4e Implement breakpoints on user events. Users may specify an event set,
Estimated hours taken: 20
Branches: main

Implement breakpoints on user events. Users may specify an event set,
an event name, both, or neither. Four forms of the mdb "break" command
create such breakpoints:

	break [the usual options] user_event <event_name>
	break [the usual options] user_event <event_set_name> <event_name>
	break [the usual options] user_event_set
	break [the usual options] user_event_set <event_set_name>

In addition, the command

	break [the usual options] user_event

is also accepted, as a synonym for

	break [the usual options] user_event_set

Since user events are not interface events or entry events, add a new, simple
ignore specification, which decrements the ignore count on every match of the
event.

Make the "break_print" mdb command consistent with the other command that
operates on existing breakpoints ("condition") by making it apply by default
to the most recently created breakpoint.

Make "condition" and "break_print" use the same option letter (-b) to introduce
the breakpoint number.

Fix a bug in the implementation of "break_print" that led to printing out
the selected variable, but not the selected *path* within the selected
variable. The reason was that we recorded what to print (variable spec plus
path) in a string, but that the process of using that record to print out
what was wanted destroyed the string (by putting a NULL between the variable
specification and the path), so that *later* uses of that string would find
an empty path. The fix is to record a var_spec/path pair in the print list.

Fix some slightly misleading output: when printing part of a variable, we
printed the name of the variable without any indication that the value printed
wasn't the whole value of the variable. We now print the path as well.

doc/user_guide.texi:
	Document the changes above.

	Document the usage "break_print [options] none", which we have always
	supported, but which was not documented.

runtime/mercury_stack_layout.h:
	Add a utility macro.

trace/mercury_trace.c:
	Fix a bug which left a variable uninitialized.

trace/mercury_trace_cmd_breakpoint.c:
	Implement the new command forms and options described above.

trace/mercury_trace_spy.[ch]:
	Implement data structures for keeping track of the new forms of
	breakpoints, and add the necessary functions for manipulating them.
	Update the function that checks whether the current event matches.
	Factor some common code out of that function, as well as out of the
	functions for adding new breakpoints.

	Change the print list data structure as described above.

	Add some utility functions.

	Add MR_ prefixes to the names of structure fields that previously
	lacked them.

trace/mercury_trace_cmd_misc.c:
	Handle the new breakpoint types.

trace/mercury_trace_tables.c:
trace/mercury_trace_internal.c:
	We used to parse the event set descriptions in module layout structures
	when the debugger was initialized (in mercury_trace_internal.c).
	However, we delay registering all the modules until this is needed,
	so at that time we don't yet *have* the list of module layout
	structures, so we used to parse nothing. This diff moves the code
	for doing the parsing to the time when the module layout structures
	are registered (in mercury_trace_tables.c).

	Don't test whether the module layout structure contains the fields
	for user event descriptions, since that diff has been installed on
	all our systems weeks ago.

trace/mercury_trace_internal.c:
	Conform to the new print list structure.

trace/mercury_trace_vars.[ch]:
	Print any selected path together with a variable name when printing a
	value. (This is the last bug fix mentioned at the top.)

	Export a function for use in mercury_trace_internal.c.

	Add some utility functions.

	Improve some error messages.

trace/mercury_trace_tables.h:
	Add a const qualifier.

tests/debugger/user_event.{inp,exp}:
	Extend this test case to test the new functionality.

tests/debugger/breakpoints.{inp,exp,exp2}:
	Conform to the change to the break_print command.

tests/queens.{inp,exp}:
	Change the input to test the bug fix to the break_print command,
	and the expected output.

tests/browser_test.exp:
tests/field_names.exp:
	Conform to the fact that we now print paths after variables names.
2007-01-19 04:42:52 +00:00
Zoltan Somogyi
dd44e0ef62 Replace the "set" command of mdb with a bunch of commands: the `format',
Estimated hours taken: 16
Branches: main, release

Replace the "set" command of mdb with a bunch of commands: the `format',
`format_param', `list_context_lines', `list_path', `xml_browser_cmd',
`xml_tmp_filename', `fail_trace_counts', `pass_trace_counts' and
`max_io_actions' commands. Each of these set just one parameter
or one of set of closely related parameters.

Move all these commands, and some existing commands that set parameters
that were elsewhere, to the "parameter" command category.

Extend some of these commands so that if given no arguments, they report
the current values of the parameters they would otherwise set.

Replace the "set" commands of the mdb browser and of the declarative debugger
with a bunch of commands: "format", "depth", "size", "width", "lines",
"actions" and "params" (the last prints the current value of the parameters).

For each category of mdb commands, create files mercury_trace_cmd_<cat>.[ch],
and move the functions dealing with that category of commands there from
mercury_trace_internal.c. Give each of these new files a logical structure
that was sometimes missing from the relevant parts of mercury_trace_internal.c.

NEWS:
	Mention these changes.

doc/mdb_categories:
	Document these changes.

doc/user_guide.texi:
	Document these changes.

	Fix an old documentation bug: you couldn't set listing paramaters
	from a declarative debugger command.

	Fix an old documentation bug: the description of the goal_path step
	for scopes was obsolete.

	Fix some obsolete references to : as module qualifier.

browser/parse.m:
	Update the browser command set along the lines at the top.

browser/declarative_user.m:
	Update the declarative debugger command set along the lines at the top.

	Move the declaration for the type representing declarative debugger
	commands to near the top of the file.

browser/browser_info.m:
	Provide some access predicates.

	Update the predicate that generates mdb commands to save the persistent
	state of the debugger to generate the new forms of parameter commands.

	Move types and predicates for dealing with browser parameters from
	browse.m to here, so that declarative_user.m can use them too.

browser/browse.m:
	Delete the code moved to browser_info.m, and conform to the other
	changes in the other modules.

browser/listing.m:
	Provide a predicate to return the type of listing paths.

scripts/mdbrc.in:
	Update the commands that set the XML parameters.

scripts/Mmakefile:
	Get mmake to rebuild mdbrc from mdbrc.in when mdbrc.in changes.

trace/mercury_trace_internal.c:
trace/mercury_trace_cmds.h:
trace/mercury_trace_cmd_*.[ch]:
	Implement the changes described at the top.

	Fix an old bug: the commands that update the search path for the "list"
	command don't make the search path term permanent, which is needed in
	non-conservative-gc grades.

trace/mercury_trace_spy.c:
	Fix some obsolete references to : as module qualifier.

trace/mercury_trace_browse.[ch]:
	Delete the functionality now moved to mercury_trace_cmd_parameter.c.

tests/debugger/mdb_command_test.inp:
	Update the set of commands being tested.

tests/debugger/save.{inp,exp}:
	Update the parameter commands in this test case.
2006-04-04 07:37:31 +00:00
Zoltan Somogyi
387a6c8878 Allow uses to associate with each breakpoint in mdb a list of print actions
Estimated hours taken: 8
Branches: main

Allow uses to associate with each breakpoint in mdb a list of print actions
that should be executed automatically when execution arrives at the breakpoint.

A new print list (a list of things to be printed) can be attached to an
existing breakpoint via the new "break_print" command, or it can be attached
to a breakpoint being created via the existing "break" command.

NEWS:
	Mention the new capability.

doc/user_guide.texi:
	Document the new capability.

trace/mercury_trace_spy.[ch]:
	Keep a print list with every breakpoint, and add functions to
	manipulate print lists.

	Convert this module to four space indentation to keep indent levels
	manageable.

trace/mercury_trace.c:
	Conform to the updated interface of the mercury_trace_spy module.

trace/mercury_trace_internal.[ch]:
	When the internal debugger is invoked at an event, whether
	interactively or not, take an extra parameter specifying the
	print list, if any, to be executed.

	Implement the new "break_print" command and the new options of
	the "break" command.

	Conform to the updated interface of the mercury_trace_spy module.

trace/mercury_trace_declarative.c:
	Conform to the updated interface of the mercury_trace_internal module.

tests/debugger/breakpoints.{inp,exp*}:
	Test the new capability.

tests/debugger/completion.exp:
tests/debugger/mdb_command_test.inp:
	Update to reflect the new command.
2005-01-27 06:17:41 +00:00
Zoltan Somogyi
da102c25e5 When printing the list of procedures in a module, allow the module name
Estimated hours taken: 1
Branches: main

trace/mercury_trace_tables.c:
	When printing the list of procedures in a module, allow the module name
	to be specified by a nickname (a less than fully qualified name).

tests/debugger/breakpoints.{a.m,inp,exp*}:
	Test the new capability.
2005-01-17 04:29:31 +00:00
Zoltan Somogyi
32d85a300f Add a table for the less-than-fully-qualified names of modules,
Estimated hours taken: 3
Branches: main

trace/mercury_trace_tables.m:
	Add a table for the less-than-fully-qualified names of modules,
	allowing any prefix of the module name to be omitted.

	Use it to allow procedure specifications (e.g. in breakpoint commands)
	to use such module names, with fully qualified module names taking
	precedence over less-than-fully-qualified module names.

tests/debugger/breakpoints.{m,inp,exp*}:
tests/debugger/breakpoints.print_list.m:
tests/debugger/breakpoints.{a,b}.m:
tests/debugger/breakpoints.{a,b}.testmod.m:
	Update this test case to test the new functionality.
2004-01-21 04:55:50 +00:00
Ralph Becket
a8ffd3680c Change the compiler and tools so that .' and not :' is now used as the
Estimated hours taken: 14
Branches: main

Change the compiler and tools so that `.' and not `:' is now used as the
module separator in all output.

Infix `.' now has associativity yfx and priority 10.

NEWS:
	Report the change.

configure.in:
	Amend the test for an up-to-date Mercury compiler to check whether
	it recognises `.' as a module qualifier.

compiler/code_gen.m:
compiler/error_util.m:
compiler/hlds_out.m:
compiler/prog_out.m:
compiler/prog_util.m:
compiler/rl_exprn.m:
compiler/rl_gen.m:
compiler/source_file_map.m:
compiler/unused_args.m:
library/io.m:
library/rtti_implementation.m:
library/type_desc.m:
runtime/mercury_debug.c:
runtime/mercury_deconstruct.c:
runtime/mercury_stack_trace.c:
	Change `:' to `.' as module separator for output.

compiler/mercury_to_mercury.m:
compiler/prog_io_typeclass.m:
	As above.
	Fixed a bug where `.' was not being recognised as a module separator.

doc/reference_manual.texi:
	Report the change.

library/term_io.m:
	Ensure that infix `.' is written without surrounding spaces.

tests/hard_coded/dot_separator.m:
tests/hard_coded/dot_separator.exp:
tests/hard_coded/Mmakefile:
	Test case added.
2003-01-17 05:57:20 +00:00
Simon Taylor
5b16c5f3d0 Fix bugs in the code to parse and match procedure
Estimated hours taken: 2.5
Branches: main

Fix bugs in the code to parse and match procedure
specifications for breakpoints:
- handle nested modules.
- handle names containing '/' and '-'.
- use the correct arity for functions, not the arity of the
  corresponding predicate.

trace/mercury_trace_tables.c:
	Fix the bugs.

runtime/mercury_stack_layout.h:
	Add a macro to adjust the arity of functions
	recorded in MR_Proc_Layouts for printing.

runtime/mercury_stack_trace.c:
	Print the correct arity of functions in stack traces
	and debugger events.

tests/debugger/breakpoints.m:
tests/debugger/breakpoints.print_list.m:
tests/debugger/breakpoints.inp:
tests/debugger/breakpoints.exp:
	Add test cases.

tests/debugger/existential_type_classes.exp:
tests/debugger/polymorphic_output.exp3:
tests/debugger/declarative/func_call.exp:
	Update expected output. (I'll update the other output
	files after this change is installed).
2002-02-11 12:52:55 +00:00
Zoltan Somogyi
bbccf83461 Associate optional ignore counts with breakpoints.
Estimated hours taken: 12
Branches: main

Associate optional ignore counts with breakpoints.

trace/mercury_trace_spy.[ch]:
	Add a mechanism for ignoring break points until execution has gone
	through a given number of events matching the breakpoint; these events
	may be required to be of a given port type (call events or interface
	events).

trace/mercury_trace_internal.c:
	Add options to the break command to allow the ignore type and count to
	be set when a breakpoint is created.

	Add a new command, ignore, to allow the ignore type and count to be set
	when the breakpoint already exists.

	Add a new command, scope, to specify the default scope of new
	breakpoints.

doc/user_guide.texi:
	Document the ignore and scope commands and the new options of the
	break command.

configure.in:
runtime/mercury_conf.h.in:
	Check whether the system has the snprintf function.

runtime/RESERVED_MACRO_NAMES:
	Add HAVE_SNPRINTF to the list.

tests/debugger/mdb_command_test.inp:
	Test the new ignore commands' documentation.

tests/debugger/breakpoints.{inp,exp}:
	Extend this test case to test ignore counts.
2001-08-07 02:16:07 +00:00
Zoltan Somogyi
3f84f112ec Handle ambiguous procedure specifications in the debugger's "break" command
Estimated hours taken: 3

Handle ambiguous procedure specifications in the debugger's "break" command
more usefully.

trace/mercury_trace_tables.[ch]:
	Add a function for returning all the procedures that match a
	specification.

trace/mercury_trace_internal.c:
	Use this function to present the user all the matches for the procedure
	specification if their specification matches more than one procedure,
	and let them choose whether they want to put a breakpoint on them all,
	and if not, which one to put the breakpoint on.

doc/user_guide.texi:
	Document the new functionality.

tests/debugger/breakpoints.{m,in,exp}:
	Introduce a function named "data" to go with the predicate, and check
	that the "break" command handles the ambiguity properly.
2000-08-25 09:53:37 +00:00
Zoltan Somogyi
f058c2f67f Add a new command to the debugger for deleting (as opposed to disabling)
Estimated hours taken: 5

Add a new command to the debugger for deleting (as opposed to disabling)
breakpoints.

doc/user_guide.texi:
	Document the delete command.

trace/mercury_trace_internal.c:
	Implement the delete command, and move all the code that deals with
	breakpoints to trace/mercury_trace_spy.c, with the exception of code
	for user interaction (since this will be different for e.g. the
	external debugger).

	In several places, update the code to reflect the fact that the
	spy points array may now have holes: entries holding deleted spy
	points.

trace/mercury_trace_spy.[ch]:
	Centralize the code for handling breakpoints here, and add a function
	for handling the deletion of a breakpoint.

tests/debugger/breakpoints.{m,inp,exp}:
	A new test case for exercising the new functionality. The code
	is the same as queens.m; it is the script that is different.

tests/debugger/Mmakefile:
	Turn on the new test case.
1999-10-07 09:31:41 +00:00