From patchwork Mon Jan 22 13:31:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Farre X-Patchwork-Id: 84554 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 6BDF33858412 for ; Mon, 22 Jan 2024 13:33:04 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by sourceware.org (Postfix) with ESMTPS id 45E3A3858415 for ; Mon, 22 Jan 2024 13:31:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 45E3A3858415 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 45E3A3858415 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::22b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705930295; cv=none; b=BCzn+/ZdrnQZO/2Lpmp6oxv+eTQWjTeYbV7bEWwVZvbS5nRAmAmjx15dug2qmAJmD4p/ZUs8w78oT0Ew9wECETIHduMyWlUVsolY8YNM8BV2SAmGQqqQOrYy8qfAFGxUKsoaF3nrAazRXUh6DBe5r9BAY1JGLhjvpigyP9qe6QI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705930295; c=relaxed/simple; bh=WW3Vcy0AVWPQYn3NyNJPfvkzMAqohitQF3pQkFMGKuM=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=UyuJDzhWMVskacZA/Oyt+5lpoPLBslB9dRrwzobo+GRRcw52bLc5QeZMlCqbN6EPYFkw3DBAaY2tRbFF4V+tbp6Gti0iJaXsuk9lXofl9bQeXXCfPLl8h2JW33/xwGlt5PQfpaYb//iGlJHQfhq8SYXV9MjSlMJK5vUJa5/6VEQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-2cd33336b32so40631591fa.0 for ; Mon, 22 Jan 2024 05:31:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705930291; x=1706535091; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3W8MVlSvpVvu94V6o4V125XVhL0qVTXhc9eG1jvcCiQ=; b=Kz4z1wgTOT+XFhXn6nWTmCk18U+btfD/YQGYbOm+HemeY8yEB+CCupzWTbLA1zX2Uh PiIJbktmJZouMN4BNJBirQ2Fvp7i4bbXTzMxALdXNE8Mbb7UyJqk3aIkolIvqTUHR0Vo I5mZ4w+JtvKQt83h9ITPijh9c5c3Y2tIgeAi6luMc6unJI1j+JPSf5JWGDopOzKy4ITm NKF1IgM9J+5hxMxyRxysyDA3pTq5BoMu6dk5qVNu1h5PDt/g1RS5rM/Cmp768kK3ZsIe VsjnlH8J4o8ZImCzu9d+S4Cv8aalfsvAbM+4p49O45CcRAweLexFfCBprh3GdHNhPuHV v0IA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705930291; x=1706535091; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3W8MVlSvpVvu94V6o4V125XVhL0qVTXhc9eG1jvcCiQ=; b=lInAEG/HbbD7IUm8ygmj6jFcuermz2MwBt2bg5S8TJavJJXdWXN+X584hxxZaFtqSs mRegOLt1sFniSeCDrtT0Vpp1+BfBXvDnyCDny0QNXjpTp9shN9d3vdM8TK2u0zP2AnUW XZytppQYzUU7KLJwFm/lmGgxLvowbutofHB+D7PZNlnxpvStLm55Ew7RmX5NgjrPm7Rq IwfgfAC8+d2NN/V1U+9tIKXr7QrB8plhXV75UjJdvp1wmXj5DLdniehXo1lP/aiTSxLg iX4oI2r35NZ0cRkRI6qdFtvX5guIE5H6T3FhPklMqhd9C9XK73Tmsmvj32V3twsEpEtn RbuA== X-Gm-Message-State: AOJu0YzWlhY3GKE5Jy2ggHaLyRbk6dMygzhvnavvhXG2Kf220NhKQJNL kXdpAyy3RacayjYDY7/Mzj8C7Gnrhn1C0/+C2XE1GSLdq+NV+SIousqqpem2 X-Google-Smtp-Source: AGHT+IFkXF6F5IWCzQKh6wqnuOxdGzUACFTXxUB7ZaLAd7NGbMzaDJuWHQvmP9kv1EgglcfdNQz+Bw== X-Received: by 2002:a05:651c:2019:b0:2cc:ee59:3de1 with SMTP id s25-20020a05651c201900b002ccee593de1mr1758973ljo.2.1705930291338; Mon, 22 Jan 2024 05:31:31 -0800 (PST) Received: from localhost.localdomain ([2001:2044:7c:4b00:37f8:fc67:7f51:113d]) by smtp.gmail.com with ESMTPSA id s17-20020a2eb8d1000000b002cccbb7ca38sm3411187ljp.2.2024.01.22.05.31.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 05:31:30 -0800 (PST) From: Simon Farre To: gdb-patches@sourceware.org Cc: tom@tromey.org, Simon Farre Subject: [PATCH v3 4/5] [dap & linetable]: Add breakpointLocations request Date: Mon, 22 Jan 2024 14:31:14 +0100 Message-ID: <20240122133115.201205-4-simon.farre.cx@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240122133115.201205-1-simon.farre.cx@gmail.com> References: <20240122133115.201205-1-simon.farre.cx@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org This adds the breakpointLocations request. Testing might strictly not be possible for this feature. Users are going to have wildly varying compilers and compiler versions that outputs wildly different debug symbol information. So unless we can restrain the tests to some specific toolchain that I can handroll the tests for, this will not be useful (and handrolling for a specific compiler defeats the purpose - as one can just use the eyes then to verify). v2: Fixed type check issue Forgot the obligatory **args at the end of breakpoint_locations v3: Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31271 --- gdb/python/lib/gdb/dap/breakpoint.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/gdb/python/lib/gdb/dap/breakpoint.py b/gdb/python/lib/gdb/dap/breakpoint.py index 9cbd7ae0c47..70c93b0a03d 100644 --- a/gdb/python/lib/gdb/dap/breakpoint.py +++ b/gdb/python/lib/gdb/dap/breakpoint.py @@ -437,3 +437,30 @@ def set_exception_breakpoints( return { "breakpoints": _set_exception_catchpoints(options), } + + +@in_gdb_thread +def _get_logical_bp_locations(name: str, line: int): + linetable = gdb.lookup_linetable(name) + if linetable is not None: + return [ + {"line": lte.line, "column": lte.column} for lte in linetable.line(line) + ] + else: + return [] + + +@request("breakpointLocations") +@capability("supportsBreakpointLocationsRequest") +def breakpoint_locations( + *, + # This is a Source but we don't type-check it. + source, + line: int, + column: Optional[int], + endLine: Optional[int], + endColumn: Optional[int], + **args, +): + # for now we don't support column, endLine, endColumn. We just return per line + return {"breakpoints": _get_logical_bp_locations(source["path"], line)}