Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* patch to ignore SIGPWR and SIGXCPU (used by pthreads)
@ 2002-01-19 12:33 Per Bothner
  2002-01-20 16:48 ` Andrew Cagney
  0 siblings, 1 reply; 9+ messages in thread
From: Per Bothner @ 2002-01-19 12:33 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 322 bytes --]

Ok to check in?  Without it, people debugging Java have to issue handle
commands, as shown in http://gcc.gnu.org/java/gdb.html.

	* infrun.c (_initialize_infrun):  Don't stop or print SIGCPU and
	SIGPWR - they are used by the Java runtime's thread support.
-- 
	--Per Bothner
per@bothner.com   http://www.bothner.com/per/

[-- Attachment #2: infrun.patch --]
[-- Type: text/plain, Size: 949 bytes --]

	* infrun.c (_initialize_infrun):  Don't stop or print SIGCPU and
	SIGPWR - they are used by the Java runtime's thread support.

Index: infrun.c
===================================================================
RCS file: /cvs/src/src/gdb/infrun.c,v
retrieving revision 1.50
diff -u -p -r1.50 infrun.c
--- infrun.c	2002/01/17 22:15:17	1.50
+++ infrun.c	2002/01/19 20:17:19
@@ -4298,6 +4298,12 @@ of the program stops.", &cmdlist);
   signal_stop[TARGET_SIGNAL_WINCH] = 0;
   signal_print[TARGET_SIGNAL_WINCH] = 0;
 
+  /* These are used for pthread context switching, used by libgcj. */
+  signal_stop[TARGET_SIGNAL_PWR] = 0;
+  signal_print[TARGET_SIGNAL_PWR] = 0;
+  signal_stop[TARGET_SIGNAL_XCPU] = 0;
+  signal_print[TARGET_SIGNAL_XCPU] = 0;
+
   /* These signals are used internally by user-level thread
      implementations.  (See signal(5) on Solaris.)  Like the above
      signals, a healthy program receives and handles them as part of

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: patch to ignore SIGPWR and SIGXCPU (used by pthreads)
  2002-01-19 12:33 patch to ignore SIGPWR and SIGXCPU (used by pthreads) Per Bothner
@ 2002-01-20 16:48 ` Andrew Cagney
  2002-01-20 21:51   ` Per Bothner
  2002-01-20 23:39   ` Per Bothner
  0 siblings, 2 replies; 9+ messages in thread
From: Andrew Cagney @ 2002-01-20 16:48 UTC (permalink / raw)
  To: Per Bothner; +Cc: gdb-patches

> Index: infrun.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/infrun.c,v
> retrieving revision 1.50
> diff -u -p -r1.50 infrun.c
> --- infrun.c	2002/01/17 22:15:17	1.50
> +++ infrun.c	2002/01/19 20:17:19
> @@ -4298,6 +4298,12 @@ of the program stops.", &cmdlist);
>    signal_stop[TARGET_SIGNAL_WINCH] = 0;
>    signal_print[TARGET_SIGNAL_WINCH] = 0;
>  
> +  /* These are used for pthread context switching, used by libgcj. */
> +  signal_stop[TARGET_SIGNAL_PWR] = 0;
> +  signal_print[TARGET_SIGNAL_PWR] = 0;
> +  signal_stop[TARGET_SIGNAL_XCPU] = 0;
> +  signal_print[TARGET_SIGNAL_XCPU] = 0;
> +
>    /* These signals are used internally by user-level thread
>       implementations.  (See signal(5) on Solaris.)  Like the above
>       signals, a healthy program receives and handles them as part of
> 


Per, can you please expand a little on the history of this choice of 
signals?

      SIGXCPU       terminate process    CPU time limit exceeded (see
      SIGPWR        discard signal       power failure/restart

I don't know that it is right to always silence/ignore these signals 
when not all systems are using pthreads/libgcj.  This is even more 
interesting given that just below we have:

   /* These signals are used internally by user-level thread
      implementations.  (See signal(5) on Solaris.)  Like the above
      signals, a healthy program receives and handles them as part of
      its normal operation.  */
   signal_stop[TARGET_SIGNAL_LWP] = 0;
   signal_print[TARGET_SIGNAL_LWP] = 0;
   signal_stop[TARGET_SIGNAL_WAITING] = 0;
   signal_print[TARGET_SIGNAL_WAITING] = 0;
   signal_stop[TARGET_SIGNAL_CANCEL] = 0;
   signal_print[TARGET_SIGNAL_CANCEL] = 0;

puzzled,

Andrew


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: patch to ignore SIGPWR and SIGXCPU (used by pthreads)
  2002-01-20 16:48 ` Andrew Cagney
@ 2002-01-20 21:51   ` Per Bothner
  2002-01-20 23:12     ` Andrew Cagney
  2002-01-20 23:39   ` Per Bothner
  1 sibling, 1 reply; 9+ messages in thread
From: Per Bothner @ 2002-01-20 21:51 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: gdb-patches

Andrew Cagney wrote:
> Per, can you please expand a little on the history of this choice of 
> signals?
> 
>      SIGXCPU       terminate process    CPU time limit exceeded (see
>      SIGPWR        discard signal       power failure/restart

I forwarded your message to the java mailing list.  But my assumption
is - what does it matter?  At least when using linux-threads, we do use
these signals.  As I understand it, linux-threads uses kernel support
and does not uses signals.  However, the garbage collector needs to be
able to stop and re-start all threads when doing a collection.  It does
this using signals, at least under linux-threads.  This has nothing to
do with the Solaris user-leel threads implementation, and is a
completely orthoginal issue.

> I don't know that it is right to always silence/ignore these signals 
> when not all systems are using pthreads/libgcj.

Why not?  What does it hurt to (by default) just pass them to the
inferior?  Having gdb stop inconveniences (and confuses) everybody who
uses gcj.  Having gdb silently pass the signals to the application
inconveniences/confuses - who?
-- 
	--Per Bothner
per@bothner.com   http://www.bothner.com/per/


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: patch to ignore SIGPWR and SIGXCPU (used by pthreads)
  2002-01-20 21:51   ` Per Bothner
@ 2002-01-20 23:12     ` Andrew Cagney
  2002-01-20 23:32       ` Per Bothner
  2002-01-21  9:32       ` Michael Snyder
  0 siblings, 2 replies; 9+ messages in thread
From: Andrew Cagney @ 2002-01-20 23:12 UTC (permalink / raw)
  To: Per Bothner; +Cc: gdb-patches


> Why not?  What does it hurt to (by default) just pass them to the
> inferior?  Having gdb stop inconveniences (and confuses) everybody who
> uses gcj.  Having gdb silently pass the signals to the application
> inconveniences/confuses - who?


Consider SIGXCPU.

With your proposed change, a program that exceeds its CPU usage will 
quietly terminate.   The user will loose their entire debug session. 
This is very different to GDB's current behavour where the signal is 
intercepted, the program is stopped, and control is returned to the user.

Andrew


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: patch to ignore SIGPWR and SIGXCPU (used by pthreads)
  2002-01-20 23:12     ` Andrew Cagney
@ 2002-01-20 23:32       ` Per Bothner
  2002-01-21  0:44         ` Andrew Cagney
  2002-01-21  9:32       ` Michael Snyder
  1 sibling, 1 reply; 9+ messages in thread
From: Per Bothner @ 2002-01-20 23:32 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: gdb-patches

Andrew Cagney wrote:
> Consider SIGXCPU.
> 
> With your proposed change, a program that exceeds its CPU usage will 
> quietly terminate.   The user will loose their entire debug session. 
> This is very different to GDB's current behavour where the signal is 
> intercepted, the program is stopped, and control is returned to the user.

How does a program exceed its CPU usage?  In any other situation except
by having a person running the program explicitly set the CPU usage?
Somebody who knows how to to do that can be expected to know how to
use the 'handle' command.  On the other hand, we should not expect
someone debugging a Java program to have to use 'handle'.  That is
not acceptable, so we need to figure some way to fix this problem.

Is there a way that gdb can check if the inferior has set a non-default
signal handler, and only stop if using the default handler (or of
course if 'handle' was explicitly set)?
-- 
	--Per Bothner
per@bothner.com   http://www.bothner.com/per/


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: patch to ignore SIGPWR and SIGXCPU (used by pthreads)
  2002-01-20 16:48 ` Andrew Cagney
  2002-01-20 21:51   ` Per Bothner
@ 2002-01-20 23:39   ` Per Bothner
  1 sibling, 0 replies; 9+ messages in thread
From: Per Bothner @ 2002-01-20 23:39 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: gdb-patches

To my forwarding of Andrew's (first) response to the Java list,
I got this response from Bryce McKinlay <bryce@waitaki.otago.ac.nz>:

Ideally the GC should just use "real-time" signals for the thread
suspend/resume on systems which support them. GDB won't stop on an RT
signal. Linux didn't support them until a few years ago but it should be
easy enough to do a configure test instead of the "#  if
defined(GC_HPUX_THREADS) || defined(GC_OSF1_THREADS)" that is currently
done in boehm-gc/linux_threads.c.

regards

Bryce.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: patch to ignore SIGPWR and SIGXCPU (used by pthreads)
  2002-01-20 23:32       ` Per Bothner
@ 2002-01-21  0:44         ` Andrew Cagney
  0 siblings, 0 replies; 9+ messages in thread
From: Andrew Cagney @ 2002-01-21  0:44 UTC (permalink / raw)
  To: Per Bothner; +Cc: gdb-patches

> Andrew Cagney wrote:
> Consider SIGXCPU.
> 
> With your proposed change, a program that exceeds its CPU usage will quietly terminate.   The user will loose their entire debug session. This is very different to GDB's current behavour where the signal is intercepted, the program is stopped, and control is returned to the user.
> 
> How does a program exceed its CPU usage?  In any other situation except
> by having a person running the program explicitly set the CPU usage?
> Somebody who knows how to to do that can be expected to know how to
> use the 'handle' command.  On the other hand, we should not expect
> someone debugging a Java program to have to use 'handle'.  That is
> not acceptable, so we need to figure some way to fix this problem.


I don't think it is reasonable to assume that it was the user that set 
the cpu-limit.  That is often a BOFH imposed restriction.

Remember, there is a compromise here.  Change GDB's behavour to give 
GCJ/Linux users a good experience (and in the process cover up a screwup 
- lets be honest :-) VS give GCJ/Linux users a bad experience but 
preserve correct behavour for all other users.

Andrew


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: patch to ignore SIGPWR and SIGXCPU (used by pthreads)
  2002-01-20 23:12     ` Andrew Cagney
  2002-01-20 23:32       ` Per Bothner
@ 2002-01-21  9:32       ` Michael Snyder
  2002-01-21 10:39         ` Daniel Jacobowitz
  1 sibling, 1 reply; 9+ messages in thread
From: Michael Snyder @ 2002-01-21  9:32 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: Per Bothner, gdb-patches

Andrew Cagney wrote:
> 
> > Why not?  What does it hurt to (by default) just pass them to the
> > inferior?  Having gdb stop inconveniences (and confuses) everybody who
> > uses gcj.  Having gdb silently pass the signals to the application
> > inconveniences/confuses - who?
> 
> Consider SIGXCPU.
> 
> With your proposed change, a program that exceeds its CPU usage will
> quietly terminate.   The user will loose their entire debug session.
> This is very different to GDB's current behavour where the signal is
> intercepted, the program is stopped, and control is returned to the user.


Java's use of these signals is somewhat analogous to what
linux threads does.  In that case, we also "silence" the 
signals, but we do it only in the context where we know
they are used.  Only for linux, and only when a multi-thread
program is detected.

Could you do something like that?


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: patch to ignore SIGPWR and SIGXCPU (used by pthreads)
  2002-01-21  9:32       ` Michael Snyder
@ 2002-01-21 10:39         ` Daniel Jacobowitz
  0 siblings, 0 replies; 9+ messages in thread
From: Daniel Jacobowitz @ 2002-01-21 10:39 UTC (permalink / raw)
  To: Michael Snyder; +Cc: Andrew Cagney, Per Bothner, gdb-patches

On Mon, Jan 21, 2002 at 09:27:29AM -0800, Michael Snyder wrote:
> Andrew Cagney wrote:
> > 
> > > Why not?  What does it hurt to (by default) just pass them to the
> > > inferior?  Having gdb stop inconveniences (and confuses) everybody who
> > > uses gcj.  Having gdb silently pass the signals to the application
> > > inconveniences/confuses - who?
> > 
> > Consider SIGXCPU.
> > 
> > With your proposed change, a program that exceeds its CPU usage will
> > quietly terminate.   The user will loose their entire debug session.
> > This is very different to GDB's current behavour where the signal is
> > intercepted, the program is stopped, and control is returned to the user.
> 
> 
> Java's use of these signals is somewhat analogous to what
> linux threads does.  In that case, we also "silence" the 
> signals, but we do it only in the context where we know
> they are used.  Only for linux, and only when a multi-thread
> program is detected.
> 
> Could you do something like that?

Could we make Boehm GC export two variables containing the values of
the signals it intends to use, and recognise their presence?

-- 
Daniel Jacobowitz                           Carnegie Mellon University
MontaVista Software                         Debian GNU/Linux Developer


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2002-01-21 18:39 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-19 12:33 patch to ignore SIGPWR and SIGXCPU (used by pthreads) Per Bothner
2002-01-20 16:48 ` Andrew Cagney
2002-01-20 21:51   ` Per Bothner
2002-01-20 23:12     ` Andrew Cagney
2002-01-20 23:32       ` Per Bothner
2002-01-21  0:44         ` Andrew Cagney
2002-01-21  9:32       ` Michael Snyder
2002-01-21 10:39         ` Daniel Jacobowitz
2002-01-20 23:39   ` Per Bothner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox