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 6B97B3858404 for ; Sat, 11 May 2024 10:08:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6B97B3858404 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 6B97B3858404 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=1715422136; cv=none; b=d+W3iDRfrOFpt6MOldt2ayQiIVZn/RVqVyX9IhWQBm6pxORjNNVyePmJb6VlqQSsR+An/NtAHBhijmbogI5D/x+qK4M3opuJIdPEdC+nQMJfTM1+XVbCtxOW7PUNHvNiToIoC5mk+HXCLgzfOzEmz53e9pxfky9QjuhtxkHitPU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715422136; c=relaxed/simple; bh=Yvst0bcnmtYFoAay+PFgd60W17CeqjrTARDMF5hgSzg=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=Vl6CI0ph1zaHMk/BJ8Xa1I0YgCnL10ENCJugvBVDt0o+FH/fDJ29D205M9DXdEb7gAgiw/P7wcBEpATS2MDu7lcfFbZwkPUCCLbH6YPTrpQKTt2F1c2FhyZIAYyI2tPCnLAgfuNIrEcz4ZRj82T2KAFRwPysJvLS0/xNI9meS+g= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1715422134; 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=Pii2aJ1N+5mzSD0BRL+AyhU+R85bJf18f7msyxqqlbrz0Iilv52mUdVw/DMxyrRfhc5bmE 1jsMC8DTsIan0HwvSefVPyoyrz55/rwhvE8HPgssBsBUY9d6KXyyQS01wtrLCWk+BqNi3E FFb95F/lHT3tfdmLxuT2s0x9CkrRRH0= 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-499-B63J26HLOYW4tjSqZtZ13g-1; Sat, 11 May 2024 06:08:53 -0400 X-MC-Unique: B63J26HLOYW4tjSqZtZ13g-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-34db1830d7cso1093258f8f.1 for ; Sat, 11 May 2024 03:08:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715422131; x=1716026931; 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=tfnE71IWTlrJb9M87pTq3/+SLlwRF0qBdQw4KpW5bHHqaKWPiMu9hOFlL8Vd+xzPNL o1pPe64fTbGJuRyYePILThYvEUy6WGuF4AxmAcaIiWjlj8uD8MfVYrIIu3BtN8f7FRgi EZeEW0t7BUqaOBEL6rkaCJVHRYkAEugHTLau3tjCqUSF+sPeVedYKxYfMWuqnzB8r/Kq +yPtiBAJkjkUGSR/siAPuTiEWuE9h1PtLWS14HGOgQz87u61lsBuKu9ss8JgRF5yiUdn 7QRXSL4zWsSsiGYFJdDIGcgFCHFqt3FtlROZXcADufIZsXJ/CDzT8xPEbogidJpKrfgM ISeQ== X-Gm-Message-State: AOJu0YyNJyH2zfb1n64eNU5AjaIPlrkPpicXxhaGKiBHuwUY33o2JD7+ wBnYDphlPnTqjT4WC24DI8KMgypkanY/PMlfD0PXBpacqN1kIlO+TmDdPeOkSrXA3iUFv3gWKS+ uveXpX4nnnmTV12N1f7oA3WgPHrrjKkvugWFPc+S5U2s/Axss/tRMqwPvkd1EDHmB3OxiIFJT2D M7wJ5lyqi4hIutBar+KziPJwIi5Srd3kY+7WGhfKD4jug= X-Received: by 2002:adf:ef52:0:b0:34d:9d2c:8ea5 with SMTP id ffacd0b85a97d-350185d93b2mr7273689f8f.28.1715422131114; Sat, 11 May 2024 03:08:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEZX68++nuTEkQdMNOx3uLqvu1wjwvsZ8B8hT7gPgGGEzxMKjEOoKYviinmG65B1eLBW9sTew== X-Received: by 2002:adf:ef52:0:b0:34d:9d2c:8ea5 with SMTP id ffacd0b85a97d-350185d93b2mr7273667f8f.28.1715422130636; Sat, 11 May 2024 03:08:50 -0700 (PDT) Received: from localhost (92.40.185.101.threembb.co.uk. [92.40.185.101]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3502b79bd40sm6674818f8f.4.2024.05.11.03.08.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 May 2024 03:08:49 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess , felix.willgerodt@intel.com, jhb@FreeBSD.org Subject: [PATCHv7 2/9] gdbserver/x86: move no-xml code earlier in x86_linux_read_description Date: Sat, 11 May 2024 11:08:32 +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=-8.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_ABUSEAT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,RCVD_IN_SBL_CSS,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