From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by sourceware.org (Postfix) with ESMTPS id 46016385843D; Tue, 8 Nov 2022 06:49:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 46016385843D Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667890177; x=1699426177; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=MF2M9/9Iwy/oBO4HUtEkOFccr5W91/ZNt0QFqWmTxzY=; b=XtAjpx+sL+gspZhWRg0LOcFR6qthG0usfO5WEoT+RQDpuKiS1noRd+vJ mrEDmPiHBzFohfHbHUACcdJ3XO66vfnJefhMyRNDPnVJ+ZqKp7HjqEuDi W2f1tTlFuS0V3UGb3YfVrua4/T4UECj80G2fBBP1KqJ/EokjQWCCOI/Mn 77WZ5nWUtAL3u7ergx4714fLkyGf/Y3Iv/jUqVO/sC/4yP8Ebqt3zZoQg ApaMnuwmAtZw5STxl8VJcx8ex9crsfZ6JbT3cegc9LVs4NdDqP6DY8asG aLINdzH58bXR1f8lQwqzLtzGjqi+jdjqNlNusy1j7Rib1sI0NKu+ZTPV0 w==; X-IronPort-AV: E=McAfee;i="6500,9779,10524"; a="290341159" X-IronPort-AV: E=Sophos;i="5.96,147,1665471600"; d="scan'208";a="290341159" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Nov 2022 22:49:35 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10524"; a="811130978" X-IronPort-AV: E=Sophos;i="5.96,147,1665471600"; d="scan'208";a="811130978" Received: from labpc2407.iul.intel.com (HELO localhost) ([172.28.48.175]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Nov 2022 22:49:34 -0800 From: Markus Metzger To: gdb-patches@sourceware.org, binutils@sourceware.org Subject: [PATCH 2/2] gdb, btrace: use cpuident.h to implement btrace_this_cpu Date: Tue, 8 Nov 2022 06:45:30 +0100 Message-Id: <20221108054530.796968-2-markus.t.metzger@intel.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221108054530.796968-1-markus.t.metzger@intel.com> References: <20221108054530.796968-1-markus.t.metzger@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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_PASS,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 List-Id: --- gdb/nat/linux-btrace.c | 39 ++++++++++++--------------------------- 1 file changed, 12 insertions(+), 27 deletions(-) diff --git a/gdb/nat/linux-btrace.c b/gdb/nat/linux-btrace.c index a951f3b56aa..108a4a10ecb 100644 --- a/gdb/nat/linux-btrace.c +++ b/gdb/nat/linux-btrace.c @@ -23,7 +23,7 @@ #include "linux-btrace.h" #include "gdbsupport/common-regcache.h" #include "gdbsupport/gdb_wait.h" -#include "x86-cpuid.h" +#include "include/cpuident.h" #include "gdbsupport/filestuff.h" #include "gdbsupport/scoped_fd.h" #include "gdbsupport/scoped_mmap.h" @@ -65,38 +65,23 @@ static struct btrace_cpu btrace_this_cpu (void) { struct btrace_cpu cpu; - unsigned int eax, ebx, ecx, edx; - int ok; - memset (&cpu, 0, sizeof (cpu)); - ok = x86_cpuid (0, &eax, &ebx, &ecx, &edx); - if (ok != 0) + unsigned int vendor = cpuid_getvendor (); + switch (vendor) { - if (ebx == signature_INTEL_ebx && ecx == signature_INTEL_ecx - && edx == signature_INTEL_edx) - { - unsigned int cpuid, ignore; - - ok = x86_cpuid (1, &cpuid, &ignore, &ignore, &ignore); - if (ok != 0) - { - cpu.vendor = CV_INTEL; - - cpu.family = (cpuid >> 8) & 0xf; - if (cpu.family == 0xf) - cpu.family += (cpuid >> 20) & 0xff; + case X86_VENDOR_Intel: + cpu.vendor = CV_INTEL; + break; - cpu.model = (cpuid >> 4) & 0xf; - if ((cpu.family == 0x6) || ((cpu.family & 0xf) == 0xf)) - cpu.model += (cpuid >> 12) & 0xf0; - } - } - else if (ebx == signature_AMD_ebx && ecx == signature_AMD_ecx - && edx == signature_AMD_edx) - cpu.vendor = CV_AMD; + case X86_VENDOR_AMD: + cpu.vendor = CV_AMD; + break; } + cpu.family = (unsigned short) cpuid_getfamily (); + cpu.model = (unsigned char) cpuid_getmodel (); + return cpu; } -- 2.37.3 Intel Deutschland GmbH Registered Address: Am Campeon 10, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928