How can debugger be paused automatically in chrome developer tools on return value of a specific JavaScript function? - google-chrome-devtools

I have a javascript function with multiple return statements based on different conditions. For debugging this function, is there a way in chrome developer tools so the debugger would be paused automatically on this functions return?
Because its tedious to set manually breakpoints for all the multiple return statements.
Thanks.

Related

How to automatically terminate last instance when running or debugging in VS Code

Coming from Eclipse, I am very used to the option to terminate the possible old and running instance of the code I'm working on. With VS Code, I instead have to select the console, press Ctrl+C, wait for the process to end and only then can I launch a new instance via Ctrl+F5 (same for debug/regular F5).
I was surprised to find no such option in VS Code, am I missing something or is this feature simply not supported ? If this is possible to configure somehow, how would I go about it ? Multiple tags because I'm not sure which part of VS Code would be responsible here. I am specifically developing in Java, if that is relevant.

Break on postmessage?

I want to be able to break on postmessage in Chrome Developer Tools, but it appears there's no such option:
Is it possible to conveniently break on postmessage without specifically searching the line in source code?
Edit: Someone suggested the question is a duplicate of this post: Any good debugger for HTML5 Javascript postMessage API?
The answer features Firebug extension, however, Firebug is no longer available (https://blog.getfirebug.com/)
If you are using the Browser's console, you can run debug(window.postMessage
there to make the execution stop when the next postMessage call is made.

Eclipse Pydev interactive console use inside functions

What are the best practices for developing with the Eclipse Pydev interactive console once code migrates inside a function?
I heavily use the interactive console as my projects are typically experimental, open-ended, and not spec-driven. The interactive console works well for code in the main loop, but as soon as I migrate that code to a function, I only know to use breakpoints with the debug view. However, that seems unwieldy, and I don't need the entire stack, nor error-catching mechanisms.
Is there a way to have the vanilla pydev environment interactive console inside a function, for example on the first breakpoint, or raised error?
Without this, I typically have to copy the function back into the main loop. Then, I end up using the same variable names, which leads to occasional global variable name accidents when I copy back to a function.
Thanks in advance.

How to send Chromium debugger a command (set breakpoint)?

I'm using an advanced text editor (but not a totally IDE) while developing web based applications, so I do rely on Chromium's debugger.
I want to provide an easier way to put a temporary breakpoints in the runtime via text editor's window.
All I need is to be able to send a breakpoint information in the runtime to the Chromium Debugger. Is there a way to achieve this?
You will either need to connect your text editor to the Chrome Developer Tools or write some small(ish) programs that connect to the Chrome Developer Tools and issue the appropriate setBreakpoint command.
Setting the breakpoint is basically just sending some JSON to the Chrome Developer Tools, but for that to work, you need to first ask Chrome for a Websocket connection, connect to that Websocket and then issue your command. There are various ways of automating the Chrome Developer Tools for Pyhon, NodeJS, C# and Perl (written by me), so if you can tell us what language you are comfortable in, we can likely suggest concrete libraries to do the communication with Chrome / Chromium for you.
See also
https://chromedevtools.github.io/devtools-protocol/tot/Debugger#method-setBreakpoint

Eclipse debugger for GEF editor

I have a GEF editor which represent a finite state machine. Editor's input (and output) is XML. What I am looking for is a way to debug my editor visually.
The way editor works is you create a state Start->Email->End, XML that is created is send to the server and there magic happens, of course Email object has properties that you set: from email, to email, subject, etc. What I am looking for is a way I can launch a debugger and step through each step of execution. So for example if I break at Email step I would be able to see what message was, whom it was for and what server returned at the end.
Is this something that is possible to accomplish and if so are there any articles I need to read to familiarize myself with how to create this debugger?
I found some discussion about Eclipse debuggers (1,2) but nothing about what I am interested in doing.
There are two different issues here.
One is writing a debugger engine, that manages the execution of your model, for example steps the execution, allows querying the variables/states, etc., and another one that outputs the result in your editor.
The articles you have linked work with the first issue: creating an engine that executes the model in the background, and integrates the engine into the Eclipse environment using 1) the launch framework to execute it similarly as Java programs, and 2) allows displaying the state in the textual editors.
You want to display the state in graphical editors. Because graphical editors have much less in common, the back-annotation of the debug state has to be done manually (instead of the generic support for text editors). Basically, I would create actions that set up breakpoints, and update the model to be able to store/query the execution state, and then update the GEF views to display it on the GUI. For this you have to change your Figures and your EditParts at least, and possibly other places as well.