Thread overview
Can I use the stack info in Exception?
Dec 03, 2016
Dsby
Dec 03, 2016
Dsby
Dec 14, 2016
Johan Engelen
December 03, 2016
I use the ldc1.1-b5.
when I tach the Exception, in ldc, it not printf the stack info. in dmd ,it has.

import std.json;
import std.stdio;

string pjson(ref JSONValue js)
{
    return js["hhh"].str;
}

void main()
{
    JSONValue js;
    js["hh"] = 10;
    try{
        pjson(js);
    } catch(Exception e){
        writeln(e.toString());
    }
}

In ldc , only printf:
std.json.JSONException@/build/src/ldc/runtime/phobos/std/json.d(442): Key not found: hhh
----------------


In dmd , it printf:
std.json.JSONException@std/json.d(442): Key not found: hhh
----------------
??:? pure @safe void std.exception.bailOut!(std.json.JSONException).bailOut(immutable(char)[], ulong, const(char[])) [0x452c66]
??:? pure @safe inout(std.json.JSONValue)* std.exception.enforce!(std.json.JSONException, inout(std.json.JSONValue)*).enforce(inout(std.json.JSONValue)*, lazy const(char)[], immutable(char)[], ulong) [0x452cca]
??:? std.json.JSONValue.opIndexinout(pure ref inout(std.json.JSONValue) function(immutable(char)[])) [0x448072]
??:? immutable(char)[] exception.pjson(ref std.json.JSONValue) [0x442f0a]
??:? _Dmain [0x442f4f]
??:? _D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv [0x445142]
??:? void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).tryExec(scope void delegate()) [0x44508c]
??:? void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).runAll() [0x4450fe]
??:? void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).tryExec(scope void delegate()) [0x44508c]
??:? _d_run_main [0x444ffd]
??:? main [0x443715]
??:? __libc_start_main [0x604f7290]



Does has any parameter  to enable cath the stack info?

December 03, 2016
On Saturday, 3 December 2016 at 15:34:37 UTC, Dsby wrote:
> I use the ldc1.1-b5.
> when I tach the Exception, in ldc, it not printf the stack info. in dmd ,it has.
>
> import std.json;
> import std.stdio;
>
> string pjson(ref JSONValue js)
> {
>     return js["hhh"].str;
> }
>
> void main()
> {
>     JSONValue js;
>     js["hh"] = 10;
>     try{
>         pjson(js);
>     } catch(Exception e){
>         writeln(e.toString());
>     }
> }
>
> In ldc , only printf:
> std.json.JSONException@/build/src/ldc/runtime/phobos/std/json.d(442): Key not found: hhh
> ----------------
>
>
> In dmd , it printf:
> std.json.JSONException@std/json.d(442): Key not found: hhh
> ----------------
> ??:? pure @safe void std.exception.bailOut!(std.json.JSONException).bailOut(immutable(char)[], ulong, const(char[])) [0x452c66]
> ??:? pure @safe inout(std.json.JSONValue)* std.exception.enforce!(std.json.JSONException, inout(std.json.JSONValue)*).enforce(inout(std.json.JSONValue)*, lazy const(char)[], immutable(char)[], ulong) [0x452cca]
> ??:? std.json.JSONValue.opIndexinout(pure ref inout(std.json.JSONValue) function(immutable(char)[])) [0x448072]
> ??:? immutable(char)[] exception.pjson(ref std.json.JSONValue) [0x442f0a]
> ??:? _Dmain [0x442f4f]
> ??:? _D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv [0x445142]
> ??:? void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).tryExec(scope void delegate()) [0x44508c]
> ??:? void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).runAll() [0x4450fe]
> ??:? void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).tryExec(scope void delegate()) [0x44508c]
> ??:? _d_run_main [0x444ffd]
> ??:? main [0x443715]
> ??:? __libc_start_main [0x604f7290]
>
>
>
> Does has any parameter  to enable cath the stack info?

I am in Linux X86_64.

 uname -a                                                         
                                                                  
                                                                  
       2016年12月03日 星期六 23时37分11秒
Linux dushibaiyu.suse 4.8.10-1-default #1 SMP PREEMPT Mon Nov 21 13:50:28 UTC 2016 (d1ec066) x86_64 x86_64 x86_64 GNU/Linux


cat /etc/os-release                                               
                                                                  
                                                                  
      2016年12月03日 星期六 23时37分14秒
NAME="openSUSE Tumbleweed"
# VERSION="20161201"
ID=opensuse
ID_LIKE="suse"
VERSION_ID="20161201"
PRETTY_NAME="openSUSE Tumbleweed"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:opensuse:tumbleweed:20161201"
BUG_REPORT_URL="https://bugs.opensuse.org"
HOME_URL="https://www.opensuse.org/"
December 14, 2016
On Saturday, 3 December 2016 at 15:34:37 UTC, Dsby wrote:
> I use the ldc1.1-b5.
> when I tach the Exception, in ldc, it not printf the stack info. in dmd ,it has.

https://github.com/ldc-developers/ldc/issues/115

どうも!
  Johan