• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* libunwind - a platform-independent unwind library
2    Copyright (C) 2012 Tommi Rantala <tt.rantala@gmail.com>
3    Copyright (C) 2013 Linaro Limited
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 "unwind_i.h"
27 
28 /* The restorer stub will always have the form:
29 
30    d2801168        movz    x8, #0x8b
31    d4000001        svc     #0x0
32 */
33 
34 int
unw_is_signal_frame(unw_cursor_t * cursor)35 unw_is_signal_frame (unw_cursor_t *cursor)
36 {
37 #ifdef __linux__
38   struct cursor *c = (struct cursor *) cursor;
39   unw_word_t w0, ip;
40   unw_addr_space_t as;
41   unw_accessors_t *a;
42   void *arg;
43   int ret;
44 
45   as = c->dwarf.as;
46   a = unw_get_accessors_int (as);
47   arg = c->dwarf.as_arg;
48 
49   ip = c->dwarf.ip;
50 
51   ret = (*a->access_mem) (as, ip, &w0, 0, arg);
52   if (ret < 0)
53     return ret;
54 
55   /* FIXME: distinguish 32bit insn vs 64bit registers.  */
56   if (w0 != 0xd4000001d2801168)
57     return 0;
58 
59   return 1;
60 
61 #else
62   return -UNW_ENOINFO;
63 #endif
64 }
65