From patchwork Tue Nov 8 05:45:30 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: 60164 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 8A2063858021 for ; Tue, 8 Nov 2022 06:51:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8A2063858021 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1667890287; bh=I07iuiYNXfAXDRyLhfpX0zJFyIG+PyytPi5l3FaDlM8=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=yrwPFCJV00kUJCubkgYaHtCv/C1nqx/PBF2I12yzMlg+Hhf07HHYjuVeaAjdu05Ct jE87Z1MCPpbZgLUKiKQ+YkDEu9T/yueHP2T48MmhmCC1Q1bYTjQ2Y0u9PxVFo7yOb3 5A2MSio/JNRqUqYtSCF14gMhM9RVfL304o9BYl5w= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org 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 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 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 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 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" --- 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; }