From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id MCHYCOXvD2YqYiQAWB0awg (envelope-from ) for ; Fri, 05 Apr 2024 08:34:45 -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=eYyWpZTW; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 1603E1E0C0; Fri, 5 Apr 2024 08:34:45 -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 DFFC11E030 for ; Fri, 5 Apr 2024 08:34:42 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4CB8C38449C9 for ; Fri, 5 Apr 2024 12:34:42 +0000 (GMT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id E186D384772B for ; Fri, 5 Apr 2024 12:33:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E186D384772B 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 E186D384772B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712320419; cv=none; b=AfvYnaOyKS7ZdwZlytCu+4B5ICR5Qm67xXK3099KNaQLzo5waXdafLGMbmedlfE4uy+ohdCmhWtspV+GN/4F4v+3aapagyChdBxqIrvIxgEgGgtRqplfD8yNN/4HG6wX/94wH5WKU+NnF7EVVBMDlGcrZ4fyA2Ti3pasoAkpAKo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712320419; c=relaxed/simple; bh=hpedPXBi1NQ75POSVXWRR9e0QAsy4RnQdDvdOVf5p9s=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=uuToTHRKMUbvManuVt/5f2aqJ0L+g0R8UFyBadVUo6uzRA7YZGOxeEiUp2cypL/h7SvXUtEvxoujNJOJjPq6jGrxioGLgSh/NPk8nUpdsc0sb5OOg4vY183Xh9iD4L+hrWtqbRtjsHa5jhQtnPZjwKNiz2f+Y9IMkt7kdd9iiFw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712320415; 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=J8ResLLCWHmStqicnub/KJPH/xhy7xorDRr5Chm4IDc=; b=eYyWpZTWBLrmcMcFbtu8ZsZSboPDik7oDQ0xPWJZ8S7mHoeAHYPRfEt1ZJVzzpLmWNZzHS ahmYVKyCEVc5amZtu4CzphPLA6FVInDakYV/Siy5iyFv71WvdlD5hhik7n/bu0KtQR2Unm //uHe847JmEhrHapO+VPZoBvtWlmJ10= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-632-ZVI9GDekMf-7wiaHA-XCmw-1; Fri, 05 Apr 2024 08:33:34 -0400 X-MC-Unique: ZVI9GDekMf-7wiaHA-XCmw-1 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-a4e05cee8faso88350866b.1 for ; Fri, 05 Apr 2024 05:33:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712320412; x=1712925212; 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=J8ResLLCWHmStqicnub/KJPH/xhy7xorDRr5Chm4IDc=; b=K7gzP5u3AHO7vzblMWDJ/tIAYWVCdIezp0NpT4lXoW08j3xrkAX7AFtuHOs+6v24gn mrcO1k4kF5/vzUe/tLjl1Oni+zfQmx94rvigxPV0G6nXyr5ISN6vsfZmQjaX9JxO1IJ4 6CcL55t0oWCVsmxgHqCJ1PKpK6zMHzBkRIAxsLWhkOqYVokrNB55/b0+4U6uYTjCRzl1 PmxVPG6+iv4QuFHMfK1uxB7yTmZCaH//ZQbBtd/ej/7Q84EfdC7G79qhgc+Mv/m/iF0s /EaadG62LsmACD1XNsvbBqUlrJYEU3H+XqypJFW4xSoG8yx2Ralnh43q1fzv4VK8OGc6 HvYA== X-Gm-Message-State: AOJu0YwHpdHZNqNPRGfS/oKju/CA5j8u3K4KDC0SpPw7gCrRIauPscum k5DQNwThfzJarbbCE0h7eSyR6q+mlc9yl8tmQC9iaUzhmB0K2WeQbvsBkRQ2cBiXlS0V7Aiv9gQ 8CZYGDDNRCAPW5R2kyzoCDLaPF+xsc8lwz6hAukR5rvREtVCbSylq5BTLdVT/a4a7mB8Frjsq3O VxMrm9mEGpaWQp23XPxGRAs1KLQKVWoQ90k2wlGwRd6qU= X-Received: by 2002:a50:d61e:0:b0:56e:359d:fcea with SMTP id x30-20020a50d61e000000b0056e359dfceamr521193edi.34.1712320412457; Fri, 05 Apr 2024 05:33:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHb57APZRVXHzgh9CAGSx7lBpTSKjpIpJYHA7L3FmgtWkmcDDksmNWYrx3cJ6tmMp4Z42HKAQ== X-Received: by 2002:a50:d61e:0:b0:56e:359d:fcea with SMTP id x30-20020a50d61e000000b0056e359dfceamr521175edi.34.1712320411865; Fri, 05 Apr 2024 05:33:31 -0700 (PDT) Received: from localhost (185.223.159.143.dyn.plus.net. [143.159.223.185]) by smtp.gmail.com with ESMTPSA id h1-20020a0564020e8100b005682a0e915fsm738893eda.76.2024.04.05.05.33.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 05:33:29 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess , John Baldwin Subject: [PATCHv4 04/10] gdbserver/x86: move no-xml code earlier in x86_linux_read_description Date: Fri, 5 Apr 2024 13:33:14 +0100 Message-Id: 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=-11.9 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 2603fb2ac5d..eeeddcb9429 100644 --- a/gdbserver/linux-x86-low.cc +++ b/gdbserver/linux-x86-low.cc @@ -890,6 +890,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) { @@ -906,17 +922,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