Is there a way to add a breakpoint with the console?

4,276 views
Skip to first unread message

gun...@gmail.com

unread,
Jul 27, 2012, 4:54:58 PM7/27/12
to google-chrome-...@googlegroups.com
In firebug I can do debug(nameOfFunction); and it will add a breakpoint right the begging of the function. With SpiderMonkey I belive it is taken a step further i can use the Debugger.Script  object to add breakpoints in a specific line number of the function. Is there any way possible to do this in chrome DevTools?


PhistucK

unread,
Jul 28, 2012, 3:43:43 AM7/28/12
to gun...@gmail.com, google-chrome-...@googlegroups.com
Yes. You can enter "debugger;".
For example -
debugger; function bla() { alert('hey'); } bla();
Will break before bla();.
You can put it anywhere you want to break.

PhistucK

gun...@gmail.com

unread,
Jul 30, 2012, 1:22:12 PM7/30/12
to google-chrome-...@googlegroups.com, gun...@gmail.com
Perhaps I missed the most important details, in the body of my post (but I did include it in the title) I want to be able to add breakpoints from the console. Not by adding the keyword "debugger;" but rather to add a breakpoint at runtime. When I load a page and bring up the console, I wonder if it is possible to add a breakpoint doing somehting like:   debug(nameOfFunction);  

Angel Vera

unread,
Jul 30, 2012, 3:13:19 PM7/30/12
to Abraham Williams, google-chrome-...@googlegroups.com
Still not what I am looking for. I understand people are not that familiar with this type of function but here is a explanation from firebug:


On Mon, Jul 30, 2012 at 2:36 PM, Abraham Williams <4br...@gmail.com> wrote:
You can dynamically add breakpoints in the dev tools scripts tab (or sources depending on which version of Chrome you are running) by clicking on a line number.

https://developers.google.com/chrome-developer-tools/docs/scripts-breakpoints

Abraham
--
Abraham Williams | abrah.am | abraham+ | addvocate.co
@abraham | github.com/abraham | blog.abrah.am
This email is: [ ] shareable [x] ask first [ ] private.

Abraham Williams

unread,
Jul 30, 2012, 3:32:30 PM7/30/12
to Angel Vera, google-chrome-...@googlegroups.com
Ah. I see what you are asking for. I don't believe Chrome currently features that. The best you can currently do is follow my suggestion and add breakpoints to the first line of the function. You can use cmd/ctrl+f to search the current script for the function name.

You can also request the ability to set breakpoints on fonctions: http://new.crbug.com


Abraham
--
Abraham Williams | abrah.am | abraham+ | addvocate.co
@abraham | github.com/abraham | blog.abrah.am
This email is: [ ] shareable [x] ask first [ ] private.



Abraham Williams

unread,
Jul 30, 2012, 2:36:58 PM7/30/12
to gun...@gmail.com, google-chrome-...@googlegroups.com
You can dynamically add breakpoints in the dev tools scripts tab (or sources depending on which version of Chrome you are running) by clicking on a line number.

https://developers.google.com/chrome-developer-tools/docs/scripts-breakpoints

Abraham
--
Abraham Williams | abrah.am | abraham+ | addvocate.co
@abraham | github.com/abraham | blog.abrah.am
This email is: [ ] shareable [x] ask first [ ] private.



On Mon, Jul 30, 2012 at 10:22 AM, <gun...@gmail.com> wrote:

Marco De Rosa

unread,
Feb 10, 2017, 10:24:48 AM2/10/17
to Google Chrome Developer Tools, gun...@gmail.com
You can write a function in console tab. Then write the name of the function and press enter. Chrome will show a preview of the function and you'll be able to double-click on it and go to Source tab where it's possible to add a breakpoint into the code
I hope it is useful :)

Marco

Pavel Feldman

unread,
Feb 10, 2017, 10:34:29 AM2/10/17
to Google Chrome Developer Tools, gun...@gmail.com
https://getfirebug.com/wiki/index.php/Command_Line_API#debug.28fn.29 is the closest that we have.

--
You received this message because you are subscribed to the Google Groups "Google Chrome Developer Tools" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-chrome-develo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-chrome-developer-tools/9c0d5613-dab3-46f7-8c68-796aee2f0d1c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages