Stack traces: Difference between revisions

→‎{{header|Nim}}: Move Nim entry to the correct place and added output
(→‎{{header|Nim}}: Move Nim entry to the correct place and added output)
Line 1,222:
RStackTraces.inner
</pre>
 
=={{header|Nim}}==
In (normal) debug builds stacktraces are enabled, while in release builds stacktraces are disabled by default, but can be enabled like this: <code>nim c -d:release --stacktrace:on --linetrace:on file.nim</code>
<lang nim>proc g() =
# Writes the current stack trace to stderr.
writeStackTrace()
# Or fetch the stack trace entries for the current stack trace:
echo "----"
for e in getStackTraceEntries():
echo e.filename, "@", e.line, " in ", e.procname
 
proc f() =
g()
 
f()</lang>
{{out}}
For a release build:
<pre>Traceback (most recent call last)
stack_traces.nim(12) stack_traces
stack_traces.nim(10) f
stack_traces.nim(3) g
----
stack_traces.nim@12 in stack_traces
stack_traces.nim@10 in f
stack_traces.nim@6 in g
</pre>
In a debug build the stacktrace contains the full path to the source.
 
=={{header|Objective-C}}==
Line 1,416 ⟶ 1,443:
Output:
[[File:Oz_stacktrace2.png|center|Stack trace created by the Debug module.]]
 
=={{header|Nim}}==
In (normal) debug builds stacktraces are enabled, while in release builds stacktraces are disabled by default, but can be enabled like this: <code>nim c -d:release --stacktrace:on --linetrace:on file.nim</code>
<lang nim>proc g() =
writeStackTrace()
proc f() =
g()
 
f()</lang>
 
=={{header|Perl}}==