Chrome DevTools error: "Failed to save to temp variable." - node.js

I am using Node Monkey to debug my NodeJS app.
It happens frequently that when I click "Store as Global Variable" in my Chrome Console it says "Failed to save to temp variable."
console.log({why:'dont', you:'work?'})
It happens also in this jsfiddle
1) Am I doing something wrong?
2) Why this happens?
Chrome: 50.0.2661.102 (64-bit)
OSX El Capitan 10.11.4

I can see two reasons why Store As Global Variable wouldn't work:
1. Wrong Console Context Selected
This is arguably a Chrome bug, but you can only store an object as a global if the console is set to the same context as the code that logged the object.
In practice this means you might need to select the correct IFrame or web worker.
For example, on jsFiddle:
In the normal jsFiddle editor page context I'm getting an error. But it works if I change the context to the contents of the fiddle itself:
2. Garbage Collection
In order for Chrome to give you a reference to the object the object still has to be in memory. If that isn't the case it can only throw an error.
However, I'm pretty sure that being shown in the console forces V8 to keep a reference to the value.

You need to create the object in the Console itself, as the reference to the object needs to be maintained by Chrome. Just put the following into the console instead:
{why:'dont', you:'work?'}
If you check out this revision where the feature was added, it says:
Adding ability to access objects from printed ObjectPropertySections
(console, scopes pane and etc.).
The problem, based on my understanding, is that console.log is outputting a string representation of the object, and just using object formatters to display it nicely. The object doesn't exist anymore. When you create an object through the console itself, Chrome is storing the object itself in memory. If you have paused on a breakpoint and have locally scoped variables, these can also be stored globally because they are also in memory.
One thing you could do in your code, if you haven't got circular references is:
console.log(JSON.stringify({why:'dont', you:'work?'}));
> {"why":"dont","you":"work?"}
In the Console, copy the output and paste it into a JSON.parse call:
JSON.parse('{"why":"dont","you":"work?"}');
> Object {why: "dont", you: "work?"}
The variable exists now in memory so you can store it.

press Ctrl+Shift+C and select any element inside the frame that prints the object, then try again.
This will fix the problem.

Related

How do I change a variable value in Xilinx SDK debugger using Linux TCF Agent connected to our target?

I am connected to our target over ethernet using the Linux TCF agent to debug an application.
I've used a lot of debuggers over my 25 year career, but this is my first time using Eclipse/Linux/Xilinx environment. I can set break points. I can single step through the code. I can view variables. I can view memory. I can type a new value in the memory location, but the variable value doesn't change. I tried to click or double click the value in the Variables pane. I tried right clicking to see if it would give me an option to modify the value.
I'm not sure what good a debugging tool is if I can't change a variable value to alter the execution path of my software...
In addition to the hacky solution we came up in the comments, which is to get the address of a variable and then modify them through the mr command from the xsct console, the same console provide commands to properly get/set a local variable.
The syntax is the following:
locals [options] [variable-name [variable-value]]
And an example:
locals my_int_var 10
locals my_float_var 1.4

Viewing value of Python attribute when debugging

I have a Python class Cards which has an attribute _Count. I create an instance of the class, say card_obj. I can step through the code and set breakpoints by using an IDE such as Thonny. When the code stops at a breakpoint, or I step through the code, the variables window shows the address of the object. I want to be able to see the value of card_obj._Count. I can assign the contents of card_obj._Count to another variable, temp_var, then print the contents of temp_var. But this source change will take ages for all the variables I want to inspect. Is there a "direct" way to view the value of an attribute in an object while stepping through the code? I can download any free IDE, but I would like to use Thonny as I like the way it displays stack frames while debugging.

Why is nothing in scope in the protractor debugger?

I'm on OSX, with protractor version 1.3.1 installed. If I put browser.debugger() in my test and run with
$ protractor debug test/protractor.conf.js
I go into the debugger screen. Then I hit "c" and it seems to stop at my breakpoint.
However, nothing seems to be in scope, everything comes up as undefined.
debug> browser
ReferenceError: browser is not defined
If I enter 'repl', I go into a node repl loop (I think?) and I can look at the browser object, but none of my local variables from the test seem to be in scope, they all come up as undefined.
Any suggestions?
Yes, to inspect variables / evaluate code you need to go to repl first. Your variables might be optimised out by v8 if they are not referenced in the current scope. Possible solutions: reference them in code, add with({}) block, use try/catch or some other ways
Your local variables don't show up because browser.debugger doesn't pause in the same local scope - what it does is add a command to the control flow queue to debug when the control flow gets there.
This is desirable so that if your test does
someElem.click();
browser.debugger();
otherElem.click();
That it will pause after the click has occurred, instead of just after it has been scheduled.
You can still use debugger; directly if you want to investigate local variables.

ZF2 partial loop error

Moving my project from my local (osx) development to (debian) production put's me in some erros. Everything works wel on my local dev but on the debian two things goes wrong.
My layout.phtml won't render (no error) and I get this error for partial loops.
Paste of error output:
http://pastebin.com/74g1dL8g
Thanks! :)
nick
As Error states.
"Rows as part of this DataSource, with type object cannot be cast to an array".
You must have moved your database with structure only option without data. In your code somewhere, you have not place empty checks to verify dataset or records. I think it is trying to caste empty object into array....
You need to debug your application either using XDebug which provides step-by-step debugging, and can be used with eclipse PDT, netbeans and even vim.
Or
use old fashioned way
echo "programing working to till this line";
exit();

Overriding PromptService in newer XULRunner

Our application uses embedded xulrunner. We override the default PromptService to provide custom dialogs for alert, prompt, etc by
componentRegistrar.RegisterFactory (PROMPTSERVICE_CID, aClassName, aContractID, MyPromptServiceFactory);
where,
PROMPTSERVICE_CID is "a2112d6a-0e28-421f-b46a-25c0b308cbd0"
CONTRACT_ID is "#mozilla.org/embedcomp/prompt-service;1"
When using XULRunner 1.9.* versions, this works perfectly and the call comes to MyPromptSerivceFactory. But, this doesn't work on newer XULRunner versions (>= 4.0)
I have modified the PROMPTSERVICE_CID to "7ad1b327-6dfa-46ec-9234-f2a620ea7e00" (copied from nsPrompter.manifest). While registering the factory I get the error NS_ERROR_FACTORY_EXISTS.
If I continue to use the old PROMPTSERVICE_CID, then nsIPromptService2 is not used instead nsIWindowCreator2.CreateChromeWindow2 is used to display alerts and prompts.
I have googled on this, but I couldn't find a solution to either fix the NS_ERROR_FACTORY_EXISTS error or for MyPromptServiceFactory to be used.
Any help/suggestions?
It would probably be better to use the existing prompt service the way Firefox does it rather than replace it. If you look at nsPrompter.openPrompt(), before opening a modal dialog it will try to locate and call a JavaScript function getTabModalPrompt() in the window containing the browser. It expects to get a promptBox element back and will call methods appendPrompt() and removePrompt() on it. Obviously, you don't have to give it a promptBox element, just something that behaves similarly - and displays a message any way you like.
But if you really want to replace system components, you shouldn't duplicate prompter's CID - use your own one but #mozilla.org/prompter;1 as contract ID (the old contract ID is for backwards compatibility only).

Resources