الحلقة

أدوات إلغاء التجزئة #170 - مصحح الأخطاء - البرمجة النصية ل JavaScript

في هذه الحلقة من أدوات Defrag، يتحدث أندرو ريتشاردز إلى أندي لوهرز وبيل مسمر من فريق أدوات تصحيح الأخطاء ل Windows . نتحدث عن قدرات قابلية توسعة JavaScript الجديدة والبرمجة النصية في WinDbg المتوفرة في إصدار WDK وSDK 14951 والأحدث.

استفد بيل من نموذج كائن مصحح الأخطاء سابقا في هذه الحلقات:

Timeline:

[00:00] مرحبا بك ومقدمات
[00:24] إسقاط SDK جديد
[00:29] لماذا JavaScript
[02:07] أوامر جديدة
[03:50] Visual Studio Code
[04:00] مثال - مرحبًا بالعالم
[07:15] مساحات الأسماء الافتراضية لمصحح الأخطاء
[09:07] مثال - طباعة كافة مؤشرات الترابط
[10:26] مثال - نقطة توقف شرطية
[18:13] 'g' مقابل 'gc' – أندرو كان محقا! يستأنف 'gc' التنفيذ بنفس الطريقة التي بدأ بها. لذلك إذا ضربت "p" ثم وصلت إلى نقطة توقف شرطية تحتوي على "gc" فيها، فإن "gc" ستنهي "p" الأولي.
[20:40] مثال - مكدسات فريدة
[34:40] مثال - إضافة

الأسئلة/التعليقات؟ برجاء إرسال بريد إلكتروني علي defragtools@microsoft.com

مستندات JavaScript MSDN:

مثال على المكدسات الفريدة (المثال الصحيح):

"استخدام صارم"؛

class __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 + "    ");
    }
}

}

class __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("");
}

}

فئة __threadSameStacks { منشئ (مؤشر ترابط) { this.__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")]; }

هل لديك ملاحظات؟ أرسل مشكلة هنا.