From patchwork Wed Jan 17 21:05:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Farre X-Patchwork-Id: 84302 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 8D1A6385802D for ; Wed, 17 Jan 2024 21:06:18 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by sourceware.org (Postfix) with ESMTPS id 88CB43858426 for ; Wed, 17 Jan 2024 21:05:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 88CB43858426 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 88CB43858426 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::130 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705525539; cv=none; b=MCx1gAsdjzG/DAfRFjH+oNElAitQ2kY5L2LxKcmgPNpAf8669phnuysCImmAZ5KrEpUMofpMYHDG2HLGBH5nCrL6Sv56Y6pt/+bRjs2uWys2+Wl7WHmoKva3JeE6D0vbvoUAJHF0az0N2cv3vjxxhJUlnRiugbKvVZrNMmgP0cY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705525539; c=relaxed/simple; bh=Ay9t/lu+j5jsfuXXKTPujIW7xQwVdzKYYVKKQcP318I=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=pRalpuEkyG0whw/AEVIrwcwaZZaIjNP74zimWSnnTboUNC1TrMAo5pI80rgOq/tijTSSCQ7OoWPzKDDWgUeNIFtbVPz+uitOtMm5MUtV8FL5wqV4VPWdRZ6aeaOjPTfmtuCjcxOOwu0H8L6fQOEHQ+xL38HzRw894xJGU6Fc4sI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-50eabfac2b7so13724790e87.0 for ; Wed, 17 Jan 2024 13:05:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705525535; x=1706130335; 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=RFOBGTkSijQclaSvqCVmIxUcGDx/YAtUXMcdF4TsxIU=; b=Ys+GWLLKVQvLicnrrvmniDMKbnvRSxnIOsy0n3JwgIB5jnNbVueRgGl2sZQTshpHLs HbE0AG8ecCTRQM9jSfr88ShBz7jjW1ZJw9s6VsFGJntatzyc6R/hef4A1s+PqfsAp9A0 7ArJsofDhMrwJwt3ph2LesHHHHxATcuf8R/Kb7X6erAcUY0kK5UYze9BDncgrlM1+663 K+147lwab5UlWVmxXKJVXJvON/8ac0ffICWpnymEkdHaYJ5zpsECV7y6BF2zadUE68Ok dt7yadAWyghAOWt4Hs345B9S5u8jkjBdj8aMDWkXh0Bc1SkL9kJGLffEfBlMK1kD1dsq U/bA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705525535; x=1706130335; 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=RFOBGTkSijQclaSvqCVmIxUcGDx/YAtUXMcdF4TsxIU=; b=MqeD0R3cd1hVuyY1UCzUgiR/FJyCWR4Iz0UlyhoKhe71Xao1eHVF9hL5HBRYVFXmTY d1sL6PbWsx7GuG9RL4T/cq3D7+kaZbq/XbUOQspML49utdyikc2xCzhOn8619B7MvZcr J5Koywr/GeL8c96GzkE9exSm4Wl2UY7+tbZnVoCLczpCk90xrJsFtf5e4DKWbbGOvEW1 17N4974RZHJgJ8xPog01bgiT+tRYO56WjhVOKzq03IzTPGUYw6s9UItvt7SI5+rnS5Sp bxOfMUaKVuV6YhdyWT2Y5rT7i30P05LSoCHrVMsdpXqyzK9FzMrUu7jFsNGgj9lQ1ihu OwSw== X-Gm-Message-State: AOJu0YzkvJ4esgrSf28XsgxfdeDGtpyjYxiXY4GopbktaxBTeDoiseKa POowud1N+FUm3TBLyAQ0LodR8QDNZbg= X-Google-Smtp-Source: AGHT+IFcMGPJUICYZq1VnZHrP4tru6s7TFZWg08udibpO44l2L6O3aE+jWajXsW6SGaArav3WzHtYA== X-Received: by 2002:a05:6512:220c:b0:50e:efe2:5c99 with SMTP id h12-20020a056512220c00b0050eefe25c99mr4449900lfu.41.1705525535500; Wed, 17 Jan 2024 13:05:35 -0800 (PST) Received: from localhost.localdomain ([2001:2044:7c:4b00:37f8:fc67:7f51:113d]) by smtp.gmail.com with ESMTPSA id n1-20020ac242c1000000b0050ecae41c51sm375386lfl.135.2024.01.17.13.05.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 13:05:35 -0800 (PST) From: Simon Farre To: gdb-patches@sourceware.org Cc: Simon Farre Subject: [PATCH v2 4/5] [dap & linetable]: Add breakpointLocations request Date: Wed, 17 Jan 2024 22:05:18 +0100 Message-ID: <20240117210518.1784638-3-simon.farre.cx@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240117210518.1784638-1-simon.farre.cx@gmail.com> References: <20240117210518.1784638-1-simon.farre.cx@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.6 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 --- 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)}