Closed Bug 1520972 Opened 6 years ago Closed 6 years ago

Handle log points in the server

Categories

(DevTools :: Debugger, enhancement)

enhancement
Not set
normal

Tracking

(firefox67 fixed)

RESOLVED FIXED
Firefox 67
Tracking Status
firefox67 --- fixed

People

(Reporter: bhackett1024, Assigned: bhackett1024)

References

Details

Attachments

(1 file, 3 obsolete files)

Currently, log points are implemented as a special kind of breakpoint condition --- the logged value is wrapped in a console.log() call and added to the breakpoint's condition. It would be nicer if log points were handled in the server instead. This provides the following advantages:

  • The server can more carefully manage how the log point is implemented. One bug in the current implementation is that logged messages have a 'debugger eval' filename associated with them, rather than the location of the log point. While the attached patch does not fix this, I don't think this can be fixed without handling the log in the server. Log points have a separate implementation when replaying, and this can be tapped into much more easily if the server knows it is dealing with a log point.

  • The client's state can be more easily managed when the logging string is separate state from the condition. The current implementation can expose the 'console.log()' call to users, if for example a log point is added and its condition is then edited.

The attached patch makes this change: the condition and logged string are both stored in an options object which is attached to the breakpoint in both the server and client. A few other aspects of breakpoint handling are tidied up, such as the need to delete breakpoints when changing their condition.

Attached patch patch (obsolete) (deleted) — Splinter Review

Patch with both server and client changes. I'm going to try to split this up into two pieces --- a client side piece which can land to debugger.html by itself, and another operating on the server and the server/client interface.

Attached patch patch (obsolete) (deleted) — Splinter Review

This patch applies on top of the debugger.html changes in https://github.com/devtools-html/debugger.html/pull/7749 and takes care of changes to the server/client interface and the server itself.

Attachment #9037428 - Attachment is obsolete: true
Attachment #9037446 - Flags: review?(jlaster)
Comment on attachment 9037446 [details] [diff] [review] patch Review of attachment 9037446 [details] [diff] [review]: ----------------------------------------------------------------- ::: devtools/server/actors/breakpoint.js @@ +120,5 @@ > + column: columnNumber, > + executionPoint: point, > + message: "return" in rv ? "" + rv.return : "" + rv.throw, > + }; > + this.conn.send(packet); I forgot to note earlier, but the logic here depends on part 3 of bug 1513118, which adds devtools support for virtual console logs when we're replaying.
Severity: normal → enhancement
Comment on attachment 9037446 [details] [diff] [review] patch Review of attachment 9037446 [details] [diff] [review]: ----------------------------------------------------------------- a couple comments. But looking good. ::: devtools/server/actors/breakpoint.js @@ +101,5 @@ > }, > > + // Update any state affected by changing options on a script this breakpoint > + // is associated with. > + _updateOptionsForScript(script, offsets, oldOptions, newOptions) { maybe we should leave this out of this patch and add it in 1513118 @@ +218,5 @@ > + } > + > + // In the non-replaying case, log values are handled by treating them as > + // conditions. console.log() never returns true so we will not pause. > + const condition = this.options.logValue ? `console.log(${this.options.logValue})` i forgot why we went with logValue and not log @@ +219,5 @@ > + > + // In the non-replaying case, log values are handled by treating them as > + // conditions. console.log() never returns true so we will not pause. > + const condition = this.options.logValue ? `console.log(${this.options.logValue})` > + : this.options.condition; It would be nice to have conditional log points, 1. check if the condition is true 2. if true, evaluate `console.log(logValue)` we can do that here or in a follow up

(In reply to Jason Laster [:jlast] from comment #4)

Comment on attachment 9037446 [details] [diff] [review]
patch

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

a couple comments. But looking good.

::: devtools/server/actors/breakpoint.js
@@ +101,5 @@

},

  • // Update any state affected by changing options on a script this breakpoint
  • // is associated with.
  • _updateOptionsForScript(script, offsets, oldOptions, newOptions) {

maybe we should leave this out of this patch and add it in 1513118

Well, the logic in this function has already been reviewed in part 3 of bug 1513118. It's a little awkward given the complicated history of these two bugs for it to have moved over here, but I don't think it needs to be reviewed again and can be ignored in this patch.

@@ +218,5 @@

  •  }
    
  •  // In the non-replaying case, log values are handled by treating them as
    
  •  // conditions. console.log() never returns true so we will not pause.
    
  •  const condition = this.options.logValue ? `console.log(${this.options.logValue})`
    

i forgot why we went with logValue and not log

I picked logValue because it has a clearer meaning when reading and is easier to grep for. I don't feel strongly one way or the other though.

@@ +219,5 @@

  •  // In the non-replaying case, log values are handled by treating them as
    
  •  // conditions. console.log() never returns true so we will not pause.
    
  •  const condition = this.options.logValue ? `console.log(${this.options.logValue})`
    
  •                                          : this.options.condition;
    

It would be nice to have conditional log points,

  1. check if the condition is true
  2. if true, evaluate console.log(logValue)

we can do that here or in a follow up

Sure, I can fix that now. I thought about doing this but didn't for some reason that I don't remember now.

Attached patch patch (deleted) — Splinter Review

Updated patch with server-side support for conditional log points.

Attachment #9037446 - Attachment is obsolete: true
Attachment #9037446 - Flags: review?(jlaster)
Attachment #9039371 - Flags: review?(jlaster)

What do you think about having a server unit test for a breakpoint with a log + condition.

e.g. https://searchfox.org/mozilla-central/source/devtools/server/tests/unit/test_conditional_breakpoint-01.js

(In reply to Jason Laster [:jlast] from comment #7)

What do you think about having a server unit test for a breakpoint with a log + condition.

e.g. https://searchfox.org/mozilla-central/source/devtools/server/tests/unit/test_conditional_breakpoint-01.js

Sure, I can add a unit test before landing.

Comment on attachment 9039371 [details] [diff] [review] patch Review of attachment 9039371 [details] [diff] [review]: ----------------------------------------------------------------- Looks good to me.
Attachment #9039371 - Flags: review?(jlaster) → review+
Pushed by bhackett@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/89bc47c1926c Handle log points in the devtools server, r=jlast.
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 67
Attachment #9041695 - Attachment is obsolete: true
Comment on attachment 9039371 [details] [diff] [review] patch Review of attachment 9039371 [details] [diff] [review]: ----------------------------------------------------------------- ::: devtools/server/actors/breakpoint.js @@ +81,3 @@ > */ > + addScript: function(script, offsets) { > + this.scripts.set(script, offsets.concat(this.scripts.get(offsets) || [])); FYI, I just noticed there's a typo here. This should be `.get(script)`.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: