New code, in the pdb branch, completes #915 
<https://github.com/leo-editor/leo-editor/issues/915>.  It's far more than 
a prototype.  Almost all features are complete, including essential gui 
features.

The new supports the xdb and various db-* commands, corresponding to the pdb 
<https://docs.python.org/3/library/pdb.html> commands:

*xdb*:  Start a Leo's integrated debugger in a separate thread.

At present, *you should run Leo from a console window*.  That will change 
soon.  See below.

Start the debugger from any part of any @<file> tree. Now you are ready to 
execute all the db-* commands. You can execute these commands from the 
minibuffer, or, if the xdb_pane.py plugin is enabled, from the the Debug 
pane. The following correspond to the pdb commands:

*db-b*: Set a breakpoint at the line shown in Leo. It should be an 
executable line.
*db-c*: Continue, that is, run until the next breakpoint.
*db-h*: Print the help message (in the console, for now)
*db-l*: List a few lines around present location.
*db-n*: Execute the next line.
*db-q*: End the debugger.
*db-r*: Return from the present function/method.
*db-s*: Step into the next line.
*db-w*: Print the stack.

There are two additional commands:

*db-again*: Run the previous db-command.
*db-input*: Prompt for any pdb command, then execute it.

The db-input command allows you can enter any pdb command at all.  For 
example: "print c".

But you don't have to run these commands from the minibuffer, as discussed 
next.

*Setting breakpoints in the gutter*

When @bool use_gutter = True, Leo shows a border in the body pane.  By 
default, the line-numbering.py plugin is enabled, and if so, the gutter 
shows correct line number in the external file.

*After* executing the xdb command, you can set a breakpoint on any 
executable line by clicking in the gutter to the right of the line number.  
You can also set a breakpoint any time the debugger is stopped.

Using the gutter is optional. You can also set breakpoints with the db-b 
command or by typing "d line-number" or "d file-name:line-number using the 
db-input command, or by using the Debug pane (see below)

*The Debug pane*

The xdb_pane.py plugin creates the Debug pane in the Log pane.  The pane 
contains buttons corresponding to all the commands listed above.  In 
addition, there is an input area in which you can enter pdb commands. This 
is a bit easier to use than the db-input command.

Soon, all xdb/pdb output will be sent to an output area in the debug pane.  
Once that happens, you will be able to run the debugger without running Leo 
from a console window.

*Significance*

The new code finally adds a debugger to Leo's IDE.

Working on the code has taught me about inter-thread communication, and it 
may serve as the basis for inter-process communication.  I'll discuss these 
and other technical details soon in a separate post.

The new code will soon be merged into the devel branch.  It has essentially 
no impact on Leo's core.

*Summary*

The xdb and db-* commands are always available. They correspond to pdb 
commands.

When xdb is active you may set breakpoints by clicking in the gutter next 
to any executable line.  The line_numbering plugin must be enabled and 
@bool use_gutter must be True.

The xdb_pane plugin creates the Debug pane in the Log window. This will 
soon sport an output area to which all xdb/pdb output will be sent.

The code appears stable, but much more testing is needed. Please give it a 
try.

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Reply via email to