1 /* Stack unwinding code based on dwarf2 frame info for GDB, the GNU debugger.
3 Copyright 2001, 2002, 2003 Free Software Foundation, Inc.
5 Contributed by Jiri Smid, SuSE Labs.
6 Based on code written by Daniel Berlin (dan@dberlin.org).
8 This file is part of GDB.
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330,
23 Boston, MA 02111-1307, USA. */
31 #include "elf/dwarf2.h"
34 #include "dwarf2cfi.h"
35 #include "gdb_assert.h"
37 /* Common Information Entry - holds information that is shared among many
41 /* Offset of this unit in .debug_frame or .eh_frame. */
44 /* A null-terminated string that identifies the augmentation to this CIE or
45 to the FDEs that use it. */
48 /* A constant that is factored out of all advance location instructions. */
49 unsigned int code_align
;
51 /* A constant that is factored out of all offset instructions. */
54 /* A constant that indicates which regiter represents the return address
58 /* Indicates how addresses are encoded. */
59 unsigned char addr_encoding
;
61 /* Pointer and length of the cie program. */
63 unsigned int data_length
;
65 struct objfile
*objfile
;
68 struct cie_unit
*next
;
71 /* Frame Description Entry. */
74 /* Address of the first location associated with this entry. */
75 CORE_ADDR initial_location
;
77 /* Length of program section described by this entry. */
78 CORE_ADDR address_range
;
80 /* Pointer to asociated CIE. */
81 struct cie_unit
*cie_ptr
;
83 /* Pointer and length of the cie program. */
85 unsigned int data_length
;
90 struct fde_unit
**array
;
95 struct frame_state_reg
116 /* Each register save state can be described in terms of a CFA slot,
117 another register, or a location expression. */
118 struct frame_state_regs
120 struct frame_state_reg
*reg
;
122 /* Used to implement DW_CFA_remember_state. */
123 struct frame_state_regs
*prev
;
127 /* The CFA can be described in terms of a reg+offset or a
128 location expression. */
131 unsigned char *cfa_exp
;
140 /* The PC described by the current frame state. */
143 /* The information we care about from the CIE/FDE. */
145 unsigned int code_align
;
146 unsigned char retaddr_column
;
147 unsigned char addr_encoding
;
149 struct objfile
*objfile
;
154 PE_absptr
= DW_EH_PE_absptr
,
155 PE_pcrel
= DW_EH_PE_pcrel
,
156 PE_textrel
= DW_EH_PE_textrel
,
157 PE_datarel
= DW_EH_PE_datarel
,
158 PE_funcrel
= DW_EH_PE_funcrel
161 #define UNWIND_CONTEXT(fi) ((struct context *) (deprecated_get_frame_context (fi)))
164 static struct cie_unit
*cie_chunks
;
165 static struct fde_array fde_chunks
;
166 /* Obstack for allocating temporary storage used during unwind operations. */
167 static struct obstack unwind_tmp_obstack
;
169 extern file_ptr dwarf_frame_offset
;
170 extern unsigned int dwarf_frame_size
;
171 extern file_ptr dwarf_eh_frame_offset
;
172 extern unsigned int dwarf_eh_frame_size
;
173 extern asection
*dwarf_frame_section
;
174 extern asection
*dwarf_eh_frame_section
;
178 extern char *dwarf2_read_section (struct objfile
*objfile
, file_ptr offset
,
179 unsigned int size
, asection
* sectp
);
181 static struct fde_unit
*fde_unit_alloc (void);
182 static struct cie_unit
*cie_unit_alloc (void);
183 static void fde_chunks_need_space ();
185 static void unwind_tmp_obstack_init ();
186 static void unwind_tmp_obstack_free ();
188 static unsigned int read_1u (bfd
*abfd
, char **p
);
189 static int read_1s (bfd
*abfd
, char **p
);
190 static unsigned int read_2u (bfd
*abfd
, char **p
);
191 static int read_2s (bfd
*abfd
, char **p
);
192 static unsigned int read_4u (bfd
*abfd
, char **p
);
193 static int read_4s (bfd
*abfd
, char **p
);
194 static ULONGEST
read_8u (bfd
*abfd
, char **p
);
195 static LONGEST
read_8s (bfd
*abfd
, char **p
);
197 static ULONGEST
read_uleb128 (bfd
*abfd
, char **p
);
198 static LONGEST
read_sleb128 (bfd
*abfd
, char **p
);
199 static CORE_ADDR
read_pointer (bfd
*abfd
, char **p
);
200 static CORE_ADDR
read_encoded_pointer (bfd
*abfd
, char **p
,
201 unsigned char encoding
);
202 static enum ptr_encoding
pointer_encoding (unsigned char encoding
, struct objfile
*objfile
);
204 static LONGEST
read_initial_length (bfd
*abfd
, char *buf
, int *bytes_read
);
205 static ULONGEST
read_length (bfd
*abfd
, char *buf
, int *bytes_read
,
208 static int is_cie (ULONGEST cie_id
, int dwarf64
);
209 static int compare_fde_unit (const void *a
, const void *b
);
210 void dwarf2_build_frame_info (struct objfile
*objfile
);
212 static void execute_cfa_program (struct objfile
*objfile
, char *insn_ptr
,
213 char *insn_end
, struct context
*context
,
214 struct frame_state
*fs
);
215 static struct fde_unit
*get_fde_for_addr (CORE_ADDR pc
);
216 static void frame_state_for (struct context
*context
, struct frame_state
*fs
);
217 static void get_reg (char *reg
, struct context
*context
, int regnum
);
218 static CORE_ADDR
execute_stack_op (struct objfile
*objfile
,
219 char *op_ptr
, char *op_end
,
220 struct context
*context
,
222 static void update_context (struct context
*context
, struct frame_state
*fs
,
226 /* Memory allocation functions. */
227 static struct fde_unit
*
228 fde_unit_alloc (void)
230 struct fde_unit
*fde
;
232 fde
= (struct fde_unit
*) xmalloc (sizeof (struct fde_unit
));
233 memset (fde
, 0, sizeof (struct fde_unit
));
237 static struct cie_unit
*
238 cie_unit_alloc (void)
240 struct cie_unit
*cie
;
242 cie
= (struct cie_unit
*) xmalloc (sizeof (struct cie_unit
));
243 memset (cie
, 0, sizeof (struct cie_unit
));
248 fde_chunks_need_space (void)
250 if (fde_chunks
.elems
< fde_chunks
.array_size
)
252 fde_chunks
.array_size
=
253 fde_chunks
.array_size
? 2 * fde_chunks
.array_size
: 1024;
255 xrealloc (fde_chunks
.array
,
256 sizeof (struct fde_unit
) * fde_chunks
.array_size
);
259 /* Alocate a new `struct context' on temporary obstack. */
263 struct context
*context
;
265 int regs_size
= sizeof (struct context_reg
) * NUM_REGS
;
267 context
= (struct context
*) obstack_alloc (&unwind_tmp_obstack
,
268 sizeof (struct context
));
269 memset (context
, 0, sizeof (struct context
));
270 context
->reg
= (struct context_reg
*) obstack_alloc (&unwind_tmp_obstack
,
272 memset (context
->reg
, 0, regs_size
);
276 /* Alocate a new `struct frame_state' on temporary obstack. */
278 frame_state_alloc (void)
280 struct frame_state
*fs
;
282 int regs_size
= sizeof (struct frame_state_reg
) * NUM_REGS
;
284 fs
= (struct frame_state
*) obstack_alloc (&unwind_tmp_obstack
,
285 sizeof (struct frame_state
));
286 memset (fs
, 0, sizeof (struct frame_state
));
288 (struct frame_state_reg
*) obstack_alloc (&unwind_tmp_obstack
, regs_size
);
289 memset (fs
->regs
.reg
, 0, regs_size
);
294 unwind_tmp_obstack_init (void)
296 obstack_init (&unwind_tmp_obstack
);
300 unwind_tmp_obstack_free (void)
302 obstack_free (&unwind_tmp_obstack
, NULL
);
303 unwind_tmp_obstack_init ();
307 context_cpy (struct context
*dst
, struct context
*src
)
309 int regs_size
= sizeof (struct context_reg
) * NUM_REGS
;
310 struct context_reg
*dreg
;
312 /* Since `struct context' contains a pointer to an array with
313 register values, make sure we end up with a copy of that array,
314 and not with a copy of the pointer to that array. */
318 memcpy (dst
->reg
, src
->reg
, regs_size
);
322 read_1u (bfd
*abfd
, char **p
)
326 ret
= bfd_get_8 (abfd
, (bfd_byte
*) * p
);
332 read_1s (bfd
*abfd
, char **p
)
336 ret
= bfd_get_signed_8 (abfd
, (bfd_byte
*) * p
);
342 read_2u (bfd
*abfd
, char **p
)
346 ret
= bfd_get_16 (abfd
, (bfd_byte
*) * p
);
352 read_2s (bfd
*abfd
, char **p
)
356 ret
= bfd_get_signed_16 (abfd
, (bfd_byte
*) * p
);
362 read_4u (bfd
*abfd
, char **p
)
366 ret
= bfd_get_32 (abfd
, (bfd_byte
*) * p
);
372 read_4s (bfd
*abfd
, char **p
)
376 ret
= bfd_get_signed_32 (abfd
, (bfd_byte
*) * p
);
382 read_8u (bfd
*abfd
, char **p
)
386 ret
= bfd_get_64 (abfd
, (bfd_byte
*) * p
);
392 read_8s (bfd
*abfd
, char **p
)
396 ret
= bfd_get_signed_64 (abfd
, (bfd_byte
*) * p
);
402 read_uleb128 (bfd
*abfd
, char **p
)
413 byte
= bfd_get_8 (abfd
, (bfd_byte
*) * p
);
415 ret
|= ((unsigned long) (byte
& 127) << shift
);
416 if ((byte
& 128) == 0)
426 read_sleb128 (bfd
*abfd
, char **p
)
429 int i
, shift
, size
, num_read
;
439 byte
= bfd_get_8 (abfd
, (bfd_byte
*) * p
);
441 ret
|= ((long) (byte
& 127) << shift
);
443 if ((byte
& 128) == 0)
448 if ((shift
< size
) && (byte
& 0x40))
450 ret
|= -(1 << shift
);
456 read_pointer (bfd
*abfd
, char **p
)
458 switch (TARGET_ADDR_BIT
/ TARGET_CHAR_BIT
)
461 return read_4u (abfd
, p
);
463 return read_8u (abfd
, p
);
465 error ("dwarf cfi error: unsupported target address length [in module %s]",
466 bfd_get_filename (abfd
));
470 /* Read the appropriate amount of data from *P and return the
471 resulting value based on ENCODING, which the calling function must
474 read_encoded_pointer (bfd
*abfd
, char **p
, unsigned char encoding
)
478 switch (encoding
& 0x0f)
480 case DW_EH_PE_absptr
:
481 ret
= read_pointer (abfd
, p
);
484 case DW_EH_PE_uleb128
:
485 ret
= read_uleb128 (abfd
, p
);
487 case DW_EH_PE_sleb128
:
488 ret
= read_sleb128 (abfd
, p
);
491 case DW_EH_PE_udata2
:
492 ret
= read_2u (abfd
, p
);
494 case DW_EH_PE_udata4
:
495 ret
= read_4u (abfd
, p
);
497 case DW_EH_PE_udata8
:
498 ret
= read_8u (abfd
, p
);
501 case DW_EH_PE_sdata2
:
502 ret
= read_2s (abfd
, p
);
504 case DW_EH_PE_sdata4
:
505 ret
= read_4s (abfd
, p
);
507 case DW_EH_PE_sdata8
:
508 ret
= read_8s (abfd
, p
);
512 internal_error (__FILE__
, __LINE__
,
513 "read_encoded_pointer: unknown pointer encoding [in module %s]",
514 bfd_get_filename (abfd
));
520 /* The variable 'encoding' carries three different flags:
521 - encoding & 0x0f : size of the address (handled in read_encoded_pointer())
522 - encoding & 0x70 : type (absolute, relative, ...)
523 - encoding & 0x80 : indirect flag (DW_EH_PE_indirect == 0x80). */
525 pointer_encoding (unsigned char encoding
, struct objfile
*objfile
)
529 if (encoding
& DW_EH_PE_indirect
)
530 warning ("CFI: Unsupported pointer encoding: DW_EH_PE_indirect [in module %s]",
533 switch (encoding
& 0x70)
535 case DW_EH_PE_absptr
:
537 case DW_EH_PE_textrel
:
538 case DW_EH_PE_datarel
:
539 case DW_EH_PE_funcrel
:
540 ret
= encoding
& 0x70;
543 internal_error (__FILE__
, __LINE__
, "CFI: unknown pointer encoding [in module %s]",
550 read_initial_length (bfd
*abfd
, char *buf
, int *bytes_read
)
554 ret
= bfd_get_32 (abfd
, (bfd_byte
*) buf
);
556 if (ret
== 0xffffffff)
558 ret
= bfd_get_64 (abfd
, (bfd_byte
*) buf
+ 4);
570 read_length (bfd
*abfd
, char *buf
, int *bytes_read
, int dwarf64
)
575 return read_8u (abfd
, &buf
);
580 return read_4u (abfd
, &buf
);
585 execute_cfa_program (struct objfile
*objfile
, char *insn_ptr
, char *insn_end
,
586 struct context
*context
, struct frame_state
*fs
)
588 struct frame_state_regs
*unused_rs
= NULL
;
590 /* Don't allow remember/restore between CIE and FDE programs. */
591 fs
->regs
.prev
= NULL
;
593 while (insn_ptr
< insn_end
&& fs
->pc
< context
->ra
)
595 unsigned char insn
= *insn_ptr
++;
596 ULONGEST reg
, uoffset
;
599 if (insn
& DW_CFA_advance_loc
)
600 fs
->pc
+= (insn
& 0x3f) * fs
->code_align
;
601 else if (insn
& DW_CFA_offset
)
604 uoffset
= read_uleb128 (objfile
->obfd
, &insn_ptr
);
605 offset
= (long) uoffset
*fs
->data_align
;
606 fs
->regs
.reg
[reg
].how
= REG_SAVED_OFFSET
;
607 fs
->regs
.reg
[reg
].loc
.offset
= offset
;
609 else if (insn
& DW_CFA_restore
)
612 fs
->regs
.reg
[reg
].how
= REG_UNSAVED
;
618 fs
->pc
= read_encoded_pointer (objfile
->obfd
, &insn_ptr
,
621 if (pointer_encoding (fs
->addr_encoding
, objfile
) != PE_absptr
)
622 warning ("CFI: DW_CFA_set_loc uses relative addressing [in module %s]",
627 case DW_CFA_advance_loc1
:
628 fs
->pc
+= read_1u (objfile
->obfd
, &insn_ptr
);
630 case DW_CFA_advance_loc2
:
631 fs
->pc
+= read_2u (objfile
->obfd
, &insn_ptr
);
633 case DW_CFA_advance_loc4
:
634 fs
->pc
+= read_4u (objfile
->obfd
, &insn_ptr
);
637 case DW_CFA_offset_extended
:
638 reg
= read_uleb128 (objfile
->obfd
, &insn_ptr
);
639 uoffset
= read_uleb128 (objfile
->obfd
, &insn_ptr
);
640 offset
= (long) uoffset
*fs
->data_align
;
641 fs
->regs
.reg
[reg
].how
= REG_SAVED_OFFSET
;
642 fs
->regs
.reg
[reg
].loc
.offset
= offset
;
645 case DW_CFA_restore_extended
:
646 reg
= read_uleb128 (objfile
->obfd
, &insn_ptr
);
647 fs
->regs
.reg
[reg
].how
= REG_UNSAVED
;
650 case DW_CFA_undefined
:
651 case DW_CFA_same_value
:
655 case DW_CFA_register
:
658 reg
= read_uleb128 (objfile
->obfd
, &insn_ptr
);
659 reg2
= read_uleb128 (objfile
->obfd
, &insn_ptr
);
660 fs
->regs
.reg
[reg
].how
= REG_SAVED_REG
;
661 fs
->regs
.reg
[reg
].loc
.reg
= reg2
;
665 case DW_CFA_remember_state
:
667 struct frame_state_regs
*new_rs
;
671 unused_rs
= unused_rs
->prev
;
674 new_rs
= xmalloc (sizeof (struct frame_state_regs
));
677 fs
->regs
.prev
= new_rs
;
681 case DW_CFA_restore_state
:
683 struct frame_state_regs
*old_rs
= fs
->regs
.prev
;
685 old_rs
->prev
= unused_rs
;
691 reg
= read_uleb128 (objfile
->obfd
, &insn_ptr
);
692 uoffset
= read_uleb128 (objfile
->obfd
, &insn_ptr
);
694 fs
->cfa_offset
= uoffset
;
695 fs
->cfa_how
= CFA_REG_OFFSET
;
698 case DW_CFA_def_cfa_register
:
699 reg
= read_uleb128 (objfile
->obfd
, &insn_ptr
);
701 fs
->cfa_how
= CFA_REG_OFFSET
;
704 case DW_CFA_def_cfa_offset
:
705 uoffset
= read_uleb128 (objfile
->obfd
, &insn_ptr
);
706 fs
->cfa_offset
= uoffset
;
709 case DW_CFA_def_cfa_expression
:
710 uoffset
= read_uleb128 (objfile
->obfd
, &insn_ptr
);
711 fs
->cfa_exp
= insn_ptr
;
712 fs
->cfa_how
= CFA_EXP
;
716 case DW_CFA_expression
:
717 reg
= read_uleb128 (objfile
->obfd
, &insn_ptr
);
718 uoffset
= read_uleb128 (objfile
->obfd
, &insn_ptr
);
719 fs
->regs
.reg
[reg
].how
= REG_SAVED_EXP
;
720 fs
->regs
.reg
[reg
].loc
.exp
= insn_ptr
;
724 /* From the 2.1 draft. */
725 case DW_CFA_offset_extended_sf
:
726 reg
= read_uleb128 (objfile
->obfd
, &insn_ptr
);
727 offset
= read_sleb128 (objfile
->obfd
, &insn_ptr
);
728 offset
*= fs
->data_align
;
729 fs
->regs
.reg
[reg
].how
= REG_SAVED_OFFSET
;
730 fs
->regs
.reg
[reg
].loc
.offset
= offset
;
733 case DW_CFA_def_cfa_sf
:
734 reg
= read_uleb128 (objfile
->obfd
, &insn_ptr
);
735 offset
= read_sleb128 (objfile
->obfd
, &insn_ptr
);
736 fs
->cfa_offset
= offset
;
738 fs
->cfa_how
= CFA_REG_OFFSET
;
741 case DW_CFA_def_cfa_offset_sf
:
742 uoffset
= read_uleb128 (objfile
->obfd
, &insn_ptr
);
743 fs
->cfa_offset
= uoffset
;
744 /* cfa_how deliberately not set. */
747 case DW_CFA_GNU_window_save
:
748 /* ??? Hardcoded for SPARC register window configuration. */
749 for (reg
= 16; reg
< 32; ++reg
)
751 fs
->regs
.reg
[reg
].how
= REG_SAVED_OFFSET
;
752 fs
->regs
.reg
[reg
].loc
.offset
= (reg
- 16) * sizeof (void *);
756 case DW_CFA_GNU_args_size
:
757 uoffset
= read_uleb128 (objfile
->obfd
, &insn_ptr
);
758 context
->args_size
= uoffset
;
761 case DW_CFA_GNU_negative_offset_extended
:
762 /* Obsoleted by DW_CFA_offset_extended_sf, but used by
763 older PowerPC code. */
764 reg
= read_uleb128 (objfile
->obfd
, &insn_ptr
);
765 uoffset
= read_uleb128 (objfile
->obfd
, &insn_ptr
);
766 offset
= (long) uoffset
*fs
->data_align
;
767 fs
->regs
.reg
[reg
].how
= REG_SAVED_OFFSET
;
768 fs
->regs
.reg
[reg
].loc
.offset
= -offset
;
772 error ("dwarf cfi error: unknown cfa instruction %d [in module %s]", insn
,
778 static struct fde_unit
*
779 get_fde_for_addr (CORE_ADDR pc
)
782 struct fde_unit
*fde
= NULL
;
784 hi
= fde_chunks
.elems
;
788 size_t i
= (lo
+ hi
) / 2;
789 fde
= fde_chunks
.array
[i
];
790 if (pc
< fde
->initial_location
)
792 else if (pc
>= fde
->initial_location
+ fde
->address_range
)
801 frame_state_for (struct context
*context
, struct frame_state
*fs
)
803 struct fde_unit
*fde
;
804 struct cie_unit
*cie
;
806 context
->args_size
= 0;
809 fde
= get_fde_for_addr (context
->ra
- 1);
814 fs
->pc
= fde
->initial_location
;
816 gdb_assert (fde
->cie_ptr
!= NULL
);
820 fs
->code_align
= cie
->code_align
;
821 fs
->data_align
= cie
->data_align
;
822 fs
->retaddr_column
= cie
->ra
;
823 fs
->addr_encoding
= cie
->addr_encoding
;
824 fs
->objfile
= cie
->objfile
;
826 execute_cfa_program (cie
->objfile
, cie
->data
,
827 cie
->data
+ cie
->data_length
, context
, fs
);
828 execute_cfa_program (cie
->objfile
, fde
->data
,
829 fde
->data
+ fde
->data_length
, context
, fs
);
833 get_reg (char *reg
, struct context
*context
, int regnum
)
835 switch (context
->reg
[regnum
].how
)
837 case REG_CTX_UNSAVED
:
838 deprecated_read_register_gen (regnum
, reg
);
840 case REG_CTX_SAVED_OFFSET
:
841 target_read_memory (context
->cfa
+ context
->reg
[regnum
].loc
.offset
,
842 reg
, REGISTER_RAW_SIZE (regnum
));
844 case REG_CTX_SAVED_REG
:
845 deprecated_read_register_gen (context
->reg
[regnum
].loc
.reg
, reg
);
847 case REG_CTX_SAVED_ADDR
:
848 target_read_memory (context
->reg
[regnum
].loc
.addr
,
849 reg
, REGISTER_RAW_SIZE (regnum
));
852 memcpy (reg
, &context
->reg
[regnum
].loc
.addr
,
853 REGISTER_RAW_SIZE (regnum
));
856 internal_error (__FILE__
, __LINE__
, "get_reg: unknown register rule");
860 /* Decode a DW_OP stack program. Return the top of stack. Push INITIAL
861 onto the stack to start. */
863 execute_stack_op (struct objfile
*objfile
,
864 char *op_ptr
, char *op_end
, struct context
*context
,
867 CORE_ADDR stack
[64]; /* ??? Assume this is enough. */
873 while (op_ptr
< op_end
)
875 enum dwarf_location_atom op
= *op_ptr
++;
914 result
= op
- DW_OP_lit0
;
918 result
= read_pointer (objfile
->obfd
, &op_ptr
);
922 result
= read_1u (objfile
->obfd
, &op_ptr
);
925 result
= read_1s (objfile
->obfd
, &op_ptr
);
928 result
= read_2u (objfile
->obfd
, &op_ptr
);
931 result
= read_2s (objfile
->obfd
, &op_ptr
);
934 result
= read_4u (objfile
->obfd
, &op_ptr
);
937 result
= read_4s (objfile
->obfd
, &op_ptr
);
940 result
= read_8u (objfile
->obfd
, &op_ptr
);
943 result
= read_8s (objfile
->obfd
, &op_ptr
);
946 result
= read_uleb128 (objfile
->obfd
, &op_ptr
);
949 result
= read_sleb128 (objfile
->obfd
, &op_ptr
);
984 get_reg ((char *) &result
, context
, op
- DW_OP_reg0
);
987 reg
= read_uleb128 (objfile
->obfd
, &op_ptr
);
988 get_reg ((char *) &result
, context
, reg
);
1023 offset
= read_sleb128 (objfile
->obfd
, &op_ptr
);
1024 get_reg ((char *) &result
, context
, op
- DW_OP_breg0
);
1028 reg
= read_uleb128 (objfile
->obfd
, &op_ptr
);
1029 offset
= read_sleb128 (objfile
->obfd
, &op_ptr
);
1030 get_reg ((char *) &result
, context
, reg
);
1036 internal_error (__FILE__
, __LINE__
, "execute_stack_op error [in module %s]", objfile
->name
);
1037 result
= stack
[stack_elt
- 1];
1041 if (--stack_elt
< 0)
1042 internal_error (__FILE__
, __LINE__
, "execute_stack_op error [in module %s]", objfile
->name
);
1047 if (offset
>= stack_elt
- 1)
1048 internal_error (__FILE__
, __LINE__
, "execute_stack_op error [in module %s]", objfile
->name
);
1049 result
= stack
[stack_elt
- 1 - offset
];
1054 internal_error (__FILE__
, __LINE__
, "execute_stack_op error [in module %s]", objfile
->name
);
1055 result
= stack
[stack_elt
- 2];
1060 CORE_ADDR t1
, t2
, t3
;
1063 internal_error (__FILE__
, __LINE__
, "execute_stack_op error [in module %s]", objfile
->name
);
1064 t1
= stack
[stack_elt
- 1];
1065 t2
= stack
[stack_elt
- 2];
1066 t3
= stack
[stack_elt
- 3];
1067 stack
[stack_elt
- 1] = t2
;
1068 stack
[stack_elt
- 2] = t3
;
1069 stack
[stack_elt
- 3] = t1
;
1074 case DW_OP_deref_size
:
1078 case DW_OP_plus_uconst
:
1079 /* Unary operations. */
1080 if (--stack_elt
< 0)
1081 internal_error (__FILE__
, __LINE__
, "execute_stack_op error [in module %s]", objfile
->name
);
1082 result
= stack
[stack_elt
];
1088 int len
= TARGET_ADDR_BIT
/ TARGET_CHAR_BIT
;
1089 if (len
!= 4 && len
!= 8)
1090 internal_error (__FILE__
, __LINE__
,
1091 "execute_stack_op error [in module %s]", objfile
->name
);
1092 result
= read_memory_unsigned_integer (result
, len
);
1096 case DW_OP_deref_size
:
1098 int len
= *op_ptr
++;
1099 if (len
!= 1 && len
!= 2 && len
!= 4 && len
!= 8)
1100 internal_error (__FILE__
, __LINE__
,
1101 "execute_stack_op error [in module %s]", objfile
->name
);
1102 result
= read_memory_unsigned_integer (result
, len
);
1116 case DW_OP_plus_uconst
:
1117 result
+= read_uleb128 (objfile
->obfd
, &op_ptr
);
1138 /* Binary operations. */
1139 CORE_ADDR first
, second
;
1140 if ((stack_elt
-= 2) < 0)
1141 internal_error (__FILE__
, __LINE__
, "execute_stack_op error [in module %s]", objfile
->name
);
1142 second
= stack
[stack_elt
];
1143 first
= stack
[stack_elt
+ 1];
1148 result
= second
& first
;
1151 result
= (LONGEST
) second
/ (LONGEST
) first
;
1154 result
= second
- first
;
1157 result
= (LONGEST
) second
% (LONGEST
) first
;
1160 result
= second
* first
;
1163 result
= second
| first
;
1166 result
= second
+ first
;
1169 result
= second
<< first
;
1172 result
= second
>> first
;
1175 result
= (LONGEST
) second
>> first
;
1178 result
= second
^ first
;
1181 result
= (LONGEST
) first
<= (LONGEST
) second
;
1184 result
= (LONGEST
) first
>= (LONGEST
) second
;
1187 result
= (LONGEST
) first
== (LONGEST
) second
;
1190 result
= (LONGEST
) first
< (LONGEST
) second
;
1193 result
= (LONGEST
) first
> (LONGEST
) second
;
1196 result
= (LONGEST
) first
!= (LONGEST
) second
;
1199 error ("execute_stack_op: Unknown DW_OP_ value [in module %s]", objfile
->name
);
1206 offset
= read_2s (objfile
->obfd
, &op_ptr
);
1211 if (--stack_elt
< 0)
1212 internal_error (__FILE__
, __LINE__
, "execute_stack_op error [in module %s]", objfile
->name
);
1213 offset
= read_2s (objfile
->obfd
, &op_ptr
);
1214 if (stack
[stack_elt
] != 0)
1222 internal_error (__FILE__
, __LINE__
, "execute_stack_op error [in module %s]", objfile
->name
);
1225 /* Most things push a result value. */
1226 if ((size_t) stack_elt
>= sizeof (stack
) / sizeof (*stack
))
1227 internal_error (__FILE__
, __LINE__
, "execute_stack_op error [in module %s]", objfile
->name
);
1228 stack
[++stack_elt
] = result
;
1232 /* We were executing this program to get a value. It should be
1234 if (--stack_elt
< 0)
1235 internal_error (__FILE__
, __LINE__
, "execute_stack_op error [in module %s]", objfile
->name
);
1236 return stack
[stack_elt
];
1240 update_context (struct context
*context
, struct frame_state
*fs
, int chain
)
1242 struct context
*orig_context
;
1246 unwind_tmp_obstack_init ();
1248 orig_context
= context_alloc ();
1249 context_cpy (orig_context
, context
);
1251 /* Compute this frame's CFA. */
1252 switch (fs
->cfa_how
)
1254 case CFA_REG_OFFSET
:
1255 get_reg ((char *) &cfa
, context
, fs
->cfa_reg
);
1256 cfa
+= fs
->cfa_offset
;
1260 /* ??? No way of knowing what register number is the stack pointer
1261 to do the same sort of handling as above. Assume that if the
1262 CFA calculation is so complicated as to require a stack program
1263 that this will not be a problem. */
1265 char *exp
= fs
->cfa_exp
;
1268 len
= read_uleb128 (fs
->objfile
->obfd
, &exp
);
1269 cfa
= (CORE_ADDR
) execute_stack_op (fs
->objfile
, exp
,
1270 exp
+ len
, context
, 0);
1279 orig_context
->cfa
= cfa
;
1281 /* Compute the addresses of all registers saved in this frame. */
1282 for (i
= 0; i
< NUM_REGS
; ++i
)
1283 switch (fs
->regs
.reg
[i
].how
)
1288 context
->reg
[i
].how
= REG_CTX_VALUE
;
1289 context
->reg
[i
].loc
.addr
= cfa
;
1292 context
->reg
[i
].how
= REG_CTX_UNSAVED
;
1294 case REG_SAVED_OFFSET
:
1295 context
->reg
[i
].how
= REG_CTX_SAVED_OFFSET
;
1296 context
->reg
[i
].loc
.offset
= fs
->regs
.reg
[i
].loc
.offset
;
1299 switch (orig_context
->reg
[fs
->regs
.reg
[i
].loc
.reg
].how
)
1301 case REG_CTX_UNSAVED
:
1302 context
->reg
[i
].how
= REG_CTX_UNSAVED
;
1304 case REG_CTX_SAVED_OFFSET
:
1305 context
->reg
[i
].how
= REG_CTX_SAVED_OFFSET
;
1306 context
->reg
[i
].loc
.offset
= orig_context
->cfa
- context
->cfa
+
1307 orig_context
->reg
[fs
->regs
.reg
[i
].loc
.reg
].loc
.offset
;
1309 case REG_CTX_SAVED_REG
:
1310 context
->reg
[i
].how
= REG_CTX_SAVED_REG
;
1311 context
->reg
[i
].loc
.reg
=
1312 orig_context
->reg
[fs
->regs
.reg
[i
].loc
.reg
].loc
.reg
;
1314 case REG_CTX_SAVED_ADDR
:
1315 context
->reg
[i
].how
= REG_CTX_SAVED_ADDR
;
1316 context
->reg
[i
].loc
.addr
=
1317 orig_context
->reg
[fs
->regs
.reg
[i
].loc
.reg
].loc
.addr
;
1320 internal_error (__FILE__
, __LINE__
, "bad switch 0x%02X",
1321 orig_context
->reg
[fs
->regs
.reg
[i
].loc
.reg
].how
);
1326 char *exp
= fs
->regs
.reg
[i
].loc
.exp
;
1330 len
= read_uleb128 (fs
->objfile
->obfd
, &exp
);
1331 val
= execute_stack_op (fs
->objfile
, exp
, exp
+ len
,
1333 context
->reg
[i
].how
= REG_CTX_SAVED_ADDR
;
1334 context
->reg
[i
].loc
.addr
= val
;
1338 internal_error (__FILE__
, __LINE__
, "bad switch 0x%02X",
1339 fs
->regs
.reg
[i
].how
);
1341 get_reg ((char *) &context
->ra
, context
, fs
->retaddr_column
);
1342 unwind_tmp_obstack_free ();
1346 is_cie (ULONGEST cie_id
, int dwarf64
)
1348 return dwarf64
? (cie_id
== 0xffffffffffffffff) : (cie_id
== 0xffffffff);
1352 compare_fde_unit (const void *a
, const void *b
)
1354 struct fde_unit
**first
, **second
;
1355 first
= (struct fde_unit
**) a
;
1356 second
= (struct fde_unit
**) b
;
1357 if ((*first
)->initial_location
> (*second
)->initial_location
)
1359 else if ((*first
)->initial_location
< (*second
)->initial_location
)
1365 /* Build the cie_chunks and fde_chunks tables from informations
1366 found in .debug_frame and .eh_frame sections. */
1367 /* We can handle both of these sections almost in the same way, however there
1368 are some exceptions:
1369 - CIE ID is -1 in debug_frame, but 0 in eh_frame
1370 - eh_frame may contain some more information that are used only by gcc
1371 (eg. personality pointer, LSDA pointer, ...). Most of them we can ignore.
1372 - In debug_frame FDE's item cie_id contains offset of it's parent CIE.
1373 In eh_frame FDE's item cie_id is a relative pointer to the parent CIE.
1374 Anyway we don't need to bother with this, because we are smart enough
1375 to keep the pointer to the parent CIE of oncomming FDEs in 'last_cie'.
1376 - Although debug_frame items can contain Augmentation as well as
1377 eh_frame ones, I have never seen them non-empty. Thus only in eh_frame
1378 we can encounter for example non-absolute pointers (Aug. 'R').
1381 parse_frame_info (struct objfile
*objfile
, file_ptr frame_offset
,
1382 unsigned int frame_size
, asection
*frame_section
,
1385 bfd
*abfd
= objfile
->obfd
;
1386 asection
*curr_section_ptr
;
1389 char *frame_buffer
= NULL
;
1390 char *curr_section_name
, *aug_data
;
1391 struct cie_unit
*last_cie
= NULL
;
1392 int last_dup_fde
= 0;
1394 CORE_ADDR curr_section_vma
= 0;
1396 unwind_tmp_obstack_init ();
1398 frame_buffer
= dwarf2_read_section (objfile
, frame_offset
, frame_size
,
1401 start
= frame_buffer
;
1402 end
= frame_buffer
+ frame_size
;
1404 curr_section_name
= eh_frame
? ".eh_frame" : ".debug_frame";
1405 curr_section_ptr
= bfd_get_section_by_name (abfd
, curr_section_name
);
1406 if (curr_section_ptr
)
1407 curr_section_vma
= curr_section_ptr
->vma
;
1413 unsigned long length
;
1415 ULONGEST unit_offset
= start
- frame_buffer
;
1416 int bytes_read
, dwarf64
;
1419 length
= read_initial_length (abfd
, start
, &bytes_read
);
1420 start
+= bytes_read
;
1421 dwarf64
= (bytes_read
== 12);
1422 block_end
= start
+ length
;
1430 cie_id
= read_length (abfd
, start
, &bytes_read
, dwarf64
);
1431 start
+= bytes_read
;
1433 if ((eh_frame
&& cie_id
== 0) || is_cie (cie_id
, dwarf64
))
1435 struct cie_unit
*cie
= cie_unit_alloc ();
1438 cie
->objfile
= objfile
;
1439 cie
->next
= cie_chunks
;
1442 cie
->objfile
= objfile
;
1444 cie
->offset
= unit_offset
;
1446 start
++; /* version */
1448 cie
->augmentation
= aug
= start
;
1449 while (*start
++); /* Skips last NULL as well */
1451 cie
->code_align
= read_uleb128 (abfd
, &start
);
1452 cie
->data_align
= read_sleb128 (abfd
, &start
);
1453 cie
->ra
= read_1u (abfd
, &start
);
1456 z Indicates that a uleb128 is present to size the
1457 augmentation section.
1458 L Indicates the encoding (and thus presence) of
1459 an LSDA pointer in the FDE augmentation.
1460 R Indicates a non-default pointer encoding for
1462 P Indicates the presence of an encoding + language
1463 personality routine in the CIE augmentation.
1465 [This info comes from GCC's dwarf2out.c]
1469 aug_len
= read_uleb128 (abfd
, &start
);
1476 cie
->data_length
= block_end
- cie
->data
;
1478 while (*aug
!= '\0')
1480 if (aug
[0] == 'e' && aug
[1] == 'h')
1482 aug_data
+= sizeof (void *);
1485 else if (aug
[0] == 'R')
1486 cie
->addr_encoding
= *aug_data
++;
1487 else if (aug
[0] == 'P')
1489 CORE_ADDR pers_addr
;
1492 pers_addr_enc
= *aug_data
++;
1493 /* We don't need pers_addr value and so we
1494 don't care about it's encoding. */
1495 pers_addr
= read_encoded_pointer (abfd
, &aug_data
,
1498 else if (aug
[0] == 'L' && eh_frame
)
1502 /* Perhaps we should save this to CIE for later use?
1503 Do we need it for something in GDB? */
1504 lsda_addr_enc
= *aug_data
++;
1507 warning ("CFI warning: unknown augmentation \"%c\""
1509 "\t%s", aug
[0], curr_section_name
,
1518 struct fde_unit
*fde
;
1519 struct cie_unit
*cie
;
1523 /* We assume that debug_frame is in order
1524 CIE,FDE,CIE,FDE,FDE,... and thus the CIE for this FDE
1525 should be stored in last_cie pointer. If not, we'll
1526 try to find it by the older way. */
1531 warning ("CFI: last_cie == NULL. "
1532 "Perhaps a malformed %s section in '%s'...?\n",
1533 curr_section_name
, objfile
->name
);
1538 if (cie
->objfile
== objfile
)
1542 (unit_offset
+ bytes_read
- cie_id
)))
1544 if (!eh_frame
&& (cie
->offset
== cie_id
))
1551 error ("CFI: can't find CIE pointer [in module %s]",
1552 bfd_get_filename (abfd
));
1555 init_loc
= read_encoded_pointer (abfd
, &start
,
1556 cie
->addr_encoding
);
1558 switch (pointer_encoding (cie
->addr_encoding
, objfile
))
1563 /* start-frame_buffer gives offset from
1564 the beginning of actual section. */
1565 init_loc
+= curr_section_vma
+ start
- frame_buffer
;
1568 warning ("CFI: Unsupported pointer encoding [in module %s]",
1569 bfd_get_filename (abfd
));
1572 /* For relocatable objects we must add an offset telling
1573 where the section is actually mapped in the memory. */
1574 init_loc
+= ANOFFSET (objfile
->section_offsets
,
1575 SECT_OFF_TEXT (objfile
));
1577 /* If we have both .debug_frame and .eh_frame present in
1578 a file, we must eliminate duplicate FDEs. For now we'll
1579 run through all entries in fde_chunks and check it one
1580 by one. Perhaps in the future we can implement a faster
1581 searching algorithm. */
1582 /* eh_frame==2 indicates, that this file has an already
1583 parsed .debug_frame too. When eh_frame==1 it means, that no
1584 .debug_frame is present and thus we don't need to check for
1585 duplicities. eh_frame==0 means, that we parse .debug_frame
1586 and don't need to care about duplicate FDEs, because
1587 .debug_frame is parsed first. */
1589 for (i
= 0; eh_frame
== 2 && i
< fde_chunks
.elems
; i
++)
1591 /* We assume that FDEs in .debug_frame and .eh_frame
1592 have the same order (if they are present, of course).
1593 If we find a duplicate entry for one FDE and save
1594 it's index to last_dup_fde it's very likely, that
1595 we'll find an entry for the following FDE right after
1596 the previous one. Thus in many cases we'll run this
1598 last_dup_fde
= (last_dup_fde
+ i
) % fde_chunks
.elems
;
1599 if (fde_chunks
.array
[last_dup_fde
]->initial_location
1607 /* Allocate a new entry only if this FDE isn't a duplicate of
1608 something we have already seen. */
1611 fde_chunks_need_space ();
1612 fde
= fde_unit_alloc ();
1614 fde_chunks
.array
[fde_chunks
.elems
++] = fde
;
1616 fde
->initial_location
= init_loc
;
1617 fde
->address_range
= read_encoded_pointer (abfd
, &start
,
1623 /* Here we intentionally ignore augmentation data
1624 from FDE, because we don't need them. */
1625 if (cie
->augmentation
[0] == 'z')
1626 start
+= read_uleb128 (abfd
, &start
);
1629 fde
->data_length
= block_end
- start
;
1634 qsort (fde_chunks
.array
, fde_chunks
.elems
,
1635 sizeof (struct fde_unit
*), compare_fde_unit
);
1639 /* We must parse both .debug_frame section and .eh_frame because
1640 * not all frames must be present in both of these sections. */
1642 dwarf2_build_frame_info (struct objfile
*objfile
)
1644 int after_debug_frame
= 0;
1646 /* If we have .debug_frame then the parser is called with
1647 eh_frame==0 for .debug_frame and eh_frame==2 for .eh_frame,
1648 otherwise it's only called once for .eh_frame with argument
1651 if (dwarf_frame_offset
)
1653 parse_frame_info (objfile
, dwarf_frame_offset
,
1654 dwarf_frame_size
, dwarf_frame_section
,
1655 0 /* = debug_frame */ );
1656 after_debug_frame
= 1;
1659 if (dwarf_eh_frame_offset
)
1660 parse_frame_info (objfile
, dwarf_eh_frame_offset
, dwarf_eh_frame_size
,
1661 dwarf_eh_frame_section
,
1662 1 /* = eh_frame */ + after_debug_frame
);
1665 /* Return the frame address. */
1669 struct context
*context
;
1670 struct frame_state
*fs
;
1673 unwind_tmp_obstack_init ();
1675 context
= context_alloc ();
1676 fs
= frame_state_alloc ();
1678 context
->ra
= read_pc () + 1;
1680 frame_state_for (context
, fs
);
1681 update_context (context
, fs
, 0);
1685 unwind_tmp_obstack_free ();
1690 /* Store the frame address. This function is not used. */
1693 cfi_write_fp (CORE_ADDR val
)
1695 struct context
*context
;
1696 struct frame_state
*fs
;
1698 unwind_tmp_obstack_init ();
1700 context
= context_alloc ();
1701 fs
= frame_state_alloc ();
1703 context
->ra
= read_pc () + 1;
1705 frame_state_for (context
, fs
);
1707 if (fs
->cfa_how
== CFA_REG_OFFSET
)
1709 val
-= fs
->cfa_offset
;
1710 deprecated_write_register_gen (fs
->cfa_reg
, (char *) &val
);
1713 warning ("Can't write fp.");
1715 unwind_tmp_obstack_free ();
1718 /* Restore the machine to the state it had before the current frame
1721 cfi_pop_frame (struct frame_info
*fi
)
1723 char *regbuf
= alloca (MAX_REGISTER_RAW_SIZE
);
1726 for (regnum
= 0; regnum
< NUM_REGS
; regnum
++)
1728 get_reg (regbuf
, UNWIND_CONTEXT (fi
), regnum
);
1729 deprecated_write_register_bytes (REGISTER_BYTE (regnum
), regbuf
,
1730 REGISTER_RAW_SIZE (regnum
));
1732 write_register (PC_REGNUM
, UNWIND_CONTEXT (fi
)->ra
);
1734 flush_cached_frames ();
1737 /* Determine the address of the calling function's frame. */
1739 cfi_frame_chain (struct frame_info
*fi
)
1741 struct context
*context
;
1742 struct frame_state
*fs
;
1745 unwind_tmp_obstack_init ();
1747 context
= context_alloc ();
1748 fs
= frame_state_alloc ();
1749 context_cpy (context
, UNWIND_CONTEXT (fi
));
1751 /* outermost frame */
1752 if (context
->ra
== 0)
1754 unwind_tmp_obstack_free ();
1758 frame_state_for (context
, fs
);
1759 update_context (context
, fs
, 1);
1762 unwind_tmp_obstack_free ();
1767 /* Sets the pc of the frame. */
1769 cfi_init_frame_pc (int fromleaf
, struct frame_info
*fi
)
1771 if (get_next_frame (fi
))
1774 /* FIXME: cagney/2002-12-04: This is straight wrong. It's
1775 assuming that the PC is CORE_ADDR (a host quantity) in size. */
1776 get_reg ((void *)&pc
, UNWIND_CONTEXT (get_next_frame (fi
)), PC_REGNUM
);
1783 /* Initialize unwind context informations of the frame. */
1785 cfi_init_extra_frame_info (int fromleaf
, struct frame_info
*fi
)
1787 struct frame_state
*fs
;
1789 unwind_tmp_obstack_init ();
1791 fs
= frame_state_alloc ();
1792 deprecated_set_frame_context (fi
, frame_obstack_zalloc (sizeof (struct context
)));
1793 UNWIND_CONTEXT (fi
)->reg
=
1794 frame_obstack_zalloc (sizeof (struct context_reg
) * NUM_REGS
);
1795 memset (UNWIND_CONTEXT (fi
)->reg
, 0,
1796 sizeof (struct context_reg
) * NUM_REGS
);
1798 if (get_next_frame (fi
))
1800 context_cpy (UNWIND_CONTEXT (fi
), UNWIND_CONTEXT (get_next_frame (fi
)));
1801 frame_state_for (UNWIND_CONTEXT (fi
), fs
);
1802 update_context (UNWIND_CONTEXT (fi
), fs
, 1);
1806 UNWIND_CONTEXT (fi
)->ra
= get_frame_pc (fi
) + 1;
1807 frame_state_for (UNWIND_CONTEXT (fi
), fs
);
1808 update_context (UNWIND_CONTEXT (fi
), fs
, 0);
1811 unwind_tmp_obstack_free ();
1814 /* Obtain return address of the frame. */
1816 cfi_get_ra (struct frame_info
*fi
)
1818 return UNWIND_CONTEXT (fi
)->ra
;
1821 /* Find register number REGNUM relative to FRAME and put its
1822 (raw) contents in *RAW_BUFFER. Set *OPTIMIZED if the variable
1823 was optimized out (and thus can't be fetched). If the variable
1824 was fetched from memory, set *ADDRP to where it was fetched from,
1825 otherwise it was fetched from a register.
1827 The argument RAW_BUFFER must point to aligned memory. */
1829 cfi_get_saved_register (char *raw_buffer
,
1832 struct frame_info
*frame
,
1833 int regnum
, enum lval_type
*lval
)
1835 if (!target_has_registers
)
1836 error ("No registers.");
1838 /* Normal systems don't optimize out things with register numbers. */
1839 if (optimized
!= NULL
)
1842 if (addrp
) /* default assumption: not found in memory */
1845 if (!get_next_frame (frame
))
1847 deprecated_read_register_gen (regnum
, raw_buffer
);
1849 *lval
= lval_register
;
1851 *addrp
= REGISTER_BYTE (regnum
);
1855 frame
= get_next_frame (frame
);
1856 switch (UNWIND_CONTEXT (frame
)->reg
[regnum
].how
)
1858 case REG_CTX_UNSAVED
:
1859 deprecated_read_register_gen (regnum
, raw_buffer
);
1862 if (optimized
!= NULL
)
1865 case REG_CTX_SAVED_OFFSET
:
1866 target_read_memory (UNWIND_CONTEXT (frame
)->cfa
+
1867 UNWIND_CONTEXT (frame
)->reg
[regnum
].loc
.offset
,
1868 raw_buffer
, REGISTER_RAW_SIZE (regnum
));
1870 *lval
= lval_memory
;
1873 UNWIND_CONTEXT (frame
)->cfa
+
1874 UNWIND_CONTEXT (frame
)->reg
[regnum
].loc
.offset
;
1876 case REG_CTX_SAVED_REG
:
1877 deprecated_read_register_gen (UNWIND_CONTEXT (frame
)->reg
[regnum
].loc
.reg
,
1880 *lval
= lval_register
;
1883 REGISTER_BYTE (UNWIND_CONTEXT (frame
)->reg
[regnum
].loc
.reg
);
1885 case REG_CTX_SAVED_ADDR
:
1886 target_read_memory (UNWIND_CONTEXT (frame
)->reg
[regnum
].loc
.addr
,
1887 raw_buffer
, REGISTER_RAW_SIZE (regnum
));
1889 *lval
= lval_memory
;
1891 *addrp
= UNWIND_CONTEXT (frame
)->reg
[regnum
].loc
.addr
;
1894 memcpy (raw_buffer
, &UNWIND_CONTEXT (frame
)->reg
[regnum
].loc
.addr
,
1895 REGISTER_RAW_SIZE (regnum
));
1898 if (optimized
!= NULL
)
1902 internal_error (__FILE__
, __LINE__
,
1903 "cfi_get_saved_register: unknown register rule 0x%02X",
1904 UNWIND_CONTEXT (frame
)->reg
[regnum
].how
);
1909 /* Return the register that the function uses for a frame pointer,
1910 plus any necessary offset to be applied to the register before
1911 any frame pointer offsets. */
1913 cfi_virtual_frame_pointer (CORE_ADDR pc
, int *frame_reg
,
1914 LONGEST
* frame_offset
)
1916 struct context
*context
;
1917 struct frame_state
*fs
;
1919 unwind_tmp_obstack_init ();
1921 context
= context_alloc ();
1922 fs
= frame_state_alloc ();
1924 context
->ra
= read_pc () + 1;
1926 frame_state_for (context
, fs
);
1928 if (fs
->cfa_how
== CFA_REG_OFFSET
)
1930 *frame_reg
= fs
->cfa_reg
;
1931 *frame_offset
= fs
->cfa_offset
;
1934 error ("dwarf cfi error: CFA is not defined as CFA_REG_OFFSET");
1936 unwind_tmp_obstack_free ();