Stack traces: Difference between revisions

PascalABC.NET
m (syntax highlighting fixup automation)
(PascalABC.NET)
 
(8 intermediate revisions by 4 users not shown)
Line 622:
=={{header|Elena}}==
{{trans|C#}}
ELENA 56.0x :
<syntaxhighlight lang="elena">import extensions;
Line 650:
{{out}}
<pre>
mytestsandbox'program.inner[01]:testsandbox.l(7)
mytestsandbox'program.middle[01]:testsandbox.l(12)
mytestsandbox'program.outer[01]:testsandbox.l(17)
mytestsandbox'program.function:#invoke[0]:testsandbox.l(23)
system'$private'entry.function:#invoke[0]:win32_appapp.l(375)
system'$private'entrySymbol#startUpsym:win32_appapp.l(5544)
</pre>
 
Line 809:
 
Should a fatal error be declared by the run-time system, none of this will happen, but if while running, some unrecoverable or a should-never-happen but I'll check anyway type of problem be noted, then a possibly informative output will follow.
 
=={{header|FreeBASIC}}==
Code extracted from FreeBAsic Forum
[https://freebasic.net/forum/viewtopic.php?t=31371 https://freebasic.net/forum/viewtopic.php?t=31371]
<syntaxhighlight lang="vb">#include "windows.bi"
 
Private Function Fn2() As Long
Dim frames(0 To 60) As Any Ptr
Dim framesPtr As Any Ptr Ptr = @frames(0)
Dim hash As DWORD
Dim As Long caught = CaptureStackBackTrace(0, 61, framesPtr, @hash)
Print Using "Caught & frames using stack capture"; caught
For i As Long = 0 To caught - 1
Print Using "&) &"; caught - i; Hex(frames(i))
Next
Return caught
End Function
 
Private Sub Fn1(num As Ulong)
Dim As Long numFn2 = Fn2()
Print Using "Fn2 returned & with num = &"; numFn2; num
End Sub
 
Fn1(87)
Sleep</syntaxhighlight>
{{out}}
<pre>Caught 7 frames using stack capture
7) 4016FE
6) 40185E
5) 4015BA
4) 4013B4
3) 40150B
2) 7FFBD6AC7614
1) 7FFBD7B226A1
Fn2 returned 7 with num = 87</pre>
 
 
=={{header|Go}}==
Line 1,106 ⟶ 1,142:
 
Continuing ...
</pre>
 
=={{header|Lang}}==
<syntaxhighlight lang="lang">
# fn.getStackTrace() returns a text-based stack trace
fp.printStackTrace = () -> fn.println(fn.getStackTrace())
 
# Example
fp.f1 = () -> {
fn.println(F1:)
fp.printStackTrace()
}
fp.f2 = () -> {
fn.println(F2:)
fp.printStackTrace()
fp.f1()
}
fp.f2()
 
fn.combA0(fp.f2)
 
# Partially called combinator functions' names are represented as "<comb...-func(...)>"
fn.combA(fn.combC(fn.combAE(), x), fp.f2)
</syntaxhighlight>
{{out}}
The file paths were redacted. If ":x" is outputted as the line number, no line number information is available (e.g. If Lang is implemented with an interpreter, predefined functions are written in the host language)
<pre>
F2:
at "[redacted]:x" in function "getStackTrace"
at "[redacted]:2" in function "fp.printStackTrace"
at "[redacted]:11" in function "fp.f2"
at "[redacted]:14" in function "main"
F1:
at "[redacted]:x" in function "getStackTrace"
at "[redacted]:2" in function "fp.printStackTrace"
at "[redacted]:7" in function "fp.f1"
at "[redacted]:12" in function "fp.f2"
at "[redacted]:14" in function "main"
F2:
at "[redacted]:x" in function "getStackTrace"
at "[redacted]:2" in function "fp.printStackTrace"
at "[redacted]:11" in function "fp.f2"
at "[redacted]:x" in function "combA0"
at "[redacted]:16" in function "main"
F1:
at "[redacted]:x" in function "getStackTrace"
at "[redacted]:2" in function "fp.printStackTrace"
at "[redacted]:7" in function "fp.f1"
at "[redacted]:12" in function "fp.f2"
at "[redacted]:x" in function "combA0"
at "[redacted]:16" in function "main"
F2:
at "[redacted]:x" in function "getStackTrace"
at "[redacted]:2" in function "fp.printStackTrace"
at "[redacted]:11" in function "fp.f2"
at "[redacted]:x" in function "<combAE-func()>"
at "[redacted]:x" in function "<combC-func(<combAE-func()>, <arg>)>"
at "[redacted]:x" in function "combA"
at "[redacted]:19" in function "main"
F1:
at "[redacted]:x" in function "getStackTrace"
at "[redacted]:2" in function "fp.printStackTrace"
at "[redacted]:7" in function "fp.f1"
at "[redacted]:12" in function "fp.f2"
at "[redacted]:x" in function "<combAE-func()>"
at "[redacted]:x" in function "<combC-func(<combAE-func()>, <arg>)>"
at "[redacted]:x" in function "combA"
at "[redacted]:19" in function "main"
</pre>
 
Line 1,474 ⟶ 1,578:
Output:
[[File:Oz_stacktrace2.png|center|Stack trace created by the Debug module.]]
 
=={{header|PascalABC.NET}}==
<syntaxhighlight lang="perl">
procedure qqq;
begin
var st := new System.Diagnostics.StackTrace();
Print(st);
end;
 
procedure ppp;
begin
qqq;
end;
 
begin
ppp
end.
</syntaxhighlight>
{{out}}
<pre>
at Rosetta_StackTrace.Program.qqq()
at Rosetta_StackTrace.Program.ppp()
at Rosetta_StackTrace.Program.$Main()
at Rosetta_StackTrace.Program.Main()
</pre>
 
 
 
=={{header|Perl}}==
Line 2,158 ⟶ 2,289:
 
However, it is not possible to continue execution of the script afterwards. Whilst one can 'catch' such an error using Fiber.try() this will only allow you to inspect the error itself, not the chain of function calls that led up to it.
<syntaxhighlight lang="ecmascriptwren">var func2 = Fn.new {
Fiber.abort("Forced error.")
}
246

edits