Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] Improve "start" command for Ada
@ 2004-10-21  3:48 Joel Brobecker
  2004-10-21  5:31 ` Eli Zaretskii
  0 siblings, 1 reply; 13+ messages in thread
From: Joel Brobecker @ 2004-10-21  3:48 UTC (permalink / raw)
  To: gdb-patches

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

This is a followup on a thread started at:

        http://sources.redhat.com/ml/gdb-patches/2004-05/msg00521.html

It is the second part of the change that introduced the start
command, needed to make this command work for Ada. The principle
was sort of agreed on but it was a while ago, so things may have
changed. See:

        http://sources.redhat.com/ml/gdb-patches/2004-05/msg00618.html

Small refresher (it took me a while to collect all the elements of
the puzzle again):

        . Around the 20th of March 2004, I introduced a new command
          named "start". The implementation of this command was
          relying on a function called "main_name". At the time,
          this function was returning either the name of the main
          provided by STABS, or was defaulting to "main".

          The name of the main procedure in Ada changes from executable
          to executable, so this is not enough for Ada. But this Ada
          support was not activated then, we stopped there.

        . Now that Ada is activated, it is no longer enough for
          main_name to default to "main". So the intent was to
          later update that main_name() to search for the name of
          the main procedure a bit more precisely. And the approach
          selected was just to call language-specific procedures that
          would return either the name of the main procedure, or NULL
          if not found.

This is essentially what this patch does.

But on top of this, we have to be a bit careful, because the name
of the main program is cached, and we don't want to use an old name
incorrectly. So I added a small observer, that notifies us when the
executable file being debug changes, so that we can reset the cached
name.

2004-10-20  Joel Brobecker  <brobecker@gnat.com>

        * doc/observer.texi (executable_changed): New observer.
        * symtab.c: Include "observer.h".
        (find_main_name): New function.
        (main_name): If name_of_main is unset, then compute it
        using find_main_name.
        (symtab_observer_executable_changed): New function.
        (_initialize_symtab): Attach executable_changed observer.
        * exec.c: Include "observer.h".
        (exec_file_attach): Emit executable_changed notification.
        * Makefile.in (exec.o): Add dependency on observer.h.
        (symtab.o): Likewise.

Tested on x86-linux. Fixes the failure that I introduced with
the patch I submitted for gdb.ada/null_record.exp (making the
expected output a bit more stringent on what we verify). See

        http://sources.redhat.com/ml/gdb-patches/2004-10/msg00350.html

OK to commit?

Thanks,
-- 
Joel

[-- Attachment #2: find_main_name.diff --]
[-- Type: text/plain, Size: 4498 bytes --]

Index: doc/observer.texi
===================================================================
RCS file: /cvs/src/src/gdb/doc/observer.texi,v
retrieving revision 1.8
diff -u -p -r1.8 observer.texi
--- doc/observer.texi	1 Sep 2004 17:59:37 -0000	1.8
+++ doc/observer.texi	21 Oct 2004 03:43:33 -0000
@@ -83,6 +83,10 @@ The inferior has stopped for real.
 The target's register contents have changed.
 @end deftypefun
 
+@deftypefun void executable_changed (void *@var{unused_args})
+The executable being debugged by GDB has changed.
+@end deftypefun
+
 @deftypefun void inferior_created (struct target_ops *@var{objfile}, int @var{from_tty})
 @value{GDBN} has just connected to an inferior.  For @samp{run},
 @value{GDBN} calls this observer while the inferior is still stopped
Index: symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.140
diff -u -p -r1.140 symtab.c
--- symtab.c	2 Oct 2004 09:55:15 -0000	1.140
+++ symtab.c	21 Oct 2004 03:43:35 -0000
@@ -55,6 +55,7 @@
 #include "gdb_stat.h"
 #include <ctype.h>
 #include "cp-abi.h"
+#include "observer.h"
 
 /* Prototypes for local functions */
 
@@ -4090,15 +4091,44 @@ set_main_name (const char *name)
     }
 }
 
+/* Deduce the name of the main procedure, and set NAME_OF_MAIN
+   accordingly.  */
+
+static void
+find_main_name (void)
+{
+  char *new_main_name;
+
+  /* Try to see if the main procedure is in Ada.  */
+  new_main_name = ada_main_name ();
+  if (new_main_name != NULL)
+    { 
+      set_main_name (new_main_name);
+      return;
+    }
+
+  /* The languages above didn't identify the name of the main procedure.
+     Fallback to "main".  */
+  set_main_name ("main");
+}
+
 char *
 main_name (void)
 {
-  if (name_of_main != NULL)
-    return name_of_main;
-  else
-    return "main";
+  if (name_of_main == NULL)
+    find_main_name ();
+
+  return name_of_main;
 }
 
+/* Handle ``executable_changed'' events for the symtab module.  */
+
+static void
+symtab_observer_executable_changed (void *unused)
+{
+  /* NAME_OF_MAIN may no longer be the same, so reset it for now.  */
+  set_main_name (NULL);
+}
 
 void
 _initialize_symtab (void)
@@ -4140,4 +4170,6 @@ _initialize_symtab (void)
   /* Initialize the one built-in type that isn't language dependent... */
   builtin_type_error = init_type (TYPE_CODE_ERROR, 0, 0,
 				  "<unknown type>", (struct objfile *) NULL);
+
+  observer_attach_executable_changed (symtab_observer_executable_changed);
 }
Index: exec.c
===================================================================
RCS file: /cvs/src/src/gdb/exec.c,v
retrieving revision 1.43
diff -u -p -r1.43 exec.c
--- exec.c	8 Oct 2004 20:29:46 -0000	1.43
+++ exec.c	21 Oct 2004 03:43:35 -0000
@@ -32,6 +32,7 @@
 #include "completer.h"
 #include "value.h"
 #include "exec.h"
+#include "observer.h"
 
 #include <fcntl.h>
 #include "readline/readline.h"
@@ -268,6 +269,7 @@ exec_file_attach (char *filename, int fr
 	(*deprecated_exec_file_display_hook) (filename);
     }
   bfd_cache_close_all ();
+  observer_notify_executable_changed (NULL);
 }
 
 /*  Process the first arg in ARGS as the new exec file.
Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.643
diff -u -p -r1.643 Makefile.in
--- Makefile.in	15 Oct 2004 16:17:34 -0000	1.643
+++ Makefile.in	21 Oct 2004 03:43:38 -0000
@@ -1887,7 +1887,7 @@ event-top.o: event-top.c $(defs_h) $(top
 exec.o: exec.c $(defs_h) $(frame_h) $(inferior_h) $(target_h) $(gdbcmd_h) \
 	$(language_h) $(symfile_h) $(objfiles_h) $(completer_h) $(value_h) \
 	$(exec_h) $(readline_h) $(gdb_string_h) $(gdbcore_h) $(gdb_stat_h) \
-	$(xcoffsolib_h)
+	$(xcoffsolib_h) $(observer_h)
 expprint.o: expprint.c $(defs_h) $(symtab_h) $(gdbtypes_h) $(expression_h) \
 	$(value_h) $(language_h) $(parser_defs_h) $(user_regs_h) $(target_h) \
 	$(gdb_string_h) $(block_h)
@@ -2611,7 +2611,7 @@ symtab.o: symtab.c $(defs_h) $(symtab_h)
 	$(language_h) $(demangle_h) $(inferior_h) $(linespec_h) $(source_h) \
 	$(filenames_h) $(objc_lang_h) $(ada_lang_h) $(hashtab_h) \
 	$(gdb_obstack_h) $(block_h) $(dictionary_h) $(gdb_string_h) \
-	$(gdb_stat_h) $(cp_abi_h)
+	$(gdb_stat_h) $(cp_abi_h) $(observer_h)
 target.o: target.c $(defs_h) $(gdb_string_h) $(target_h) $(gdbcmd_h) \
 	$(symtab_h) $(inferior_h) $(bfd_h) $(symfile_h) $(objfiles_h) \
 	$(gdb_wait_h) $(dcache_h) $(regcache_h) $(gdb_assert_h) $(gdbcore_h)

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

* Re: [RFA] Improve "start" command for Ada
  2004-10-21  3:48 [RFA] Improve "start" command for Ada Joel Brobecker
@ 2004-10-21  5:31 ` Eli Zaretskii
  2004-10-21 21:09   ` Joel Brobecker
  0 siblings, 1 reply; 13+ messages in thread
From: Eli Zaretskii @ 2004-10-21  5:31 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

> Date: Wed, 20 Oct 2004 20:47:59 -0700
> From: Joel Brobecker <brobecker@gnat.com>
> 
> +@deftypefun void executable_changed (void *@var{unused_args})
> +The executable being debugged by GDB has changed.
> +@end deftypefun

This is not clear enough: what does it mean ``the executable has
changed''?  Did its file name change? what if its the same program,
but it was recompiled and its debugging session restarted?


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

* Re: [RFA] Improve "start" command for Ada
  2004-10-21  5:31 ` Eli Zaretskii
@ 2004-10-21 21:09   ` Joel Brobecker
  2004-10-23 10:05     ` Eli Zaretskii
                       ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Joel Brobecker @ 2004-10-21 21:09 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gdb-patches

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

> > +@deftypefun void executable_changed (void *@var{unused_args})
> > +The executable being debugged by GDB has changed.
> > +@end deftypefun
> 
> This is not clear enough: what does it mean ``the executable has
> changed''?  Did its file name change? what if its the same program,
> but it was recompiled and its debugging session restarted?

That's a very good point, which pointed at something I didn't consider
when I first wrote the patch: The signal needs to be sent when the
program has been recompiled, or course. Is this version better?

2004-10-20  Joel Brobecker  <brobecker@gnat.com>

        * doc/observer.texi (executable_changed): New observer.
        * symtab.c: Include "observer.h".
        (find_main_name): New function.
        (main_name): If name_of_main is unset, then compute it
        using find_main_name.
        (symtab_observer_executable_changed): New function.
        (_initialize_symtab): Attach executable_changed observer.
        * exec.c: Include "observer.h".
        (exec_file_attach): Emit executable_changed notification.
        * symfile.c: Include "observer.h".
        (reread_symbols): Send an executable_changed if appropriate.
        * Makefile.in (exec.o): Add dependency on observer.h.
        (symfile.o): Likewise.
        (symtab.o): Likewise.

Tested on x86-linux. Still fixes 1 FAIL in gdb.ada/null_record.exp.

-- 
Joel

[-- Attachment #2: find_main_name.diff --]
[-- Type: text/plain, Size: 5965 bytes --]

Index: exec.c
===================================================================
RCS file: /cvs/src/src/gdb/exec.c,v
retrieving revision 1.43
diff -u -p -r1.43 exec.c
--- exec.c	8 Oct 2004 20:29:46 -0000	1.43
+++ exec.c	21 Oct 2004 20:57:08 -0000
@@ -32,6 +32,7 @@
 #include "completer.h"
 #include "value.h"
 #include "exec.h"
+#include "observer.h"
 
 #include <fcntl.h>
 #include "readline/readline.h"
@@ -268,6 +269,7 @@ exec_file_attach (char *filename, int fr
 	(*deprecated_exec_file_display_hook) (filename);
     }
   bfd_cache_close_all ();
+  observer_notify_executable_changed (NULL);
 }
 
 /*  Process the first arg in ARGS as the new exec file.
Index: symfile.c
===================================================================
RCS file: /cvs/src/src/gdb/symfile.c,v
retrieving revision 1.143
diff -u -p -r1.143 symfile.c
--- symfile.c	1 Oct 2004 10:23:09 -0000	1.143
+++ symfile.c	21 Oct 2004 20:59:03 -0000
@@ -48,6 +48,7 @@
 #include "readline/readline.h"
 #include "gdb_assert.h"
 #include "block.h"
+#include "observer.h"
 
 #include <sys/types.h>
 #include <fcntl.h>
@@ -1990,7 +1991,13 @@ reread_symbols (void)
     }
 
   if (reread_one)
-    clear_symtab_users ();
+    {
+      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);
+    }
+      
 }
 
 
Index: symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.140
diff -u -p -r1.140 symtab.c
--- symtab.c	2 Oct 2004 09:55:15 -0000	1.140
+++ symtab.c	21 Oct 2004 20:59:05 -0000
@@ -55,6 +55,7 @@
 #include "gdb_stat.h"
 #include <ctype.h>
 #include "cp-abi.h"
+#include "observer.h"
 
 /* Prototypes for local functions */
 
@@ -4090,15 +4091,44 @@ set_main_name (const char *name)
     }
 }
 
+/* Deduce the name of the main procedure, and set NAME_OF_MAIN
+   accordingly.  */
+
+static void
+find_main_name (void)
+{
+  char *new_main_name;
+
+  /* Try to see if the main procedure is in Ada.  */
+  new_main_name = ada_main_name ();
+  if (new_main_name != NULL)
+    { 
+      set_main_name (new_main_name);
+      return;
+    }
+
+  /* The languages above didn't identify the name of the main procedure.
+     Fallback to "main".  */
+  set_main_name ("main");
+}
+
 char *
 main_name (void)
 {
-  if (name_of_main != NULL)
-    return name_of_main;
-  else
-    return "main";
+  if (name_of_main == NULL)
+    find_main_name ();
+
+  return name_of_main;
 }
 
+/* Handle ``executable_changed'' events for the symtab module.  */
+
+static void
+symtab_observer_executable_changed (void *unused)
+{
+  /* NAME_OF_MAIN may no longer be the same, so reset it for now.  */
+  set_main_name (NULL);
+}
 
 void
 _initialize_symtab (void)
@@ -4140,4 +4170,6 @@ _initialize_symtab (void)
   /* Initialize the one built-in type that isn't language dependent... */
   builtin_type_error = init_type (TYPE_CODE_ERROR, 0, 0,
 				  "<unknown type>", (struct objfile *) NULL);
+
+  observer_attach_executable_changed (symtab_observer_executable_changed);
 }
Index: doc/observer.texi
===================================================================
RCS file: /cvs/src/src/gdb/doc/observer.texi,v
retrieving revision 1.8
diff -u -p -r1.8 observer.texi
--- doc/observer.texi	1 Sep 2004 17:59:37 -0000	1.8
+++ doc/observer.texi	21 Oct 2004 20:59:52 -0000
@@ -83,6 +83,13 @@ The inferior has stopped for real.
 The target's register contents have changed.
 @end deftypefun
 
+@deftypefun void executable_changed (void *@var{unused_args})
+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,
+for instance).
+@end deftypefun
+
 @deftypefun void inferior_created (struct target_ops *@var{objfile}, int @var{from_tty})
 @value{GDBN} has just connected to an inferior.  For @samp{run},
 @value{GDBN} calls this observer while the inferior is still stopped
Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.643
diff -u -p -r1.643 Makefile.in
--- Makefile.in	15 Oct 2004 16:17:34 -0000	1.643
+++ Makefile.in	21 Oct 2004 21:08:16 -0000
@@ -1887,7 +1887,7 @@ event-top.o: event-top.c $(defs_h) $(top
 exec.o: exec.c $(defs_h) $(frame_h) $(inferior_h) $(target_h) $(gdbcmd_h) \
 	$(language_h) $(symfile_h) $(objfiles_h) $(completer_h) $(value_h) \
 	$(exec_h) $(readline_h) $(gdb_string_h) $(gdbcore_h) $(gdb_stat_h) \
-	$(xcoffsolib_h)
+	$(xcoffsolib_h) $(observer_h)
 expprint.o: expprint.c $(defs_h) $(symtab_h) $(gdbtypes_h) $(expression_h) \
 	$(value_h) $(language_h) $(parser_defs_h) $(user_regs_h) $(target_h) \
 	$(gdb_string_h) $(block_h)
@@ -2598,7 +2598,7 @@ symfile.o: symfile.c $(defs_h) $(bfdlink
 	$(complaints_h) $(demangle_h) $(inferior_h) $(filenames_h) \
 	$(gdb_stabs_h) $(gdb_obstack_h) $(completer_h) $(bcache_h) \
 	$(hashtab_h) $(readline_h) $(gdb_assert_h) $(block_h) \
-	$(gdb_string_h) $(gdb_stat_h)
+	$(gdb_string_h) $(gdb_stat_h) $(observer_h)
 symfile-mem.o: symfile-mem.c $(defs_h) $(symtab_h) $(gdbcore_h) \
 	$(objfiles_h) $(gdbcmd_h) $(target_h) $(value_h) $(symfile_h)
 symmisc.o: symmisc.c $(defs_h) $(symtab_h) $(gdbtypes_h) $(bfd_h) \
@@ -2611,7 +2611,7 @@ symtab.o: symtab.c $(defs_h) $(symtab_h)
 	$(language_h) $(demangle_h) $(inferior_h) $(linespec_h) $(source_h) \
 	$(filenames_h) $(objc_lang_h) $(ada_lang_h) $(hashtab_h) \
 	$(gdb_obstack_h) $(block_h) $(dictionary_h) $(gdb_string_h) \
-	$(gdb_stat_h) $(cp_abi_h)
+	$(gdb_stat_h) $(cp_abi_h) $(observer_h)
 target.o: target.c $(defs_h) $(gdb_string_h) $(target_h) $(gdbcmd_h) \
 	$(symtab_h) $(inferior_h) $(bfd_h) $(symfile_h) $(objfiles_h) \
 	$(gdb_wait_h) $(dcache_h) $(regcache_h) $(gdb_assert_h) $(gdbcore_h)

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

* Re: [RFA] Improve "start" command for Ada
  2004-10-21 21:09   ` Joel Brobecker
@ 2004-10-23 10:05     ` Eli Zaretskii
  2004-11-01 19:47     ` Joel Brobecker
  2004-11-22 19:10     ` Joel Brobecker
  2 siblings, 0 replies; 13+ messages in thread
From: Eli Zaretskii @ 2004-10-23 10:05 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

> Date: Thu, 21 Oct 2004 14:09:51 -0700
> From: Joel Brobecker <brobecker@gnat.com>
> Cc: gdb-patches@sources.redhat.com
> 
> > This is not clear enough: what does it mean ``the executable has
> > changed''?  Did its file name change? what if its the same program,
> > but it was recompiled and its debugging session restarted?
> 
> That's a very good point, which pointed at something I didn't consider
> when I first wrote the patch: The signal needs to be sent when the
> program has been recompiled, or course. Is this version better?

Yes, much better; thanks.  The Texinfo patch is approved.


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

* Re: [RFA] Improve "start" command for Ada
  2004-10-21 21:09   ` Joel Brobecker
  2004-10-23 10:05     ` Eli Zaretskii
@ 2004-11-01 19:47     ` Joel Brobecker
  2004-11-29  2:12       ` Elena Zannoni
  2004-11-22 19:10     ` Joel Brobecker
  2 siblings, 1 reply; 13+ messages in thread
From: Joel Brobecker @ 2004-11-01 19:47 UTC (permalink / raw)
  To: gdb-patches

Ping? (doco already approved by Eli)

On Thu, Oct 21, 2004 at 02:09:51PM -0700, Joel Brobecker wrote:
> 2004-10-20  Joel Brobecker  <brobecker@gnat.com>
> 
>         * doc/observer.texi (executable_changed): New observer.
>         * symtab.c: Include "observer.h".
>         (find_main_name): New function.
>         (main_name): If name_of_main is unset, then compute it
>         using find_main_name.
>         (symtab_observer_executable_changed): New function.
>         (_initialize_symtab): Attach executable_changed observer.
>         * exec.c: Include "observer.h".
>         (exec_file_attach): Emit executable_changed notification.
>         * symfile.c: Include "observer.h".
>         (reread_symbols): Send an executable_changed if appropriate.
>         * Makefile.in (exec.o): Add dependency on observer.h.
>         (symfile.o): Likewise.
>         (symtab.o): Likewise.
> 
> Tested on x86-linux. Still fixes 1 FAIL in gdb.ada/null_record.exp.
> 
> -- 
> Joel

> Index: exec.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/exec.c,v
> retrieving revision 1.43
> diff -u -p -r1.43 exec.c
> --- exec.c	8 Oct 2004 20:29:46 -0000	1.43
> +++ exec.c	21 Oct 2004 20:57:08 -0000
> @@ -32,6 +32,7 @@
>  #include "completer.h"
>  #include "value.h"
>  #include "exec.h"
> +#include "observer.h"
>  
>  #include <fcntl.h>
>  #include "readline/readline.h"
> @@ -268,6 +269,7 @@ exec_file_attach (char *filename, int fr
>  	(*deprecated_exec_file_display_hook) (filename);
>      }
>    bfd_cache_close_all ();
> +  observer_notify_executable_changed (NULL);
>  }
>  
>  /*  Process the first arg in ARGS as the new exec file.
> Index: symfile.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/symfile.c,v
> retrieving revision 1.143
> diff -u -p -r1.143 symfile.c
> --- symfile.c	1 Oct 2004 10:23:09 -0000	1.143
> +++ symfile.c	21 Oct 2004 20:59:03 -0000
> @@ -48,6 +48,7 @@
>  #include "readline/readline.h"
>  #include "gdb_assert.h"
>  #include "block.h"
> +#include "observer.h"
>  
>  #include <sys/types.h>
>  #include <fcntl.h>
> @@ -1990,7 +1991,13 @@ reread_symbols (void)
>      }
>  
>    if (reread_one)
> -    clear_symtab_users ();
> +    {
> +      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);
> +    }
> +      
>  }
>  
>  
> Index: symtab.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/symtab.c,v
> retrieving revision 1.140
> diff -u -p -r1.140 symtab.c
> --- symtab.c	2 Oct 2004 09:55:15 -0000	1.140
> +++ symtab.c	21 Oct 2004 20:59:05 -0000
> @@ -55,6 +55,7 @@
>  #include "gdb_stat.h"
>  #include <ctype.h>
>  #include "cp-abi.h"
> +#include "observer.h"
>  
>  /* Prototypes for local functions */
>  
> @@ -4090,15 +4091,44 @@ set_main_name (const char *name)
>      }
>  }
>  
> +/* Deduce the name of the main procedure, and set NAME_OF_MAIN
> +   accordingly.  */
> +
> +static void
> +find_main_name (void)
> +{
> +  char *new_main_name;
> +
> +  /* Try to see if the main procedure is in Ada.  */
> +  new_main_name = ada_main_name ();
> +  if (new_main_name != NULL)
> +    { 
> +      set_main_name (new_main_name);
> +      return;
> +    }
> +
> +  /* The languages above didn't identify the name of the main procedure.
> +     Fallback to "main".  */
> +  set_main_name ("main");
> +}
> +
>  char *
>  main_name (void)
>  {
> -  if (name_of_main != NULL)
> -    return name_of_main;
> -  else
> -    return "main";
> +  if (name_of_main == NULL)
> +    find_main_name ();
> +
> +  return name_of_main;
>  }
>  
> +/* Handle ``executable_changed'' events for the symtab module.  */
> +
> +static void
> +symtab_observer_executable_changed (void *unused)
> +{
> +  /* NAME_OF_MAIN may no longer be the same, so reset it for now.  */
> +  set_main_name (NULL);
> +}
>  
>  void
>  _initialize_symtab (void)
> @@ -4140,4 +4170,6 @@ _initialize_symtab (void)
>    /* Initialize the one built-in type that isn't language dependent... */
>    builtin_type_error = init_type (TYPE_CODE_ERROR, 0, 0,
>  				  "<unknown type>", (struct objfile *) NULL);
> +
> +  observer_attach_executable_changed (symtab_observer_executable_changed);
>  }
> Index: doc/observer.texi
> ===================================================================
> RCS file: /cvs/src/src/gdb/doc/observer.texi,v
> retrieving revision 1.8
> diff -u -p -r1.8 observer.texi
> --- doc/observer.texi	1 Sep 2004 17:59:37 -0000	1.8
> +++ doc/observer.texi	21 Oct 2004 20:59:52 -0000
> @@ -83,6 +83,13 @@ The inferior has stopped for real.
>  The target's register contents have changed.
>  @end deftypefun
>  
> +@deftypefun void executable_changed (void *@var{unused_args})
> +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,
> +for instance).
> +@end deftypefun
> +
>  @deftypefun void inferior_created (struct target_ops *@var{objfile}, int @var{from_tty})
>  @value{GDBN} has just connected to an inferior.  For @samp{run},
>  @value{GDBN} calls this observer while the inferior is still stopped
> Index: Makefile.in
> ===================================================================
> RCS file: /cvs/src/src/gdb/Makefile.in,v
> retrieving revision 1.643
> diff -u -p -r1.643 Makefile.in
> --- Makefile.in	15 Oct 2004 16:17:34 -0000	1.643
> +++ Makefile.in	21 Oct 2004 21:08:16 -0000
> @@ -1887,7 +1887,7 @@ event-top.o: event-top.c $(defs_h) $(top
>  exec.o: exec.c $(defs_h) $(frame_h) $(inferior_h) $(target_h) $(gdbcmd_h) \
>  	$(language_h) $(symfile_h) $(objfiles_h) $(completer_h) $(value_h) \
>  	$(exec_h) $(readline_h) $(gdb_string_h) $(gdbcore_h) $(gdb_stat_h) \
> -	$(xcoffsolib_h)
> +	$(xcoffsolib_h) $(observer_h)
>  expprint.o: expprint.c $(defs_h) $(symtab_h) $(gdbtypes_h) $(expression_h) \
>  	$(value_h) $(language_h) $(parser_defs_h) $(user_regs_h) $(target_h) \
>  	$(gdb_string_h) $(block_h)
> @@ -2598,7 +2598,7 @@ symfile.o: symfile.c $(defs_h) $(bfdlink
>  	$(complaints_h) $(demangle_h) $(inferior_h) $(filenames_h) \
>  	$(gdb_stabs_h) $(gdb_obstack_h) $(completer_h) $(bcache_h) \
>  	$(hashtab_h) $(readline_h) $(gdb_assert_h) $(block_h) \
> -	$(gdb_string_h) $(gdb_stat_h)
> +	$(gdb_string_h) $(gdb_stat_h) $(observer_h)
>  symfile-mem.o: symfile-mem.c $(defs_h) $(symtab_h) $(gdbcore_h) \
>  	$(objfiles_h) $(gdbcmd_h) $(target_h) $(value_h) $(symfile_h)
>  symmisc.o: symmisc.c $(defs_h) $(symtab_h) $(gdbtypes_h) $(bfd_h) \
> @@ -2611,7 +2611,7 @@ symtab.o: symtab.c $(defs_h) $(symtab_h)
>  	$(language_h) $(demangle_h) $(inferior_h) $(linespec_h) $(source_h) \
>  	$(filenames_h) $(objc_lang_h) $(ada_lang_h) $(hashtab_h) \
>  	$(gdb_obstack_h) $(block_h) $(dictionary_h) $(gdb_string_h) \
> -	$(gdb_stat_h) $(cp_abi_h)
> +	$(gdb_stat_h) $(cp_abi_h) $(observer_h)
>  target.o: target.c $(defs_h) $(gdb_string_h) $(target_h) $(gdbcmd_h) \
>  	$(symtab_h) $(inferior_h) $(bfd_h) $(symfile_h) $(objfiles_h) \
>  	$(gdb_wait_h) $(dcache_h) $(regcache_h) $(gdb_assert_h) $(gdbcore_h)


-- 
Joel


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

* Re: [RFA] Improve "start" command for Ada
  2004-10-21 21:09   ` Joel Brobecker
  2004-10-23 10:05     ` Eli Zaretskii
  2004-11-01 19:47     ` Joel Brobecker
@ 2004-11-22 19:10     ` Joel Brobecker
  2 siblings, 0 replies; 13+ messages in thread
From: Joel Brobecker @ 2004-11-22 19:10 UTC (permalink / raw)
  To: gdb-patches

Ping? (one month)

The doco part has already been approved.

On Thu, Oct 21, 2004 at 02:09:51PM -0700, Joel Brobecker wrote:
> 2004-10-20  Joel Brobecker  <brobecker@gnat.com>
> 
>         * doc/observer.texi (executable_changed): New observer.
>         * symtab.c: Include "observer.h".
>         (find_main_name): New function.
>         (main_name): If name_of_main is unset, then compute it
>         using find_main_name.
>         (symtab_observer_executable_changed): New function.
>         (_initialize_symtab): Attach executable_changed observer.
>         * exec.c: Include "observer.h".
>         (exec_file_attach): Emit executable_changed notification.
>         * symfile.c: Include "observer.h".
>         (reread_symbols): Send an executable_changed if appropriate.
>         * Makefile.in (exec.o): Add dependency on observer.h.
>         (symfile.o): Likewise.
>         (symtab.o): Likewise.
> 
> Tested on x86-linux. Still fixes 1 FAIL in gdb.ada/null_record.exp.

The patch is available at: 

        http://sources.redhat.com/ml/gdb-patches/2004-10/msg00365.html

Thanks!
-- 
Joel


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

* Re: [RFA] Improve "start" command for Ada
  2004-11-01 19:47     ` Joel Brobecker
@ 2004-11-29  2:12       ` Elena Zannoni
  2004-12-01  3:03         ` Joel Brobecker
  0 siblings, 1 reply; 13+ messages in thread
From: Elena Zannoni @ 2004-11-29  2:12 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

Joel Brobecker writes:
 > Ping? (doco already approved by Eli)
 > 
 > On Thu, Oct 21, 2004 at 02:09:51PM -0700, Joel Brobecker wrote:
 > > 2004-10-20  Joel Brobecker  <brobecker@gnat.com>
 > > 
 > >         * doc/observer.texi (executable_changed): New observer.
 > >         * symtab.c: Include "observer.h".
 > >         (find_main_name): New function.
 > >         (main_name): If name_of_main is unset, then compute it
 > >         using find_main_name.
 > >         (symtab_observer_executable_changed): New function.
 > >         (_initialize_symtab): Attach executable_changed observer.
 > >         * exec.c: Include "observer.h".
 > >         (exec_file_attach): Emit executable_changed notification.
 > >         * symfile.c: Include "observer.h".
 > >         (reread_symbols): Send an executable_changed if appropriate.
 > >         * Makefile.in (exec.o): Add dependency on observer.h.
 > >         (symfile.o): Likewise.
 > >         (symtab.o): Likewise.
 > > 
 > > Tested on x86-linux. Still fixes 1 FAIL in gdb.ada/null_record.exp.
 > > 

We need a testcase where the name of the executable is changed, and
this code is exercised. Otherwise ok, except for this:


 > > +/* Deduce the name of the main procedure, and set NAME_OF_MAIN
 > > +   accordingly.  */
 > > +
 > > +static void
 > > +find_main_name (void)
 > > +{
 > > +  char *new_main_name;
 > > +
 > > +  /* Try to see if the main procedure is in Ada.  */
 > > +  new_main_name = ada_main_name ();
 > > +  if (new_main_name != NULL)
 > > +    { 
 > > +      set_main_name (new_main_name);
 > > +      return;
 > > +    }
 > > +
 > > +  /* The languages above didn't identify the name of the main procedure.
 > > +     Fallback to "main".  */
 > > +  set_main_name ("main");
 > > +}
 > > +
 > >  char *
 > >  main_name (void)
 > >  {
 > > -  if (name_of_main != NULL)
 > > -    return name_of_main;
 > > -  else
 > > -    return "main";
 > > +  if (name_of_main == NULL)
 > > +    find_main_name ();
 > > +
 > > +  return name_of_main;
 > >  }
 > >  

Can this find_main_name become an element in the language vector? I
really don't want to have a special language cases in the symtab file.


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

* Re: [RFA] Improve "start" command for Ada
  2004-11-29  2:12       ` Elena Zannoni
@ 2004-12-01  3:03         ` Joel Brobecker
  2005-02-09 18:22           ` Joel Brobecker
  0 siblings, 1 reply; 13+ messages in thread
From: Joel Brobecker @ 2004-12-01  3:03 UTC (permalink / raw)
  To: Elena Zannoni; +Cc: gdb-patches

Hello Elena,

Thanks for the your review.

On Sun, Nov 28, 2004 at 09:08:21PM -0500, Elena Zannoni wrote:
> Joel Brobecker writes:
>  > Ping? (doco already approved by Eli)
>  > 
>  > On Thu, Oct 21, 2004 at 02:09:51PM -0700, Joel Brobecker wrote:
>  > > 2004-10-20  Joel Brobecker  <brobecker@gnat.com>
>  > > 
>  > >         * doc/observer.texi (executable_changed): New observer.
>  > >         * symtab.c: Include "observer.h".
>  > >         (find_main_name): New function.
>  > >         (main_name): If name_of_main is unset, then compute it
>  > >         using find_main_name.
>  > >         (symtab_observer_executable_changed): New function.
>  > >         (_initialize_symtab): Attach executable_changed observer.
>  > >         * exec.c: Include "observer.h".
>  > >         (exec_file_attach): Emit executable_changed notification.
>  > >         * symfile.c: Include "observer.h".
>  > >         (reread_symbols): Send an executable_changed if appropriate.
>  > >         * Makefile.in (exec.o): Add dependency on observer.h.
>  > >         (symfile.o): Likewise.
>  > >         (symtab.o): Likewise.
>  > > 
>  > > Tested on x86-linux. Still fixes 1 FAIL in gdb.ada/null_record.exp.
>  > > 
> 
> We need a testcase where the name of the executable is changed, and
> this code is exercised. Otherwise ok, except for this:

OK, I will add something along the line of reread.exp.

>  > > +/* Deduce the name of the main procedure, and set NAME_OF_MAIN
>  > > +   accordingly.  */
>  > > +
>  > > +static void
>  > > +find_main_name (void)
>  > > +{
>  > > +  char *new_main_name;
>  > > +
>  > > +  /* Try to see if the main procedure is in Ada.  */
>  > > +  new_main_name = ada_main_name ();
>  > > +  if (new_main_name != NULL)
>  > > +    { 
>  > > +      set_main_name (new_main_name);
>  > > +      return;
>  > > +    }
>  > > +
>  > > +  /* The languages above didn't identify the name of the main procedure.
>  > > +     Fallback to "main".  */
>  > > +  set_main_name ("main");
>  > > +}
>  > > +
>  > >  char *
>  > >  main_name (void)
>  > >  {
>  > > -  if (name_of_main != NULL)
>  > > -    return name_of_main;
>  > > -  else
>  > > -    return "main";
>  > > +  if (name_of_main == NULL)
>  > > +    find_main_name ();
>  > > +
>  > > +  return name_of_main;
>  > >  }
>  > >  
> 
> Can this find_main_name become an element in the language vector? I
> really don't want to have a special language cases in the symtab file.

This has actually been discussed already. There were several messages
exchanged between Daniel and myself, but here are some important ones:

    http://sources.redhat.com/ml/gdb-patches/2004-05/msg00607.html
    (one potential confusion if we use the *current* language vector
    to determine the name of main. This is also where the suggestion
    of calling the Ada routine directly was suggested.

    http://sources.redhat.com/ml/gdb-patches/2004-05/msg00612.html
    (we agree that it's ok to call ada_main_name directly)

In short, the answer to the discussion was that this was probably the
best approach for now. The reason why it can't be put in the language
vector is that this is not a property of the language (which can vary
within the same program, depending on the frame), but a property of
the executable. None of us like this approach much, but it was something
that we felt sucked the least.

If you want, what we can do is replace the hard-coded call to
ada_main_name() by a loop of calls to a new language method,
looping on all languages until we find a positive match. That
way, the hard wiring to Ada disappears. But I don't think we're
getting much from this extra slight complexity. 

-- 
Joel


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

* Re: [RFA] Improve "start" command for Ada
  2004-12-01  3:03         ` Joel Brobecker
@ 2005-02-09 18:22           ` Joel Brobecker
  2005-03-07 19:30             ` Joel Brobecker
  0 siblings, 1 reply; 13+ messages in thread
From: Joel Brobecker @ 2005-02-09 18:22 UTC (permalink / raw)
  To: Elena Zannoni; +Cc: gdb-patches

Hello Elena,

There is one part of the patch that hasn't been approved yet. I tried
to explain a bit the history of the code you were concerned with, and
I was wondering what your thoughts were. Could you have a look? (way
at the bottom of the message - I kept the rest to keep the entire
context together).

Thanks,
-- 
Joel

> On Sun, Nov 28, 2004 at 09:08:21PM -0500, Elena Zannoni wrote:
> > Joel Brobecker writes:
> >  > Ping? (doco already approved by Eli)
> >  > 
> >  > On Thu, Oct 21, 2004 at 02:09:51PM -0700, Joel Brobecker wrote:
> >  > > 2004-10-20  Joel Brobecker  <brobecker@gnat.com>
> >  > > 
> >  > >         * doc/observer.texi (executable_changed): New observer.
> >  > >         * symtab.c: Include "observer.h".
> >  > >         (find_main_name): New function.
> >  > >         (main_name): If name_of_main is unset, then compute it
> >  > >         using find_main_name.
> >  > >         (symtab_observer_executable_changed): New function.
> >  > >         (_initialize_symtab): Attach executable_changed observer.
> >  > >         * exec.c: Include "observer.h".
> >  > >         (exec_file_attach): Emit executable_changed notification.
> >  > >         * symfile.c: Include "observer.h".
> >  > >         (reread_symbols): Send an executable_changed if appropriate.
> >  > >         * Makefile.in (exec.o): Add dependency on observer.h.
> >  > >         (symfile.o): Likewise.
> >  > >         (symtab.o): Likewise.
> >  > > 
> >  > > Tested on x86-linux. Still fixes 1 FAIL in gdb.ada/null_record.exp.
> >  > > 
> > 
> > We need a testcase where the name of the executable is changed, and
> > this code is exercised. Otherwise ok, except for this:
> 
> OK, I will add something along the line of reread.exp.
> 
> >  > > +/* Deduce the name of the main procedure, and set NAME_OF_MAIN
> >  > > +   accordingly.  */
> >  > > +
> >  > > +static void
> >  > > +find_main_name (void)
> >  > > +{
> >  > > +  char *new_main_name;
> >  > > +
> >  > > +  /* Try to see if the main procedure is in Ada.  */
> >  > > +  new_main_name = ada_main_name ();
> >  > > +  if (new_main_name != NULL)
> >  > > +    { 
> >  > > +      set_main_name (new_main_name);
> >  > > +      return;
> >  > > +    }
> >  > > +
> >  > > +  /* The languages above didn't identify the name of the main procedure.
> >  > > +     Fallback to "main".  */
> >  > > +  set_main_name ("main");
> >  > > +}
> >  > > +
> >  > >  char *
> >  > >  main_name (void)
> >  > >  {
> >  > > -  if (name_of_main != NULL)
> >  > > -    return name_of_main;
> >  > > -  else
> >  > > -    return "main";
> >  > > +  if (name_of_main == NULL)
> >  > > +    find_main_name ();
> >  > > +
> >  > > +  return name_of_main;
> >  > >  }
> >  > >  
> > 
> > Can this find_main_name become an element in the language vector? I
> > really don't want to have a special language cases in the symtab file.
> 
> This has actually been discussed already. There were several messages
> exchanged between Daniel and myself, but here are some important ones:
> 
>     http://sources.redhat.com/ml/gdb-patches/2004-05/msg00607.html
>     (one potential confusion if we use the *current* language vector
>     to determine the name of main. This is also where the suggestion
>     of calling the Ada routine directly was suggested.
> 
>     http://sources.redhat.com/ml/gdb-patches/2004-05/msg00612.html
>     (we agree that it's ok to call ada_main_name directly)
> 
> In short, the answer to the discussion was that this was probably the
> best approach for now. The reason why it can't be put in the language
> vector is that this is not a property of the language (which can vary
> within the same program, depending on the frame), but a property of
> the executable. None of us like this approach much, but it was something
> that we felt sucked the least.
> 
> If you want, what we can do is replace the hard-coded call to
> ada_main_name() by a loop of calls to a new language method,
> looping on all languages until we find a positive match. That
> way, the hard wiring to Ada disappears. But I don't think we're
> getting much from this extra slight complexity. 

-- 
Joel


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

* Re: [RFA] Improve "start" command for Ada
  2005-02-09 18:22           ` Joel Brobecker
@ 2005-03-07 19:30             ` Joel Brobecker
  2005-03-07 20:59               ` Elena Zannoni
  0 siblings, 1 reply; 13+ messages in thread
From: Joel Brobecker @ 2005-03-07 19:30 UTC (permalink / raw)
  To: Elena Zannoni; +Cc: gdb-patches

Hello Elena,

Do you think you would have some time to look at this? The review
process stalled more than 3 months ago, and it would be nice to get
the problem fixed. In the meantime, I will KFAIL the tests in gdb.ada
that rely on the "start" command.

Thanks,

On Wed, Feb 09, 2005 at 12:05:43PM -0500, Joel Brobecker wrote:
> Hello Elena,
> 
> There is one part of the patch that hasn't been approved yet. I tried
> to explain a bit the history of the code you were concerned with, and
> I was wondering what your thoughts were. Could you have a look? (way
> at the bottom of the message - I kept the rest to keep the entire
> context together).
> 
> Thanks,
> -- 
> Joel
> 
> > On Sun, Nov 28, 2004 at 09:08:21PM -0500, Elena Zannoni wrote:
> > > Joel Brobecker writes:
> > >  > Ping? (doco already approved by Eli)
> > >  > 
> > >  > On Thu, Oct 21, 2004 at 02:09:51PM -0700, Joel Brobecker wrote:
> > >  > > 2004-10-20  Joel Brobecker  <brobecker@gnat.com>
> > >  > > 
> > >  > >         * doc/observer.texi (executable_changed): New observer.
> > >  > >         * symtab.c: Include "observer.h".
> > >  > >         (find_main_name): New function.
> > >  > >         (main_name): If name_of_main is unset, then compute it
> > >  > >         using find_main_name.
> > >  > >         (symtab_observer_executable_changed): New function.
> > >  > >         (_initialize_symtab): Attach executable_changed observer.
> > >  > >         * exec.c: Include "observer.h".
> > >  > >         (exec_file_attach): Emit executable_changed notification.
> > >  > >         * symfile.c: Include "observer.h".
> > >  > >         (reread_symbols): Send an executable_changed if appropriate.
> > >  > >         * Makefile.in (exec.o): Add dependency on observer.h.
> > >  > >         (symfile.o): Likewise.
> > >  > >         (symtab.o): Likewise.
> > >  > > 
> > >  > > Tested on x86-linux. Still fixes 1 FAIL in gdb.ada/null_record.exp.
> > >  > > 
> > > 
> > > We need a testcase where the name of the executable is changed, and
> > > this code is exercised. Otherwise ok, except for this:
> > 
> > OK, I will add something along the line of reread.exp.
> > 
> > >  > > +/* Deduce the name of the main procedure, and set NAME_OF_MAIN
> > >  > > +   accordingly.  */
> > >  > > +
> > >  > > +static void
> > >  > > +find_main_name (void)
> > >  > > +{
> > >  > > +  char *new_main_name;
> > >  > > +
> > >  > > +  /* Try to see if the main procedure is in Ada.  */
> > >  > > +  new_main_name = ada_main_name ();
> > >  > > +  if (new_main_name != NULL)
> > >  > > +    { 
> > >  > > +      set_main_name (new_main_name);
> > >  > > +      return;
> > >  > > +    }
> > >  > > +
> > >  > > +  /* The languages above didn't identify the name of the main procedure.
> > >  > > +     Fallback to "main".  */
> > >  > > +  set_main_name ("main");
> > >  > > +}
> > >  > > +
> > >  > >  char *
> > >  > >  main_name (void)
> > >  > >  {
> > >  > > -  if (name_of_main != NULL)
> > >  > > -    return name_of_main;
> > >  > > -  else
> > >  > > -    return "main";
> > >  > > +  if (name_of_main == NULL)
> > >  > > +    find_main_name ();
> > >  > > +
> > >  > > +  return name_of_main;
> > >  > >  }
> > >  > >  
> > > 
> > > Can this find_main_name become an element in the language vector? I
> > > really don't want to have a special language cases in the symtab file.
> > 
> > This has actually been discussed already. There were several messages
> > exchanged between Daniel and myself, but here are some important ones:
> > 
> >     http://sources.redhat.com/ml/gdb-patches/2004-05/msg00607.html
> >     (one potential confusion if we use the *current* language vector
> >     to determine the name of main. This is also where the suggestion
> >     of calling the Ada routine directly was suggested.
> > 
> >     http://sources.redhat.com/ml/gdb-patches/2004-05/msg00612.html
> >     (we agree that it's ok to call ada_main_name directly)
> > 
> > In short, the answer to the discussion was that this was probably the
> > best approach for now. The reason why it can't be put in the language
> > vector is that this is not a property of the language (which can vary
> > within the same program, depending on the frame), but a property of
> > the executable. None of us like this approach much, but it was something
> > that we felt sucked the least.
> > 
> > If you want, what we can do is replace the hard-coded call to
> > ada_main_name() by a loop of calls to a new language method,
> > looping on all languages until we find a positive match. That
> > way, the hard wiring to Ada disappears. But I don't think we're
> > getting much from this extra slight complexity. 
> 
> -- 
> Joel

-- 
Joel


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

* Re: [RFA] Improve "start" command for Ada
  2005-03-07 19:30             ` Joel Brobecker
@ 2005-03-07 20:59               ` Elena Zannoni
  2005-03-07 21:12                 ` Joel Brobecker
  2005-03-08  4:40                 ` Joel Brobecker
  0 siblings, 2 replies; 13+ messages in thread
From: Elena Zannoni @ 2005-03-07 20:59 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: Elena Zannoni, gdb-patches

Joel Brobecker writes:
 > Hello Elena,
 > 
 > Do you think you would have some time to look at this? The review
 > process stalled more than 3 months ago, and it would be nice to get
 > the problem fixed. In the meantime, I will KFAIL the tests in gdb.ada
 > that rely on the "start" command.

It would be useful if you pointed to the last version of the patch to
look at. Is this the last one?
http://sources.redhat.com/ml/gdb-patches/2004-10/msg00365.html

If so, can you please add a comment about what could be done instead
of calling ada_main_name directly?
Something like what you wrote:

> > If you want, what we can do is replace the hard-coded call to
> > ada_main_name() by a loop of calls to a new language method,
> > looping on all languages until we find a positive match. That
> > way, the hard wiring to Ada disappears.

Otherwise ok


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

* Re: [RFA] Improve "start" command for Ada
  2005-03-07 20:59               ` Elena Zannoni
@ 2005-03-07 21:12                 ` Joel Brobecker
  2005-03-08  4:40                 ` Joel Brobecker
  1 sibling, 0 replies; 13+ messages in thread
From: Joel Brobecker @ 2005-03-07 21:12 UTC (permalink / raw)
  To: Elena Zannoni; +Cc: gdb-patches

Elena,

Thank you very much.

> It would be useful if you pointed to the last version of the patch to
> look at. Is this the last one?
> http://sources.redhat.com/ml/gdb-patches/2004-10/msg00365.html

That's correct. Sorry about not pointing at the latest patch, I should
have done that. Next time, don't hesitate to ask me to do the search
for you, I'll be more than happy to do so.

> If so, can you please add a comment about what could be done instead
> of calling ada_main_name directly?
> Something like what you wrote:

Sure, will add the comment and commit.

> > > If you want, what we can do is replace the hard-coded call to
> > > ada_main_name() by a loop of calls to a new language method,
> > > looping on all languages until we find a positive match. That
> > > way, the hard wiring to Ada disappears.
> 
> Otherwise ok

Thanks a lot!

-- 
Joel


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

* Re: [RFA] Improve "start" command for Ada
  2005-03-07 20:59               ` Elena Zannoni
  2005-03-07 21:12                 ` Joel Brobecker
@ 2005-03-08  4:40                 ` Joel Brobecker
  1 sibling, 0 replies; 13+ messages in thread
From: Joel Brobecker @ 2005-03-08  4:40 UTC (permalink / raw)
  To: Elena Zannoni; +Cc: gdb-patches

Just to confirm that I just checked in the following patch:

2005-03-07  Joel Brobecker  <brobecker@adacore.com>

        * doc/observer.texi (executable_changed): New observer.
        * symtab.c: Include "observer.h".
        (find_main_name): New function.
        (main_name): If name_of_main is unset, then compute it
        using find_main_name.
        (symtab_observer_executable_changed): New function.
        (_initialize_symtab): Attach executable_changed observer.
        * exec.c: Include "observer.h".
        (exec_file_attach): Emit executable_changed notification.
        * symfile.c: Include "observer.h".
        (reread_symbols): Send an executable_changed if appropriate.
        * Makefile.in (exec.o): Add dependency on observer.h.
        (symfile.o): Likewise.
        (symtab.o): Likewise.

This fixes the following 2 FAILs:

        FAIL: gdb.ada/null_record.exp: start (PRMS ada/1892)
        FAIL: gdb.ada/start.exp: start (PRMS ada/1892)

Here is the comment that I added:

  /* FIXME: brobecker/2005-03-07: Another way of doing this would
     be to add a new method in the language vector, and call this
     method for each language until one of them returns a non-empty
     name.  This would allow us to remove this hard-coded call to
     an Ada function.  It is not clear that this is a better approach
     at this point, because all methods need to be written in a way
     such that false positives never be returned. For instance, it is
     important that a method does not return a wrong name for the main
     procedure if the main procedure is actually written in a different
     language.  It is easy to guaranty this with Ada, since we use a
     special symbol generated only when the main in Ada to find the name
     of the main procedure. It is difficult however to see how this can
     be guarantied for languages such as C, for instance.  This suggests
     that order of call for these methods becomes important, which means
     a more complicated approach.  */

-- 
Joel


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

end of thread, other threads:[~2005-03-08  4:40 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-21  3:48 [RFA] Improve "start" command for Ada Joel Brobecker
2004-10-21  5:31 ` Eli Zaretskii
2004-10-21 21:09   ` Joel Brobecker
2004-10-23 10:05     ` Eli Zaretskii
2004-11-01 19:47     ` Joel Brobecker
2004-11-29  2:12       ` Elena Zannoni
2004-12-01  3:03         ` Joel Brobecker
2005-02-09 18:22           ` Joel Brobecker
2005-03-07 19:30             ` Joel Brobecker
2005-03-07 20:59               ` Elena Zannoni
2005-03-07 21:12                 ` Joel Brobecker
2005-03-08  4:40                 ` Joel Brobecker
2004-11-22 19:10     ` Joel Brobecker

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