PR tui/9217
[deliverable/binutils-gdb.git] / gdb / ui-out.c
index 98c81739144ab9d35ac91ad02514ee76d2c5af53..c79e54ee2b2587e8d910db09fdd5658925b194ae 100644 (file)
@@ -1,6 +1,6 @@
 /* Output generating routines for GDB.
 
-   Copyright (C) 1999, 2000, 2001, 2002, 2004, 2005
+   Copyright (C) 1999, 2000, 2001, 2002, 2004, 2005, 2007, 2008, 2009, 2010
    Free Software Foundation, Inc.
 
    Contributed by Cygnus Solutions.
@@ -10,7 +10,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,
@@ -19,9 +19,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., 51 Franklin Street, Fifth Floor,
-   Boston, MA 02110-1301, USA.  */
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
 #include "gdb_string.h"
@@ -46,7 +44,7 @@ struct ui_out_hdr
    is always available.  Stack/nested level 0 is reserved for the
    top-level result. */
 
-enum { MAX_UI_OUT_LEVELS = 6 };
+enum { MAX_UI_OUT_LEVELS = 8 };
 
 struct ui_out_level
   {
@@ -102,7 +100,7 @@ struct ui_out
     int flags;
     /* specific implementation of ui-out */
     struct ui_out_impl *impl;
-    struct ui_out_data *data;
+    void *data;
 
     /* Sub structure tracking the ui-out depth.  */
     int level;
@@ -244,9 +242,6 @@ static void uo_field_int (struct ui_out *uiout, int fldno, int width,
                          enum ui_align align, const char *fldname, int value);
 static void uo_field_skip (struct ui_out *uiout, int fldno, int width,
                           enum ui_align align, const char *fldname);
-static void uo_field_string (struct ui_out *uiout, int fldno, int width,
-                            enum ui_align align, const char *fldname,
-                            const char *string);
 static void uo_field_fmt (struct ui_out *uiout, int fldno, int width,
                          enum ui_align align, const char *fldname,
                          const char *format, va_list args)
@@ -490,15 +485,19 @@ ui_out_field_fmt_int (struct ui_out *uiout,
 void
 ui_out_field_core_addr (struct ui_out *uiout,
                        const char *fldname,
+                       struct gdbarch *gdbarch,
                        CORE_ADDR address)
 {
   char addstr[20];
+  int addr_bit = gdbarch_addr_bit (gdbarch);
+
+  if (addr_bit < (sizeof (CORE_ADDR) * HOST_CHAR_BIT))
+    address &= ((CORE_ADDR) 1 << addr_bit) - 1;
 
   /* FIXME: cagney/2002-05-03: Need local_address_string() function
      that returns the language localized string formatted to a width
-     based on TARGET_ADDR_BIT.  */
-  /* deprecated_print_address_numeric (address, 1, local_stream); */
-  if (TARGET_ADDR_BIT <= 32)
+     based on gdbarch_addr_bit.  */
+  if (addr_bit <= 32)
     strcpy (addstr, hex_string_custom (address, 8));
   else
     strcpy (addstr, hex_string_custom (address, 16));
@@ -1031,15 +1030,20 @@ append_header_to_list (struct ui_out *uiout,
   temphdr = XMALLOC (struct ui_out_hdr);
   temphdr->width = width;
   temphdr->alignment = alignment;
-  /* we have to copy the column title as the original may be an automatic */
+  /* We have to copy the column title as the original may be an
+     automatic.  */
   if (colhdr != NULL)
     temphdr->colhdr = xstrdup (colhdr);
   else
     temphdr->colhdr = NULL;
+
   if (col_name != NULL)
+    temphdr->col_name = xstrdup (col_name);
+  else if (colhdr != NULL)
     temphdr->col_name = xstrdup (colhdr);
   else
-    temphdr->col_name = xstrdup (colhdr);
+    temphdr->col_name = NULL;
+
   temphdr->next = NULL;
   if (uiout->table.header_first == NULL)
     {
@@ -1130,7 +1134,7 @@ ui_out_get_field_separator (struct ui_out *uiout)
 
 /* Access to ui-out members data */
 
-struct ui_out_data *
+void *
 ui_out_data (struct ui_out *uiout)
 {
   return uiout->data;
@@ -1139,8 +1143,7 @@ ui_out_data (struct ui_out *uiout)
 /* initalize private members at startup */
 
 struct ui_out *
-ui_out_new (struct ui_out_impl *impl,
-           struct ui_out_data *data,
+ui_out_new (struct ui_out_impl *impl, void *data,
            int flags)
 {
   struct ui_out *uiout = XMALLOC (struct ui_out);
This page took 0.038458 seconds and 4 git commands to generate.