summaryrefslogtreecommitdiff
path: root/gdb/arm-tdep.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2016-10-28 23:08:08 +0100
committerPedro Alves <palves@redhat.com>2016-11-17 03:10:00 +0000
commit3d4ed53ca597f71c72ff0db995468578482a0ee0 (patch)
tree23c91cebc43c07ae98f0a494642734aa8abc83f5 /gdb/arm-tdep.c
parent05c10af4c15d9501046f6740cdf1173fbd9c3a2e (diff)
downloadbinutils-gdb-3d4ed53ca597f71c72ff0db995468578482a0ee0.tar.gz
Eliminate make_cleanup_ui_file_deleteusers/palves/cxx-eliminate-cleanups
And now that ui_file_as_string is in, let's eliminate it. :-) Makes ui_file a real C++ hierarchy. mem_fileopen is replaced with a new string_file class that is treated as a value class created on the stack. This alone eliminates most make_cleanup_ui_file_delete calls, and, simplifies code a whole lot (diffstat shows almost 1k loc dropped.) string_file has a string() method that gives you a direct reference to the internal std::string. This is what replaces old (well, new) ui_file_as_string, which used to alway return a new copy of the same data the stream had inside.. With direct access via a writable reference, we can instead move the string out of the string_stream. Note I needed a tweak on scoped_restore. That one should probably be split out to a separate patch. This exposed the need to make use of gnulib namespace support. Otherwise, making use of read/write/printf/puts/etc symbol names will clash on systems where gnulib replaces those functions, due to '#define foo rpl_foo'.
Diffstat (limited to 'gdb/arm-tdep.c')
-rw-r--r--gdb/arm-tdep.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index 0f9f0f3b86c..5b51d030586 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -9578,7 +9578,6 @@ extern initialize_file_ftype _initialize_arm_tdep; /* -Wmissing-prototypes */
void
_initialize_arm_tdep (void)
{
- struct ui_file *stb;
long length;
const char *setname;
const char *setdesc;
@@ -9650,13 +9649,12 @@ _initialize_arm_tdep (void)
valid_disassembly_styles[num_disassembly_options] = NULL;
/* Create the help text. */
- stb = mem_fileopen ();
- fprintf_unfiltered (stb, "%s%s%s",
- _("The valid values are:\n"),
- regdesc,
- _("The default is \"std\"."));
- helptext = ui_file_as_string (stb);
- ui_file_delete (stb);
+ string_file stb;
+ stb.printf ("%s%s%s",
+ _("The valid values are:\n"),
+ regdesc,
+ _("The default is \"std\"."));
+ helptext = std::move (stb.string ());
add_setshow_enum_cmd("disassembler", no_class,
valid_disassembly_styles, &disassembly_style,