From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-il1-x12e.google.com (mail-il1-x12e.google.com [IPv6:2607:f8b0:4864:20::12e]) by sourceware.org (Postfix) with ESMTPS id 32F663858D38 for ; Tue, 22 Aug 2023 15:25:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 32F663858D38 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-il1-x12e.google.com with SMTP id e9e14a558f8ab-34ca07e6d6cso9059055ab.0 for ; Tue, 22 Aug 2023 08:25:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1692717911; x=1693322711; h=to:content-transfer-encoding:mime-version:message-id:date:subject :from:from:to:cc:subject:date:message-id:reply-to; bh=dCLoEryNiGp9/bCTazpuoc/x+BkJ6AVMReehxPavP+4=; b=hlylqRyRTwNOBx4+N8jm16tlKeBR7NJaHClw8mm0Maiv7ISrvu7lx/j9Hi5wKj2EP1 BH//vnkQ44ZzJfzGlo5ZJRw6i87WXDu7TKv3aqAIcfKvwYBOpH9RokeZNvoJk/AVKzeO XSMvLUhKplBLdD5T/mPVZ79cIo5nnCnkJhB4wYu8tEbRGDHzfddzkJ9IDeJfctYvLzO/ WsJAZbJnNQ/7FQ8Elnh3gZv4gUJmaErYTz7wzN5Esy9MFsqtNgApDnUzuyPP/Yp51mVN SzsVheT792dhZ0wjRXkvPsh5uKC9Xo5LnqESDKe0uAYz7jAk4QedZa4M+OEaqrmjO+mQ tvqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692717911; x=1693322711; h=to:content-transfer-encoding:mime-version:message-id:date:subject :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=dCLoEryNiGp9/bCTazpuoc/x+BkJ6AVMReehxPavP+4=; b=bSQak6Y48EVxHeqh74EjMB2NM6cdcYi1EgXfOg05G0VW7vj1tZDdgbvww9BJzQ4dg4 k8XIz3joSy87MjPTrYEo2MFnYO9X9NAqKRZXl/vRzwCB6wL6c19cVrgqc1YHiCayWGbq d+jNLa032HaNNR0wVYl2nsKYM93kOjq/cEI2uI5Q7Ox3g8Dfz6DU6ksGE1ieDu/4yUHE HPHyWubQZrclBhLKVYOPag6SW4Wa5wl9sqYIaiJHr5yQNaXltyXrlo0bD6W8ZwzHUIDA 01Udq493IzOMmuLcc8o+AqKpX9uFQ53EB2et8v9DQyGgpQgwdYUBvyz4vfptXdCEziQ3 QHFA== X-Gm-Message-State: AOJu0YxbFSdR+1JZJ95vUK67zi4ue75AHjkgSsFJGyajlZ4uLdhCt/tl n4Wie7rZLX42uLnvcPZXbfyITJIkF3d8KZvLzapg1A== X-Google-Smtp-Source: AGHT+IExYohxSmSKjDgzY0RxUTfmfClnqB1MGi1OtslsGrXhfQhlGk8cooW05wzJrA8yp99Evzo9oA== X-Received: by 2002:a05:6e02:1d9d:b0:345:a6c5:1ce8 with SMTP id h29-20020a056e021d9d00b00345a6c51ce8mr25634ila.14.1692717911335; Tue, 22 Aug 2023 08:25:11 -0700 (PDT) Received: from localhost.localdomain (75-166-142-177.hlrn.qwest.net. [75.166.142.177]) by smtp.gmail.com with ESMTPSA id e8-20020a92de48000000b003460b8505easm1721608ilr.19.2023.08.22.08.25.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Aug 2023 08:25:10 -0700 (PDT) From: Tom Tromey Subject: [PATCH 0/8] Handle array- and string-like types in DAP Date: Tue, 22 Aug 2023 09:25:06 -0600 Message-Id: <20230822-array-and-string-like-v1-0-2dcea29b0567@adacore.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIAFLT5GQC/x3MQQrCQAxA0auUrA1Mo+DoVcRF2knboEZJSlFK7 +7o8i3+XyHEVQLOzQoui4Y+raLdNdBPbKOglmqgRPuUiZDd+YNsBWN2tRHvehMciE+HthxzTgS 1fbkM+v5/L9fqjkOwc7Z++t0eHLM4bNsX/SELTIAAAAA= To: gdb-patches@sourceware.org X-Mailer: b4 0.12.3 X-Spam-Status: No, score=-5.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 autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: A co-worker noticed that some Ada array types did not display properly via DAP. Looking into this, I found a couple related problems. In Ada, some arrays are represented as structures. The Ada code in gdb (ada-valprint.c and ada-varobj.c) know how to display these as arrays, instead. Also, in Ada, a String is just an array of characters, and again the Ada code in gdb understands this and displays them more naturally. Similar cases occur in Rust. After thinking about this for a while, I decided to try to take a relatively generic approach to fixing this. This series adds some Python API so that Python code can know if a type is "array-like" or "string-like", and then changes the no-op value-printers to use this information. All the tests are deferred until the end of the series. --- Tom Tromey (8): Move rust_language::lookup_symbol_nonlocal Refactor Rust code for slice-to-array operation Introduce TYPE_SPECIFIC_RUST_STUFF Use ada_value_subscript in valpy_getitem Introduce type::is_array_like and value_to_array Select frame when fetching a frame variable in DAP Add new Python APIs to support DAP value display Handle array- and string-like values in no-op pretty printers gdb/NEWS | 8 ++ gdb/ada-lang.c | 1 + gdb/doc/python.texi | 24 ++++++ gdb/dwarf2/read.c | 9 ++- gdb/gdbtypes.c | 24 ++++++ gdb/gdbtypes.h | 16 +++- gdb/python/lib/gdb/dap/next.py | 11 ++- gdb/python/lib/gdb/dap/scopes.py | 4 + gdb/python/lib/gdb/printing.py | 26 ++++++- gdb/python/py-type.c | 57 ++++++++++++++ gdb/python/py-value.c | 40 ++++++++++ gdb/rust-lang.c | 74 +++++++++++++++--- gdb/rust-lang.h | 39 ++-------- gdb/testsuite/gdb.dap/ada-arrays.exp | 123 ++++++++++++++++++++++++++++++ gdb/testsuite/gdb.dap/ada-arrays/cstuff.c | 22 ++++++ gdb/testsuite/gdb.dap/ada-arrays/main.adb | 24 ++++++ gdb/testsuite/gdb.dap/ada-arrays/pck.adb | 21 +++++ gdb/testsuite/gdb.dap/ada-arrays/pck.ads | 51 +++++++++++++ gdb/testsuite/gdb.dap/rust-slices.exp | 119 +++++++++++++++++++++++++++++ gdb/testsuite/gdb.dap/rust-slices.rs | 29 +++++++ gdb/valarith.c | 21 +++++ gdb/value.h | 4 + 22 files changed, 699 insertions(+), 48 deletions(-) --- base-commit: 8032f75b2994816e87e9d2ab7c46ad86601c999b change-id: 20230822-array-and-string-like-f2a941d78802 Best regards, -- Tom Tromey