aboutsummaryrefslogtreecommitdiff
path: root/gdb/mi/mi-main.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/mi/mi-main.c')
-rw-r--r--gdb/mi/mi-main.c61
1 files changed, 24 insertions, 37 deletions
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index 57c23eb..b249f2d 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -1267,7 +1267,6 @@ output_register (struct frame_info *frame, int regnum, int format,
struct value *val = value_of_register (regnum, frame);
struct cleanup *tuple_cleanup;
struct value_print_options opts;
- struct ui_file *stb;
if (skip_unavailable && !value_entirely_available (val))
return;
@@ -1281,14 +1280,13 @@ output_register (struct frame_info *frame, int regnum, int format,
if (format == 'r')
format = 'z';
- stb = mem_fileopen ();
- make_cleanup_ui_file_delete (stb);
+ string_file stb;
get_formatted_print_options (&opts, format);
opts.deref_ref = 1;
val_print (value_type (val),
value_embedded_offset (val), 0,
- stb, 0, val, &opts, current_language);
+ &stb, 0, val, &opts, current_language);
uiout->field_stream ("value", stb);
do_cleanups (tuple_cleanup);
@@ -1358,15 +1356,10 @@ mi_cmd_data_write_register_values (char *command, char **argv, int argc)
void
mi_cmd_data_evaluate_expression (char *command, char **argv, int argc)
{
- struct cleanup *old_chain;
struct value *val;
- struct ui_file *stb;
struct value_print_options opts;
struct ui_out *uiout = current_uiout;
- stb = mem_fileopen ();
- old_chain = make_cleanup_ui_file_delete (stb);
-
if (argc != 1)
error (_("-data-evaluate-expression: "
"Usage: -data-evaluate-expression expression"));
@@ -1375,14 +1368,14 @@ mi_cmd_data_evaluate_expression (char *command, char **argv, int argc)
val = evaluate_expression (expr.get ());
+ string_file stb;
+
/* Print the result of the expression evaluation. */
get_user_print_options (&opts);
opts.deref_ref = 0;
- common_val_print (val, stb, 0, &opts, current_language);
+ common_val_print (val, &stb, 0, &opts, current_language);
uiout->field_stream ("value", stb);
-
- do_cleanups (old_chain);
}
/* This is the -data-read-memory command.
@@ -1522,15 +1515,13 @@ mi_cmd_data_read_memory (char *command, char **argv, int argc)
/* Build the result as a two dimentional table. */
{
- struct ui_file *stream;
- struct cleanup *cleanup_stream;
int row;
int row_byte;
+ struct cleanup *cleanup_list;
- stream = mem_fileopen ();
- cleanup_stream = make_cleanup_ui_file_delete (stream);
+ string_file stream;
- make_cleanup_ui_out_list_begin_end (uiout, "memory");
+ cleanup_list = make_cleanup_ui_out_list_begin_end (uiout, "memory");
for (row = 0, row_byte = 0;
row < nr_rows;
row++, row_byte += nr_cols * word_size)
@@ -1557,9 +1548,9 @@ mi_cmd_data_read_memory (char *command, char **argv, int argc)
}
else
{
- ui_file_rewind (stream);
+ stream.clear ();
print_scalar_formatted (&mbuf[col_byte], word_type, &opts,
- word_asize, stream);
+ word_asize, &stream);
uiout->field_stream (NULL, stream);
}
}
@@ -1568,22 +1559,22 @@ mi_cmd_data_read_memory (char *command, char **argv, int argc)
{
int byte;
- ui_file_rewind (stream);
+ stream.clear ();
for (byte = row_byte;
byte < row_byte + word_size * nr_cols; byte++)
{
if (byte >= nr_bytes)
- fputc_unfiltered ('X', stream);
+ stream.putc ('X');
else if (mbuf[byte] < 32 || mbuf[byte] > 126)
- fputc_unfiltered (aschar, stream);
+ stream.putc (aschar);
else
- fputc_unfiltered (mbuf[byte], stream);
+ stream.putc (mbuf[byte]);
}
uiout->field_stream ("ascii", stream);
}
do_cleanups (cleanup_tuple);
}
- do_cleanups (cleanup_stream);
+ do_cleanups (cleanup_list);
}
}
@@ -2317,15 +2308,12 @@ mi_cmd_execute (struct mi_parse *parse)
else
{
/* FIXME: DELETE THIS. */
- struct ui_file *stb;
-
- stb = mem_fileopen ();
+ string_file stb;
- fputs_unfiltered ("Undefined mi command: ", stb);
- fputstr_unfiltered (parse->command, '"', stb);
- fputs_unfiltered (" (missing implementation)", stb);
+ stb.puts ("Undefined mi command: ");
+ stb.putstr (parse->command, '"');
+ stb.puts (" (missing implementation)");
- make_cleanup_ui_file_delete (stb);
error_stream (stb);
}
do_cleanups (cleanup);
@@ -2705,12 +2693,10 @@ print_variable_or_computed (const char *expression, enum print_values values)
{
struct cleanup *old_chain;
struct value *val;
- struct ui_file *stb;
struct type *type;
struct ui_out *uiout = current_uiout;
- stb = mem_fileopen ();
- old_chain = make_cleanup_ui_file_delete (stb);
+ string_file stb;
expression_up expr = parse_expression (expression);
@@ -2719,6 +2705,7 @@ print_variable_or_computed (const char *expression, enum print_values values)
else
val = evaluate_expression (expr.get ());
+ old_chain = make_cleanup (null_cleanup, NULL);
if (values != PRINT_NO_VALUES)
make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
uiout->field_string ("name", expression);
@@ -2727,7 +2714,7 @@ print_variable_or_computed (const char *expression, enum print_values values)
{
case PRINT_SIMPLE_VALUES:
type = check_typedef (value_type (val));
- type_print (value_type (val), "", stb, -1);
+ type_print (value_type (val), "", &stb, -1);
uiout->field_stream ("type", stb);
if (TYPE_CODE (type) != TYPE_CODE_ARRAY
&& TYPE_CODE (type) != TYPE_CODE_STRUCT
@@ -2737,7 +2724,7 @@ print_variable_or_computed (const char *expression, enum print_values values)
get_no_prettyformat_print_options (&opts);
opts.deref_ref = 1;
- common_val_print (val, stb, 0, &opts, current_language);
+ common_val_print (val, &stb, 0, &opts, current_language);
uiout->field_stream ("value", stb);
}
break;
@@ -2747,7 +2734,7 @@ print_variable_or_computed (const char *expression, enum print_values values)
get_no_prettyformat_print_options (&opts);
opts.deref_ref = 1;
- common_val_print (val, stb, 0, &opts, current_language);
+ common_val_print (val, &stb, 0, &opts, current_language);
uiout->field_stream ("value", stb);
}
break;