From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by sourceware.org (Postfix) with ESMTPS id 2FD803857364 for ; Mon, 9 May 2022 21:52:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2FD803857364 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com Received: by mail-wm1-x330.google.com with SMTP id v64-20020a1cac43000000b0038cfd1b3a6dso280356wme.5 for ; Mon, 09 May 2022 14:52:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=from:to:cc:subject:date:message-id; bh=hGLrdlQwS1WhGGCr7eQhCbyxH+DKksDIbN0qqn/GbyE=; b=R11doxDAszJwaY847vJZPsVVJsjWmCZKm7GXkI5WKRlEKAmsoHXfFeyawqApW4imF3 HIMfhwSireOWihsn69b0Y5IavFBx5FVkECZ1E0jqoZ4GCERL/0EOJDeZKIvodtWKPdSr IggVIT+3nGWGgXDV1K3aFizUTqWO/lmUBRXlq2CCrm4tg3w8On3jy9iz6nE3oKuAwlGo jen0MuHTWMsg1KcAajmgscNkh/GLXx2xug+Fscdx9WyeDgsafdwl7XnY/6irYf5HE8pw LTkI3u9ZZ0gf0CccTUc+fPvbfLvj65gaq4ygusJ9ujZMMy4ErDvTu+/H7+D4hQ/p1TVB 8mJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=hGLrdlQwS1WhGGCr7eQhCbyxH+DKksDIbN0qqn/GbyE=; b=pMsggEtPfnhqxEnWQiqTQuZDCwjhIYuexRuFmPaBVtgfdRS3SG/YfoBTLNje7imKny wvi/pUBaYmfg0NP049x/8ie8RBXYlMgDR19nuQiBpax2TrSJcHhU1HZRdXkzCaNX7X/A R+GnpYn3VjbCyyrFwRvpK/FPkJOdD6Jjd72lYEx3cPqq1MWIo4Q/opuowWz2ogqkI5kd dmbg9E+KpbxoQVoIKsaZhitfS/flHZH0QDdlZZXs0GpAZp8L5i1iLZ4Nr4bzHI9uFMYU CTLQNSwCwMWBeCrZ66+5+pFIWY7SDdgbvEbuQ+L9c3IlAZmIZBWVbPsfobzgEJK+UFFj Y+VA== X-Gm-Message-State: AOAM530g2NLfQvJFOxkPXsdSLM8UM3W6x7ve5WlxIzUTARl4sZMaOglu Hj9R0Wj6BdXAlJ83mI/6qwhua2RATEbzXg== X-Google-Smtp-Source: ABdhPJyIguFhlaJQgh7dRf4+ZeVuUla9Qal/37gk5T32y00ecjI8hKN1ZuO/fAw5zfRwSFF+OKInBQ== X-Received: by 2002:a05:600c:ad1:b0:394:1585:a164 with SMTP id c17-20020a05600c0ad100b003941585a164mr24849035wmr.101.1652133151906; Mon, 09 May 2022 14:52:31 -0700 (PDT) Received: from localhost.localdomain ([80.0.65.139]) by smtp.gmail.com with ESMTPSA id v12-20020a5d610c000000b0020c5253d8e1sm3821691wrt.45.2022.05.09.14.52.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 14:52:31 -0700 (PDT) From: Craig Blackmore To: gdb-patches@sourceware.org Subject: [RFC PATCH 0/3] Support different overlay systems Date: Mon, 9 May 2022 22:51:21 +0100 Message-Id: <20220509215124.27095-1-craig.blackmore@embecosm.com> X-Mailer: git-send-email 2.17.1 X-Spam-Status: No, score=-6.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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-List-Received-Date: Mon, 09 May 2022 21:52:35 -0000 This patch series lays the groundwork for supporting a wider range of overlay systems by creating a base gdb_overlay_manager class from which new overlay managers can be implemented. This work builds on a prototype written by Andrew Burgess. GDB's existing overlay support works by placing overlays in sections and using the LMA as unmapped address and VMA as mapped address. This restricts overlays to having a one-to-one mapping between a fixed pair of unmapped and mapped addresses. The motivation for these changes is to support overlay systems such as the RISC-V overlay system https://github.com/riscv-software-src/riscv-overlay/blob/master/docs/overlay-hld.adoc that can dynamically map an overlay to any address within the overlay area rather than being limited to a link-time defined address. In the case of RISC-V, the same overlay could also be mapped to multiple addresses at once. The existing GDB overlay support has been moved to the default_overlay_manager class, which is a sub-class of gdb_overlay_manager. There should be no functional change to the original overlay support. This patch series includes a gdb_py_overlay_manager class which is extendable via python code such that an overlay system could be shipped with a supporting python script that contains all the internal knowledge of the system and implements a set of hooks needed by GDB to debug such a system. There are a few changes that I am working on that are not yet included in this patch series: GDB expects to be able to find symbol and line info whether it is using an unmapped or mapped address. However, for the kind of overlay system I want to support, mapped addresses are not associated with the symbol and line info for the overlay, so GDB must use the unmapped address to look up this information. The new function overlay_address_for_sal will be used to tell GDB which address to use for lookups. Breakpoint handling. When a breakpoint is created for an overlay, add a location for each address that the overlay is currently mapped to. When the overlay event breakpoint is hit, delete locations at which the overlay is no longer mapped and add newly mapped locations. Now that we can support more overlay systems, this should be reflected in the GDB documentation. The new python interface also needs documenting. I expect these changes to add to, rather than significantly modify, the existing set of patches, so any feedback at this stage is welcome. I will follow up and re-post with these additional changes later. Craig Blackmore (3): gdb: Move overlay support to new file gdb: Add new overlay manager class gdb: Add support for writing overlay managers in python gdb/Makefile.in | 3 + gdb/ax-gdb.c | 1 + gdb/block.c | 1 + gdb/blockframe.c | 1 + gdb/breakpoint.c | 4 + gdb/csky-tdep.c | 5 +- gdb/elfread.c | 1 + gdb/findvar.c | 2 +- gdb/ft32-tdep.c | 4 +- gdb/infcall.c | 1 + gdb/infcmd.c | 1 + gdb/infrun.c | 1 + gdb/linespec.c | 1 + gdb/m32r-tdep.c | 5 +- gdb/moxie-tdep.c | 5 +- gdb/objfiles.c | 1 + gdb/overlay.c | 998 +++++++++++++++++++++++++++++++++++ gdb/overlay.h | 146 +++++ gdb/parse.c | 2 +- gdb/printcmd.c | 3 +- gdb/probe.c | 1 + gdb/psymtab.c | 1 + gdb/python/py-overlay.c | 409 ++++++++++++++ gdb/python/python-internal.h | 3 + gdb/python/python.c | 4 +- gdb/symfile.c | 714 +------------------------ gdb/symfile.h | 40 -- gdb/symtab.c | 1 + gdb/target.c | 1 + gdb/z80-tdep.c | 1 + 30 files changed, 1595 insertions(+), 766 deletions(-) create mode 100644 gdb/overlay.c create mode 100644 gdb/overlay.h create mode 100644 gdb/python/py-overlay.c -- 2.17.1