Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome Dev Tools - Start debugging by function 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.

like image 895
Israel Fonseca Avatar asked May 12 '14 20:05

Israel Fonseca


People also ask

How do I add a conditional breakpoint in Chrome?

Add a conditional breakpoint by right clicking a line number, selecting Add Conditional Breakpoint , and entering an expression. Note: Because the conditional breakpoint simply evaluates an expression, you can add useful logging statements within the expression.

How do I debug F12 in Chrome?

The Chrome Web Inspector and Debugger are conveniently built-in with Chrome. You can launch it by hitting F12 while in your browser or by right clicking on a web page and selecting the Inspect menu item. The images below show a few different views that you'll see in the Chrome DevTools browser.


Video Answer


2 Answers

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

like image 52
epascarello Avatar answered Oct 17 '22 02:10

epascarello


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

like image 26
Glenn 'devalias' Grant Avatar answered Oct 17 '22 02:10

Glenn 'devalias' Grant