NodeJS, use Eclipse Debugger for variables inspection? - javascript

I'm following https://github.com/joyent/node/wiki/Using-Eclipse-as-Node-Applications-Debugger
and leaves me with questions
How can I see what variables contain?
How can I execute arbitrary commands?
This is similar to webkit's inspector. You can do both there, it has a console tab to execute whatever you want and inputing variable's name will display its contents.

I've built my own tool for the time being.
https://github.com/ketamynx/node-codein

Related

Accessing a JavaScript variable I can see in the console

I am helping to develop a WordPress website. One of the website's plugins "returns" a JavaScript object named FWP. The reason that I put "returns" in quotations is because I'm not clear what returns means. In other words: I'm unclear where FWP is stored.
I can see this object in Chrome's developer console by typing FWP in the console, which then displays the object in the console.
But this all happens in the Chrome developer console. I'm not really doing anything to the variable in the webpage itself. I don't really have access to modify the real FWP object.
Objective: I would like to send this FWP object, as an input parameter, to a custom WordPress plugin that I have written in PHP.
I am confused how to actually grab the FWP object from the webpage, so that I can do things with it.
I know that it's there...somewhere... in the webpage, because I can see it in Chrome's console. Right? I just don't know how to access it.
Is there a general way to access JavaScript variables that one can see in the Chrome developer console? Basically:
1) is there some place where JavaScript variables, visible in Chrome developer console, are stored in the webpage?
2) If so, is there a general method to access them?
Thanks for any guidance. I'm not new to WordPress or php or JavaScript, but I am having a blind spot with this question, and feel that I'm missing something that I haven't learned yet.

Understanding a javascript code from website

I'm trying to understand how a webpage works. When you click a button, they call a function from javascript, with some arguments, just like this <a href="javascript:ShowListing('24343434', 22, '2', '434331')" class="btn">. The function (in an external .js) looks like this:
function ShowListing(id1,id2,id3,id4) {
somecode here
Dialog.Show( id1, assets[id2][id3][id4] );
}
My question is, what's assets? I looked for the declaration of the variable in all the scripts and I couldn't find it. Maybe it's defined in a .php?
Is there any way of knowing the value it has given some specific [ids]?
Thanks!
My question is, what's assets?
A variable containing an object of some sort. We can't tell any more than that from the code you've supplied.
I looked for the declaration of the variable in all the scripts and I couldn't find it. Maybe it's defined in a .php?
It has to be defined by client side JavaScript (unless it is a browser built-in which I don't recognise, but seems highly unlikely given the context it is used in). That JS could be in a .php file.
Is there any way of knowing the value it has given some specific [ids]?
Just about every modern browser has a Developer Tools feature.
Developer Tools come with a JavaScript debugger that lets you set breakpoints.
Set a breakpoint to that line and then you can examine the variables in it using the debugger.
Search terms such as how to use the chrome developer tools debugger will help you learn to use those tools for your browser.
First hit F12 if you're on firefox (i think the same goes for chrome) the console panel should be visible, then add the console.log() and refresh the page to see what is asset use
console.log(assets);
the same goes for the other ids and the value of each array in assets

MIPS: Print Register Value To Console

I'm trying to emulate the most basic form of javascript debugging in MIPS. What would be the equivalent of this ($t0 equals a javascript variable in this example):
console.log($t0);
In other words, how would I print the content of some variable to the console in MIPS?
syscall is the way to go. Also if you need a good interface to work with MIPS then I suggest this tool. It comes with some easy to use and strong debugging tools, which sound like might help:
http://pages.cs.wisc.edu/~larus/spim.html

How to access JavaScript execution trace at runtime in Firefox?

I want to know how to access JavaScript execution trace at runtime. I saw Firebug can do something like this:
Refer to the image above, all the line numbers executed are highlighted in green. They are achieved at runtime. I guess there must be some way to access those info from the JavaScript engine used by the browser.
Say now I want to build a firebug plugin to access those info and examine all the variables in each executed line at the runtime, how should I start?
Obviously you asked the same question in the Firebug forum.
To duplicate Honza's answer:
Firebug is currently using JSD (jsdIDebuggerService) to figure out,
which line is executable. However, the plan is to switch to JSD2 (work
in progress) https://wiki.mozilla.org/Debugger
You should also base your extension on JSD2
Look for getLineOffsets(line) and getOffsetLine(offset) in the
Debugger document. I didn't test it, but I think that if getLineOffset
returns null, the line is not executable.
Sebastian

Get attributes in javascript

I get an element by id, and I would like to know all attributes of the object.
I've using alerts for all this kind of stuff, is that the way its done in javascript? In AS3 or whatever, I would place a break point, and investigate the object in the variables panel.
Second, if that is the way its done, how can I show ALL attributes, if I don't know what they are in advance, and show them in alert boxes? Using jquery 1.5. Thanks
If by "attributes", you mean the "properties" of the DOM node, then use...
console.dir(element);
...in Chrome's developer tools, or Firebug for Firefox.
This will allow you to expand the Object and fully inspect all of its properties, including the .attributes property.
Debugging with alerts will slowly drain your soul out through your nose. Luckily, there is a better way.
The Javascript console in a modern browser (like Chrome or Safari, or with the Firefox extension Firebug) is awesome.
You can also set breakpoints in the script tab, or from the code via the debugger statement. You can inspect globals and local variables in the scripts tab as well. It's seriously awesome.
Checkout the chrome dev tools videos for way more awesome: http://code.google.com/chrome/devtools/docs/videos.html
You have a few options:
console.log(domElement);
That'll let you log statements and view the item as it exists after your script runs. Note though that Firebug treats the object as live, so changes to the object reflect in your log statement (you'll see the actual object in your log, not just a bunch of strings) at least, it did the last time I used it).
debugger;
That'll let you pause execution and analyze your object via watch window in Firebug or Chrome dev tools, or even in IE9's developer tools.

Categories