Skip to content
This repository was archived by the owner on Oct 15, 2020. It is now read-only.

Commit b612f0e

Browse files
mrkmarronkfarnung
authored andcommitted
lib,src: enable TTD auto-trace config
Also updated TTD Readme PR-URL: #543 Reviewed-By: Jimmy Thomson <jithomso@microsoft.com> Reviewed-By: Kyle Farnung <kfarnung@microsoft.com>
1 parent b621e3c commit b612f0e

File tree

4 files changed

+20
-12
lines changed

4 files changed

+20
-12
lines changed

TTD-README.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,27 +63,25 @@ to understand the problem.
6363

6464
TTD functionality is available in Node-ChakraCore and is supported by
6565
[VSCode](https://code.visualstudio.com/). You can use VSCode to debug diagnostic
66-
traces even if you don't have the project sources available. This is done by:
67-
- Creating an empty `dummy.js` file in the trace directory.
68-
- Adding the following configuration into your `.vscode\launch.json`
69-
configuration file.
66+
traces even if you don't have the project sources available. This is done by
67+
adding the following configuration into your `.vscode\launch.json`configuration
68+
file.
7069

7170
```json
7271
{
7372
"name": "Trace Debug",
7473
"type": "node",
7574
"request": "launch",
7675
"stopOnEntry": true,
77-
"program": "${workspaceRoot}/dummy.js",
7876
"windows": { "runtimeExecutable": "nvs.cmd" },
7977
"osx": { "runtimeExecutable": "nvs" },
8078
"linux": { "runtimeExecutable": "nvs" },
8179
"runtimeArgs": [
8280
"run",
83-
"chakracore-nightly",
81+
"chakracore",
8482
"--nolazy",
8583
"--break-first",
86-
"--replay-debug=./"
84+
"--replay-debug=[path to trace directory]"
8785
],
8886
"console": "internalConsole"
8987
}

lib/trace_mgr.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -489,13 +489,13 @@ function generateFuzzyStack(eventKind) {
489489
return directIsAbsolute(frame);
490490
});
491491

492-
const lastframe = errstk.length > 0 ?
493-
errstk[errstk.length - 1] :
494-
'empty_stack';
495-
496-
const fname = lastframe.substr(lastframe.lastIndexOf(path.sep) + 1)
492+
let fname = 'empty_stack';
493+
if (errstk.length !== 0) {
494+
const lastframe = errstk[errstk.length - 1];
495+
fname = lastframe.substr(lastframe.lastIndexOf(path.sep) + 1)
497496
.replace('.js:', '_line-')
498497
.replace(':', '_column-');
498+
}
499499

500500
// Identify which frames are recursive (appear multiple times in the stack)
501501
const recFrames = new Map();

src/chakra_ttd.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
extern bool s_doTTRecord;
1212
extern bool s_doTTReplay;
1313
extern bool s_doTTEnableDebug;
14+
extern bool s_ttAutoTraceEnabled;
1415
#endif
1516

1617
#endif // SRC_CHAKRA_TTD_H_

src/node.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ bool s_doTTRecord = false;
126126
bool s_doTTReplay = false;
127127
bool s_doTTEnableDebug = false;
128128
size_t s_ttoptReplayUriLength = 0;
129+
bool s_ttAutoTraceEnabled = true;
129130
const char* s_ttoptReplayUri = nullptr;
130131
uint32_t s_ttdSnapInterval = 2000;
131132
uint32_t s_ttdSnapHistoryLength = 2;
@@ -3582,6 +3583,8 @@ static void PrintHelp() {
35823583
" --replay-debug=dir replay and debug using recording log\n"
35833584
" --break-first break at first statement when running\n"
35843585
" in --replay-debug mode\n"
3586+
" --disable-auto-trace disable the auto-trace feature during\n"
3587+
" record\n"
35853588
#endif
35863589
" --track-heap-objects track heap object allocations for heap "
35873590
"snapshots\n"
@@ -3914,6 +3917,8 @@ static void ParseArgs(int* argc,
39143917
} else if (strstr(arg, "--record-history=") == arg) {
39153918
const char* historyStr = arg + strlen("--record-history=");
39163919
s_ttdSnapHistoryLength = (uint32_t)atoi(historyStr);
3920+
} else if (strcmp(arg, "--disable-auto-trace") == 0) {
3921+
s_ttAutoTraceEnabled = false;
39173922
} else if (strstr(arg, "-TTRecord:") == arg) {
39183923
TTDFlagWarning(arg, "--record");
39193924
} else if (strstr(arg, "-TTReplay:") == arg) {
@@ -4676,6 +4681,10 @@ inline int Start(Isolate* isolate, void* isolate_context,
46764681
if (s_doTTRecord) {
46774682
fprintf(stderr, "Recording started (after main module loaded)...\n");
46784683
JsTTDStart();
4684+
4685+
if (!s_ttAutoTraceEnabled) {
4686+
JsTTDDiagSetAutoTraceStatus(s_ttAutoTraceEnabled);
4687+
}
46794688
}
46804689
#endif
46814690

0 commit comments

Comments
 (0)