annotate runtime/internal/memory.d @ 1650:40bd4a0d4870

Update to work with LLVM 2.7. Removed use of dyn_cast, llvm no compiles without exceptions and rtti by default. We do need exceptions for the libconfig stuff, but rtti isn't necessary (anymore). Debug info needs to be rewritten, as in LLVM 2.7 the format has completely changed. To have something to look at while rewriting, the old code has been wrapped inside #ifndef DISABLE_DEBUG_INFO , this means that you have to define this to compile at the moment. Updated tango 0.99.9 patch to include updated EH runtime code, which is needed for LLVM 2.7 as well.
author Tomas Lindquist Olsen
date Wed, 19 May 2010 12:42:32 +0200
parents 4a5eea0334e5
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 }
1151
3cf0066e6faf - Versioned Expresssion::toElem with #if IN_DMD/IN_LLVM.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 905
diff changeset
71 pragma(intrinsic, "llvm.frameaddress")
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 {
1151
3cf0066e6faf - Versioned Expresssion::toElem with #if IN_DMD/IN_LLVM.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 905
diff changeset
73 void* llvm_frameaddress(uint level=0);
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
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 }
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 */
872
aa953cc960b6 Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents: 794
diff changeset
81
aa953cc960b6 Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents: 794
diff changeset
82 version( solaris ) {
aa953cc960b6 Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents: 794
diff changeset
83 version(X86_64) {
aa953cc960b6 Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents: 794
diff changeset
84 extern (C) void* _userlimit;
aa953cc960b6 Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents: 794
diff changeset
85 }
aa953cc960b6 Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents: 794
diff changeset
86 }
aa953cc960b6 Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents: 794
diff changeset
87
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
88 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
89 {
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
90 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
91 {
578
8caa9adce5ae Fix (?) rt_stackBottom for Windows.
Christian Kamm <kamm incasoftware de>
parents: 577
diff changeset
92 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
93 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
94 {
578
8caa9adce5ae Fix (?) rt_stackBottom for Windows.
Christian Kamm <kamm incasoftware de>
parents: 577
diff changeset
95 mov EAX, FS:4;
8caa9adce5ae Fix (?) rt_stackBottom for Windows.
Christian Kamm <kamm incasoftware de>
parents: 577
diff changeset
96 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
97 }
578
8caa9adce5ae Fix (?) rt_stackBottom for Windows.
Christian Kamm <kamm incasoftware de>
parents: 577
diff changeset
98 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
99 }
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 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
101 {
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 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
103 {
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 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
105 }
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 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
107 {
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 // 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
109 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
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 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
112 {
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 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
114 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
115 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
116 }
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 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
118 }
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 }
558
02fb65cddc3e Merge rest of patch from #72.
Christian Kamm <kamm incasoftware de>
parents: 443
diff changeset
120 else version( darwin )
02fb65cddc3e Merge rest of patch from #72.
Christian Kamm <kamm incasoftware de>
parents: 443
diff changeset
121 {
559
5d6ef6e6805d Make rt_stackBottom return the right fixed value for darwin.
Christian Kamm <kamm incasoftware de>
parents: 558
diff changeset
122 // darwin has a fixed stack bottom
1289
4a5eea0334e5 Add runtime support for darwin x86_64
Benjamin Kramer <benny.kra@gmail.com>
parents: 1151
diff changeset
123 version(X86_64)
4a5eea0334e5 Add runtime support for darwin x86_64
Benjamin Kramer <benny.kra@gmail.com>
parents: 1151
diff changeset
124 return cast(void*) 0x7fff5fc00000;
4a5eea0334e5 Add runtime support for darwin x86_64
Benjamin Kramer <benny.kra@gmail.com>
parents: 1151
diff changeset
125 else
4a5eea0334e5 Add runtime support for darwin x86_64
Benjamin Kramer <benny.kra@gmail.com>
parents: 1151
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 {
1151
3cf0066e6faf - Versioned Expresssion::toElem with #if IN_DMD/IN_LLVM.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 905
diff changeset
150 version( D_InlineAsm_X86 )
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 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
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 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
155 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
156 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
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 }
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 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
160 {
1151
3cf0066e6faf - Versioned Expresssion::toElem with #if IN_DMD/IN_LLVM.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 905
diff changeset
161 return llvm_frameaddress();
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
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 }
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
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 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
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 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
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 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
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 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
173 extern int _bss_end__;
900
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
174 }
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
175
900
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
176 alias _data_start__ Data_Start;
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
177 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
178 }
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 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
180 {
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
181 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
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 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
184 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
185 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
186 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
187 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
188 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
189 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
190 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
191 }
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
900
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
193 alias __data_start Data_Start;
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
194 alias _end Data_End;
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
195 }
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
196 else version( solaris )
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
197 {
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
198 extern(C)
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
199 {
903
493d42562733 Further Solaris data segment detection fixes. Thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 900
diff changeset
200 extern int _environ;
900
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
201 extern int _end;
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
202 }
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 alias _environ Data_Start;
900
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
205 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
206 }
577
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
207
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
208 version( GC_Use_Dynamic_Ranges )
558
02fb65cddc3e Merge rest of patch from #72.
Christian Kamm <kamm incasoftware de>
parents: 443
diff changeset
209 {
577
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
210 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
211
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
212 struct DataSeg
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
213 {
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
214 void* beg;
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
215 void* end;
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
216 }
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 DataSeg* allSegs = null;
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
219 size_t numSegs = 0;
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 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
222 {
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
223 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
224
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
225 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
226 {
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
227 allSegs = cast(DataSeg*) ptr;
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
228 allSegs[numSegs].beg = beg;
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
229 allSegs[numSegs].end = end;
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
230 numSegs++;
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
231 }
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
232 }
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
233
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
234 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
235 {
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
236 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
237 {
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
238 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
239 {
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
240 while( ++pos < numSegs )
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 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
243 }
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
244 numSegs--;
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
245 return;
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
246 }
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 }
558
02fb65cddc3e Merge rest of patch from #72.
Christian Kamm <kamm incasoftware de>
parents: 443
diff changeset
249 }
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
250
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
251 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
252
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
253 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
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
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
256
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
257 /**
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 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
261 {
577
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
262 scan( dataStart, dataEnd );
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
263
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
264 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
265 {
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
266 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
267 {
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
268 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
269 }
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
270 }
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
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
273 void initStaticDataPtrs()
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 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
276
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
277 // 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
278 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
279 {
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
280 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
281 }
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
282
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
283 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
284 {
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
285 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
286 }
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
287
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
288 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
289 {
577
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
290 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
291 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
292 }
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
293 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
294 {
23d36edea021 Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents: 894
diff changeset
295 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
296 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
297 }
900
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
298 else version(solaris)
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
299 {
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
300 dataStart = adjust_up( &Data_Start );
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
301 dataEnd = adjust_down( &Data_End );
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
302 }
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
303 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
304 {
bd000a7fab18 Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents: 903
diff changeset
305 _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
306 }
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
307 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
308 {
23d36edea021 Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents: 894
diff changeset
309 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
310 }
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
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 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
313 {
900
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
314 parseDataProcMaps();
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
315 }
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
316 }
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
317
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
318 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
319 {
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
320 version(solaris)
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 typedef long offset_t;
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
323 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
324 extern(C)
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 struct prmap {
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
327 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
328 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
329 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
330 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
331 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
332 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
333 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
334
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
335 private int[1] pr_filler;
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
336 }
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
337 }
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
338
903
493d42562733 Further Solaris data segment detection fixes. Thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 900
diff changeset
339 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
340
900
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
341 void parseDataProcMaps()
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
342 {
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
343 debug (ProcMaps) printf("initStaticDataPtrs()\n");
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
344 // 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
345 prmap pr;
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 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
348 scope (exit) close(fd);
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
349
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
350 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
351 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
352 {
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
353 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
354 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
355 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
356
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
357 // Exclude stack and dataStart..dataEnd
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
358 if ( ( !dataEnd ||
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
359 !( dataStart >= start && dataEnd <= end ) ) &&
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
360 !( &pr >= start && &pr < end ) )
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
361 {
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
362 // 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
363 // is heap (%% check)
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
364 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
365 _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
366 }
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
367 }
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
368 }
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
369 }
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
370 else
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 const int S = (void*).sizeof;
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 // TODO: This could use cleanup!
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
375 void parseDataProcMaps()
177afbf5297b Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 899
diff changeset
376 {
577
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
377 // 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
378
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
379 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
380 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
381 char buf[2024];
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
382 char* p;
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
383 char* e;
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
384 char* s;
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
385 void* start;
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
386 void* end;
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
387
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
388 p = buf.ptr;
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
389 if (fd != -1)
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
390 {
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
391 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
392 {
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
393 e = p + count;
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
394 p = buf.ptr;
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
395 while (true)
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 s = p;
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
398 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
399 p++;
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
400 if (p < e)
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
401 {
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
402 // 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
403 static if( S == 4 )
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
404 {
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
405 enum Ofs
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
406 {
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
407 Write_Prot = 19,
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
408 Start_Addr = 0,
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
409 End_Addr = 9,
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
410 Addr_Len = 8,
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
411 }
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
412 }
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
413 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
414 {
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
415 //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
416 //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
417 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
418 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
419 {
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 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
421 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
422 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
423 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
424 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
425 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
426 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
427 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
428 }
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 }
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 else
577
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
431 {
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
432 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
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 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
435 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
436 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
437 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
438 }
577
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
439 }
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
440 }
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
441 else
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
442 {
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
443 static assert( false );
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
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
446 // %% 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
447 // 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
448 // 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
449 // 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
450
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
451 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
452 {
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
453 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
454 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
455 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
456 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
457
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
458 // 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
459 // 2. Exclude stack
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
460 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
461 !( 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
462 !( &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
463 {
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
464 // 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
465 // is heap (%% check)
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
466 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
467 _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
468 }
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
469 }
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
470 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
471 {
23d36edea021 Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents: 894
diff changeset
472 //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
473 //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
474 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
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 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
477 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
478 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
479 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
480 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
481 !( 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
482 !( &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
483 {
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 _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
485 }
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 }
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
577
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
489 p++;
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
490 }
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
491 else
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
492 {
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
493 count = p - s;
794
661384d6a936 Fix warnings on x86-64. By fvbommel.
Christian Kamm <kamm incasoftware de>
parents: 664
diff changeset
494 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
495 p = buf.ptr + count;
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
496 break;
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
497 }
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
498 }
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
499 }
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
500 close(fd);
68be7408a0db Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents: 559
diff changeset
501 }
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
502 }
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
503 }
903
493d42562733 Further Solaris data segment detection fixes. Thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents: 900
diff changeset
504 }
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
505
bd000a7fab18 Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents: 903
diff changeset
506 /*
bd000a7fab18 Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents: 903
diff changeset
507 * 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
508 * 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
509 * 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
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 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
512 {
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 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
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 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
516 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
517 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
518 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
519
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 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
521 {
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* 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
523 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
524 }
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 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
527 {
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 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
529 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
530 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
531 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
532 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
533 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
534 uint flags;
1289
4a5eea0334e5 Add runtime support for darwin x86_64
Benjamin Kramer <benny.kra@gmail.com>
parents: 1151
diff changeset
535 version(X86_64)
4a5eea0334e5 Add runtime support for darwin x86_64
Benjamin Kramer <benny.kra@gmail.com>
parents: 1151
diff changeset
536 uint reserved;
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
537 }
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
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 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
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 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
542 char[16] segname;
1289
4a5eea0334e5 Add runtime support for darwin x86_64
Benjamin Kramer <benny.kra@gmail.com>
parents: 1151
diff changeset
543 version(X86_64)
4a5eea0334e5 Add runtime support for darwin x86_64
Benjamin Kramer <benny.kra@gmail.com>
parents: 1151
diff changeset
544 {
4a5eea0334e5 Add runtime support for darwin x86_64
Benjamin Kramer <benny.kra@gmail.com>
parents: 1151
diff changeset
545 ulong addr;
4a5eea0334e5 Add runtime support for darwin x86_64
Benjamin Kramer <benny.kra@gmail.com>
parents: 1151
diff changeset
546 ulong size;
4a5eea0334e5 Add runtime support for darwin x86_64
Benjamin Kramer <benny.kra@gmail.com>
parents: 1151
diff changeset
547 }
4a5eea0334e5 Add runtime support for darwin x86_64
Benjamin Kramer <benny.kra@gmail.com>
parents: 1151
diff changeset
548 else
4a5eea0334e5 Add runtime support for darwin x86_64
Benjamin Kramer <benny.kra@gmail.com>
parents: 1151
diff changeset
549 {
4a5eea0334e5 Add runtime support for darwin x86_64
Benjamin Kramer <benny.kra@gmail.com>
parents: 1151
diff changeset
550 uint addr;
4a5eea0334e5 Add runtime support for darwin x86_64
Benjamin Kramer <benny.kra@gmail.com>
parents: 1151
diff changeset
551 uint size;
4a5eea0334e5 Add runtime support for darwin x86_64
Benjamin Kramer <benny.kra@gmail.com>
parents: 1151
diff changeset
552 }
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
553 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
554 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
555 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
556 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
557 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
558 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
559 uint reserved2;
1289
4a5eea0334e5 Add runtime support for darwin x86_64
Benjamin Kramer <benny.kra@gmail.com>
parents: 1151
diff changeset
560 version(X86_64)
4a5eea0334e5 Add runtime support for darwin x86_64
Benjamin Kramer <benny.kra@gmail.com>
parents: 1151
diff changeset
561 uint reserved3;
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
562 }
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 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
565
1289
4a5eea0334e5 Add runtime support for darwin x86_64
Benjamin Kramer <benny.kra@gmail.com>
parents: 1151
diff changeset
566 version(X86_64)
4a5eea0334e5 Add runtime support for darwin x86_64
Benjamin Kramer <benny.kra@gmail.com>
parents: 1151
diff changeset
567 extern (C) /*const*/ section* getsectbynamefromheader_64(/*const*/ mach_header* mhp, /*const*/ char* segname, /*const*/ char* sectname);
4a5eea0334e5 Add runtime support for darwin x86_64
Benjamin Kramer <benny.kra@gmail.com>
parents: 1151
diff changeset
568 else
4a5eea0334e5 Add runtime support for darwin x86_64
Benjamin Kramer <benny.kra@gmail.com>
parents: 1151
diff changeset
569 extern (C) /*const*/ section* getsectbynamefromheader(/*const*/ mach_header* mhp, /*const*/ char* segname, /*const*/ char* sectname);
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
570 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
571 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
572
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 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
574
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 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
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 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
578 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
579 /*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
580
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 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
582 {
1289
4a5eea0334e5 Add runtime support for darwin x86_64
Benjamin Kramer <benny.kra@gmail.com>
parents: 1151
diff changeset
583 version(X86_64)
4a5eea0334e5 Add runtime support for darwin x86_64
Benjamin Kramer <benny.kra@gmail.com>
parents: 1151
diff changeset
584 sec = getsectbynamefromheader_64(hdr, s.segment, s.section);
4a5eea0334e5 Add runtime support for darwin x86_64
Benjamin Kramer <benny.kra@gmail.com>
parents: 1151
diff changeset
585 else
4a5eea0334e5 Add runtime support for darwin x86_64
Benjamin Kramer <benny.kra@gmail.com>
parents: 1151
diff changeset
586 sec = getsectbynamefromheader(hdr, s.segment, s.section);
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
587
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 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
589 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
590
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 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
592 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
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 _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
595 }
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
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 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
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 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
601 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
602 /*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
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 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
605 {
1289
4a5eea0334e5 Add runtime support for darwin x86_64
Benjamin Kramer <benny.kra@gmail.com>
parents: 1151
diff changeset
606 version(X86_64)
4a5eea0334e5 Add runtime support for darwin x86_64
Benjamin Kramer <benny.kra@gmail.com>
parents: 1151
diff changeset
607 sec = getsectbynamefromheader_64(hdr, s.segment, s.section);
4a5eea0334e5 Add runtime support for darwin x86_64
Benjamin Kramer <benny.kra@gmail.com>
parents: 1151
diff changeset
608 else
4a5eea0334e5 Add runtime support for darwin x86_64
Benjamin Kramer <benny.kra@gmail.com>
parents: 1151
diff changeset
609 sec = getsectbynamefromheader(hdr, s.segment, s.section);
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
610
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 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
612 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
613
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 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
615 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
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 _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
618 }
bd000a7fab18 Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents: 903
diff changeset
619 }
bd000a7fab18 Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents: 903
diff changeset
620
bd000a7fab18 Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents: 903
diff changeset
621 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
622 {
bd000a7fab18 Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents: 903
diff changeset
623 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
624
bd000a7fab18 Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents: 903
diff changeset
625 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
626 {
bd000a7fab18 Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents: 903
diff changeset
627 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
628
bd000a7fab18 Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents: 903
diff changeset
629 _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
630 _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
631 }
bd000a7fab18 Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents: 903
diff changeset
632 }
bd000a7fab18 Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents: 903
diff changeset
633 }
bd000a7fab18 Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents: 903
diff changeset
634 }
bd000a7fab18 Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents: 903
diff changeset
635