From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 ED51D3846043 for ; Wed, 8 May 2024 16:46:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org ED51D3846043 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 ED51D3846043 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=1715186816; cv=none; b=MjtuQN+0zROy+uxuo6QAzwGuHcD3yuitPlRv+7xdiHWotCOF/48Do20jfIJC9bNiawZrxmKv/efsQpe1Z7LLr5QLVRB8aUw5vZSAWyNEpOozH5VEmcgIHeY5VxJXjXfatEZTxloBca3NFNrxtiy8EB6wHmyZeu48sJIZ+RpV/y8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715186816; c=relaxed/simple; bh=Yvst0bcnmtYFoAay+PFgd60W17CeqjrTARDMF5hgSzg=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=YkHZVq31rrmO6/26e9Fyne8+6rc9mdCl6QiCC0DnhZFMbwU+EjC8GaC2Arfp+l82Ez6CPwqIW7b6AbkZuo4uIa9cLA4+P3vUmhmwkTauxKCCMYfI8KSKViYhtUvNv//EruDWEZNx4SgoNyQSaFIZRlQ25NNsqyyNgjPMfPU3BIs= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1715186812; 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=aPhdQkVUz+dr3FxKW6fZsG6q3nZxo7a/XW73wZ/ewvQ=; b=CbPXPLZm7pBTi6O+DrjE8ME2m8/qBEB//JFQfH9b4pzRGKyu2C50YTMz/Wbf//zNCsVoYq P5w1vFJEysViEP0whYvEYPfiOksgT+o67gaCQ/jKj3dQ5Lm9KYKX8isE4R4oOqyMbcsDFD SWwbmGa3z4Wt2UlB8UAVqX2rW0/gVvo= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-183-5xINmCrTMmCg4nROwQnLrA-1; Wed, 08 May 2024 12:46:51 -0400 X-MC-Unique: 5xINmCrTMmCg4nROwQnLrA-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-34da4921505so2673783f8f.3 for ; Wed, 08 May 2024 09:46:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715186810; x=1715791610; 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=aPhdQkVUz+dr3FxKW6fZsG6q3nZxo7a/XW73wZ/ewvQ=; b=oARrzOFwAAkm9bK8/+zJK4eSgWT+sM1c+qoN49NIkwPw7jPpKa4/FUn5i6yVkC9J5x 0C4w2w4EMr5mqCeF18LVOLxAggTzw/SQGSd8ECAJ7Og5RprfIDKPHkLtYQoxlq9RMXUG +F4kdCU+dgImHrrMiVm6BRf4S3FKxiCeENwYSVHTTr/notXB2huTDmsvzTQBijy9nY1z Nq/mI+oZ++pDo5upUpRPgsvjGh5LbkV70I01eB+anN0du13RdtDhIQhmLc9qgaQcHNjz cEfHAaCmIQMTUSL2CIwchJlh67Tx1uG+/SRatll4/fVW6TyWoKwuoHQ9IRIi4fJyLPJ6 f7+A== X-Gm-Message-State: AOJu0YycYINnAR9Oj2VfasOhNu8kvcNdrAe4Nvff1YC2gHdJ/noof/o9 st8zGRsd3LjZ1QegIFe1W3c+fB9OUKSNCvlXuWMJhMZzgbPfiSbDx9w6M1yz5hgI52s0wVa7l7Q 18oGIvAPCHBCOH3TVpzZ8eatyZwPAWK4/L/9FrYXwTCW0beTEOM2urubduVN9lS8QzzJLIXZOzS qKYoHZZ//hAKHs4/LwkOEcxXkAa47yqOLes4jyOfhir/c= X-Received: by 2002:a5d:4b82:0:b0:34b:44d7:f3eb with SMTP id ffacd0b85a97d-34fca433f79mr2904410f8f.3.1715186809780; Wed, 08 May 2024 09:46:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEnVFMFee1cuFpNZGyahEtAhDUS0y9kSiI6aHEE4ECOfqB6GMOMXnOu4KAVnBxlUWk8S9IQSg== X-Received: by 2002:a5d:4b82:0:b0:34b:44d7:f3eb with SMTP id ffacd0b85a97d-34fca433f79mr2904382f8f.3.1715186809153; Wed, 08 May 2024 09:46:49 -0700 (PDT) Received: from localhost ([31.111.84.240]) by smtp.gmail.com with ESMTPSA id l18-20020adffe92000000b00350141ea310sm245874wrr.90.2024.05.08.09.46.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 09:46:48 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess , felix.willgerodt@intel.com, jhb@FreeBSD.org Subject: [PATCHv6 2/9] gdbserver/x86: move no-xml code earlier in x86_linux_read_description Date: Wed, 8 May 2024 17:46:38 +0100 Message-Id: <090291eeebe4ea47f86ae85fedbb8d3e449805f8.1715185683.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.0 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 List-Id: 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 Approved-By: Felix Willgerodt --- 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 6de44aeb2d9..e8ef3667eb4 100644 --- a/gdbserver/linux-x86-low.cc +++ b/gdbserver/linux-x86-low.cc @@ -869,6 +869,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) { @@ -885,17 +901,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