From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 4Tf/M0dW2mrvWAwAWB0awg (envelope-from ) for ; Thu, 22 Oct 2026 14:30:31 -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=kl1d2kcD; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id D0BFC378002; Thu, 22 Oct 2026 14:30:31 -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 188AB1E007 for ; Thu, 22 Oct 2026 14:30:31 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 968544BA2E2F for ; Thu, 22 Oct 2026 18:30:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 968544BA2E2F 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=kl1d2kcD Received: from mail-ot1-x32b.google.com (mail-ot1-x32b.google.com [IPv6:2607:f8b0:4864:20::32b]) by sourceware.org (Postfix) with ESMTPS id 01B334BA2E2A for ; Thu, 22 Oct 2026 18:28:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 01B334BA2E2A 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 01B334BA2E2A Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::32b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1792693705; cv=none; b=ON2VU3IccO5DypC8PfZvhy+WOCWVsNZd7eG7BNO/25JljMzChNGGv5zmFJkO3OXEnTPc+s9Osc3DmhMcLp/LWuPuHhC4pOeyfjmBCVYGI9LljQ8kjr55U5wdVqmFf1Cu/hLQY+4GxPI92cV9BaVVQ9aeT5Plmd0eQitrrF/UNeU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1792693705; c=relaxed/simple; bh=w+xIoiyeqvAqB/DW74ij/9g/ha7Tjj4Z8XkIrjF4CLU=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=VKxvAi+J34BOFDgfoRmMRUwIzADH7fUgQYJKeeXYxtOo4MV9wqcw/7NyxoP3r/JZ3O9kLsB3hIxfmF3lWe8SUfBWZHFYCTAeh+a3c5rCUfvnRBSOC8xt24kDsi+zzyzWF1SkHcKZSnLZGVxo3YKIolo2APsEo846AsBh9goYyp0= 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=kl1d2kcD DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 01B334BA2E2A Received: by mail-ot1-x32b.google.com with SMTP id 46e09a7af769-8439fe796ebso26607a34.3 for ; Thu, 22 Oct 2026 11:28:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1792693704; x=1793298504; 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=UIMOg5Lo4DSXVBb5XtcAr81SimOEY6CWGjjv3PnFNOE=; b=kl1d2kcD61sa03/yeIXIDvkAd3wdaEK19/jRvadorzGiPrjz9NVpoice3KrtXKizHl upxZPBkK6GZ63leDHz543bsOe6gE9nD9fxxWzryOUzQ6yEBikmBOXaY+HROgdKdZS2es h55r3NS/GbMADoZ86RXCUaorypX5sjpuIOH+XAFOmmRTSZNdR0kS8ugpZjZLeSHZLK5h V5CJUV18NEQ093FlvR586AqWuQ76SnfGUl/ZyUQVtCd5O+i+J/lF3NVFU3UUS5V44VXy +Q55a57KM24Z5bEGnTv4vAC/YAxyYo/mDRMTAiovImUoEzIDyYZWGU1GDhLfDZj6uFU9 yHbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792693704; x=1793298504; 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=UIMOg5Lo4DSXVBb5XtcAr81SimOEY6CWGjjv3PnFNOE=; b=jVpqi6XeA1t3zGqyrIIQuv5k83ErJKgD9lCxIZ1CDinv8lqqHhCQeloZy/goxac6Ep NdL3pRaExmNKOMRyDoP+b7pSVqLZ2Xm//22yzB+kYjklHGtlpISGY56KFZs2Ty2KnJ+B j+ZzUGH7mSJDAB9m8fvoxhV9Z9KbG00t/GlyxcKeBD4xNupCMejx4mUT4PVN9QdAZ9tz udl+mVHtmkXyr32x5aUhWgL9hGclx83HKoNNP57CH8Rm1TQ33q5PoJuv2HIPkTKH0Dk/ wmaSDTLbwPsELzcl3CokNarYJ9OXk3d9FK/iku8OG48lS0zPLhN2Tirh/OQ3fcZxrPWL kRTw== X-Gm-Message-State: AFq9FYIMYfG8eV6N5t4RTs770c4WG4BpyJ32fuNX7jOswlHg7Yvpte7P ayCaNorpK7RPcYSOmBIfvozZHsxmNvXOVf4YgTd6yOprZ/McbWYvAw3DtcI+gYTCEgeTL/c4rRu h+j5CGw== X-Gm-Gg: AYBFou3hW3JobGV2noI7SQdXe9LoCCv6MOpEcCjazUGDqH1R+U/ERG9d1v9Gp3litFl 9S6nSXO39YAKzXDvHhXxaqABt6d/bH7ngKm3ZIZJM//nuKXnJkJnK7tq/FTOY5II+RZJRc90Wcw JuaOO7MVZbMHkUkQIrw7mPZilgr6fVGVINVobtmiN3EtWkp1ylzV2LriqHZmDxYAYo+zIUK377y rkfPh0PEGTClZ7YbeJLCzM3+lk0GmiZJ997lAKR6CSiP5t0yQXMdCO1SRu8kdtSd8ksMpCmOY6o q8VR2IZQKXcLppumJY0f+nUKdnbSiXT4lJrcPTXvBL/lFQf7z65kl5m5Rw9aiGR5u4JFKOi86R1 ovRL117RrRRQ9hto6twih8q7dpBDq7Rw3qn/1vJgIv2TJNn6wNhpNx6tak7wbma0qU2rviqoXpm Y1oeGiBm4lt+yi81WlU42O6dietiJvo8plKHhEktR+pe/le5MVWrShu8Azc0YUXZPmtDA9yO/bD O+gDXeocl/u/Nwxw+jMvg3S9ouf7XATmakBL4eHJesVEb/Z51nMUNeatYGbuDh31vuq2f3nWz6Y biwJUooTDXbHAg== X-Received: by 2002:a05:6830:2b29:b0:829:2af1:a07d with SMTP id 46e09a7af769-84d07a0521emr5314330a34.5.1792693704217; Thu, 22 Oct 2026 11:28:24 -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.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Oct 2026 11:28:23 -0700 (PDT) From: Tom Tromey Date: Thu, 22 Oct 2026 12:28:16 -0600 Subject: [PATCH RFC 6/6] Add gdb.handler.android module MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261022-android-apk-file-v1-6-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 This adds gdb.handler.android and arranges for it to be automatically loaded. This new module provides a missing objfile handler that knows how to extract a .so from an Android APK file. --- gdb/data-directory/Makefile.in | 2 ++ gdb/python/lib/gdb/__init__.py | 2 +- gdb/python/lib/gdb/handler/__init__.py | 14 +++++++++++ gdb/python/lib/gdb/handler/android.py | 43 ++++++++++++++++++++++++++++++++++ 4 files changed, 60 insertions(+), 1 deletion(-) diff --git a/gdb/data-directory/Makefile.in b/gdb/data-directory/Makefile.in index 7257da9cd11..3c272efb982 100644 --- a/gdb/data-directory/Makefile.in +++ b/gdb/data-directory/Makefile.in @@ -124,6 +124,8 @@ PYTHON_FILE_LIST = \ gdb/function/as_string.py \ gdb/function/caller_is.py \ gdb/function/strfns.py \ + gdb/handler/__init__.py \ + gdb/handler/android.py \ gdb/printer/__init__.py @HAVE_PYTHON_TRUE@PYTHON_FILES = $(PYTHON_FILE_LIST) diff --git a/gdb/python/lib/gdb/__init__.py b/gdb/python/lib/gdb/__init__.py index bc47585378c..2f2bbb98569 100644 --- a/gdb/python/lib/gdb/__init__.py +++ b/gdb/python/lib/gdb/__init__.py @@ -152,7 +152,7 @@ PYTHONDIR = os.path.dirname(os.path.dirname(__file__)) # Packages to auto-load. -packages = ["function", "command", "printer"] +packages = ["function", "command", "printer", "handler"] # pkgutil.iter_modules is not available prior to Python 2.6. Instead, # manually iterate the list, collating the Python files in each module diff --git a/gdb/python/lib/gdb/handler/__init__.py b/gdb/python/lib/gdb/handler/__init__.py new file mode 100644 index 00000000000..d28abe3fc3f --- /dev/null +++ b/gdb/python/lib/gdb/handler/__init__.py @@ -0,0 +1,14 @@ +# Copyright (C) 2026 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . diff --git a/gdb/python/lib/gdb/handler/android.py b/gdb/python/lib/gdb/handler/android.py new file mode 100644 index 00000000000..2febf851dd5 --- /dev/null +++ b/gdb/python/lib/gdb/handler/android.py @@ -0,0 +1,43 @@ +# Copyright (C) 2026 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Missing objfile handler for Android. + +import gdb +import gdb.missing_objfile + + +class _AndroidHandler(gdb.missing_objfile.MissingObjfileHandler): + buildid_required = False + + def __call__(self, pspace, buildid, filename): + elts = filename.split(".apk!/", maxsplit=1) + if len(elts) != 2: + return None + initial, member = elts + apk_fd = gdb.TargetFile(initial + ".apk") + + import zipfile + + apk_file = zipfile.ZipFile(apk_fd) + info = apk_file.getinfo(member) + member_fd = apk_file.open(info) + + # Use the full filename here so the user can see what is going + # on. + return gdb.missing_objfile.BFDFile(member_fd, filename) + + +gdb.missing_objfile.register_handler(None, _AndroidHandler("Android")) -- 2.56.0