diff options
author | Tom Tromey <tromey@adacore.com> | 2020-12-17 13:29:38 -0700 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2020-12-17 13:29:38 -0700 |
commit | 32f47895b5859c1f34abec75478ef55f2d92b023 (patch) | |
tree | cf6b98937829b3a3d5801feea8797c3d591aedef /gdb/compile | |
parent | 85be4f5a8c8bec8d3163585a82e288a4dec08b07 (diff) | |
download | gdb-32f47895b5859c1f34abec75478ef55f2d92b023.zip gdb-32f47895b5859c1f34abec75478ef55f2d92b023.tar.gz gdb-32f47895b5859c1f34abec75478ef55f2d92b023.tar.bz2 |
Remove printfi_filtered and fprintfi_filtered
After seeing Simon's patch, I thought maybe it was finally time to
remove printfi_filtered and fprintfi_filtered, in favor of using the
"%*s" approach to indenting.
In this patch I took the straightforward approach of always adding a
leading "%*s", even when the format already started with "%s", to
avoid the trickier form of:
printf ("%*s", -indent, string)
Regression tested on x86-64 Fedora 32.
Let me know what you think.
gdb/ChangeLog
2020-12-17 Tom Tromey <tromey@adacore.com>
* gdbtypes.c (print_args, dump_fn_fieldlists, print_cplus_stuff)
(print_gnat_stuff, print_fixed_point_type_info)
(recursive_dump_type): Update.
* go32-nat.c (go32_sysinfo, display_descriptor): Update.
* c-typeprint.c (c_type_print_base_struct_union)
(c_type_print_base_1): Update.
* rust-lang.c (rust_internal_print_type): Update.
* f-typeprint.c (f_language::f_type_print_base): Update.
* utils.h (fprintfi_filtered, printfi_filtered): Remove.
* m2-typeprint.c (m2_record_fields): Update.
* p-typeprint.c (pascal_type_print_base): Update.
* compile/compile-loc2c.c (push, pushf, unary, binary)
(do_compile_dwarf_expr_to_c): Update.
* utils.c (fprintfi_filtered, printfi_filtered): Remove.
Diffstat (limited to 'gdb/compile')
-rw-r--r-- | gdb/compile/compile-loc2c.c | 106 |
1 files changed, 57 insertions, 49 deletions
diff --git a/gdb/compile/compile-loc2c.c b/gdb/compile/compile-loc2c.c index 2fd1810..e88e733 100644 --- a/gdb/compile/compile-loc2c.c +++ b/gdb/compile/compile-loc2c.c @@ -434,9 +434,9 @@ compute_stack_depth (enum bfd_endian byte_order, unsigned int addr_size, static void push (int indent, string_file *stream, ULONGEST l) { - fprintfi_filtered (indent, stream, - "__gdb_stack[++__gdb_tos] = (" GCC_UINTPTR ") %s;\n", - hex_string (l)); + fprintf_filtered (stream, + "%*s__gdb_stack[++__gdb_tos] = (" GCC_UINTPTR ") %s;\n", + indent, "", hex_string (l)); } /* Emit code to push an arbitrary expression. This works like @@ -450,13 +450,13 @@ pushf (int indent, string_file *stream, const char *format, ...) { va_list args; - fprintfi_filtered (indent, stream, "__gdb_stack[__gdb_tos + 1] = "); + fprintf_filtered (stream, "%*s__gdb_stack[__gdb_tos + 1] = ", indent, ""); va_start (args, format); stream->vprintf (format, args); va_end (args); stream->puts (";\n"); - fprintfi_filtered (indent, stream, "++__gdb_tos;\n"); + fprintf_filtered (stream, "%*s++__gdb_tos;\n", indent, ""); } /* Emit code for a unary expression -- one which operates in-place on @@ -470,7 +470,7 @@ unary (int indent, string_file *stream, const char *format, ...) { va_list args; - fprintfi_filtered (indent, stream, "__gdb_stack[__gdb_tos] = "); + fprintf_filtered (stream, "%*s__gdb_stack[__gdb_tos] = ", indent, ""); va_start (args, format); stream->vprintf (format, args); va_end (args); @@ -487,12 +487,12 @@ binary (int indent, string_file *stream, const char *format, ...) { va_list args; - fprintfi_filtered (indent, stream, "__gdb_stack[__gdb_tos - 1] = "); + fprintf_filtered (stream, "%*s__gdb_stack[__gdb_tos - 1] = ", indent, ""); va_start (args, format); stream->vprintf (format, args); va_end (args); stream->puts (";\n"); - fprintfi_filtered (indent, stream, "--__gdb_tos;\n"); + fprintf_filtered (stream, "%*s--__gdb_tos;\n", indent, ""); } /* Print the name of a label given its "SCOPE", an arbitrary integer @@ -599,9 +599,9 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream, ++scope; - fprintfi_filtered (indent, stream, "__attribute__ ((unused)) %s %s;\n", - type_name, result_name); - fprintfi_filtered (indent, stream, "{\n"); + fprintf_filtered (stream, "%*s__attribute__ ((unused)) %s %s;\n", + indent, "", type_name, result_name); + fprintf_filtered (stream, "%*s{\n", indent, ""); indent += 2; stack_depth = compute_stack_depth (byte_order, addr_size, @@ -637,19 +637,19 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream, "compiled code."), sym->print_name ()); - fprintfi_filtered (indent, stream, "%s = %s;\n", - result_name, - core_addr_to_string (value_address (val))); - fprintfi_filtered (indent - 2, stream, "}\n"); + fprintf_filtered (stream, "%*s%s = %s;\n", + indent, "", result_name, + core_addr_to_string (value_address (val))); + fprintf_filtered (stream, "%*s}\n", indent - 2, ""); return; } - fprintfi_filtered (indent, stream, GCC_UINTPTR " __gdb_stack[%d];\n", - stack_depth); + fprintf_filtered (stream, "%*s" GCC_UINTPTR " __gdb_stack[%d];\n", + indent, "", stack_depth); if (need_tempvar) - fprintfi_filtered (indent, stream, GCC_UINTPTR " __gdb_tmp;\n"); - fprintfi_filtered (indent, stream, "int __gdb_tos = -1;\n"); + fprintf_filtered (stream, "%*s" GCC_UINTPTR " __gdb_tmp;\n", indent, ""); + fprintf_filtered (stream, "%*sint __gdb_tos = -1;\n", indent, ""); if (initial != NULL) pushf (indent, stream, "%s", core_addr_to_string (*initial)); @@ -908,7 +908,7 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream, break; case DW_OP_drop: - fprintfi_filtered (indent, stream, "--__gdb_tos;\n"); + fprintf_filtered (stream, "%*s--__gdb_tos;\n", indent, ""); break; case DW_OP_pick: @@ -918,13 +918,16 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream, break; case DW_OP_swap: - fprintfi_filtered (indent, stream, - "__gdb_tmp = __gdb_stack[__gdb_tos - 1];\n"); - fprintfi_filtered (indent, stream, - "__gdb_stack[__gdb_tos - 1] = " - "__gdb_stack[__gdb_tos];\n"); - fprintfi_filtered (indent, stream, ("__gdb_stack[__gdb_tos] = " - "__gdb_tmp;\n")); + 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, ""); break; case DW_OP_over: @@ -932,16 +935,20 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream, break; case DW_OP_rot: - fprintfi_filtered (indent, stream, ("__gdb_tmp = " - "__gdb_stack[__gdb_tos];\n")); - fprintfi_filtered (indent, stream, - "__gdb_stack[__gdb_tos] = " - "__gdb_stack[__gdb_tos - 1];\n"); - fprintfi_filtered (indent, stream, - "__gdb_stack[__gdb_tos - 1] = " - "__gdb_stack[__gdb_tos -2];\n"); - fprintfi_filtered (indent, stream, "__gdb_stack[__gdb_tos - 2] = " - "__gdb_tmp;\n"); + 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, ""); break; case DW_OP_deref: @@ -962,11 +969,11 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream, /* Cast to a pointer of the desired type, then dereference. */ - fprintfi_filtered (indent, stream, - "__gdb_stack[__gdb_tos] = " - "*((__gdb_int_%s *) " - "__gdb_stack[__gdb_tos]);\n", - mode); + fprintf_filtered (stream, + "%*s__gdb_stack[__gdb_tos] = " + "*((__gdb_int_%s *) " + "__gdb_stack[__gdb_tos]);\n", + indent, "", mode); } break; @@ -1088,7 +1095,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; - fprintfi_filtered (indent, stream, "goto "); + fprintf_filtered (stream, "%*sgoto ", indent, ""); print_label (stream, scope, op_ptr + offset - base); stream->puts (";\n"); break; @@ -1096,9 +1103,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; - fprintfi_filtered (indent, stream, - "if ((( " GCC_INTPTR - ") __gdb_stack[__gdb_tos--]) != 0) goto "); + fprintf_filtered (stream, + "%*sif ((( " GCC_INTPTR + ") __gdb_stack[__gdb_tos--]) != 0) goto ", + indent, ""); print_label (stream, scope, op_ptr + offset - base); stream->puts (";\n"); break; @@ -1111,9 +1119,9 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream, } } - fprintfi_filtered (indent, stream, "%s = __gdb_stack[__gdb_tos];\n", - result_name); - fprintfi_filtered (indent - 2, stream, "}\n"); + fprintf_filtered (stream, "%*s%s = __gdb_stack[__gdb_tos];\n", + indent, "", result_name); + fprintf_filtered (stream, "%*s}\n", indent - 2, ""); } /* See compile.h. */ |