Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH/RFC] observer tests & GCC 3.4
@ 2003-12-11 13:55 Mark Kettenis
  2003-12-11 14:14 ` Joel Brobecker
  2003-12-11 14:34 ` Eli Zaretskii
  0 siblings, 2 replies; 5+ messages in thread
From: Mark Kettenis @ 2003-12-11 13:55 UTC (permalink / raw)
  To: gdb-patches, brobecker

The compiler is getting too smart for its own good again.  At the end
of observer.c, we have a bit of code that used in the
gdb.gdb/observer.exp testcase.  Since the variables and functions are
declared static, the compiler simply optimizes these out.  The
attached patch fixes this.  Objections?

Mark


Index: ChangeLog
from  Mark Kettenis  <kettenis@gnu.org>

	* observer.c (observer_test_first_observer,
	observer_test_second_observer, observer_test_third_observer):
	Don't define as `static'.
	(observer_test_first_notification_function,
	observer_test_second_notification_function,
	observer_test_third_notification_function): Likewise.

Index: observer.c
===================================================================
RCS file: /cvs/src/src/gdb/observer.c,v
retrieving revision 1.3
diff -u -p -r1.3 observer.c
--- observer.c 18 Mar 2003 18:05:50 -0000 1.3
+++ observer.c 11 Dec 2003 13:52:40 -0000
@@ -191,30 +191,30 @@ observer_notify_normal_stop (void)
   generic_observer_notify (normal_stop_subject, NULL);
 }
 
-/* The following code is only used to unit-test the observers from
-   our testsuite.  DO NOT USE IT within observer.c!  */
+/* The following code is only used to unit-test the observers from our
+   testsuite.  DO NOT USE IT within observer.c (or anywhere else for
+   that matter)!  */
 
-/* Since this code will not be used within GDB, it will trigger
-   a warning if we decide to compile with -Wunused-function.
-   This is ok for now.  (brobecker 2003-03-18)  */
+/* If we define these variables and functions as `static', the
+   compiler will optimize them out.  */
  
-static int observer_test_first_observer = 0;
-static int observer_test_second_observer = 0;
-static int observer_test_third_observer = 0;
+int observer_test_first_observer = 0;
+int observer_test_second_observer = 0;
+int observer_test_third_observer = 0;
 
-static void
+void
 observer_test_first_notification_function (void)
 {
   observer_test_first_observer++;
 }
 
-static void
+void
 observer_test_second_notification_function (void)
 {
   observer_test_second_observer++;
 }
 
-static void
+void
 observer_test_third_notification_function (void)
 {
   observer_test_third_observer++;


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

* Re: [PATCH/RFC] observer tests & GCC 3.4
  2003-12-11 13:55 [PATCH/RFC] observer tests & GCC 3.4 Mark Kettenis
@ 2003-12-11 14:14 ` Joel Brobecker
  2003-12-11 14:24   ` Daniel Jacobowitz
  2003-12-11 14:34 ` Eli Zaretskii
  1 sibling, 1 reply; 5+ messages in thread
From: Joel Brobecker @ 2003-12-11 14:14 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: gdb-patches

> The compiler is getting too smart for its own good again.  At the end
> of observer.c, we have a bit of code that used in the
> gdb.gdb/observer.exp testcase.  Since the variables and functions are
> declared static, the compiler simply optimizes these out.  The
> attached patch fixes this.  Objections?

Humph. I don't know of any other way to stop GDB from optimizing
them out, so no objection from me.

> Index: ChangeLog
> from  Mark Kettenis  <kettenis@gnu.org>
> 
> 	* observer.c (observer_test_first_observer,
> 	observer_test_second_observer, observer_test_third_observer):
> 	Don't define as `static'.
> 	(observer_test_first_notification_function,
> 	observer_test_second_notification_function,
> 	observer_test_third_notification_function): Likewise.

-- 
Joel


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

* Re: [PATCH/RFC] observer tests & GCC 3.4
  2003-12-11 14:14 ` Joel Brobecker
@ 2003-12-11 14:24   ` Daniel Jacobowitz
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Jacobowitz @ 2003-12-11 14:24 UTC (permalink / raw)
  To: gdb-patches

On Thu, Dec 11, 2003 at 09:14:16AM -0500, Joel Brobecker wrote:
> > The compiler is getting too smart for its own good again.  At the end
> > of observer.c, we have a bit of code that used in the
> > gdb.gdb/observer.exp testcase.  Since the variables and functions are
> > declared static, the compiler simply optimizes these out.  The
> > attached patch fixes this.  Objections?
> 
> Humph. I don't know of any other way to stop GDB from optimizing
> them out, so no objection from me.

You can do it with GCC-isms (the appropriate one in this case is
__attribute__((__used__))), but I think that Mark's solution is a
better one in this case.  Making them global ought to fix the problem
for good (since any compiler which supports shared objects will have to
export them, since something like libthread_db might use them).


> > Index: ChangeLog
> > from  Mark Kettenis  <kettenis@gnu.org>
> > 
> > 	* observer.c (observer_test_first_observer,
> > 	observer_test_second_observer, observer_test_third_observer):
> > 	Don't define as `static'.
> > 	(observer_test_first_notification_function,
> > 	observer_test_second_notification_function,
> > 	observer_test_third_notification_function): Likewise.
> 
> -- 
> Joel
> 

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer


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

* Re: [PATCH/RFC] observer tests & GCC 3.4
  2003-12-11 13:55 [PATCH/RFC] observer tests & GCC 3.4 Mark Kettenis
  2003-12-11 14:14 ` Joel Brobecker
@ 2003-12-11 14:34 ` Eli Zaretskii
  2003-12-12 16:24   ` Mark Kettenis
  1 sibling, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2003-12-11 14:34 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: gdb-patches, brobecker

> Date: Thu, 11 Dec 2003 14:55:15 +0100 (CET)
> From: Mark Kettenis <kettenis@chello.nl>
> 
> Index: ChangeLog
> from  Mark Kettenis  <kettenis@gnu.org>
> 
> 	* observer.c (observer_test_first_observer,
> 	observer_test_second_observer, observer_test_third_observer):
> 	Don't define as `static'.
> 	(observer_test_first_notification_function,
> 	observer_test_second_notification_function,
> 	observer_test_third_notification_function): Likewise.

Nitpicking: the format of the ChangeLog entries is not according to
standards.texi.  (See my other message today, in another thread.)


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

* Re: [PATCH/RFC] observer tests & GCC 3.4
  2003-12-11 14:34 ` Eli Zaretskii
@ 2003-12-12 16:24   ` Mark Kettenis
  0 siblings, 0 replies; 5+ messages in thread
From: Mark Kettenis @ 2003-12-12 16:24 UTC (permalink / raw)
  To: eliz; +Cc: gdb-patches, brobecker

   Date: 11 Dec 2003 16:34:40 +0200
   From: Eli Zaretskii <eliz@elta.co.il>

   > Date: Thu, 11 Dec 2003 14:55:15 +0100 (CET)
   > From: Mark Kettenis <kettenis@chello.nl>
   > 
   > Index: ChangeLog
   > from  Mark Kettenis  <kettenis@gnu.org>
   > 
   > 	* observer.c (observer_test_first_observer,
   > 	observer_test_second_observer, observer_test_third_observer):
   > 	Don't define as `static'.
   > 	(observer_test_first_notification_function,
   > 	observer_test_second_notification_function,
   > 	observer_test_third_notification_function): Likewise.

   Nitpicking: the format of the ChangeLog entries is not according to
   standards.texi.  (See my other message today, in another thread.)

Oh dear.  I've been doing this the wrong way for *years*.  I'll try to
be a good boy from now on ;-).

Anyway, I committed the attached.

Mark

Index: ChangeLog
from  Mark Kettenis  <kettenis@gnu.org>

	* observer.c (observer_test_first_observer)
	(observer_test_second_observer, observer_test_third_observer):
	Don't define as `static'.
	(observer_test_first_notification_function)
	(observer_test_second_notification_function)
	(observer_test_third_notification_function): Likewise.

Index: observer.c
===================================================================
RCS file: /cvs/src/src/gdb/observer.c,v
retrieving revision 1.3
diff -u -p -r1.3 observer.c
--- observer.c 18 Mar 2003 18:05:50 -0000 1.3
+++ observer.c 12 Dec 2003 16:09:32 -0000
@@ -191,30 +191,30 @@ observer_notify_normal_stop (void)
   generic_observer_notify (normal_stop_subject, NULL);
 }
 
-/* The following code is only used to unit-test the observers from
-   our testsuite.  DO NOT USE IT within observer.c!  */
+/* The following code is only used to unit-test the observers from our
+   testsuite.  DO NOT USE IT within observer.c (or anywhere else for
+   that matter)!  */
 
-/* Since this code will not be used within GDB, it will trigger
-   a warning if we decide to compile with -Wunused-function.
-   This is ok for now.  (brobecker 2003-03-18)  */
+/* If we define these variables and functions as `static', the
+   compiler will optimize them out.  */
  
-static int observer_test_first_observer = 0;
-static int observer_test_second_observer = 0;
-static int observer_test_third_observer = 0;
+int observer_test_first_observer = 0;
+int observer_test_second_observer = 0;
+int observer_test_third_observer = 0;
 
-static void
+void
 observer_test_first_notification_function (void)
 {
   observer_test_first_observer++;
 }
 
-static void
+void
 observer_test_second_notification_function (void)
 {
   observer_test_second_observer++;
 }
 
-static void
+void
 observer_test_third_notification_function (void)
 {
   observer_test_third_observer++;


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

end of thread, other threads:[~2003-12-12 16:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-11 13:55 [PATCH/RFC] observer tests & GCC 3.4 Mark Kettenis
2003-12-11 14:14 ` Joel Brobecker
2003-12-11 14:24   ` Daniel Jacobowitz
2003-12-11 14:34 ` Eli Zaretskii
2003-12-12 16:24   ` Mark Kettenis

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