[m-rev.] for review: add `info' declarative debugger response

Julien Fischer juliensf at cs.mu.OZ.AU
Sat Feb 26 23:32:34 AEDT 2005


On Sat, 26 Feb 2005, Ian MacLarty wrote:

> For review by anyone.
>
> Estimated hours taken: 6
> Branches: main
>
> Add a new declarative debugger response, `info', which shows some information
> about the current question and the state of the bug search.
>
> browser/declarative_analyser.m
> 	Add the show_info predicate.
>
> browser/declarative_debugger.m
> 	Handle the oracle show_info response.
>
> browser/declarative_edt.m
> 	Add a new method to the mercury_edt typeclass, edt_context,
> 	which returns the filename and line number of the predicate for
> 	a node.
>
> browser/declarative_execution.m
> 	Instead of recording the goal path of a call in its parent, record
> 	the return label.  The goal path and the parent context can then
> 	be derived from the return label.
>
> 	Add a function to get the goal path from a return label.
>
> 	Add a function to get the context of a label.
>
> 	Modify the exported predicates used to build the annotated trace
> 	to take a return label instead of the goal path.
>
> browser/declarative_oracle.m
> 	Add a `show_info' oracle response.
>
> browser/declarative_tree.m
> 	Implement trace_context which returns the filename and line number
> 	of the predicate that corresponds with a node in the annotated trace.
>
> 	Derive a call's goal path in its caller from the return label where
> 	necessary.
>
> browser/declarative_user.m
> 	Add and document the user response `info'.
>
> browser/dice.m
> 	Fix a line that was over 79 characters.
>
> tests/debugger/declarative/Mmakefile
> tests/debugger/declarative/info.exp
> tests/debugger/declarative/info.inp
> tests/debugger/declarative/info.m
> 	Test the new response.
>
> trace/mercury_trace_declarative.c
> 	Pass the return label when constructing the annotated trace.
>

You need to add the info response to the user guide as well.

> +show_info(Store, OutStream, Analyser, Response, !IO) :-
> +	SearchSpace = Analyser ^ search_space,
> +	some [!FieldNames, !Data] (
> +		!:FieldNames = [],
> +		!:Data = [],
> +		%
> +		% Get the context of the current question.
> +		%
> +		(
> +			Analyser ^ last_search_question = yes(LastQuestionId),
> +			(
> +				edt_context(Store, get_edt_node(SearchSpace,
> +					LastQuestionId), FileName -  LineNo,
> +					MaybeReturnContext)
> +			->
> +				(
> +					MaybeReturnContext =
> +						yes(ReturnFileName -
> +						ReturnLineNo),
> +					ContextStr = FileName ++ ":" ++
> +						int_to_string(LineNo) ++
> +						" (" ++ ReturnFileName ++ ":"
> +						++ int_to_string(ReturnLineNo)
> +						++ ")"
> +				;
> +					MaybeReturnContext = no,
> +					ContextStr = FileName ++ ":" ++
> +						int_to_string(LineNo)
> +				),
> +				list.append(!.FieldNames,
> +					["Context of current question"],
> +					!:FieldNames),
> +				list.append(!.Data, [ContextStr], !:Data)
> +			;
> +				true
> +			)
> +		;
> +			Analyser ^ last_search_question = no,
> +			throw(internal_error("show_info", "no last question"))
> +		),
> +
> +		list.append(!.FieldNames, ["Search mode"],
> +			!:FieldNames),
> +		list.append(!.Data, [search_mode_to_string(
> +			Analyser ^ search_mode)], !:Data),
> +
> +		(
> +			Analyser ^ search_mode = divide_and_query
> +		->
> +			list.append(!.FieldNames,
> +				["Estimated questions remaining"],
> +				!:FieldNames),
> +			EstimatedQuestions = float.ceiling_to_int(
> +				math.log2(float(Weight))),
> +			list.append(!.Data,
> +				[int_to_string(EstimatedQuestions)], !:Data)
> +		;
> +			true
> +		),
> +
> +		list.append(!.FieldNames, ["Number of suspect events"],
> +			!:FieldNames),
> +		(
> +			root(SearchSpace, RootId)
> +		->
> +			StartId = RootId
> +		;
> +			topmost_det(SearchSpace, StartId)
> +		),
> +		Weight = get_weight(SearchSpace, StartId),
> +		list.append(!.Data, [int_to_string_thousands(Weight)], !:Data),
> +
> +		InfoMessage = string.format_table([left(!.FieldNames),
> +			left(!.Data)], " : ")
> +	),
> +	io.nl(OutStream, !IO),
> +	io.write_string(OutStream, InfoMessage, !IO),
> +	io.nl(OutStream, !IO),
> +	io.nl(OutStream, !IO),

That would be more concise as:

	io.format(OutStream, "\n%s\n\n", [s(InfoMessage)], !IO)

> +	Node = get_edt_node(SearchSpace, LastQuestionId),
> +	edt_question(Analyser ^ io_action_map, Store, Node,
> +		OracleQuestion),
> +	Response = oracle_question(OracleQuestion).

How large are the FieldNames and Data lists likely to get?  It may be
worth constructing them in reverse and then reversing them before you
need them rather than always appending to the end of a list.

The rest looks ok.

Julien.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list