1224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng/* libunwind - a platform-independent unwind library
2224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng   Copyright (C) 2006-2007 IBM
3224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng   Contributed by
4224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng     Corey Ashford cjashfor@us.ibm.com
5224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng     Jose Flavio Aguilar Paulino <jflavio@br.ibm.com> <joseflavio@gmail.com>
6224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng
7224b54f69543a5c0ec18f99bd717d2b724582eb6Ben ChengThis file is part of libunwind.
8224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng
9224b54f69543a5c0ec18f99bd717d2b724582eb6Ben ChengPermission is hereby granted, free of charge, to any person obtaining
10224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Chenga copy of this software and associated documentation files (the
11224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng"Software"), to deal in the Software without restriction, including
12224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Chengwithout limitation the rights to use, copy, modify, merge, publish,
13224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Chengdistribute, sublicense, and/or sell copies of the Software, and to
14224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Chengpermit persons to whom the Software is furnished to do so, subject to
15224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Chengthe following conditions:
16224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng
17224b54f69543a5c0ec18f99bd717d2b724582eb6Ben ChengThe above copyright notice and this permission notice shall be
18224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Chengincluded in all copies or substantial portions of the Software.
19224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng
20224b54f69543a5c0ec18f99bd717d2b724582eb6Ben ChengTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21224b54f69543a5c0ec18f99bd717d2b724582eb6Ben ChengEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22224b54f69543a5c0ec18f99bd717d2b724582eb6Ben ChengMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23224b54f69543a5c0ec18f99bd717d2b724582eb6Ben ChengNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24224b54f69543a5c0ec18f99bd717d2b724582eb6Ben ChengLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25e084501669a4e4931c9d648351ecd7d595b81b79Christopher FerrisOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26e084501669a4e4931c9d648351ecd7d595b81b79Christopher FerrisWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  */
27224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng
28224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#include <stdlib.h>
29224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng
30e084501669a4e4931c9d648351ecd7d595b81b79Christopher Ferris#include "unwind_i.h"
31224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng
32224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#ifndef UNW_REMOTE_ONLY
33224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng
34224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#include <sys/syscall.h>
35224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng
36224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng/* sigreturn() is a no-op on x86_64 glibc.  */
37224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng
38224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Chengstatic NORETURN inline long
39224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Chengmy_rt_sigreturn (void *new_sp)
40224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng{
41224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng  /* XXX: empty stub.  */
42224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng  abort ();
43224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng}
44224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng
45224b54f69543a5c0ec18f99bd717d2b724582eb6Ben ChengHIDDEN inline int
46224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Chengppc64_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, void *arg)
47224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng{
48224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng  /* XXX: empty stub.  */
49224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng  return -UNW_EINVAL;
50224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng}
51224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng
52224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#endif /* !UNW_REMOTE_ONLY */
53224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng
54224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng/* This routine is responsible for copying the register values in
55224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng   cursor C and establishing them as the current machine state. */
56224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng
57224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Chengstatic inline int
58224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Chengestablish_machine_state (struct cursor *c)
59224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng{
60224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng  /* XXX: empty stub.  */
61224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng  return 0;
62224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng}
63224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng
64224b54f69543a5c0ec18f99bd717d2b724582eb6Ben ChengPROTECTED int
65224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Chengunw_resume (unw_cursor_t *cursor)
66224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng{
67224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng  struct cursor *c = (struct cursor *) cursor;
68224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng  int ret;
69224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng
70224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng  Debug (1, "(cursor=%p)\n", c);
71224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng
72224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng  if ((ret = establish_machine_state (c)) < 0)
73224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng    return ret;
74224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng
75224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng  return (*c->dwarf.as->acc.resume) (c->dwarf.as, (unw_cursor_t *) c,
76224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng				     c->dwarf.as_arg);
77224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng}
78224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng