1 /* libunwind - a platform-independent unwind library
2 Copyright (c) 2002-2004 Hewlett-Packard Development Company, L.P.
3 Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
5 This file is part of libunwind.
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:
15 The above copyright notice and this permission notice shall be
16 included in all copies or substantial portions of the Software.
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. */
30 x86_scratch_loc (struct cursor
*c
, unw_regnum_t reg
)
32 if (c
->sigcontext_addr
)
33 return x86_get_scratch_loc (c
, reg
);
35 return DWARF_REG_LOC (&c
->dwarf
, reg
);
39 tdep_access_reg (struct cursor
*c
, unw_regnum_t reg
, unw_word_t
*valp
,
42 dwarf_loc_t loc
= DWARF_NULL_LOC
;
51 c
->dwarf
.ip
= *valp
; /* also update the EIP cache */
52 loc
= c
->dwarf
.loc
[EIP
];
58 return -UNW_EREADONLYREG
;
64 arg_num
= reg
- UNW_X86_EAX
;
65 mask
= (1 << arg_num
);
68 c
->dwarf
.eh_args
[arg_num
] = *valp
;
69 c
->dwarf
.eh_valid_mask
|= mask
;
72 else if ((c
->dwarf
.eh_valid_mask
& mask
) != 0)
74 *valp
= c
->dwarf
.eh_args
[arg_num
];
78 loc
= c
->dwarf
.loc
[(reg
== UNW_X86_EAX
) ? EAX
: EDX
];
81 case UNW_X86_ECX
: loc
= c
->dwarf
.loc
[ECX
]; break;
82 case UNW_X86_EBX
: loc
= c
->dwarf
.loc
[EBX
]; break;
84 case UNW_X86_EBP
: loc
= c
->dwarf
.loc
[EBP
]; break;
85 case UNW_X86_ESI
: loc
= c
->dwarf
.loc
[ESI
]; break;
86 case UNW_X86_EDI
: loc
= c
->dwarf
.loc
[EDI
]; break;
87 case UNW_X86_EFLAGS
: loc
= c
->dwarf
.loc
[EFLAGS
]; break;
88 case UNW_X86_TRAPNO
: loc
= c
->dwarf
.loc
[TRAPNO
]; break;
107 loc
= x86_scratch_loc (c
, reg
);
111 Debug (1, "bad register number %u\n", reg
);
116 return dwarf_put (&c
->dwarf
, loc
, *valp
);
118 return dwarf_get (&c
->dwarf
, loc
, valp
);
122 tdep_access_fpreg (struct cursor
*c
, unw_regnum_t reg
, unw_fpreg_t
*valp
,
125 struct dwarf_loc loc
= DWARF_NULL_LOC
;
130 loc
= c
->dwarf
.loc
[ST0
];
133 /* stacked fp registers */
141 /* SSE fp registers */
150 case UNW_X86_XMM0_lo
:
151 case UNW_X86_XMM0_hi
:
152 case UNW_X86_XMM1_lo
:
153 case UNW_X86_XMM1_hi
:
154 case UNW_X86_XMM2_lo
:
155 case UNW_X86_XMM2_hi
:
156 case UNW_X86_XMM3_lo
:
157 case UNW_X86_XMM3_hi
:
158 case UNW_X86_XMM4_lo
:
159 case UNW_X86_XMM4_hi
:
160 case UNW_X86_XMM5_lo
:
161 case UNW_X86_XMM5_hi
:
162 case UNW_X86_XMM6_lo
:
163 case UNW_X86_XMM6_hi
:
164 case UNW_X86_XMM7_lo
:
165 case UNW_X86_XMM7_hi
:
166 loc
= x86_scratch_loc (c
, reg
);
170 Debug (1, "bad register number %u\n", reg
);
175 return dwarf_putfp (&c
->dwarf
, loc
, *valp
);
177 return dwarf_getfp (&c
->dwarf
, loc
, valp
);