From patchwork Fri Apr 5 12:33:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 56852 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 712B5384646C for ; Fri, 5 Apr 2024 12:34:04 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org 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 48CB13858C24 for ; Fri, 5 Apr 2024 12:33:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 48CB13858C24 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 48CB13858C24 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=1712320411; cv=none; b=cymf4MlG9F4d5HDqnAsyKY1c7+NZfEG9M+S/4cmlYcTAdxluzhggUnDjIHw2Av55yPImuDSztSN8NjIq5hEAG2gELcq+Dti0XOu2+AR+U3256OyqEbtoozJ8yaYc3NqvyW+4cd3yBK6LV/Cy7r8QI/bNTBj1RbctbJZS/Vg3cFk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712320411; c=relaxed/simple; bh=+rNVdlSWfuHgskdrxx3t++t+BCLqFTpX/rdDeeEs2WA=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=Ab/cWvMrGM5rMfbz3ZjSop8bfm0krmwiDILFaMrftlzwf46pnCV59eVJn3ITPzIc4bRcYUWlwiqq4iWvXaHYo1eN7oklaqyjpCnPODyXWCrna2t3+EhNRn//R5AkLoi1h7rBqD6DiPbJ6OLddbN2w2792eTQjgmMYXVpRKn+iGQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712320409; 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=h1s+KGBWl6nuxf+IuMawxGa+7Lbqfj0GLpV4T1WuJio=; b=V5k7ItbhdHKhg6K3zwdVYEoJUWEfcwQhBs6N2oKoZ+/kHv4I/qzN4rZ6D2T8mW2Yu7HMek xQp7nEVFD4Lj4u/Vv5hBAGKPXscpv5pRcDQdlRv+8divkva4EzW47eOTMsDA5+zGdKNwGj xLuVBiHplFz8A4Ixvee1R8cB9C0xOQ8= 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-458-6-v5wxITM-yxj4BLBViUWg-1; Fri, 05 Apr 2024 08:33:27 -0400 X-MC-Unique: 6-v5wxITM-yxj4BLBViUWg-1 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-a4751b21400so226947866b.1 for ; Fri, 05 Apr 2024 05:33:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712320406; x=1712925206; 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=h1s+KGBWl6nuxf+IuMawxGa+7Lbqfj0GLpV4T1WuJio=; b=Z5ZYmT3PG7yMSGIdHguRvjLz9DuaUlp0xpku3q4bWJd0QVeF/KxeVy5d+N0NWHdCSG AfsbeAO6nW1l8bh2+Q+EvBiB46ZiTVWjM55th+j5nzVqU7/iaTul6UbemxYfUESRXrTP JCigo/ey7Ou+SsL6Nghv15EzKuOM3SSgwKGzkU+CrUujbxd9SogRr2cxxR91p+eR3oaM oNgza7YBDcsdo8yxM0VpdEQe8c/VxPBGn0O/3rYmIFyOCwunqkR7sJgRYUt/my+Sqyh2 OimZmY6TbB9NArb4AlZX+4zXLlgHpJ7tuwuRvCIlXyxYq3DZgdd6E54NQaqPsiAwrq5o K9Zw== X-Gm-Message-State: AOJu0YwCzbrPH/nJNGNpsy1G5G6GCXfufNvJb1l8bytJdWlEBs/O9wRJ MylvBiodn81N+12go1JsYHhvSA4djgmXw84Ebb/Z24NOYXJBeD33ZjPehBAI1DHiWdbebwIUM0R 8wKAUsoCdXFLFxcmLMXwN32Z00UC6WNwnR9OGJ8jQXqwWS6izWr9rdR9gkOxcuPL/od9HdFU04N l/8RVReWqXTJkAHANy2N75JQsMb1C4C7XxUNkdgmZRKc0= X-Received: by 2002:a17:907:7da9:b0:a51:abd8:8621 with SMTP id oz41-20020a1709077da900b00a51abd88621mr631907ejc.19.1712320405662; Fri, 05 Apr 2024 05:33:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHSXuu3sZ6s+AVmdkOeUJ/IMoWmSsJBBzi+IyllpuhOpKzZr8hQcyMw6qkVqURbj29o6vjqJg== X-Received: by 2002:a17:907:7da9:b0:a51:abd8:8621 with SMTP id oz41-20020a1709077da900b00a51abd88621mr631872ejc.19.1712320405033; Fri, 05 Apr 2024 05:33:25 -0700 (PDT) Received: from localhost (185.223.159.143.dyn.plus.net. [143.159.223.185]) by smtp.gmail.com with ESMTPSA id dr19-20020a170907721300b00a4a33cfe593sm787785ejc.39.2024.04.05.05.33.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 05:33:24 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv4 00/10] x86/Linux Target Description Changes Date: Fri, 5 Apr 2024 13:33:10 +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 X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, 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+patchwork=sourceware.org@sourceware.org In v4: - I tried merging V3, but it turned out I broke pretty much everything that wasn't x86 based when configured with --enable-targets=all, - The problem was a failure to correctly split the shared code between the gdb/arch/ and gdb/nat/ directories, as a consequence, code which is needed on a non x86 based host to support x86 based targets wasn't available to the compilation, and the build failed, - In V4 I've gone through every patch and resplit the code in a way which I now believe is correct, I've done the following tests: + On a non x86 host I've built GDB to support only the current host as a target, to support all targets, and to support x86-64 and i386 linux targets, + On an i386 virtual machine I built GDB only for the host as a target, and for all targets. I regression tested the all targets build for unix, native-gdbserver, and native-extended-gdbserver, + On an x86-64 machine I've built GDB for only the current host as a target, and for all targets. I regression tested the all targets build for unix, native-gdbserver, and native-extended-gdbserver. - Only patches 6, 8, and 10 require significant review. All of the other patches are pretty trivial (though reviews always welcome). - I think there's more improvements that can be made to the x86 target description creation/lookup/caching. This series only changes the Linux lookup, and we still cache i386/amd64/x32 separately. In the future I think we can merge all x86 target description caching into a single data structure, this would be for all OS variants and all ABI variants. Though making that "grand unification" will certainly require some of the code in this series to change, I think the bulk of it will remain, and trying to do everything in one series is just going to result in an even larger series. I'd prefer to get these first patches merged, then come back to build on this work once this is merged and we know there's no problems with it. In v3: - Rebased. Nasty merge conflict with 4bb20a6244b7091 which I think I've resolved, but am unable to test. Reposting so the author of that other commit can validate. - Initial testing looks good. Full tests are still running. In v2: - Rebase to current upstream/master, no merge conflicts, - Retested. --- Andrew Burgess (10): gdbserver/ipa/x86: remove unneeded declarations gdbserver: convert have_ptrace_getregset to a tribool gdb/x86: move reading of cs and ds state into gdb/nat directory gdbserver/x86: move no-xml code earlier in x86_linux_read_description gdb/gdbserver: share I386_LINUX_XSAVE_XCR0_OFFSET definition gdb/gdbserver: share some code relating to target description creation gdb/arch: assert that X86_XSTATE_MPX is not set for x32 gdbserver: update target description creation for x86/linux gdb: move xcr0 == 0 check into i386_linux_core_read_description gdb/gdbserver: share x86/linux tdesc caching gdb/Makefile.in | 8 + gdb/amd64-linux-tdep.c | 32 +--- gdb/amd64-linux-tdep.h | 6 - gdb/arch/amd64-linux-tdesc.c | 61 +++++++ gdb/arch/amd64-linux-tdesc.h | 30 ++++ gdb/arch/amd64.c | 8 +- gdb/arch/i386-linux-tdesc.c | 51 ++++++ gdb/arch/i386-linux-tdesc.h | 29 ++++ gdb/arch/x86-linux-tdesc-features.c | 247 ++++++++++++++++++++++++++++ gdb/arch/x86-linux-tdesc-features.h | 62 +++++++ gdb/arch/x86-linux-tdesc.h | 37 +++++ gdb/configure.nat | 8 +- gdb/configure.tgt | 11 +- gdb/i386-linux-tdep.c | 42 ++--- gdb/i386-linux-tdep.h | 23 --- gdb/nat/x86-linux-tdesc.c | 120 ++++++++++++++ gdb/nat/x86-linux-tdesc.h | 60 +++++++ gdb/nat/x86-linux.c | 47 ++++++ gdb/nat/x86-linux.h | 28 ++++ gdb/x86-linux-nat.c | 123 ++------------ gdbserver/configure.srv | 11 ++ gdbserver/linux-amd64-ipa.cc | 50 ++---- gdbserver/linux-arm-low.cc | 6 +- gdbserver/linux-i386-ipa.cc | 26 +-- gdbserver/linux-low.cc | 2 +- gdbserver/linux-low.h | 2 +- gdbserver/linux-x86-low.cc | 192 +++++++-------------- gdbserver/linux-x86-tdesc.cc | 142 +--------------- gdbserver/linux-x86-tdesc.h | 56 ------- gdbsupport/x86-xstate.h | 20 +++ 30 files changed, 949 insertions(+), 591 deletions(-) create mode 100644 gdb/arch/amd64-linux-tdesc.c create mode 100644 gdb/arch/amd64-linux-tdesc.h create mode 100644 gdb/arch/i386-linux-tdesc.c create mode 100644 gdb/arch/i386-linux-tdesc.h create mode 100644 gdb/arch/x86-linux-tdesc-features.c create mode 100644 gdb/arch/x86-linux-tdesc-features.h create mode 100644 gdb/arch/x86-linux-tdesc.h create mode 100644 gdb/nat/x86-linux-tdesc.c create mode 100644 gdb/nat/x86-linux-tdesc.h delete mode 100644 gdbserver/linux-x86-tdesc.h base-commit: 16810e455feb26ef826a3ed876d6d7e6d24818b0