Mercurial > projects > ldc
annotate runtime/internal/memory.d @ 903:493d42562733
Further Solaris data segment detection fixes. Thanks BlueZeniX!
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Fri, 23 Jan 2009 10:13:27 +0100 |
parents | 177afbf5297b |
children | bd000a7fab18 |
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 |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
30 version(Posix) |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
31 { |
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
|
32 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
|
33 } |
900
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
34 version(solaris) |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
35 { |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
36 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
|
37 } |
577
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
38 |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
39 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
|
40 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
41 version(Posix) {} else { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
42 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
|
43 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
44 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
|
45 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
|
46 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
|
47 |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
48 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
|
49 } |
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
|
50 |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
51 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
|
52 { |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
53 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
|
54 { |
44f08170f4ef
Removed tango from the repository and instead added a 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 //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
|
56 |
44f08170f4ef
Removed tango from the repository and instead added a 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 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
|
58 { |
44f08170f4ef
Removed tango from the repository and instead added a 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 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
|
60 } |
44f08170f4ef
Removed tango from the repository and instead added a 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 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
|
62 { |
44f08170f4ef
Removed tango from the repository and instead added a 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 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
|
64 } |
44f08170f4ef
Removed tango from the repository and instead added a 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 } |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
578
diff
changeset
|
66 version(LDC) |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
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 pragma(intrinsic, "llvm.frameaddress") |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
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 void* llvm_frameaddress(uint level=0); |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
71 } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
72 } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
73 } |
44f08170f4ef
Removed tango from the repository and instead added a 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 */ |
872
aa953cc960b6
Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents:
794
diff
changeset
|
79 |
aa953cc960b6
Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents:
794
diff
changeset
|
80 version( solaris ) { |
aa953cc960b6
Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents:
794
diff
changeset
|
81 version(X86_64) { |
aa953cc960b6
Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents:
794
diff
changeset
|
82 extern (C) void* _userlimit; |
aa953cc960b6
Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents:
794
diff
changeset
|
83 } |
aa953cc960b6
Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents:
794
diff
changeset
|
84 } |
aa953cc960b6
Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents:
794
diff
changeset
|
85 |
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
|
86 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
|
87 { |
44f08170f4ef
Removed tango from the repository and instead added a 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 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
|
89 { |
578
8caa9adce5ae
Fix (?) rt_stackBottom for Windows.
Christian Kamm <kamm incasoftware de>
parents:
577
diff
changeset
|
90 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
|
91 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
|
92 { |
578
8caa9adce5ae
Fix (?) rt_stackBottom for Windows.
Christian Kamm <kamm incasoftware de>
parents:
577
diff
changeset
|
93 mov EAX, FS:4; |
8caa9adce5ae
Fix (?) rt_stackBottom for Windows.
Christian Kamm <kamm incasoftware de>
parents:
577
diff
changeset
|
94 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
|
95 } |
578
8caa9adce5ae
Fix (?) rt_stackBottom for Windows.
Christian Kamm <kamm incasoftware de>
parents:
577
diff
changeset
|
96 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
|
97 } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
98 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
|
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 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
|
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 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
|
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 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
|
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 // 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
|
107 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
|
108 |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
109 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
|
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 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
|
112 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
|
113 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
|
114 } |
44f08170f4ef
Removed tango from the repository and instead added a 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 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
|
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 } |
558
02fb65cddc3e
Merge rest of patch from #72.
Christian Kamm <kamm incasoftware de>
parents:
443
diff
changeset
|
118 else version( darwin ) |
02fb65cddc3e
Merge rest of patch from #72.
Christian Kamm <kamm incasoftware de>
parents:
443
diff
changeset
|
119 { |
559
5d6ef6e6805d
Make rt_stackBottom return the right fixed value for darwin.
Christian Kamm <kamm incasoftware de>
parents:
558
diff
changeset
|
120 // 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
|
121 return cast(void*) 0xc0000000; |
558
02fb65cddc3e
Merge rest of patch from #72.
Christian Kamm <kamm incasoftware de>
parents:
443
diff
changeset
|
122 } |
872
aa953cc960b6
Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents:
794
diff
changeset
|
123 else version( solaris ) |
aa953cc960b6
Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents:
794
diff
changeset
|
124 { |
aa953cc960b6
Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents:
794
diff
changeset
|
125 version(X86_64) { |
aa953cc960b6
Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents:
794
diff
changeset
|
126 return _userlimit; |
aa953cc960b6
Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents:
794
diff
changeset
|
127 } |
aa953cc960b6
Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents:
794
diff
changeset
|
128 else { |
aa953cc960b6
Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents:
794
diff
changeset
|
129 // <sys/vmparam.h> |
aa953cc960b6
Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents:
794
diff
changeset
|
130 return cast(void*) 0x8048000; |
aa953cc960b6
Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents:
794
diff
changeset
|
131 } |
aa953cc960b6
Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
Christian Kamm <kamm incasoftware de>
parents:
794
diff
changeset
|
132 } |
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
|
133 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
|
134 { |
44f08170f4ef
Removed tango from the repository and instead added a 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 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
|
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 } |
44f08170f4ef
Removed tango from the repository and instead added a 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 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
|
144 { |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
578
diff
changeset
|
145 version(LDC) |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
146 { |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
147 return llvm_frameaddress(); |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
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 else version( D_InlineAsm_X86 ) |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
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 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
|
152 { |
44f08170f4ef
Removed tango from the repository and instead added a 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 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
|
154 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
|
155 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
|
156 } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
157 } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
158 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
|
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 static assert( false, "Architecture not supported." ); |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
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 |
44f08170f4ef
Removed tango from the repository and instead added a 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 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
|
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 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
|
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 (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
|
170 { |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
171 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
|
172 extern int _bss_end__; |
900
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
173 } |
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
|
174 |
900
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
175 alias _data_start__ Data_Start; |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
176 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
|
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 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
|
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 (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
|
181 { |
44f08170f4ef
Removed tango from the repository and instead added a 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 _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
|
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 _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 _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
|
186 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
|
187 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
|
188 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
|
189 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
|
190 } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
191 |
900
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
192 alias __data_start Data_Start; |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
193 alias _end Data_End; |
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 else version( solaris ) |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
196 { |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
197 extern(C) |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
198 { |
903
493d42562733
Further Solaris data segment detection fixes. Thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
900
diff
changeset
|
199 extern int _environ; |
900
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
200 extern int _end; |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
201 } |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
202 |
903
493d42562733
Further Solaris data segment detection fixes. Thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
900
diff
changeset
|
203 alias _environ Data_Start; |
900
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
204 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
|
205 } |
577
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
206 |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
207 version( GC_Use_Dynamic_Ranges ) |
558
02fb65cddc3e
Merge rest of patch from #72.
Christian Kamm <kamm incasoftware de>
parents:
443
diff
changeset
|
208 { |
577
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
209 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
|
210 |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
211 struct DataSeg |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
212 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
213 void* beg; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
214 void* end; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
215 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
216 |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
217 DataSeg* allSegs = null; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
218 size_t numSegs = 0; |
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 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
|
221 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
222 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
|
223 |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
224 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
|
225 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
226 allSegs = cast(DataSeg*) ptr; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
227 allSegs[numSegs].beg = beg; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
228 allSegs[numSegs].end = end; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
229 numSegs++; |
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 } |
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 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
|
234 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
235 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
|
236 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
237 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
|
238 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
239 while( ++pos < numSegs ) |
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 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
|
242 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
243 numSegs--; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
244 return; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
245 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
246 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
247 } |
558
02fb65cddc3e
Merge rest of patch from #72.
Christian Kamm <kamm incasoftware de>
parents:
443
diff
changeset
|
248 } |
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
|
249 |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
250 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
|
251 |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
252 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
|
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 * |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
258 */ |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
259 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
|
260 { |
577
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
261 scan( dataStart, dataEnd ); |
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 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
|
264 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
265 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
|
266 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
267 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
|
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 } |
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 void initStaticDataPtrs() |
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 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
|
275 |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
276 // 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
|
277 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
|
278 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
279 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
|
280 } |
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 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
|
283 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
284 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
|
285 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
286 |
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
|
287 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
|
288 { |
577
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
289 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
|
290 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
|
291 } |
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
|
292 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
|
293 { |
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 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
|
295 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
|
296 } |
900
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
297 else version(solaris) |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
298 { |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
299 dataStart = adjust_up( &Data_Start ); |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
300 dataEnd = adjust_down( &Data_End ); |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
301 } |
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
|
302 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
|
303 { |
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 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
|
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 |
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 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
|
308 { |
900
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
309 parseDataProcMaps(); |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
310 } |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
311 } |
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 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
|
314 { |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
315 version(solaris) |
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 typedef long offset_t; |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
318 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
|
319 extern(C) |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
320 { |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
321 struct prmap { |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
322 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
|
323 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
|
324 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
|
325 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
|
326 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
|
327 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
|
328 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
|
329 |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
330 private int[1] pr_filler; |
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 } |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
333 |
903
493d42562733
Further Solaris data segment detection fixes. Thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
900
diff
changeset
|
334 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
|
335 |
900
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
336 void parseDataProcMaps() |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
337 { |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
338 debug (ProcMaps) printf("initStaticDataPtrs()\n"); |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
339 // 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
|
340 prmap pr; |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
341 |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
342 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
|
343 scope (exit) close(fd); |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
344 |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
345 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
|
346 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
|
347 { |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
348 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
|
349 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
|
350 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
|
351 |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
352 // Exclude stack and dataStart..dataEnd |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
353 if ( ( !dataEnd || |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
354 !( dataStart >= start && dataEnd <= end ) ) && |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
355 !( &pr >= start && &pr < end ) ) |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
356 { |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
357 // 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
|
358 // is heap (%% check) |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
359 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
|
360 _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
|
361 } |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
362 } |
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 else |
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 const int S = (void*).sizeof; |
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 // TODO: This could use cleanup! |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
370 void parseDataProcMaps() |
177afbf5297b
Solaris compatibility and proc map parsing #183, thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
899
diff
changeset
|
371 { |
577
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
372 // 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
|
373 |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
374 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
|
375 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
|
376 char buf[2024]; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
377 char* p; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
378 char* e; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
379 char* s; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
380 void* start; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
381 void* end; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
382 |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
383 p = buf.ptr; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
384 if (fd != -1) |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
385 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
386 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
|
387 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
388 e = p + count; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
389 p = buf.ptr; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
390 while (true) |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
391 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
392 s = p; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
393 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
|
394 p++; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
395 if (p < e) |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
396 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
397 // 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
|
398 static if( S == 4 ) |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
399 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
400 enum Ofs |
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 Write_Prot = 19, |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
403 Start_Addr = 0, |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
404 End_Addr = 9, |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
405 Addr_Len = 8, |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
406 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
407 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
408 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
|
409 { |
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
|
410 //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
|
411 //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
|
412 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
|
413 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
|
414 { |
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 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
|
416 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
|
417 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
|
418 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
|
419 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
|
420 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
|
421 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
|
422 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
|
423 } |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
424 } |
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 else |
577
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
426 { |
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
|
427 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
|
428 { |
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
429 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
|
430 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
|
431 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
|
432 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
|
433 } |
577
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
434 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
435 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
436 else |
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 static assert( false ); |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
439 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
440 |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
441 // %% 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
|
442 // 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
|
443 // 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
|
444 // 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
|
445 |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
446 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
|
447 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
448 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
|
449 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
|
450 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
|
451 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
|
452 |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
453 // 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
|
454 // 2. Exclude stack |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
455 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
|
456 !( 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
|
457 !( &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
|
458 { |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
459 // 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
|
460 // is heap (%% check) |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
461 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
|
462 _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
|
463 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
464 } |
899
23d36edea021
Add wilsonk's static data segment finding code for x86-64 from #181. Thanks!
Christian Kamm <kamm incasoftware de>
parents:
894
diff
changeset
|
465 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
|
466 { |
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 //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
|
468 //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
|
469 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
|
470 { |
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 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
|
472 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
|
473 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
|
474 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
|
475 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
|
476 !( 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
|
477 !( &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
|
478 { |
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 _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
|
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 } |
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 |
577
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
484 p++; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
485 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
486 else |
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 count = p - s; |
794
661384d6a936
Fix warnings on x86-64. By fvbommel.
Christian Kamm <kamm incasoftware de>
parents:
664
diff
changeset
|
489 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
|
490 p = buf.ptr + count; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
491 break; |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
492 } |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
493 } |
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 close(fd); |
68be7408a0db
Merge Dynamic_Ranges and Data_Proc_Maps from GDC runtime.
Christian Kamm <kamm incasoftware de>
parents:
559
diff
changeset
|
496 } |
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
|
497 } |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
498 } |
903
493d42562733
Further Solaris data segment detection fixes. Thanks BlueZeniX!
Christian Kamm <kamm incasoftware de>
parents:
900
diff
changeset
|
499 } |