Use malloc/free in the dbgapi callbacks
[deliverable/binutils-gdb.git] / gdb / ui-out.c
index 8cbaa4e0bc19a42010544cf2a3b2cdbf1b0ea9f2..4ecb65630b8bd33153eaed2bf5c2cadf506a685a 100644 (file)
@@ -1,6 +1,6 @@
 /* Output generating routines for GDB.
 
-   Copyright (C) 1999-2019 Free Software Foundation, Inc.
+   Copyright (C) 1999-2020 Free Software Foundation, Inc.
 
    Contributed by Cygnus Solutions.
    Written by Fernando Nasser for Cygnus.
@@ -26,6 +26,7 @@
 #include "ui-out.h"
 #include "gdbsupport/format.h"
 #include "cli/cli-style.h"
+#include "diagnostics.h"
 
 #include <vector>
 #include <memory>
@@ -545,7 +546,25 @@ ui_out::field_fmt (const char *fldname, const char *format, ...)
 
   va_start (args, format);
 
-  do_field_fmt (fldno, width, align, fldname, format, args);
+  do_field_fmt (fldno, width, align, fldname, ui_file_style (), format, args);
+
+  va_end (args);
+}
+
+void
+ui_out::field_fmt (const char *fldname, const ui_file_style &style,
+                  const char *format, ...)
+{
+  va_list args;
+  int fldno;
+  int width;
+  ui_align align;
+
+  verify_field (&fldno, &width, &align);
+
+  va_start (args, format);
+
+  do_field_fmt (fldno, width, align, fldname, style, format, args);
 
   va_end (args);
 }
@@ -569,7 +588,15 @@ ui_out::call_do_message (const ui_file_style &style, const char *format,
   va_list args;
 
   va_start (args, format);
+
+  /* Since call_do_message is only used as a helper of vmessage, silence the
+     warning here once instead of at all call sites in vmessage, if we were
+     to put a "format" attribute on call_do_message.  */
+  DIAGNOSTIC_PUSH
+  DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL
   do_message (style, format, args);
+  DIAGNOSTIC_POP
+
   va_end (args);
 }
 
@@ -661,6 +688,24 @@ ui_out::vmessage (const ui_file_style &in_style, const char *format,
              }
          }
          break;
+       case size_t_arg:
+         {
+           size_t val = va_arg (args, size_t);
+           switch (piece.n_int_args)
+             {
+             case 0:
+               call_do_message (style, current_substring, val);
+               break;
+             case 1:
+               call_do_message (style, current_substring, intvals[0], val);
+               break;
+             case 2:
+               call_do_message (style, current_substring,
+                                intvals[0], intvals[1], val);
+               break;
+             }
+         }
+         break;
        case double_arg:
          call_do_message (style, current_substring, va_arg (args, double));
          break;
@@ -685,13 +730,13 @@ ui_out::vmessage (const ui_file_style &in_style, const char *format,
                base_field_s *bf = va_arg (args, base_field_s *);
                switch (bf->kind)
                  {
-                 case field_kind::SIGNED:
+                 case field_kind::FIELD_SIGNED:
                    {
                      auto *f = (signed_field_s *) bf;
                      field_signed (f->name, f->val);
                    }
                    break;
-                 case field_kind::STRING:
+                 case field_kind::FIELD_STRING:
                    {
                      auto *f = (string_field_s *) bf;
                      field_string (f->name, f->str);
This page took 0.024171 seconds and 4 git commands to generate.