Don't cast a tui_win_info directly to tui_gen_win_info
[deliverable/binutils-gdb.git] / gdb / tui / tui-stack.c
index 21a8bacebace1997e86915fc61de7a925acc836e..b7e7ae81dff2368c8ebce13d140dc995d63c34a2 100644 (file)
@@ -1,6 +1,6 @@
 /* TUI display locator.
 
-   Copyright (C) 1998-2017 Free Software Foundation, Inc.
+   Copyright (C) 1998-2019 Free Software Foundation, Inc.
 
    Contributed by Hewlett-Packard Company.
 
@@ -53,7 +53,7 @@ static int tui_set_locator_info (struct gdbarch *gdbarch,
                                 const char *procname,
                                  int lineno, CORE_ADDR addr);
 
-static void tui_update_command (char *, int);
+static void tui_update_command (const char *, int);
 \f
 
 /* Create the status line to display as much information as we can on
@@ -72,10 +72,14 @@ tui_make_status_line (struct tui_locator_element *loc)
   int pid_width;
   int line_width;
 
-  if (ptid_equal (inferior_ptid, null_ptid))
+  std::string pid_name_holder;
+  if (inferior_ptid == null_ptid)
     pid_name = "No process";
   else
-    pid_name = target_pid_to_str (inferior_ptid);
+    {
+      pid_name_holder = target_pid_to_str (inferior_ptid);
+      pid_name = pid_name_holder.c_str ();
+    }
 
   target_width = strlen (target_shortname);
   if (target_width > MAX_TARGET_WIDTH)
@@ -246,7 +250,7 @@ tui_show_locator_content (void)
 
   locator = tui_locator_win_info_ptr ();
 
-  if (locator != NULL && locator->handle != (WINDOW *) NULL)
+  if (locator != NULL && locator->handle != NULL)
     {
       struct tui_win_element *element;
 
@@ -358,7 +362,6 @@ tui_show_frame_info (struct frame_info *fi)
 {
   struct tui_win_info *win_info;
   int locator_changed_p;
-  int i;
 
   if (fi)
     {
@@ -366,10 +369,9 @@ tui_show_frame_info (struct frame_info *fi)
       CORE_ADDR low;
       struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
       int source_already_displayed;
-      struct symtab_and_line sal;
       CORE_ADDR pc;
 
-      find_frame_sal (fi, &sal);
+      symtab_and_line sal = find_frame_sal (fi);
 
       source_already_displayed = sal.symtab != 0
         && tui_source_is_displayed (symtab_to_fullname (sal.symtab));
@@ -412,8 +414,7 @@ tui_show_frame_info (struct frame_info *fi)
          else
            {
              if (find_pc_partial_function (get_frame_pc (fi),
-                                           (const char **) NULL,
-                                           &low, NULL) == 0)
+                                           NULL, &low, NULL) == 0)
                {
                  /* There is no symbol available for current PC.  There is no
                     safe way how to "disassemble backwards".  */
@@ -474,7 +475,7 @@ tui_show_frame_info (struct frame_info *fi)
        return 0;
 
       tui_show_locator_content ();
-      for (i = 0; i < (tui_source_windows ())->count; i++)
+      for (int i = 0; i < (tui_source_windows ())->count; i++)
        {
          win_info = (tui_source_windows ())->list[i];
          tui_clear_source_content (win_info, EMPTY_SOURCE_PROMPT);
@@ -488,23 +489,17 @@ tui_show_frame_info (struct frame_info *fi)
 /* Function to initialize gdb commands, for tui window stack
    manipulation.  */
 
-/* Provide a prototype to silence -Wmissing-prototypes.  */
-extern initialize_file_ftype _initialize_tui_stack;
-
 void
 _initialize_tui_stack (void)
 {
   add_com ("update", class_tui, tui_update_command,
           _("Update the source window and locator to "
-            "display the current execution point.\n"));
+            "display the current execution point."));
 }
 
 /* Command to update the display with the current execution point.  */
 static void
-tui_update_command (char *arg, int from_tty)
+tui_update_command (const char *arg, int from_tty)
 {
-  char cmd[sizeof("frame 0")];
-
-  strcpy (cmd, "frame 0");
-  execute_command (cmd, from_tty);
+  execute_command ("frame 0", from_tty);
 }
This page took 0.025507 seconds and 4 git commands to generate.