Unify gdb printf functions

Now that filtered and unfiltered output can be treated identically, we
can unify the printf family of functions.  This is done under the name
"gdb_printf".  Most of this patch was written by script.
This commit is contained in:
Tom Tromey
2022-01-02 11:46:15 -07:00
parent a11ac3b3e8
commit 6cb06a8cda
249 changed files with 8449 additions and 8463 deletions

View File

@@ -435,9 +435,9 @@ compute_stack_depth (enum bfd_endian byte_order, unsigned int addr_size,
static void
push (int indent, string_file *stream, ULONGEST l)
{
fprintf_filtered (stream,
"%*s__gdb_stack[++__gdb_tos] = (" GCC_UINTPTR ") %s;\n",
indent, "", hex_string (l));
gdb_printf (stream,
"%*s__gdb_stack[++__gdb_tos] = (" GCC_UINTPTR ") %s;\n",
indent, "", hex_string (l));
}
/* Emit code to push an arbitrary expression. This works like
@@ -451,13 +451,13 @@ pushf (int indent, string_file *stream, const char *format, ...)
{
va_list args;
fprintf_filtered (stream, "%*s__gdb_stack[__gdb_tos + 1] = ", indent, "");
gdb_printf (stream, "%*s__gdb_stack[__gdb_tos + 1] = ", indent, "");
va_start (args, format);
stream->vprintf (format, args);
va_end (args);
stream->puts (";\n");
fprintf_filtered (stream, "%*s++__gdb_tos;\n", indent, "");
gdb_printf (stream, "%*s++__gdb_tos;\n", indent, "");
}
/* Emit code for a unary expression -- one which operates in-place on
@@ -471,7 +471,7 @@ unary (int indent, string_file *stream, const char *format, ...)
{
va_list args;
fprintf_filtered (stream, "%*s__gdb_stack[__gdb_tos] = ", indent, "");
gdb_printf (stream, "%*s__gdb_stack[__gdb_tos] = ", indent, "");
va_start (args, format);
stream->vprintf (format, args);
va_end (args);
@@ -488,12 +488,12 @@ binary (int indent, string_file *stream, const char *format, ...)
{
va_list args;
fprintf_filtered (stream, "%*s__gdb_stack[__gdb_tos - 1] = ", indent, "");
gdb_printf (stream, "%*s__gdb_stack[__gdb_tos - 1] = ", indent, "");
va_start (args, format);
stream->vprintf (format, args);
va_end (args);
stream->puts (";\n");
fprintf_filtered (stream, "%*s--__gdb_tos;\n", indent, "");
gdb_printf (stream, "%*s--__gdb_tos;\n", indent, "");
}
/* Print the name of a label given its "SCOPE", an arbitrary integer
@@ -614,9 +614,9 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream,
++scope;
fprintf_filtered (stream, "%*s__attribute__ ((unused)) %s %s;\n",
indent, "", type_name, result_name);
fprintf_filtered (stream, "%*s{\n", indent, "");
gdb_printf (stream, "%*s__attribute__ ((unused)) %s %s;\n",
indent, "", type_name, result_name);
gdb_printf (stream, "%*s{\n", indent, "");
indent += 2;
stack_depth = compute_stack_depth (byte_order, addr_size,
@@ -652,19 +652,19 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream,
"compiled code."),
sym->print_name ());
fprintf_filtered (stream, "%*s%s = %s;\n",
indent, "", result_name,
core_addr_to_string (value_address (val)));
fprintf_filtered (stream, "%*s}\n", indent - 2, "");
gdb_printf (stream, "%*s%s = %s;\n",
indent, "", result_name,
core_addr_to_string (value_address (val)));
gdb_printf (stream, "%*s}\n", indent - 2, "");
return;
}
fprintf_filtered (stream, "%*s" GCC_UINTPTR " __gdb_stack[%d];\n",
indent, "", stack_depth);
gdb_printf (stream, "%*s" GCC_UINTPTR " __gdb_stack[%d];\n",
indent, "", stack_depth);
if (need_tempvar)
fprintf_filtered (stream, "%*s" GCC_UINTPTR " __gdb_tmp;\n", indent, "");
fprintf_filtered (stream, "%*sint __gdb_tos = -1;\n", indent, "");
gdb_printf (stream, "%*s" GCC_UINTPTR " __gdb_tmp;\n", indent, "");
gdb_printf (stream, "%*sint __gdb_tos = -1;\n", indent, "");
if (initial != NULL)
pushf (indent, stream, "%s", core_addr_to_string (*initial));
@@ -684,8 +684,8 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream,
stream->printf ("/* %s */\n", get_DW_OP_name (op));
/* This is handy for debugging the generated code:
fprintf_filtered (stream, "if (__gdb_tos != %d) abort ();\n",
(int) info[op_ptr - base].depth - 1);
gdb_printf (stream, "if (__gdb_tos != %d) abort ();\n",
(int) info[op_ptr - base].depth - 1);
*/
++op_ptr;
@@ -923,7 +923,7 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream,
break;
case DW_OP_drop:
fprintf_filtered (stream, "%*s--__gdb_tos;\n", indent, "");
gdb_printf (stream, "%*s--__gdb_tos;\n", indent, "");
break;
case DW_OP_pick:
@@ -933,16 +933,16 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream,
break;
case DW_OP_swap:
fprintf_filtered (stream,
"%*s__gdb_tmp = __gdb_stack[__gdb_tos - 1];\n",
indent, "");
fprintf_filtered (stream,
"%*s__gdb_stack[__gdb_tos - 1] = "
"__gdb_stack[__gdb_tos];\n",
indent, "");
fprintf_filtered (stream, ("%*s__gdb_stack[__gdb_tos] = "
"__gdb_tmp;\n"),
indent, "");
gdb_printf (stream,
"%*s__gdb_tmp = __gdb_stack[__gdb_tos - 1];\n",
indent, "");
gdb_printf (stream,
"%*s__gdb_stack[__gdb_tos - 1] = "
"__gdb_stack[__gdb_tos];\n",
indent, "");
gdb_printf (stream, ("%*s__gdb_stack[__gdb_tos] = "
"__gdb_tmp;\n"),
indent, "");
break;
case DW_OP_over:
@@ -950,20 +950,20 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream,
break;
case DW_OP_rot:
fprintf_filtered (stream, ("%*s__gdb_tmp = "
"__gdb_stack[__gdb_tos];\n"),
indent, "");
fprintf_filtered (stream,
"%*s__gdb_stack[__gdb_tos] = "
"__gdb_stack[__gdb_tos - 1];\n",
indent, "");
fprintf_filtered (stream,
"%*s__gdb_stack[__gdb_tos - 1] = "
"__gdb_stack[__gdb_tos -2];\n",
indent, "");
fprintf_filtered (stream, "%*s__gdb_stack[__gdb_tos - 2] = "
"__gdb_tmp;\n",
indent, "");
gdb_printf (stream, ("%*s__gdb_tmp = "
"__gdb_stack[__gdb_tos];\n"),
indent, "");
gdb_printf (stream,
"%*s__gdb_stack[__gdb_tos] = "
"__gdb_stack[__gdb_tos - 1];\n",
indent, "");
gdb_printf (stream,
"%*s__gdb_stack[__gdb_tos - 1] = "
"__gdb_stack[__gdb_tos -2];\n",
indent, "");
gdb_printf (stream, "%*s__gdb_stack[__gdb_tos - 2] = "
"__gdb_tmp;\n",
indent, "");
break;
case DW_OP_deref:
@@ -984,11 +984,11 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream,
/* Cast to a pointer of the desired type, then
dereference. */
fprintf_filtered (stream,
"%*s__gdb_stack[__gdb_tos] = "
"*((__gdb_int_%s *) "
"__gdb_stack[__gdb_tos]);\n",
indent, "", mode);
gdb_printf (stream,
"%*s__gdb_stack[__gdb_tos] = "
"*((__gdb_int_%s *) "
"__gdb_stack[__gdb_tos]);\n",
indent, "", mode);
}
break;
@@ -1110,7 +1110,7 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream,
case DW_OP_skip:
offset = extract_signed_integer (op_ptr, 2, byte_order);
op_ptr += 2;
fprintf_filtered (stream, "%*sgoto ", indent, "");
gdb_printf (stream, "%*sgoto ", indent, "");
print_label (stream, scope, op_ptr + offset - base);
stream->puts (";\n");
break;
@@ -1118,10 +1118,10 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream,
case DW_OP_bra:
offset = extract_signed_integer (op_ptr, 2, byte_order);
op_ptr += 2;
fprintf_filtered (stream,
"%*sif ((( " GCC_INTPTR
") __gdb_stack[__gdb_tos--]) != 0) goto ",
indent, "");
gdb_printf (stream,
"%*sif ((( " GCC_INTPTR
") __gdb_stack[__gdb_tos--]) != 0) goto ",
indent, "");
print_label (stream, scope, op_ptr + offset - base);
stream->puts (";\n");
break;
@@ -1134,9 +1134,9 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream,
}
}
fprintf_filtered (stream, "%*s%s = __gdb_stack[__gdb_tos];\n",
indent, "", result_name);
fprintf_filtered (stream, "%*s}\n", indent - 2, "");
gdb_printf (stream, "%*s%s = __gdb_stack[__gdb_tos];\n",
indent, "", result_name);
gdb_printf (stream, "%*s}\n", indent - 2, "");
}
/* See compile.h. */