annotate dmd/TObject.d @ 192:eb38fdcb3e62 default tip

updated to compile with dmd2.062
author korDen
date Sat, 02 Mar 2013 01:25:52 -0800
parents e3afd1303184
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
178
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
1 module dmd.TObject;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
2 /*
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
3 import core.runtime;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
4 import core.stdc.stdio;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
5 import core.stdc.string;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
6 import core.stdc.stdlib;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
7
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
8 import dmd.TObject;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
9
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
10 import core.sys.windows.windows;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
11 import core.sys.windows.codeview;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
12 import core.demangle;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
13 import core.memory;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
14 import core.stdc.stdlib;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
15
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
16 version = TrackArray;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
17
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
18 version (TrackList) {
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
19 enum mNull = TObject.pack(0);
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
20 __gshared size_t mHead = mNull;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
21 } else version (TrackArray) {
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
22 __gshared size_t[] objects;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
23 }
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
24 */
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
25 class TObject
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
26 {
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
27 void register()
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
28 {
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
29 }
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
30
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
31 void forceRegister()
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
32 {
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
33 }
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
34
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
35 /*
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
36 this()
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
37 {
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
38 register();
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
39 }
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
40
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
41 ~this()
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
42 {
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
43 size_t mThis = pack(this);
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
44
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
45 version (TrackList) {
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
46 if (mPrev != mNull) {
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
47 unpack(mPrev).mNext = mNext;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
48 } else {
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
49 assert(mHead == mThis);
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
50 mHead = mNext;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
51 }
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
52
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
53 if (mNext != mNull) {
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
54 unpack(mNext).mPrev = mPrev;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
55 }
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
56 } else version (TrackArray) {
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
57 foreach (i, o; objects) {
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
58 if (o == mThis) {
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
59 size_t newLen = objects.length - 1;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
60 objects[i] = objects[newLen];
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
61 objects.length = newLen;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
62
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
63 alloc = cast(void*)-1;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
64 return;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
65 }
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
66 }
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
67 }
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
68 }
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
69
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
70 version (TrackList) {
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
71 size_t mPrev;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
72 size_t mNext;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
73 }
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
74
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
75 void* alloc;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
76
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
77 static TObject unpack(size_t m)
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
78 {
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
79 m &= ~(1 << 31);
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
80 return cast(TObject)cast(void*)m;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
81 }
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
82
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
83 static size_t pack(size_t m)
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
84 {
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
85 return m |= (1 << 31);
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
86 }
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
87
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
88 static size_t pack(TObject o)
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
89 {
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
90 return pack(cast(size_t)cast(void*)o);
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
91 }
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
92
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
93 void forceRegister()
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
94 {
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
95 version (TrackList) {
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
96 alloc = alloc_point();
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
97 size_t mThis = pack(this);
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
98
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
99 mNext = mHead;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
100 if (mHead != mNull) {
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
101 unpack(mHead).mPrev = mThis;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
102 }
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
103
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
104 mPrev = mNull;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
105 mHead = mThis;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
106 } else version (TrackArray) {
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
107 alloc = alloc_point();
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
108 objects ~= pack(this);
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
109 }
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
110 }
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
111
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
112 void register()
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
113 {
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
114 if (alloc !is null) return;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
115 forceRegister();
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
116 }
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
117
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
118 static void dump()
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
119 {
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
120 int[void*] allocStat;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
121
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
122 version (TrackList) {
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
123 auto o = unpack(mHead);
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
124 while (o !is null) {
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
125 allocStat[o.alloc]++;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
126 o = unpack(o.mNext);
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
127 }
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
128 } else version (TrackArray) {
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
129 foreach (i, m; objects) {
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
130 allocStat[unpack(m).alloc]++;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
131 }
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
132 }
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
133
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
134 FILE* f = fopen("alloc_stat.txt", "wb");
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
135 if (f is null) return;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
136
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
137 StackFrameInfo* frame = void;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
138 DebugImage* imageList, image = void;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
139 char[255] buffer = void;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
140
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
141 MEMORY_BASIC_INFORMATION mbi = void;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
142
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
143 void resolve(const(void)* c) {
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
144 StackFrameInfo frame;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
145 frame.va = cast(void*)c;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
146
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
147 // mbi.Allocation base is the handle to stack frame's module
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
148 VirtualQuery(frame.va, &mbi, MEMORY_BASIC_INFORMATION.sizeof);
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
149 if (!mbi.AllocationBase) return;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
150
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
151 image = imageList;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
152 while(image) {
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
153 if (image.baseAddress == cast(size_t)mbi.AllocationBase) break;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
154 image = image.next;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
155 }
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
156
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
157 if (!image) {
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
158 image = new DebugImage;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
159
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
160 with (*image) {
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
161 next = imageList;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
162 imageList = image;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
163 baseAddress = cast(size_t)mbi.AllocationBase;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
164
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
165 uint len = GetModuleFileNameA(cast(HMODULE)baseAddress, buffer.ptr, buffer.length);
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
166 moduleName = buffer[0 .. len].idup;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
167
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
168 if (len != 0) {
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
169 exeModule = new PEImage(moduleName);
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
170 rvaOffset = baseAddress + exeModule.codeOffset;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
171 debugInfo = exeModule.debugInfo;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
172 }
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
173 }
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
174 }
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
175
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
176 frame.moduleName = image.moduleName;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
177
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
178 size_t va = cast(size_t)frame.va;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
179
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
180 if (image.debugInfo) with (image.debugInfo) {
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
181 uint rva = va - image.rvaOffset;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
182
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
183 frame.symbol = ResolveSymbol(rva);
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
184 frame.fileLine = ResolveFileLine(rva);
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
185 }
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
186
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
187 auto s = image.exeModule.closestSymbol(va);
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
188 printf("%.*s\n", s);
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
189 auto symbol = demangle(s.symbol);
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
190
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
191 if (frame.fileLine.file.length != 0) {
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
192 fprintf(f, "%.*s %.*s:%d\n", symbol, frame.fileLine.file, frame.fileLine.line);
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
193 // } else {
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
194 // if (symbol.length != 0) {
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
195 // fprintf(f, "%.*s", symbol);
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
196 // }
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
197 }
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
198 }
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
199
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
200 while (imageList) {
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
201 image = imageList.next;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
202 delete imageList.debugInfo;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
203 delete imageList.exeModule;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
204 delete imageList;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
205 imageList = image;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
206 }
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
207
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
208 int max = 0;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
209 int total = 0;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
210 fprintf(f, "%d\n", allocStat.length);
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
211 foreach (alloc, count; allocStat) {
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
212 resolve(alloc);
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
213
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
214 fprintf(f, "count: %d\n\n", count);
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
215 if (count > max) max = count;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
216 total += count;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
217 }
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
218 fprintf(f, "max: %d\n\n", max);
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
219 fprintf(f, "total: %d\n\n", total);
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
220 fclose(f);
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
221 }
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
222 */
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
223 }
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
224 /*
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
225 void* alloc_point()
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
226 {
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
227 void** bp = void;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
228
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
229 asm {
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
230 mov bp, EBP;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
231 }
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
232
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
233 bp = cast(void**)*bp;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
234 bp = cast(void**)*bp;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
235 bp = cast(void**)*bp;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
236 return *(bp + 1);
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
237 }
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
238
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
239 void callstack_print(FILE* f, void*[] callstack)
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
240 {
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
241 char** framelist = backtrace_symbols(callstack.ptr, callstack.length);
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
242 for( int i = 0; i < callstack.length; ++i )
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
243 {
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
244 auto line = framelist[i];
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
245 if (strcmp(line, "<no debug info found>") == 0) {
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
246 continue;
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
247 }
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
248 fwrite(line, 1, strlen(line), f);
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
249 fwrite("\n".ptr, 1, 1, f);
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
250 }
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
251 free(framelist);
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
252 }
e3afd1303184 Many small bugs fixed
korDen
parents:
diff changeset
253 */