Difference between revisions of "Sedb"

From Liberty Eiffel Wiki
Jump to navigation Jump to search
(typo)
(in French, English words are in italics. In English, they don't need to ;-))
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
[[Category:Book]]
 
[[Category:Book]]
   
  +
*** Please translate this page from the French one
 
  +
The SmartEiffel debugger is an ''Embedded debugger''. This means that, in order to use it, you need to compile your application with a special flag <TT>-sedb</TT>. The executable will then have the debugger inside, you can launch your application the usual way.
*** Thanks!
 
  +
  +
Note: <TT>sedb</TT> is only available with [[compile_to_c]] (or [[compile]]).
  +
  +
The debugger offers powerful commands which allows you to examine the bowels of your program:
  +
* commands to control execution,
  +
* commands to set or unset breakpoints,
  +
* commands to print your data,
  +
* other various commands.
  +
  +
== Execution control ==
  +
  +
These commands allows your program to execute. You can either run step by step or make bigger strides, or even force execution until the end.
  +
  +
Whatever your choice is, the program will run until the next breakpoint (see below), or until the next <TT>^C</TT>.
  +
  +
The available commands are (by increasing order of step size):
  +
  +
{|
  +
|-
  +
| <TT>s</TT>&nbsp;
  +
| Move only one ''step'' forward. This means entering a routine if it is a [[Glossary#Feature|feature]] call.
  +
|-
  +
| <TT>n</TT>&nbsp;
  +
| Move only one step forward (next), but without entering a routine (this means that a [[Glossary#Feature|feature]] call is considered being one step).
  +
|-
  +
| <TT>f</TT>&nbsp;
  +
| Move to the next routine return (finish).
  +
|-
  +
| <TT>c</TT>&nbsp;
  +
| Move as far as possible (continue), so maybe until the end of the program.
  +
|-
  +
| <TT>C</TT>&nbsp;
  +
| Continue until the end of the program, ignoring all breakpoints (statical et dynamical ones).
  +
|}
  +
  +
== Breakpoints ==
  +
  +
There is two kind of breakpoints:
  +
* those explicitly placed in the code, with the instruction <TT>sedb_breakpoint</TT>,
  +
* those dynamically placed in the debugger. To modify dynamical breakpoints, you can use the following commands:
  +
  +
{|
  +
|-
  +
| <TT>b</TT>&nbsp;
  +
| Add a dynamical breakpoint. There are many possible criteria, described below. All chosen criteria must be valid to activate the breakpoint.
  +
|-
  +
| <TT>B</TT>&nbsp;
  +
| Print all dynamical breakpoints.
  +
|-
  +
| <TT>-&lt;num&gt;</TT>&nbsp;
  +
| Remove a dynamical breakpoint designed by its number. The number are printed by the <TT>B</TT> command.
  +
|}
  +
  +
=== The <TT>sedb_breakpoint</TT> instruction===
  +
  +
The <TT>sedb_breakpoint</TT> instruction is defined in [[library_class:ANY|<TT>ANY</TT>]]. It places a statical breakpoint directly in the Eiffel source. This command does nothing if the program is not compiled with the <TT>-sedb</TT> flag.
  +
  +
These breakpoints cannot be removed by the <TT>-&lt;num&gt;</TT> command. The only way to ignore them is to use the <TT>C</TT> command (continue until the end of the program).
  +
  +
=== Specifications of a dynamical breakpoint ===
  +
  +
To set up a dynamical breakpoint, you are able to specify one or more criteria.
  +
* '''Name''': the name of the method and the class name in which the method is defined, separeted by a space, for example <TT>"item STRING"</TT>. You can specify a substring of this name. Thus, if you specify <TT>item</TT> then the program will strop a the beginning of the <TT>item</TT> method of [[library_class:STRING|<TT>STRING</TT>]], but also at the beginning of the one in [[library_class:ARRAY|<TT>ARRAY</TT>]], etc. Similarly, if you specify <TT>STRING</TT> then the program will stop when encountering any method of [[library_class:STRING|<TT>STRING</TT>]], but also of [[library_class:HASHED_DICTIONARY|<TT>HASHED_DICTIONARY</TT>]]<TT>[</TT>[[library_class:STRING|<TT>STRING</TT>]]<TT>, </TT>[[library_class:INTEGER|<TT>INTEGER</TT>]]<TT>]</TT>. You can even be original: I let you guess the behaviour of the <TT>is_</TT> specification :-)
  +
* '''File''': for example, <TT>string.e</TT>. As the file name is applied to the complete path, you can specify <TT>lib/kernel</TT> which will stop at all the methods in the classes of this cluster.
  +
* '''Line numbers''': you can specify an interval of lines, for example <TT>[12,13]</TT>.
  +
* '''Execution stack''': this condition allows to track the size of the execution stack (useful for debugging a recursive function for example). For example, you can specify the limit of the stack size to <TT>10</TT>, which will stop the execution when the stack size reaches 10. An optional automatic increment permits the limit to be incremented each time the breakpoint is reached. If you don't use this option, this breakpoint can be good way of track the memory consumption of the stack.
  +
  +
Of course, all these specifications are cumulative: in this case, the must all be true at the same time to active the breakpoint.
  +
  +
== Data printing ==
  +
  +
The following commands allows to print the data of your program:
  +
  +
{|
  +
|-
  +
| <TT>e&nbsp;&lt;exp&gt;</TT>&nbsp;
  +
| Evaluates and prints the result of an expression. '''Note that''' the general Eiffel expressions are not supported.
  +
|-
  +
|
  +
| Only the following can be printed:
  +
* ''Current''
  +
* local variables
  +
* a parameter of the current routine
  +
* the content of the case of a [[library_class:NATIVE_ARRAY|<TT>NATIVE_ARRAY</TT>]] and suffixing by a dot one of its index beginning at zero (for example <TT>storage.2</TT> prints the ''third'' element of <TT>storage</TT>)
  +
* the attributes of these objects, by using the classical notation with dots (for example <TT>my_string.count</TT> or <TT>my_string.storage.4</TT>), recursively
  +
* the result of [[Syntax_diagrams#RoutineBody|<TT>once</TT> functions]] at the condition that the have already been evaluated (i.e. the debugger does not procede to the function call; it only checks the result)
  +
|-
  +
| <TT>p</TT>
  +
  +
<TT>p&nbsp;&lt;exp&gt;</TT>&nbsp;
  +
| Re-evalutes the same expression by suffixing a dot and the expression (if present). This is very useful to chain printing. You can also use the particular expression <TT>..</TT> which goes one level up, <TT>....</TT> which goes two levels up, etc.
  +
|-
  +
|
  +
| Example of the use of <TT>e</TT> and <TT>p</TT>&nbsp;:
  +
sedb> e Current
  +
STD_OUTPUT#0x807ab00
  +
[ filter = Void
  +
buffer_position = 0
  +
buffer = NATIVE_ARRAY[CHARACTER]#0x806c030
  +
capacity = 4096
  +
]
  +
sedb> e buffer
  +
NATIVE_ARRAY[CHARACTER]#0x806c030
  +
sedb> p.0
  +
(sedb) e buffer.0
  +
'H'
  +
sedb> p..1
  +
(sedb) e buffer.1
  +
'e'
  +
sedb> p....buffer_position
  +
(sedb) e buffer_position
  +
0
  +
sedb>
  +
|-
  +
| <TT>.</TT>&nbsp;
  +
| Print the current frame; that is the content of local variables of the current routine.
  +
|-
  +
| <TT>u</TT>&nbsp;
  +
| Goes up in the stack (i.e. goes to the caller). This means that the ''current routine'' becomes the calling routine. Note that the <TT>e</TT>, <TT>p</TT> and <TT>.</TT> commands follow the current routine.
  +
|-
  +
| <TT>d</TT>&nbsp;
  +
| Goes down in the stack (opposite of <TT>u</TT>).
  +
|-
  +
| <TT>S</TT>&nbsp;
  +
| Prints the execution stack. There are two printing modes:
  +
* compact mode which only prints the name of the file and executed routine; an asterisk indicates the current routine
  +
* complete mode which prints the entire stack, with all frames (as the printed stack when a program crashes outside sedb).
  +
|}
  +
  +
== Various commands ==
  +
  +
{|
  +
|-
  +
| <TT>q</TT>&nbsp;
  +
| Quits the debugger; the programm will be stopped. You can also use <TT>Q</TT> which doesn't ask for confirmation.
  +
|-
  +
| <TT>h</TT>
  +
  +
<TT>?</TT>&nbsp;
  +
| Prints help.
  +
|-
  +
| <TT>H</TT>&nbsp;
  +
| Prints detailed help.
  +
|-
  +
| <TT>G</TT>&nbsp;
  +
| Run the [[GarbageCollector|garbage collector]], if it's present.
  +
|-
  +
| <TT>T</TT>&nbsp;
  +
| Changes the trace mode, if it's present (flag <TT>-trace</TT> when compiling). If the mode is active, the file <TT>trace.se</TT> fills up (very quickly!)
  +
|-
  +
| ''Return''&nbsp;
  +
| Re-execute the last command.
  +
|}

Revision as of 23:55, 8 July 2005


The SmartEiffel debugger is an Embedded debugger. This means that, in order to use it, you need to compile your application with a special flag -sedb. The executable will then have the debugger inside, you can launch your application the usual way.

Note: sedb is only available with compile_to_c (or compile).

The debugger offers powerful commands which allows you to examine the bowels of your program:

  • commands to control execution,
  • commands to set or unset breakpoints,
  • commands to print your data,
  • other various commands.

Execution control

These commands allows your program to execute. You can either run step by step or make bigger strides, or even force execution until the end.

Whatever your choice is, the program will run until the next breakpoint (see below), or until the next ^C.

The available commands are (by increasing order of step size):

s  Move only one step forward. This means entering a routine if it is a feature call.
n  Move only one step forward (next), but without entering a routine (this means that a feature call is considered being one step).
f  Move to the next routine return (finish).
c  Move as far as possible (continue), so maybe until the end of the program.
C  Continue until the end of the program, ignoring all breakpoints (statical et dynamical ones).

Breakpoints

There is two kind of breakpoints:

  • those explicitly placed in the code, with the instruction sedb_breakpoint,
  • those dynamically placed in the debugger. To modify dynamical breakpoints, you can use the following commands:
b  Add a dynamical breakpoint. There are many possible criteria, described below. All chosen criteria must be valid to activate the breakpoint.
B  Print all dynamical breakpoints.
-<num>  Remove a dynamical breakpoint designed by its number. The number are printed by the B command.

The sedb_breakpoint instruction

The sedb_breakpoint instruction is defined in ANY. It places a statical breakpoint directly in the Eiffel source. This command does nothing if the program is not compiled with the -sedb flag.

These breakpoints cannot be removed by the -<num> command. The only way to ignore them is to use the C command (continue until the end of the program).

Specifications of a dynamical breakpoint

To set up a dynamical breakpoint, you are able to specify one or more criteria.

  • Name: the name of the method and the class name in which the method is defined, separeted by a space, for example "item STRING". You can specify a substring of this name. Thus, if you specify item then the program will strop a the beginning of the item method of STRING, but also at the beginning of the one in ARRAY, etc. Similarly, if you specify STRING then the program will stop when encountering any method of STRING, but also of HASHED_DICTIONARY[STRING, INTEGER]. You can even be original: I let you guess the behaviour of the is_ specification :-)
  • File: for example, string.e. As the file name is applied to the complete path, you can specify lib/kernel which will stop at all the methods in the classes of this cluster.
  • Line numbers: you can specify an interval of lines, for example [12,13].
  • Execution stack: this condition allows to track the size of the execution stack (useful for debugging a recursive function for example). For example, you can specify the limit of the stack size to 10, which will stop the execution when the stack size reaches 10. An optional automatic increment permits the limit to be incremented each time the breakpoint is reached. If you don't use this option, this breakpoint can be good way of track the memory consumption of the stack.

Of course, all these specifications are cumulative: in this case, the must all be true at the same time to active the breakpoint.

Data printing

The following commands allows to print the data of your program:

e <exp>  Evaluates and prints the result of an expression. Note that the general Eiffel expressions are not supported.
Only the following can be printed:
  • Current
  • local variables
  • a parameter of the current routine
  • the content of the case of a NATIVE_ARRAY and suffixing by a dot one of its index beginning at zero (for example storage.2 prints the third element of storage)
  • the attributes of these objects, by using the classical notation with dots (for example my_string.count or my_string.storage.4), recursively
  • the result of once functions at the condition that the have already been evaluated (i.e. the debugger does not procede to the function call; it only checks the result)
p

p <exp> 

Re-evalutes the same expression by suffixing a dot and the expression (if present). This is very useful to chain printing. You can also use the particular expression .. which goes one level up, .... which goes two levels up, etc.
Example of the use of e and p :
sedb> e Current
STD_OUTPUT#0x807ab00
        [ filter = Void
          buffer_position = 0
          buffer = NATIVE_ARRAY[CHARACTER]#0x806c030
          capacity = 4096
        ]
sedb> e buffer
NATIVE_ARRAY[CHARACTER]#0x806c030
sedb> p.0
(sedb) e buffer.0
'H'
sedb> p..1
(sedb) e buffer.1
'e'
sedb> p....buffer_position
(sedb) e buffer_position
0
sedb>
.  Print the current frame; that is the content of local variables of the current routine.
u  Goes up in the stack (i.e. goes to the caller). This means that the current routine becomes the calling routine. Note that the e, p and . commands follow the current routine.
d  Goes down in the stack (opposite of u).
S  Prints the execution stack. There are two printing modes:
  • compact mode which only prints the name of the file and executed routine; an asterisk indicates the current routine
  • complete mode which prints the entire stack, with all frames (as the printed stack when a program crashes outside sedb).

Various commands

q  Quits the debugger; the programm will be stopped. You can also use Q which doesn't ask for confirmation.
h

? 

Prints help.
H  Prints detailed help.
G  Run the garbage collector, if it's present.
T  Changes the trace mode, if it's present (flag -trace when compiling). If the mode is active, the file trace.se fills up (very quickly!)
Return  Re-execute the last command.