Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: gdb-patches@sources.redhat.com
Subject: RFA: lift no-argument restriction on observers
Date: Thu, 17 Jul 2008 22:55:00 -0000	[thread overview]
Message-ID: <m3bq0wxgse.fsf@fleche.redhat.com> (raw)

I noticed a comment in observer.texi to the effect that no-argument
observers are not possible.  Sure enough, observer.sh does not handle
this case, and there is one observer that takes a dummy argument to
work around this problem.

This patch lifts the restriction by changing observer.sh.  It also
modifies that one observer to remove the dummy argument.

Tested on x86 F8, no regressions.  Ok?

Tom

ChangeLog:
2008-07-17  Tom Tromey  <tromey@redhat.com>

	* symfile.c (reread_symbols): Don't pass argument to observer.
	* exec.c (exec_file_attach): Don't pass argument to observer.
	* ada-lang.c (ada_executable_changed_observer): Remove argument.
	* symtab.c (symtab_observer_executable_changed): Remove argument.
	* observer.sh: Handle functions with no arguments.

doc/ChangeLog:
2008-07-17  Tom Tromey  <tromey@redhat.com>

	* observer.texi (GDB Observers): Remove obsolete comment.
	<executable_changed>: Remove argument.

Index: ada-lang.c
===================================================================
RCS file: /cvs/src/src/gdb/ada-lang.c,v
retrieving revision 1.150
diff -u -r1.150 ada-lang.c
--- ada-lang.c	15 Jul 2008 19:11:34 -0000	1.150
+++ ada-lang.c	17 Jul 2008 22:23:50 -0000
@@ -9769,7 +9769,7 @@
    each time a new executable is loaded by GDB.  */
 
 static void
-ada_executable_changed_observer (void *unused)
+ada_executable_changed_observer (void)
 {
   /* If the executable changed, then it is possible that the Ada runtime
      is different.  So we need to invalidate the exception support info
Index: exec.c
===================================================================
RCS file: /cvs/src/src/gdb/exec.c,v
retrieving revision 1.75
diff -u -r1.75 exec.c
--- exec.c	3 May 2008 18:04:02 -0000	1.75
+++ exec.c	17 Jul 2008 22:23:50 -0000
@@ -275,7 +275,7 @@
 	(*deprecated_exec_file_display_hook) (filename);
     }
   bfd_cache_close_all ();
-  observer_notify_executable_changed (NULL);
+  observer_notify_executable_changed ();
 }
 
 /*  Process the first arg in ARGS as the new exec file.
Index: observer.sh
===================================================================
RCS file: /cvs/src/src/gdb/observer.sh,v
retrieving revision 1.15
diff -u -r1.15 observer.sh
--- observer.sh	14 Mar 2008 17:21:07 -0000	1.15
+++ observer.sh	17 Jul 2008 22:23:51 -0000
@@ -123,8 +123,14 @@
 
 static struct observer_list *${event}_subject = NULL;
 
+EOF
+	if test "$formal" != "void"; then
+	    cat<<EOF >>${otmp}
 struct ${event}_args { `echo "${formal}" | sed -e 's/,/;/g'`; };
 
+EOF
+	fi
+	cat <<EOF >>${otmp}
 static void
 observer_${event}_notification_stub (const void *data, const void *args_data)
 {
@@ -150,8 +156,17 @@
 void
 observer_notify_${event} (${formal})
 {
+EOF
+	if test "$formal" != "void"; then
+	    cat<<EOF >>${otmp}
   struct ${event}_args args;
   `echo ${actual} | sed -e 's/\([a-z0-9_][a-z0-9_]*\)/args.\1 = \1/g'`;
+
+EOF
+	else
+	    echo "char *args = NULL;" >> ${otmp}
+	fi
+	cat<<EOF >>${otmp}
   if (observer_debug)
     fprintf_unfiltered (gdb_stdlog, "observer_notify_${event}() called\n");
   generic_observer_notify (${event}_subject, &args);
Index: symfile.c
===================================================================
RCS file: /cvs/src/src/gdb/symfile.c,v
retrieving revision 1.207
diff -u -r1.207 symfile.c
--- symfile.c	10 Jul 2008 23:08:21 -0000	1.207
+++ symfile.c	17 Jul 2008 22:23:51 -0000
@@ -2495,7 +2495,7 @@
       clear_symtab_users ();
       /* At least one objfile has changed, so we can consider that
          the executable we're debugging has changed too.  */
-      observer_notify_executable_changed (NULL);
+      observer_notify_executable_changed ();
     }
       
 }
Index: symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.191
diff -u -r1.191 symtab.c
--- symtab.c	13 Jul 2008 16:58:19 -0000	1.191
+++ symtab.c	17 Jul 2008 22:23:51 -0000
@@ -4325,7 +4325,7 @@
 /* Handle ``executable_changed'' events for the symtab module.  */
 
 static void
-symtab_observer_executable_changed (void *unused)
+symtab_observer_executable_changed (void)
 {
   /* NAME_OF_MAIN may no longer be the same, so reset it for now.  */
   set_main_name (NULL);
Index: doc/observer.texi
===================================================================
RCS file: /cvs/src/src/gdb/doc/observer.texi,v
retrieving revision 1.16
diff -u -r1.16 observer.texi
--- doc/observer.texi	10 Jun 2008 10:23:54 -0000	1.16
+++ doc/observer.texi	17 Jul 2008 22:23:54 -0000
@@ -88,8 +88,6 @@
 
 The following observable events are defined:
 
-@c note: all events must take at least one parameter.
-
 @deftypefun void normal_stop (struct bpstats *@var{bs})
 The inferior has stopped for real.
 @end deftypefun
@@ -98,7 +96,7 @@
 The target's register contents have changed.
 @end deftypefun
 
-@deftypefun void executable_changed (void *@var{unused_args})
+@deftypefun void executable_changed (void)
 The executable being debugged by GDB has changed: The user decided
 to debug a different program, or the program he was debugging has
 been modified since being loaded by the debugger (by being recompiled,
@@ -141,4 +139,3 @@
 The target was resumed.  The @var{ptid} parameter specifies which
 thread was resume, and may be RESUME_ALL if all threads are resumed.
 @end deftypefun
-


             reply	other threads:[~2008-07-17 22:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-17 22:55 Tom Tromey [this message]
2008-07-21 15:56 ` Daniel Jacobowitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3bq0wxgse.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=gdb-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox