2008-02-21 Pedro Alves <pedro@codesorcery.com>
[deliverable/binutils-gdb.git] / gdb / tui / tui-stack.c
index 0ee538988f42ae174842a342fa8f43082b4c4f94..ccc9b9ffdb2f4e5c4831247d051d0e71e7d1fb77 100644 (file)
@@ -1,7 +1,7 @@
 /* TUI display locator.
 
-   Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software
-   Foundation, Inc.
+   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2006, 2007, 2008,
+   2009 Free Software Foundation, Inc.
 
    Contributed by Hewlett-Packard Company.
 
@@ -9,7 +9,7 @@
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
@@ -18,9 +18,7 @@
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.  */
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
 #include "symtab.h"
 /* Get a printable name for the function at the address.
    The symbol name is demangled if demangling is turned on.
    Returns a pointer to a static area holding the result.  */
-static chartui_get_function_from_frame (struct frame_info *fi);
+static char *tui_get_function_from_frame (struct frame_info *fi);
 
 /* Set the filename portion of the locator.  */
 static void tui_set_locator_filename (const char *filename);
 
 /* Update the locator, with the provided arguments.  */
-static void tui_set_locator_info (const char *filename, const char *procname,
+static void tui_set_locator_info (const char *filename,
+                                 const char *procname,
                                   int lineno, CORE_ADDR addr);
 
 static void tui_update_command (char *, int);
 \f
 
-/* Create the status line to display as much information as we
-   can on this single line: target name, process number, current
-   function, current line, current PC, SingleKey mode.  */
+/* Create the status line to display as much information as we can on
+   this single line: target name, process number, current function,
+   current line, current PC, SingleKey mode.  */
 static char*
-tui_make_status_line (struct tui_locator_elementloc)
+tui_make_status_line (struct tui_locator_element *loc)
 {
-  charstring;
+  char *string;
   char line_buf[50], *pname;
-  charbuf;
+  char *buf;
   int status_size;
   int i, proc_width;
-  const charpid_name;
-  const charpc_buf;
+  const char *pid_name;
+  const char *pc_buf;
   int target_width;
   int pid_width;
   int line_width;
@@ -103,7 +102,7 @@ tui_make_status_line (struct tui_locator_element* loc)
 
   /* Translate PC address.  */
   pc_out = tui_sfileopen (128);
-  print_address_numeric (loc->addr, 1, pc_out);
+  fputs_filtered (paddress (loc->addr), pc_out);
   pc_buf = tui_file_get_strbuf (pc_out);
   pc_width = strlen (pc_buf);
   
@@ -145,13 +144,13 @@ tui_make_status_line (struct tui_locator_element* loc)
         }
     }
 
-  /* Now convert elements to string form */
+  /* Now convert elements to string form */
   pname = loc->proc_name;
 
-  /* Now create the locator line from the string version
-     of the elements.  We could use sprintf() here but
-     that wouldn't ensure that we don't overrun the size
-     of the allocated buffer.  strcat_to_buf() will.  */
+  /* Now create the locator line from the string version of the
+     elements.  We could use sprintf() here but that wouldn't ensure
+     that we don't overrun the size of the allocated buffer.
+     strcat_to_buf() will.  */
   *string = (char) 0;
 
   if (target_width > 0)
@@ -174,7 +173,7 @@ tui_make_status_line (struct tui_locator_element* loc)
       strcat_to_buf (string, status_size, " ");
     }
 
-  /* procedure/class name */
+  /* Procedure/class name.  */
   if (proc_width > 0)
     {
       if (strlen (pname) > proc_width)
@@ -207,9 +206,9 @@ tui_make_status_line (struct tui_locator_element* loc)
   return string;
 }
 
-/* Get a printable name for the function at the address.
-   The symbol name is demangled if demangling is turned on.
-   Returns a pointer to a static area holding the result.  */
+/* Get a printable name for the function at the address.  The symbol
+   name is demangled if demangling is turned on.  Returns a pointer to
+   a static area holding the result.  */
 static char*
 tui_get_function_from_frame (struct frame_info *fi)
 {
@@ -220,9 +219,9 @@ tui_get_function_from_frame (struct frame_info *fi)
   print_address_symbolic (get_frame_pc (fi), stream, demangle, "");
   p = tui_file_get_strbuf (stream);
 
-  /* Use simple heuristics to isolate the function name.  The symbol can
-     be demangled and we can have function parameters.  Remove them because
-     the status line is too short to display them.  */
+  /* Use simple heuristics to isolate the function name.  The symbol
+     can be demangled and we can have function parameters.  Remove
+     them because the status line is too short to display them.  */
   if (*p == '<')
     p++;
   strncpy (name, p, sizeof (name));
@@ -242,13 +241,13 @@ void
 tui_show_locator_content (void)
 {
   char *string;
-  struct tui_gen_win_info * locator;
+  struct tui_gen_win_info *locator;
 
   locator = tui_locator_win_info_ptr ();
 
   if (locator != NULL && locator->handle != (WINDOW *) NULL)
     {
-      struct tui_win_element * element;
+      struct tui_win_element *element;
 
       element = (struct tui_win_element *) locator->content[0];
 
@@ -270,8 +269,8 @@ tui_show_locator_content (void)
 static void
 tui_set_locator_filename (const char *filename)
 {
-  struct tui_gen_win_info * locator = tui_locator_win_info_ptr ();
-  struct tui_locator_element * element;
+  struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
+  struct tui_locator_element *element;
 
   if (locator->content[0] == NULL)
     {
@@ -286,11 +285,13 @@ tui_set_locator_filename (const char *filename)
 
 /* Update the locator, with the provided arguments.  */
 static void
-tui_set_locator_info (const char *filename, const char *procname, int lineno,
+tui_set_locator_info (const char *filename, 
+                     const char *procname, 
+                     int lineno,
                       CORE_ADDR addr)
 {
-  struct tui_gen_win_info * locator = tui_locator_win_info_ptr ();
-  struct tui_locator_element * element;
+  struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
+  struct tui_locator_element *element;
 
   /* Allocate the locator content if necessary.  */
   if (locator->content_size <= 0)
@@ -319,14 +320,14 @@ tui_update_locator_filename (const char *filename)
 void
 tui_show_frame_info (struct frame_info *fi)
 {
-  struct tui_win_info * win_info;
+  struct tui_win_info *win_info;
   int i;
 
   if (fi)
     {
       int start_line, i;
       CORE_ADDR low;
-      struct tui_gen_win_info * locator = tui_locator_win_info_ptr ();
+      struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
       int source_already_displayed;
       struct symtab_and_line sal;
 
@@ -343,7 +344,7 @@ tui_show_frame_info (struct frame_info *fi)
       for (i = 0; i < (tui_source_windows ())->count; i++)
        {
          union tui_which_element *item;
-         win_info = (struct tui_win_info *) (tui_source_windows ())->list[i];
+         win_info = (tui_source_windows ())->list[i];
 
          item = &((struct tui_win_element *) locator->content[0])->which_element;
          if (win_info == TUI_SRC_WIN)
@@ -356,22 +357,23 @@ tui_show_frame_info (struct frame_info *fi)
          else
            {
              if (find_pc_partial_function (get_frame_pc (fi), (char **) NULL,
-                                           &low, (CORE_ADDR) NULL) == 0)
-               error ("No function contains program counter for selected frame.\n");
+                                           &low, (CORE_ADDR) 0) == 0)
+               error (_("No function contains program counter for selected frame."));
              else
                low = tui_get_low_disassembly_address (low, get_frame_pc (fi));
            }
 
          if (win_info == TUI_SRC_WIN)
            {
-             union tui_line_or_address l;
-             l.line_no = start_line;
+             struct tui_line_or_address l;
+             l.loa = LOA_LINE;
+             l.u.line_no = start_line;
              if (!(source_already_displayed
                    && tui_line_is_displayed (item->locator.line_no, win_info, TRUE)))
                tui_update_source_window (win_info, sal.symtab, l, TRUE);
              else
                {
-                 l.line_no = item->locator.line_no;
+                 l.u.line_no = item->locator.line_no;
                  tui_set_is_exec_point_at (l, win_info);
                }
            }
@@ -379,13 +381,14 @@ tui_show_frame_info (struct frame_info *fi)
            {
              if (win_info == TUI_DISASM_WIN)
                {
-                 union tui_line_or_address a;
-                 a.addr = low;
+                 struct tui_line_or_address a;
+                 a.loa = LOA_ADDRESS;
+                 a.u.addr = low;
                  if (!tui_addr_is_displayed (item->locator.addr, win_info, TRUE))
                    tui_update_source_window (win_info, sal.symtab, a, TRUE);
                  else
                    {
-                     a.addr = item->locator.addr;
+                     a.u.addr = item->locator.addr;
                      tui_set_is_exec_point_at (a, win_info);
                    }
                }
@@ -399,7 +402,7 @@ tui_show_frame_info (struct frame_info *fi)
       tui_show_locator_content ();
       for (i = 0; i < (tui_source_windows ())->count; i++)
        {
-         win_info = (struct tui_win_info *) (tui_source_windows ())->list[i];
+         win_info = (tui_source_windows ())->list[i];
          tui_clear_source_content (win_info, EMPTY_SOURCE_PROMPT);
          tui_update_exec_info (win_info);
        }
@@ -408,12 +411,15 @@ 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");
+  add_com ("update", class_tui, tui_update_command, _("\
+Update the source window and locator to display the current execution point.\n"));
 }
 
 /* Command to update the display with the current execution point.  */
This page took 0.030287 seconds and 4 git commands to generate.