From patchwork Fri Apr 11 18:21:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 110293 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 731E1382FAF6 for ; Fri, 11 Apr 2025 18:29:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 731E1382FAF6 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=default header.b=pSSfE8GW X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 253473858405 for ; Fri, 11 Apr 2025 18:21:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 253473858405 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=polymtl.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=polymtl.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 253473858405 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=132.207.4.11 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1744395718; cv=none; b=XySuc0BGSiTn3Lw3ZOAz95Tnn9FTFfMEHw6ybRav1n/ymZ89EiSSJd6sn3TAJ3T9j9rZiCj7R2k1gvyRUu/Mmplrnrx+98I8fKDkvH3pg3E86b9QTzufWYx3QZD5rEwm6+nZbIzKF3Bcuiy9KEPKwyFmqB1Nii2eUqrmrmAT1g8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1744395718; c=relaxed/simple; bh=79I3ejeJd8YMfpZTf3sVGnmHiF2wgxJz0OlmSxjTOsQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=hUiw6HCm1Boox5n5RCkSLeZMpEbPHJyEPwgbktMuIA8UqRbFRo7sdVXWFKfggEF1LcmgGVyGRMkZ2P3yzKDRGE4GVkpPvM/mNISmVwrQ8qySCkdD61NCIsSIUPZe8FgthktAM1F1tPleyuLSJmXn3WAzbY7BOQ6kadf7jPBKNBw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 253473858405 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 53BILq7u100707 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 11 Apr 2025 14:21:57 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 53BILq7u100707 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=polymtl.ca; s=default; t=1744395717; bh=z8j9/kG2MMEDDW4Eg/JK2ox3RBIRWDjOlgLMkpcHFE4=; h=From:To:Cc:Subject:Date:From; b=pSSfE8GWjRfoMmOsUIwaCTHwy4upvP7CVwGU2r3A6XIPl2R7w9X1LKqJquotMrOTG eWqWXGKY7TQjchEfYpo7+hjSJwf7n0eTt2ggFUeuT04uZFcudTDqRTFTuuF0zggFdo ydwq/Px5x6Y8/zQBC+vrT9npP7haQehc4GDF3bVQ= Received: by simark.ca (Postfix, from userid 112) id D7A541E10E; Fri, 11 Apr 2025 14:21:52 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-Spam-Level: X-Spam-Status: No, score=-3187.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 Received: from simark.localdomain (modemcable238.237-201-24.mc.videotron.ca [24.201.237.238]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 392D71E05C; Fri, 11 Apr 2025 14:21:52 -0400 (EDT) From: simon.marchi@polymtl.ca To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 1/3] gdbsupport: move run_time_clock::now(user, system) out of run_time_clock Date: Fri, 11 Apr 2025 14:21:30 -0400 Message-ID: <20250411182151.1427430-1-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.49.0 MIME-Version: 1.0 X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Fri, 11 Apr 2025 18:21:53 +0000 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~patchwork=sourceware.org@sourceware.org From: Simon Marchi It is completely unrelated to run_time_clock, so I don't think it makes sense to have it as a static function there. Move it to be a free function named "get_run_time". Change-Id: I0c3e4d3cc44ca37e523c94d72f7cd66add95645e --- gdb/mi/mi-main.c | 2 +- gdbsupport/run-time-clock.cc | 4 ++-- gdbsupport/run-time-clock.h | 13 +++++++------ 3 files changed, 10 insertions(+), 9 deletions(-) base-commit: 7fa205d2fe280f331ff08de24198229fa864014f diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index 850a9ab33418..aea8fa9a02e8 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -2218,7 +2218,7 @@ timestamp (struct mi_timestamp *tv) using namespace std::chrono; tv->wallclock = steady_clock::now (); - run_time_clock::now (tv->utime, tv->stime); + get_run_time (tv->utime, tv->stime); } static void diff --git a/gdbsupport/run-time-clock.cc b/gdbsupport/run-time-clock.cc index 43da1d9b07fd..d8de0313148a 100644 --- a/gdbsupport/run-time-clock.cc +++ b/gdbsupport/run-time-clock.cc @@ -38,8 +38,8 @@ timeval_to_microseconds (struct timeval *tv) #endif void -run_time_clock::now (user_cpu_time_clock::time_point &user, - system_cpu_time_clock::time_point &system) noexcept +get_run_time (user_cpu_time_clock::time_point &user, + system_cpu_time_clock::time_point &system) noexcept { #ifdef HAVE_GETRUSAGE struct rusage rusage; diff --git a/gdbsupport/run-time-clock.h b/gdbsupport/run-time-clock.h index a961f4cff6ef..c789e9dcf799 100644 --- a/gdbsupport/run-time-clock.h +++ b/gdbsupport/run-time-clock.h @@ -51,6 +51,13 @@ struct system_cpu_time_clock static time_point now () noexcept = delete; }; +/* Return the user/system time as separate time points, if + supported. If not supported, then the combined user+kernel time + is returned in USER and SYSTEM is set to zero. */ + +void get_run_time (user_cpu_time_clock::time_point &user, + system_cpu_time_clock::time_point &system) noexcept; + /* Count the total amount of time spent executing in userspace+kernel mode. */ @@ -64,12 +71,6 @@ struct run_time_clock static constexpr bool is_steady = true; static time_point now () noexcept; - - /* Return the user/system time as separate time points, if - supported. If not supported, then the combined user+kernel time - is returned in USER and SYSTEM is set to zero. */ - static void now (user_cpu_time_clock::time_point &user, - system_cpu_time_clock::time_point &system) noexcept; }; #endif /* GDBSUPPORT_RUN_TIME_CLOCK_H */