From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id T/WwLeEEfWBvZgAAWB0awg (envelope-from ) for ; Mon, 19 Apr 2021 00:19:45 -0400 Received: by simark.ca (Postfix, from userid 112) id ADB381F104; Mon, 19 Apr 2021 00:19:45 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.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 253341E813 for ; Mon, 19 Apr 2021 00:19:45 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C90743952039; Mon, 19 Apr 2021 04:19:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C90743952039 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1618805984; bh=5uUsTBvaQFHguott/kZ/Oe9s38GONS3ZHIgA+z+j6gw=; h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=CNSXlF5+vLPn3/29PHsQ3nTwFPMjrYUnX8ZPaoRL6FXNi5l6lXbw93zvy9IyfxBqN MW2HU8hvId1/EdH2sQm0dSJrec+iZx4Xog8vTLWPFUJxmpcT6EgBLRKyA+WSnQUAzr WRrm6HMDEHYnp+i6sU58hAFOeIOu6LZnvK//4uH4= Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by sourceware.org (Postfix) with ESMTP id C984339518B4 for ; Mon, 19 Apr 2021 04:19:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C984339518B4 Received: from vapier (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id E1AC7340E15; Mon, 19 Apr 2021 04:19:41 +0000 (UTC) Date: Mon, 19 Apr 2021 00:19:41 -0400 To: Jim Wilson Subject: Re: [PATCH 13/24] RISC-V sim: Add gettimeofday. Message-ID: Mail-Followup-To: Jim Wilson , gdb-patches@sourceware.org, Kuan-Lin Chen References: <20210417175831.16413-1-jimw@sifive.com> <20210417175831.16413-14-jimw@sifive.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210417175831.16413-14-jimw@sifive.com> 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: Mike Frysinger via Gdb-patches Reply-To: Mike Frysinger Cc: Kuan-Lin Chen , gdb-patches@sourceware.org Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" On 17 Apr 2021 10:58, Jim Wilson wrote: > + case TARGET_SYS_gettimeofday: > + { > + int rv; > + struct timeval tv; > + > + rv = gettimeofday (&tv, 0); > + if (RISCV_XLEN (cpu) == 32) > + { > + sim_core_write_unaligned_4 (cpu, cpu->pc, write_map, > + cpu->a0, tv.tv_sec); > + sim_core_write_unaligned_4 (cpu, cpu->pc, write_map, > + cpu->a0 + 4, > + tv.tv_usec); > + } > + else > + { > + sim_core_write_unaligned_8 (cpu, cpu->pc, write_map, > + cpu->a0, tv.tv_sec); > + sim_core_write_unaligned_8 (cpu, cpu->pc, write_map, > + cpu->a0 + 8, > + tv.tv_usec); > + } this is incomplete/buggy. if arg0==0, you'll write to the wrong place. if arg1!=0, you leave the memory uninitialized. if rv!=0, you write to the arg0 struct. see bfin/interp.c for a "full" implementation. if we extended host_callback_struct to include a timeval_map, we would be able to implement this in the common code and do so with full support for everyone. -mike