[OT] Which IDE / Editor do you use?
Paolo Invernizzi
paolo.invernizzi at gmail.com
Sat Sep 14 13:20:01 PDT 2013
On Saturday, 14 September 2013 at 17:34:27 UTC, Adam D. Ruppe
wrote:
> On Saturday, 14 September 2013 at 12:25:44 UTC, Paolo Invernizzi
> wrote:
>> Give me a way to writeln the callstack frames at a certain
>
> Challenge accepted:
>
>
> import std.stdio;
>
> string getStackTrace() {
> import core.runtime;
>
> version(Posix) {
> // druntime cuts out the first few functions on
> the trace as they are internal
> // so we'll make some dummy functions here so
> our
> actual info doesn't get cut
> Throwable.TraceInfo f5() { return
> defaultTraceHandler(); }
> Throwable.TraceInfo f4() { return f5(); }
> Throwable.TraceInfo f3() { return f4(); }
> Throwable.TraceInfo f2() { return f3(); }
> auto stuff = f2();
> } else {
> auto stuff = defaultTraceHandler();
> }
>
> return stuff.toString();
> }
>
>
> void foo() {
> writeln("on foo");
> bar();
> }
>
> void bar() {
> writeln("on bar");
> omg();
> }
>
> void omg() {
> writeln("on omg");
>
> writeln(getStackTrace());
> }
>
> void main() {
> omg();
>
> writeln("\n****\n");
> foo();
> }
O_o
Adam, this is *really* an unexpected gift!
I suggest to add this example in the core.runtime DDoc at least!
- Paolo
More information about the Digitalmars-d
mailing list