~rdoering/ubuntu/karmic/erlang/fix-535090

« back to all changes in this revision

Viewing changes to lib/debugger/doc/src/int.xml

  • Committer: Bazaar Package Importer
  • Author(s): Sergei Golovan
  • Date: 2009-02-15 16:42:52 UTC
  • mfrom: (3.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090215164252-q5x4rcf8a5pbesb1
Tags: 1:12.b.5-dfsg-2
Upload to unstable after lenny is released.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="latin1" ?>
 
2
<!DOCTYPE erlref SYSTEM "erlref.dtd">
 
3
 
 
4
<erlref>
 
5
  <header>
 
6
    <copyright>
 
7
      <year>1998</year>
 
8
      <year>2007</year>
 
9
      <holder>Ericsson AB, All Rights Reserved</holder>
 
10
    </copyright>
 
11
    <legalnotice>
 
12
  The contents of this file are subject to the Erlang Public License,
 
13
  Version 1.1, (the "License"); you may not use this file except in
 
14
  compliance with the License. You should have received a copy of the
 
15
  Erlang Public License along with this software. If not, it can be
 
16
  retrieved online at http://www.erlang.org/.
 
17
 
 
18
  Software distributed under the License is distributed on an "AS IS"
 
19
  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
 
20
  the License for the specific language governing rights and limitations
 
21
  under the License.
 
22
 
 
23
  The Initial Developer of the Original Code is Ericsson AB.
 
24
    </legalnotice>
 
25
 
 
26
    <title>int</title>
 
27
    <prepared></prepared>
 
28
    <docno></docno>
 
29
    <date></date>
 
30
    <rev></rev>
 
31
  </header>
 
32
  <module>int</module>
 
33
  <modulesummary>Interpreter Interface</modulesummary>
 
34
  <description>
 
35
    <p>The Erlang interpreter provides mechanisms for breakpoints and
 
36
      stepwise execution of code. It is mainly intended to be used by
 
37
      the <em>Debugger</em>, see Debugger User's Guide and
 
38
      <c>debugger(3)</c>.</p>
 
39
    
 
40
    <p>From the shell, it is possible to:</p>
 
41
    <list>
 
42
      <item>Specify which modules should be interpreted.</item>
 
43
      <item>Specify breakpoints.</item>
 
44
      <item>Monitor the current status of all processes executing code
 
45
        in interpreted modules, also processes at other Erlang nodes.
 
46
      </item>
 
47
    </list>
 
48
 
 
49
    <p>By <em>attaching to</em> a process executing interpreted code, it
 
50
      is possible to examine variable bindings and order stepwise
 
51
      execution. This is done by sending and receiving information
 
52
      to/from the process via a third process, called the meta process.
 
53
      It is possible to implement your own attached process. See
 
54
      <c>int.erl</c> for available functions and <c>dbg_ui_trace.erl</c>
 
55
      for possible messages.</p>
 
56
 
 
57
    <p>The interpreter depends on the Kernel, STDLIB and GS
 
58
      applications, which means modules belonging to any of these
 
59
      applications are not allowed to be interpreted as it could lead
 
60
      to a deadlock or emulator crash. This also applies to modules
 
61
      belonging to the Debugger application itself.</p>
 
62
  </description>
 
63
 
 
64
  <section>
 
65
    <title>Breakpoints</title>
 
66
 
 
67
    <p>Breakpoints are specified on a line basis. When a process
 
68
      executing code in an interpreted module reaches a breakpoint, it
 
69
      will stop. This means that that a breakpoint must be set at an
 
70
      executable line, that is, a line of code containing an executable
 
71
      expression.</p>
 
72
 
 
73
    <p>A breakpoint have a status, a trigger action and may have a
 
74
      condition associated with it. The status is either <em>active</em>
 
75
      or <em>inactive</em>. An inactive breakpoint is ignored. When a
 
76
      breakpoint is reached, the trigger action specifies if
 
77
      the breakpoint should continue to be active (<em>enable</em>), if
 
78
      it should become inactive (<em>disable</em>), or if it should be
 
79
      removed (<em>delete</em>). A condition is a tuple
 
80
      <c>{Module,Name}</c>. When the breakpoint is reached,
 
81
      <c>Module:Name(Bindings)</c> is called. If this evaluates to
 
82
      <c>true</c>, execution will stop. If this evaluates to
 
83
      <c>false</c>, the breakpoint is ignored. <c>Bindings</c> contains
 
84
      the current variable bindings, use <c>get_binding</c> to retrieve
 
85
      the value for a given variable.</p>
 
86
 
 
87
    <p>By default, a breakpoint is active, has trigger action
 
88
      <c>enable</c> and has no condition associated with it. For more
 
89
      detailed information about breakpoints, refer to Debugger User's
 
90
      Guide.</p>
 
91
  </section>
 
92
 
 
93
  <funcs>
 
94
    <func>
 
95
      <name>i(AbsModule) -> {module,Module} | error</name>
 
96
      <name>i(AbsModules) -> ok</name>
 
97
      <name>ni(AbsModule) -> {module,Module} | error</name>
 
98
      <name>ni(AbsModules) -> ok</name>
 
99
      <fsummary>Interpret a module</fsummary>
 
100
      <type>
 
101
        <v>AbsModules = [AbsModule]</v>
 
102
        <v>AbsModule = Module | File | [Module | File]</v>
 
103
        <v>&nbsp;Module = atom()</v>
 
104
        <v>&nbsp;File = string()</v>
 
105
      </type>
 
106
      <desc>
 
107
        <p>Interprets the specified module(s). <c>i/1</c> interprets
 
108
          the module only at the current node. <c>ni/1</c> interprets
 
109
          the module at all known nodes.</p>
 
110
 
 
111
        <p>A module may be given by its module name (atom) or by its
 
112
          file name. If given by its module name, the object code
 
113
          <c>Module.beam</c> is searched for in the current path.
 
114
          The source code <c>Module.erl</c> is searched for first in
 
115
          the same directory as the object code, then in a <c>src</c>
 
116
          directory next to it.</p>
 
117
 
 
118
        <p>If given by its file name, the file name may include a path
 
119
          and the <c>.erl</c> extension may be omitted. The object code
 
120
          <c>Module.beam</c> is searched for first in the same directory
 
121
          as the source code, then in an <c>ebin</c> directory next to
 
122
          it, and then in the current path.</p>
 
123
 
 
124
        <note>
 
125
          <p>The interpreter needs both the source code and the object
 
126
            code, and the object code <em>must</em> include debug
 
127
            information. That is, only modules compiled with the option
 
128
            <c>debug_info</c> set can be interpreted.</p>
 
129
        </note>
 
130
 
 
131
        <p>The functions returns <c>{module,Module}</c> if the module
 
132
          was interpreted, or <c>error</c> if it was not.</p>
 
133
 
 
134
        <p>The argument may also be a list of modules/file names, in
 
135
          which case the function tries to interpret each module as
 
136
          specified above. The function then always returns <c>ok</c>,
 
137
          but prints some information to stdout if a module could not be
 
138
          interpreted.</p>
 
139
      </desc>
 
140
    </func>
 
141
        
 
142
    <func>
 
143
      <name>n(AbsModule) -> ok</name>
 
144
      <name>nn(AbsModule) -> ok</name>
 
145
      <fsummary>Stop interpreting a module</fsummary>
 
146
      <type>
 
147
        <v>AbsModule = Module | File | [Module | File]</v>
 
148
        <v>&nbsp;Module = atom()</v>
 
149
        <v>&nbsp;File = string()</v>
 
150
      </type>
 
151
      <desc>
 
152
        <p>Stops interpreting the specified module. <c>n/1</c> stops
 
153
          interpreting the module only at the current node. <c>nn/1</c>
 
154
          stops interpreting the module at all known nodes.</p>
 
155
 
 
156
        <p>As for <c>i/1</c> and <c>ni/1</c>, a module may be given by
 
157
          either its module name or its file name.</p>
 
158
      </desc>
 
159
    </func>
 
160
 
 
161
    <func>
 
162
      <name>interpreted() -> [Module]</name>
 
163
      <fsummary>Get all interpreted modules</fsummary>
 
164
      <type>
 
165
        <v>Module = atom()</v>
 
166
      </type>
 
167
      <desc>
 
168
        <p>Returns a list with all interpreted modules.</p>
 
169
      </desc>
 
170
    </func>
 
171
 
 
172
    <func>
 
173
      <name>file(Module) -> File | {error,not_loaded}</name>
 
174
      <fsummary>Get the file name for an interpreted module</fsummary>
 
175
      <type>
 
176
        <v>Module = atom()</v>
 
177
        <v>File = string()</v>
 
178
      </type>
 
179
      <desc>
 
180
        <p>Returns the source code file name <c>File</c> for an
 
181
          interpreted module <c>Module</c>.</p>
 
182
      </desc>
 
183
    </func>
 
184
 
 
185
    <func>
 
186
      <name>interpretable(AbsModule) -> true | {error,Reason}</name>
 
187
      <fsummary>Check if a module is possible to interpret</fsummary>
 
188
      <type>
 
189
        <v>AbsModule = Module | File</v>
 
190
        <v>&nbsp;Module = atom()</v>
 
191
        <v>&nbsp;File = string()</v>
 
192
        <v>Reason = no_src | no_beam | no_debug_info | badarg
 
193
          | {app,App}</v>
 
194
        <v>&nbsp;App = atom()</v>
 
195
      </type>
 
196
      <desc>
 
197
        <p>Checks if a module is possible to interpret. The module can
 
198
          be given by its module name <c>Module</c> or its source file
 
199
          name <c>File</c>. If given by a module name, the module is
 
200
          searched for in the code path.</p>
 
201
 
 
202
        <p>The function returns <c>true</c> if both source code and
 
203
          object code for the module is found, the module has been
 
204
          compiled with the option <c>debug_info</c> set and does not
 
205
          belong to any of the applications Kernel, STDLIB, GS or
 
206
          Debugger itself.</p>
 
207
 
 
208
        <p>The function returns <c>{error,Reason}</c> if the module for
 
209
          some reason is not possible to interpret.</p>
 
210
        
 
211
        <p><c>Reason</c> is <c>no_src</c> if no source code is found or
 
212
          <c>no_beam</c> if no object code is found. It is assumed that
 
213
          the source- and object code are located either in the same
 
214
          directory, or in <c>src</c> and <c>ebin</c> directories next
 
215
          to each other.</p>
 
216
 
 
217
        <p><c>Reason</c> is <c>no_debug_info</c> if the module has not
 
218
          been compiled with the option <c>debug_info</c> set.</p>
 
219
 
 
220
        <p><c>Reason</c> is <c>badarg</c> if <c>AbsModule</c> is not
 
221
          found. This could be because the specified file does not
 
222
          exist, or because <c>code:which/1</c> does not return a
 
223
          beam file name, which is the case not only for non-existing
 
224
          modules but also for modules which are preloaded or cover
 
225
          compiled.</p>
 
226
 
 
227
        <p><c>Reason</c> is <c>{app,App}</c> where <c>App</c> is
 
228
          <c>kernel</c>, <c>stdlib</c>, <c>gs</c> or <c>debugger</c> if
 
229
          <c>AbsModule</c> belongs to one of these applications.</p>
 
230
 
 
231
        <p>Note that the function can return <c>true</c> for a module
 
232
          which in fact is not interpretable in the case where
 
233
          the module is marked as sticky or resides in a directory
 
234
          marked as sticky, as this is not discovered until
 
235
          the interpreter actually tries to load the module.</p>
 
236
      </desc>
 
237
    </func>
 
238
 
 
239
    <func>
 
240
      <name>auto_attach() -> false | {Flags,Function}</name>
 
241
      <name>auto_attach(false)</name>
 
242
      <name>auto_attach(Flags, Function)</name>
 
243
      <fsummary>Get/set when and how to attach to a process</fsummary>
 
244
      <type>
 
245
        <v>Flags = [init | break | exit]</v>
 
246
        <v>Function = {Module,Name,Args}</v>
 
247
        <v>&nbsp;Module = Name = atom()</v>
 
248
        <v>&nbsp;Args = [term()]</v>
 
249
      </type>
 
250
      <desc>
 
251
        <p>Gets and sets when and how to automatically attach to a
 
252
          process executing code in interpreted modules. <c>false</c>
 
253
          means never automatically attach, this is the default.
 
254
          Otherwise automatic attach is defined by a list of flags and
 
255
          a function. The following flags may be specified:</p>
 
256
        <list>
 
257
          <item><c>init</c> - attach when a process for the very first
 
258
            time calls an interpreted function.</item>
 
259
          <item><c>break</c> - attach whenever a process reaches a
 
260
            breakpoint.</item>
 
261
          <item><c>exit</c> - attach when a process terminates.</item>
 
262
        </list>
 
263
 
 
264
        <p>When the specified event occurs, the function <c>Function</c>
 
265
          will be called as:</p>
 
266
        <pre>
 
267
spawn(Module, Name, [Pid | Args])
 
268
        </pre>
 
269
        <p><c>Pid</c> is the pid of the process executing interpreted
 
270
          code.</p>
 
271
      </desc>
 
272
    </func>
 
273
 
 
274
    <func>
 
275
      <name>stack_trace() -> Flag</name>
 
276
      <name>stack_trace(Flag)</name>
 
277
      <fsummary>Get/set if and how to save call frames</fsummary>
 
278
      <type>
 
279
        <v>Flag = all | no_tail | false</v>
 
280
      </type>
 
281
      <desc>
 
282
        <p>Gets and sets how to save call frames in the stack. Saving
 
283
          call frames makes it possible to inspect the call chain of a
 
284
          process, and is also used to emulate the stack trace if an
 
285
          error (an exception of class error) occurs.</p>
 
286
        <list>
 
287
          <item><c>all</c> - save information about all current calls,
 
288
            that is, function calls that have not yet returned a value.
 
289
            This is the default.</item>
 
290
          <item><c>no_tail</c> - save information about current calls,
 
291
            but discard previous information when a tail recursive call
 
292
            is made. This option consumes less memory and may be
 
293
            necessary to use for processes with long lifetimes and many
 
294
            tail recursive calls.</item>
 
295
          <item><c>false</c> - do not save any information about current
 
296
            calls.</item>
 
297
        </list>
 
298
      </desc>
 
299
    </func>
 
300
 
 
301
    <func>
 
302
      <name>break(Module, Line) -> ok | {error,break_exists}</name>
 
303
      <fsummary>Create a breakpoint</fsummary>
 
304
      <type>
 
305
        <v>Module = atom()</v>
 
306
        <v>Line = int()</v>
 
307
      </type>
 
308
      <desc>
 
309
        <p>Creates a breakpoint at <c>Line</c> in <c>Module</c>.</p>
 
310
      </desc>
 
311
    </func>
 
312
 
 
313
    <func>
 
314
      <name>delete_break(Module, Line) -> ok</name>
 
315
      <fsummary>Delete a breakpoint</fsummary>
 
316
      <type>
 
317
        <v>Module = atom()</v>
 
318
        <v>Line = int()</v>
 
319
      </type>
 
320
      <desc>
 
321
        <p>Deletes the breakpoint located at <c>Line</c> in
 
322
          <c>Module</c>.</p>
 
323
      </desc>
 
324
    </func>
 
325
 
 
326
    <func>
 
327
      <name>break_in(Module, Name, Arity) -> ok
 
328
        | {error,function_not_found}</name>
 
329
      <fsummary>Create breakpoints in the specified function</fsummary>
 
330
      <type>
 
331
        <v>Module = Name = atom()</v>
 
332
        <v>Arity = int()</v>
 
333
      </type>
 
334
      <desc>
 
335
        <p>Creates a breakpoint at the first line of every clause of 
 
336
          the <c>Module:Name/Arity</c> function.</p>
 
337
      </desc>
 
338
    </func>
 
339
 
 
340
    <func>
 
341
      <name>del_break_in(Module, Name, Arity) -> ok
 
342
        | {error,function_not_found}</name>
 
343
      <fsummary>Delete breakpoints from the specified function
 
344
      </fsummary>
 
345
      <type>
 
346
        <v>Module = Name = atom()</v>
 
347
        <v>Arity = int()</v>
 
348
      </type>
 
349
      <desc>
 
350
        <p>Deletes the breakpoints at the first line of every clause of 
 
351
          the <c>Module:Name/Arity</c> function.
 
352
        </p>
 
353
      </desc>
 
354
    </func>
 
355
 
 
356
    <func>
 
357
      <name>no_break() -> ok</name>
 
358
      <name>no_break(Module) -> ok</name>
 
359
      <fsummary>Delete all breakpoints</fsummary>
 
360
      <desc>
 
361
        <p>Deletes all breakpoints, or all breakpoints in <c>Module</c>.
 
362
        </p>
 
363
      </desc>
 
364
    </func>
 
365
 
 
366
    <func>
 
367
      <name>disable_break(Module, Line) -> ok</name>
 
368
      <fsummary>Make a breakpoint inactive</fsummary>
 
369
      <type>
 
370
        <v>Module = atom()</v>
 
371
        <v>Line = int()</v>
 
372
      </type>
 
373
      <desc>
 
374
        <p>Makes the breakpoint at <c>Line</c> in <c>Module</c>
 
375
          inactive.</p>
 
376
      </desc>
 
377
    </func>
 
378
 
 
379
    <func>
 
380
      <name>enable_break(Module, Line) -> ok</name>
 
381
      <fsummary>Make a breakpoint active</fsummary>
 
382
      <type>
 
383
        <v>Module = atom()</v>
 
384
        <v>Line = int()</v>
 
385
      </type>
 
386
      <desc>
 
387
        <p>Makes the breakpoint at <c>Line</c> in <c>Module</c> active.
 
388
        </p>
 
389
      </desc>
 
390
    </func>
 
391
 
 
392
    <func>
 
393
      <name>action_at_break(Module, Line, Action) -> ok</name>
 
394
      <fsummary>Set the trigger action of a breakpoint</fsummary>
 
395
      <type>
 
396
        <v>Module = atom()</v>
 
397
        <v>Line = int()</v>
 
398
        <v>Action = enable | disable | delete</v>
 
399
      </type>
 
400
      <desc>
 
401
        <p>Sets the trigger action of the breakpoint at <c>Line</c> in
 
402
          <c>Module</c> to <c>Action</c>.</p>
 
403
      </desc>
 
404
    </func>
 
405
 
 
406
    <func>
 
407
      <name>test_at_break(Module, Line, Function) -> ok</name>
 
408
      <fsummary>Set the conditional test of a breakpoint</fsummary>
 
409
      <type>
 
410
        <v>Module = atom()</v>
 
411
        <v>Line = int()</v>
 
412
        <v>Function = {Module,Name}</v>
 
413
        <v>&nbsp;Name = atom()</v>
 
414
      </type>
 
415
      <desc>
 
416
        <p>Sets the conditional test of the breakpoint at <c>Line</c> in
 
417
          <c>Module</c> to <c>Function</c>. The function must
 
418
          fulfill the requirements specified in the section
 
419
          <em>Breakpoints</em> above.</p>
 
420
      </desc>
 
421
    </func>
 
422
 
 
423
    <func>
 
424
      <name>get_binding(Var, Bindings) -> {value,Value} | unbound</name>
 
425
      <fsummary>Retrieve a variable binding</fsummary>
 
426
      <type>
 
427
        <v>Var = atom()</v>
 
428
        <v>Bindings = term()</v>
 
429
        <v>Value = term()</v>
 
430
      </type>
 
431
      <desc>
 
432
        <p>Retrieves the binding of <c>Var</c>. This function is
 
433
          intended to be used by the conditional function of a
 
434
          breakpoint.</p>
 
435
      </desc>
 
436
    </func>
 
437
 
 
438
    <func>
 
439
      <name>all_breaks() -> [Break]</name>
 
440
      <name>all_breaks(Module) -> [Break]</name>
 
441
      <fsummary>Get all breakpoints</fsummary>
 
442
      <type>
 
443
        <v>Break = {Point,Options}</v>
 
444
        <v>&nbsp;Point = {Module,Line}</v>
 
445
        <v>&nbsp;&nbsp;Module = atom()</v>
 
446
        <v>&nbsp;&nbsp;Line = int()</v>
 
447
        <v>&nbsp;Options = [Status,Trigger,null,Cond|]</v>
 
448
        <v>&nbsp;&nbsp;Status = active | inactive</v>
 
449
        <v>&nbsp;&nbsp;Trigger = enable | disable | delete</v>
 
450
        <v>&nbsp;&nbsp;Cond = null | Function</v>
 
451
        <v>&nbsp;&nbsp;&nbsp;Function = {Module,Name}</v>
 
452
        <v>&nbsp;&nbsp;&nbsp;&nbsp;Name = atom()</v>
 
453
      </type>
 
454
      <desc>
 
455
        <p>Gets all breakpoints, or all breakpoints in <c>Module</c>.
 
456
        </p>
 
457
      </desc>
 
458
    </func>
 
459
 
 
460
    <func>
 
461
      <name>snapshot() -> [Snapshot]</name>
 
462
      <fsummary>Get information about all processes excuting interpreted
 
463
        code</fsummary>
 
464
      <type>
 
465
        <v>Snapshot = {Pid, Function, Status, Info}</v>
 
466
        <v>&nbsp;Pid = pid()</v>
 
467
        <v>&nbsp;Function = {Module,Name,Args}</v>
 
468
        <v>&nbsp;&nbsp;Module = Name = atom()</v>
 
469
        <v>&nbsp;&nbsp;Args = [term()]</v>
 
470
        <v>&nbsp;Status = idle | running | waiting | break | exit
 
471
          | no_conn</v>
 
472
        <v>&nbsp;Info = {} | {Module,Line} | ExitReason</v>
 
473
        <v>&nbsp;&nbsp;Line = int()</v>
 
474
        <v>&nbsp;&nbsp;ExitReason = term()</v>
 
475
      </type>
 
476
      <desc>
 
477
        <p>Gets information about all processes executing interpreted code.
 
478
        </p>
 
479
        <list>
 
480
          <item><c>Pid</c> - process identifier.</item>
 
481
          <item><c>Function</c> - first interpreted function called by
 
482
            the process.</item>
 
483
          <item><c>Status</c> - current status of the process.</item>
 
484
          <item><c>Info</c> - additional information.</item>
 
485
        </list>
 
486
        <p><c>Status</c> is one of:</p>
 
487
        <list>
 
488
          <item><c>idle</c> - the process is no longer executing
 
489
            interpreted code. <c>Info={}</c>.</item>
 
490
          <item><c>running</c> - the process is running. <c>Info={}</c>.
 
491
          </item>
 
492
          <item><c>waiting</c> - the process is waiting at a
 
493
            <c>receive</c>. <c>Info={}</c>.</item>
 
494
          <item><c>break</c> - process execution has been stopped,
 
495
            normally at a breakpoint. <c>Info={Module,Line}</c>.</item>
 
496
          <item><c>exit</c> - the process has terminated.
 
497
            <c>Info=ExitReason</c>.</item>
 
498
          <item><c>no_conn</c> - the connection is down to the node
 
499
            where the process is running. <c>Info={}</c>.</item>
 
500
        </list>
 
501
      </desc>
 
502
    </func>
 
503
 
 
504
    <func>
 
505
      <name>clear() -> ok</name>
 
506
      <fsummary>Clear information about processes executing interpreted
 
507
        code</fsummary>
 
508
      <desc>
 
509
        <p>Clears information about processes executing interpreted code
 
510
          by removing all information about terminated processes.</p>
 
511
      </desc>
 
512
    </func>
 
513
 
 
514
    <func>
 
515
      <name>continue(Pid) -> ok | {error,not_interpreted}</name>
 
516
      <name>continue(X,Y,Z) -> ok | {error,not_interpreted}</name>
 
517
      <fsummary>Resume process execution</fsummary>
 
518
      <type>
 
519
        <v>Pid = pid()</v>
 
520
        <v>X = Y = Z = int()</v>
 
521
      </type>
 
522
      <desc>
 
523
        <p>Resume process execution for <c>Pid</c>, or for
 
524
          <c>c:pid(X,Y,Z)</c>.</p>
 
525
      </desc>
 
526
    </func>
 
527
  </funcs>
 
528
</erlref>
 
529