This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[commit/Ada] Make the exception_support_info data per inferior.


Hello,

This is something that entered my radar while I was cleanup exception
catchpoint support. I noticed that we were saving the exception data in
the same static global for all inferiors, which is wrong. Each inferior
might be different, and thus this patch makes this data per-inferior.

gdb/ChangeLog:

        * ada-lang.c (struct ada_inferior_data) [exception_info]:
        New field.
        (exception_info): Delete.
        (ada_exception_support_info_sniffer): Get exception_support_info
        data from our per-inferior data.  Adjust code accordingly.
        (ada_unhandled_exception_name_addr_from_raise): Likewise.
        (ada_exception_name_addr_1, ada_exception_sym_name): Ditto.
        (ada_executable_changed_observer): Delete.
        (_initialize_ada_language): Remove call to
        observer_attach_executable_changed.

Tested on x86_64-linux. Checked in.

---
 gdb/ChangeLog  |   13 +++++++++++++
 gdb/ada-lang.c |   52 ++++++++++++++++++++++------------------------------
 2 files changed, 35 insertions(+), 30 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 31397e0..9089e21 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,18 @@
 2011-12-11  Joel Brobecker  <brobecker@adacore.com>
 
+	* ada-lang.c (struct ada_inferior_data) [exception_info]:
+	New field.
+	(exception_info): Delete.
+	(ada_exception_support_info_sniffer): Get exception_support_info
+	data from our per-inferior data.  Adjust code accordingly.
+	(ada_unhandled_exception_name_addr_from_raise): Likewise.
+	(ada_exception_name_addr_1, ada_exception_sym_name): Ditto.
+	(ada_executable_changed_observer): Delete.
+	(_initialize_ada_language): Remove call to
+	observer_attach_executable_changed.
+
+2011-12-11  Joel Brobecker  <brobecker@adacore.com>
+
 	* ada-lang.c (ada_has_this_exception_support): Raise an error
 	if we could find the Ada exception hook in the Ada runtime,
 	but no debugging info for that hook.
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index b3c0a24..ff43ca4 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -318,6 +318,11 @@ struct ada_inferior_data
      accessible through a component ("tsd") in the object tag.  But this
      is no longer the case, so we cache it for each inferior.  */
   struct type *tsd_type;
+
+  /* The exception_support_info data.  This data is used to determine
+     how to implement support for Ada exception catchpoints in a given
+     inferior.  */
+  const struct exception_support_info *exception_info;
 };
 
 /* Our key to this module's inferior data.  */
@@ -10698,36 +10703,33 @@ ada_has_this_exception_support (const struct exception_support_info *einfo)
   return 1;
 }
 
-/* For each executable, we sniff which exception info structure to use
-   and cache it in the following global variable.  */
-
-static const struct exception_support_info *exception_info = NULL;
-
 /* Inspect the Ada runtime and determine which exception info structure
    should be used to provide support for exception catchpoints.
 
-   This function will always set exception_info, or raise an error.  */
+   This function will always set the per-inferior exception_info,
+   or raise an error.  */
 
 static void
 ada_exception_support_info_sniffer (void)
 {
+  struct ada_inferior_data *data = get_ada_inferior_data (current_inferior ());
   struct symbol *sym;
 
   /* If the exception info is already known, then no need to recompute it.  */
-  if (exception_info != NULL)
+  if (data->exception_info != NULL)
     return;
 
   /* Check the latest (default) exception support info.  */
   if (ada_has_this_exception_support (&default_exception_support_info))
     {
-      exception_info = &default_exception_support_info;
+      data->exception_info = &default_exception_support_info;
       return;
     }
 
   /* Try our fallback exception suport info.  */
   if (ada_has_this_exception_support (&exception_support_info_fallback))
     {
-      exception_info = &exception_support_info_fallback;
+      data->exception_info = &exception_support_info_fallback;
       return;
     }
 
@@ -10758,19 +10760,6 @@ ada_exception_support_info_sniffer (void)
   error (_("Cannot insert catchpoints in this configuration."));
 }
 
-/* An observer of "executable_changed" events.
-   Its role is to clear certain cached values that need to be recomputed
-   each time a new executable is loaded by GDB.  */
-
-static void
-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
-     cache.  */
-  exception_info = NULL;
-}
-
 /* True iff FRAME is very likely to be that of a function that is
    part of the runtime system.  This is all very heuristic, but is
    intended to be used as advice as to what frames are uninteresting
@@ -10870,6 +10859,7 @@ ada_unhandled_exception_name_addr_from_raise (void)
 {
   int frame_level;
   struct frame_info *fi;
+  struct ada_inferior_data *data = get_ada_inferior_data (current_inferior ());
 
   /* To determine the name of this exception, we need to select
      the frame corresponding to RAISE_SYM_NAME.  This frame is
@@ -10887,7 +10877,7 @@ ada_unhandled_exception_name_addr_from_raise (void)
 
       find_frame_funname (fi, &func_name, &func_lang, NULL);
       if (func_name != NULL
-          && strcmp (func_name, exception_info->catch_exception_sym) == 0)
+          && strcmp (func_name, data->exception_info->catch_exception_sym) == 0)
         break; /* We found the frame we were looking for...  */
       fi = get_prev_frame (fi);
     }
@@ -10909,6 +10899,8 @@ static CORE_ADDR
 ada_exception_name_addr_1 (enum exception_catchpoint_kind ex,
                            struct breakpoint *b)
 {
+  struct ada_inferior_data *data = get_ada_inferior_data (current_inferior ());
+
   switch (ex)
     {
       case ex_catch_exception:
@@ -10916,7 +10908,7 @@ ada_exception_name_addr_1 (enum exception_catchpoint_kind ex,
         break;
 
       case ex_catch_exception_unhandled:
-        return exception_info->unhandled_exception_name_addr ();
+        return data->exception_info->unhandled_exception_name_addr ();
         break;
       
       case ex_catch_assert:
@@ -11638,18 +11630,20 @@ catch_ada_exception_command_split (char *args,
 static const char *
 ada_exception_sym_name (enum exception_catchpoint_kind ex)
 {
-  gdb_assert (exception_info != NULL);
+  struct ada_inferior_data *data = get_ada_inferior_data (current_inferior ());
+
+  gdb_assert (data->exception_info != NULL);
 
   switch (ex)
     {
       case ex_catch_exception:
-        return (exception_info->catch_exception_sym);
+        return (data->exception_info->catch_exception_sym);
         break;
       case ex_catch_exception_unhandled:
-        return (exception_info->catch_exception_unhandled_sym);
+        return (data->exception_info->catch_exception_unhandled_sym);
         break;
       case ex_catch_assert:
-        return (exception_info->catch_assert_sym);
+        return (data->exception_info->catch_assert_sym);
         break;
       default:
         internal_error (__FILE__, __LINE__,
@@ -12538,8 +12532,6 @@ With an argument, catch only exceptions with the given name."),
     (256, htab_hash_string, (int (*)(const void *, const void *)) streq,
      NULL, xcalloc, xfree);
 
-  observer_attach_executable_changed (ada_executable_changed_observer);
-
   /* Setup per-inferior data.  */
   observer_attach_inferior_exit (ada_inferior_exit);
   ada_inferior_data
-- 
1.7.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]