1 /* Determine the virtual memory area of a given address. Win32 version.
2 Copyright (C) 2002 Bruno Haible <bruno@clisp.org>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software Foundation,
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
22 static void DumpProcessMemoryMap()
24 MEMORY_BASIC_INFORMATION info
;
25 unsigned long address
= 0;
26 printf("Memory dump:\n");
27 while (VirtualQuery((void*)address
,&info
,sizeof(info
)) == sizeof(info
))
29 /* Always info.BaseAddress = address. */
32 case MEM_FREE
: printf("-"); break;
33 case MEM_RESERVE
: printf("+"); break;
34 case MEM_COMMIT
: printf("*"); break;
35 default: printf("?"); break;
37 printf(" 0x%lx - 0x%lx",
38 (unsigned long)info
.BaseAddress
,
39 (unsigned long)info
.BaseAddress
+info
.RegionSize
-1);
40 if (info
.State
!= MEM_FREE
)
42 printf(" (0x%lx) ",(unsigned long)info
.AllocationBase
);
43 /* info.AllocationProtect is apparently irrelevant. */
44 switch (info
.Protect
& ~(PAGE_GUARD
|PAGE_NOCACHE
))
46 case PAGE_READONLY
: printf(" R "); break;
47 case PAGE_READWRITE
: printf(" RW "); break;
48 case PAGE_WRITECOPY
: printf(" RWC"); break;
49 case PAGE_EXECUTE
: printf("X "); break;
50 case PAGE_EXECUTE_READ
: printf("XR "); break;
51 case PAGE_EXECUTE_READWRITE
: printf("XRW "); break;
52 case PAGE_EXECUTE_WRITECOPY
: printf("XRWC"); break;
53 case PAGE_NOACCESS
: printf("----"); break;
54 default: printf("?"); break;
56 if (info
.Protect
& PAGE_GUARD
)
57 printf(" PAGE_GUARD");
58 if (info
.Protect
& PAGE_NOCACHE
)
59 printf(" PAGE_NOCACHE");
63 case MEM_IMAGE
: printf("MEM_IMAGE"); break;
64 case MEM_MAPPED
: printf("MEM_MAPPED"); break;
65 case MEM_PRIVATE
: printf("MEM_PRIVATE"); break;
66 default: printf("MEM_?"); break;
70 address
= (unsigned long)info
.BaseAddress
+ info
.RegionSize
;
72 printf("End of memory dump.\n");
76 sigsegv_get_vma (unsigned long address
, struct vma_struct
*vma
)
78 DumpProcessMemoryMap();