Use gdb::byte_vector in load_progress
[deliverable/binutils-gdb.git] / gdb / event-top.c
index 1281df89225d80ee50643f7ce4531a99ad4609bc..54fe471f2c03686c0680ce35a25550b5313e266d 100644 (file)
@@ -48,7 +48,7 @@
 /* readline defines this.  */
 #undef savestring
 
-static char *top_level_prompt (void);
+static std::string top_level_prompt ();
 
 /* Signal handlers.  */
 #ifdef SIGQUIT
@@ -352,16 +352,13 @@ gdb_rl_callback_handler_reinstall (void)
 void
 display_gdb_prompt (const char *new_prompt)
 {
-  char *actual_gdb_prompt = NULL;
-  struct cleanup *old_chain;
+  std::string actual_gdb_prompt;
 
   annotate_display_prompt ();
 
   /* Reset the nesting depth used when trace-commands is set.  */
   reset_command_nest_depth ();
 
-  old_chain = make_cleanup (free_current_contents, &actual_gdb_prompt);
-
   /* Do not call the python hook on an explicit prompt change as
      passed to this function, as this forms a secondary/local prompt,
      IE, displayed but not set.  */
@@ -391,7 +388,6 @@ display_gdb_prompt (const char *new_prompt)
 
          if (current_ui->command_editing)
            gdb_rl_callback_handler_remove ();
-         do_cleanups (old_chain);
          return;
        }
       else if (ui->prompt_state == PROMPT_NEEDED)
@@ -402,12 +398,12 @@ display_gdb_prompt (const char *new_prompt)
        }
     }
   else
-    actual_gdb_prompt = xstrdup (new_prompt);
+    actual_gdb_prompt = new_prompt;
 
   if (current_ui->command_editing)
     {
       gdb_rl_callback_handler_remove ();
-      gdb_rl_callback_handler_install (actual_gdb_prompt);
+      gdb_rl_callback_handler_install (actual_gdb_prompt.c_str ());
     }
   /* new_prompt at this point can be the top of the stack or the one
      passed in.  It can't be NULL.  */
@@ -416,19 +412,16 @@ display_gdb_prompt (const char *new_prompt)
       /* Don't use a _filtered function here.  It causes the assumed
          character position to be off, since the newline we read from
          the user is not accounted for.  */
-      fputs_unfiltered (actual_gdb_prompt, gdb_stdout);
+      fputs_unfiltered (actual_gdb_prompt.c_str (), gdb_stdout);
       gdb_flush (gdb_stdout);
     }
-
-  do_cleanups (old_chain);
 }
 
 /* Return the top level prompt, as specified by "set prompt", possibly
    overriden by the python gdb.prompt_hook hook, and then composed
-   with the prompt prefix and suffix (annotations).  The caller is
-   responsible for freeing the returned string.  */
+   with the prompt prefix and suffix (annotations).  */
 
-static char *
+static std::string
 top_level_prompt (void)
 {
   char *prompt;
@@ -448,10 +441,10 @@ top_level_prompt (void)
         beginning.  */
       const char suffix[] = "\n\032\032prompt\n";
 
-      return concat (prefix, prompt, suffix, (char *) NULL);
+      return std::string (prefix) + prompt + suffix;
     }
 
-  return xstrdup (prompt);
+  return prompt;
 }
 
 /* See top.h.  */
@@ -548,7 +541,7 @@ async_enable_stdin (void)
 
   if (ui->prompt_state == PROMPT_BLOCKED)
     {
-      target_terminal_ours ();
+      target_terminal::ours ();
       ui_register_input_event_handler (ui);
       ui->prompt_state = PROMPT_NEEDED;
     }
@@ -957,7 +950,7 @@ default_quit_handler (void)
 {
   if (check_quit_flag ())
     {
-      if (target_terminal_is_ours ())
+      if (target_terminal::is_ours ())
        quit ();
       else
        target_pass_ctrlc ();
@@ -967,51 +960,6 @@ default_quit_handler (void)
 /* See defs.h.  */
 quit_handler_ftype *quit_handler = default_quit_handler;
 
-/* Data for make_cleanup_override_quit_handler.  Wrap the previous
-   handler pointer in a data struct because it's not portable to cast
-   a function pointer to a data pointer, which is what make_cleanup
-   expects.  */
-struct quit_handler_cleanup_data
-{
-  /* The previous quit handler.  */
-  quit_handler_ftype *prev_handler;
-};
-
-/* Cleanup call that restores the previous quit handler.  */
-
-static void
-restore_quit_handler (void *arg)
-{
-  struct quit_handler_cleanup_data *data
-    = (struct quit_handler_cleanup_data *) arg;
-
-  quit_handler = data->prev_handler;
-}
-
-/* Destructor for the quit handler cleanup.  */
-
-static void
-restore_quit_handler_dtor (void *arg)
-{
-  xfree (arg);
-}
-
-/* See defs.h.  */
-
-struct cleanup *
-make_cleanup_override_quit_handler (quit_handler_ftype *new_quit_handler)
-{
-  struct cleanup *old_chain;
-  struct quit_handler_cleanup_data *data;
-
-  data = XNEW (struct quit_handler_cleanup_data);
-  data->prev_handler = quit_handler;
-  old_chain = make_cleanup_dtor (restore_quit_handler, data,
-                                restore_quit_handler_dtor);
-  quit_handler = new_quit_handler;
-  return old_chain;
-}
-
 /* Handle a SIGINT.  */
 
 void
This page took 0.029096 seconds and 4 git commands to generate.