繁体   English   中英

在Chrome Dev Tools中停用和禁用断点之间的区别是什么

[英]What's the difference between deactivating and disabling a breakpoint in Chrome Dev Tools

Chrome(版本23.0.1271.101)。 我在OS X上,如果这甚至很重要的话。

为什么Chrome可以禁用和/或停用断点? 是否有一些我不知道的用电?

注意到,我可以禁用一些断点,然后关闭所有。 重新激活它们后,将禁用相同的禁用它们。 除此之外,拥有这两个选项的目的是什么?

在此输入图像描述

Deactivate Breakpoints将关闭断点功能。 禁用所有断点是将每个断点标记为已禁用的快捷方式。

比较启用所有断点和激活断点时,差异会变得更清晰。

可以通过每个断点旁边的复选框启用或禁用单个断点。

在此输入图像描述

禁用所有断点取消选中所有断点,实际上会关闭断点功能。 Deactivate Breakpoints显式关闭断点功能。 所以这两个选项具有相同的效果。

Activate Breakpoints启用断点功能,保留各个断点的启用/禁用状态。 Enable All Breakpoints启用每个断点,但如果已取消激活,则不会打开断点功能。

这是最近铬源的断点原型。 如您所见,启用或禁用断点。 我没有看到任何可能反映断点被“禁用”或“停用”的属性。 也许它与条件有关。 否则我会说这是一个前端不一致。

WebInspector.BreakpointManager.Breakpoint.prototype = {
/**
 * @return {WebInspector.UILocation}
 */
primaryUILocation: function()
{
    return this._primaryUILocation;
},

/**
 * @param {WebInspector.DebuggerModel.Location} location
 */
_addResolvedLocation: function(location)
{
    this._liveLocations.push(this._breakpointManager._debuggerModel.createLiveLocation(location, this._locationUpdated.bind(this, location)));
},

/**
 * @param {WebInspector.DebuggerModel.Location} location
 * @param {WebInspector.UILocation} uiLocation
 */
_locationUpdated: function(location, uiLocation)
{
    var stringifiedLocation = location.scriptId + ":" + location.lineNumber + ":" + location.columnNumber;
    var oldUILocation = /** @type {WebInspector.UILocation} */ (this._uiLocations[stringifiedLocation]);
    if (oldUILocation)
        this._breakpointManager._uiLocationRemoved(this, oldUILocation);
    if (this._uiLocations[""]) {
        delete this._uiLocations[""];
        this._breakpointManager._uiLocationRemoved(this, this._primaryUILocation);
    }
    this._uiLocations[stringifiedLocation] = uiLocation;
    this._breakpointManager._uiLocationAdded(this, uiLocation);
},

/**
 * @return {boolean}
 */
enabled: function()
{
    return this._enabled;
},

/**
 * @param {boolean} enabled
 */
setEnabled: function(enabled)
{
    this._updateBreakpoint(this._condition, enabled);
},

/**
 * @return {string}
 */
condition: function()
{
    return this._condition;
},

/**
 * @param {string} condition
 */
setCondition: function(condition)
{
    this._updateBreakpoint(condition, this._enabled);
},

/**
 * @param {string} condition
 * @param {boolean} enabled
 */
_updateBreakpoint: function(condition, enabled)
{
    if (this._enabled === enabled && this._condition === condition)
        return;

    if (this._enabled)
        this._removeFromDebugger();

    this._enabled = enabled;
    this._condition = condition;
    this._breakpointManager._storage._updateBreakpoint(this);

    var scriptFile = this._primaryUILocation.uiSourceCode.scriptFile();
    if (this._enabled && !(scriptFile && scriptFile.hasDivergedFromVM())) {
        this._setInDebugger();
        return;
    }

    this._fakeBreakpointAtPrimaryLocation();
},

/**
 * @param {boolean=} keepInStorage
 */
remove: function(keepInStorage)
{
    var removeFromStorage = !keepInStorage;
    this._resetLocations();
    this._removeFromDebugger();
    this._breakpointManager._removeBreakpoint(this, removeFromStorage);
},

_setInDebugger: function()
{
    var rawLocation = this._primaryUILocation.uiLocationToRawLocation();
    var debuggerModelLocation = /** @type {WebInspector.DebuggerModel.Location} */ (rawLocation);
    if (debuggerModelLocation)
        this._breakpointManager._debuggerModel.setBreakpointByScriptLocation(debuggerModelLocation, this._condition, didSetBreakpoint.bind(this));
    else
        this._breakpointManager._debuggerModel.setBreakpointByURL(this._primaryUILocation.uiSourceCode.url, this._primaryUILocation.lineNumber, 0, this._condition, didSetBreakpoint.bind(this));

    /**
     * @this {WebInspector.BreakpointManager.Breakpoint}
     * @param {?DebuggerAgent.BreakpointId} breakpointId
     * @param {Array.<WebInspector.DebuggerModel.Location>} locations
     */
    function didSetBreakpoint(breakpointId, locations)
    {
        if (!breakpointId) {
            this._resetLocations();
            this._breakpointManager._removeBreakpoint(this, false);
            return;
        }

        this._debuggerId = breakpointId;
        this._breakpointManager._breakpointForDebuggerId[breakpointId] = this;

        if (!locations.length) {
            this._fakeBreakpointAtPrimaryLocation();
            return;
        }

        this._resetLocations();
        for (var i = 0; i < locations.length; ++i) {
            var script = this._breakpointManager._debuggerModel.scriptForId(locations[i].scriptId);
            var uiLocation = script.rawLocationToUILocation(locations[i].lineNumber, locations[i].columnNumber);
            if (this._breakpointManager.findBreakpoint(uiLocation.uiSourceCode, uiLocation.lineNumber)) {
                // location clash
                this.remove();
                return;
            }
        }

        for (var i = 0; i < locations.length; ++i)
            this._addResolvedLocation(locations[i]);
    }
},

_removeFromDebugger: function()
{
    if (this._debuggerId) {
        this._breakpointManager._debuggerModel.removeBreakpoint(this._debuggerId);
        delete this._breakpointManager._breakpointForDebuggerId[this._debuggerId];
        delete this._debuggerId;
    }
},

_resetLocations: function()
{
    for (var stringifiedLocation in this._uiLocations)
        this._breakpointManager._uiLocationRemoved(this, this._uiLocations[stringifiedLocation]);

    for (var i = 0; i < this._liveLocations.length; ++i)
        this._liveLocations[i].dispose();
    this._liveLocations = [];

    this._uiLocations = {};
},

/**
 * @return {string}
 */
_breakpointStorageId: function()
{
    return this._sourceFileId + ":" + this._primaryUILocation.lineNumber;
},

_fakeBreakpointAtPrimaryLocation: function()
{
    this._resetLocations();
    this._uiLocations[""] = this._primaryUILocation;
    this._breakpointManager._uiLocationAdded(this, this._primaryUILocation);
}
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM