• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

Révision8de00631b8bd1c328f1916b1fd95bd0d9ff2017e (tree)
l'heure2016-11-09 00:26:43
AuteurPedro Alves <palves@redh...>
CommiterPedro Alves

Message de Log

Introduce ui_file_as_string

ui_file_as_string is a variant of ui_file_xstrdup that returns a
std::string instead of a xmalloc'ed char *. The idea is using the new
function to eliminate "make_cleanup (xfree, ...)" cleanups
throughout.

Following patches will make use of this.

gdb/ChangeLog:
2016-11-08 Pedro Alves <palves@redhat.com>

* ui-file.c (do_ui_file_as_string, ui_file_as_string): New
functions.
* ui-file.h: Include <string>.
(ui_file_as_string): New declaration.

Change Summary

Modification

--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,12 @@
11 2016-11-08 Pedro Alves <palves@redhat.com>
22
3+ * ui-file.c (do_ui_file_as_string, ui_file_as_string): New
4+ functions.
5+ * ui-file.h: Include <string>.
6+ (ui_file_as_string): New declaration.
7+
8+2016-11-08 Pedro Alves <palves@redhat.com>
9+
310 * ada-lang.c (ada_read_renaming_var_value): Use expression_up.
411 (struct ada_catchpoint_location) <excep_cond_expr>: Now an
512 expression_up.
--- a/gdb/ui-file.c
+++ b/gdb/ui-file.c
@@ -356,6 +356,28 @@ ui_file_xstrdup (struct ui_file *file, long *length)
356356 return acc.buffer;
357357 }
358358
359+/* ui_file utility function for converting a ``struct ui_file'' into a
360+ std:string. */
361+
362+static void
363+do_ui_file_as_string (void *context, const char *buffer, long length)
364+{
365+ std::string *str = (std::string *) context;
366+
367+ *str = std::string (buffer, length);
368+}
369+
370+/* See ui-file.h. */
371+
372+std::string
373+ui_file_as_string (struct ui_file *file)
374+{
375+ std::string str;
376+
377+ ui_file_put (file, do_ui_file_as_string, &str);
378+ return str;
379+}
380+
359381 static void
360382 do_ui_file_obsavestring (void *context, const char *buffer, long length)
361383 {
--- a/gdb/ui-file.h
+++ b/gdb/ui-file.h
@@ -22,6 +22,8 @@
2222 struct obstack;
2323 struct ui_file;
2424
25+#include <string>
26+
2527 /* Create a generic ui_file object with null methods. */
2628
2729 extern struct ui_file *ui_file_new (void);
@@ -117,6 +119,10 @@ extern void ui_file_put (struct ui_file *src,
117119 minus that appended NUL. */
118120 extern char *ui_file_xstrdup (struct ui_file *file, long *length);
119121
122+/* Returns a std::string containing the entire contents of FILE (as
123+ determined by ui_file_put()). */
124+extern std::string ui_file_as_string (struct ui_file *file);
125+
120126 /* Similar to ui_file_xstrdup, but return a new string allocated on
121127 OBSTACK. */
122128 extern char *ui_file_obsavestring (struct ui_file *file,