Fix regression: cannot start with LD_PRELOAD=libSegFault.so (PR gdb/18653#c7)
[deliverable/binutils-gdb.git] / gdb / common / format.h
index f3a94b8bbb6c06b2000fe622b90936c881b2578a..1745517518bb5786ccc31cdb80f6136748882fd0 100644 (file)
@@ -1,6 +1,6 @@
 /* Parse a printf-style format string.
 
-   Copyright (C) 1986-2017 Free Software Foundation, Inc.
+   Copyright (C) 1986-2018 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -48,22 +48,46 @@ enum argclass
 
 struct format_piece
 {
-  char *string;
+  format_piece (const char *str, enum argclass argc)
+    : string (str),
+      argclass (argc)
+  {
+  }
+
+  const char *string;
   enum argclass argclass;
 };
 
-/* Return an array of printf fragments found at the given string, and
-   rewrite ARG with a pointer to the end of the format string.  */
+class format_pieces
+{
+public:
+
+  format_pieces (const char **arg);
+  ~format_pieces () = default;
+
+  DISABLE_COPY_AND_ASSIGN (format_pieces);
 
-extern struct format_piece *parse_format_string (const char **arg);
+  format_piece &operator[] (size_t index)
+  {
+    return m_pieces[index];
+  }
 
-/* Given a pointer to an array of format pieces, free any memory that
-   would have been allocated by parse_format_string.  */
+  typedef std::vector<format_piece>::iterator iterator;
 
-extern void free_format_pieces (struct format_piece *frags);
+  iterator begin ()
+  {
+    return m_pieces.begin ();
+  }
 
-/* Freeing, cast as a cleanup.  */
+  iterator end ()
+  {
+    return m_pieces.end ();
+  }
 
-extern void free_format_pieces_cleanup (void *);
+private:
+
+  std::vector<format_piece> m_pieces;
+  gdb::unique_xmalloc_ptr<char> m_storage;
+};
 
 #endif /* COMMON_FORMAT_H */
This page took 0.025075 seconds and 4 git commands to generate.