1 /* Determine the virtual memory area of a given address. Linux version.
2 Copyright (C) 2002, 2006, 2008 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. */
21 #include "stackvma-simple.c"
22 #include "stackvma-rofile.c"
25 # define sigsegv_get_vma mincore_get_vma
26 # define STATIC static
27 # include "stackvma-mincore.c"
28 # undef sigsegv_get_vma
32 sigsegv_get_vma (unsigned long address
, struct vma_struct
*vma
)
36 unsigned long start
, end
;
37 #if STACK_DIRECTION < 0
41 /* Open the current process' maps file. It describes one VMA per line. */
42 if (rof_open (&rof
, "/proc/self/maps") < 0)
45 #if STACK_DIRECTION < 0
50 if (!(rof_scanf_lx (&rof
, &start
) >= 0
51 && rof_getchar (&rof
) == '-'
52 && rof_scanf_lx (&rof
, &end
) >= 0))
54 while (c
= rof_getchar (&rof
), c
!= -1 && c
!= '\n')
56 if (address
>= start
&& address
<= end
- 1)
60 #if STACK_DIRECTION < 0
63 if (!(rof_scanf_lx (&rof
, &vma
->next_start
) >= 0
64 && rof_getchar (&rof
) == '-'
65 && rof_scanf_lx (&rof
, &end
) >= 0))
69 vma
->is_near_this
= simple_is_near_this
;
72 #if STACK_DIRECTION < 0
79 return mincore_get_vma (address
, vma
);