From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id qMXcHjXCK2Zj5TwAWB0awg (envelope-from ) for ; Fri, 26 Apr 2024 11:03:17 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=GoTzftga; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 797E11E0CE; Fri, 26 Apr 2024 11:03:17 -0400 (EDT) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 6168A1E0C0 for ; Fri, 26 Apr 2024 11:03:15 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CF78D384AB7C for ; Fri, 26 Apr 2024 15:03:14 +0000 (GMT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id B329F3858402 for ; Fri, 26 Apr 2024 15:02:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B329F3858402 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B329F3858402 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714143740; cv=none; b=pgLMTIqrGYl9YjEySFi6Cto92lt7BObLLvejPJShGctJSJ1LOdH1smsI4u5MU3602gkM8oZD1oZDQE4MFZgwXX4XGXIks3mrzCeOO+TbxAxeyUPLH/zzHnLM+UOCuSBv+oZiV5emlGHkM7hr/YahlZDuf/m1LBJwh51CBOCqafQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714143740; c=relaxed/simple; bh=/5tbOj13nRkJvuVQtpBvXHD4FPkft2rbryqqkBUX83g=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=wx3m9E/Ch9BR/IWF+vYRopUqOPc25scnYAjwdgXnERotxe5ky95o7TN9n9Fidlq0se/yA1Dx0QPv4kmLa5VdsgtLwpa+fBkjE+tuTjbRmGyR2MK9RXg0Af7FRhAhD0PgCbw/hpNij+i60HwmVrAv+23AOZzxPo7LOYlmBV8PG5k= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714143737; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WVFb0+RqsdC/kcf1Gc+n5Q+YTVV2revazB7y8+kCJ3Y=; b=GoTzftgazSKXJ1zVcvxIBgDCHWlN84zRM6mr2z4Z+E1asG8TVHvnptQgiMTD7HtgeQu/6D 0EDsdDp+MhD0HxSsnEHhZoFbJaK4AB/wj0uCzvm0qCYcdaMdjFShdYIFRhcxolFsJNUbAi mPMrpLh6o7kn5pwM30IbJ4XgwitRskg= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-149-W6zfR-0CPReawM5gN_hS8A-1; Fri, 26 Apr 2024 11:02:16 -0400 X-MC-Unique: W6zfR-0CPReawM5gN_hS8A-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-34b40e8482aso1785696f8f.0 for ; Fri, 26 Apr 2024 08:02:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714143734; x=1714748534; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WVFb0+RqsdC/kcf1Gc+n5Q+YTVV2revazB7y8+kCJ3Y=; b=U3KQxICe/fHnF8eGzmVVNZZNjtJ0kq2OXG11Jnxx/ZufdZ+wG/uwjmPOPWY6I6006U l5KfjfkCwZodHTt7YQ5k/BtIeKlb8p6uLU443ghAVeJ42iIKMV9hkzIF9wKP0hrBM3s/ 3c8zsm0EGtAL0SXQYQgmzdK7FrUBX/Ri/X5FSvANv0wsIx8SP1jYvxBTB1VawejWeRFy FgYHSMuoerMJ3Bj34FUnoBgq8t9iT9dFXZMXae8FdBmMCb01Vb2G1Lld1k3PYsCRp4s/ Xj2Cyci8IVYP+tS4pXHWeJb5B4K9CX/E5QKfPPWG/l1b8iig3IDYHQDOObRROZlD1xIb b2RQ== X-Gm-Message-State: AOJu0YyJlf3VWjsj7lF9aiu5UKLHONHJ/RfIMQoz1A4oxntJv6wBEiWZ ocBQcpXam0xxwlFbfJKAOjC2BonclI7Nan/qI9QRtXPjW7KMeyNCCRJH5o7S1fJF9nrYgux0nof i5RZmHDm26fFP+T7BmZpFPiNV56CxCQAYLCLkbS9IV9AmZmcWKjDidYfcslzikyxH3hUaaOJH+Y pFdTw8QEhpadj6a2nCNKPbNS2P4psb+ffQ1lAWlgc9O0c= X-Received: by 2002:adf:fecf:0:b0:343:734e:73d1 with SMTP id q15-20020adffecf000000b00343734e73d1mr2294640wrs.37.1714143733986; Fri, 26 Apr 2024 08:02:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH5nkk/x54rYquCUkcYWr9v5LiNFnbqjTW8lhhevxYD4/ftywT+NLObRxuXYMTc4k1iwyeQsw== X-Received: by 2002:adf:fecf:0:b0:343:734e:73d1 with SMTP id q15-20020adffecf000000b00343734e73d1mr2294600wrs.37.1714143733260; Fri, 26 Apr 2024 08:02:13 -0700 (PDT) Received: from localhost (185.223.159.143.dyn.plus.net. [143.159.223.185]) by smtp.gmail.com with ESMTPSA id b7-20020adff907000000b0034b3394f0e1sm12112808wrr.10.2024.04.26.08.02.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 08:02:11 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess , felix.willgerodt@intel.com, John Baldwin Subject: [PATCHv5 05/11] gdbserver/x86: move no-xml code earlier in x86_linux_read_description Date: Fri, 26 Apr 2024 16:01:49 +0100 Message-Id: <6e7440d3bb04135432f9f18e0630ee1bca23e4d6.1714143669.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, 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.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org This commit is part of a series that aims to share more of the x86 target description reading/generation code between GDB and gdbserver. There are a huge number of similarities between the code in gdbserver's x86_linux_read_description function and GDB's x86_linux_nat_target::read_description function, and it is this similarity that I plan, in a later commit, to share between GDB and gdbserver. However, one thing that is different in x86_linux_read_description is the code inside the '!use_xml' block. This is the code that handles the case where gdbserver is not allowed to send an XML target description back to GDB. In this case gdbserver uses some predefined, fixed, target descriptions. First, it's worth noting that I suspect this code is not tested any more. I couldn't find anything in the testsuite that tries to disable XML target description support. And the idea of having a single "fixed" target description really doesn't work well when we think about all the various x86 extensions that exist. Part of me would like to rip out the no-xml support in gdbserver (at least for x86), and if a GDB connects that doesn't support XML target descriptions, gdbserver can just give an error and drop the connection. GDB has supported XML target descriptions for 16 years now, I think it would be reasonable for our shipped gdbserver to drop support for the old way of doing things. Anyway.... this commit doesn't do that. What I did notice was that, over time, the '!use_xml' block appears to have "drifted" within the x86_linux_read_description function; it's now not the first check we do. Instead we make some ptrace calls and return a target description generated based on the result of these ptrace calls. Surely it only makes sense to generate variable target descriptions if we can send these back to GDB? So in this commit I propose to move the '!use_xml' block earlier in the x86_linux_read_description function. The benefit of this is that this leaves the later half of x86_linux_read_description much more similar to the GDB function x86_linux_nat_target::read_description and sets us up for potentially sharing code between GDB and gdbserver in a later commit. Approved-By: John Baldwin --- gdbserver/linux-x86-low.cc | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/gdbserver/linux-x86-low.cc b/gdbserver/linux-x86-low.cc index 8199b0ccc09..ffb2a90731d 100644 --- a/gdbserver/linux-x86-low.cc +++ b/gdbserver/linux-x86-low.cc @@ -879,6 +879,22 @@ x86_linux_read_description (void) #endif } + /* If we are not allowed to send an XML target description then we need + to use the hard-wired target descriptions. This corresponds to GDB's + default machine for x86. + + This check needs to occur before any returns statements that might + generate some alternative target descriptions. */ + if (!use_xml) + { +#ifdef __x86_64__ + if (machine == EM_X86_64) + return tdesc_amd64_linux_no_xml.get (); + else +#endif + return tdesc_i386_linux_no_xml.get (); + } + #if !defined __x86_64__ && defined HAVE_PTRACE_GETFPXREGS if (machine == EM_386 && have_ptrace_getfpxregs == -1) { @@ -895,17 +911,6 @@ x86_linux_read_description (void) } #endif - if (!use_xml) - { - /* Don't use XML. */ -#ifdef __x86_64__ - if (machine == EM_X86_64) - return tdesc_amd64_linux_no_xml.get (); - else -#endif - return tdesc_i386_linux_no_xml.get (); - } - if (have_ptrace_getregset == TRIBOOL_UNKNOWN) { uint64_t xstateregs[(X86_XSTATE_SSE_SIZE / sizeof (uint64_t))]; -- 2.25.4