From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id OHQzIOkw+V+qQgAAWB0awg (envelope-from ) for ; Fri, 08 Jan 2021 23:28:25 -0500 Received: by simark.ca (Postfix, from userid 112) id 7ED161EE11; Fri, 8 Jan 2021 23:28:25 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 2722D1E4F4 for ; Fri, 8 Jan 2021 23:28:24 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D5C96398547E; Sat, 9 Jan 2021 04:28:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D5C96398547E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1610166503; bh=LJxyJBKMLPmz4iINQRbAnRiNNePkmGvjRUWanY1x348=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=AayN0cKcfwQptRHEAChpIbSIUYGryqqvOhryn1sJ3UidHCMdXSqIDA8j9cyS8fLu+ ZrSWOyfnOw1Tkbk4caodd5nOrZ1G/Dn+P28RgmM6qSrSX0tcpW+rEU7aG0GK+SsYUe 9KOrhceP1Pxs9rd3UqsSVNcpPLwjrHchqrJoEU00= Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id 6AFC9386F411 for ; Sat, 9 Jan 2021 04:28:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6AFC9386F411 X-ASG-Debug-ID: 1610166498-0c856e67e23b2170001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id kKPGEyMeLcpmj0mR (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 08 Jan 2021 23:28:18 -0500 (EST) X-Barracuda-Envelope-From: simon.marchi@polymtl.ca X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from simark.localdomain (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) by smtp.ebox.ca (Postfix) with ESMTP id 18F60441D64; Fri, 8 Jan 2021 23:28:18 -0500 (EST) X-Barracuda-RBL-IP: 192.222.157.6 X-Barracuda-Effective-Source-IP: 192-222-157-6.qc.cable.ebox.net[192.222.157.6] X-Barracuda-Apparent-Source-IP: 192.222.157.6 To: gdb-patches@sourceware.org Subject: [PATCH 3/5] gdb: convert aarch64 to new-style debug macros Date: Fri, 8 Jan 2021 23:28:14 -0500 X-ASG-Orig-Subj: [PATCH 3/5] gdb: convert aarch64 to new-style debug macros Message-Id: <20210109042816.4140840-3-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210109042816.4140840-1-simon.marchi@polymtl.ca> References: <20210109042816.4140840-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1610166498 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Barracuda-BRTS-Status: 1 X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Scan-Msg-Size: 7649 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=8.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.87110 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Simon Marchi via Gdb-patches Reply-To: Simon Marchi Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" I haven't tried this on an actual aarch64 machine, but I am able to exercise it like this: (gdb) set debug aarch64 (gdb) maintenance selftest aa Running selftest aarch64-analyze-prologue. [aarch64] aarch64_analyze_prologue: prologue analysis gave up addr=0x14 opcode=0xf94013e0 Running selftest aarch64-process-record. Ran 2 unit tests, 0 failed gdb/ChangeLog: * arch/aarch64-insn.h (aarch64_debug_printf): New. * arch/aarch64-insn.c: Use aarch64_debug_printf. * aarch64-tdep.c: Use aarch64_debug_printf. Change-Id: Ifdb40e2816ab8e55a9aabb066d1833d9b5a46094 --- gdb/aarch64-tdep.c | 89 ++++++++++++++++------------------------- gdb/arch/aarch64-insn.c | 9 ++--- gdb/arch/aarch64-insn.h | 5 +++ 3 files changed, 42 insertions(+), 61 deletions(-) diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index 77e6ad700fcd..a51b3341e789 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -388,12 +388,10 @@ aarch64_analyze_prologue (struct gdbarch *gdbarch, regs[rd] = regs[rm]; else { - if (aarch64_debug) - { - debug_printf ("aarch64: prologue analysis gave up " - "addr=%s opcode=0x%x (orr x register)\n", - core_addr_to_string_nz (start), insn); - } + aarch64_debug_printf ("prologue analysis gave up " + "addr=%s opcode=0x%x (orr x register)", + core_addr_to_string_nz (start), insn); + break; } } @@ -513,10 +511,9 @@ aarch64_analyze_prologue (struct gdbarch *gdbarch, } else { - if (aarch64_debug) - debug_printf ("aarch64: prologue analysis gave up addr=%s" - " opcode=0x%x (iclass)\n", - core_addr_to_string_nz (start), insn); + aarch64_debug_printf ("prologue analysis gave up addr=%s" + " opcode=0x%x (iclass)", + core_addr_to_string_nz (start), insn); break; } @@ -527,12 +524,10 @@ aarch64_analyze_prologue (struct gdbarch *gdbarch, } else { - if (aarch64_debug) - { - debug_printf ("aarch64: prologue analysis gave up addr=%s" - " opcode=0x%x\n", - core_addr_to_string_nz (start), insn); - } + aarch64_debug_printf ("prologue analysis gave up addr=%s" + " opcode=0x%x", + core_addr_to_string_nz (start), insn); + break; } } @@ -1606,12 +1601,10 @@ pass_in_x (struct gdbarch *gdbarch, struct regcache *regcache, && (typecode == TYPE_CODE_STRUCT || typecode == TYPE_CODE_UNION)) regval <<= ((X_REGISTER_SIZE - partial_len) * TARGET_CHAR_BIT); - if (aarch64_debug) - { - debug_printf ("arg %d in %s = 0x%s\n", info->argnum, - gdbarch_register_name (gdbarch, regnum), - phex (regval, X_REGISTER_SIZE)); - } + aarch64_debug_printf ("arg %d in %s = 0x%s", info->argnum, + gdbarch_register_name (gdbarch, regnum), + phex (regval, X_REGISTER_SIZE)); + regcache_cooked_write_unsigned (regcache, regnum, regval); len -= partial_len; buf += partial_len; @@ -1646,11 +1639,9 @@ pass_in_v (struct gdbarch *gdbarch, memcpy (reg, buf, len); regcache->cooked_write (regnum, reg); - if (aarch64_debug) - { - debug_printf ("arg %d in %s\n", info->argnum, - gdbarch_register_name (gdbarch, regnum)); - } + aarch64_debug_printf ("arg %d in %s", info->argnum, + gdbarch_register_name (gdbarch, regnum)); + return 1; } info->nsrn = 8; @@ -1680,11 +1671,8 @@ pass_on_stack (struct aarch64_call_info *info, struct type *type, if (align > 16) align = 16; - if (aarch64_debug) - { - debug_printf ("arg %d len=%d @ sp + %d\n", info->argnum, len, - info->nsaa); - } + aarch64_debug_printf ("arg %d len=%d @ sp + %d\n", info->argnum, len, + info->nsaa); item.len = len; item.data = buf; @@ -1833,13 +1821,11 @@ aarch64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, /* The struct_return pointer occupies X8. */ if (return_method != return_method_normal) { - if (aarch64_debug) - { - debug_printf ("struct return in %s = 0x%s\n", - gdbarch_register_name (gdbarch, - AARCH64_STRUCT_RETURN_REGNUM), - paddress (gdbarch, struct_addr)); - } + aarch64_debug_printf + ("struct return in %s = 0x%s", + gdbarch_register_name (gdbarch, AARCH64_STRUCT_RETURN_REGNUM), + paddress (gdbarch, struct_addr)); + regcache_cooked_write_unsigned (regcache, AARCH64_STRUCT_RETURN_REGNUM, struct_addr); } @@ -2246,12 +2232,10 @@ aarch64_extract_return_value (struct type *type, struct regcache *regs, gdb_byte buf[register_size (gdbarch, regno)]; gdb_assert (len <= sizeof (buf)); - if (aarch64_debug) - { - debug_printf ("read HFA or HVA return value element %d from %s\n", - i + 1, - gdbarch_register_name (gdbarch, regno)); - } + aarch64_debug_printf + ("read HFA or HVA return value element %d from %s", + i + 1, gdbarch_register_name (gdbarch, regno)); + regs->cooked_read (regno, buf); memcpy (valbuf, buf, len); @@ -2358,12 +2342,9 @@ aarch64_store_return_value (struct type *type, struct regcache *regs, gdb_byte tmpbuf[register_size (gdbarch, regno)]; gdb_assert (len <= sizeof (tmpbuf)); - if (aarch64_debug) - { - debug_printf ("write HFA or HVA return value element %d to %s\n", - i + 1, - gdbarch_register_name (gdbarch, regno)); - } + aarch64_debug_printf + ("write HFA or HVA return value element %d to %s", + i + 1, gdbarch_register_name (gdbarch, regno)); memcpy (tmpbuf, valbuf, len > V_REGISTER_SIZE ? V_REGISTER_SIZE : len); @@ -2438,8 +2419,7 @@ aarch64_return_value (struct gdbarch *gdbarch, struct value *func_value, { if (aarch64_return_in_memory (gdbarch, valtype)) { - if (aarch64_debug) - debug_printf ("return value in memory\n"); + aarch64_debug_printf ("return value in memory"); return RETURN_VALUE_STRUCT_CONVENTION; } } @@ -2450,8 +2430,7 @@ aarch64_return_value (struct gdbarch *gdbarch, struct value *func_value, if (readbuf) aarch64_extract_return_value (valtype, regcache, readbuf); - if (aarch64_debug) - debug_printf ("return value in registers\n"); + aarch64_debug_printf ("return value in registers"); return RETURN_VALUE_REGISTER_CONVENTION; } diff --git a/gdb/arch/aarch64-insn.c b/gdb/arch/aarch64-insn.c index 125288909137..6a5abf729bb2 100644 --- a/gdb/arch/aarch64-insn.c +++ b/gdb/arch/aarch64-insn.c @@ -69,12 +69,9 @@ aarch64_decode_adr (CORE_ADDR addr, uint32_t insn, int *is_adrp, else *offset = (immhi | immlo); - if (aarch64_debug) - { - debug_printf ("decode: 0x%s 0x%x %s x%u, #?\n", - core_addr_to_string_nz (addr), insn, - *is_adrp ? "adrp" : "adr", *rd); - } + aarch64_debug_printf ("decode: 0x%s 0x%x %s x%u, #?", + core_addr_to_string_nz (addr), insn, + *is_adrp ? "adrp" : "adr", *rd); return 1; } return 0; diff --git a/gdb/arch/aarch64-insn.h b/gdb/arch/aarch64-insn.h index 57aeb23feab1..1e8c5eac940e 100644 --- a/gdb/arch/aarch64-insn.h +++ b/gdb/arch/aarch64-insn.h @@ -21,6 +21,11 @@ extern bool aarch64_debug; +/* Print an "aarch64" debug statement. */ + +#define aarch64_debug_printf(fmt, ...) \ + debug_prefixed_printf_cond (aarch64_debug, "aarch64", fmt, ##__VA_ARGS__) + /* Support routines for instruction parsing. */ /* Create a mask of X bits. */ -- 2.29.2