1b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino/* libunwind - a platform-independent unwind library
2b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino   Copyright (C) 2006-2007 IBM
3b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino   Contributed by
4b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino     Corey Ashford <cjashfor@us.ibm.com>
5b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino     Jose Flavio Aguilar Paulino <jflavio@br.ibm.com> <joseflavio@gmail.com>
6b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino
7b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar PaulinoThis file is part of libunwind.
8b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino
9b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar PaulinoPermission is hereby granted, free of charge, to any person obtaining
10b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulinoa copy of this software and associated documentation files (the
11b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino"Software"), to deal in the Software without restriction, including
12b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulinowithout limitation the rights to use, copy, modify, merge, publish,
13b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulinodistribute, sublicense, and/or sell copies of the Software, and to
14b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulinopermit persons to whom the Software is furnished to do so, subject to
15b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulinothe following conditions:
16b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino
17b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar PaulinoThe above copyright notice and this permission notice shall be
18b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulinoincluded in all copies or substantial portions of the Software.
19b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino
20b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar PaulinoTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar PaulinoEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar PaulinoMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar PaulinoNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar PaulinoLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar PaulinoOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar PaulinoWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  */
27b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino
28b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino#include "unwind_i.h"
29b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino#include "ucontext_i.h"
30b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino#include <signal.h>
31b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino
32b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino/* This definition originates in /usr/include/asm-ppc64/ptrace.h, but is
33b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino   defined there only when __KERNEL__ is defined.  We reproduce it here for
34b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino   our use at the user level in order to locate the ucontext record, which
35b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino   appears to be at this offset relative to the stack pointer when in the
36b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino   context of the signal handler return trampoline code -
37b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino   __kernel_sigtramp_rt64.  */
38b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino#define __SIGNAL_FRAMESIZE 128
39b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino
40b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino/* This definition comes from the document "64-bit PowerPC ELF Application
41b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino   Binary Interface Supplement 1.9", section 3.2.2.
42b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino   http://www.linux-foundation.org/spec/ELF/ppc64/PPC-elf64abi-1.9.html#STACK */
43b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino
44b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulinotypedef struct
45b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino{
46b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino  long unsigned back_chain;
47b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino  long unsigned cr_save;
48b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino  long unsigned lr_save;
49b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino  /* many more fields here, but they are unused by this code */
50b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino} stack_frame_t;
51b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino
52b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino
53b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar PaulinoPROTECTED int
54b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulinounw_step (unw_cursor_t * cursor)
55b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino{
56b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino  struct cursor *c = (struct cursor *) cursor;
57b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino  stack_frame_t dummy;
58b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino  unw_word_t back_chain_offset, lr_save_offset, v_regs_ptr;
59b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino  struct dwarf_loc back_chain_loc, lr_save_loc, sp_loc, ip_loc, v_regs_loc;
60b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino  int ret;
61b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino
62b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino  Debug (1, "(cursor=%p, ip=0x%016lx)\n", c, (unsigned long) c->dwarf.ip);
63b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino
64b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino  if (c->dwarf.ip == 0)
65b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino    {
66b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino      /* Unless the cursor or stack is corrupt or uninitialized,
67b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino         we've most likely hit the top of the stack */
68b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino      return 0;
69b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino    }
70b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino
71b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino  /* Try DWARF-based unwinding... */
72b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino
73b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino  ret = dwarf_step (&c->dwarf);
74b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino
75b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino  if (ret < 0 && ret != -UNW_ENOINFO)
76b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino    {
77b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino      Debug (2, "returning %d\n", ret);
78b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino      return ret;
79b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino    }
80b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino
81b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino  if (unlikely (ret < 0))
82b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino    {
83b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino      if (likely (!unw_is_signal_frame (cursor)))
84b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	{
85b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  /* DWARF unwinding failed.  As of 09/26/2006, gcc in 64-bit mode
86b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	     produces the mandatory level of traceback record in the code, but
87b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	     I get the impression that this is transitory, that eventually gcc
88b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	     will not produce any traceback records at all.  So, for now, we
89b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	     won't bother to try to find and use these records.
90b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino
91b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	     We can, however, attempt to unwind the frame by using the callback
92b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	     chain.  This is very crude, however, and won't be able to unwind
93b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	     any registers besides the IP, SP, and LR . */
94b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino
95b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  back_chain_offset = ((void *) &dummy.back_chain - (void *) &dummy);
96b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  lr_save_offset = ((void *) &dummy.lr_save - (void *) &dummy);
97b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino
98b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  back_chain_loc = DWARF_LOC (c->dwarf.cfa + back_chain_offset, 0);
99b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino
100b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  if ((ret =
101b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	       dwarf_get (&c->dwarf, back_chain_loc, &c->dwarf.cfa)) < 0)
102b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    {
1038f94f1e6c01648ff41dec9b44bd7a8b6a230671eTommi Rantala	      Debug (2,
1048f94f1e6c01648ff41dec9b44bd7a8b6a230671eTommi Rantala		 "Unable to retrieve CFA from back chain in stack frame - %d\n",
105b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino		 ret);
106b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      return ret;
107b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    }
108b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  if (c->dwarf.cfa == 0)
109b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    /* Unless the cursor or stack is corrupt or uninitialized we've most
110b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	       likely hit the top of the stack */
111b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    return 0;
112b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino
113b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  lr_save_loc = DWARF_LOC (c->dwarf.cfa + lr_save_offset, 0);
114b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino
115b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  if ((ret = dwarf_get (&c->dwarf, lr_save_loc, &c->dwarf.ip)) < 0)
116b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    {
1178f94f1e6c01648ff41dec9b44bd7a8b6a230671eTommi Rantala	      Debug (2,
1188f94f1e6c01648ff41dec9b44bd7a8b6a230671eTommi Rantala		 "Unable to retrieve IP from lr save in stack frame - %d\n",
119b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino		 ret);
120b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      return ret;
121b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    }
122b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  ret = 1;
123b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	}
124b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino      else
125b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	{
126b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino          /* Find the sigcontext record by taking the CFA and adjusting by
127b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino             the dummy signal frame size.
128b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino
129b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino             Note that there isn't any way to determined if SA_SIGINFO was
130b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino             set in the sa_flags parameter to sigaction when the signal
131b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino             handler was established.  If it was not set, the ucontext
132b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino             record is not required to be on the stack, in which case the
133b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino             following code will likely cause a seg fault or other crash
134b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino             condition.  */
135b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino
136b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  unw_word_t ucontext = c->dwarf.cfa + __SIGNAL_FRAMESIZE;
137b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino
138b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  Debug (1, "signal frame, skip over trampoline\n");
139b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino
1404499bb29a6214b5df5b3b21e03c6b4f3c8f26cfdJose Flavio Aguilar Paulino	  c->sigcontext_format = PPC_SCF_LINUX_RT_SIGFRAME;
141b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->sigcontext_addr = ucontext;
142b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino
143b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  sp_loc = DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R1, 0);
144b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  ip_loc = DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_NIP, 0);
145b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino
146b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  ret = dwarf_get (&c->dwarf, sp_loc, &c->dwarf.cfa);
147b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  if (ret < 0)
148b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    {
149b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      Debug (2, "returning %d\n", ret);
150b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      return ret;
151b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    }
152b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  ret = dwarf_get (&c->dwarf, ip_loc, &c->dwarf.ip);
153b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  if (ret < 0)
154b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    {
155b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      Debug (2, "returning %d\n", ret);
156b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      return ret;
157b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    }
158b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino
159b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  /* Instead of just restoring the non-volatile registers, do all
160b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	     of the registers for now.  This will incur a performance hit,
161b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	     but it's rare enough not to cause too much of a problem, and
162b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	     might be useful in some cases.  */
163b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_R0] =
164b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R0, 0);
165b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_R1] =
166b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R1, 0);
167b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_R2] =
168b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R2, 0);
169b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_R3] =
170b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R3, 0);
171b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_R4] =
172b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R4, 0);
173b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_R5] =
174b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R5, 0);
175b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_R6] =
176b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R6, 0);
177b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_R7] =
178b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R7, 0);
179b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_R8] =
180b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R8, 0);
181b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_R9] =
182b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R9, 0);
183b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_R10] =
184b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R10, 0);
185b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_R11] =
186b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R11, 0);
187b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_R12] =
188b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R12, 0);
189b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_R13] =
190b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R13, 0);
191b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_R14] =
192b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R14, 0);
193b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_R15] =
194b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R15, 0);
195b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_R16] =
196b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R16, 0);
197b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_R17] =
198b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R17, 0);
199b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_R18] =
200b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R18, 0);
201b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_R19] =
202b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R19, 0);
203b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_R20] =
204b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R20, 0);
205b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_R21] =
206b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R21, 0);
207b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_R22] =
208b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R22, 0);
209b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_R23] =
210b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R23, 0);
211b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_R24] =
212b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R24, 0);
213b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_R25] =
214b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R25, 0);
215b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_R26] =
216b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R26, 0);
217b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_R27] =
218b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R27, 0);
219b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_R28] =
220b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R28, 0);
221b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_R29] =
222b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R29, 0);
223b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_R30] =
224b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R30, 0);
225b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_R31] =
226b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R31, 0);
227b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino
228b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_LR] =
229b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_LINK, 0);
230b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_CTR] =
231b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_CTR, 0);
232b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  /* This CR0 assignment is probably wrong.  There are 8 dwarf columns
233b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	     assigned to the CR registers, but only one CR register in the
234b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	     mcontext structure */
235b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_CR0] =
236b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_CCR, 0);
237b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_XER] =
238b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_XER, 0);
239b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_NIP] =
240b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_NIP, 0);
241b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino
242b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  /* TODO: Is there a way of obtaining the value of the
243b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	     pseudo frame pointer (which is sp + some fixed offset, I
244b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	     assume), based on the contents of the ucontext record
245b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	     structure?  For now, set this loc to null. */
246b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_FRAME_POINTER] = DWARF_NULL_LOC;
247b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino
248b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_F0] =
249b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R0, 0);
250b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_F1] =
251b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R1, 0);
252b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_F2] =
253b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R2, 0);
254b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_F3] =
255b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R3, 0);
256b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_F4] =
257b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R4, 0);
258b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_F5] =
259b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R5, 0);
260b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_F6] =
261b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R6, 0);
262b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_F7] =
263b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R7, 0);
264b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_F8] =
265b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R8, 0);
266b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_F9] =
267b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R9, 0);
268b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_F10] =
269b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R10, 0);
270b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_F11] =
271b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R11, 0);
272b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_F12] =
273b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R12, 0);
274b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_F13] =
275b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R13, 0);
276b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_F14] =
277b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R14, 0);
278b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_F15] =
279b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R15, 0);
280b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_F16] =
281b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R16, 0);
282b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_F17] =
283b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R17, 0);
284b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_F18] =
285b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R18, 0);
286b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_F19] =
287b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R19, 0);
288b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_F20] =
289b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R20, 0);
290b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_F21] =
291b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R21, 0);
292b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_F22] =
293b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R22, 0);
294b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_F23] =
295b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R23, 0);
296b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_F24] =
297b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R24, 0);
298b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_F25] =
299b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R25, 0);
300b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_F26] =
301b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R26, 0);
302b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_F27] =
303b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R27, 0);
304b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_F28] =
305b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R28, 0);
306b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_F29] =
307b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R29, 0);
308b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_F30] =
309b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R30, 0);
310b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  c->dwarf.loc[UNW_PPC64_F31] =
311b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R31, 0);
312b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  /* Note that there is no .eh_section register column for the
313b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	     FPSCR register.  I don't know why this is.  */
314b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino
315b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  v_regs_loc = DWARF_LOC (ucontext + UC_MCONTEXT_V_REGS, 0);
316b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  ret = dwarf_get (&c->dwarf, v_regs_loc, &v_regs_ptr);
317b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  if (ret < 0)
318b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    {
319b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      Debug (2, "returning %d\n", ret);
320b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      return ret;
321b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    }
322b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  if (v_regs_ptr != 0)
323b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    {
324b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      /* The v_regs_ptr is not null.  Set all of the AltiVec locs */
325b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino
326b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V0] =
327b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino		DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R0, 0);
328b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V1] =
329b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino		DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R1, 0);
330b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V2] =
331b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino		DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R2, 0);
332b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V3] =
333b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino		DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R3, 0);
334b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V4] =
335b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino		DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R4, 0);
336b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V5] =
337b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino		DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R5, 0);
338b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V6] =
339b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino		DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R6, 0);
340b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V7] =
341b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino		DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R7, 0);
342b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V8] =
343b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino		DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R8, 0);
344b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V9] =
345b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino		DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R9, 0);
346b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V10] =
347b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino		DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R10, 0);
348b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V11] =
349b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino		DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R11, 0);
350b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V12] =
351b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino		DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R12, 0);
352b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V13] =
353b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino		DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R13, 0);
354b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V14] =
355b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino		DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R14, 0);
356b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V15] =
357b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino		DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R15, 0);
358b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V16] =
359b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino		DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R16, 0);
360b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V17] =
361b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino		DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R17, 0);
362b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V18] =
363b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino		DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R18, 0);
364b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V19] =
365b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino		DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R19, 0);
366b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V20] =
367b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino		DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R20, 0);
368b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V21] =
369b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino		DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R21, 0);
370b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V22] =
371b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino		DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R22, 0);
372b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V23] =
373b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino		DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R23, 0);
374b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V24] =
375b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino		DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R24, 0);
376b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V25] =
377b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino		DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R25, 0);
378b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V26] =
379b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino		DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R26, 0);
380b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V27] =
381b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino		DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R27, 0);
382b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V28] =
383b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino		DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R28, 0);
384b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V29] =
385b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino		DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R29, 0);
386b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V30] =
387b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino		DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R30, 0);
388b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V31] =
389b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino		DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R31, 0);
390b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_VRSAVE] =
391b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino		DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_VRSAVE, 0);
392b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_VSCR] =
393b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino		DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_VSCR, 0);
394b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    }
395b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  else
396b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    {
397b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V0] = DWARF_NULL_LOC;
398b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V1] = DWARF_NULL_LOC;
399b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V2] = DWARF_NULL_LOC;
400b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V3] = DWARF_NULL_LOC;
401b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V4] = DWARF_NULL_LOC;
402b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V5] = DWARF_NULL_LOC;
403b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V6] = DWARF_NULL_LOC;
404b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V7] = DWARF_NULL_LOC;
405b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V8] = DWARF_NULL_LOC;
406b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V9] = DWARF_NULL_LOC;
407b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V10] = DWARF_NULL_LOC;
408b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V11] = DWARF_NULL_LOC;
409b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V12] = DWARF_NULL_LOC;
410b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V13] = DWARF_NULL_LOC;
411b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V14] = DWARF_NULL_LOC;
412b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V15] = DWARF_NULL_LOC;
413b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V16] = DWARF_NULL_LOC;
414b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V17] = DWARF_NULL_LOC;
415b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V18] = DWARF_NULL_LOC;
416b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V19] = DWARF_NULL_LOC;
417b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V20] = DWARF_NULL_LOC;
418b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V21] = DWARF_NULL_LOC;
419b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V22] = DWARF_NULL_LOC;
420b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V23] = DWARF_NULL_LOC;
421b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V24] = DWARF_NULL_LOC;
422b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V25] = DWARF_NULL_LOC;
423b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V26] = DWARF_NULL_LOC;
424b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V27] = DWARF_NULL_LOC;
425b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V28] = DWARF_NULL_LOC;
426b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V29] = DWARF_NULL_LOC;
427b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V30] = DWARF_NULL_LOC;
428b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_V31] = DWARF_NULL_LOC;
429b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_VRSAVE] = DWARF_NULL_LOC;
430b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	      c->dwarf.loc[UNW_PPC64_VSCR] = DWARF_NULL_LOC;
431b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	    }
432b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	  ret = 1;
433b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino	}
434b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino    }
435b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino  return ret;
436b33021e4b2f3a92141c01eb24b98bc51a97c498dJose Flavio Aguilar Paulino}
437