next up previous contents index
Next: Scenario ``source'' Up: Morphine - Reference Manual Previous: Morphine - Reference Manual

Subsections

     
Scenario ``morphine_kernel''

Scenario morphine_kernel contains all the basic mechanisms of Morphine which are needed to debug Mercury programs.

Commands

fget(AttributeConstraints) {fg}    
Moves forwards through the execution until the first event that satisfy the list of constraints specified in AttributeConstraints (*). AttributeConstraints can be either a conjunction of attribute constraints, separated by ``and'' (fget(AC1 and AC2 and ...)) or a list of constraints (fget([AC1, AC2, ...])). The different attributes for fget are :
1.
chrono: chronological event number of the event,
2.
call: call event number of the event,
3.
depth: depth in the proof three (number of ancestors - 1) of the event,
4.
port: type of the event,
5.
proc_type: tells if the current procedure is a predicate or a function,
6.
decl_module: module name where the procedure is declared,
7.
def_module: module name where the procedure is defined,
8.
name: procedure name,
9.
arity: procedure arity,
10.
mode_number: procedure mode number,
11.
proc: procedure ([proc_type->][decl_module:](name[/arity][-mode_number]) where only the attribute name is mandatory],
12.
det: procedure determinism,
13.
goal_path: goal path of the call of the procedure.

(*) An attribute constraint is a term of the form ``AttributeAlias = Term'' where AttributeAlias is an alias of a Mercury event attribute and Term can be:

and for integer attributes (chrono, call, depth, arity), Each attribute has a list of possible aliases that you can list with the command list_alias_attributes/0.

Example: the Morphine goal fget(chrono = [20, 789] and depth = 3..6 and proc = foo/2) will make the execution move forwards until the first event which chronological event number is 20 or 789, depth is 3, 4, 5 or 6, procedure name is foo and arity is not 2. You can also use a list as an argument of fget: fget([chrono=[20, 789], depth = 3..6, proc = foo/2]) will have the same effect as the previous goal.
AttributeConstraints : is_list_or_conj_of_attribute_constraints_fget
type of command : trace

det_fget(List)    
It is the deterministic version of fget/1.
List : is_list_or_conj_of_attribute_constraints_fget
type of command : trace

retry    
Restarts execution at the call port of the current goal. The command will fail unless the values of all the input arguments are available at the current port. (The compiler will keep the values of the input arguments of traced procedures as long as possible, but it cannot keep them beyond the point where they are destructively updated.)

The debugger can perform a retry only from an exit or fail port; only at these ports does the debugger have enough information to figure out how to reset the stacks. If the debugger is not at such a port when a retry command is given, the debugger will continue forward execution until it reaches an exit or fail port of the call to be retried before it performs the retry. This may require a noticeable amount of time.
type of command : trace

current(AttributesConjunctOrList) {curr}    
Gets or checks the values of the event attributes specified in AttributesConjunctOrList. AttributesConjunctOrList is a conjunction or a list of terms of the form attribute = Value. If Value is a free variable, it is unified with the current value of the attribute. If Value is a ground term, the current value of the attribute is retrieved and checked against Value. The different attributes for current/1 are :

1.
chrono: chronological event number of the event,
2.
call: call event number of the event,
3.
depth: depth in the proof three (number of ancestors - 1) of the event,
4.
port: type of the event,
5.
proc_type: tells if the current procedure is a predicate or a function,
6.
decl_module: module name where the procedure is declared,
7.
def_module: module name where the procedure is defined,
8.
name: procedure name,
9.
arity: procedure arity,
10.
mode_number: procedure mode number,
11.
proc: procedure ([proc_type->][decl_module:](name[/arity][-mode_number]) where only the attribute name is mandatory),
12.
det: procedure determinism,
13.
goal_path: goal path of the call of the procedure,
14.
args: list of procedure arguments (*),
15.
arg_names: list of procedure argument names,
16.
arg_types: list of procedure argument types, v
17.
ars: list of the currently live variables,
18.
var_names_and_types: list of the currently live variable names and types,
19.
local_vars: list of the currently non-argument local live variables.

For example, current(chrono = Chrono and name = Name) (or current([chrono = Chrono, name = Name])) will unify Chrono with the chronological event number and Name with the procedure name of the current event. current(depth =3) will succeed iff the depth of the current event is 3. current(args =[Arg1, -, -]) will unify Arg1 with the first argument of the current procedure if is live. (*) non lived arguments are unified with '-' and if you do not want to retrieve all the arguments (because one of them is very big for example), you can use the atom '-': for example, current(arg = [X, -, -]) will only retrieve the first argument. Note that current(arg = [X, _, _] will have the same behaviour, but arguments will be retrieved through the socket.
AttributesConjunctOrList : is_list_or_conj_of_attributes_current
type of command : opium

current_live_var(VarId, VarValue, VarType) {clv}    
Gets or checks the name, the value and the type of the currently live variables. VarId can be a string representing the variable name or, if it is an argument of the current procedure, an integer representing the rank the argument. Example: current_live_var(``HeadVar__3'', VarValue, _Type) (or equivalently current_live_var(3, VarValue, _Type)) binds VarValue with the current value of the third argument of the current predicate if it exists and if it is live, fails otherwise. You can get all the live variables by querying current_live_var(VarId, VarValue, VarType) and typing ``;'' at the prompt to search for other solutions. You can also get the list of all the currently live variables of type int with the Morphine query setof((Name, Value), current_live_var(Name, Value, int), List).
VarId : is_string_or_integer_or_var
VarValue : is_term
VarType : is_atom_or_var
type of command : opium

stack    
Displays the ancestors stack.
type of command : opium

list_attribute_aliases {laa}    
List the available aliases for the different Mercury event attributes (fget/1 and current/1).
type of command : opium

re_init_opium    
Re-initializes the Morphine debugging session. This command migth be useful if Morphine is broken.
type of command : opium

run(ProgramCall)    
Executes a Mercury program from Morphine.

Example: run(``./cat(filename)'') will run under the control of Morphine the mercury program ``cat'' that takes ``filename'' as argument. run(hello) will run the Mercury program hello.
ProgramCall : is_atom_or_string
type of command : opium

abort_trace {a}    
Aborts the current execution in the traced session.
type of command : opium

no_trace {o}    
Continues execution until it reaches the end of the current execution without printing any further trace information.
type of command : opium

rerun {r}    
Runs again the last executed program.
type of command : opium

goto(Chrono)    
Moves forwards the trace pointer to the event with chronological event number Chrono. If the current event number is larger than Chrono, it fails.
Chrono : integer
type of command : trace no_window    
Set the `window_command' parameter to "" (its default value). The Mercury program executes in the same window as Morphine.
type of command : opium

use_xterm    
Set the `window_command' parameter to "xterm -e ", which make the Mercury executes in a new xterm window; the program's Input/Output will go to that window and the Morphine's Input/Output will go to the current terminal.
type of command : opium

use_gdb    
Set the `window_command' parameter to "xterm -e gdb ". This is to be able to use both gdb and Morphine. Note that to use gdb, you will need to compile your mercury program with the option `-c-debug'.
type of command : opium

browse(VarName)    
Call the Mercury term browser. Type `help' at the browser prompt to get on-line help
VarName : string
type of command : opium

query(ModuleList)    
The commands query/1, cc_query/1 and io_query/1 allow you to type in queries (goals) interactively in the debugger. When you use one of these commands, the debugger will respond with a query prompt (`?-' or `run <-'), at which you can type in a goal; the debugger will the compile and execute the goal and display the answer(s). You can return from the query prompt to the Morphine prompt by typing the end-of-file indicator (typically control-D or control-Z), or by typing `quit.'.

The list of module names passed down in the argument of the query specify which modules will be imported. Note that you can also add new modules to the list of imports directly at the query prompt, by using a command of the form `[module]', e.g. `[int]'. You need to import all the modules that define symbols used in your query. Queries can only use symbols that are exported from a module; entities which are declared in a module's implementation section only cannot be used.

The three variants differ in what kind of goals they allow. For goals which perform I/O, you need to use `io_query/1'; this lets you type in the goal using DCG syntax. For goals which don't do I/O, but which have determinism `cc_nondet' or `cc_multi', you need to use `cc_query/1'; this finds only one solution to the specified goal. For all other goals, you can use plain `query/1', which finds all the solutions to the goal. For `query/1' and `cc_query/1', the debugger will print out all the variables in the goal using `io__write'. The goal must bind all of its variables to ground terms, otherwise you will get a mode error.

The current implementation works by compiling the queries on-the-fly and then dynamically linking them into the program being debugged. Thus it may take a little while for your query to be executed. Each query will be written to a file named `query.m' in the current directory, so make sure you don't name your source file `query.m'. Note that dynamic linking may not be supported on some systems; if you are using a system for which dynamic linking is not supported, you will get an error message when you try to run these commands.
ModuleList : is_list
type of command : opium

cc_query(ModuleList)    
cf query/1.
ModuleList : is_list
type of command : opium

io_query(ModuleList)    
cf query/1.
ModuleList : is_list
type of command : opium

mmc_options(String)    
This command sets the options that will be passed to `mmc' to compile your query when you use one of the query commands: `query/1', `cc_query/2', or `io_query/3'. For example, if a query results in a compile error, it may sometimes be helpful to use mmc_options("-verbose-errors").
String : string
type of command : opium

Primitives

fget_np(AttributeConstraints) {fg_np}    
Primitive which does the same as command fget except printing a trace line.
AttributeConstraints : is_list_or_conj_of_attribute_constraints_fget

det_fget_np(List)    
Primitive which does the same as command det_fget except printing a trace line.
List : is_list_or_conj_of_attribute_constraints_fget

retry_np    
Primitive which does the same as command retry except printing a trace line.

current_arg(ArgumentList)    
Gets or checks the values of the currently live arguments of the current event. It will unify non-live arguments with the atom '-'. Example: if the first argument of the current procedure is 2, the second is [4, 6] and the third is not live, current_arg(Arg) will unify Arg with the list [2, [4, 6], -].

If you do not want to retrieve an argument (because it is very big for example), you can use the atom '-': for example, current_arg([X, -, -]) will only retrieve the first argument.
ArgumentList : is_list_or_var

current_arg_names(ListArgNames)    
Gets or checks the list of the names of the current procedure arguments. Unify non-live arguments with the atom '-'.
ListArgNames : is_list_or_var

current_arg_types(ListArgTypes)    
Gets or checks the list of the arguments types of the current procedure. Unify non-live arguments with the atom '-'
ListArgTypes : is_list_or_var

current_vars(LiveArgList, OtherLiveVarList)    
Gets or checks the values of the currently live (*) variables of the current event. These variables are separated in two lists: one containing the live arguments of the current predicate, one containing other currently live variables.

(*) We say that a variable is live at a given point of the execution if it has been instantiated and if the result of that instantiation is still available (which is not the case for for destructively updated variables).
LiveArgList : is_list_or_var
OtherLiveVarList : is_list_or_var

current_live_var_names_and_types(ListVarNames)    
Gets or checks the list of names and types of the currently live variables. Each live variable is represented by the term live_var_names_and_types(VariableName, TypeOfTheVariable).
ListVarNames : is_list_or_var

current_live_var_names_and_types    
current_live_var_names_and_types/0 gets and displays the live variable names and types. You can change this display by customizing the procedure display_list_var_names.

nondet_stack    
Prints the contents of the fixed attributes of the frames on the nondet stack. This command is intended to be of use only to developers of the Mercury implementation.

stack_regs    
Prints the contents of the virtual machine registers that point to the det and nondet stacks. This command is intended to be of use only to developers of the Mercury implementation.

init_opium_session    
Initializes Morphine.

goto_np(Chrono)    
Primitive which does the same as command goto except printing a trace line.
Chrono : integer

end_connection {ec}    
Ends the connection with the traced program.

Procedures

opium_write_debug(X)    
This procedure is used to print information to debug Opium.

opium_write_debug(Stream, X)    
This procedure is used to print information to debug Opium.

opium_printf_debug(Format, X)    
This procedure is used to print information to debug Opium.

opium_printf_debug(Stream, Format, X)    
This procedure is used to print information to debug Opium.

Parameters

socket_domain(Domain)    
Parameter which tells which domain is used by the socket communication betwenn the two processes.
Domain : is_member([unix, inet])
default value : socket_domain(unix)
type of parameter : single

debug_opium(OnOff)    
Prints additional information in the trace to debug Opium.
OnOff : is_member([on, off])
default value : debug_opium(off)
type of parameter : single

Types

is_list_or_conj_of_attribute_constraints_fget    
Type which succeeds for list or conjunctions of terms of the form: ``AttributeAlias = Term'', where AttributeAlias is an alias of a Mercury event attribute and Term is a variable, an exact value, a negated value, a list of values, or an interval (Bottom..Up). Example: fget(chrono=[20, 789] and depth=3..6 and name=foo and arity=not(2)), which can also be typed fget([chrono=[20, 789], depth=3..6, name=foo, arity=not(2)])

is_list_or_conj_of_attributes_current    
Type which succeeds for list or conjunctions of terms of the form: ``AttributeAlias = Term'', where AttributeAlias is an alias of a Mercury event attribute and Term is a variable or a possible value for the corresponding attribute. Example: current(name = Name and decl_module = module1), current([port = call, name = Name]).

is_port    
Type which succeeds for a Mercury Port. Mercury ports are call (or 'CALL'), exit (or 'EXIT'), fail (or 'FAIL'), redo (or 'REDO'), then (or 'THEN'), else (or 'ELSE'), disj (or 'DISJ'), switch (or 'SWITCH' or 'SWTC'), first (or 'FIRST' or 'FRST'), later (or 'LATER' or 'LATR'), exception (or 'EXCP' or 'EXCEPTION').

is_port_or_var    
Type which succeeds for a Mercury port or a variable (See is_port/1).

is_list_of_ports    
Type which succeeds for a sublist of ['CALL', 'EXIT', 'REDO', 'FAIL', 'THEN', 'ELSE', 'DISJ', 'SWITCH', 'SWTC', 'FIRST', 'FRST', 'LATER', 'LATR', 'EXCP', 'EXCEPTION', call, exit, fail, redo, then, else, disj, switch, first, later, exception].

is_port_attribute    
Type which succeeds for a port, a negated port (not('CALL')), a list of ports, '-' or a variable.

is_goal_path    
Type which succeeds for list of atoms of the form 'e', 't', '?', 'ci', 'si', 'di' where i is an integer > 0.

is_goal_path_or_var    
Type which succeeds for a Mercury goal path or a variable (See is_goal_path/1).

is_goal_path_attribute    
Type which succeeds for a goal path, a negated goal path, a list of goal path, '-' or a variable.

is_atom_attribute    
Type which succeeds for an atom, a negated atoms, a list of atom, a variable or '-'. It is intended to check proc_name def_module and decl_module attributes.

is_proc_type    
Type which succeeds for the atoms predicate and function.

is_proc_type_attribute    
Type which succeeds for pred or func, not(pred) or not(func), a list of atoms pred or func, '-' or a variable.

is_det_marker    
Type which succeeds for a Mercury determinism marker. Mercury determinism are det (or DET'), semidet (or 'SEMI'), nondet (or 'NON'), multidet (or MUL'), cc_nondet (or 'CCNON'), cc_multidet (or 'CCMUL'), failure (or 'FAIL') and erroneous (or 'ERR').

is_det_marker_or_var    
Type which succeeds for a Mercury determinism markers or a variable.

is_list_of_dets    
Type which succeeds for a sublist of [det, semidet, nondet, multidet, cc_nondet, cc_multidet, failure, erroneous, 'DET', 'SEMI', 'NON', 'MUL', 'ERR', 'FAIL', 'CCNON', 'CCMUL'] (the determinism marker in capital letters are the one use in mdb, the internal Mercury debugger).

is_det_marker_attribute    
Type which succeeds for a Mercury determinism marker, a negated determinism (not(nondet)), a list of determinism markers, '-' or a variable.

is_proc    
Type which succeeds for terms of the form [ProcType+][Module:]ProcName[/Arity][-ModeNum] where terms betwenn square bracquets are optional, ProcType has type is_proc_type_attribute/1, Module and ProcName have type is_atom_attribute/1, Arity and ModeNum have type is_integer_attribute/1.

is_proc_or_var    
Type which succeeds for a Mercury procedure or a variable.

is_arg_attribute    
For the time being, you can't perform filtering on arguments i.e. you can only have variables or '-' for that attribute.

is_integer_attribute    
Type which succeeds for an integer, a negated integer (not 6), a list of integers ([3, 5, 9]), an interval ('3..11'), a variable or '-'.

is_string_attribute    
Type which succeeds for a string, a negated string (not ``foo''), a list of strings, a variable or '-'.


next up previous contents index
Next: Scenario ``source'' Up: Morphine - Reference Manual Previous: Morphine - Reference Manual
jahier@irisa.fr