0

I have created a python script which starts an python console "pythonstart.py"

import sys
import subprocess
subprocess.call(['/usr/bin/python'])

I am sourcing it from inside gdb

gdb# source pythonstart.py

It gives an python console.

Problem: When I exit from python console, it returns to gdb, if I press "ENTER" again it again goes back to python console. I am not sure why its happening. Once I have quit the python console then why its coming back.

There is another situation: After exit from python, if I don't press "ENTER" on gdb but execute any command and then press "ENTER", problem does not appear.

(gdb) (gdb) source pythonstart.py Python 2.7.6 (default, Jun 22 2015, 18:00:18) [GCC 4.8.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> >>> >>> exit() (gdb) <---- Pressing Enter here Python 2.7.6 (default, Jun 22 2015, 18:00:18) [GCC 4.8.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> >>> 

I want to stop this from falling back to python console after pressing enter key. Please help.

0

1 Answer 1

2

After you type a command line, gdb saves it. If you type just a blank line, gdb re-executes the saved command (if any). In your case, typing ENTER will re-execute source pythonstart.py.

If the command is a script, it can call the gdb command dont-repeat, which will clear the saved command.

So you can add gdb.execute("dont-repeat") to your python script if you don't want a blank line to re-execute the source command.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.