D   A   T   A   W   O   K





Creation: December 28 2015
Modified: February 05 2022

PYCLEWN

Pyclewn is a Vim front-end to the gdb and pdb debuggers.

The debugger output is redirected to a Vim window, the console. The debugger commands are mapped to Vim user-defined commands and completion is available on the Vim command line.

Installation

If your linux distribution provides a pyclewn package simply install it via the package manager. For example, Arch Linux provides pyclewn in AUR. This will result in a system-wide installation.

$ yaourt -S pyclewn

Simple "by hand" installation

You may need to install a specific package required to compile python extensions. For example I've got to install it explicitly within my raspberry-pi raspbian distibution.

$ apt-get install python-dev python-pip

Install the pyclewn python package via "pip"

$ pip install pyclewn

This command install the clewn package and it's dependencies.

Install the Vim runtime files with a vimball. The vimball is part of the clewn package installed in the previous part

$ python -c "import clewn; clewn.get_vimball()"

Then source the vimball and install the Vim runtime files with

$ vim -S pyclewn-2.2.vmb

Type :quit to quit Vim after the vimball is installed.

Note: this will result in a user-only installation of Pyclewn. Eventually repeat the "source the vimball" step for each user.

Usage

Once installed the plugin is easily started from Vim command mode with the command

:Pyclewn

From now on you can feed commands to the underlying gdb running instance via the vim command mode and by using the :C prefix:

:C <gdb-command>

For example:

:C run

To terminate the gdb session:

:C exitclewn

Start from the shell

Start pyclewn with:

$ python -m clewn [options] [debugger]

"debugger" defaults to "gdb".

Tips

By default pyclewn uses for program IO the /dev/null file. If your debugged program requires user IO, first open a shell dedicated to the program IO and get the port name (e.g. by using the tty command).

Then, to prevent the shell from executing our input strings let it execute a tight dummy loop.

$ while true; do sleep 1000; done

Before you run you program with pyclewn, you must set the tty port used by gdb via the tty command.

:C tty /dev/pts/nn

You program IO is thus bound to the /dev/pts/nn device.

Troubleshooting

First set the pyclewn_terminal Vim global variable to have pyclewn started in a terminal instead of a daemon, and to visualize the log traces at the "info" log level. The variable must be a string of comma separated arguments needed to start a terminal and a program running on this terminal. For example:

:let g:pyclewn_terminal = "xterm, -e"

Utilities

References

Proudly self-hosted on a cheap Raspberry Pi