Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add function breakpoints #727

Open
aldevv opened this issue Oct 20, 2022 · 2 comments
Open

add function breakpoints #727

aldevv opened this issue Oct 20, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@aldevv
Copy link

aldevv commented Oct 20, 2022

Problem Statement

would be a nice addition to add a breakpoint having only the name of the function
https://code.visualstudio.com/Docs/editor/debugging#_function-breakpoints

Possible Solutions

No response

Considered Alternatives

No response

@mfussenegger mfussenegger added the enhancement New feature or request label Nov 18, 2022
@hanek23
Copy link

hanek23 commented Dec 11, 2023

I managed to hack my way into a solution but I do not dare to send any pull request since my knowledge of Lua and/or DAP are very minimal but I at least can provide my hacky solution since someone else might find it useful.

I use Java and I needed to set a breakpoint in java.lang.Object default constructor so I changed a method in nvim-dap/lua/dap/session.lua#set_breakpoints accordingly. In my case that would be editing the payload table so that it does not contain parameters line and column and instead it contains parameter name with value "java.lang.Object#<init>" and also the request endpoint from "setBreakpoints" to "setFunctionBreakpoints".

Note that the <> are there only for constructors since those do not have a name themselves, the structure of the name parameter is "className#methodName" so for hashCode on the Object it would be "java.lang.Object#hashCode"

Here is a snippet of that:

local payload = {
  .
  .
    return {
      -- line = bp.line, **comment this out**
      -- column = bp.column, **comment this out**
      name = "java.lang.Object#<init>", **add this**
  .
  .
-- **change the request**
self:request("setFunctionBreakpoints", payload, function(err1, resp)

I am sure this can be done more cleanly and without manual changes to internal files but I need this once in a blue moon and it was sufficient.

@hebaishi
Copy link

This is another feature that would be incredibly useful for debugging C++ projects. I'd love to make a PR for this if you'd be happy to have a look @mfussenegger

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants