14

Is there any way to specify the debugger for listening for specific method names? Example: When the function myFunc get called, I want to start debugging. Yes, I know that this seems strange, but in some projects I don't know the name of the javascript file to start the debugging, but I do know the name of the method.

It would be something like the Event Listener Breakpoints, but with an arbitrary method name instead an event name.

6
  • Put a breakpoint inside the function, try debugger; Commented May 12, 2014 at 21:01
  • You can set breakpoints on lines inside the function that gets called. Commented May 12, 2014 at 21:02
  • 3
    @elclanrs: To do that, he'd have to know what file it was in. Commented May 12, 2014 at 21:02
  • 1
    @T.J.Crowder: Well he can debug it to find out, oh the irony. If the function is anonymous and minified, good luck with that Commented May 12, 2014 at 21:02
  • 2
    @elclanrs I am starting to wonder if you actually read the OP's question. Commented May 12, 2014 at 21:09

2 Answers 2

10
+50

Just wanted to add another method that I came across today while searching, you can open the JS console and use debug(Some.path.to.myFunc) and it will set a debug breakpoint on the function. Use undebug(func) to unset it. You can also use monitor(func) and unmonitor(func) to get a console log when that function is called. Learned about these from: https://amasad.me/debugging

Sign up to request clarification or add additional context in comments.

1 Comment

9

You can find the function name with a search and set the break point. You can use the following key combination to search accross the files.

  • Windows: ctrl+shift+F
  • OSX: Cmd + Opt + F

enter image description here

2 Comments

Yeah. Fairly sure the literal answer to the OP's question is "no" and this is the best workaround. If the function is defined by a function declaration or named function expression, you can type tion foo when looking for function foo, to avoid hitting everywhere it's used. (That won't help with anonymous function expressions, of course.)
It's indeed not the exactly answer for my question, but it's more than enough for my usecase, with that I solve the problem of debugging some generated JS files that are hard to trace in the project source.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.