From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id +T1YF+VV2mrvWAwAWB0awg (envelope-from ) for ; Thu, 22 Oct 2026 14:28:53 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=iNj6C+Zr; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 5CA36378002; Thu, 22 Oct 2026 14:28:53 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (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 BF9D11E007 for ; Thu, 22 Oct 2026 14:28:52 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5B8294BA2E2A for ; Thu, 22 Oct 2026 18:28:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5B8294BA2E2A Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=iNj6C+Zr Received: from mail-ot1-x32d.google.com (mail-ot1-x32d.google.com [IPv6:2607:f8b0:4864:20::32d]) by sourceware.org (Postfix) with ESMTPS id 9DF194BA2E0F for ; Thu, 22 Oct 2026 18:28:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9DF194BA2E0F Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9DF194BA2E0F Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::32d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1792693702; cv=none; b=ADcmbRta81rrTaxydb9MahmoZjyZjky1HjN7m46p1p4RDcqQ1sAbrGXejb6SS6OUL8RFMjUx8Pbqb6LZ4vBUVIn120EEHvBvYixBgDaLMtqt5v5i8Cf4Icz7tcvpmSV23FPogNvdy2Y/6aKScJ/CvyepdgS3B8vihU5mIkWoVco= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1792693702; c=relaxed/simple; bh=e18h7rCPGQND8g1PKOkake2CINo4KDUvL7RWGP35Abc=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=Uc3WOxGUcQFe0RZVNPVBvZG+nQ6Lu0b1Kn9CtjS+WcM28kmOdxJtEB5w07JfBa/+IGHQe3oRxFdZ3czJiiIaHd5Mu0JCoWI77OLKVqz1q50OQ5oC2oQ9sKMiShs+lSZe9ckG5QL/SmwRNli2naEQKHI/benaotJ43rQEqmD2oxY= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=iNj6C+Zr DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9DF194BA2E0F Received: by mail-ot1-x32d.google.com with SMTP id 46e09a7af769-8479f46ecd8so29486a34.0 for ; Thu, 22 Oct 2026 11:28:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1792693702; x=1793298502; darn=sourceware.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=4XPitEBFfGHobzI6axkphjM6esIwMRmxZQArGVjnewY=; b=iNj6C+Zr2JRwg9hBFreCuYTMhKKM/L8ktsGw3YjdFxRRGgbS2SVl5rMRzmdvV85DqN xEwZm2cNrLb9NPnvocc1BjjNfPr8DpHv9cc9x4Oupb2O9etPRzqBlYmLzLQTFSTuyWyZ 7kTxq739cEQrfGpT4HqSgYM1T64ipHLyRSGjZdYf2UzllV6ppbT7FftfYgaLWbBV/BfX kToMwNyleR7QIIqidOi7AlY0gU8nA3gStgPRPBLj3P63qdJyXaorn6n8oLlh86oQDldR cKBNCJO5pOBYdMjLzGakCp/o3OENCLcY3yCZ0pNAIjER8VFm18KJfYjPahETbI5JPuX5 OYTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792693702; x=1793298502; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=4XPitEBFfGHobzI6axkphjM6esIwMRmxZQArGVjnewY=; b=zApkAHWrU6TuU5i80lOg70aseoxed7EFwJvFGq2oldPreLI3hDdvmbbkrDAmEkSgEo MLlHgy6yvNGqmHrDF0mUAUwH8/CyYKHGAE7ryy6BcdhWwZUHZKtVWb9wXMUaHf22eLuo mXeWtdrHOS7DPacXXcj6hHsY9Mh0Xj1rdrMxSWX74bh3t0xnEGtiP0xIHxcKsdkbhQwT LFaYwUBBQLsR/79UyDcZqQ+a7m50bJr39H7eEa/2yD2uI3ZWTUkQMbM0WQ/Sj82MrGg6 tzXVmHGYB3hW4H597Z73K2pTlVKmb59ZdIAo4bZL5aLyiBumhfDqy+fedonyYRqD7hEx uJxw== X-Gm-Message-State: AFq9FYK0smZHxd+M03O/uSIlLbV1/NdO9rXhe4wHnL9lbvBbZ97lz8ho qan8WW0iZNm9wOwLrizSgUrlphpafq0wVW7hFXBaRPXs9czlCIGKsAvh9YhZTV1cXoY0KzAYpsd jVj0ytw== X-Gm-Gg: AYBFou2gH+hG+CXmF0f3EIVdUT90aGkpSS3ttUD+eBv5TvTWrjGz3VINmMqKwOQbcWI 5OXdOPoLdRNECvjbtEdgPc/YqvFtvZ+GywccyeSlnXVUd2GNIpgn8Wjt4o9GyQ6KU5nT0GHhQL1 JQRspKaZPkLJZu99iRMoXv+a6yVLzlJ7HF4Wv15XuFHaRVs+gs7T9kze66o8UK2ISBGbuj3Ys+a yTjb1u6HCa6+8L0Y+x8gxGTGpqfCFkvtN+tpLo0RQo5VF6g4hFD92mzTTFB/PXLdNonepiORrAc w7CT+jBUNmU5MaUEbVpspHHWYoMshAYDcZWRud42sz5AR67/OO+PxsOdYGgaSWkEWTUWeG6FgBH gagG+bC62KZGhR1pQCo5z3i5ZbdzyGi7xwxhGRg8WH244oEdvgaXjxesgRKMTaRdx79H5enOr/R VA/4mA5VgwQ45GW5Hj5+9NePLwZ57zDBR3LXyRJuakRxlrNljiCiNVu8SU7G6Ler52j8iw0DWZn Wk2LXxjzQTUkyS7+eCHL1t8hyeOqY/IJRJMfZm4ahEB2SBHEQbSF+GLST5albRnPISV2RQFL7jW R3gjN4Juh1lzgg== X-Received: by 2002:a05:6830:4ac6:b0:835:63b5:8b7b with SMTP id 46e09a7af769-84d0810557cmr4979082a34.10.1792693701831; Thu, 22 Oct 2026 11:28:21 -0700 (PDT) Received: from [192.168.0.26] (97-122-110-129.hlrn.qwest.net. [97.122.110.129]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-84f784f3c50sm419557a34.21.2026.10.22.11.28.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Oct 2026 11:28:21 -0700 (PDT) From: Tom Tromey Date: Thu, 22 Oct 2026 12:28:13 -0600 Subject: [PATCH RFC 3/6] Allow missing build-id when finding an objfile MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261022-android-apk-file-v1-3-8444bb5f832a@adacore.com> References: <20261022-android-apk-file-v1-0-8444bb5f832a@adacore.com> In-Reply-To: <20261022-android-apk-file-v1-0-8444bb5f832a@adacore.com> To: gdb-patches@sourceware.org Cc: Tom Tromey X-Mailer: b4 0.15.2 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 Currently the "missing objfile" code requires a build-id. However, in my situation, the build-id is not known. But, aside from this small detail, the missing objfile code looked close to what I wanted to implement. This patch extends the API to allow the build-id to be missing. In this case, None is passed to Python. However, because this is an API change, MissingObjfileHandler is also extended to record whether the build-id is required. And, by default it is required, so that existing handlers won't be called in this new situation. --- gdb/python/lib/gdb/__init__.py | 17 +++++++++++++---- gdb/python/lib/gdb/missing_objfile.py | 4 ++++ gdb/python/python.c | 17 +++++++++++------ 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/gdb/python/lib/gdb/__init__.py b/gdb/python/lib/gdb/__init__.py index 1a4aefcd802..f16e0a66c5b 100644 --- a/gdb/python/lib/gdb/__init__.py +++ b/gdb/python/lib/gdb/__init__.py @@ -382,7 +382,8 @@ def _handle_missing_objfile(pspace, buildid, filename): pspace: A gdb.Progspace for which the missing objfile handlers should be run. This is the program space in which an objfile was found to be missing. - buildid: A string containing the build-id we're looking for. + buildid: A string containing the build-id we're looking for, + or None if the buildid is not known. filename: The filename of the file GDB tried to find but couldn't. This is not where the file should be placed if found, in fact, this file might already @@ -403,9 +404,17 @@ def _handle_missing_objfile(pspace, buildid, filename): missing objfile. """ - return _handle_missing_files( - pspace, "objfile", lambda h: h(pspace, buildid, filename) - ) + # Delay this as long as possible. + from gdb.missing_objfile import MissingObjfileHandler + + def maybe_call_handler(handler): + if buildid is not None or ( + isinstance(handler, MissingObjfileHandler) and not handler.buildid_required + ): + return handler(pspace, buildid, filename) + return None + + return _handle_missing_files(pspace, "objfile", maybe_call_handler) class ParameterPrefix: diff --git a/gdb/python/lib/gdb/missing_objfile.py b/gdb/python/lib/gdb/missing_objfile.py index 45661d0f415..fe45a418c6d 100644 --- a/gdb/python/lib/gdb/missing_objfile.py +++ b/gdb/python/lib/gdb/missing_objfile.py @@ -30,8 +30,12 @@ class MissingObjfileHandler(MissingFileHandler): Attributes: name: Read-only attribute, the name of this handler. enabled: When true this handler is enabled. + buildid_required: When False, this handler can accept a + request with buildid=None. """ + buildid_required = True + def __call__(self, buildid, filename): """Handle a missing objfile when GDB can knows the build-id. diff --git a/gdb/python/python.c b/gdb/python/python.c index 5a9c876c197..06ad0876527 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -1950,7 +1950,6 @@ gdbpy_find_objfile_from_buildid (const struct extension_language_defn *extlang, const char *missing_filename) { gdb_assert (pspace != nullptr); - gdb_assert (build_id != nullptr); gdb_assert (missing_filename != nullptr); /* Early exit if Python is not initialised. */ @@ -1960,12 +1959,18 @@ gdbpy_find_objfile_from_buildid (const struct extension_language_defn *extlang, gdbpy_enter enter_py; /* Convert BUILD_ID into a Python object. */ - std::string hex_form = bin2hex (build_id->data, build_id->size); - gdbpy_ref<> pyo_buildid = host_string_to_python_string (hex_form.c_str ()); - if (pyo_buildid == nullptr) + gdbpy_ref<> pyo_buildid; + if (build_id == nullptr) + pyo_buildid = gdbpy_ref<>::new_reference (Py_None); + else { - gdbpy_print_stack (); - return {}; + std::string hex_form = bin2hex (build_id->data, build_id->size); + pyo_buildid = host_string_to_python_string (hex_form.c_str ()); + if (pyo_buildid == nullptr) + { + gdbpy_print_stack (); + return {}; + } } /* Convert MISSING_FILENAME to a Python object. */ -- 2.56.0