From patchwork Tue Nov 22 15:09:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 60982 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 7A5EE3858D35 for ; Tue, 22 Nov 2022 15:10:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7A5EE3858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1669129811; bh=Y5410C1tnkl9MftQazxVXAP+ROaVzwbKtdGVn2lLSig=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=ushZimVSdSMqA8amf+PIyfBVNt11jWsIndChiHFE+SL95hnHGvJ/2Lm424NqgOgx8 8HWxdQvzygAsSRz4C1eenrJE72Ql/iqJjX0WZpvRefiwG+Usv6bqB3DWqyoS766cBx FqGbz+/U6UTBxvGTR+k/B696arjJHBLIyMXD+Jdw= 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 D3EB73858D35 for ; Tue, 22 Nov 2022 15:09:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D3EB73858D35 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-314-udXFa9hIM7S5wF3MCNKasg-1; Tue, 22 Nov 2022 10:09:46 -0500 X-MC-Unique: udXFa9hIM7S5wF3MCNKasg-1 Received: by mail-wm1-f70.google.com with SMTP id 1-20020a05600c028100b003cf7833293cso11130276wmk.3 for ; Tue, 22 Nov 2022 07:09:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Y5410C1tnkl9MftQazxVXAP+ROaVzwbKtdGVn2lLSig=; b=NQNo8oa/XVgUMZMMRLIzXIjQnSsZrZshM9FvrHah3IPs8qZiJu6LnMBhwciwfzX8g8 uhycwGDpa82gBA02UU+uZCiUv1Omefxw5Eafjvp8x9TX+t5QACzbYiVuoIIk7uplQ4xk w9glRMtpCM7vWtD5a13PN6L29XEXO/mfxZ7uRFEUHuu0zBUDrD4A5Kj/BoixvB+6ZSDP gVSYfp8cM7C7A7AIVb/YwMXCrWZcSYaB9nuDlZFWdYYC9m1LSYJ+fmSEbEVTxGGNamp/ uh6P8RDrQn0UdJTtkuqUBGjljDJKo8Jpelf285RhNeUFZANVeUy9xXugWukKbqqout5T 703w== X-Gm-Message-State: ANoB5pmgPGkF6E71lGXP8I1ECiwOu6InMOfpirwt97p18uWOJh8Bg4dk 8o6ZC3ehshnr9zDWzaK3qL8W0X47+uq9swsdIM3EHpeuxVkuMxYxV3eHaVCrm6NTLTgHV7KjIkb ahTkEvzRZEBlJQjBUiUkNPpDgORsbJvha5expTaXBStLK64QG5eJd30k1g8+XpHMOwXuw1DeW1Q == X-Received: by 2002:a5d:6d47:0:b0:230:3652:205 with SMTP id k7-20020a5d6d47000000b0023036520205mr2394306wri.322.1669129784986; Tue, 22 Nov 2022 07:09:44 -0800 (PST) X-Google-Smtp-Source: AA0mqf4an8RSIord7x0EWJL+Tb0SsU+j5vPec0RZeealXDuZ0pZQN/nLeSuo0VCfVzcLDQXgBfocpw== X-Received: by 2002:a5d:6d47:0:b0:230:3652:205 with SMTP id k7-20020a5d6d47000000b0023036520205mr2394294wri.322.1669129784671; Tue, 22 Nov 2022 07:09:44 -0800 (PST) Received: from localhost ([31.111.84.238]) by smtp.gmail.com with ESMTPSA id v17-20020a5d5911000000b00241da0e018dsm4874299wrd.29.2022.11.22.07.09.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Nov 2022 07:09:43 -0800 (PST) To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH] gdb: relax requirement for the map_failed stap probe to be present Date: Tue, 22 Nov 2022 15:09:40 +0000 Message-Id: X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.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 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.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Andrew Burgess via Gdb-patches From: Andrew Burgess Reply-To: Andrew Burgess Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" From glibc 2.35 and later, the "map_failed" stap probe is no longer included in glibc. The removal of the probe looks like an accident, but it was caused by a glibc commit which meant that the "map_failed" probe could no longer be reached; the compiler than helpfully optimised out the probe. In GDB, in solib-svr4.c, we have a list of probes that we look for related to the shared library loading detection. If any of these probes are missing then GDB will fall back to the non-probe based mechanism for detecting shared library loading. The "map_failed" probe is include in the list of required probes. This means that on glibc 2.35 (or later) systems, GDB is going to always fall back to the non-probes based mechanism for detecting shared library loading. I raised a glibc bug to discuss this issue: https://sourceware.org/bugzilla/show_bug.cgi?id=29818 But, whatever the ultimate decision from the glibc team, given there are version of glibc in the wild without the "map_failed" probe, we probably should update GDB to handle this situation. The "map_failed" probe is already a little strange, very early versions of glibc didn't include this probe, so, in some cases, if this probe is missing GDB is happy to ignore it. In this commit I just expand this logic to make the "map_failed" probe fully optional. With this commit in place, then, when using a glibc 2.35 or later system, GDB will once again use the stap probes for shared library detection. Reviewed-By: Lancelot SIX --- gdb/solib-svr4.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) base-commit: 84f9fbe90e5429adb9dee68f04f44c92fa9e2345 diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c index 6acaf87960b..87cd06f251a 100644 --- a/gdb/solib-svr4.c +++ b/gdb/solib-svr4.c @@ -2205,10 +2205,15 @@ svr4_find_and_create_probe_breakpoints (svr4_info *info, probes[i] = find_probes_in_objfile (os->objfile, "rtld", name); - /* The "map_failed" probe did not exist in early - versions of the probes code in which the probes' - names were prefixed with "rtld_". */ - if (with_prefix && streq (name, "rtld_map_failed")) + /* The "map_failed" probe did not exist in early versions of the + probes code in which the probes' names were prefixed with + "rtld_". + + Additionally, the "map_failed" probe was accidentally removed + from glibc 2.35 and later, when changes in glibc meant the probe + could no longer be reached. In this case the probe name doesn't + have the "rtld_" prefix. */ + if (streq (probe_info[i].name, "map_failed")) continue; /* Ensure at least one probe for the current name was found. */