From patchwork Fri Sep 27 21:25:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 34699 Received: (qmail 106504 invoked by alias); 27 Sep 2019 21:25:33 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 106333 invoked by uid 89); 27 Sep 2019 21:25:32 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=disp, disposition, spots X-HELO: gateway23.websitewelcome.com Received: from gateway23.websitewelcome.com (HELO gateway23.websitewelcome.com) (192.185.50.185) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 27 Sep 2019 21:25:25 +0000 Received: from cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway23.websitewelcome.com (Postfix) with ESMTP id 930964FE77 for ; Fri, 27 Sep 2019 16:25:24 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id DxjwiUgSx3Qi0Dxjwi4DSa; Fri, 27 Sep 2019 16:25:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=esBBggkUbhewN0ghL7giWlqSHO8Csc6apGWqpr/luQY=; b=vw4bUenv0HX1q5+ZM+92A8Ow3c jnLBt6K7nKDXt9/d2yfsn49ejDw5e98Mze8UvbnJA4rcDYWhbGI0FhbFO8b6tdf814l2SJ/6oty0b nUhPskA3o1oGpbkhnlL7PR+iY; Received: from 71-218-73-27.hlrn.qwest.net ([71.218.73.27]:34758 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1iDxjw-002PvY-BP; Fri, 27 Sep 2019 16:25:24 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Pedro Alves Subject: [PATCH 4/8] Use new %p format suffixes in gdb Date: Fri, 27 Sep 2019 15:25:16 -0600 Message-Id: <20190927212520.20073-5-tom@tromey.com> In-Reply-To: <20190927212520.20073-1-tom@tromey.com> References: <20190927212520.20073-1-tom@tromey.com> From: Pedro Alves This changes various spots in gdb to use the new %p format suffixes. gdb/ChangeLog 2019-09-27 Pedro Alves Tom Tromey * symtab.c (print_symbol_info): Uew %ps. (print_msymbol_info): Use %ps. * symfile.c (symbol_file_add_with_addrs): Use %ps. * printcmd.c (print_variable_and_value): Use %ps. * macrocmd.c (show_pp_source_pos): Use %ps. * infrun.c (print_exited_reason): Use ui_out::message. * breakpoint.c (watchpoint_check, print_one_breakpoint_location) (describe_other_breakpoints): Use ui_out::message and new formats. (say_where): Use new formats. (bkpt_print_it, tracepoint_print_one_detail): Use ui_out::message and new formats. --- gdb/ChangeLog | 16 ++++++++++++ gdb/breakpoint.c | 65 ++++++++++++++++++++++-------------------------- gdb/infrun.c | 19 ++++++-------- gdb/macrocmd.c | 6 +++-- gdb/printcmd.c | 5 ++-- gdb/symfile.c | 13 +++++----- gdb/symtab.c | 24 +++++++++--------- 7 files changed, 77 insertions(+), 71 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index dd8fe4c8620..2030687728c 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -4912,10 +4912,10 @@ watchpoint_check (bpstat bs) if (uiout->is_mi_like_p ()) uiout->field_string ("reason", async_reason_lookup (EXEC_ASYNC_WATCHPOINT_SCOPE)); - uiout->text ("\nWatchpoint "); - uiout->field_signed ("wpnum", b->number); - uiout->text (" deleted because the program has left the block in\n" - "which its expression is valid.\n"); + uiout->message ("\nWatchpoint %pF deleted because the program has " + "left the block in\n" + "which its expression is valid.\n", + signed_field ("wpnum", b->number)); } /* Make sure the watchpoint's commands aren't executed. */ @@ -6141,10 +6141,9 @@ print_one_breakpoint_location (struct breakpoint *b, && breakpoint_condition_evaluation_mode () == condition_evaluation_target) { - uiout->text (" ("); - uiout->field_string ("evaluated-by", - bp_condition_evaluator (b)); - uiout->text (" evals)"); + uiout->message (" (%pF evals)", + string_field ("evaluated-by", + bp_condition_evaluator (b))); } uiout->text ("\n"); } @@ -6193,9 +6192,8 @@ print_one_breakpoint_location (struct breakpoint *b, if (!part_of_multiple && b->ignore_count) { annotate_field (8); - uiout->text ("\tignore next "); - uiout->field_signed ("ignore", b->ignore_count); - uiout->text (" hits\n"); + uiout->message ("\tignore next %pF hits\n", + signed_field ("ignore", b->ignore_count)); } /* Note that an enable count of 1 corresponds to "enable once" @@ -6658,9 +6656,9 @@ describe_other_breakpoints (struct gdbarch *gdbarch, (others > 1) ? "," : ((others == 1) ? " and" : "")); } - printf_filtered (_("also set at pc ")); - fputs_styled (paddress (gdbarch, pc), address_style.style (), gdb_stdout); - printf_filtered (".\n"); + current_uiout->message (_("also set at pc %ps.\n"), + styled_string (address_style.style (), + paddress (gdbarch, pc))); } } @@ -12075,23 +12073,21 @@ say_where (struct breakpoint *b) else { if (opts.addressprint || b->loc->symtab == NULL) - { - printf_filtered (" at "); - fputs_styled (paddress (b->loc->gdbarch, b->loc->address), - address_style.style (), - gdb_stdout); - } + printf_filtered (" at %ps", + styled_string (address_style.style (), + paddress (b->loc->gdbarch, + b->loc->address))); if (b->loc->symtab != NULL) { /* If there is a single location, we can print the location more nicely. */ if (b->loc->next == NULL) { - puts_filtered (": file "); - fputs_styled (symtab_to_filename_for_display (b->loc->symtab), - file_name_style.style (), - gdb_stdout); - printf_filtered (", line %d.", + const char *filename + = symtab_to_filename_for_display (b->loc->symtab); + printf_filtered (": file %ps, line %d.", + styled_string (file_name_style.style (), + filename), b->loc->line_number); } else @@ -12389,18 +12385,18 @@ bkpt_print_it (bpstat bs) annotate_breakpoint (b->number); maybe_print_thread_hit_breakpoint (uiout); - if (bp_temp) - uiout->text ("Temporary breakpoint "); - else - uiout->text ("Breakpoint "); if (uiout->is_mi_like_p ()) { uiout->field_string ("reason", async_reason_lookup (EXEC_ASYNC_BREAKPOINT_HIT)); uiout->field_string ("disp", bpdisp_text (b->disposition)); } - uiout->field_signed ("bkptno", b->number); - uiout->text (", "); + if (bp_temp) + uiout->message ("Temporary breakpoint %pF, ", + signed_field ("bkptno", b->number)); + else + uiout->message ("Breakpoint %pF, ", + signed_field ("bkptno", b->number)); return PRINT_SRC_AND_LOC; } @@ -12716,10 +12712,9 @@ tracepoint_print_one_detail (const struct breakpoint *self, { gdb_assert (self->type == bp_static_tracepoint); - uiout->text ("\tmarker id is "); - uiout->field_string ("static-tracepoint-marker-string-id", - tp->static_trace_marker_id); - uiout->text ("\n"); + uiout->message ("\tmarker id is %pF\n", + string_field ("static-tracepoint-marker-string-id", + tp->static_trace_marker_id.c_str ())); } } diff --git a/gdb/infrun.c b/gdb/infrun.c index be29cbe4f51..07aebfa678f 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -7656,24 +7656,19 @@ print_exited_reason (struct ui_out *uiout, int exitstatus) { if (uiout->is_mi_like_p ()) uiout->field_string ("reason", async_reason_lookup (EXEC_ASYNC_EXITED)); - uiout->text ("[Inferior "); - uiout->text (plongest (inf->num)); - uiout->text (" ("); - uiout->text (pidstr.c_str ()); - uiout->text (") exited with code "); - uiout->field_fmt ("exit-code", "0%o", (unsigned int) exitstatus); - uiout->text ("]\n"); + std::string exit_code_str + = string_printf ("0%o", (unsigned int) exitstatus); + uiout->message ("[Inferior %s (%s) exited with code %pF]\n", + plongest (inf->num), pidstr.c_str (), + string_field ("exit-code", exit_code_str.c_str ())); } else { if (uiout->is_mi_like_p ()) uiout->field_string ("reason", async_reason_lookup (EXEC_ASYNC_EXITED_NORMALLY)); - uiout->text ("[Inferior "); - uiout->text (plongest (inf->num)); - uiout->text (" ("); - uiout->text (pidstr.c_str ()); - uiout->text (") exited normally]\n"); + uiout->message ("[Inferior %s (%s) exited normally]\n", + plongest (inf->num), pidstr.c_str ()); } } diff --git a/gdb/macrocmd.c b/gdb/macrocmd.c index 0f81c3d5da4..cb7267d07a3 100644 --- a/gdb/macrocmd.c +++ b/gdb/macrocmd.c @@ -120,8 +120,10 @@ show_pp_source_pos (struct ui_file *stream, int line) { std::string fullname = macro_source_fullname (file); - fputs_styled (fullname.c_str (), file_name_style.style (), stream); - fprintf_filtered (stream, ":%d\n", line); + fprintf_filtered (stream, "%ps:%d\n", + styled_string (file_name_style.style (), + fullname.c_str ()), + line); while (file->included_by) { diff --git a/gdb/printcmd.c b/gdb/printcmd.c index b3f7b59863b..c17afe29bb2 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -2214,9 +2214,8 @@ print_variable_and_value (const char *name, struct symbol *var, if (!name) name = SYMBOL_PRINT_NAME (var); - fputs_filtered (n_spaces (2 * indent), stream); - fputs_styled (name, variable_name_style.style (), stream); - fputs_filtered (" = ", stream); + fprintf_filtered (stream, "%s%ps = ", n_spaces (2 * indent), + styled_string (variable_name_style.style (), name)); try { diff --git a/gdb/symfile.c b/gdb/symfile.c index b914b05a175..ca1360f0a7e 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -1106,11 +1106,8 @@ symbol_file_add_with_addrs (bfd *abfd, const char *name, if (deprecated_pre_add_symbol_hook) deprecated_pre_add_symbol_hook (name); else - { - puts_filtered (_("Reading symbols from ")); - fputs_styled (name, file_name_style.style (), gdb_stdout); - puts_filtered ("...\n"); - } + printf_filtered (_("Reading symbols from %ps...\n"), + styled_string (file_name_style.style (), name)); } syms_from_objfile (objfile, addrs, add_flags); @@ -1122,7 +1119,8 @@ symbol_file_add_with_addrs (bfd *abfd, const char *name, if ((flags & OBJF_READNOW)) { if (should_print) - printf_filtered (_("Expanding full symbols from %s...\n"), name); + printf_filtered (_("Expanding full symbols from %ps...\n"), + styled_string (file_name_style.style (), name)); if (objfile->sf) objfile->sf->qf->expand_all_symtabs (objfile); @@ -1134,7 +1132,8 @@ symbol_file_add_with_addrs (bfd *abfd, const char *name, file, and so printing it twice is just redundant. */ if (should_print && !objfile_has_symbols (objfile) && objfile->separate_debug_objfile == nullptr) - printf_filtered (_("(No debugging symbols found in %s)\n"), name); + printf_filtered (_("(No debugging symbols found in %ps)\n"), + styled_string (file_name_style.style (), name)); if (should_print) { diff --git a/gdb/symtab.c b/gdb/symtab.c index 6ea9fc6971e..df6b87f9483 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -4748,9 +4748,9 @@ print_symbol_info (enum search_domain kind, if (filename_cmp (last, s_filename) != 0) { - fputs_filtered ("\nFile ", gdb_stdout); - fputs_styled (s_filename, file_name_style.style (), gdb_stdout); - fputs_filtered (":\n", gdb_stdout); + printf_filtered (_("\nFile %ps:\n"), + styled_string (file_name_style.style (), + s_filename)); } if (SYMBOL_LINE (sym) != 0) @@ -4812,15 +4812,15 @@ print_msymbol_info (struct bound_minimal_symbol msymbol) else tmp = hex_string_custom (BMSYMBOL_VALUE_ADDRESS (msymbol), 16); - fputs_styled (tmp, address_style.style (), gdb_stdout); - fputs_filtered (" ", gdb_stdout); - if (msymbol.minsym->text_p ()) - fputs_styled (MSYMBOL_PRINT_NAME (msymbol.minsym), - function_name_style.style (), - gdb_stdout); - else - fputs_filtered (MSYMBOL_PRINT_NAME (msymbol.minsym), gdb_stdout); - fputs_filtered ("\n", gdb_stdout); + + ui_file_style sym_style = (msymbol.minsym->text_p () + ? function_name_style.style () + : ui_file_style ()); + + printf_filtered (_("%ps %ps\n"), + styled_string (address_style.style (), tmp), + styled_string (sym_style, + MSYMBOL_PRINT_NAME (msymbol.minsym))); } /* This is the guts of the commands "info functions", "info types", and