File size: 1,759 Bytes
91f2293
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//#CLIENTSIDE
function onCreated() {
    showTraceGui();
}

function showTraceGui() {
    if (findobject("TraceWin") != nil) findobject("TraceWin").destroy();
    
    new GuiWindowCtrl("TraceWin") {
        profile = GuiBlueWindowProfile;
        text = "Function Call Tracer v1.0";
        x = 200; y = 200;
        width = 550; height = 400; 
        canclose = true;

        new GuiButtonCtrl("BtnGetTrace") {
            profile = GuiBlueButtonProfile;
            x = 10; y = 40; width = 120; height = 40;
            text = "Trace";
        }

        new GuiButtonCtrl("BtnClearTrace") {
            profile = GuiBlueButtonProfile;
            x = 10; y = 90; width = 120; height = 40;
            text = "Clear";
        }

        new GuiScrollCtrl("ScrollTrace") {
            profile = GuiBlueScrollProfile;
            x = 140; y = 40; width = 400; height = 350;
            hscrollbar = "dynamic";
            vscrollbar = "always";

            new GuiMLTextCtrl("TxtOutput") {
                profile = GuiBlueTextProfile;
                x = 0; y = 0; width = 370;
                text = "Waiting for trace data...";
            }
        }
    }
}

function BtnGetTrace.onAction() {
    echo("Requesting call trace...");
    getcalltrace(this, "onActionHook", 1000);
}

function BtnClearTrace.onAction() {
    if (findobject("TxtOutput") != nil) {
        TxtOutput.text = "Logs cleared.";
        echo("Trace logs cleared.");
    }
}

function onActionHook(temp.traceData) {
    if (findobject("TxtOutput") != nil) {
        TxtOutput.text = temp.traceData;
        
        if (findobject("ScrollTrace") != nil) {
            ScrollTrace.scrollto(0, 100000);
        }
    }
}