From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id KBtBJky5u2XcfA8AWB0awg (envelope-from ) for ; Thu, 01 Feb 2024 10:31:24 -0500 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=Ko2GrL27; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 995721E0C3; Thu, 1 Feb 2024 10:31:24 -0500 (EST) 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 86D231E092 for ; Thu, 1 Feb 2024 10:31:22 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 05687385E444 for ; Thu, 1 Feb 2024 15:31:22 +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 CFF8D3857809 for ; Thu, 1 Feb 2024 15:28:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CFF8D3857809 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 CFF8D3857809 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=1706801331; cv=none; b=E3BuYiyR5seikyoteelDzm4A7nPhM3KDSubtJiSI6PWKzkTC0w2+dqNmbWt0gcpd9CCosDGlRP0x8zJvWkNBlL0NAXWnihXnIQ1Wj13vc2Uq5Z9OJMWJUYbeBXcM19E9IBG2mrKgigcxQ04OjmIY4LSe5uO4NBLLhRHO08kine4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706801331; c=relaxed/simple; bh=9/HqTaCvTazW1RjeOAOizbbNirCf+b+Oq8ruTP8S+qw=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=Lh9mof7eq4VuXmmZWs14nI44otHcJv7I1Ok/7sePp7MabhQ1PE+iJNGJqubx2f56ifdnI2AJnlI9eOrz8xHVa1VUjoEcwksRQ9KjMbEK8CeVW325ff3gls27BXm00iMR5de2lv1ZzslyJO3OediRpPgk03O/yEB7ZoI9GEH4eGg= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706801328; 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=gIxf/Z9eGBVC+AA09DfGemGgR17B1hKcwD9+MJo0YZ0=; b=Ko2GrL27asGrqiYLU3igxYuQrlM4SupXBtqGyHSAZ5t1boLxpPjgWlVY0xY587WpFtjfU+ gh0IP1IqYBPifQ3udH8xu/itRoYDTqoCywI8Eksr2z/sLSoRhSzoF8ym2CTvSY5NyJVTvq rrMyUyfdXEM6k2Kweoq7gGGfhLrEyQI= Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-177-v0tMEJT1NL-PuzhcX7sUkg-1; Thu, 01 Feb 2024 10:28:45 -0500 X-MC-Unique: v0tMEJT1NL-PuzhcX7sUkg-1 Received: by mail-lf1-f69.google.com with SMTP id 2adb3069b0e04-50e91f9d422so1189921e87.2 for ; Thu, 01 Feb 2024 07:28:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706801323; x=1707406123; 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=gIxf/Z9eGBVC+AA09DfGemGgR17B1hKcwD9+MJo0YZ0=; b=gjqeO8WmnCp9w2UQ0JkQ1zt+veaJZGNUpc3+2YOmPpExdB0PBLtCxHh7UFOCjdr2R5 JgDc164sfvgi7YdUVaShNLHcvObHRiYS8vWDIvn1pDCxnOe8XyDK8hBZ96JegvRRVXbn BevmXay02jgLo5bN8PcY1oX4JOGjJ64Nd5uXkFkh+L7EamTKHDtEzJCGZIWel98g9dsE Tu3ILBAgxwTBaDELMYC7l0AMIdSdIROpAEI8FHOqUVQVjSTGEhgCq9DyEsV8zOtpLDAC ivvA4guxF2Wfc1fgWl8BTgCwd+h5viBOCSOtakwd889xW8gCLhEcVJsa+tHD8oOd/7hk o5fg== X-Gm-Message-State: AOJu0YwhIqTIzgxDFGngWdymt7CDoec01HKkOl7b8vjJysSpIdScgwNW w2HJaBQMjKrV7zOrAIkZhkoGp3KFs7ZOl8Z/tp29takKedRV+SQ695jtv1K7MLdYD32feMdMfal VfVd6j+7EhQFLJYKHlRuIo4h1hWwfxrqAVs8Or24GaHdg7eDc/O9s84DnVWYGohMZ3Poqg6+PUN QWOkJCMX67SthFOy31lPBie8sgZILo6bGpZUF0FkbHftM= X-Received: by 2002:ac2:4188:0:b0:510:253f:32e0 with SMTP id z8-20020ac24188000000b00510253f32e0mr1930438lfh.11.1706801323024; Thu, 01 Feb 2024 07:28:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IHKYJKDqUsltw2KVo4lwI+xQkUGVmtQ7gW+QMqaIdZ55XuUeeONzXp3FS4fZ4hdGiXGvhM95A== X-Received: by 2002:ac2:4188:0:b0:510:253f:32e0 with SMTP id z8-20020ac24188000000b00510253f32e0mr1930419lfh.11.1706801322560; Thu, 01 Feb 2024 07:28:42 -0800 (PST) Received: from localhost (185.223.159.143.dyn.plus.net. [143.159.223.185]) by smtp.gmail.com with ESMTPSA id u7-20020a05600c19c700b0040fbe0ad3efsm1613601wmq.45.2024.02.01.07.28.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 07:28:41 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 3/7] gdbserver/x86: move no-xml code earlier in x86_linux_read_description Date: Thu, 1 Feb 2024 15:28:30 +0000 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=-12.7 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_H2, 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. --- 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 0a3bd2c8670..ec80bfe905c 100644 --- a/gdbserver/linux-x86-low.cc +++ b/gdbserver/linux-x86-low.cc @@ -891,6 +891,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) { @@ -907,17 +923,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