Stack traces: Difference between revisions

Stack traces in FreeBASIC
(Add Lang examples)
(Stack traces in FreeBASIC)
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}}==
2,130

edits