Mercurial > projects > ldc
annotate runtime/internal/memory.d @ 1151:3cf0066e6faf
- Versioned Expresssion::toElem with #if IN_DMD/IN_LLVM.
- Eliminated the DLRValue DValue.
- Implemented proactive handling of l-value CastExpS.
- Minor tweak in runtime memory.d .
author | Tomas Lindquist Olsen <tomas.l.olsen gmail.com> |
---|---|
date | Sat, 28 Mar 2009 05:00:43 +0100 |
parents | bd000a7fab18 |
children | 4a5eea0334e5 |
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 |
5d6ef6e6805d
Make rt_stackBottom return the right fixed value for darwin.
Christian Kamm <kamm incasoftware de>
parents:
558
diff
changeset
|
123 return cast(void*) 0xc0000000; |
558
02fb65cddc3e
Merge rest of patch from #72.
Christian Kamm <kamm incasoftware de>
parents:
443
diff
changeset
|
124 } |
872
aa953cc960b6
Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents:
794
diff
changeset
|
125 else version( solaris ) |
aa953cc960b6
Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents:
794
diff
changeset
|
126 { |
aa953cc960b6
Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents:
794
diff
changeset
|
127 version(X86_64) { |
aa953cc960b6
Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents:
794
diff
changeset
|
128 return _userlimit; |
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 else { |
aa953cc960b6
Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents:
794
diff
changeset
|
131 // <sys/vmparam.h> |
aa953cc960b6
Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents:
794
diff
changeset
|
132 return cast(void*) 0x8048000; |
aa953cc960b6
Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents:
794
diff
changeset
|
133 } |
aa953cc960b6
Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents:
794
diff
changeset
|
134 } |
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
|
135 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
|
136 { |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
137 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
|
138 } |
44f08170f4ef
Removed tango from the repository and instead added a 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 |
44f08170f4ef
Removed tango from the repository and instead added a 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 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
|
146 { |
1151
3cf0066e6faf
- Versioned Expresssion::toElem with #if IN_DMD/IN_LLVM.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
905
diff
changeset
|
147 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
|
148 { |
44f08170f4ef
Removed tango from the repository and instead added a 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 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
|
150 { |
44f08170f4ef
Removed tango from the repository and instead added a 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 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
|
152 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
|
153 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
|
154 } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
155 } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
156 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
|
157 { |
1151
3cf0066e6faf
- Versioned Expresssion::toElem with #if IN_DMD/IN_LLVM.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
905
diff
changeset
|
158 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
|
159 } |
44f08170f4ef
Removed tango from the repository and instead added a 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 } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
161 |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
162 |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
163 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
|
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 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
|
166 { |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
167 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
|
168 { |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
169 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
|
170 extern int _bss_end__; |
900
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
171 } |
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
|
172 |
900
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
173 alias _data_start__ Data_Start; |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
174 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
|
175 } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
176 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
|
177 { |
44f08170f4ef
Removed tango from the repository and instead added a 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 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
|
179 { |
44f08170f4ef
Removed tango from the repository and instead added a 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 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
|
181 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
|
182 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
|
183 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
|
184 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
|
185 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
|
186 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
|
187 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
|
188 } |
44f08170f4ef
Removed tango from the repository and instead added a 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 |
900
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
190 alias __data_start Data_Start; |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
191 alias _end Data_End; |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
192 } |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
193 else version( solaris ) |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
194 { |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
195 extern(C) |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
196 { |
903
493d42562733
Further Solaris data segment detection fixes. Thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
900
diff
changeset
|
197 extern int _environ; |
900
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
198 extern int _end; |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
199 } |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
200 |
903
493d42562733
Further Solaris data segment detection fixes. Thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
900
diff
changeset
|
201 alias _environ Data_Start; |
900
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
202 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
|
203 } |
577
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
204 |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
205 version( GC_Use_Dynamic_Ranges ) |
558
02fb65cddc3e
Merge rest of patch from #72.
Christian Kamm <kamm incasoftware de>
parents:
443
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 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
|
208 |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
209 struct DataSeg |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
210 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
211 void* beg; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
212 void* end; |
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 |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
215 DataSeg* allSegs = null; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
216 size_t numSegs = 0; |
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 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
|
219 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
220 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
|
221 |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
222 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
|
223 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
224 allSegs = cast(DataSeg*) ptr; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
225 allSegs[numSegs].beg = beg; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
226 allSegs[numSegs].end = end; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
227 numSegs++; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
228 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
229 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
230 |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
231 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
|
232 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
233 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
|
234 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
235 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
|
236 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
237 while( ++pos < numSegs ) |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
238 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
239 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
|
240 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
241 numSegs--; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
242 return; |
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 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
245 } |
558
02fb65cddc3e
Merge rest of patch from #72.
Christian Kamm <kamm incasoftware de>
parents:
443
diff
changeset
|
246 } |
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
|
247 |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
248 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
|
249 |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
250 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
|
251 } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
252 |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
253 |
44f08170f4ef
Removed tango from the repository and instead added a 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 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
|
258 { |
577
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
259 scan( dataStart, dataEnd ); |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
260 |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
261 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
|
262 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
263 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
|
264 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
265 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
|
266 } |
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 } |
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 void initStaticDataPtrs() |
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 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
|
273 |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
274 // 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
|
275 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
|
276 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
277 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
|
278 } |
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 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
|
281 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
282 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
|
283 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
284 |
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
|
285 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
|
286 { |
577
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
287 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
|
288 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
|
289 } |
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
|
290 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
|
291 { |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
292 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
|
293 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
|
294 } |
900
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
295 else version(solaris) |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
296 { |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
297 dataStart = adjust_up( &Data_Start ); |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
298 dataEnd = adjust_down( &Data_End ); |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
299 } |
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
|
300 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
|
301 { |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
302 _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
|
303 } |
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
|
304 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
|
305 { |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
306 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
|
307 } |
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 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
|
310 { |
900
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
311 parseDataProcMaps(); |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
312 } |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
313 } |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
314 |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
315 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
|
316 { |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
317 version(solaris) |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
318 { |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
319 typedef long offset_t; |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
320 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
|
321 extern(C) |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
322 { |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
323 struct prmap { |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
324 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
|
325 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
|
326 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
|
327 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
|
328 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
|
329 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
|
330 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
|
331 |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
332 private int[1] pr_filler; |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
333 } |
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 |
903
493d42562733
Further Solaris data segment detection fixes. Thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
900
diff
changeset
|
336 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
|
337 |
900
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
338 void parseDataProcMaps() |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
339 { |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
340 debug (ProcMaps) printf("initStaticDataPtrs()\n"); |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
341 // 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
|
342 prmap pr; |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
343 |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
344 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
|
345 scope (exit) close(fd); |
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 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
|
348 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
|
349 { |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
350 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
|
351 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
|
352 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
|
353 |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
354 // Exclude stack and dataStart..dataEnd |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
355 if ( ( !dataEnd || |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
356 !( dataStart >= start && dataEnd <= end ) ) && |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
357 !( &pr >= start && &pr < end ) ) |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
358 { |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
359 // 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
|
360 // is heap (%% check) |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
361 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
|
362 _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
|
363 } |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
364 } |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
365 } |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
366 } |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
367 else |
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 const int S = (void*).sizeof; |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
370 |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
371 // TODO: This could use cleanup! |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
372 void parseDataProcMaps() |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
373 { |
577
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
374 // 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
|
375 |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
376 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
|
377 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
|
378 char buf[2024]; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
379 char* p; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
380 char* e; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
381 char* s; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
382 void* start; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
383 void* end; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
384 |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
385 p = buf.ptr; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
386 if (fd != -1) |
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 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
|
389 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
390 e = p + count; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
391 p = buf.ptr; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
392 while (true) |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
393 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
394 s = p; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
395 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
|
396 p++; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
397 if (p < e) |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
398 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
399 // 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
|
400 static if( S == 4 ) |
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 enum Ofs |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
403 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
404 Write_Prot = 19, |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
405 Start_Addr = 0, |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
406 End_Addr = 9, |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
407 Addr_Len = 8, |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
408 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
409 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
410 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
|
411 { |
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
|
412 //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
|
413 //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
|
414 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
|
415 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
|
416 { |
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 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
|
418 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
|
419 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
|
420 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
|
421 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
|
422 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
|
423 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
|
424 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
|
425 } |
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 } |
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 else |
577
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
428 { |
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
|
429 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
|
430 { |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
431 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
|
432 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
|
433 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
|
434 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
|
435 } |
577
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
436 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
437 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
438 else |
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 static assert( false ); |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
441 } |
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 // %% 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
|
444 // 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
|
445 // 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
|
446 // 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
|
447 |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
448 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
|
449 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
450 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
|
451 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
|
452 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
|
453 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
|
454 |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
455 // 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
|
456 // 2. Exclude stack |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
457 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
|
458 !( 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
|
459 !( &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
|
460 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
461 // 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
|
462 // is heap (%% check) |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
463 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
|
464 _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
|
465 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
466 } |
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
|
467 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
|
468 { |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
469 //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
|
470 //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
|
471 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
|
472 { |
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 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
|
474 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
|
475 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
|
476 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
|
477 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
|
478 !( 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
|
479 !( &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
|
480 { |
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 _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
|
482 } |
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 } |
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 |
577
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
486 p++; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
487 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
488 else |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
489 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
490 count = p - s; |
794
661384d6a936
Fix warnings on x86-64. By fvbommel.
Christian Kamm <kamm incasoftware de>
parents:
664
diff
changeset
|
491 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
|
492 p = buf.ptr + count; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
493 break; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
494 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
495 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
496 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
497 close(fd); |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
498 } |
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
|
499 } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
500 } |
903
493d42562733
Further Solaris data segment detection fixes. Thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
900
diff
changeset
|
501 } |
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
|
502 |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
503 /* |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
504 * 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
|
505 * 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
|
506 * 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
|
507 */ |
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 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
|
509 { |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
510 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
|
511 { |
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 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
|
513 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
|
514 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
|
515 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
|
516 |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
517 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
|
518 { |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
519 const char* 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
|
520 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
|
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 |
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 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
|
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 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
|
526 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
|
527 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
|
528 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
|
529 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
|
530 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
|
531 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
|
532 } |
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 |
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 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
|
535 { |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
536 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
|
537 char[16] segname; |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
538 uint addr; |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
539 uint size; |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
540 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
|
541 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
|
542 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
|
543 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
|
544 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
|
545 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
|
546 uint reserved2; |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
547 } |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
548 |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
549 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
|
550 |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
551 extern (C) /*const*/ section* getsectbynamefromheader(/*const*/ mach_header* mhp, /*const*/ char* segname, /*const*/ char* sectname); |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
552 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
|
553 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
|
554 |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
555 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
|
556 |
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 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
|
558 { |
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 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
|
560 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
|
561 /*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
|
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 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
|
564 { |
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 sec = getsectbynamefromheader(hdr, s.segment, s.section); |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
566 |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
567 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
|
568 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
|
569 |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
570 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
|
571 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
|
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 _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
|
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 } |
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 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
|
578 { |
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 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
|
580 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
|
581 /*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
|
582 |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
583 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
|
584 { |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
585 sec = getsectbynamefromheader(hdr, s.segment, s.section); |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
586 |
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 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
|
588 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
|
589 |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
590 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
|
591 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
|
592 |
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 _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
|
594 } |
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 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
|
598 { |
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 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
|
600 |
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 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
|
602 { |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
603 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
|
604 |
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 _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
|
606 _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
|
607 } |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
608 } |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
609 } |
bd000a7fab18
Applied doob's patch to port GDC's Dyld data segment tracking for Mac.
Christian Kamm <kamm incasoftware de>
parents:
903
diff
changeset
|
610 } |
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 |