AngularJS: How do I force Chrome's Dev Console to show me which instruction caused the error? - google-chrome-devtools

I very often get error from angular.js, googleapi etc. like "undefined is not a function".
The problem is that I can't figure out how to find the instruction (written by me) who caused the error.
Normally I can use the debugger but there is a huge stack of calls and it's very difficult/long to find the original problem.
This is even more difficult while working with Google API's minified js.
Any clue?
Thanks in advance

In the debugger use breakpoint, or put it in your code with :
debugger;
If the console is up, the code will stop, helping you to do step by step process.
More info : https://developer.chrome.com/devtools/docs/javascript-debugging
Also maybe, you will have more info with a dev version of chrome https://www.google.fr/chrome/browser/canary.html

In the Sources Inspector of the Chrome DevTools you can press the Pause button (the one on the far right). This will cause the code to stop prior to the exception and maybe this can help you identify the cause of the problem, since you can inspect the scope variables and use the Console to further investigate the call stack.

Related

Remove anonymous debugger from Chrome Dev Tools

A while ago I was working on a webapp and for the purpose of debugging I've added a listener function directly in the console of Chrome Dev Tools and I've included a js debugger keyword in it to have a breakpoint there.
Now I can't get rid of that debugger and whenever I try inspecting the page, click on Select an element in the page to incspect it and I click anywhere on the page to take me to that node in the DOM structure I'm entering the breakpoint and I need to Continue script execution multiple times.
The debugged code looks like this:
I've tried triggering Never pause here option on each possible line, but it just opens a new VMxxxxx file. The breakpoint is not available in the Breakpoints list so I can't remove or uncheck it from there. Do you know how to get rid of it?
I was having the same issue, i found that one of my browser extentions was throwing the anonymous debugger. I solved the problem by disabling all my extentions, confirming the anonymous debugger issue went away and then reenabled one extention at a time.

GWT shows an empty page

From time to time I run into it. E.g., right now I can't see anything in my project but everything is OK in a sandbox project.
I've already found the bug. I used MapWidget before calling loadMapsApi (see the guide). But there might be something less obvious next time. It would be better if a web page gave an error message or some feedback.
What should I use?
I press Debug As -> Web Application. It allows me to use breakpoints and debug client code.

Unable to turn on GWT Super Dev Mode

While trying to use GWT Super Dev Mode, I followed those guidelines :
GWT-2.5-Super-Dev-Mode
Introducing Super Dev Mode
How does GWT's Super Dev Mode work?
However, I am stuck at the step trying to turn on Super Dev Mode :
Once I fully compiled my project, I run the code server and the dev mode, go at http://127.0.0.1:8888/myapp.html (without the ?gwt.codesvr=127.0.0.1:9997) and then click on the bookmark Dev Mode On. It detects my module, asks me to recompile, a glass screen appears with a message Compiling MyApp ... and then nothing ... No error, no stack trace either in Chrome or Eclipse. Just nothing happens.
Debugging the js code from dev_mode_on.js file, the script is interrupted at line 324 :
...
function getBindingParameters(module_name, get_prop_map) {
var session_key = '__gwtDevModeSession:' + module_name;
--> var prop_map = get_prop_map(); <--
...
Once the function get_prop_map is called, a few more obfuscated functions run and the debugger returns.
I know it is still experimental, but do you have any idea of what I could have done wrong ?
PS: I am using GWT 2.5, GWT-maven-plugin 2.5 and Chrome 23.0.1271.64 m
We have found a similar issue and tracked down the cause, looks like a boundary case not handled in GWT.
More info can be found here: http://code.google.com/p/google-web-toolkit/issues/detail?id=7894
I don't have an answer, but I can give some general debugging tips for this sort of problem.
Super Dev Mode currently (as of 2.5) doesn't report any progress to the web browser while it's compiling. It won't update the dialog until the compile finishes. So it's possible that it's just very slow for your program for some reason, or the compile stopped and somehow didn't report an error like it normally does.
However, there are other ways you can monitor its progress. The compiler log is available as a web page by following links from the code server's front page; you will have to refresh the page to see updates. Or you could look at the log on disk in the code server's work directory. (You can set the work directory with the -workDir argument when you start it.)
Another way is to start the code server from the command line. Any stack traces from the code server will be printed there. You should also be able to look at the output in Eclipse or IntelliJ if you're running it from there.
From this you should be able to tell whether the compiler is slow, but still working (it's still printing output) or has actually stopped with a stack trace.

debugging issue with iphone simulator 4.0

Friends,
I am building and debugging my xproj. Now the control is not stopping at the breakpoint i kept in the program but it is stopping at the return statement of operator++() in the stl_iterator.h file. After I press Continue the code is giving expected results but the thing is I cannot see the step by step debugging. Can any one give me clue why it is happening so, always i see the control at same position. I cleaned all targets and tried but no luck.
Active SDK = iphonesimulator4.0, Active Configuration = Build. (I used C++ in the code).
With iphoneSImulator3.1.2, i can able to debug step-by-step for the same code.
Thanks in Advance,
Anil
Sometimes the compiler will optimize your code and make breakpoints move around. Be sure to turn off all optimizations when building for debugging purposes; this should already be set in the “Debug” build setting.

iPhone - Debugging EXC_BAD_ACCESS crashes

From times to times, while debugging an Application, I see this error on Xcode:
Program received signal: “EXC_BAD_ACCESS”.
and the debugger does not stop on the problematic line. In fact the debugger just shows me a page with a bunch assembly language code and that's it.
I have to have paranormal powers to figure out where the exact problem is.
Is there a way to force Xcode to give me more "nutritive" error messages – that can detail the problem – and stop on the offending line when such errors occur?
thanks for any help.
When the crash happens, open the Debugger in Xcode (Run -> Debugger). There should be 3 to 4 panes like this:
http://developer.apple.com/mac/library/documentation/DeveloperTools/Conceptual/XcodeDebugging/art/debugger_disassembly.jpg
On the top-left pane (the "stack trace"), select the topmost row which is not gray.
(Note: Sometimes the stack trace can only find internal functions because of bad memory management triggered in the run loop. Try to Build -> Build and Analyze to eliminate all potential memory management bugs first.)
You can enable NSZombies see here and I've found a good way to see where the actual problem is, is to run and debug the program with the debugger open.
This way when the program stops executing it more often then shows the line that was executing when the program crashed.
I wrote up a blog that tells you how to use some compiler switches that help a lot in finding crashes that are the result of releasing objects before you are done with them.
http://loufranco.com/blog/files/debugging-memory-iphone.html
Build and Analyze is ok, but not as good as scan-build (which it is based on). Instructions for installing that are here:
http://loufranco.com/blog/files/scan-build-better-than-build-analyze.html