Epizoda
Defrag Tools #170 – Ladicí program – Skriptování JavaScriptu
V této epizodě Defrag Tools, Andrew Richards hovoří s Andy Luhrs a Bill Messmer z týmu Debugging Tools for Windows . Hovoříme o nových možnostech rozšiřitelnosti a skriptování Jazyka JavaScript ve WinDbg, které jsou k dispozici v buildu WDK a SDK 14951 a novějším.
- Blog- https://blogs.msdn.microsoft.com/windbg/
- E-mail- windbgfb@microsoft.com
Faktura využila objektový model ladicího programu dříve v těchto epizodách:
- Defrag Tools #138 - Debugging - 'dx' Command Part 1
- Defrag Tools #139 - Debugging - 'dx' Command Part 2
- Defrag Tools #169 - Debugging Tools for Windows Team
Časová osa:
[00:00] Vítejte a úvod
[00:24] Nová sada SDK drop
[00:29] Proč JavaScript
[02:07] Nové příkazy
[03:50] Visual Studio Code
[04:00] Příklad – Hello World
[07:15] Výchozí obory názvů ladicího programu
[09:07] Příklad – Tisk všech vláken
[10:26] Příklad – podmíněná zarážka
[18:13] 'g' vs. 'gc' - Andrew měl pravdu! Příkaz gc obnoví provádění stejným způsobem, jakým se spustil. Takže pokud stisknete "p" a pak dosáhnete podmíněné zarážky, která má v něm "gc", 'gc' dokončí vaše počáteční 'p'.
[20:40] Příklad – jedinečné zásobníky
[34:40] Příklad – sčítání
Máte dotazy nebo komentáře? Pošlete nám e-mail na adresu defragtools@microsoft.com
JavaScript MSDN Docs:
- Skriptování ladicího programu JavaScriptu
- Ukázkové skripty ladicího programu JavaScriptu
- Nativní objekty ladicího programu v rozšířeních JavaScriptu
Příklad jedinečných zásobníků (vpravo):
"použít striktní";
třída __stackEntry { constructor(frameString) { this.threads = []; this.frameString = frameString; this.children = new Map(); }
display(indent)
{
for (var child of this.children.values())
{
host.diagnostics.debugLog(indent, child.frameString, " [Threads In Branch: ");
for (var thread of child.threads)
{
host.diagnostics.debugLog(thread.Id, " ");
}
host.diagnostics.debugLog("]\n");
child.display(indent + " ");
}
}
}
třída __stackMap { constructor(process) { this.__process = process; this.__root = new __stackEntry("); this.build(); }
build()
{
for (var thread of this.__process.Threads)
{
var current = this.__root;
var frameNum = 0;
var frameCount = thread.Stack.Frames.Count();
for (var frameNum = frameCount - 1; frameNum >= 0; --frameNum) {
var frame = thread.Stack.Frames[frameNum];
var frameString = frame.toString();
if (current.children.has(frameString)) {
current = current.children.get(frameString);
current.threads.push(thread);
}
else {
var newEntry = new __stackEntry(frameString);
current.children.set(frameString, newEntry);
current = newEntry;
current.threads.push(thread);
}
}
}
}
findEntry(thread)
{
var current = this.__root;
var frameCount = thread.Stack.Frames.Count();
for (var frameNum = frameCount - 1; frameNum >= 0; --frameNum)
{
var frame = thread.Stack.Frames[frameNum];
var frameString = frame.toString();
if (!current.children.has(frameString))
{
return null;
}
current = current.children.get(frameString);
}
return current;
}
display()
{
this.__root.display("");
}
}
class __threadSameStacks { constructor(thread) { this.__thread = thread; }
getDimensionality()
{
return 1;
}
getValueAt(idx)
{
for (var idxVal of this)
{
var tid = idxVal[Symbol.indicies][0];
if (idxVal[Symbol.indicies][0] == idx && tid != this.__thread.Id)
{
return idxVal.value;
}
}
return undefined;
}
*[Symbol.iterator]()
{
var context = this.__thread.hostContext;
var session = host.namespace.Debugger.Sessions.getValueAt(context);
var process = session.Processes.getValueAt(context);
var map = new __stackMap(process);
var entry = map.findEntry(this.__thread);
if (entry != null)
{
for (var sharingThread of entry.threads)
{
if (sharingThread.Id != this.__thread.Id)
{
yield new host.indexedValue(sharingThread, [sharingThread.Id]);
}
}
}
}
}
class __threadExtension { get IdenticalStacks() { return new __threadSameStacks(this); } }
function invokeScript() { var map = new __stackMap(host.currentProcess); map.display(); }
function initializeScript() { return [new host.namedModelParent(__threadExtension; "Debugger.Models.Thread")]; }
V této epizodě Defrag Tools, Andrew Richards hovoří s Andy Luhrs a Bill Messmer z týmu Debugging Tools for Windows . Hovoříme o nových možnostech rozšiřitelnosti a skriptování Jazyka JavaScript ve WinDbg, které jsou k dispozici v buildu WDK a SDK 14951 a novějším.
- Blog- https://blogs.msdn.microsoft.com/windbg/
- E-mail- windbgfb@microsoft.com
Faktura využila objektový model ladicího programu dříve v těchto epizodách:
- Defrag Tools #138 - Debugging - 'dx' Command Part 1
- Defrag Tools #139 - Debugging - 'dx' Command Part 2
- Defrag Tools #169 - Debugging Tools for Windows Team
Časová osa:
[00:00] Vítejte a úvod
[00:24] Nová sada SDK drop
[00:29] Proč JavaScript
[02:07] Nové příkazy
[03:50] Visual Studio Code
[04:00] Příklad – Hello World
[07:15] Výchozí obory názvů ladicího programu
[09:07] Příklad – Tisk všech vláken
[10:26] Příklad – podmíněná zarážka
[18:13] 'g' vs. 'gc' - Andrew měl pravdu! Příkaz gc obnoví provádění stejným způsobem, jakým se spustil. Takže pokud stisknete "p" a pak dosáhnete podmíněné zarážky, která má v něm "gc", 'gc' dokončí vaše počáteční 'p'.
[20:40] Příklad – jedinečné zásobníky
[34:40] Příklad – sčítání
Máte dotazy nebo komentáře? Pošlete nám e-mail na adresu defragtools@microsoft.com
JavaScript MSDN Docs:
- Skriptování ladicího programu JavaScriptu
- Ukázkové skripty ladicího programu JavaScriptu
- Nativní objekty ladicího programu v rozšířeních JavaScriptu
Příklad jedinečných zásobníků (vpravo):
"použít striktní";
třída __stackEntry { constructor(frameString) { this.threads = []; this.frameString = frameString; this.children = new Map(); }
display(indent)
{
for (var child of this.children.values())
{
host.diagnostics.debugLog(indent, child.frameString, " [Threads In Branch: ");
for (var thread of child.threads)
{
host.diagnostics.debugLog(thread.Id, " ");
}
host.diagnostics.debugLog("]\n");
child.display(indent + " ");
}
}
}
třída __stackMap { constructor(process) { this.__process = process; this.__root = new __stackEntry("); this.build(); }
build()
{
for (var thread of this.__process.Threads)
{
var current = this.__root;
var frameNum = 0;
var frameCount = thread.Stack.Frames.Count();
for (var frameNum = frameCount - 1; frameNum >= 0; --frameNum) {
var frame = thread.Stack.Frames[frameNum];
var frameString = frame.toString();
if (current.children.has(frameString)) {
current = current.children.get(frameString);
current.threads.push(thread);
}
else {
var newEntry = new __stackEntry(frameString);
current.children.set(frameString, newEntry);
current = newEntry;
current.threads.push(thread);
}
}
}
}
findEntry(thread)
{
var current = this.__root;
var frameCount = thread.Stack.Frames.Count();
for (var frameNum = frameCount - 1; frameNum >= 0; --frameNum)
{
var frame = thread.Stack.Frames[frameNum];
var frameString = frame.toString();
if (!current.children.has(frameString))
{
return null;
}
current = current.children.get(frameString);
}
return current;
}
display()
{
this.__root.display("");
}
}
class __threadSameStacks { constructor(thread) { this.__thread = thread; }
getDimensionality()
{
return 1;
}
getValueAt(idx)
{
for (var idxVal of this)
{
var tid = idxVal[Symbol.indicies][0];
if (idxVal[Symbol.indicies][0] == idx && tid != this.__thread.Id)
{
return idxVal.value;
}
}
return undefined;
}
*[Symbol.iterator]()
{
var context = this.__thread.hostContext;
var session = host.namespace.Debugger.Sessions.getValueAt(context);
var process = session.Processes.getValueAt(context);
var map = new __stackMap(process);
var entry = map.findEntry(this.__thread);
if (entry != null)
{
for (var sharingThread of entry.threads)
{
if (sharingThread.Id != this.__thread.Id)
{
yield new host.indexedValue(sharingThread, [sharingThread.Id]);
}
}
}
}
}
class __threadExtension { get IdenticalStacks() { return new __threadSameStacks(this); } }
function invokeScript() { var map = new __stackMap(host.currentProcess); map.display(); }
function initializeScript() { return [new host.namedModelParent(__threadExtension; "Debugger.Models.Thread")]; }