Re: Does anybody know how to modify the source code in order to log the executions of the JavaScript functions?
So summarizing, I will describe here all the necessary changes to be done in order to get my solution working. The produced log is as that: --- Mon Jan 26 19:13:15 2015 | GETTER: [Style], FILE: [http://static.gazeta.pl/info/portal/3.2.3/portal.jsgz], PID: [http://pieniadze.gazeta.pl/pieniadz/1,136159,17311064,Do_frytek_z_McDonald_apos_s_w_USA_dodaja_14_substancji.html#Prze] Mon Jan 26 19:13:23 2015 | SETTER: [SetPosition], FILE: [http://static.gazeta.pl/info/portal/3.2.3/portal.jsgz], PID: [http://pieniadze.gazeta.pl/pieniadz/1,136159,17311064,Do_frytek_z_McDonald_apos_s_w_USA_dodaja_14_substancji.html#Prze] Mon Jan 26 19:13:18 2015 | METHOD: [NamedGetter], FILE: [http://static.gazeta.pl/info/portal/3.2.3/portal.jsgz], PID: [http://pieniadze.gazeta.pl/pieniadz/1,136159,17311064,Do_frytek_z_McDonald_apos_s_w_USA_dodaja_14_substancji.html#Prze] --- 1. Edit "mozilla-central/dom/bindings/Codegen.py": a) in "class CGBindingRoot(CGThing):", just after "bindingHeaders["xpcpublic.h"] = dictionaries", we should add: --- bindingHeaders["nsGlobalWindow.h"] = True --- b) in "def __init__", we should add the following content right before "self.cgRoot = CGList(cgThings)": --- cgThings.append(CGGeneric(' std::string mess = __TIMESTAMP__; \n')) cgThings.append(CGGeneric(' mess += " | "; \n')) if setter: cgThings.append(CGGeneric(' mess += "SETTER"; \n')) elif getter: cgThings.append(CGGeneric(' mess += "GETTER"; \n')) else: cgThings.append(CGGeneric(' mess += "METHOD"; \n')) cgThings.append(CGGeneric(' mess += ": [' + nativeMethodName + ']"; \n')) cgThings.append(CGGeneric(' \n')) cgThings.append(CGGeneric(' int loopActive = 1; \n')) cgThings.append(CGGeneric(' \n')) cgThings.append(CGGeneric(' while (loopActive) { \n')) cgThings.append(CGGeneric(' \n')) cgThings.append(CGGeneric('JS::Rooted stack(cx); \n')) cgThings.append(CGGeneric(' \n')) cgThings.append(CGGeneric('if (!JS::CaptureCurrentStack(cx, &stack, 1)) { \n')) cgThings.append(CGGeneric(' loopActive = 0; \n')) cgThings.append(CGGeneric(' break; \n')) cgThings.append(CGGeneric('} \n')) cgThings.append(CGGeneric(' \n')) cgThings.append(CGGeneric('if (!stack) { \n')) cgThings.append(CGGeneric(' loopActive = 0; \n')) cgThings.append(CGGeneric(' break; \n')) cgThings.append(CGGeneric('} \n')) cgThings.append(CGGeneric(' \n')) cgThings.append(CGGeneric('JS::Rooted source(cx); \n')) cgThings.append(CGGeneric(' \n')) cgThings.append(CGGeneric('if (!JS_GetProperty(cx, stack, "source", &source)) {\n')) cgThings.append(CGGeneric(' loopActive = 0; \n')) cgThings.append(CGGeneric(' break; \n')) cgThings.append(CGGeneric('}
Re: Does anybody know how to modify the source code in order to log the executions of the JavaScript functions?
On 1/26/15 12:48 PM, Tomasz wrote: In what cases were the early-return cases actually hit? They correspond to things like out-of-memory conditions and should not have been getting hit... Here: cgThings.append(CGGeneric('if (!stack) { \n')) Right, I said that one shouldn't be an early return. But the other ones should be. -Boris ___ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform
Re: Does anybody know how to modify the source code in order to log the executions of the JavaScript functions?
> In what cases were the early-return cases actually hit? They correspond > to things like out-of-memory conditions and should not have been getting > hit... Here: cgThings.append(CGGeneric('if (!stack) { \n')) cgThings.append(CGGeneric(' loopActive = 0; \n')) cgThings.append(CGGeneric(' break; \n')) cgThings.append(CGGeneric('} \n')) > You should probably just use > xpc::WindowOrNull(JS::CurrentGlobalOrNull(cx)) instead of messing around > with "obj". Perfect, working, thanks! :) ___ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform
Re: Does anybody know how to modify the source code in order to log the executions of the JavaScript functions?
On 1/26/15 11:49 AM, Tomasz wrote: Using immediate returns from the functions was not a good solution as it was breaking functions where some operations were performed after our code In what cases were the early-return cases actually hit? They correspond to things like out-of-memory conditions and should not have been getting hit... I have one more question regarding the URL of the current window. The code to obtain it works for getters and setters, but it does not work for methods. You should probably just use xpc::WindowOrNull(JS::CurrentGlobalOrNull(cx)) instead of messing around with "obj". -Boris ___ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform
Re: Does anybody know how to modify the source code in order to log the executions of the JavaScript functions?
> Hmm. It's possible that stack came back null if the call into the > binding wasn't actually from script. Add a null-check (this part > _should_ end up with an indented block and all that). Well, I got my function working. Using immediate returns from the functions was not a good solution as it was breaking functions where some operations were performed after our code was inserted. Nested conditional statements made good job, by I designed the code by using a one-time loop covering the inserted code, which was broken when some conditions occur. I am pasting my current, fully working code, below. I have one more question regarding the URL of the current window. The code to obtain it works for getters and setters, but it does not work for methods. The reason is that not all the methods contain "obj", which is required by the following line of code: nsPIDOMWindow* cwindow = xpc::WindowGlobalOrNull(obj); Some of the methods have different parameters, which are called "proxy" or something else instead of "obj". So inserting the code causes compilation errors. Is there any way to see if the generated functions contain a parameter called "obj" and insert the code only if such a parameter exist? Here is the fully working code: cgThings.append(CGGeneric(' std::string mess = __TIMESTAMP__; \n')) cgThings.append(CGGeneric(' mess += " | "; \n')) if setter: cgThings.append(CGGeneric(' mess += "SETTER: [' + nativeMethodName + ']"; \n')) cgThings.append(CGGeneric(' \n')) cgThings.append(CGGeneric(' int loopActive = 1; \n')) cgThings.append(CGGeneric(' \n')) cgThings.append(CGGeneric(' while (loopActive) { \n')) cgThings.append(CGGeneric(' \n')) cgThings.append(CGGeneric('JS::Rooted stack(cx); \n')) cgThings.append(CGGeneric(' \n')) cgThings.append(CGGeneric('if (!JS::CaptureCurrentStack(cx, &stack, 1)) { \n')) cgThings.append(CGGeneric(' loopActive = 0; \n')) cgThings.append(CGGeneric(' break; \n')) cgThings.append(CGGeneric('} \n')) cgThings.append(CGGeneric(' \n')) cgThings.append(CGGeneric('if (!stack) { \n')) cgThings.append(CGGeneric(' loopActive = 0; \n')) cgThings.append(CGGeneric(' break; \n')) cgThings.append(CGGeneric('} \n')) cgThings.append(CGGeneric(' \n')) cgThings.append(CGGeneric('JS::Rooted source(cx); \n')) cgThings.append(CGGeneric(' \n')) cgThings.append(CGGeneric('if (!JS_GetProperty(cx, stack, "source", &source)) { \n')) cgThings.append(CGGeneric(' loopActive = 0; \n')) cgThings.append(CGGeneric(' break; \n')) cgThings.append(CGGeneric('} \n')) cgThings.append(CGGeneric(' \n')) cgThings.append(CGGeneric('if (source.isString()) { \n')) cgThings.append(CGGeneric(' nsAutoJSString str; \n')) cgThings.append(CGGeneric(' if (!str.init(cx, source.toString())) {\n')) cgThings.append(CGGeneric('loopActive = 0; \n')) cgThings.append(CGGeneric('break; \n')) cgThings.append(CGGeneric(' } \n')) cgThings.append(CGGeneric(' mess += ", FILE: [";
Re: Does anybody know how to modify the source code in order to log the executions of the JavaScript functions?
On 1/23/15 12:06 PM, Tomasz wrote: Both versions (with returns and conditional statements) compile fine. However, neither of them works. Both versions crash on browser startup on: JS_GetProperty(cx, stack, "source", &source) Hmm. It's possible that stack came back null if the call into the binding wasn't actually from script. Add a null-check (this part _should_ end up with an indented block and all that). -Boris ___ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform
Re: Does anybody know how to modify the source code in order to log the executions of the JavaScript functions?
Well, in the version with returns it is: cgThings.append(CGGeneric(' JS::Rooted stack(cx); \n')) cgThings.append(CGGeneric(' if (!JS::CaptureCurrentStack(cx, &stack, 1)) { \n')) cgThings.append(CGGeneric('return false; \n')) cgThings.append(CGGeneric(' } \n')) cgThings.append(CGGeneric(' JS::Rooted source(cx); \n')) cgThings.append(CGGeneric(' if (!JS_GetProperty(cx, stack, "source", &source)) {\n')) cgThings.append(CGGeneric('return false; \n')) cgThings.append(CGGeneric(' } \n')) cgThings.append(CGGeneric(' if (source.isString()) { \n')) cgThings.append(CGGeneric('nsAutoJSString str; \n')) cgThings.append(CGGeneric('if (!str.init(cx, source.toString())) { \n')) cgThings.append(CGGeneric(' return false; \n')) cgThings.append(CGGeneric('} \n')) cgThings.append(CGGeneric('printf("FULL: %s\\n", NS_ConvertUTF16toUTF8(str).get()); \n')) cgThings.append(CGGeneric(' } \n')) Both versions (with returns and conditional statements) compile fine. However, neither of them works. Both versions crash on browser startup on: JS_GetProperty(cx, stack, "source", &source) Tomasz ___ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform
Re: Does anybody know how to modify the source code in order to log the executions of the JavaScript functions?
On 1/23/15 10:33 AM, Tomasz wrote: cgThings.append(CGGeneric(' if (JS::CaptureCurrentStack(cx, &stack, 1)) { \n')) cgThings.append(CGGeneric('JS::Rooted source(cx); \n')) Also, this is very very wrong. If JS::CaptureCurrentStack returns false, you must immediately return false from this function. Same if JS_GetProperty returns false or if nsAutoJSString::init returns false. I very carefully wrote it with early returns; I'm not sure why you converted to nested conditionals. In the nested-conditional case, you will continue to do things after this code even if there's already an exception thrown (which is what the false returns mean), which will make the code after this block blow up spectacularly and randomly. Please do use the early returns. ;) -Boris ___ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform
Re: Does anybody know how to modify the source code in order to log the executions of the JavaScript functions?
On 2015-01-23 10:33 AM, Tomasz wrote: Thanks, however, this does not want to compile. I re-wrote it to a form which I can include in the Python code: -- cgThings.append(CGGeneric(' JS::Rooted stack(cx); \n')) cgThings.append(CGGeneric(' if (JS::CaptureCurrentStack(cx, &stack, 1)) { \n')) cgThings.append(CGGeneric('JS::Rooted source(cx); \n')) cgThings.append(CGGeneric('if (JS_GetProperty(stack, "source", &source)) { \n')) cgThings.append(CGGeneric(' if (source.isString()) { \n')) cgThings.append(CGGeneric('nsAutoJSString str; \n')) cgThings.append(CGGeneric('if (str.init(cx, source.toString())) { \n')) cgThings.append(CGGeneric(' printf("FULL: %s\\n", NS_ConvertUTF16toUTF8(str).get()); \n')) cgThings.append(CGGeneric('} \n')) cgThings.append(CGGeneric(' } \n')) cgThings.append(CGGeneric('} \n')) cgThings.append(CGGeneric(' } \n')) -- Unfortunately, I am getting a compilation error: -- 0:33.26 /home/tomasz/CPPProjects/mozilla-central/obj-x86_64-unknown-linux-gnu/dom/bindings/HTMLMediaElementBinding.cpp: In function 'bool mozilla::dom::HTMLMediaElementBinding::get_mozPreservesPitch(JSContext*, JS::Handle, mozilla::dom::HTMLMediaElement*, JSJitGetterCallArgs)': 0:33.26 /home/tomasz/CPPProjects/mozilla-central/obj-x86_64-unknown-linux-gnu/dom/bindings/HTMLMediaElementBinding.cpp:2115:50: error: cannot convert 'JS::Rooted' to 'JSContext*' for argument '1' to 'bool JS_GetProperty(JSContext*, JS::HandleObject, const char*, JS::MutableHandleValue)' 0:33.26if (JS_GetProperty(stack, "source", &source)) { 0:33.26 ^ -- Try passing cx as the first argument to JS_GetProperty (it takes 4 arguments, not 3.) ___ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform
Re: Does anybody know how to modify the source code in order to log the executions of the JavaScript functions?
Thanks, however, this does not want to compile. I re-wrote it to a form which I can include in the Python code: -- cgThings.append(CGGeneric(' JS::Rooted stack(cx); \n')) cgThings.append(CGGeneric(' if (JS::CaptureCurrentStack(cx, &stack, 1)) { \n')) cgThings.append(CGGeneric('JS::Rooted source(cx); \n')) cgThings.append(CGGeneric('if (JS_GetProperty(stack, "source", &source)) { \n')) cgThings.append(CGGeneric(' if (source.isString()) { \n')) cgThings.append(CGGeneric('nsAutoJSString str; \n')) cgThings.append(CGGeneric('if (str.init(cx, source.toString())) { \n')) cgThings.append(CGGeneric(' printf("FULL: %s\\n", NS_ConvertUTF16toUTF8(str).get()); \n')) cgThings.append(CGGeneric('} \n')) cgThings.append(CGGeneric(' } \n')) cgThings.append(CGGeneric('} \n')) cgThings.append(CGGeneric(' } \n')) -- Unfortunately, I am getting a compilation error: -- 0:33.26 /home/tomasz/CPPProjects/mozilla-central/obj-x86_64-unknown-linux-gnu/dom/bindings/HTMLMediaElementBinding.cpp: In function 'bool mozilla::dom::HTMLMediaElementBinding::get_mozPreservesPitch(JSContext*, JS::Handle, mozilla::dom::HTMLMediaElement*, JSJitGetterCallArgs)': 0:33.26 /home/tomasz/CPPProjects/mozilla-central/obj-x86_64-unknown-linux-gnu/dom/bindings/HTMLMediaElementBinding.cpp:2115:50: error: cannot convert 'JS::Rooted' to 'JSContext*' for argument '1' to 'bool JS_GetProperty(JSContext*, JS::HandleObject, const char*, JS::MutableHandleValue)' 0:33.26if (JS_GetProperty(stack, "source", &source)) { 0:33.26 ^ -- Regards, Tomasz ___ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform
Re: Does anybody know how to modify the source code in order to log the executions of the JavaScript functions?
On 1/23/15 7:50 AM, Tomasz wrote: This is not what I wanted :) I want to have the exact URLs of the particular files in which the calls were. So, if a particular method is called from a JavaScript from Doubleclick.net, I expect to get a URL of this JavaScript. Yeah, you didn't say that up front ;) JS::Rooted stack(cx); if (!JS::CaptureCurrentStack(cx, &stack, 1)) { return false; } JS::Rooted source(cx); if (!JS_GetProperty(stack, "source", &source)) { return false; } if (source.isString()) { nsAutoJSString str; if (!str.init(cx, source.toString())) { return false; } printf("%s\n", NS_ConvertUTF16toUTF8(str).get()); } // Obviously you can also print line/column numbers, since this is an // entire stack representation. -Boris ___ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform
Re: Does anybody know how to modify the source code in order to log the executions of the JavaScript functions?
> Remove 'signaling_unittests' from the list of tests in > http://mxr.mozilla.org/mozilla-central/source/media/webrtc/signaling/test/moz.build > Yes, it worked. Now the code compiles. There are, however, several other problems, which I am describing below. > Filing a bug on "Core: WebRTC", pasting your build log, and assigning it > to ":jib" should be good enough, I think; I talked to Jan-Ivar about > this already yesterday so it's not like it will come as a surprise. ;) Perfect. The bug report was filled by me yesterday. For now, the current code looks as follows: -- cgThings = [] if setter: cgThings.append(CGGeneric('printf("setter: ' + nativeMethodName + ' [");\n')) cgThings.append(CGGeneric('nsPIDOMWindow* cwindow = xpc::WindowGlobalOrNull(obj);\n')) cgThings.append(CGGeneric('nsIURI* oURI = 0;\n')) cgThings.append(CGGeneric('if (cwindow) { oURI = cwindow->GetDocumentURI(); }\n')) cgThings.append(CGGeneric('nsCString spec;\n')) cgThings.append(CGGeneric('if (oURI) { oURI->GetAsciiSpec(spec); }\n')) cgThings.append(CGGeneric('if (oURI) { printf("%s", spec.get()); }\n')) cgThings.append(CGGeneric('printf("]\\n");\n')) elif getter: cgThings.append(CGGeneric('printf("getter: ' + nativeMethodName + ' [");\n')) cgThings.append(CGGeneric('nsPIDOMWindow* cwindow = xpc::WindowGlobalOrNull(obj);\n')) cgThings.append(CGGeneric('nsIURI* oURI = 0;\n')) cgThings.append(CGGeneric('if (cwindow) { oURI = cwindow->GetDocumentURI(); }\n')) cgThings.append(CGGeneric('nsCString spec;\n')) cgThings.append(CGGeneric('if (oURI) { oURI->GetAsciiSpec(spec); }\n')) cgThings.append(CGGeneric('if (oURI) { printf("%s", spec.get()); }\n')) cgThings.append(CGGeneric('printf("]\\n");\n')) else: cgThings.append(CGGeneric('printf("method: ' + nativeMethodName + ' [");\n')) cgThings.append(CGGeneric('printf("]\\n");\n')) -- There are, however, 2 important problems: 1. Using this method, I am obtaining only this URL which is displayed at the browser bar (the URL of the currently opened browser tab). This is not what I wanted :) I want to have the exact URLs of the particular files in which the calls were. So, if a particular method is called from a JavaScript from Doubleclick.net, I expect to get a URL of this JavaScript. Any idea how to get that? 2. This methodology works only for getters and setters. When I try to do that with methods, the code does not compile. The main problem is that there are many methods which do not have "obj" as the second parameter. They have sometimes "proxy" or something else, but as far as I saw, all these second function parameters are of the correct type. The only problem is that I do not know how to guess the correct name - or avoid placing my code if the argument of the correct type is not present in the invocation of the method at all. But, this is a minor problem, which can be solved later. Best regards, Tomasz ___ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform
Re: Does anybody know how to modify the source code in order to log the executions of the JavaScript functions?
On 1/22/15 9:30 AM, Tomasz wrote: So, any idea how to fix the following error? Remove 'signaling_unittests' from the list of tests in http://mxr.mozilla.org/mozilla-central/source/media/webrtc/signaling/test/moz.build ? Uh.. why is that #including the binding _cpp_ file? That's broken. Please file a bug on webrtc to not do that? Hmm I know nothing about Python programing (I am a C/C++ and Java developer) This is a C++ bug. signaling_unittests.cpp is doing this: #include "PeerConnectionImplEnumsBinding.cpp" And it's doing this in an environment in which certain #defines are set in such a way that the string classes used are not the normal ones used by bindings. This happens to work completely by accident because PeerConnectionImplEnumsBinding.cpp doesn't #include anything that involves strings too much, but including nsGlobalWindow.h in PeerConnectionImplEnumsBinding.cpp includes some string stuff and the world blows up. Filing a bug on "Core: WebRTC", pasting your build log, and assigning it to ":jib" should be good enough, I think; I talked to Jan-Ivar about this already yesterday so it's not like it will come as a surprise. ;) Thanks, Boris ___ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform
Re: Does anybody know how to modify the source code in order to log the executions of the JavaScript functions?
> Odd. The directory it's in is in LOCAL_INCLUDES in > dom/bindings/moz.build... Try adding it there in > dom/bindings/test/moz.build as well? Thank you, however, the problem still exists. Including nsGlobalWindow.h in the test directory only causes other early errors saying that the file is already included, so I needed to rollback the changes. So, any idea how to fix the following error? --- 5:43.34 In file included from ../../../../dist/include/nsGlobalWindow.h:44:0, 5:43.34 from /home/tomasz/CPPProjects/mozilla-central/obj-x86_64-unknown-linux-gnu/dom/bindings/PeerConnectionImplEnumsBinding.cpp:5, 5:43.34 from /home/tomasz/CPPProjects/mozilla-central/media/webrtc/signaling/test/signaling_unittests.cpp:45: 5:43.34 ../../../../dist/include/nsFrameMessageManager.h: At global scope: 5:43.34 ../../../../dist/include/nsFrameMessageManager.h:66:63: error: type/value mismatch at argument 1 in template parameter list for 'template class nsTArray' 5:43.34 InfallibleTArray* aJSONRetVal, 5:43.34^ 5:43.34 ../../../../dist/include/nsFrameMessageManager.h:66:63: error: expected a type, got 'nsString_external' 5:43.34 ../../../../dist/include/nsFrameMessageManager.h:233:52: error: type/value mismatch at argument 1 in template parameter list for 'template class nsTArray' 5:43.34InfallibleTArray* aJSONRetVal); 5:43.34 ^ 5:43.34 ../../../../dist/include/nsFrameMessageManager.h:233:52: error: expected a type, got 'nsString_external' 5:43.34 ../../../../dist/include/nsFrameMessageManager.h:305:20: error: type/value mismatch at argument 1 in template parameter list for 'template class nsTArray' 5:43.34nsTArray mPendingScripts; 5:43.34 ^ 5:43.34 ../../../../dist/include/nsFrameMessageManager.h:305:20: error: expected a type, got 'nsString_external' 5:43.35 In file included from ../../../../dist/include/nsStringGlue.h:21:0, 5:43.35 from ../../../../dist/include/mozilla/ErrorResult.h:18, 5:43.35 from ../../../../dist/include/mozilla/dom/PeerConnectionObserverEnumsBinding.h:8, 5:43.35 from /home/tomasz/CPPProjects/mozilla-central/media/webrtc/signaling/test/FakePCObserver.h:21, 5:43.35 from /home/tomasz/CPPProjects/mozilla-central/media/webrtc/signaling/test/signaling_unittests.cpp:23: 5:43.35 ../../../../dist/include/nsStringAPI.h:906:40: error: 'nsString_external' does not name a type 5:43.35 #define nsString nsString_external 5:43.35 ^ 5:43.35 ../../../../dist/include/nsFrameMessageManager.h:358:3: note: in expansion of macro 'nsString' 5:43.35nsString mMessage; --- > Uh.. why is that #including the binding _cpp_ file? That's broken. > Please file a bug on webrtc to not do that? Hmm I know nothing about Python programing (I am a C/C++ and Java developer), so I have no idea what I should really report here. Should I just paste the log and write that this error appears after including nsGlobalWindow.h? Best, Tomasz ___ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform
Re: Does anybody know how to modify the source code in order to log the executions of the JavaScript functions?
On 1/21/15 11:22 AM, Tomasz wrote: --- 2:18.70 /home/tomasz/CPPProjects/mozilla-central/obj-x86_64-unknown-linux-gnu/dom/bindings/TestDictionaryBinding.cpp:11:28: fatal error: nsGlobalWindow.h: No such file or directory 2:18.70 #include "nsGlobalWindow.h" --- Odd. The directory it's in is in LOCAL_INCLUDES in dom/bindings/moz.build... Try adding it there in dom/bindings/test/moz.build as well? 9:32.05 In file included from /home/tomasz/CPPProjects/mozilla-central/dom/base/nsGlobalWindow.h:44:0, 9:32.05 from /home/tomasz/CPPProjects/mozilla-central/obj-x86_64-unknown-linux-gnu/dom/bindings/PeerConnectionImplEnumsBinding.cpp:3, 9:32.05 from /home/tomasz/CPPProjects/mozilla-central/media/webrtc/signaling/test/signaling_unittests.cpp:45: Uh.. why is that #including the binding _cpp_ file? That's broken. Please file a bug on webrtc to not do that? -Boris ___ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform
Re: Does anybody know how to modify the source code in order to log the executions of the JavaScript functions?
> You can add nsGlobalWindow.h to the list at > http://mxr.mozilla.org/mozilla-central/source/dom/base/moz.build#42 to > rectify this. Thank you, this is fixed. However, the second problem still exists. Including nsGlobalWindow.h (only that, without any other modifications) causes the following errors and breaks the compilation: --- 5:43.34 In file included from ../../../../dist/include/nsGlobalWindow.h:44:0, 5:43.34 from /home/tomasz/CPPProjects/mozilla-central/obj-x86_64-unknown-linux-gnu/dom/bindings/PeerConnectionImplEnumsBinding.cpp:5, 5:43.34 from /home/tomasz/CPPProjects/mozilla-central/media/webrtc/signaling/test/signaling_unittests.cpp:45: 5:43.34 ../../../../dist/include/nsFrameMessageManager.h: At global scope: 5:43.34 ../../../../dist/include/nsFrameMessageManager.h:66:63: error: type/value mismatch at argument 1 in template parameter list for 'template class nsTArray' 5:43.34 InfallibleTArray* aJSONRetVal, 5:43.34^ 5:43.34 ../../../../dist/include/nsFrameMessageManager.h:66:63: error: expected a type, got 'nsString_external' 5:43.34 ../../../../dist/include/nsFrameMessageManager.h:233:52: error: type/value mismatch at argument 1 in template parameter list for 'template class nsTArray' 5:43.34InfallibleTArray* aJSONRetVal); 5:43.34 ^ 5:43.34 ../../../../dist/include/nsFrameMessageManager.h:233:52: error: expected a type, got 'nsString_external' 5:43.34 ../../../../dist/include/nsFrameMessageManager.h:305:20: error: type/value mismatch at argument 1 in template parameter list for 'template class nsTArray' 5:43.34nsTArray mPendingScripts; 5:43.34 ^ 5:43.34 ../../../../dist/include/nsFrameMessageManager.h:305:20: error: expected a type, got 'nsString_external' 5:43.35 In file included from ../../../../dist/include/nsStringGlue.h:21:0, 5:43.35 from ../../../../dist/include/mozilla/ErrorResult.h:18, 5:43.35 from ../../../../dist/include/mozilla/dom/PeerConnectionObserverEnumsBinding.h:8, 5:43.35 from /home/tomasz/CPPProjects/mozilla-central/media/webrtc/signaling/test/FakePCObserver.h:21, 5:43.35 from /home/tomasz/CPPProjects/mozilla-central/media/webrtc/signaling/test/signaling_unittests.cpp:23: 5:43.35 ../../../../dist/include/nsStringAPI.h:906:40: error: 'nsString_external' does not name a type 5:43.35 #define nsString nsString_external 5:43.35 ^ 5:43.35 ../../../../dist/include/nsFrameMessageManager.h:358:3: note: in expansion of macro 'nsString' 5:43.35nsString mMessage; --- Best regards, Tomasz ___ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform
Re: Does anybody know how to modify the source code in order to log the executions of the JavaScript functions?
On 2015-01-21 11:22 AM, Tomasz wrote: What you need to do is to make sure that nsGlobalWindow.h is included in each generated binding file. The simplest way to do that is to add the line bindingHeaders["nsGlobalWindow.h"] = True where all the other such lines are (e.g. right after the line that sets bindingHeaders["xpcpublic.h"]). Thank you, I just made that, but other issues appear: --- 2:18.70 /home/tomasz/CPPProjects/mozilla-central/obj-x86_64-unknown-linux-gnu/dom/bindings/TestDictionaryBinding.cpp:11:28: fatal error: nsGlobalWindow.h: No such file or directory 2:18.70 #include "nsGlobalWindow.h" --- The problem is that nsGlobalWindow.h is not automatically copied to the build directory, so the compiler does not see it during the later stage of the compilation. When I specify the absolute path to the file You can add nsGlobalWindow.h to the list at http://mxr.mozilla.org/mozilla-central/source/dom/base/moz.build#42 to rectify this. Cheers, Josh ___ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform
Re: Does anybody know how to modify the source code in order to log the executions of the JavaScript functions?
> What you need to do is to make sure that nsGlobalWindow.h is included in > each generated binding file. The simplest way to do that is to add the line > > bindingHeaders["nsGlobalWindow.h"] = True > > where all the other such lines are (e.g. right after the line that sets > bindingHeaders["xpcpublic.h"]). Thank you, I just made that, but other issues appear: --- 2:18.70 /home/tomasz/CPPProjects/mozilla-central/obj-x86_64-unknown-linux-gnu/dom/bindings/TestDictionaryBinding.cpp:11:28: fatal error: nsGlobalWindow.h: No such file or directory 2:18.70 #include "nsGlobalWindow.h" --- The problem is that nsGlobalWindow.h is not automatically copied to the build directory, so the compiler does not see it during the later stage of the compilation. When I specify the absolute path to the file --- bindingHeaders["/home/tomasz/CPPProjects/mozilla-central/dom/base/nsGlobalWindow.h"] = True --- I got the following error, however, the compilation is progressing much more than before (around 9 minutes comparing to 2 minutes before): --- 9:32.05 In file included from /home/tomasz/CPPProjects/mozilla-central/dom/base/nsGlobalWindow.h:44:0, 9:32.05 from /home/tomasz/CPPProjects/mozilla-central/obj-x86_64-unknown-linux-gnu/dom/bindings/PeerConnectionImplEnumsBinding.cpp:3, 9:32.05 from /home/tomasz/CPPProjects/mozilla-central/media/webrtc/signaling/test/signaling_unittests.cpp:45: 9:32.05 /home/tomasz/CPPProjects/mozilla-central/dom/base/nsFrameMessageManager.h: At global scope: 9:32.05 /home/tomasz/CPPProjects/mozilla-central/dom/base/nsFrameMessageManager.h:66:63: error: type/value mismatch at argument 1 in template parameter list for 'template class nsTArray' 9:32.05 InfallibleTArray* aJSONRetVal, 9:32.05^ 9:32.05 /home/tomasz/CPPProjects/mozilla-central/dom/base/nsFrameMessageManager.h:66:63: error: expected a type, got 'nsString_external' 9:32.05 /home/tomasz/CPPProjects/mozilla-central/dom/base/nsFrameMessageManager.h:233:52: error: type/value mismatch at argument 1 in template parameter list for 'template class nsTArray' 9:32.05InfallibleTArray* aJSONRetVal); 9:32.05 ^ 9:32.05 /home/tomasz/CPPProjects/mozilla-central/dom/base/nsFrameMessageManager.h:233:52: error: expected a type, got 'nsString_external' 9:32.05 /home/tomasz/CPPProjects/mozilla-central/dom/base/nsFrameMessageManager.h:305:20: error: type/value mismatch at argument 1 in template parameter list for 'template class nsTArray' 9:32.05nsTArray mPendingScripts; --- So, I am not able to compile the code anyway... Any idea how to solve that? Best, Tomasz ___ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform
Re: Does anybody know how to modify the source code in order to log the executions of the JavaScript functions?
On 1/20/15 11:42 AM, Tomasz wrote: cgThings.append(CGGeneric('nsPIDOMWindow* cwindow = xpc::WindowGlobalOrNull(obj);\n')) Yep, that looks good. error: cannot convert 'nsGlobalWindow*' to 'nsPIDOMWindow*' in initialization Right, because WindowGlobalOrNull returns nsGlobalWindow*, but the header it's declared in only forward-declares the nsGlobalWindow class, so the fact that it inherits from nsPIDOMWindow* is not known in translation units that don't also include nsGlobalWindow.h. error: invalid use of incomplete type 'class nsGlobalWindow' nsIURI* oURI = cwindow->GetDocumentURI(); Yes, this is the same issue. What you need to do is to make sure that nsGlobalWindow.h is included in each generated binding file. The simplest way to do that is to add the line bindingHeaders["nsGlobalWindow.h"] = True where all the other such lines are (e.g. right after the line that sets bindingHeaders["xpcpublic.h"]). -Boris ___ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform
Re: Does anybody know how to modify the source code in order to log the executions of the JavaScript functions?
On 2015-01-20 11:42 AM, Tomasz wrote: You can do something similar to the beginning of mozilla::dom::CheckPermissions to get an nsPIDOMWindow*, and then call GetDocumentURI() on it. Thank you Ehsan. I tried to do that, but I did not afford to make that working. Probably, because I have totally no experience with Firefox code (actually, it is the first time I am looking at it) and I have no idea how the things are implemented there... So, in mozilla-central/dom/bindings/BindingUtils.cpp, there is a function: --- bool CheckPermissions(JSContext* aCx, JSObject* aObj, const char* const aPermissions[]) { JS::Rooted rootedObj(aCx, aObj); nsPIDOMWindow* window = xpc::WindowGlobalOrNull(rootedObj); --- In every file generated by the Python script mozilla-central/dom/bindings/Codegen.py, the function headers are a little bit different, for example: --- set_border_spacing(JSContext* cx, JS::Handle obj, nsDOMCSSDeclaration* self, JSJitSetterCallArgs args) --- It means that the second argument is JS::Handle instead of JSObject* as in the previous case. I found that JS::Handle is just a const reference to JS::Rooted, so, if I understand correctly, I should just add the following line to mozilla-central/dom/bindings/Codegen.py: --- cgThings.append(CGGeneric('nsPIDOMWindow* cwindow = xpc::WindowGlobalOrNull(obj);\n')) --- However, when I do that, an error appears: --- error: cannot convert 'nsGlobalWindow*' to 'nsPIDOMWindow*' in initialization --- So, I tried to use nsGlobalWindow* instead of nsPIDOMWindow*: --- cgThings.append(CGGeneric('nsGlobalWindow* cwindow = xpc::WindowGlobalOrNull(obj);\n')) --- and I obtained no errors from the compiler (only warnings about the unused variable, which is normal). However, I am not able to do anything with this variable. If I try any of the following lines: --- cgThings.append(CGGeneric('nsIURI* oURI = cwindow->GetDocumentURI();\n')) cgThings.append(CGGeneric('nsPIDOMWindow* qwerty = cwindow->GetPrivateParent();\n')) --- I am obtaining 2 different errors: --- error: invalid use of incomplete type 'class nsGlobalWindow' nsIURI* oURI = cwindow->GetDocumentURI(); ../../dist/include/mozilla/dom/ScriptSettings.h:21:7: error: forward declaration of 'class nsGlobalWindow' class nsGlobalWindow --- Any idea what is the problem here? You need to #include "nsGlobalWindow.h" in order to be able to use the type. Look for occurrences of CGHeaders in Codegen.py to see how to add a header #include statement to a generated bindings file. ___ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform
Re: Does anybody know how to modify the source code in order to log the executions of the JavaScript functions?
> You can do something similar to the beginning of > mozilla::dom::CheckPermissions to get an nsPIDOMWindow*, and then call > GetDocumentURI() on it. Thank you Ehsan. I tried to do that, but I did not afford to make that working. Probably, because I have totally no experience with Firefox code (actually, it is the first time I am looking at it) and I have no idea how the things are implemented there... So, in mozilla-central/dom/bindings/BindingUtils.cpp, there is a function: --- bool CheckPermissions(JSContext* aCx, JSObject* aObj, const char* const aPermissions[]) { JS::Rooted rootedObj(aCx, aObj); nsPIDOMWindow* window = xpc::WindowGlobalOrNull(rootedObj); --- In every file generated by the Python script mozilla-central/dom/bindings/Codegen.py, the function headers are a little bit different, for example: --- set_border_spacing(JSContext* cx, JS::Handle obj, nsDOMCSSDeclaration* self, JSJitSetterCallArgs args) --- It means that the second argument is JS::Handle instead of JSObject* as in the previous case. I found that JS::Handle is just a const reference to JS::Rooted, so, if I understand correctly, I should just add the following line to mozilla-central/dom/bindings/Codegen.py: --- cgThings.append(CGGeneric('nsPIDOMWindow* cwindow = xpc::WindowGlobalOrNull(obj);\n')) --- However, when I do that, an error appears: --- error: cannot convert 'nsGlobalWindow*' to 'nsPIDOMWindow*' in initialization --- So, I tried to use nsGlobalWindow* instead of nsPIDOMWindow*: --- cgThings.append(CGGeneric('nsGlobalWindow* cwindow = xpc::WindowGlobalOrNull(obj);\n')) --- and I obtained no errors from the compiler (only warnings about the unused variable, which is normal). However, I am not able to do anything with this variable. If I try any of the following lines: --- cgThings.append(CGGeneric('nsIURI* oURI = cwindow->GetDocumentURI();\n')) cgThings.append(CGGeneric('nsPIDOMWindow* qwerty = cwindow->GetPrivateParent();\n')) --- I am obtaining 2 different errors: --- error: invalid use of incomplete type 'class nsGlobalWindow' nsIURI* oURI = cwindow->GetDocumentURI(); ../../dist/include/mozilla/dom/ScriptSettings.h:21:7: error: forward declaration of 'class nsGlobalWindow' class nsGlobalWindow --- Any idea what is the problem here? Best regards, Tomasz ___ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform
Re: Does anybody know how to modify the source code in order to log the executions of the JavaScript functions?
On 2015-01-19 11:33 AM, Tomasz wrote: Thank you very much, it works as expected. The code, which I added to the function, is: if setter: cgThings.append(CGGeneric('printf("setter: ' + nativeMethodName + '\\n");\n')) elif getter: cgThings.append(CGGeneric('printf("getter: ' + nativeMethodName + '\\n");\n')) else: cgThings.append(CGGeneric('printf("method: ' + nativeMethodName + '\\n");\n')) What about the document URL? Is it also possible to print it somewhere in the code in a way that the document URL will appear exactly before all the embedded methods / setters / getters? You can do something similar to the beginning of mozilla::dom::CheckPermissions to get an nsPIDOMWindow*, and then call GetDocumentURI() on it. On Monday, January 19, 2015 at 3:29:52 PM UTC+1, Josh Matthews wrote: Half of the battle is modifying CGPerSignatureCall in Codegen.py - that will get you the name of the DOM implementation method being invoked and deals with both DOM methods and DOM getters/setters. Getting the owning document URL is a separate struggle. Cheers, Josh On 2015-01-19 7:57 AM, Tomasz wrote: Hi all, I would like to modify the Firefox source code in order to log every execution of any JavaScript API function (or object method) invoked by any JavaScript code on any website together with the full URL to the file which contained the JavaScript code. For example, we have the following files, which include (among others) the following statements: * http://www.aaa.com/dir1/file1.htm var x = document.getElementById("demo"); * http://www.bbb.com/dirT/file44.htm var c = document.getElementById("myCanvas"); var ctx = c.getContext("2d"); ctx.fillStyle = "#FF"; ctx.fillRect(0,0,150,75); I would like to automatically log the execution of these functions as: http://www.aaa.com/dir1/file1.htm | getElementById http://www.bbb.com/dirT/file44.htm | getElementById http://www.bbb.com/dirT/file44.htm | getContext http://www.bbb.com/dirT/file44.htm | fillRect If it is possible, I would also like to separately log all the set / read properties, as: http://www.bbb.com/dirT/file44.htm | fillStyle I know that the JavaScript API functions are implemented in Firefox in 2 ways: as C++ functions or JavaScript functions. However, I do not care how the functions are internally implemented - I just want to log all the executions. Is there any easy way to do that besides adding logging statements to every single JavaScript function we want to log? Thank you for all your suggestions in advance. Best regards, Tomasz ___ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform ___ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform
Re: Does anybody know how to modify the source code in order to log the executions of the JavaScript functions?
Thank you very much, it works as expected. The code, which I added to the function, is: if setter: cgThings.append(CGGeneric('printf("setter: ' + nativeMethodName + '\\n");\n')) elif getter: cgThings.append(CGGeneric('printf("getter: ' + nativeMethodName + '\\n");\n')) else: cgThings.append(CGGeneric('printf("method: ' + nativeMethodName + '\\n");\n')) What about the document URL? Is it also possible to print it somewhere in the code in a way that the document URL will appear exactly before all the embedded methods / setters / getters? Tomasz On Monday, January 19, 2015 at 3:29:52 PM UTC+1, Josh Matthews wrote: > Half of the battle is modifying CGPerSignatureCall in Codegen.py - that > will get you the name of the DOM implementation method being invoked and > deals with both DOM methods and DOM getters/setters. Getting the owning > document URL is a separate struggle. > > Cheers, > Josh > > On 2015-01-19 7:57 AM, Tomasz wrote: > > Hi all, > > > > I would like to modify the Firefox source code in order to log every > > execution of any JavaScript API function (or object method) invoked by any > > JavaScript code on any website together with the full URL to the file which > > contained the JavaScript code. > > > > For example, we have the following files, which include (among others) the > > following statements: > > > > > > * http://www.aaa.com/dir1/file1.htm > > var x = document.getElementById("demo"); > > > > * http://www.bbb.com/dirT/file44.htm > > > > var c = document.getElementById("myCanvas"); > > var ctx = c.getContext("2d"); > > ctx.fillStyle = "#FF"; > > ctx.fillRect(0,0,150,75); > > > > > > I would like to automatically log the execution of these functions as: > > > > http://www.aaa.com/dir1/file1.htm | getElementById > > http://www.bbb.com/dirT/file44.htm | getElementById > > http://www.bbb.com/dirT/file44.htm | getContext > > http://www.bbb.com/dirT/file44.htm | fillRect > > > > If it is possible, I would also like to separately log all the set / read > > properties, as: > > > > http://www.bbb.com/dirT/file44.htm | fillStyle > > > > I know that the JavaScript API functions are implemented in Firefox in 2 > > ways: as C++ functions or JavaScript functions. However, I do not care how > > the functions are internally implemented - I just want to log all the > > executions. Is there any easy way to do that besides adding logging > > statements to every single JavaScript function we want to log? > > > > Thank you for all your suggestions in advance. > > > > Best regards, > > Tomasz > > ___ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform
Re: Does anybody know how to modify the source code in order to log the executions of the JavaScript functions?
Half of the battle is modifying CGPerSignatureCall in Codegen.py - that will get you the name of the DOM implementation method being invoked and deals with both DOM methods and DOM getters/setters. Getting the owning document URL is a separate struggle. Cheers, Josh On 2015-01-19 7:57 AM, Tomasz wrote: Hi all, I would like to modify the Firefox source code in order to log every execution of any JavaScript API function (or object method) invoked by any JavaScript code on any website together with the full URL to the file which contained the JavaScript code. For example, we have the following files, which include (among others) the following statements: * http://www.aaa.com/dir1/file1.htm var x = document.getElementById("demo"); * http://www.bbb.com/dirT/file44.htm var c = document.getElementById("myCanvas"); var ctx = c.getContext("2d"); ctx.fillStyle = "#FF"; ctx.fillRect(0,0,150,75); I would like to automatically log the execution of these functions as: http://www.aaa.com/dir1/file1.htm | getElementById http://www.bbb.com/dirT/file44.htm | getElementById http://www.bbb.com/dirT/file44.htm | getContext http://www.bbb.com/dirT/file44.htm | fillRect If it is possible, I would also like to separately log all the set / read properties, as: http://www.bbb.com/dirT/file44.htm | fillStyle I know that the JavaScript API functions are implemented in Firefox in 2 ways: as C++ functions or JavaScript functions. However, I do not care how the functions are internally implemented - I just want to log all the executions. Is there any easy way to do that besides adding logging statements to every single JavaScript function we want to log? Thank you for all your suggestions in advance. Best regards, Tomasz ___ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform