From patchwork Tue Nov 8 05:45:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Metzger, Markus T" X-Patchwork-Id: 60163 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 DE63F38582A8 for ; Tue, 8 Nov 2022 06:49:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DE63F38582A8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1667890195; bh=aL+fTpxN0b1X8MEPFZEayLvvpClC7NRN6u/tQZYyBiY=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=JnvZjZty+4OtpmWPybQjbudFrH38oT+Ha9s8C80xuo/1RgwWGDvgcemmekG6caKwM j2KY1+ujZBcsCARvilw0qX7vFFk715Wo5q/yxLbBbIrHVXpf9r065N4SCHtT+6nnyp /C8ZlVDmWM6Cdm6feDw09uYdNFtccBxQsSHl43lw= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by sourceware.org (Postfix) with ESMTPS id 984CC3858C2D; Tue, 8 Nov 2022 06:49:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 984CC3858C2D X-IronPort-AV: E=McAfee;i="6500,9779,10524"; a="396916975" X-IronPort-AV: E=Sophos;i="5.96,147,1665471600"; d="scan'208";a="396916975" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Nov 2022 22:49:28 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10524"; a="699805744" X-IronPort-AV: E=Sophos;i="5.96,147,1665471600"; d="scan'208";a="699805744" Received: from labpc2407.iul.intel.com (HELO localhost) ([172.28.48.175]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Nov 2022 22:49:27 -0800 To: gdb-patches@sourceware.org, binutils@sourceware.org Subject: [PATCH 1/2] gprofng: make cpu identification available to others Date: Tue, 8 Nov 2022 06:45:29 +0100 Message-Id: <20221108054530.796968-1-markus.t.metzger@intel.com> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_NONE, 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 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: , X-Patchwork-Original-From: Markus Metzger via Gdb-patches From: "Metzger, Markus T" Reply-To: Markus Metzger Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" I ran gprofng.display/display.exp on Fedora 36 x86-64 and I got UNSUPPORTED: jsynprog ERROR: comparison of results in mttest failed UNRESOLVED: mttest ERROR: comparison of results in mttest failed UNRESOLVED: mttest PASS: synprog PASS: synprog with and without this patch. --- gprofng/common/hwcdrv.c | 2 +- gprofng/common/cpuid.c => include/cpuident.h | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) rename gprofng/common/cpuid.c => include/cpuident.h (96%) diff --git a/gprofng/common/hwcdrv.c b/gprofng/common/hwcdrv.c index 03c3a71c8e2..115638aa623 100644 --- a/gprofng/common/hwcdrv.c +++ b/gprofng/common/hwcdrv.c @@ -32,7 +32,7 @@ /* macros */ #define IS_GLOBAL /* Mark global symbols */ -#include "cpuid.c" /* ftns for identifying a chip */ +#include "cpuident.h" /* ftns for identifying a chip */ static hdrv_pcbe_api_t hdrv_pcbe_core_api; static hdrv_pcbe_api_t hdrv_pcbe_opteron_api; diff --git a/gprofng/common/cpuid.c b/include/cpuident.h similarity index 96% rename from gprofng/common/cpuid.c rename to include/cpuident.h index 211e09aa8ac..7ab6fc1f2b1 100644 --- a/gprofng/common/cpuid.c +++ b/include/cpuident.h @@ -18,6 +18,11 @@ Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ +#ifndef _CPUIDENT_H +#define _CPUIDENT_H + +#include + #if defined(__i386__) || defined(__x86_64) #include /* GCC-provided */ #elif defined(__aarch64__) @@ -85,7 +90,7 @@ typedef struct #if defined(__i386__) || defined(__x86_64) -static uint_t +static unsigned int cpuid_vendorstr_to_vendorcode (char *vendorstr) { if (strcmp (vendorstr, X86_VENDORSTR_Intel) == 0) @@ -101,8 +106,10 @@ my_cpuid (unsigned int op, cpuid_regs_t *regs) { regs->eax = regs->ebx = regs->ecx = regs->edx = 0; int ret = __get_cpuid (op, ®s->eax, ®s->ebx, ®s->ecx, ®s->edx); +#ifdef DBG_LT1 TprintfT (DBG_LT1, "my_cpuid: __get_cpuid(0x%x, 0x%x, 0x%x, 0x%x, 0x%x) returns %d\n", op, regs->eax, regs->ebx, regs->ecx, regs->edx, ret); +#endif return ret; } #endif @@ -184,20 +191,22 @@ get_cpuid_info () return cpi; } -static inline uint_t +static inline unsigned int cpuid_getvendor () { return get_cpuid_info ()->cpi_vendor; } -static inline uint_t +static inline unsigned int cpuid_getfamily () { return get_cpuid_info ()->cpi_family; } -static inline uint_t +static inline unsigned int cpuid_getmodel () { return get_cpuid_info ()->cpi_model; } + +#endif /* _CPUIDENT_H */