From patchwork Tue Mar 6 12:56:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 26207 Received: (qmail 80210 invoked by alias); 6 Mar 2018 12:56:13 -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 80201 invoked by uid 89); 6 Mar 2018 12:56:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=22507 X-HELO: mail-wr0-f194.google.com Received: from mail-wr0-f194.google.com (HELO mail-wr0-f194.google.com) (209.85.128.194) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 06 Mar 2018 12:56:10 +0000 Received: by mail-wr0-f194.google.com with SMTP id z12so20837298wrg.4 for ; Tue, 06 Mar 2018 04:56:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=A46+BYDqjge/LxKbMm5u7Q9XicGmW9Ym0Ixo7a9dIBQ=; b=JJcfhhO7+4wQHOoYT+Kr0ZSgMBUNf6arumyVAvUWOCF0LUsQbvz8bU7W0V+7Rl2y4V t6/fNun6/KcraECXyDqVXmwDKlvEsZ8WtSMj4yhHSdi2EJ9sLk+Fo/a91aoAmRKn3fk+ 8HXrbFALeX6eFTowFExC7PPVPlnNRwdYoGky4ILt7i7kmrhGvwex+GRM4APv2goE2w5d 3U4BZxTyfVfs639rcn9uYAdmYw1naq3C/jHQ10IJsKhk9cjAo8WLixPg+DZqyizGuyvB HYsD5ql8t4L2bFhqrNfvvKhNpyMYhbzOVUr6fKVdO/GhACqZRgTiVQvZn67/yoRXIAR2 GNWg== X-Gm-Message-State: APf1xPCw0lF2LOKAx3NgV1zvgBoAlZJ6YX9Zkm28Vc1iOwccMdY7rOoh 9qDIFGAIX55LXx4hO9rtRlSnFhX7 X-Google-Smtp-Source: AG47ELtTaTBij3OGKSx51ReccLCxu9rkcKAn3R7ngYQOBEVu1wudyL41T54UIgp/eDTCsNU9lxiXUg== X-Received: by 10.223.200.140 with SMTP id k12mr15786033wrh.191.1520340967303; Tue, 06 Mar 2018 04:56:07 -0800 (PST) Received: from localhost (host86-164-103-156.range86-164.btcentralplus.com. [86.164.103.156]) by smtp.gmail.com with ESMTPSA id b30sm29187011wra.34.2018.03.06.04.56.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Mar 2018 04:56:06 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PUSHED] [PATCH] gdb/riscv: Fixes to printf format strings Date: Tue, 6 Mar 2018 12:56:03 +0000 Message-Id: <20180306125603.32649-1-andrew.burgess@embecosm.com> X-IsSubscribed: yes I'm aware that I've managed to break a few of the GDB build tests with my riscv patch. Sorry for that. I'm working my way through the issues that I'm aware of. I pushed the patch below as it seemed pretty obvious, hopefully this is the right thing to do. I've seen the build-bot failure reports, and the email from Yao about some other failures, but if anyone sees any other issues, please let me know. Again, sorry for the inconvenience and I hope to have fixes out soon. Thanks, Andrew --- Some of the format strings used in the new riscv target were incorrect, resulting in build failures on some hosts. This commit does the following: 1. Uses core_addr_to_string for formatting CORE_ADDR types. 2. Fixes legacy use of stderr for logging in one place that got missed, instead gdb_stdlog is used. 3. Re-indent a few printf related lines that were wrong. This should resolve some (but not all) of the build failures the new riscv target introduced. gdb/ChangeLog: * riscv-tdep.c (riscv_print_arg_location): Add header comment, change parameter type. Use GDB's print functions, and use core_addr_to_string where appropriate. (riscv_push_dummy_call): Use core_addr_to_string where appropriate, update call to riscv_print_arg_location, and reindent a few lines. (riscv_return_value): Update call to riscv_print_arg_location. --- gdb/ChangeLog | 10 ++++++++ gdb/riscv-tdep.c | 74 ++++++++++++++++++++++++++++++++------------------------ 2 files changed, 53 insertions(+), 31 deletions(-) diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c index c757f9fca3e..5c04a740df0 100644 --- a/gdb/riscv-tdep.c +++ b/gdb/riscv-tdep.c @@ -1959,8 +1959,13 @@ riscv_arg_location (struct gdbarch *gdbarch, } } +/* Used for printing debug information about the call argument location in + INFO to STREAM. The addresses in SP_REFS and SP_ARGS are the base + addresses for the location of pass-by-reference and + arguments-on-the-stack memory areas. */ + static void -riscv_print_arg_location (FILE *stream, struct gdbarch *gdbarch, +riscv_print_arg_location (ui_file *stream, struct gdbarch *gdbarch, struct riscv_arg_info *info, CORE_ADDR sp_refs, CORE_ADDR sp_args) { @@ -1968,26 +1973,28 @@ riscv_print_arg_location (FILE *stream, struct gdbarch *gdbarch, if (type_name == nullptr) type_name = "???"; - fprintf (stream, "type: '%s', length: 0x%x, alignment: 0x%x", - type_name, info->length, info->align); + fprintf_unfiltered (stream, "type: '%s', length: 0x%x, alignment: 0x%x", + type_name, info->length, info->align); switch (info->argloc[0].loc_type) { case riscv_arg_info::location::in_reg: - fprintf (stream, ", register %s", - gdbarch_register_name (gdbarch, info->argloc[0].loc_data.regno)); + fprintf_unfiltered + (stream, ", register %s", + gdbarch_register_name (gdbarch, info->argloc[0].loc_data.regno)); if (info->argloc[0].c_length < info->length) { switch (info->argloc[1].loc_type) { case riscv_arg_info::location::in_reg: - fprintf (stream, ", register %s", - gdbarch_register_name (gdbarch, - info->argloc[1].loc_data.regno)); + fprintf_unfiltered + (stream, ", register %s", + gdbarch_register_name (gdbarch, + info->argloc[1].loc_data.regno)); break; case riscv_arg_info::location::on_stack: - fprintf (stream, ", on stack at offset 0x%x", - info->argloc[1].loc_data.offset); + fprintf_unfiltered (stream, ", on stack at offset 0x%x", + info->argloc[1].loc_data.offset); break; case riscv_arg_info::location::by_ref: @@ -2000,31 +2007,34 @@ riscv_print_arg_location (FILE *stream, struct gdbarch *gdbarch, } if (info->argloc[1].c_offset > info->argloc[0].c_length) - fprintf (stream, " (offset 0x%x)", info->argloc[1].c_offset); + fprintf_unfiltered (stream, " (offset 0x%x)", + info->argloc[1].c_offset); } break; case riscv_arg_info::location::on_stack: - fprintf (stream, ", on stack at offset 0x%x", - info->argloc[0].loc_data.offset); + fprintf_unfiltered (stream, ", on stack at offset 0x%x", + info->argloc[0].loc_data.offset); break; case riscv_arg_info::location::by_ref: - fprintf (stream, ", by reference, data at offset 0x%x (0x%lx)", - info->argloc[0].loc_data.offset, - (sp_refs + info->argloc[0].loc_data.offset)); + fprintf_unfiltered + (stream, ", by reference, data at offset 0x%x (%s)", + info->argloc[0].loc_data.offset, + core_addr_to_string (sp_refs + info->argloc[0].loc_data.offset)); if (info->argloc[1].loc_type == riscv_arg_info::location::in_reg) - fprintf (stream, ", address in register %s", - gdbarch_register_name (gdbarch, - info->argloc[1].loc_data.regno)); + fprintf_unfiltered + (stream, ", address in register %s", + gdbarch_register_name (gdbarch, info->argloc[1].loc_data.regno)); else { gdb_assert (info->argloc[1].loc_type == riscv_arg_info::location::on_stack); - fprintf (stream, ", address on stack at offset 0x%x (0x%lx)", - info->argloc[1].loc_data.offset, - (sp_args + info->argloc[1].loc_data.offset)); + fprintf_unfiltered + (stream, ", address on stack at offset 0x%x (%s)", + info->argloc[1].loc_data.offset, + core_addr_to_string (sp_args + info->argloc[1].loc_data.offset)); } break; @@ -2099,20 +2109,20 @@ riscv_push_dummy_call (struct gdbarch *gdbarch, struct riscv_arg_info *info = &arg_info [i]; fprintf_unfiltered (gdb_stdlog, "[%2d] ", i); - riscv_print_arg_location (stderr, gdbarch, info, sp_refs, sp_args); + riscv_print_arg_location (gdb_stdlog, gdbarch, info, sp_refs, sp_args); fprintf_unfiltered (gdb_stdlog, "\n"); } if (call_info.memory.arg_offset > 0 || call_info.memory.ref_offset > 0) { - fprintf_unfiltered (gdb_stdlog, " Original sp: 0x%lx\n", - osp); + fprintf_unfiltered (gdb_stdlog, " Original sp: %s\n", + core_addr_to_string (osp)); fprintf_unfiltered (gdb_stdlog, "Stack required (for args): 0x%x\n", - call_info.memory.arg_offset); + call_info.memory.arg_offset); fprintf_unfiltered (gdb_stdlog, "Stack required (for refs): 0x%x\n", - call_info.memory.ref_offset); + call_info.memory.ref_offset); fprintf_unfiltered (gdb_stdlog, " Stack allocated: 0x%lx\n", - (osp - sp)); + (osp - sp)); } } @@ -2213,13 +2223,15 @@ riscv_push_dummy_call (struct gdbarch *gdbarch, A dummy breakpoint will be setup to execute the call. */ if (riscv_debug_infcall > 0) - fprintf_unfiltered (gdb_stdlog, ": writing $ra = 0x%lx\n", bp_addr); + fprintf_unfiltered (gdb_stdlog, ": writing $ra = %s\n", + core_addr_to_string (bp_addr)); regcache_cooked_write_unsigned (regcache, RISCV_RA_REGNUM, bp_addr); /* Finally, update the stack pointer. */ if (riscv_debug_infcall > 0) - fprintf_unfiltered (gdb_stdlog, ": writing $sp = 0x%lx\n", sp); + fprintf_unfiltered (gdb_stdlog, ": writing $sp = %s\n", + core_addr_to_string (sp)); regcache_cooked_write_unsigned (regcache, RISCV_SP_REGNUM, sp); return sp; @@ -2250,7 +2262,7 @@ riscv_return_value (struct gdbarch *gdbarch, { fprintf_unfiltered (gdb_stdlog, "riscv return value:\n"); fprintf_unfiltered (gdb_stdlog, "[R] "); - riscv_print_arg_location (stderr, gdbarch, &info, 0, 0); + riscv_print_arg_location (gdb_stdlog, gdbarch, &info, 0, 0); fprintf_unfiltered (gdb_stdlog, "\n"); }