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: Markus Metzger X-Patchwork-Id: 16885 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2526502wru; Mon, 7 Nov 2022 22:50:14 -0800 (PST) X-Google-Smtp-Source: AMsMyM7EYwRsQnjPgTqDZqkk5ITx5Cs/Dawz0pw2gTTFHUmCtGAGfKBZMTAJUC2m+/HKW+M7hjxQ X-Received: by 2002:a05:6402:1b03:b0:458:9925:fb74 with SMTP id by3-20020a0564021b0300b004589925fb74mr911719edb.330.1667890214344; Mon, 07 Nov 2022 22:50:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667890214; cv=none; d=google.com; s=arc-20160816; b=NIIm+tjckgA1f6lX8lDW1AOywWIybwFaWmCptby/8aij+Be2gV6McaezRVWWwd1A6E LBOqe/YnirKbjL4q3vqGjZZpHd7pI0Zw5pMhxcaEPsGk0ueU/ir3yY6/LqQYNEnianqk EyBAsOkBgwIpEtuZWbiz2MJ1ygcKIMc7p7yx3wdpcDd3yp/rTGSvE2PVTz5hQXMgbSch gSf5oI6oJGQOeiHk1wR0d4gHIefwA7OndtZQVsoH9Ede4+OJZ2xcllBSKXR1UdSqoxkj p590+BA1IqciWRDqurLyXmgnOj5Q2Z2gjxy1kPmmb60h9nqiSD44DluM97rfbYOVULa0 lNKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=I07iuiYNXfAXDRyLhfpX0zJFyIG+PyytPi5l3FaDlM8=; b=DMgOebZ9aIgHGNcrgTYGG0QiqUPovNMSks1UYx8Jl2by0zDj7Lt3mBkyj6CJyrGr61 ftIGqppzk1m9FAxprYePK00XmvoVOiOJBiB5rRCS66Tn7ngOaboJmmRKkKl6DN3kcO+V jh9+pmOwwxme9I+xBwg6yd9LmpTSKAeTWrItBA3+b7uJVQw/j5tJxeQMdOlc/3oyH0RP c1FhzJNh/pteRP8VRGBytsjFBIwATETK9ObOZ1OaFT/WP7508PB2/IXHK143j9cZnxLh mzEGKpmggY8gJJ6iYHbDRxgMZkINW18jOArPGMLIGdul26CaS3zyeml2k/MCijukHm/p Wnfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=nMGugKkN; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id h1-20020a0564020e8100b00463525e8776si10226439eda.491.2022.11.07.22.50.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Nov 2022 22:50:14 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=nMGugKkN; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7CF60385840B for ; Tue, 8 Nov 2022 06:50:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7CF60385840B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1667890209; 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=nMGugKkNIsF2sICRP8+5TTr2k/bV56PpV9s0/kh3BX4VLdU8KIpV7BzR+M5yDz3jw kXjAMHodri4A7y9JTHGcC6pIGtU+nVcJxQ8RlPDBnW8DUYrAeRGETq+z77gv+DhEDy gYWZW5Iij5M/K9MAGukBlflPwMMSIzsL3qWigPyg= X-Original-To: binutils@sourceware.org Delivered-To: binutils@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: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Markus Metzger via Binutils From: Markus Metzger Reply-To: Markus Metzger Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748909649171584853?= X-GMAIL-MSGID: =?utf-8?q?1748909649171584853?= --- 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; }