Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/control/ContextReceiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,15 @@ namespace ContextReceiver {
export function applyBreakpoint(breakpointId: string, source: string | undefined, line: number,
frames: Debugger.CallFrame[], variables) {
debugLog(`applyBreakpoint: ${breakpointId} ${source} ${line}`);
let activeSpan = ContextManager.current.newLocalSpan(callFrameToString(frames[0]));

let liveBreakpoint = SourcePlusPlus.liveInstrumentRemote.instruments.get(breakpointId);
if (liveBreakpoint.throttle.isRateLimited()) {
return;
} else {
//todo: eval condition
}

let activeSpan = ContextManager.current.newLocalSpan(callFrameToString(frames[0]));
activeSpan.start();

let localVars = variables['local'];
Expand Down Expand Up @@ -94,6 +101,16 @@ namespace ContextReceiver {
})

activeSpan.stop();

if (liveBreakpoint.isFinished()) {
debugLog(`Finished breakpoint: ${breakpointId}`);
SourcePlusPlus.liveInstrumentRemote.removeInstrument(breakpointId);

SourcePlusPlus.liveInstrumentRemote.eventBus.publish("spp.processor.status.live-instrument-removed", {
instrument: JSON.stringify(liveBreakpoint.toJson()),
occurredAt: Date.now()
})
}
}

export function applyLog(liveLogId: string, logFormat: string, logArguments: any) {
Expand Down
28 changes: 28 additions & 0 deletions test/HitLimitTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const assert = require('assert');
const TestUtils = require("./TestUtils.js");

module.exports = function () {
function hitLimit() {
TestUtils.addLineLabel("done", () => TestUtils.getLineNumber())
}

it('add live breakpoint', async function () {
hitLimit() //setup labels

await TestUtils.addLiveBreakpoint({
"source": TestUtils.getFilename()(),
"line": TestUtils.getLineLabelNumber("done")
}, null, 1).then(function (res) {
assert.equal(res.status, 200);
hitLimit(); //trigger breakpoint
}).catch(function (err) {
assert.fail(err)
});
});

it('verify breakpoint removed', async function () {
this.timeout(2000)
let event = await TestUtils.awaitMarkerEvent("BREAKPOINT_REMOVED");
assert.notEqual(event, null);
});
};
3 changes: 2 additions & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ after(TestUtils.teardownProbe);

describe("test simple primitives", require("./SimplePrimitivesLiveInstrumentTest"));
describe("test simple collections", require("./SimpleCollectionsLiveInstrumentTest"));
describe("test live log", require("./LiveLogTest"));
describe("test live log", require("./LiveLogTest"));
describe("test hit limit", require("./HitLimitTest"));