From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id CCA9E45+YWYlUygAWB0awg (envelope-from ) for ; Thu, 06 Jun 2024 05:17:02 -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=YfyQa2CV; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 4B6EC1E0C0; Thu, 6 Jun 2024 05:17:02 -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 3641C1E092 for ; Thu, 6 Jun 2024 05:17:00 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E931D38F9831 for ; Thu, 6 Jun 2024 09:16:59 +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 37F3738F980F for ; Thu, 6 Jun 2024 09:16:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 37F3738F980F 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 37F3738F980F 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=1717665381; cv=none; b=U8keS40s0J2I509SX5p4jI4YNCpuZgt3et3+V9st9F0zPNq2NnZIvjqYMzyO446qUCJYD5c3+jETYby3NxhoXNGayXzGZRx+eEM3yQy12LPfGHx8n5EgILj89flXes6PmWX/xNXhqpWoO9vbgyLuyug5YsoPwrqMGh607xZxEDw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1717665381; c=relaxed/simple; bh=Yvst0bcnmtYFoAay+PFgd60W17CeqjrTARDMF5hgSzg=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=OCKEYTOkwLTdVczHm+S+IPR7REtS8R2UCguGySNCs1/ShXatmuFzhgZ4UrIDuny9OyFzeUMmg7kUgP48YmM0UKfAf8KE13Fwk49gXXxMF03DwKscGz6OIvi2HEiaEligKz1/0AXZJXWoaeuKzDusq0xGuyGGyrI7Y+Dk0FE82u0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717665379; 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=YfyQa2CVT3o5oSBokWN2JIwKtFy8aHvK8iV40D9zzljLlKisP4ZKAt0PXhhRrIqeaYJL5E C+OGvduYTEzqK3fiDz8rOfkSfeue96LjzF05vvEfo+UZTByzt1r+FZh0IsCsdawQXm5Os2 vfS8vccNf7mcc1mlkXHvbtM7eQunKok= Received: from mail-lj1-f198.google.com (mail-lj1-f198.google.com [209.85.208.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-518-k2YgQcp-OuGN6buEPFi7vA-1; Thu, 06 Jun 2024 05:16:18 -0400 X-MC-Unique: k2YgQcp-OuGN6buEPFi7vA-1 Received: by mail-lj1-f198.google.com with SMTP id 38308e7fff4ca-2eaa7dfc983so6094981fa.3 for ; Thu, 06 Jun 2024 02:16:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717665376; x=1718270176; 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=k6QzJuRhH9hTWudfqh0F/upADadHSeTHaOk8tKurHnP6atpTFGWXpyxRF8fUdZ+/ps xzWDM35hCHCd/c5l6wbslfePbySJ4ougNqg1oR+zn5yiZajOr713VPjK2gcezN87zFnQ FV5JuDO6vQphQlp32ORfdNI8/ludfI2ooNK2gWQw6rUHmH7toRVdHTAu9bakVWrMOVOo bW1p59JkyhpeY910rtI2fu81VbECVCmyhiAKWMA9orDuAZ0m27178FHJIa70b6t38VGF afkg/VDYUCw9leFzHY4JPTp8y9mv2O5+mTYoKOo6t/aoznMbGOTAD/MAubjoe6IAbBuv ge3g== X-Gm-Message-State: AOJu0YyEeGnyV2934QCWnpeLE9BM7BZk4xZs61aL7p6floJ1gKCuYGbT Wh4KZ2GqYQAlSmvI0iEqjM2r3nDxDJ4vyHzZhtHeYHiKwQqpN9AxqwugNWX2sfWS7GMYsOKchjd eDE1iUApsUvJtkPwt6ciQdl4/tTTMKM8HknmHtPffg52QGY0aaUiE/ZjjbOHsKgBQm/1XFd/d02 FHIXcGm3so06CM5I0ayOIZFNBs+Yr+q9MBWw0j9OdAukc= X-Received: by 2002:a2e:9c0f:0:b0:2e4:45a6:cdcf with SMTP id 38308e7fff4ca-2eac7a70e6bmr27329381fa.43.1717665376162; Thu, 06 Jun 2024 02:16:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHx3yS81uR50/6bnEjgYodLxk90CaTjHQG55/U626KtLEAekzx47fBKfLEo3hoAirvSF+QirA== X-Received: by 2002:a2e:9c0f:0:b0:2e4:45a6:cdcf with SMTP id 38308e7fff4ca-2eac7a70e6bmr27329111fa.43.1717665375564; Thu, 06 Jun 2024 02:16:15 -0700 (PDT) Received: from localhost ([31.111.84.186]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35ef5fc1ca8sm1021568f8f.97.2024.06.06.02.16.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 02:16:12 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess , felix.willgerodt@intel.com, John Baldwin Subject: [PATCHv8 2/9] gdbserver/x86: move no-xml code earlier in x86_linux_read_description Date: Thu, 6 Jun 2024 10:15:58 +0100 Message-Id: <275ad30b5ba034aafc0e992d17a2a60c0f77d568.1717664371.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=-11.8 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, T_SCC_BODY_TEXT_LINE 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 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