From patchwork Thu Aug 4 10:37:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 14311 Received: (qmail 31908 invoked by alias); 4 Aug 2016 10:37:56 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 31898 invoked by uid 89); 4 Aug 2016 10:37:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=beneath, *result X-HELO: mail-pf0-f196.google.com Received: from mail-pf0-f196.google.com (HELO mail-pf0-f196.google.com) (209.85.192.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 04 Aug 2016 10:37:44 +0000 Received: by mail-pf0-f196.google.com with SMTP id h186so17517384pfg.2 for ; Thu, 04 Aug 2016 03:37:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id; bh=5XftgJcE6sFytl3IMOJFSZOUkE5qQvFjc0U+ujZcmes=; b=glPeVpv/FWNpivLP9gGePs6LJHl0ejvQ9pgVRiEsT8IvrLjbFyez5zOrU+a7B0nmHl uDUwWLjhCVz0YDC76LJe/UCCg0JtDSHTvs0yLob91nLJjSYBLTNvnMGPThKTSnABKvB4 fGv8NRCVPsMmVYYPaz4SncH6BQEEcHN5sMEA0S32kGB6/3B/Mgtw8oB+FB3In4IEgsdV FTHnElc840UXc0zpDq/Wbdqg9fQ9GbgzB04ZqUicXK31E6+PE8g8bWODHiHDqQVHJLIv r60jIpiXVtE1e78H075c1Ns9ldWAmEJruOQ94krc8tJk6GTTiNYKpF9CJsG1XCiX3x2r nUrQ== X-Gm-Message-State: AEkoouvpVa6VzDyeksNhHWxqzZQkwPjELW5YiJIXF+vz7OKArLrCvRMWv/Q5WZJxj4hKHg== X-Received: by 10.98.12.200 with SMTP id 69mr124582037pfm.15.1470307062664; Thu, 04 Aug 2016 03:37:42 -0700 (PDT) Received: from E107787-LIN.cambridge.arm.com (gcc1-power7.osuosl.org. [140.211.15.137]) by smtp.gmail.com with ESMTPSA id w76sm19230456pfd.69.2016.08.04.03.37.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 04 Aug 2016 03:37:42 -0700 (PDT) From: Yao Qi X-Google-Original-From: Yao Qi To: gdb-patches@sourceware.org Subject: [PATCH master+7.12] Determine target description for native aarch64 Date: Thu, 4 Aug 2016 11:37:36 +0100 Message-Id: <1470307056-18144-1-git-send-email-yao.qi@linaro.org> X-IsSubscribed: yes I find the following test fail when I test native aarch64 gdb with arm program, (gdb) PASS: gdb.base/attach-pie-noexec.exp: attach set architecture arm^M warning: Selected architecture arm is not compatible with reported target architecture aarch64^M Architecture `arm' not recognized.^M The target architecture is set automatically (currently aarch64)^M (gdb) FAIL: gdb.base/attach-pie-noexec.exp: set architecture arm GDB thinks the target is aarch64, but it isn't. Nowadays, we are using some entries AT_PHENT and AT_HWCAP in auxv to determine whether the process is a 32-bit arm one or 64-bit aarch64 one, and get the right gdbarch. However, in the process of parsing auxv (in inf_ptrace_auxv_parse), the size of int and data pointer of target_gdbarch is used. If debug program exists (in most of cases), target_gdbarch is already set according to the debug program, which is arm in my case. Then, GDB can parse auxv successfully. However, in gdb.base/attach-pie-noexec.exp, the debug program is removed, target_gdbarch is aarch64 when GDB parse auxv, so GDB can't parse it successfully. Instead of using auxv, we check the return value of ptrace NT_ARM_VFP. If the program is an arm process, NT_ARM_VFP is OK, otherwise, error is returned. Additionally, we only return tdesc_arm_with_neon for arm process, because neon is mandatory on ARMv8. I'll push it in to master and 7.12. gdb: 2016-08-04 Yao Qi * aarch64-linux-nat.c (tdesc_arm_with_vfpv3): Remove the declaration. (aarch64_linux_read_description): Remove code on getting auxv and select target description on it. Select target description by the result of NT_ARM_VFP ptrace request. --- gdb/ChangeLog | 8 ++++++++ gdb/aarch64-linux-nat.c | 50 +++++++++++-------------------------------------- 2 files changed, 19 insertions(+), 39 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 24a53a5..7f604a7 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +2016-08-04 Yao Qi + + * aarch64-linux-nat.c (tdesc_arm_with_neon): Remove the + declaration. + (aarch64_linux_read_description): Remove code on getting + auxv and select target description on it. Select target + description by the result of NT_ARM_VFP ptrace request. + 2016-08-03 Tom Tromey PR python/18565: diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c index fe1631d..e431637 100644 --- a/gdb/aarch64-linux-nat.c +++ b/gdb/aarch64-linux-nat.c @@ -481,7 +481,6 @@ aarch64_linux_child_post_startup_inferior (struct target_ops *self, super_post_startup_inferior (self, ptid); } -extern struct target_desc *tdesc_arm_with_vfpv3; extern struct target_desc *tdesc_arm_with_neon; /* Implement the "to_read_description" target_ops method. */ @@ -489,47 +488,20 @@ extern struct target_desc *tdesc_arm_with_neon; static const struct target_desc * aarch64_linux_read_description (struct target_ops *ops) { - CORE_ADDR at_phent; - - if (target_auxv_search (ops, AT_PHENT, &at_phent) == 1) - { - if (at_phent == sizeof (Elf64_External_Phdr)) - return tdesc_aarch64; - else - { - CORE_ADDR arm_hwcap = 0; - - if (target_auxv_search (ops, AT_HWCAP, &arm_hwcap) != 1) - return ops->beneath->to_read_description (ops->beneath); - -#ifndef COMPAT_HWCAP_VFP -#define COMPAT_HWCAP_VFP (1 << 6) -#endif -#ifndef COMPAT_HWCAP_NEON -#define COMPAT_HWCAP_NEON (1 << 12) -#endif -#ifndef COMPAT_HWCAP_VFPv3 -#define COMPAT_HWCAP_VFPv3 (1 << 13) -#endif - - if (arm_hwcap & COMPAT_HWCAP_VFP) - { - char *buf; - const struct target_desc *result = NULL; - - if (arm_hwcap & COMPAT_HWCAP_NEON) - result = tdesc_arm_with_neon; - else if (arm_hwcap & COMPAT_HWCAP_VFPv3) - result = tdesc_arm_with_vfpv3; + int ret, tid; + gdb_byte regbuf[VFP_REGS_SIZE]; + struct iovec iovec; - return result; - } + tid = ptid_get_lwp (inferior_ptid); - return NULL; - } - } + iovec.iov_base = regbuf; + iovec.iov_len = VFP_REGS_SIZE; - return tdesc_aarch64; + ret = ptrace (PTRACE_GETREGSET, tid, NT_ARM_VFP, &iovec); + if (ret == 0) + return tdesc_arm_with_neon; + else + return tdesc_aarch64; } /* Convert a native/host siginfo object, into/from the siginfo in the