|
View:
New views
11 Messages
—
Rating Filter:
Alert me
|
|
|
controlling gdb via python's pexpectCan someone please give me an example of how this is done.
I'm afraid the documentation is not helping me. Thx |
|
|
Re: controlling gdb via python's pexpectfpga wrote:
> Can someone please give me an example of how this is done. > I'm afraid the documentation is not helping me. > Thx > Hi, I have had some success in controlling GDB (via MI) from python, using the subprocess module and communicating with GDB via pipes. (http://docs.python.org/library/subprocess.html) The main issue so far is that some applications detect when they are running with pipes instead of a terminal for output, and buffer program output by block rather than line as on a terminal, leading to delays in receiving program output issued via printf, for example, unless it is followed by an explicit fflush call. (I too would be interested in an example of using pexpect to control GDB) Cheers, George Russell |
|
|
Re: controlling gdb via python's pexpectThx George You've got further than I have! I tried to use subprocess before trying pexpect but failed. pexpect was suggested by experts on the python forum. Unfortuntely they seem unable to correct my trivial example of opening a terminal and sending 'gdb' to it. Therefore any working snippets would be welcome. Looking at my repositories I see libdevel-gdb-perl. I like python's orderliness but have noticed that when python fails perl usually delivers. |
|
|
Re: controlling gdb via python's pexpectfpga wrote:
> fpga wrote: > >> Can someone please give me an example of how this is done. >> I'm afraid the documentation is not helping me. >> Thx >> >> > > Thx George > You've got further than I have! > I tried to use subprocess before trying pexpect but failed. > pexpect was suggested by experts on the python forum. > Unfortuntely they appear incapable of correcting my trivial example of > opening a terminal and sending the command 'gdb' to it. > Any snippets most welcome. > Looking at my repositories I see libdevel-gdb-perl. > I like python's orderliness but have noticed that when python fails perl > usually delivers. > http://www.dalkescientific.com/writings/diary/archive/2005/04/12/wrapping_command_line_programs.html http://www.dalkescientific.com/writings/diary/archive/2005/04/15/wrapping_command_line_programs_II.html http://www.dalkescientific.com/writings/diary/archive/2005/04/17/wrapping_command_line_programs_III.html http://www.dalkescientific.com/writings/diary/archive/2005/04/18/wrapping_command_line_programs_IV.html http://www.dalkescientific.com/writings/diary/archive/2005/04/18/wrapping_command_line_programs_V.html for an assortment of tips on control of external processes from Python. Cheers, George |
|
|
Re: controlling gdb via python's pexpectfpga wrote:
> > > fpga wrote: >> Can someone please give me an example of how this is done. >> I'm afraid the documentation is not helping me. >> Thx >> > > George > You've got further than I have! > I tried to use subprocess but failed. Yeah, pipes might appear to work at first if you're "lucky", but pretty quickly you'll come unstuck due to problems with buffering. Here's a trivial example for gdb with pexpect: import pexpect, sys child = pexpect.spawn( 'gdb a.out') child.setlog( sys.stdout) child.expect_exact ('(gdb) ') child.send ('run\n') child.expect_exact ('Program exited normally.') child.expect_exact ('(gdb) ') child.send ('quit\n') child.expect( pexpect.EOF Note that the pexpect.expect method takes a regular expression but "expect_exact" doesn't. If you're going to use the expect method be sure to escape things like parentheses. Greg -- Greg Law, Undo Software http://undo-software.com/ |
|
|
Re: controlling gdb via python's pexpectThat's given me something to look at.
Thank you to both of you! For anyone wanting to run Greg's helpful script - the syntax has changed slightly i.e. just replace the line child.setlog( sys.stdout) with child.logfile = sys.stdout |
|
|
Re: controlling gdb via python's pexpectGeorge Russell <george@...> writes:
> fpga wrote: >> Can someone please give me an example of how this is done. >> I'm afraid the documentation is not helping me. >> Thx >> > Hi, > > I have had some success in controlling GDB (via MI) from python, using > the subprocess module and communicating with GDB via > pipes. (http://docs.python.org/library/subprocess.html) > > The main issue so far is that some applications detect when they are > running with pipes instead of a terminal for output, and buffer > program output by block rather than line as on a terminal, leading to > delays in receiving program output issued via printf, for example, > unless it is followed by an explicit fflush call. > > (I too would be interested in an example of using pexpect to control GDB) > Cheers, > George Russell Hi, for what it is worth feel free to download http://floppsie.comp.glam.ac.uk/download/python/twingdb.tar.gz which was written to run two gdb's debugging a stage1 and stage2 generation of a compiler and single step until a line number differs. It is written in Python and uses pexpect The code is very alpha - but it worked well enough to find the bug I was hunting. regards, Gaius |
|
|
Re: controlling gdb via python's pexpectGaius Mulley <gaius@...> writes:
> for what it is worth feel free to download > http://floppsie.comp.glam.ac.uk/download/python/twingdb.tar.gz ahh correction, make that http://floppsie.comp.glam.ac.uk/download/python/tgdb-0.1.tar.gz instead.. regards, Gaius |
|
|
Re: controlling gdb via python's pexpectHi Gaius I'd like to download this but get The requested URL /download/python/twingdb.tar.gz was not found on this server. OK Got it. Thx! |
|
|
Re: controlling gdb via python's pexpectfpga <mgbg25171@...> writes:
> Hi Gaius > I'd like to download this but get > The requested URL /download/python/twingdb.tar.gz was not found on this > server. Hi, all restored now - although http://floppsie.comp.glam.ac.uk/download/python/tgdb-0.1.tar.gz is a cleaner package, regards, Gaius |
|
|
Re: controlling gdb via python's pexpectI got that one too. Thx
|
| Free embeddable forum powered by Nabble | Forum Help |