comparison runtime/internal/genobj.d @ 1196:6c31351af0c5

Apply fawzi's stacktracing update from #254.
author Christian Kamm <kamm incasoftware de>
date Sun, 05 Apr 2009 15:02:44 +0200
parents 30663babccff
children 9c2dbbdd34f8
comparison
equal deleted inserted replaced
1195:e961851fb8be 1196:6c31351af0c5
44 { 44 {
45 import tango.stdc.string; // : memcmp, memcpy, memmove; 45 import tango.stdc.string; // : memcmp, memcpy, memmove;
46 import tango.stdc.stdlib; // : calloc, realloc, free; 46 import tango.stdc.stdlib; // : calloc, realloc, free;
47 import util.string; 47 import util.string;
48 import tango.stdc.stdio; // : printf, snprintf; 48 import tango.stdc.stdio; // : printf, snprintf;
49 import tango.core.Version;
49 50
50 extern (C) void onOutOfMemoryError(); 51 extern (C) void onOutOfMemoryError();
51 extern (C) Object _d_allocclass(ClassInfo ci); 52 extern (C) Object _d_allocclass(ClassInfo ci);
52 } 53 }
53 54
903 //////////////////////////////////////////////////////////////////////////////// 904 ////////////////////////////////////////////////////////////////////////////////
904 905
905 906
906 class Exception : Object 907 class Exception : Object
907 { 908 {
908 struct FrameInfo{ 909 static if (Tango.Minor > 998) {
909 long line; 910 struct FrameInfo{
910 ptrdiff_t iframe; 911 long line;
911 ptrdiff_t offset; 912 size_t iframe;
912 size_t address; 913 ptrdiff_t offsetSymb;
913 char[] file; 914 size_t baseSymb;
914 char[] func; 915 ptrdiff_t offsetImg;
915 char[256] charBuf; 916 size_t baseImg;
916 void writeOut(void delegate(char[])sink){ 917 size_t address;
917 char[25] buf; 918 char[] file;
918 sink(func); 919 char[] func;
919 auto len = snprintf(buf.ptr,buf.length,"@%zx ",address); 920 char[] extra;
920 sink(buf[0..len]); 921 bool exactAddress;
921 len = snprintf(buf.ptr,buf.length," %+td ",address); 922 bool internalFunction;
922 sink(buf[0..len]); 923 void writeOut(void delegate(char[])sink){
923 if (file.length != 0 || line) { 924 char[25] buf;
925 if (func.length) {
926 sink(func);
927 } else {
928 sink("???");
929 }
930 auto len=sprintf(buf.ptr,"@%zx",baseSymb);
931 sink(buf[0..len]);
932 len=sprintf(buf.ptr,"%+td ",offsetSymb);
933 sink(buf[0..len]);
934 if (extra.length){
935 sink(extra);
936 sink(" ");
937 }
924 sink(file); 938 sink(file);
925 len = snprintf(buf.ptr,buf.length,":%ld",line); 939 len=sprintf(buf.ptr,":%ld ",line);
940 sink(buf[0..len]);
941 len=sprintf(buf.ptr,"%zx",baseImg);
942 sink(buf[0..len]);
943 len=sprintf(buf.ptr,"%+td ",offsetImg);
944 sink(buf[0..len]);
945 len=sprintf(buf.ptr,"[%zx]",address);
926 sink(buf[0..len]); 946 sink(buf[0..len]);
927 } 947 }
928 } 948 void clear(){
929 } 949 line=0;
930 interface TraceInfo 950 iframe=-1;
931 { 951 offsetImg=0;
932 int opApply( int delegate( ref FrameInfo fInfo ) ); 952 baseImg=0;
953 offsetSymb=0;
954 baseSymb=0;
955 address=0;
956 exactAddress=true;
957 internalFunction=false;
958 file=null;
959 func=null;
960 extra=null;
961 }
962 }
963 interface TraceInfo
964 {
965 int opApply( int delegate( ref FrameInfo fInfo ) );
966 void writeOut(void delegate(char[])sink);
967 }
968 } else static if (Tango.Minor == 998) {
969 struct FrameInfo{
970 long line;
971 ptrdiff_t iframe;
972 ptrdiff_t offset;
973 size_t address;
974 char[] file;
975 char[] func;
976 char[256] charBuf;
977 void writeOut(void delegate(char[])sink){
978 char[25] buf;
979 sink(func);
980 auto len = snprintf(buf.ptr,buf.length,"@%zx ",address);
981 sink(buf[0..len]);
982 len = snprintf(buf.ptr,buf.length," %+td ",address);
983 sink(buf[0..len]);
984 if (file.length != 0 || line) {
985 sink(file);
986 len = snprintf(buf.ptr,buf.length,":%ld",line);
987 sink(buf[0..len]);
988 }
989 }
990 }
991 interface TraceInfo
992 {
993 int opApply( int delegate( ref FrameInfo fInfo ) );
994 }
995 } else {
996 static assert(0, "Don't know FrameInfo, TraceInfo definition for Tango < 0.99.8");
933 } 997 }
934 998
935 char[] msg; 999 char[] msg;
936 char[] file; 1000 char[] file;
937 size_t line; 1001 size_t line;