Mercurial > projects > ldc
annotate runtime/internal/memory.d @ 1126:899a2d90645b
Fix some issues with fawzi's patch.
- It now actually compiles:
- import stdc.stdio for string formatting functions)
- remove extra '{'
- Use snprintf() instead of sprintf().
- Use return value from snprintf instead of strlen().
- Don't print the filename in Exception.writeOut() if it has zero length and
the line number is 0
(It would previously only skip these if the filename was null, but not if it
was a different empty string)
- Ignore empty filename + line number 0 in FrameInfo.writeOut() as well.
author | Frits van Bommel <fvbommel wxs.nl> |
---|---|
date | Wed, 18 Mar 2009 15:33:19 +0100 |
parents | bd000a7fab18 |
children | 3cf0066e6faf |
rev | line source |
---|---|
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
1 /** |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
2 * This module exposes functionality for inspecting and manipulating memory. |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
3 * |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
4 * Copyright: Copyright (C) 2005-2006 Digital Mars, www.digitalmars.com. |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
5 * All rights reserved. |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
6 * License: |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
7 * This software is provided 'as-is', without any express or implied |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
8 * warranty. In no event will the authors be held liable for any damages |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
9 * arising from the use of this software. |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
10 * |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
11 * Permission is granted to anyone to use this software for any purpose, |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
12 * including commercial applications, and to alter it and redistribute it |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
13 * freely, in both source and binary form, subject to the following |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
14 * restrictions: |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
15 * |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
16 * o The origin of this software must not be misrepresented; you must not |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
17 * claim that you wrote the original software. If you use this software |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
18 * in a product, an acknowledgment in the product documentation would be |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
19 * appreciated but is not required. |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
20 * o Altered source versions must be plainly marked as such, and must not |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
21 * be misrepresented as being the original software. |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
22 * o This notice may not be removed or altered from any source |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
23 * distribution. |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
24 * Authors: Walter Bright, Sean Kelly |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
25 */ |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
26 module memory; |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
27 |
577
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
28 version = GC_Use_Dynamic_Ranges; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
29 |
905
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
30 version(darwin) |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
31 { |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
32 version = GC_Use_Data_Dyld; |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
33 version = GC_Use_Dynamic_Ranges; |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
34 } |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
35 else version(Posix) |
577
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
36 { |
899
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
37 version = GC_Use_Data_Proc_Maps; |
577
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
38 } |
905
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
39 else version(solaris) |
900
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
40 { |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
41 version = GC_Use_Data_Proc_Maps; |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
42 } |
577
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
43 |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
44 version(GC_Use_Data_Proc_Maps) |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
45 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
46 version(Posix) {} else { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
47 static assert(false, "Proc Maps only supported on Posix systems"); |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
48 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
49 private import tango.stdc.posix.unistd; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
50 private import tango.stdc.posix.fcntl; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
51 private import tango.stdc.string; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
52 |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
53 version = GC_Use_Dynamic_Ranges; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
54 } |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
55 |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
56 private |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
57 { |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
58 version( linux ) |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
59 { |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
60 //version = SimpleLibcStackEnd; |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
61 |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
62 version( SimpleLibcStackEnd ) |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
63 { |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
64 extern (C) extern void* __libc_stack_end; |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
65 } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
66 else |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
67 { |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
68 import tango.stdc.posix.dlfcn; |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
69 } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
70 } |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
578
diff
changeset
|
71 version(LDC) |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
72 { |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
73 pragma(intrinsic, "llvm.frameaddress") |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
74 { |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
75 void* llvm_frameaddress(uint level=0); |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
76 } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
77 } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
78 } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
79 |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
80 |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
81 /** |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
82 * |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
83 */ |
872
aa953cc960b6
Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents:
794
diff
changeset
|
84 |
aa953cc960b6
Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents:
794
diff
changeset
|
85 version( solaris ) { |
aa953cc960b6
Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents:
794
diff
changeset
|
86 version(X86_64) { |
aa953cc960b6
Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents:
794
diff
changeset
|
87 extern (C) void* _userlimit; |
aa953cc960b6
Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents:
794
diff
changeset
|
88 } |
aa953cc960b6
Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents:
794
diff
changeset
|
89 } |
aa953cc960b6
Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents:
794
diff
changeset
|
90 |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
91 extern (C) void* rt_stackBottom() |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
92 { |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
93 version( Win32 ) |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
94 { |
578
8caa9adce5ae
Fix (?) rt_stackBottom for Windows.
Christian Kamm <kamm incasoftware de>
parents:
577
diff
changeset
|
95 void* bottom; |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
96 asm |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
97 { |
578
8caa9adce5ae
Fix (?) rt_stackBottom for Windows.
Christian Kamm <kamm incasoftware de>
parents:
577
diff
changeset
|
98 mov EAX, FS:4; |
8caa9adce5ae
Fix (?) rt_stackBottom for Windows.
Christian Kamm <kamm incasoftware de>
parents:
577
diff
changeset
|
99 mov bottom, EAX; |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
100 } |
578
8caa9adce5ae
Fix (?) rt_stackBottom for Windows.
Christian Kamm <kamm incasoftware de>
parents:
577
diff
changeset
|
101 return bottom; |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
102 } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
103 else version( linux ) |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
104 { |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
105 version( SimpleLibcStackEnd ) |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
106 { |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
107 return __libc_stack_end; |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
108 } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
109 else |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
110 { |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
111 // See discussion: http://autopackage.org/forums/viewtopic.php?t=22 |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
112 static void** libc_stack_end; |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
113 |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
114 if( libc_stack_end == libc_stack_end.init ) |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
115 { |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
116 void* handle = dlopen( null, RTLD_NOW ); |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
117 libc_stack_end = cast(void**) dlsym( handle, "__libc_stack_end" ); |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
118 dlclose( handle ); |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
119 } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
120 return *libc_stack_end; |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
121 } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
122 } |
558
02fb65cddc3e
Merge rest of patch from #72.
Christian Kamm <kamm incasoftware de>
parents:
443
diff
changeset
|
123 else version( darwin ) |
02fb65cddc3e
Merge rest of patch from #72.
Christian Kamm <kamm incasoftware de>
parents:
443
diff
changeset
|
124 { |
559
5d6ef6e6805d
Make rt_stackBottom return the right fixed value for darwin.
Christian Kamm <kamm incasoftware de>
parents:
558
diff
changeset
|
125 // darwin has a fixed stack bottom |
5d6ef6e6805d
Make rt_stackBottom return the right fixed value for darwin.
Christian Kamm <kamm incasoftware de>
parents:
558
diff
changeset
|
126 return cast(void*) 0xc0000000; |
558
02fb65cddc3e
Merge rest of patch from #72.
Christian Kamm <kamm incasoftware de>
parents:
443
diff
changeset
|
127 } |
872
aa953cc960b6
Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents:
794
diff
changeset
|
128 else version( solaris ) |
aa953cc960b6
Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents:
794
diff
changeset
|
129 { |
aa953cc960b6
Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents:
794
diff
changeset
|
130 version(X86_64) { |
aa953cc960b6
Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents:
794
diff
changeset
|
131 return _userlimit; |
aa953cc960b6
Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents:
794
diff
changeset
|
132 } |
aa953cc960b6
Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents:
794
diff
changeset
|
133 else { |
aa953cc960b6
Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents:
794
diff
changeset
|
134 // <sys/vmparam.h> |
aa953cc960b6
Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents:
794
diff
changeset
|
135 return cast(void*) 0x8048000; |
aa953cc960b6
Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents:
794
diff
changeset
|
136 } |
aa953cc960b6
Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents:
794
diff
changeset
|
137 } |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
138 else |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
139 { |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
140 static assert( false, "Operating system not supported." ); |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
141 } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
142 } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
143 |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
144 |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
145 /** |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
146 * |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
147 */ |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
148 extern (C) void* rt_stackTop() |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
149 { |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
578
diff
changeset
|
150 version(LDC) |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
151 { |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
152 return llvm_frameaddress(); |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
153 } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
154 else version( D_InlineAsm_X86 ) |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
155 { |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
156 asm |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
157 { |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
158 naked; |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
159 mov EAX, ESP; |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
160 ret; |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
161 } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
162 } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
163 else |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
164 { |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
165 static assert( false, "Architecture not supported." ); |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
166 } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
167 } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
168 |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
169 |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
170 private |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
171 { |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
172 version( Win32 ) |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
173 { |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
174 extern (C) |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
175 { |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
176 extern int _data_start__; |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
177 extern int _bss_end__; |
900
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
178 } |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
179 |
900
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
180 alias _data_start__ Data_Start; |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
181 alias _bss_end__ Data_End; |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
182 } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
183 else version( linux ) |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
184 { |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
185 extern (C) |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
186 { |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
187 extern int _data; |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
188 extern int __data_start; |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
189 extern int _end; |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
190 extern int _data_start__; |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
191 extern int _data_end__; |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
192 extern int _bss_start__; |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
193 extern int _bss_end__; |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
194 extern int __fini_array_end; |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
195 } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
196 |
900
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
197 alias __data_start Data_Start; |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
198 alias _end Data_End; |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
199 } |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
200 else version( solaris ) |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
201 { |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
202 extern(C) |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
203 { |
903
493d42562733
Further Solaris data segment detection fixes. Thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
900
diff
changeset
|
204 extern int _environ; |
900
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
205 extern int _end; |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
206 } |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
207 |
903
493d42562733
Further Solaris data segment detection fixes. Thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
900
diff
changeset
|
208 alias _environ Data_Start; |
900
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
209 alias _end Data_End; |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
210 } |
577
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
211 |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
212 version( GC_Use_Dynamic_Ranges ) |
558
02fb65cddc3e
Merge rest of patch from #72.
Christian Kamm <kamm incasoftware de>
parents:
443
diff
changeset
|
213 { |
577
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
214 private import tango.stdc.stdlib; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
215 |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
216 struct DataSeg |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
217 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
218 void* beg; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
219 void* end; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
220 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
221 |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
222 DataSeg* allSegs = null; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
223 size_t numSegs = 0; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
224 |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
225 extern (C) void _d_gc_add_range( void* beg, void* end ) |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
226 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
227 void* ptr = realloc( allSegs, (numSegs + 1) * DataSeg.sizeof ); |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
228 |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
229 if( ptr ) // if realloc fails, we have problems |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
230 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
231 allSegs = cast(DataSeg*) ptr; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
232 allSegs[numSegs].beg = beg; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
233 allSegs[numSegs].end = end; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
234 numSegs++; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
235 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
236 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
237 |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
238 extern (C) void _d_gc_remove_range( void* beg ) |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
239 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
240 for( size_t pos = 0; pos < numSegs; ++pos ) |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
241 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
242 if( beg == allSegs[pos].beg ) |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
243 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
244 while( ++pos < numSegs ) |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
245 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
246 allSegs[pos-1] = allSegs[pos]; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
247 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
248 numSegs--; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
249 return; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
250 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
251 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
252 } |
558
02fb65cddc3e
Merge rest of patch from #72.
Christian Kamm <kamm incasoftware de>
parents:
443
diff
changeset
|
253 } |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
254 |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
255 alias void delegate( void*, void* ) scanFn; |
577
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
256 |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
257 void* dataStart, dataEnd; |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
258 } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
259 |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
260 |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
261 /** |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
262 * |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
263 */ |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
264 extern (C) void rt_scanStaticData( scanFn scan ) |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
265 { |
577
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
266 scan( dataStart, dataEnd ); |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
267 |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
268 version( GC_Use_Dynamic_Ranges ) |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
269 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
270 for( size_t pos = 0; pos < numSegs; ++pos ) |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
271 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
272 scan( allSegs[pos].beg, allSegs[pos].end ); |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
273 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
274 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
275 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
276 |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
277 void initStaticDataPtrs() |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
278 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
279 const int S = (void*).sizeof; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
280 |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
281 // Can't assume the input addresses are word-aligned |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
282 static void* adjust_up( void* p ) |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
283 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
284 return p + ((S - (cast(size_t)p & (S-1))) & (S-1)); // cast ok even if 64-bit |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
285 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
286 |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
287 static void * adjust_down( void* p ) |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
288 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
289 return p - (cast(size_t) p & (S-1)); |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
290 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
291 |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
292 version( Win32 ) |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
293 { |
577
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
294 dataStart = adjust_up( &Data_Start ); |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
295 dataEnd = adjust_down( &Data_End ); |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
296 } |
899
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
297 else version(linux) |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
298 { |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
299 dataStart = adjust_up( &Data_Start ); |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
300 dataEnd = adjust_down( &Data_End ); |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
301 } |
900
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
302 else version(solaris) |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
303 { |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
304 dataStart = adjust_up( &Data_Start ); |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
305 dataEnd = adjust_down( &Data_End ); |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
306 } |
905
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
307 else version(GC_Use_Data_Dyld) |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
308 { |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
309 _d_dyld_start(); |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
310 } |
899
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
311 else |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
312 { |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
313 static assert( false, "Operating system not supported." ); |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
314 } |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
315 |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
316 version( GC_Use_Data_Proc_Maps ) |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
317 { |
900
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
318 parseDataProcMaps(); |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
319 } |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
320 } |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
321 |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
322 version( GC_Use_Data_Proc_Maps ) |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
323 { |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
324 version(solaris) |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
325 { |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
326 typedef long offset_t; |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
327 enum : uint { PRMAPSZ = 64, MA_WRITE = 0x02 } |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
328 extern(C) |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
329 { |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
330 struct prmap { |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
331 uintptr_t pr_vaddr; /* virtual address of mapping */ |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
332 size_t pr_size; /* size of mapping in bytes */ |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
333 char[PRMAPSZ] pr_mapname; /* name in /proc/<pid>/object */ |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
334 private offset_t pr_offset; /* offset into mapped object, if any */ |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
335 int pr_mflags; /* protection and attribute flags (see below) */ |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
336 int pr_pagesize; /* pagesize (bytes) for this mapping */ |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
337 int pr_shmid; /* SysV shmid, -1 if not SysV shared memory */ |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
338 |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
339 private int[1] pr_filler; |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
340 } |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
341 } |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
342 |
903
493d42562733
Further Solaris data segment detection fixes. Thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
900
diff
changeset
|
343 debug (ProcMaps) extern (C) int printf(char*, ...); |
493d42562733
Further Solaris data segment detection fixes. Thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
900
diff
changeset
|
344 |
900
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
345 void parseDataProcMaps() |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
346 { |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
347 debug (ProcMaps) printf("initStaticDataPtrs()\n"); |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
348 // http://docs.sun.com/app/docs/doc/816-5174/proc-4 |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
349 prmap pr; |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
350 |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
351 int fd = open("/proc/self/map", O_RDONLY); |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
352 scope (exit) close(fd); |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
353 |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
354 while (prmap.sizeof == read(fd, &pr, prmap.sizeof)) |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
355 if (pr.pr_mflags & MA_WRITE) |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
356 { |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
357 void* start = cast(void*) pr.pr_vaddr; |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
358 void* end = cast(void*)(pr.pr_vaddr + pr.pr_size); |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
359 debug (ProcMaps) printf(" vmem at %p - %p with size %d bytes\n", start, end, pr.pr_size); |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
360 |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
361 // Exclude stack and dataStart..dataEnd |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
362 if ( ( !dataEnd || |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
363 !( dataStart >= start && dataEnd <= end ) ) && |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
364 !( &pr >= start && &pr < end ) ) |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
365 { |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
366 // we already have static data from this region. anything else |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
367 // is heap (%% check) |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
368 debug (ProcMaps) printf(" Adding map range %p - %p\n", start, end); |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
369 _d_gc_add_range(start, end); |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
370 } |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
371 } |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
372 } |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
373 } |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
374 else |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
375 { |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
376 const int S = (void*).sizeof; |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
377 |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
378 // TODO: This could use cleanup! |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
379 void parseDataProcMaps() |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
380 { |
577
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
381 // TODO: Exclude zero-mapped regions |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
382 |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
383 int fd = open("/proc/self/maps", O_RDONLY); |
794
661384d6a936
Fix warnings on x86-64. By fvbommel.
Christian Kamm <kamm incasoftware de>
parents:
664
diff
changeset
|
384 ptrdiff_t count; // %% need to configure ret for read.. |
577
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
385 char buf[2024]; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
386 char* p; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
387 char* e; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
388 char* s; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
389 void* start; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
390 void* end; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
391 |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
392 p = buf.ptr; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
393 if (fd != -1) |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
394 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
395 while ( (count = read(fd, p, buf.sizeof - (p - buf.ptr))) > 0 ) |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
396 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
397 e = p + count; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
398 p = buf.ptr; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
399 while (true) |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
400 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
401 s = p; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
402 while (p < e && *p != '\n') |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
403 p++; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
404 if (p < e) |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
405 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
406 // parse the entry in [s, p) |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
407 static if( S == 4 ) |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
408 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
409 enum Ofs |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
410 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
411 Write_Prot = 19, |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
412 Start_Addr = 0, |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
413 End_Addr = 9, |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
414 Addr_Len = 8, |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
415 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
416 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
417 else static if( S == 8 ) |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
418 { |
899
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
419 //X86-64 only has 12 bytes address space(in PAE mode) - not 16 |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
420 //We also need the 32 bit offsets for 32 bit apps |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
421 version(X86_64) { |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
422 enum Ofs |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
423 { |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
424 Write_Prot = 27, |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
425 Start_Addr = 0, |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
426 End_Addr = 13, |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
427 Addr_Len = 12, |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
428 Write_Prot_32 = 19, |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
429 Start_Addr_32 = 0, |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
430 End_Addr_32 = 9, |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
431 Addr_Len_32 = 8, |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
432 } |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
433 } |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
434 else |
577
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
435 { |
899
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
436 enum Ofs |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
437 { |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
438 Write_Prot = 35, |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
439 Start_Addr = 0, |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
440 End_Addr = 9, |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
441 Addr_Len = 17, |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
442 } |
577
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
443 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
444 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
445 else |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
446 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
447 static assert( false ); |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
448 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
449 |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
450 // %% this is wrong for 64-bit: |
899
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
451 // long strtoul(const char*,char**,int); |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
452 // but seems to work on x86-64: |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
453 // probably because C's long is 64 bit there |
577
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
454 |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
455 if( s[Ofs.Write_Prot] == 'w' ) |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
456 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
457 s[Ofs.Start_Addr + Ofs.Addr_Len] = '\0'; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
458 s[Ofs.End_Addr + Ofs.Addr_Len] = '\0'; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
459 start = cast(void*) strtoul(s + Ofs.Start_Addr, null, 16); |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
460 end = cast(void*) strtoul(s + Ofs.End_Addr, null, 16); |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
461 |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
462 // 1. Exclude anything overlapping [dataStart, dataEnd) |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
463 // 2. Exclude stack |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
464 if ( ( !dataEnd || |
899
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
465 !( dataStart >= start && dataEnd <= end ) ) && |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
466 !( &buf[0] >= start && &buf[0] < end ) ) |
577
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
467 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
468 // we already have static data from this region. anything else |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
469 // is heap (%% check) |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
470 debug (ProcMaps) printf("Adding map range %p 0%p\n", start, end); |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
471 _d_gc_add_range(start, end); |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
472 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
473 } |
899
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
474 version(X86_64) |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
475 { |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
476 //We need to check here for 32 bit apps like ldc produces |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
477 //and add them to the gc scan range |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
478 if( s[Ofs.Write_Prot_32] == 'w' ) |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
479 { |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
480 s[Ofs.Start_Addr_32 + Ofs.Addr_Len_32] = '\0'; |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
481 s[Ofs.End_Addr_32 + Ofs.Addr_Len_32] = '\0'; |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
482 start = cast(void*) strtoul(s + Ofs.Start_Addr_32, null, 16); |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
483 end = cast(void*) strtoul(s + Ofs.End_Addr_32, null, 16); |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
484 if ( ( !dataEnd || |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
485 !( dataStart >= start && dataEnd <= end ) ) && |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
486 !( &buf[0] >= start && &buf[0] < end ) ) |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
487 { |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
488 _d_gc_add_range(start, end); |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
489 } |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
490 } |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
491 } |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
492 |
577
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
493 p++; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
494 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
495 else |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
496 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
497 count = p - s; |
794
661384d6a936
Fix warnings on x86-64. By fvbommel.
Christian Kamm <kamm incasoftware de>
parents:
664
diff
changeset
|
498 memmove(buf.ptr, s, cast(size_t)count); |
577
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
499 p = buf.ptr + count; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
500 break; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
501 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
502 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
503 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
504 close(fd); |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
505 } |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
506 } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
507 } |
903
493d42562733
Further Solaris data segment detection fixes. Thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
900
diff
changeset
|
508 } |
905
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
509 |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
510 /* |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
511 * GDC dyld memory module: |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
512 * http://www.dsource.org/projects/tango/browser/trunk/lib/compiler/gdc/memory_dyld.c |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
513 * Port to the D programming language: Jacob Carlborg |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
514 */ |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
515 version (GC_Use_Data_Dyld) |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
516 { |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
517 private |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
518 { |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
519 const char* SEG_DATA = "__DATA".ptr; |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
520 const char* SECT_DATA = "__data".ptr; |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
521 const char* SECT_BSS = "__bss".ptr; |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
522 const char* SECT_COMMON = "__common".ptr; |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
523 |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
524 struct SegmentSection |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
525 { |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
526 const char* segment; |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
527 const char* section; |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
528 } |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
529 |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
530 struct mach_header |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
531 { |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
532 uint magic; |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
533 int cputype; |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
534 int cpusubtype; |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
535 uint filetype; |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
536 uint ncmds; |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
537 uint sizeofcmds; |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
538 uint flags; |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
539 } |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
540 |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
541 struct section |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
542 { |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
543 char[16] sectname; |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
544 char[16] segname; |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
545 uint addr; |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
546 uint size; |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
547 uint offset; |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
548 uint align_; |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
549 uint reloff; |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
550 uint nreloc; |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
551 uint flags; |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
552 uint reserved1; |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
553 uint reserved2; |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
554 } |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
555 |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
556 alias extern (C) void function (mach_header* mh, ptrdiff_t vmaddr_slide) DyldFuncPointer; |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
557 |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
558 extern (C) /*const*/ section* getsectbynamefromheader(/*const*/ mach_header* mhp, /*const*/ char* segname, /*const*/ char* sectname); |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
559 extern (C) void _dyld_register_func_for_add_image(DyldFuncPointer func); |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
560 extern (C) void _dyld_register_func_for_remove_image(DyldFuncPointer func); |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
561 |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
562 const SegmentSection[3] GC_dyld_sections = [SegmentSection(SEG_DATA, SECT_DATA), SegmentSection(SEG_DATA, SECT_BSS), SegmentSection(SEG_DATA, SECT_COMMON)]; |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
563 |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
564 extern (C) void on_dyld_add_image (/*const*/ mach_header* hdr, ptrdiff_t slide) |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
565 { |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
566 void* start; |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
567 void* end; |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
568 /*const*/ section* sec; |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
569 |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
570 foreach (s ; GC_dyld_sections) |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
571 { |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
572 sec = getsectbynamefromheader(hdr, s.segment, s.section); |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
573 |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
574 if (sec == null || sec.size == 0) |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
575 continue; |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
576 |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
577 start = cast(void*) (sec.addr + slide); |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
578 end = cast(void*) (start + sec.size); |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
579 |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
580 _d_gc_add_range(start, end); |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
581 } |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
582 } |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
583 |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
584 extern (C) void on_dyld_remove_image (/*const*/ mach_header* hdr, ptrdiff_t slide) |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
585 { |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
586 void* start; |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
587 void* end; |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
588 /*const*/ section* sec; |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
589 |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
590 foreach (s ; GC_dyld_sections) |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
591 { |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
592 sec = getsectbynamefromheader(hdr, s.segment, s.section); |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
593 |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
594 if (sec == null || sec.size == 0) |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
595 continue; |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
596 |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
597 start = cast(void*) (sec.addr + slide); |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
598 end = cast(void*) (start + sec.size); |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
599 |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
600 _d_gc_remove_range(start); |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
601 } |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
602 } |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
603 |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
604 void _d_dyld_start () |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
605 { |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
606 static bool started; |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
607 |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
608 if (!started) |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
609 { |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
610 started = true; |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
611 |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
612 _dyld_register_func_for_add_image(&on_dyld_add_image); |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
613 _dyld_register_func_for_remove_image(&on_dyld_remove_image); |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
614 } |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
615 } |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
616 } |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
617 } |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
618 |