Expose jsdbg2 Debugger object as an XPCOM component

RESOLVED FIXED in mozilla9



JavaScript Engine
6 years ago
6 years ago


(Reporter: jorendorff, Assigned: jorendorff)



Dependency tree / graph

Firefox Tracking Flags

(Not tracked)



(1 attachment, 3 obsolete attachments)



6 years ago
Dave Camp wrote code to do this. It works like so:

  var xpcDebugger = Cc["@mozilla.org/jsdebugger;1"].getService(Ci.nsIJSDebugger);

The addClass() method modifies the current global, adding a Debugger constructor. Then you can do stuff like:

  var dbg = new Debugger(anyContentWindow);
  dbg.onDebuggerStatement = function (frame) {
      alert("this is your debugger speaking");
  anyContentWindow.setTimeout("debugger;", 0);

We have the code, with some tests even. We can expose this stuff to extension developers for FF8.

Comment 1

6 years ago
Created attachment 553224 [details] [diff] [review]

This is what Dave Camp hacked together. I got several useful comments on IRC about the approach, so I'm going to rearrange it completely and post a new patch. :)
Assignee: general → jorendorff
Note that I've updated these tests to work with the new Debugger API (onDebuggerStatement, etc.) in bug 676605. The fixes are still a WIP, but you can find them in my patch queue:



6 years ago
Duplicate of this bug: 677389

Comment 4

6 years ago
Created attachment 553305 [details] [diff] [review]

This one passes tests. The new .jsm was one of the IRC recommendations I got.

The other is to move the whole thing under the js/ directory. I think maybe js/components/{ctypes,debugger,reflect}, though I'll do the other two separately.
Attachment #553224 - Attachment is obsolete: true
Blocks: 679189
Blocks: 679165

Comment 5

6 years ago
Created attachment 553992 [details] [diff] [review]

I don't know who likes to give reviews and super-reviews on new components like this. Feel free to dodge, as long as there's someone standing behind you.
Attachment #553305 - Attachment is obsolete: true
Attachment #553992 - Flags: superreview?(benjamin)
Attachment #553992 - Flags: review?(ted.mielczarek)
Comment on attachment 553992 [details] [diff] [review]

Please use straight js/debugger. components/ is an unfortunate artifact of directory history we should avoid.
Attachment #553992 - Flags: superreview?(benjamin) → superreview+

Comment 7

6 years ago
I don't want to use js/debugger because that directory name looks like there might be something interesting in there, which would be totally untrue--it's just unloved glue code.

So following tense negotiations on IRC, bsmedberg and I have settled on
js/ductwork/debugger. Seriously.

Later I'll move toolkit/ctypes and toolkit/reflect under js/ductwork, and we can then happily forget about them until the revolution comes.

Comment 8

6 years ago
Created attachment 554366 [details] [diff] [review]
v4 - same as v3 but rename js/components to js/ductwork

Carrying forward bsmedberg's sr+.
Attachment #553992 - Attachment is obsolete: true
Attachment #553992 - Flags: review?(ted.mielczarek)
Attachment #554366 - Flags: superreview+
Attachment #554366 - Flags: review?(ted.mielczarek)

Comment 9

6 years ago
Actually it's not quite the same. v4 removes enter/exitNestedEventLoop and eventLoopNestLevel, at dcamp's encouragement.
Comment on attachment 554366 [details] [diff] [review]
v4 - same as v3 but rename js/components to js/ductwork

Review of attachment 554366 [details] [diff] [review]:

::: js/ductwork/Makefile.in
@@ +19,5 @@
> +# the Initial Developer. All Rights Reserved.
> +#
> +# Contributor(s):
> +#  Brian Ryner <bryner@brianryner.com>
> +#  Benjamin Smedberg <benjamin@smedbergs.us>

I'm sure you copy-pasted these from somewhere, but you can probably remove the contributors from these new files you're adding, since they're pretty much all yours. Also, change copyright dates to 2011 while you're copy-pasting?

::: js/ductwork/debugger/Makefile.in
@@ +55,5 @@
> +
> +CPPSRCS = \
> +    nsJSDebugger.cpp \
> +    $(NULL)

Two-space indent after line continuations, please.

@@ +64,5 @@
> +    $(NULL)
> +
> +	jsdebugger.jsm \
> +	$(NULL)

Two-space, as above, and please don't use actual tabs in Makefiles except before rule commands where they're required.

@@ +72,5 @@
> +	$(NULL)
> +
> +    DIRS += tests
> +endif

It's not really typical to indent inside conditionals in Makefiles, but I don't have strong feelings against it if you like it.

::: toolkit/components/ctypes/ctypes.jsm
@@ +52,5 @@
> +// Initialize the Debugger object. You do not need to do this yourself.
> +const init = Components.classes["@mozilla.org/jsdebugger;1"].createInstance(Components.interfaces.nsIJSDebugger);
> +init.addClass();
> +Debugger.util = init;

Is there a reason this has a two-step init? I assume addClass adds Debugger, but why can't it setup its own .util?

Not super-worried about this, this is all awful ductwork that we really ought to rip out and replace with something better.

::: js/ductwork/debugger/nsJSDebugger.cpp
@@ +1,1 @@
> +/* -*-  Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */

Dare to dream and leave off the ns prefix?

::: js/ductwork/debugger/tests/Makefile.in
@@ +44,5 @@
> +include $(DEPTH)/config/autoconf.mk
> +
> +MODULE          = test_debugger
> +

You could feasibly move this up a level and just have XPCSHELL_TESTS = tests in js/ductwork/debugger/Makefile.in, which would save us a make invocation.
Attachment #554366 - Flags: review?(ted.mielczarek) → review+

Comment 11

6 years ago
OK, I made all those changes, except that

(In reply to Ted Mielczarek [:ted, :luser] from comment #10)
> Is there a reason this has a two-step init? I assume addClass adds Debugger,
> but why can't it setup its own .util?

I ripped this out in v4.

I'll land this tonight.

Comment 12

6 years ago
Whiteboard: [inbound]

Comment 13

6 years ago
I backed it out. The test fails! Which is pretty annoying--it doesn't fail here. I'll look at it tomorrow morning.
Whiteboard: [inbound]

Comment 14

6 years ago
Ted figured it out for me. It was failing only after 'make package', due to a missing manifest entry for an xpt file.

So I added that, confirmed with Try server, and pushed.
Whiteboard: [inbound]
Last Resolved: 6 years ago
OS: Mac OS X → All
Hardware: x86 → All
Resolution: --- → FIXED
Whiteboard: [inbound]
Target Milestone: --- → mozilla9
Version: Other Branch → Trunk


6 years ago
Blocks: 683894


6 years ago
Keywords: dev-doc-needed
Added a doc for the IJSDebugger interface, which strongly recommends not using it.

Keywords: dev-doc-needed → dev-doc-complete
You need to log in before you can comment on or make changes to this bug.