write_pieced_value: Notify memory_changed observers
[deliverable/binutils-gdb.git] / gdb / auto-load.c
index 7da288ffe7905c171cb72119e2996c141374897f..37bf94286d3b3d6f4fef66c0241a60ef0ee83503 100644 (file)
@@ -1,6 +1,6 @@
 /* GDB routines for supporting auto-loaded scripts.
 
-   Copyright (C) 2012-2015 Free Software Foundation, Inc.
+   Copyright (C) 2012-2017 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -408,9 +408,9 @@ filename_is_in_pattern (const char *filename, const char *pattern)
 {
   char *filename_copy, *pattern_copy;
 
-  filename_copy = alloca (strlen (filename) + 1);
+  filename_copy = (char *) alloca (strlen (filename) + 1);
   strcpy (filename_copy, filename);
-  pattern_copy = alloca (strlen (pattern) + 1);
+  pattern_copy = (char *) alloca (strlen (pattern) + 1);
   strcpy (pattern_copy, pattern);
 
   return filename_is_in_pattern_1 (filename_copy, pattern_copy);
@@ -580,7 +580,7 @@ static const struct program_space_data *auto_load_pspace_data;
 static void
 auto_load_pspace_data_cleanup (struct program_space *pspace, void *arg)
 {
-  struct auto_load_pspace_info *info = arg;
+  struct auto_load_pspace_info *info = (struct auto_load_pspace_info *) arg;
 
   if (info->loaded_script_files)
     htab_delete (info->loaded_script_files);
@@ -597,7 +597,8 @@ get_auto_load_pspace_data (struct program_space *pspace)
 {
   struct auto_load_pspace_info *info;
 
-  info = program_space_data (pspace, auto_load_pspace_data);
+  info = ((struct auto_load_pspace_info *)
+         program_space_data (pspace, auto_load_pspace_data));
   if (info == NULL)
     {
       info = XCNEW (struct auto_load_pspace_info);
@@ -612,7 +613,7 @@ get_auto_load_pspace_data (struct program_space *pspace)
 static hashval_t
 hash_loaded_script_entry (const void *data)
 {
-  const struct loaded_script *e = data;
+  const struct loaded_script *e = (const struct loaded_script *) data;
 
   return htab_hash_string (e->name) ^ htab_hash_pointer (e->language);
 }
@@ -622,8 +623,8 @@ hash_loaded_script_entry (const void *data)
 static int
 eq_loaded_script_entry (const void *a, const void *b)
 {
-  const struct loaded_script *ea = a;
-  const struct loaded_script *eb = b;
+  const struct loaded_script *ea = (const struct loaded_script *) a;
+  const struct loaded_script *eb = (const struct loaded_script *) b;
 
   return strcmp (ea->name, eb->name) == 0 && ea->language == eb->language;
 }
@@ -693,9 +694,10 @@ maybe_add_script_file (struct auto_load_pspace_info *pspace_info, int loaded,
       char *p;
 
       /* Allocate all space in one chunk so it's easier to free.  */
-      *slot = xmalloc (sizeof (**slot)
-                      + strlen (name) + 1
-                      + (full_path != NULL ? (strlen (full_path) + 1) : 0));
+      *slot = ((struct loaded_script *)
+              xmalloc (sizeof (**slot)
+                       + strlen (name) + 1
+                       + (full_path != NULL ? (strlen (full_path) + 1) : 0)));
       p = ((char*) *slot) + sizeof (**slot);
       strcpy (p, name);
       (*slot)->name = p;
@@ -740,7 +742,8 @@ maybe_add_script_text (struct auto_load_pspace_info *pspace_info,
       char *p;
 
       /* Allocate all space in one chunk so it's easier to free.  */
-      *slot = xmalloc (sizeof (**slot) + strlen (name) + 1);
+      *slot = ((struct loaded_script *)
+              xmalloc (sizeof (**slot) + strlen (name) + 1));
       p = ((char*) *slot) + sizeof (**slot);
       strcpy (p, name);
       (*slot)->name = p;
@@ -760,7 +763,8 @@ clear_section_scripts (void)
   struct program_space *pspace = current_program_space;
   struct auto_load_pspace_info *info;
 
-  info = program_space_data (pspace, auto_load_pspace_data);
+  info = ((struct auto_load_pspace_info *)
+         program_space_data (pspace, auto_load_pspace_data));
   if (info != NULL && info->loaded_script_files != NULL)
     {
       htab_delete (info->loaded_script_files);
@@ -787,7 +791,7 @@ auto_load_objfile_script_1 (struct objfile *objfile, const char *realname,
   const char *suffix = ext_lang_auto_load_suffix (language);
 
   len = strlen (realname);
-  filename = xmalloc (len + strlen (suffix) + 1);
+  filename = (char *) xmalloc (len + strlen (suffix) + 1);
   memcpy (filename, realname, len);
   strcpy (filename + len, suffix);
 
@@ -818,7 +822,7 @@ auto_load_objfile_script_1 (struct objfile *objfile, const char *realname,
 
       for (ix = 0; VEC_iterate (char_ptr, vec, ix, dir); ++ix)
        {
-         debugfile = xmalloc (strlen (dir) + strlen (filename) + 1);
+         debugfile = (char *) xmalloc (strlen (dir) + strlen (filename) + 1);
          strcpy (debugfile, dir);
 
          /* FILENAME is absolute, so we don't need a "/" here.  */
@@ -1008,7 +1012,7 @@ execute_script_contents (struct auto_load_pspace_info *pspace_info,
 {
   objfile_script_executor_func *executor;
   const char *newline, *script_text;
-  char *name, *end;
+  char *name;
   int is_safe, in_hash_table;
   struct cleanup *cleanups;
 
@@ -1170,7 +1174,8 @@ auto_load_section_scripts (struct objfile *objfile, const char *section_name)
   bfd_byte *data = NULL;
 
   scripts_sect = bfd_get_section_by_name (abfd, section_name);
-  if (scripts_sect == NULL)
+  if (scripts_sect == NULL
+      || (bfd_get_section_flags (abfd, scripts_sect) & SEC_HAS_CONTENTS) == 0)
     return;
 
   if (!bfd_get_full_section_contents (abfd, scripts_sect, &data))
@@ -1247,8 +1252,9 @@ struct collect_matching_scripts_data
 static int
 collect_matching_scripts (void **slot, void *info)
 {
-  struct loaded_script *script = *slot;
-  struct collect_matching_scripts_data *data = info;
+  struct loaded_script *script = (struct loaded_script *) *slot;
+  struct collect_matching_scripts_data *data
+    = (struct collect_matching_scripts_data *) info;
 
   if (script->language == data->language && re_exec (script->name))
     VEC_safe_push (loaded_script_ptr, *data->scripts_p, script);
@@ -1262,24 +1268,21 @@ static void
 print_script (struct loaded_script *script)
 {
   struct ui_out *uiout = current_uiout;
-  struct cleanup *chain;
 
-  chain = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
+  ui_out_emit_tuple tuple_emitter (uiout, NULL);
 
-  ui_out_field_string (uiout, "loaded", script->loaded ? "Yes" : "No");
-  ui_out_field_string (uiout, "script", script->name);
-  ui_out_text (uiout, "\n");
+  uiout->field_string ("loaded", script->loaded ? "Yes" : "No");
+  uiout->field_string ("script", script->name);
+  uiout->text ("\n");
 
   /* If the name isn't the full path, print it too.  */
   if (script->full_path != NULL
       && strcmp (script->name, script->full_path) != 0)
     {
-      ui_out_text (uiout, "\tfull name: ");
-      ui_out_field_string (uiout, "full_path", script->full_path);
-      ui_out_text (uiout, "\n");
+      uiout->text ("\tfull name: ");
+      uiout->field_string ("full_path", script->full_path);
+      uiout->text ("\n");
     }
-
-  do_cleanups (chain);
 }
 
 /* Helper for info_auto_load_scripts to sort the scripts by name.  */
@@ -1304,7 +1307,6 @@ char auto_load_info_scripts_pattern_nl[] = "";
 static void
 print_scripts (VEC (loaded_script_ptr) *scripts)
 {
-  struct ui_out *uiout = current_uiout;
   int i;
   loaded_script_ptr script;
 
@@ -1378,15 +1380,15 @@ auto_load_info_scripts (char *pattern, int from_tty,
   /* Table header shifted right by preceding "gdb-scripts:  " would not match
      its columns.  */
   if (nr_scripts > 0 && pattern == auto_load_info_scripts_pattern_nl)
-    ui_out_text (uiout, "\n");
+    uiout->text ("\n");
 
   /* Note: This creates a cleanup to output the table end marker.  */
   make_cleanup_ui_out_table_begin_end (uiout, 2, nr_scripts,
                                       "AutoLoadedScriptsTable");
 
-  ui_out_table_header (uiout, 7, ui_left, "loaded", "Loaded");
-  ui_out_table_header (uiout, 70, ui_left, "script", "Script");
-  ui_out_table_body (uiout);
+  uiout->table_header (7, ui_left, "loaded", "Loaded");
+  uiout->table_header (70, ui_left, "script", "Script");
+  uiout->table_body ();
 
   print_scripts (script_files);
   print_scripts (script_texts);
@@ -1397,10 +1399,9 @@ auto_load_info_scripts (char *pattern, int from_tty,
   if (nr_scripts == 0)
     {
       if (pattern && *pattern)
-       ui_out_message (uiout, 0, "No auto-load scripts matching %s.\n",
-                       pattern);
+       uiout->message ("No auto-load scripts matching %s.\n", pattern);
       else
-       ui_out_message (uiout, 0, "No auto-load scripts.\n");
+       uiout->message ("No auto-load scripts.\n");
     }
 }
 
@@ -1557,26 +1558,19 @@ info_auto_load_cmd (char *args, int from_tty)
   struct cleanup *infolist_chain;
   struct ui_out *uiout = current_uiout;
 
-  infolist_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "infolist");
+  ui_out_emit_tuple tuple_emitter (uiout, "infolist");
 
   for (list = *auto_load_info_cmdlist_get (); list != NULL; list = list->next)
     {
-      struct cleanup *option_chain
-       = make_cleanup_ui_out_tuple_begin_end (uiout, "option");
+      ui_out_emit_tuple option_emitter (uiout, "option");
 
       gdb_assert (!list->prefixlist);
       gdb_assert (list->type == not_set_cmd);
 
-      ui_out_field_string (uiout, "name", list->name);
-      ui_out_text (uiout, ":  ");
+      uiout->field_string ("name", list->name);
+      uiout->text (":  ");
       cmd_func (list, auto_load_info_scripts_pattern_nl, from_tty);
-
-      /* Close the tuple.  */
-      do_cleanups (option_chain);
     }
-
-  /* Close the tuple.  */
-  do_cleanups (infolist_chain);
 }
 
 /* Initialize "info auto-load " commands prefix and return it.  */
This page took 0.027967 seconds and 4 git commands to generate.