最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Chrome Dev Tools - Start debugging by function name - Stack Overflow

programmeradmin3浏览0评论

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.

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.

Share Improve this question asked May 12, 2014 at 20:56 Israel FonsecaIsrael Fonseca 1,08311 silver badges23 bronze badges 5
  • Put a breakpoint inside the function, try debugger; – elclanrs Commented May 12, 2014 at 21:01
  • You can set breakpoints on lines inside the function that gets called. – Sunny Patel Commented May 12, 2014 at 21:02
  • 3 @elclanrs: To do that, he'd have to know what file it was in. – T.J. Crowder 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 – elclanrs Commented May 12, 2014 at 21:02
  • 2 @elclanrs I am starting to wonder if you actually read the OP's question. – epascarello Commented May 12, 2014 at 21:09
Add a ment  | 

2 Answers 2

Reset to default 9

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

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

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

发布评论

评论列表(0)

  1. 暂无评论