int(3erl) | Erlang Module Definition | int(3erl) |
int - Interpreter Interface.
The Erlang interpreter provides mechanisms for breakpoints and stepwise execution of code. It is primarily intended to be used by Debugger, see the User's Guide and debugger(3erl).
The following can be done from the shell:
By attaching to a process executing interpreted code, it is possible to examine variable bindings and order stepwise execution. This is done by sending and receiving information to/from the process through a third process, called the meta process. You can implement your own attached process. See int.erl for available functions and dbg_wx_trace.erl for possible messages.
The interpreter depends on the Kernel, STDLIB, and GS applications. This means that modules belonging to any of these applications are not allowed to be interpreted, as it could lead to a deadlock or emulator crash. This also applies to modules belonging to the Debugger application.
Breakpoints are specified on a line basis. When a process executing code in an interpreted module reaches a breakpoint, it stops. This means that a breakpoint must be set at an executable line, that is, a code line containing an executable expression.
A breakpoint has the following:
By default, a breakpoint is active, has trigger action enable, and has no associated condition. For details about breakpoints, see the User's Guide.
i(AbsModule) -> {module,Module} | error
i(AbsModules) -> ok
ni(AbsModule) -> {module,Module} | error
ni(AbsModules) -> ok
Types:
Interprets the specified module(s). i/1 interprets the module only at the current node. ni/1 interprets the module at all known nodes.
A module can be specified by its module name (atom) or filename.
If specified by its module name, the object code Module.beam is searched for in the current path. The source code Module.erl is searched for first in the same directory as the object code, then in an src directory next to it.
If specified by its filename, the filename can include a path and the .erl extension can be omitted. The object code Module.beam is searched for first in the same directory as the source code, then in an ebin directory next to it, and then in the current path.
The functions returns {module,Module} if the module was interpreted, otherwise error is returned.
The argument can also be a list of modules or filenames, in which case the function tries to interpret each module as specified earlier. The function then always returns ok, but prints some information to stdout if a module cannot be interpreted.
n(AbsModule) -> ok
nn(AbsModule) -> ok
Types:
Stops interpreting the specified module. n/1 stops interpreting the module only at the current node. nn/1 stops interpreting the module at all known nodes.
As for i/1 and ni/1, a module can be specified by its module name or filename.
interpreted() -> [Module]
Types:
Returns a list with all interpreted modules.
file(Module) -> File | {error,not_loaded}
Types:
Returns the source code filename File for an interpreted module Module.
interpretable(AbsModule) -> true | {error,Reason}
Types:
Checks if a module can be interpreted. The module can be specified by its module name Module or its source filename File. If specified by a module name, the module is searched for in the code path.
The function returns true if all of the following apply:
The function returns {error,Reason} if the module cannot be interpreted. Reason can have the following values:
Notice that the function can return true for a module that in fact is not interpretable in the case where the module is marked as sticky or resides in a directory marked as sticky. The reason is that this is not discovered until the interpreter tries to load the module.
auto_attach() -> false | {Flags,Function}
auto_attach(false)
auto_attach(Flags, Function)
Types:
Gets and sets when and how to attach automatically to a process executing code in interpreted modules. false means never attach automatically, this is the default. Otherwise automatic attach is defined by a list of flags and a function. The following flags can be specified:
When the specified event occurs, the function Function is called as:
spawn(Module, Name, [Pid | Args])
Pid is the pid of the process executing interpreted code.
stack_trace() -> Flag
stack_trace(Flag)
Types:
Gets and sets how to save call frames in the stack. Saving call frames makes it possible to inspect the call chain of a process, and is also used to emulate the stack trace if an error (an exception of class error) occurs. The following flags can be specified:
break(Module, Line) -> ok | {error,break_exists}
Types:
Creates a breakpoint at Line in Module.
delete_break(Module, Line) -> ok
Types:
Deletes the breakpoint at Line in Module.
break_in(Module, Name, Arity) -> ok |
{error,function_not_found}
Types:
Creates a breakpoint at the first line of every clause of function Module:Name/Arity.
del_break_in(Module, Name, Arity) -> ok |
{error,function_not_found}
Types:
Deletes the breakpoints at the first line of every clause of function Module:Name/Arity.
no_break() -> ok
no_break(Module) -> ok
Deletes all breakpoints, or all breakpoints in Module.
disable_break(Module, Line) -> ok
Types:
Makes the breakpoint at Line in Module inactive.
enable_break(Module, Line) -> ok
Types:
Makes the breakpoint at Line in Module active.
action_at_break(Module, Line, Action) -> ok
Types:
Sets the trigger action of the breakpoint at Line in Module to Action.
test_at_break(Module, Line, Function) -> ok
Types:
Sets the conditional test of the breakpoint at Line in Module to Function. The function must fulfill the requirements specified in section Breakpoints.
get_binding(Var, Bindings) -> {value,Value} | unbound
Types:
Retrieves the binding of Var. This function is intended to be used by the conditional function of a breakpoint.
all_breaks() -> [Break]
all_breaks(Module) -> [Break]
Types:
Gets all breakpoints, or all breakpoints in Module.
snapshot() -> [Snapshot]
Types:
Gets information about all processes executing interpreted code.
Status is one of the following:
clear() -> ok
Clears information about processes executing interpreted code by removing all information about terminated processes.
continue(Pid) -> ok | {error,not_interpreted}
continue(X,Y,Z) -> ok | {error,not_interpreted}
Types:
Resumes process execution for Pid or c:pid(X,Y,Z).
debugger 4.2.6 | Ericsson AB |