From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) by sourceware.org (Postfix) with ESMTP id 7553A3858D1E for ; Fri, 23 Dec 2022 01:04:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7553A3858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gentoo.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gentoo.org Received: by smtp.gentoo.org (Postfix, from userid 559) id 24B893413EA; Fri, 23 Dec 2022 01:04:54 +0000 (UTC) From: Mike Frysinger To: gdb-patches@sourceware.org Subject: [PATCH] sim: mips: switch from SIM_ADDR to address_word Date: Thu, 22 Dec 2022 20:03:38 -0500 Message-Id: <20221223010338.32385-1-vapier@gentoo.org> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00,GIT_PATCH_0,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: The latter type matches the address size configured for this sim. Also take the opportunity to simplify printf logic by leveraging PRI* macros. --- sim/mips/interp.c | 40 +++++++++++----------------------------- sim/mips/sim-main.h | 4 ++-- 2 files changed, 13 insertions(+), 31 deletions(-) diff --git a/sim/mips/interp.c b/sim/mips/interp.c index 951a962f1cc3..fa192d36f2e9 100644 --- a/sim/mips/interp.c +++ b/sim/mips/interp.c @@ -52,7 +52,7 @@ code on the hardware. #include "sim/sim.h" /* GDB simulator interface */ #include "sim-syscall.h" /* Simulator system call support */ -char* pr_addr (SIM_ADDR addr); +char* pr_addr (address_word addr); char* pr_uword64 (uword64 addr); @@ -134,9 +134,9 @@ static void ColdReset (SIM_DESC sd); The RSVD_INSTRUCTION... macros specify the magic instructions we use at the monitor entry points. */ static int firmware_option_p = 0; -static SIM_ADDR idt_monitor_base = 0xBFC00000; -static SIM_ADDR pmon_monitor_base = 0xBFC00500; -static SIM_ADDR lsipmon_monitor_base = 0xBFC00200; +static address_word idt_monitor_base = 0xBFC00000; +static address_word pmon_monitor_base = 0xBFC00500; +static address_word lsipmon_monitor_base = 0xBFC00200; static SIM_RC sim_firmware_command (SIM_DESC sd, char* arg); @@ -707,11 +707,11 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb, /* the default monitor region */ if (WITH_TARGET_WORD_BITSIZE == 64) - sim_do_commandf (sd, "memory alias 0x%x,0x%" PRIxTW ",0x%" PRIxTA, + sim_do_commandf (sd, "memory alias %#" PRIxTA ",%#" PRIxTA ",%#" PRIxTA, idt_monitor_base, idt_monitor_size, EXTENDED (idt_monitor_base)); else - sim_do_commandf (sd, "memory region 0x%x,0x%" PRIxTA, + sim_do_commandf (sd, "memory region %#" PRIxTA ",%#" PRIxTA, idt_monitor_base, idt_monitor_size); /* Entry into the IDT monitor is via fixed address vectors, and @@ -1088,7 +1088,7 @@ static SIM_RC sim_firmware_command (SIM_DESC sd, char *arg) { int address_present = 0; - SIM_ADDR address; + address_word address; /* Signal occurrence of this option. */ firmware_option_p = 1; @@ -1728,7 +1728,7 @@ dotrace (SIM_DESC sd, sim_cpu *cpu, FILE *tracefh, int type, - SIM_ADDR address, + address_word address, int width, const char *comment, ...) { @@ -2460,28 +2460,11 @@ get_cell (void) /* Print routines to handle variable size regs, etc */ -/* Eliminate warning from compiler on 32-bit systems */ -static int thirty_two = 32; - char* -pr_addr (SIM_ADDR addr) +pr_addr (address_word addr) { char *paddr_str=get_cell(); - switch (sizeof(addr)) - { - case 8: - sprintf(paddr_str,"%08lx%08lx", - (unsigned long)(addr>>thirty_two),(unsigned long)(addr&0xffffffff)); - break; - case 4: - sprintf(paddr_str,"%08lx",(unsigned long)addr); - break; - case 2: - sprintf(paddr_str,"%04x",(unsigned short)(addr&0xffff)); - break; - default: - sprintf(paddr_str,"%x",addr); - } + sprintf (paddr_str, "%0*" PRIxTA, (int) (sizeof (addr) * 2), addr); return paddr_str; } @@ -2489,8 +2472,7 @@ char* pr_uword64 (uword64 addr) { char *paddr_str=get_cell(); - sprintf(paddr_str,"%08lx%08lx", - (unsigned long)(addr>>thirty_two),(unsigned long)(addr&0xffffffff)); + sprintf (paddr_str, "%016" PRIx64, addr); return paddr_str; } diff --git a/sim/mips/sim-main.h b/sim/mips/sim-main.h index 3868fffef86c..9ec6c121b3aa 100644 --- a/sim/mips/sim-main.h +++ b/sim/mips/sim-main.h @@ -1029,7 +1029,7 @@ address_word micromips_instruction_decode (SIM_DESC sd, sim_cpu * cpu, int instruction_size); #if WITH_TRACE_ANY_P -void dotrace (SIM_DESC sd, sim_cpu *cpu, FILE *tracefh, int type, SIM_ADDR address, int width, const char *comment, ...) ATTRIBUTE_PRINTF (7, 8); +void dotrace (SIM_DESC sd, sim_cpu *cpu, FILE *tracefh, int type, address_word address, int width, const char *comment, ...) ATTRIBUTE_PRINTF (7, 8); extern FILE *tracefh; #else #define dotrace(sd, cpu, tracefh, type, address, width, comment, ...) @@ -1041,7 +1041,7 @@ extern int DSPHI_REGNUM[4]; INLINE_SIM_MAIN (void) pending_tick (SIM_DESC sd, sim_cpu *cpu, address_word cia); extern SIM_CORE_SIGNAL_FN mips_core_signal; -char* pr_addr (SIM_ADDR addr); +char* pr_addr (address_word addr); char* pr_uword64 (uword64 addr); -- 2.39.0