• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* libunwind - a platform-independent unwind library
2    Copyright (C) 2014 The Android Open Source Project
3 
4 This file is part of libunwind.
5 
6 Permission is hereby granted, free of charge, to any person obtaining
7 a copy of this software and associated documentation files (the
8 "Software"), to deal in the Software without restriction, including
9 without limitation the rights to use, copy, modify, merge, publish,
10 distribute, sublicense, and/or sell copies of the Software, and to
11 permit persons to whom the Software is furnished to do so, subject to
12 the following conditions:
13 
14 The above copyright notice and this permission notice shall be
15 included in all copies or substantial portions of the Software.
16 
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  */
24 
25 #include "libunwind_i.h"
26 
27 void
unw_map_set(unw_addr_space_t as,unw_map_cursor_t * map_cursor)28 unw_map_set (unw_addr_space_t as, unw_map_cursor_t *map_cursor)
29 {
30   if (map_cursor != NULL)
31     as->map_list = map_cursor->map_list;
32   else
33     as->map_list = NULL;
34 }
35 
36 int
unw_map_cursor_create(unw_map_cursor_t * map_cursor,pid_t pid)37 unw_map_cursor_create (unw_map_cursor_t *map_cursor, pid_t pid)
38 {
39   map_cursor->map_list = maps_create_list (pid);
40 
41   return map_cursor->map_list == NULL;
42 }
43 
44 void
unw_map_cursor_destroy(unw_map_cursor_t * map_cursor)45 unw_map_cursor_destroy (unw_map_cursor_t *map_cursor)
46 {
47   maps_destroy_list (map_cursor->map_list);
48 }
49 
50 void
unw_map_cursor_reset(unw_map_cursor_t * map_cursor)51 unw_map_cursor_reset (unw_map_cursor_t *map_cursor)
52 {
53   map_cursor->cur_map = map_cursor->map_list;
54 }
55 
56 int
unw_map_cursor_get(unw_map_cursor_t * map_cursor,unw_map_t * unw_map)57 unw_map_cursor_get (unw_map_cursor_t *map_cursor, unw_map_t *unw_map)
58 {
59   struct map_info *map_info = map_cursor->cur_map;
60 
61   if (map_info == NULL)
62     return 0;
63 
64   unw_map->start = map_info->start;
65   unw_map->end = map_info->end;
66   unw_map->flags = map_info->flags;
67   unw_map->path = map_info->path;
68 
69   map_cursor->cur_map = map_info->next;
70 
71   return 1;
72 }
73