Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pdb interactive mode throught telnet and rdb

I'm debugging a python daemon on a embedded Linux board. I ssh to the board on which I run the program and enter the debugger. Given that it's a deamon process I'm using rdb from celery

#Install on the system
pip3 install celery

# Set in the code
from celery.contrib import rdb
rdb.set_trace()

# Connect to the debugger
telnet localhost 5899

However in that session the tab key doesn't result in auto completion as usually in pdb and the up key doesn't scroll through history but prints a ^[[A.

The issues like these are related to the missing readline python module, however in this particular case the module is present and can be imported.

like image 603
TheMeaningfulEngineer Avatar asked Jan 19 '18 12:01

TheMeaningfulEngineer


2 Answers

I'm not sure what the issue is, and might be telnet related. A workaround it to use another remote debugger that seems to work:

#Install on the system
pip3 install epdb

# Set in the code
import epdb; epdb.serve()

# Connect to the debugger
python3 -c 'import epdb; epdb.connect()'

Given that this is just a workaround, won't accept it as an answer.

like image 200
TheMeaningfulEngineer Avatar answered Sep 23 '22 13:09

TheMeaningfulEngineer


So your possible options are

rlwrap

rlwrap telnet host port

if you have col and rows issue run below

stty rows 50 && stty cols 150

socat

socat readline tcp:127.0.0.1:6900

This will add readline and history support without needing anything else like a rlwrap

I couldn't find a way as of yet to enable Telnet with tab completion. There are few interesting SO threads which talk about putting telnet client in a nolinemode or charactermode

Force telnet client into character mode

I tried updating Rdb code to implement but all attempts failed as such

PS: Credits to https://stackoverflow.com/a/9809574/2830850 and https://stackoverflow.com/a/9219349/462849

like image 33
Tarun Lalwani Avatar answered Sep 21 '22 13:09

Tarun Lalwani