* [Python] Input from user from extended breakpoint `stop' function
@ 2011-04-19 14:42 Kevin Pouget
2011-04-19 20:10 ` Phil Muldoon
0 siblings, 1 reply; 8+ messages in thread
From: Kevin Pouget @ 2011-04-19 14:42 UTC (permalink / raw)
To: gdb; +Cc: pmuldoon
Hello,
is there any function provided by GDB to read from the terminal ?
(I still don't know much about Python)
I'm facing a problem when I was to ask a question the user from an
extended breakpoint `stop' function: try
class MyBreakpoint (gdb.Breakpoint):
def stop (self):
bug = raw_input("Input ?")
print "--> ", bug
return True
MyBreakpoint(spec="main")
and you will see this output:
> (gdb) source sigttin.py
> Breakpoint 1 at 0x400579
> (gdb) r
> Starting program: /home/kevin/a.out
> Input ?
> [1]+ Stopped gdb-git a.out
> kevin@kevin:~$ fg
> gdb-git a.out
> hello
> --> hello
> Breakpoint 1, 0x0000000000400579 in main ()
because GDB receives a SIGTTIN ("SIGTTIN is the signal sent to a
process when it attempts to read from the tty while in the
background." says wikipedia), which somehow makes sense.
Any solution, or shall I send a bug report?
cordially,
Kevin
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Python] Input from user from extended breakpoint `stop' function
2011-04-19 14:42 [Python] Input from user from extended breakpoint `stop' function Kevin Pouget
@ 2011-04-19 20:10 ` Phil Muldoon
2011-04-19 20:44 ` Andreas Schwab
0 siblings, 1 reply; 8+ messages in thread
From: Phil Muldoon @ 2011-04-19 20:10 UTC (permalink / raw)
To: Kevin Pouget; +Cc: gdb
Kevin Pouget <kevin.pouget@gmail.com> writes:
> Hello,
>
> is there any function provided by GDB to read from the terminal ?
> (I still don't know much about Python)
Nope, but in the context of this bug there might need to be. GDB does a
few things with stdout/tty.
> I'm facing a problem when I was to ask a question the user from an
> extended breakpoint `stop' function: try
>
> class MyBreakpoint (gdb.Breakpoint):
> def stop (self):
> bug = raw_input("Input ?")
> print "--> ", bug
> return True
> MyBreakpoint(spec="main")
>
>
> and you will see this output:
>
>> (gdb) source sigttin.py
>> Breakpoint 1 at 0x400579
>> (gdb) r
>> Starting program: /home/kevin/a.out
>> Input ?
>> [1]+ Stopped gdb-git a.out
>> kevin@kevin:~$ fg
>> gdb-git a.out
>> hello
>> --> hello
>> Breakpoint 1, 0x0000000000400579 in main ()
>
> because GDB receives a SIGTTIN ("SIGTTIN is the signal sent to a
> process when it attempts to read from the tty while in the
> background." says wikipedia), which somehow makes sense.
I'm not sure what is going on here. It seems GDB is not acting
correctly with the SIGTTIN. I really do not know this area of GDB at
all.
> Any solution, or shall I send a bug report?
Bug report please.
Cheers,
Phil
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Python] Input from user from extended breakpoint `stop' function
2011-04-19 20:10 ` Phil Muldoon
@ 2011-04-19 20:44 ` Andreas Schwab
2011-04-19 21:30 ` Phil Muldoon
0 siblings, 1 reply; 8+ messages in thread
From: Andreas Schwab @ 2011-04-19 20:44 UTC (permalink / raw)
To: pmuldoon; +Cc: Kevin Pouget, gdb
Phil Muldoon <pmuldoon@redhat.com> writes:
> I'm not sure what is going on here. It seems GDB is not acting
> correctly with the SIGTTIN. I really do not know this area of GDB at
> all.
The terminal still belongs to the inferior. Before gdb is doing any
input it must call terminal_ours.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Python] Input from user from extended breakpoint `stop' function
2011-04-19 20:44 ` Andreas Schwab
@ 2011-04-19 21:30 ` Phil Muldoon
2011-04-20 7:36 ` Kevin Pouget
2011-04-20 15:41 ` Tom Tromey
0 siblings, 2 replies; 8+ messages in thread
From: Phil Muldoon @ 2011-04-19 21:30 UTC (permalink / raw)
To: Andreas Schwab; +Cc: Kevin Pouget, gdb
Andreas Schwab <schwab@linux-m68k.org> writes:
> Phil Muldoon <pmuldoon@redhat.com> writes:
>
>> I'm not sure what is going on here. It seems GDB is not acting
>> correctly with the SIGTTIN. I really do not know this area of GDB at
>> all.
>
> The terminal still belongs to the inferior. Before gdb is doing any
> input it must call terminal_ours.
Thanks, that is good info. I did not know that. I wonder if we should
call that before handing over control to the python executed script in
the breakpoint "stop" callback? Or maybe provide a Python API call to
turn control of the TTY to GDB and likewise to the inferior.
Any opinions on this would be great. What do you (all) think?
Cheers
Phil
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Python] Input from user from extended breakpoint `stop' function
2011-04-19 21:30 ` Phil Muldoon
@ 2011-04-20 7:36 ` Kevin Pouget
2011-04-20 7:48 ` Andreas Schwab
2011-04-20 15:41 ` Tom Tromey
1 sibling, 1 reply; 8+ messages in thread
From: Kevin Pouget @ 2011-04-20 7:36 UTC (permalink / raw)
To: pmuldoon, Andreas Schwab; +Cc: gdb
>> Any solution, or shall I send a bug report?
> Bug report please.
http://sourceware.org/bugzilla/show_bug.cgi?id=12686 (what does PR mean ?)
>> The terminal still belongs to the inferior. Before gdb is doing any
>> input it must call terminal_ours.
that's interesting, but why `print' functions work correctly, without
sending any SIGTTOU
> Thanks, that is good info. I did not know that. I wonder if we should
> call that before handing over control to the python executed script in
> the breakpoint "stop" callback? Or maybe provide a Python API call to
> turn control of the TTY to GDB and likewise to the inferior.
>
> Any opinions on this would be great. What do you (all) think?
I would prefer a python-transparent handling, ie `terminal_ours'
called before giving the hand to the Python callback, to hide GDB's
complexity from the script interface (I guess there won't be so many
situations where this case occurs?).
However if `terminal_ours' is very costly (in comparison to the
breakpoint itself), it might not be very wise ...
Cordially,
Kevin
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Python] Input from user from extended breakpoint `stop' function
2011-04-20 7:36 ` Kevin Pouget
@ 2011-04-20 7:48 ` Andreas Schwab
2011-04-21 11:38 ` Kevin Pouget
0 siblings, 1 reply; 8+ messages in thread
From: Andreas Schwab @ 2011-04-20 7:48 UTC (permalink / raw)
To: Kevin Pouget; +Cc: pmuldoon, gdb
Kevin Pouget <kevin.pouget@gmail.com> writes:
>>> Any solution, or shall I send a bug report?
>> Bug report please.
> http://sourceware.org/bugzilla/show_bug.cgi?id=12686 (what does PR mean ?)
>
>
>>> The terminal still belongs to the inferior. Â Before gdb is doing any
>>> input it must call terminal_ours.
> that's interesting, but why `print' functions work correctly, without
> sending any SIGTTOU
Try stty tostop.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Python] Input from user from extended breakpoint `stop' function
2011-04-19 21:30 ` Phil Muldoon
2011-04-20 7:36 ` Kevin Pouget
@ 2011-04-20 15:41 ` Tom Tromey
1 sibling, 0 replies; 8+ messages in thread
From: Tom Tromey @ 2011-04-20 15:41 UTC (permalink / raw)
To: pmuldoon; +Cc: Andreas Schwab, Kevin Pouget, gdb
>>>>> "Phil" == Phil Muldoon <pmuldoon@redhat.com> writes:
Phil> I wonder if we should call that before handing over control to the
Phil> python executed script in the breakpoint "stop" callback?
I don't think so.
Phil> Or maybe provide a Python API call to turn control of the TTY to
Phil> GDB and likewise to the inferior.
This would be ok with me.
Tom
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Python] Input from user from extended breakpoint `stop' function
2011-04-20 7:48 ` Andreas Schwab
@ 2011-04-21 11:38 ` Kevin Pouget
0 siblings, 0 replies; 8+ messages in thread
From: Kevin Pouget @ 2011-04-21 11:38 UTC (permalink / raw)
To: Andreas Schwab; +Cc: gdb
>> that's interesting, but why `print' functions work correctly, without
>> sending any SIGTTOU
>
> Try stty tostop.
indeed !
what do consider as the default/good behavior? I mean, it is okay for
GDB to 'ignore' SIGTTOU, or shall I report such situations as bugs ?
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2011-04-21 11:38 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-19 14:42 [Python] Input from user from extended breakpoint `stop' function Kevin Pouget
2011-04-19 20:10 ` Phil Muldoon
2011-04-19 20:44 ` Andreas Schwab
2011-04-19 21:30 ` Phil Muldoon
2011-04-20 7:36 ` Kevin Pouget
2011-04-20 7:48 ` Andreas Schwab
2011-04-21 11:38 ` Kevin Pouget
2011-04-20 15:41 ` Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox