1 /* libunwind - a platform-independent unwind library
2 Copyright (C) 2003-2005 Hewlett-Packard Co
3 Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
4
5 This file is part of libunwind.
6
7 Permission is hereby granted, free of charge, to any person obtaining
8 a copy of this software and associated documentation files (the
9 "Software"), to deal in the Software without restriction, including
10 without limitation the rights to use, copy, modify, merge, publish,
11 distribute, sublicense, and/or sell copies of the Software, and to
12 permit persons to whom the Software is furnished to do so, subject to
13 the following conditions:
14
15 The above copyright notice and this permission notice shall be
16 included in all copies or substantial portions of the Software.
17
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
25
26 #include <limits.h>
27 #include <stdio.h>
28
29 #include "libunwind_i.h"
30 #include "map_info.h"
31 #include "os-linux.h"
32
33 /* ANDROID support update. */
34 HIDDEN struct map_info *
map_create_list(pid_t pid)35 map_create_list (pid_t pid)
36 {
37 struct map_iterator mi;
38 unsigned long start, end, offset, flags;
39 struct map_info *map_list = NULL;
40 struct map_info *cur_map;
41
42 if (maps_init (&mi, pid) < 0)
43 return NULL;
44
45 while (maps_next (&mi, &start, &end, &offset, &flags))
46 {
47 cur_map = map_alloc_info ();
48 if (cur_map == MAP_FAILED)
49 break;
50 cur_map->next = map_list;
51 cur_map->start = start;
52 cur_map->end = end;
53 cur_map->offset = offset;
54 cur_map->flags = flags;
55 cur_map->path = strdup (mi.path);
56 mutex_init (&cur_map->ei_lock);
57 cur_map->ei.size = 0;
58 cur_map->ei.image = NULL;
59
60 /* Indicate mapped memory of devices is special and should not
61 be read or written. Use a special flag instead of zeroing the
62 flags to indicate that the maps do not need to be rebuilt if
63 any values ever wind up in these special maps.
64 /dev/ashmem/... maps are special and don't have any restrictions,
65 so don't mark them as device memory. */
66 if (strncmp ("/dev/", cur_map->path, 5) == 0
67 && strncmp ("ashmem/", cur_map->path + 5, 7) != 0)
68 cur_map->flags |= MAP_FLAGS_DEVICE_MEM;
69
70 map_list = cur_map;
71 }
72
73 maps_close (&mi);
74
75 return map_list;
76 }
77 /* End of ANDROID update. */
78