sim: profile: implement --profile-file backend
[deliverable/binutils-gdb.git] / gdb / dwarf2-frame.c
CommitLineData
cfc14b3a
MK
1/* Frame unwinder for frames with DWARF Call Frame Information.
2
4c38e0a4 3 Copyright (C) 2003, 2004, 2005, 2007, 2008, 2009, 2010
0fb0cc75 4 Free Software Foundation, Inc.
cfc14b3a
MK
5
6 Contributed by Mark Kettenis.
7
8 This file is part of GDB.
9
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
a9762ec7 12 the Free Software Foundation; either version 3 of the License, or
cfc14b3a
MK
13 (at your option) any later version.
14
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.
19
20 You should have received a copy of the GNU General Public License
a9762ec7 21 along with this program. If not, see <http://www.gnu.org/licenses/>. */
cfc14b3a
MK
22
23#include "defs.h"
24#include "dwarf2expr.h"
fa8f86ff 25#include "dwarf2.h"
cfc14b3a
MK
26#include "frame.h"
27#include "frame-base.h"
28#include "frame-unwind.h"
29#include "gdbcore.h"
30#include "gdbtypes.h"
31#include "symtab.h"
32#include "objfiles.h"
33#include "regcache.h"
f2da6b3a 34#include "value.h"
cfc14b3a
MK
35
36#include "gdb_assert.h"
37#include "gdb_string.h"
38
6896c0c7 39#include "complaints.h"
cfc14b3a
MK
40#include "dwarf2-frame.h"
41
ae0d2f24
UW
42struct comp_unit;
43
cfc14b3a
MK
44/* Call Frame Information (CFI). */
45
46/* Common Information Entry (CIE). */
47
48struct dwarf2_cie
49{
ae0d2f24
UW
50 /* Computation Unit for this CIE. */
51 struct comp_unit *unit;
52
cfc14b3a
MK
53 /* Offset into the .debug_frame section where this CIE was found.
54 Used to identify this CIE. */
55 ULONGEST cie_pointer;
56
57 /* Constant that is factored out of all advance location
58 instructions. */
59 ULONGEST code_alignment_factor;
60
61 /* Constants that is factored out of all offset instructions. */
62 LONGEST data_alignment_factor;
63
64 /* Return address column. */
65 ULONGEST return_address_register;
66
67 /* Instruction sequence to initialize a register set. */
852483bc
MK
68 gdb_byte *initial_instructions;
69 gdb_byte *end;
cfc14b3a 70
303b6f5d
DJ
71 /* Saved augmentation, in case it's needed later. */
72 char *augmentation;
73
cfc14b3a 74 /* Encoding of addresses. */
852483bc 75 gdb_byte encoding;
cfc14b3a 76
ae0d2f24
UW
77 /* Target address size in bytes. */
78 int addr_size;
79
7131cb6e
RH
80 /* True if a 'z' augmentation existed. */
81 unsigned char saw_z_augmentation;
82
56c987f6
AO
83 /* True if an 'S' augmentation existed. */
84 unsigned char signal_frame;
85
303b6f5d
DJ
86 /* The version recorded in the CIE. */
87 unsigned char version;
2dc7f7b3
TT
88
89 /* The segment size. */
90 unsigned char segment_size;
b01c8410 91};
303b6f5d 92
b01c8410
PP
93struct dwarf2_cie_table
94{
95 int num_entries;
96 struct dwarf2_cie **entries;
cfc14b3a
MK
97};
98
99/* Frame Description Entry (FDE). */
100
101struct dwarf2_fde
102{
103 /* CIE for this FDE. */
104 struct dwarf2_cie *cie;
105
106 /* First location associated with this FDE. */
107 CORE_ADDR initial_location;
108
109 /* Number of bytes of program instructions described by this FDE. */
110 CORE_ADDR address_range;
111
112 /* Instruction sequence. */
852483bc
MK
113 gdb_byte *instructions;
114 gdb_byte *end;
cfc14b3a 115
4bf8967c
AS
116 /* True if this FDE is read from a .eh_frame instead of a .debug_frame
117 section. */
118 unsigned char eh_frame_p;
b01c8410 119};
4bf8967c 120
b01c8410
PP
121struct dwarf2_fde_table
122{
123 int num_entries;
124 struct dwarf2_fde **entries;
cfc14b3a
MK
125};
126
ae0d2f24
UW
127/* A minimal decoding of DWARF2 compilation units. We only decode
128 what's needed to get to the call frame information. */
129
130struct comp_unit
131{
132 /* Keep the bfd convenient. */
133 bfd *abfd;
134
135 struct objfile *objfile;
136
ae0d2f24
UW
137 /* Pointer to the .debug_frame section loaded into memory. */
138 gdb_byte *dwarf_frame_buffer;
139
140 /* Length of the loaded .debug_frame section. */
c098b58b 141 bfd_size_type dwarf_frame_size;
ae0d2f24
UW
142
143 /* Pointer to the .debug_frame section. */
144 asection *dwarf_frame_section;
145
146 /* Base for DW_EH_PE_datarel encodings. */
147 bfd_vma dbase;
148
149 /* Base for DW_EH_PE_textrel encodings. */
150 bfd_vma tbase;
151};
152
cfc14b3a 153static struct dwarf2_fde *dwarf2_frame_find_fde (CORE_ADDR *pc);
4fc771b8
DJ
154
155static int dwarf2_frame_adjust_regnum (struct gdbarch *gdbarch, int regnum,
156 int eh_frame_p);
ae0d2f24
UW
157
158static CORE_ADDR read_encoded_value (struct comp_unit *unit, gdb_byte encoding,
159 int ptr_len, gdb_byte *buf,
160 unsigned int *bytes_read_ptr,
161 CORE_ADDR func_base);
cfc14b3a
MK
162\f
163
164/* Structure describing a frame state. */
165
166struct dwarf2_frame_state
167{
168 /* Each register save state can be described in terms of a CFA slot,
169 another register, or a location expression. */
170 struct dwarf2_frame_state_reg_info
171 {
05cbe71a 172 struct dwarf2_frame_state_reg *reg;
cfc14b3a
MK
173 int num_regs;
174
2fd481e1
PP
175 LONGEST cfa_offset;
176 ULONGEST cfa_reg;
177 enum {
178 CFA_UNSET,
179 CFA_REG_OFFSET,
180 CFA_EXP
181 } cfa_how;
182 gdb_byte *cfa_exp;
183
cfc14b3a
MK
184 /* Used to implement DW_CFA_remember_state. */
185 struct dwarf2_frame_state_reg_info *prev;
186 } regs;
187
cfc14b3a
MK
188 /* The PC described by the current frame state. */
189 CORE_ADDR pc;
190
191 /* Initial register set from the CIE.
192 Used to implement DW_CFA_restore. */
193 struct dwarf2_frame_state_reg_info initial;
194
195 /* The information we care about from the CIE. */
196 LONGEST data_align;
197 ULONGEST code_align;
198 ULONGEST retaddr_column;
303b6f5d
DJ
199
200 /* Flags for known producer quirks. */
201
202 /* The ARM compilers, in DWARF2 mode, assume that DW_CFA_def_cfa
203 and DW_CFA_def_cfa_offset takes a factored offset. */
204 int armcc_cfa_offsets_sf;
205
206 /* The ARM compilers, in DWARF2 or DWARF3 mode, may assume that
207 the CFA is defined as REG - OFFSET rather than REG + OFFSET. */
208 int armcc_cfa_offsets_reversed;
cfc14b3a
MK
209};
210
211/* Store the length the expression for the CFA in the `cfa_reg' field,
212 which is unused in that case. */
213#define cfa_exp_len cfa_reg
214
f57d151a 215/* Assert that the register set RS is large enough to store gdbarch_num_regs
cfc14b3a
MK
216 columns. If necessary, enlarge the register set. */
217
218static void
219dwarf2_frame_state_alloc_regs (struct dwarf2_frame_state_reg_info *rs,
220 int num_regs)
221{
222 size_t size = sizeof (struct dwarf2_frame_state_reg);
223
224 if (num_regs <= rs->num_regs)
225 return;
226
227 rs->reg = (struct dwarf2_frame_state_reg *)
228 xrealloc (rs->reg, num_regs * size);
229
230 /* Initialize newly allocated registers. */
2473a4a9 231 memset (rs->reg + rs->num_regs, 0, (num_regs - rs->num_regs) * size);
cfc14b3a
MK
232 rs->num_regs = num_regs;
233}
234
235/* Copy the register columns in register set RS into newly allocated
236 memory and return a pointer to this newly created copy. */
237
238static struct dwarf2_frame_state_reg *
239dwarf2_frame_state_copy_regs (struct dwarf2_frame_state_reg_info *rs)
240{
d10891d4 241 size_t size = rs->num_regs * sizeof (struct dwarf2_frame_state_reg);
cfc14b3a
MK
242 struct dwarf2_frame_state_reg *reg;
243
244 reg = (struct dwarf2_frame_state_reg *) xmalloc (size);
245 memcpy (reg, rs->reg, size);
246
247 return reg;
248}
249
250/* Release the memory allocated to register set RS. */
251
252static void
253dwarf2_frame_state_free_regs (struct dwarf2_frame_state_reg_info *rs)
254{
255 if (rs)
256 {
257 dwarf2_frame_state_free_regs (rs->prev);
258
259 xfree (rs->reg);
260 xfree (rs);
261 }
262}
263
264/* Release the memory allocated to the frame state FS. */
265
266static void
267dwarf2_frame_state_free (void *p)
268{
269 struct dwarf2_frame_state *fs = p;
270
271 dwarf2_frame_state_free_regs (fs->initial.prev);
272 dwarf2_frame_state_free_regs (fs->regs.prev);
273 xfree (fs->initial.reg);
274 xfree (fs->regs.reg);
275 xfree (fs);
276}
277\f
278
279/* Helper functions for execute_stack_op. */
280
281static CORE_ADDR
282read_reg (void *baton, int reg)
283{
4a4e5149
DJ
284 struct frame_info *this_frame = (struct frame_info *) baton;
285 struct gdbarch *gdbarch = get_frame_arch (this_frame);
cfc14b3a 286 int regnum;
852483bc 287 gdb_byte *buf;
cfc14b3a 288
ad010def 289 regnum = gdbarch_dwarf2_reg_to_regnum (gdbarch, reg);
cfc14b3a 290
852483bc 291 buf = alloca (register_size (gdbarch, regnum));
4a4e5149 292 get_frame_register (this_frame, regnum, buf);
f2da6b3a
DJ
293
294 /* Convert the register to an integer. This returns a LONGEST
295 rather than a CORE_ADDR, but unpack_pointer does the same thing
296 under the covers, and this makes more sense for non-pointer
297 registers. Maybe read_reg and the associated interfaces should
298 deal with "struct value" instead of CORE_ADDR. */
299 return unpack_long (register_type (gdbarch, regnum), buf);
cfc14b3a
MK
300}
301
302static void
852483bc 303read_mem (void *baton, gdb_byte *buf, CORE_ADDR addr, size_t len)
cfc14b3a
MK
304{
305 read_memory (addr, buf, len);
306}
307
308static void
852483bc 309no_get_frame_base (void *baton, gdb_byte **start, size_t *length)
cfc14b3a
MK
310{
311 internal_error (__FILE__, __LINE__,
e2e0b3e5 312 _("Support for DW_OP_fbreg is unimplemented"));
cfc14b3a
MK
313}
314
e7802207
TT
315/* Helper function for execute_stack_op. */
316
317static CORE_ADDR
318no_get_frame_cfa (void *baton)
319{
320 internal_error (__FILE__, __LINE__,
321 _("Support for DW_OP_call_frame_cfa is unimplemented"));
322}
323
cfc14b3a
MK
324static CORE_ADDR
325no_get_tls_address (void *baton, CORE_ADDR offset)
326{
327 internal_error (__FILE__, __LINE__,
e2e0b3e5 328 _("Support for DW_OP_GNU_push_tls_address is unimplemented"));
cfc14b3a
MK
329}
330
a6a5a945
LM
331/* Execute the required actions for both the DW_CFA_restore and
332DW_CFA_restore_extended instructions. */
333static void
334dwarf2_restore_rule (struct gdbarch *gdbarch, ULONGEST reg_num,
335 struct dwarf2_frame_state *fs, int eh_frame_p)
336{
337 ULONGEST reg;
338
339 gdb_assert (fs->initial.reg);
340 reg = dwarf2_frame_adjust_regnum (gdbarch, reg_num, eh_frame_p);
341 dwarf2_frame_state_alloc_regs (&fs->regs, reg + 1);
342
343 /* Check if this register was explicitly initialized in the
344 CIE initial instructions. If not, default the rule to
345 UNSPECIFIED. */
346 if (reg < fs->initial.num_regs)
347 fs->regs.reg[reg] = fs->initial.reg[reg];
348 else
349 fs->regs.reg[reg].how = DWARF2_FRAME_REG_UNSPECIFIED;
350
351 if (fs->regs.reg[reg].how == DWARF2_FRAME_REG_UNSPECIFIED)
352 complaint (&symfile_complaints, _("\
353incomplete CFI data; DW_CFA_restore unspecified\n\
5af949e3 354register %s (#%d) at %s"),
a6a5a945
LM
355 gdbarch_register_name
356 (gdbarch, gdbarch_dwarf2_reg_to_regnum (gdbarch, reg)),
357 gdbarch_dwarf2_reg_to_regnum (gdbarch, reg),
5af949e3 358 paddress (gdbarch, fs->pc));
a6a5a945
LM
359}
360
cfc14b3a 361static CORE_ADDR
ae0d2f24 362execute_stack_op (gdb_byte *exp, ULONGEST len, int addr_size,
44353522
DE
363 struct frame_info *this_frame, CORE_ADDR initial,
364 int initial_in_stack_memory)
cfc14b3a
MK
365{
366 struct dwarf_expr_context *ctx;
367 CORE_ADDR result;
4a227398 368 struct cleanup *old_chain;
cfc14b3a
MK
369
370 ctx = new_dwarf_expr_context ();
4a227398
TT
371 old_chain = make_cleanup_free_dwarf_expr_context (ctx);
372
f7fd4728 373 ctx->gdbarch = get_frame_arch (this_frame);
ae0d2f24 374 ctx->addr_size = addr_size;
4a4e5149 375 ctx->baton = this_frame;
cfc14b3a
MK
376 ctx->read_reg = read_reg;
377 ctx->read_mem = read_mem;
378 ctx->get_frame_base = no_get_frame_base;
e7802207 379 ctx->get_frame_cfa = no_get_frame_cfa;
cfc14b3a
MK
380 ctx->get_tls_address = no_get_tls_address;
381
44353522 382 dwarf_expr_push (ctx, initial, initial_in_stack_memory);
cfc14b3a
MK
383 dwarf_expr_eval (ctx, exp, len);
384 result = dwarf_expr_fetch (ctx, 0);
385
cec03d70 386 if (ctx->location == DWARF_VALUE_REGISTER)
4a4e5149 387 result = read_reg (this_frame, result);
cec03d70
TT
388 else if (ctx->location != DWARF_VALUE_MEMORY)
389 {
390 /* This is actually invalid DWARF, but if we ever do run across
391 it somehow, we might as well support it. So, instead, report
392 it as unimplemented. */
393 error (_("Not implemented: computing unwound register using explicit value operator"));
394 }
cfc14b3a 395
4a227398 396 do_cleanups (old_chain);
cfc14b3a
MK
397
398 return result;
399}
400\f
401
402static void
ae0d2f24 403execute_cfa_program (struct dwarf2_fde *fde, gdb_byte *insn_ptr,
4a4e5149 404 gdb_byte *insn_end, struct frame_info *this_frame,
ae0d2f24 405 struct dwarf2_frame_state *fs)
cfc14b3a 406{
ae0d2f24 407 int eh_frame_p = fde->eh_frame_p;
4a4e5149 408 CORE_ADDR pc = get_frame_pc (this_frame);
cfc14b3a 409 int bytes_read;
4a4e5149 410 struct gdbarch *gdbarch = get_frame_arch (this_frame);
e17a4113 411 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
cfc14b3a
MK
412
413 while (insn_ptr < insn_end && fs->pc <= pc)
414 {
852483bc 415 gdb_byte insn = *insn_ptr++;
cfc14b3a
MK
416 ULONGEST utmp, reg;
417 LONGEST offset;
418
419 if ((insn & 0xc0) == DW_CFA_advance_loc)
420 fs->pc += (insn & 0x3f) * fs->code_align;
421 else if ((insn & 0xc0) == DW_CFA_offset)
422 {
423 reg = insn & 0x3f;
4fc771b8 424 reg = dwarf2_frame_adjust_regnum (gdbarch, reg, eh_frame_p);
cfc14b3a
MK
425 insn_ptr = read_uleb128 (insn_ptr, insn_end, &utmp);
426 offset = utmp * fs->data_align;
427 dwarf2_frame_state_alloc_regs (&fs->regs, reg + 1);
05cbe71a 428 fs->regs.reg[reg].how = DWARF2_FRAME_REG_SAVED_OFFSET;
cfc14b3a
MK
429 fs->regs.reg[reg].loc.offset = offset;
430 }
431 else if ((insn & 0xc0) == DW_CFA_restore)
432 {
cfc14b3a 433 reg = insn & 0x3f;
a6a5a945 434 dwarf2_restore_rule (gdbarch, reg, fs, eh_frame_p);
cfc14b3a
MK
435 }
436 else
437 {
438 switch (insn)
439 {
440 case DW_CFA_set_loc:
ae0d2f24
UW
441 fs->pc = read_encoded_value (fde->cie->unit, fde->cie->encoding,
442 fde->cie->addr_size, insn_ptr,
443 &bytes_read, fde->initial_location);
444 /* Apply the objfile offset for relocatable objects. */
445 fs->pc += ANOFFSET (fde->cie->unit->objfile->section_offsets,
446 SECT_OFF_TEXT (fde->cie->unit->objfile));
cfc14b3a
MK
447 insn_ptr += bytes_read;
448 break;
449
450 case DW_CFA_advance_loc1:
e17a4113 451 utmp = extract_unsigned_integer (insn_ptr, 1, byte_order);
cfc14b3a
MK
452 fs->pc += utmp * fs->code_align;
453 insn_ptr++;
454 break;
455 case DW_CFA_advance_loc2:
e17a4113 456 utmp = extract_unsigned_integer (insn_ptr, 2, byte_order);
cfc14b3a
MK
457 fs->pc += utmp * fs->code_align;
458 insn_ptr += 2;
459 break;
460 case DW_CFA_advance_loc4:
e17a4113 461 utmp = extract_unsigned_integer (insn_ptr, 4, byte_order);
cfc14b3a
MK
462 fs->pc += utmp * fs->code_align;
463 insn_ptr += 4;
464 break;
465
466 case DW_CFA_offset_extended:
467 insn_ptr = read_uleb128 (insn_ptr, insn_end, &reg);
4fc771b8 468 reg = dwarf2_frame_adjust_regnum (gdbarch, reg, eh_frame_p);
cfc14b3a
MK
469 insn_ptr = read_uleb128 (insn_ptr, insn_end, &utmp);
470 offset = utmp * fs->data_align;
471 dwarf2_frame_state_alloc_regs (&fs->regs, reg + 1);
05cbe71a 472 fs->regs.reg[reg].how = DWARF2_FRAME_REG_SAVED_OFFSET;
cfc14b3a
MK
473 fs->regs.reg[reg].loc.offset = offset;
474 break;
475
476 case DW_CFA_restore_extended:
cfc14b3a 477 insn_ptr = read_uleb128 (insn_ptr, insn_end, &reg);
a6a5a945 478 dwarf2_restore_rule (gdbarch, reg, fs, eh_frame_p);
cfc14b3a
MK
479 break;
480
481 case DW_CFA_undefined:
482 insn_ptr = read_uleb128 (insn_ptr, insn_end, &reg);
4fc771b8 483 reg = dwarf2_frame_adjust_regnum (gdbarch, reg, eh_frame_p);
cfc14b3a 484 dwarf2_frame_state_alloc_regs (&fs->regs, reg + 1);
05cbe71a 485 fs->regs.reg[reg].how = DWARF2_FRAME_REG_UNDEFINED;
cfc14b3a
MK
486 break;
487
488 case DW_CFA_same_value:
489 insn_ptr = read_uleb128 (insn_ptr, insn_end, &reg);
4fc771b8 490 reg = dwarf2_frame_adjust_regnum (gdbarch, reg, eh_frame_p);
cfc14b3a 491 dwarf2_frame_state_alloc_regs (&fs->regs, reg + 1);
05cbe71a 492 fs->regs.reg[reg].how = DWARF2_FRAME_REG_SAME_VALUE;
cfc14b3a
MK
493 break;
494
495 case DW_CFA_register:
496 insn_ptr = read_uleb128 (insn_ptr, insn_end, &reg);
4fc771b8 497 reg = dwarf2_frame_adjust_regnum (gdbarch, reg, eh_frame_p);
cfc14b3a 498 insn_ptr = read_uleb128 (insn_ptr, insn_end, &utmp);
4fc771b8 499 utmp = dwarf2_frame_adjust_regnum (gdbarch, utmp, eh_frame_p);
cfc14b3a 500 dwarf2_frame_state_alloc_regs (&fs->regs, reg + 1);
05cbe71a 501 fs->regs.reg[reg].how = DWARF2_FRAME_REG_SAVED_REG;
cfc14b3a
MK
502 fs->regs.reg[reg].loc.reg = utmp;
503 break;
504
505 case DW_CFA_remember_state:
506 {
507 struct dwarf2_frame_state_reg_info *new_rs;
508
509 new_rs = XMALLOC (struct dwarf2_frame_state_reg_info);
510 *new_rs = fs->regs;
511 fs->regs.reg = dwarf2_frame_state_copy_regs (&fs->regs);
512 fs->regs.prev = new_rs;
513 }
514 break;
515
516 case DW_CFA_restore_state:
517 {
518 struct dwarf2_frame_state_reg_info *old_rs = fs->regs.prev;
519
50ea7769
MK
520 if (old_rs == NULL)
521 {
e2e0b3e5 522 complaint (&symfile_complaints, _("\
5af949e3
UW
523bad CFI data; mismatched DW_CFA_restore_state at %s"),
524 paddress (gdbarch, fs->pc));
50ea7769
MK
525 }
526 else
527 {
528 xfree (fs->regs.reg);
529 fs->regs = *old_rs;
530 xfree (old_rs);
531 }
cfc14b3a
MK
532 }
533 break;
534
535 case DW_CFA_def_cfa:
2fd481e1 536 insn_ptr = read_uleb128 (insn_ptr, insn_end, &fs->regs.cfa_reg);
cfc14b3a 537 insn_ptr = read_uleb128 (insn_ptr, insn_end, &utmp);
303b6f5d
DJ
538
539 if (fs->armcc_cfa_offsets_sf)
540 utmp *= fs->data_align;
541
2fd481e1
PP
542 fs->regs.cfa_offset = utmp;
543 fs->regs.cfa_how = CFA_REG_OFFSET;
cfc14b3a
MK
544 break;
545
546 case DW_CFA_def_cfa_register:
2fd481e1
PP
547 insn_ptr = read_uleb128 (insn_ptr, insn_end, &fs->regs.cfa_reg);
548 fs->regs.cfa_reg = dwarf2_frame_adjust_regnum (gdbarch,
549 fs->regs.cfa_reg,
550 eh_frame_p);
551 fs->regs.cfa_how = CFA_REG_OFFSET;
cfc14b3a
MK
552 break;
553
554 case DW_CFA_def_cfa_offset:
852483bc 555 insn_ptr = read_uleb128 (insn_ptr, insn_end, &utmp);
303b6f5d
DJ
556
557 if (fs->armcc_cfa_offsets_sf)
558 utmp *= fs->data_align;
559
2fd481e1 560 fs->regs.cfa_offset = utmp;
cfc14b3a
MK
561 /* cfa_how deliberately not set. */
562 break;
563
a8504492
MK
564 case DW_CFA_nop:
565 break;
566
cfc14b3a 567 case DW_CFA_def_cfa_expression:
2fd481e1
PP
568 insn_ptr = read_uleb128 (insn_ptr, insn_end,
569 &fs->regs.cfa_exp_len);
570 fs->regs.cfa_exp = insn_ptr;
571 fs->regs.cfa_how = CFA_EXP;
572 insn_ptr += fs->regs.cfa_exp_len;
cfc14b3a
MK
573 break;
574
575 case DW_CFA_expression:
576 insn_ptr = read_uleb128 (insn_ptr, insn_end, &reg);
4fc771b8 577 reg = dwarf2_frame_adjust_regnum (gdbarch, reg, eh_frame_p);
cfc14b3a
MK
578 dwarf2_frame_state_alloc_regs (&fs->regs, reg + 1);
579 insn_ptr = read_uleb128 (insn_ptr, insn_end, &utmp);
580 fs->regs.reg[reg].loc.exp = insn_ptr;
581 fs->regs.reg[reg].exp_len = utmp;
05cbe71a 582 fs->regs.reg[reg].how = DWARF2_FRAME_REG_SAVED_EXP;
cfc14b3a
MK
583 insn_ptr += utmp;
584 break;
585
a8504492
MK
586 case DW_CFA_offset_extended_sf:
587 insn_ptr = read_uleb128 (insn_ptr, insn_end, &reg);
4fc771b8 588 reg = dwarf2_frame_adjust_regnum (gdbarch, reg, eh_frame_p);
a8504492 589 insn_ptr = read_sleb128 (insn_ptr, insn_end, &offset);
f6da8dd8 590 offset *= fs->data_align;
a8504492 591 dwarf2_frame_state_alloc_regs (&fs->regs, reg + 1);
05cbe71a 592 fs->regs.reg[reg].how = DWARF2_FRAME_REG_SAVED_OFFSET;
a8504492
MK
593 fs->regs.reg[reg].loc.offset = offset;
594 break;
595
46ea248b
AO
596 case DW_CFA_val_offset:
597 insn_ptr = read_uleb128 (insn_ptr, insn_end, &reg);
598 dwarf2_frame_state_alloc_regs (&fs->regs, reg + 1);
599 insn_ptr = read_uleb128 (insn_ptr, insn_end, &utmp);
600 offset = utmp * fs->data_align;
601 fs->regs.reg[reg].how = DWARF2_FRAME_REG_SAVED_VAL_OFFSET;
602 fs->regs.reg[reg].loc.offset = offset;
603 break;
604
605 case DW_CFA_val_offset_sf:
606 insn_ptr = read_uleb128 (insn_ptr, insn_end, &reg);
607 dwarf2_frame_state_alloc_regs (&fs->regs, reg + 1);
608 insn_ptr = read_sleb128 (insn_ptr, insn_end, &offset);
609 offset *= fs->data_align;
610 fs->regs.reg[reg].how = DWARF2_FRAME_REG_SAVED_VAL_OFFSET;
611 fs->regs.reg[reg].loc.offset = offset;
612 break;
613
614 case DW_CFA_val_expression:
615 insn_ptr = read_uleb128 (insn_ptr, insn_end, &reg);
616 dwarf2_frame_state_alloc_regs (&fs->regs, reg + 1);
617 insn_ptr = read_uleb128 (insn_ptr, insn_end, &utmp);
618 fs->regs.reg[reg].loc.exp = insn_ptr;
619 fs->regs.reg[reg].exp_len = utmp;
620 fs->regs.reg[reg].how = DWARF2_FRAME_REG_SAVED_VAL_EXP;
621 insn_ptr += utmp;
622 break;
623
a8504492 624 case DW_CFA_def_cfa_sf:
2fd481e1
PP
625 insn_ptr = read_uleb128 (insn_ptr, insn_end, &fs->regs.cfa_reg);
626 fs->regs.cfa_reg = dwarf2_frame_adjust_regnum (gdbarch,
627 fs->regs.cfa_reg,
628 eh_frame_p);
a8504492 629 insn_ptr = read_sleb128 (insn_ptr, insn_end, &offset);
2fd481e1
PP
630 fs->regs.cfa_offset = offset * fs->data_align;
631 fs->regs.cfa_how = CFA_REG_OFFSET;
a8504492
MK
632 break;
633
634 case DW_CFA_def_cfa_offset_sf:
635 insn_ptr = read_sleb128 (insn_ptr, insn_end, &offset);
2fd481e1 636 fs->regs.cfa_offset = offset * fs->data_align;
a8504492 637 /* cfa_how deliberately not set. */
cfc14b3a
MK
638 break;
639
a77f4086
MK
640 case DW_CFA_GNU_window_save:
641 /* This is SPARC-specific code, and contains hard-coded
642 constants for the register numbering scheme used by
643 GCC. Rather than having a architecture-specific
644 operation that's only ever used by a single
645 architecture, we provide the implementation here.
646 Incidentally that's what GCC does too in its
647 unwinder. */
648 {
4a4e5149 649 int size = register_size (gdbarch, 0);
a77f4086
MK
650 dwarf2_frame_state_alloc_regs (&fs->regs, 32);
651 for (reg = 8; reg < 16; reg++)
652 {
653 fs->regs.reg[reg].how = DWARF2_FRAME_REG_SAVED_REG;
654 fs->regs.reg[reg].loc.reg = reg + 16;
655 }
656 for (reg = 16; reg < 32; reg++)
657 {
658 fs->regs.reg[reg].how = DWARF2_FRAME_REG_SAVED_OFFSET;
659 fs->regs.reg[reg].loc.offset = (reg - 16) * size;
660 }
661 }
662 break;
663
cfc14b3a
MK
664 case DW_CFA_GNU_args_size:
665 /* Ignored. */
666 insn_ptr = read_uleb128 (insn_ptr, insn_end, &utmp);
667 break;
668
58894217
JK
669 case DW_CFA_GNU_negative_offset_extended:
670 insn_ptr = read_uleb128 (insn_ptr, insn_end, &reg);
4fc771b8 671 reg = dwarf2_frame_adjust_regnum (gdbarch, reg, eh_frame_p);
58894217
JK
672 insn_ptr = read_uleb128 (insn_ptr, insn_end, &offset);
673 offset *= fs->data_align;
674 dwarf2_frame_state_alloc_regs (&fs->regs, reg + 1);
675 fs->regs.reg[reg].how = DWARF2_FRAME_REG_SAVED_OFFSET;
676 fs->regs.reg[reg].loc.offset = -offset;
677 break;
678
cfc14b3a 679 default:
e2e0b3e5 680 internal_error (__FILE__, __LINE__, _("Unknown CFI encountered."));
cfc14b3a
MK
681 }
682 }
683 }
684
685 /* Don't allow remember/restore between CIE and FDE programs. */
686 dwarf2_frame_state_free_regs (fs->regs.prev);
687 fs->regs.prev = NULL;
688}
8f22cb90 689\f
cfc14b3a 690
8f22cb90 691/* Architecture-specific operations. */
cfc14b3a 692
8f22cb90
MK
693/* Per-architecture data key. */
694static struct gdbarch_data *dwarf2_frame_data;
695
696struct dwarf2_frame_ops
697{
698 /* Pre-initialize the register state REG for register REGNUM. */
aff37fc1
DM
699 void (*init_reg) (struct gdbarch *, int, struct dwarf2_frame_state_reg *,
700 struct frame_info *);
3ed09a32 701
4a4e5149 702 /* Check whether the THIS_FRAME is a signal trampoline. */
3ed09a32 703 int (*signal_frame_p) (struct gdbarch *, struct frame_info *);
4bf8967c 704
4fc771b8
DJ
705 /* Convert .eh_frame register number to DWARF register number, or
706 adjust .debug_frame register number. */
707 int (*adjust_regnum) (struct gdbarch *, int, int);
cfc14b3a
MK
708};
709
8f22cb90
MK
710/* Default architecture-specific register state initialization
711 function. */
712
713static void
714dwarf2_frame_default_init_reg (struct gdbarch *gdbarch, int regnum,
aff37fc1 715 struct dwarf2_frame_state_reg *reg,
4a4e5149 716 struct frame_info *this_frame)
8f22cb90
MK
717{
718 /* If we have a register that acts as a program counter, mark it as
719 a destination for the return address. If we have a register that
720 serves as the stack pointer, arrange for it to be filled with the
721 call frame address (CFA). The other registers are marked as
722 unspecified.
723
724 We copy the return address to the program counter, since many
725 parts in GDB assume that it is possible to get the return address
726 by unwinding the program counter register. However, on ISA's
727 with a dedicated return address register, the CFI usually only
728 contains information to unwind that return address register.
729
730 The reason we're treating the stack pointer special here is
731 because in many cases GCC doesn't emit CFI for the stack pointer
732 and implicitly assumes that it is equal to the CFA. This makes
733 some sense since the DWARF specification (version 3, draft 8,
734 p. 102) says that:
735
736 "Typically, the CFA is defined to be the value of the stack
737 pointer at the call site in the previous frame (which may be
738 different from its value on entry to the current frame)."
739
740 However, this isn't true for all platforms supported by GCC
741 (e.g. IBM S/390 and zSeries). Those architectures should provide
742 their own architecture-specific initialization function. */
05cbe71a 743
ad010def 744 if (regnum == gdbarch_pc_regnum (gdbarch))
8f22cb90 745 reg->how = DWARF2_FRAME_REG_RA;
ad010def 746 else if (regnum == gdbarch_sp_regnum (gdbarch))
8f22cb90
MK
747 reg->how = DWARF2_FRAME_REG_CFA;
748}
05cbe71a 749
8f22cb90 750/* Return a default for the architecture-specific operations. */
05cbe71a 751
8f22cb90 752static void *
030f20e1 753dwarf2_frame_init (struct obstack *obstack)
8f22cb90
MK
754{
755 struct dwarf2_frame_ops *ops;
756
030f20e1 757 ops = OBSTACK_ZALLOC (obstack, struct dwarf2_frame_ops);
8f22cb90
MK
758 ops->init_reg = dwarf2_frame_default_init_reg;
759 return ops;
760}
05cbe71a 761
8f22cb90
MK
762/* Set the architecture-specific register state initialization
763 function for GDBARCH to INIT_REG. */
764
765void
766dwarf2_frame_set_init_reg (struct gdbarch *gdbarch,
767 void (*init_reg) (struct gdbarch *, int,
aff37fc1
DM
768 struct dwarf2_frame_state_reg *,
769 struct frame_info *))
8f22cb90 770{
030f20e1 771 struct dwarf2_frame_ops *ops = gdbarch_data (gdbarch, dwarf2_frame_data);
8f22cb90 772
8f22cb90
MK
773 ops->init_reg = init_reg;
774}
775
776/* Pre-initialize the register state REG for register REGNUM. */
05cbe71a
MK
777
778static void
779dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
aff37fc1 780 struct dwarf2_frame_state_reg *reg,
4a4e5149 781 struct frame_info *this_frame)
05cbe71a 782{
030f20e1 783 struct dwarf2_frame_ops *ops = gdbarch_data (gdbarch, dwarf2_frame_data);
8f22cb90 784
4a4e5149 785 ops->init_reg (gdbarch, regnum, reg, this_frame);
05cbe71a 786}
3ed09a32
DJ
787
788/* Set the architecture-specific signal trampoline recognition
789 function for GDBARCH to SIGNAL_FRAME_P. */
790
791void
792dwarf2_frame_set_signal_frame_p (struct gdbarch *gdbarch,
793 int (*signal_frame_p) (struct gdbarch *,
794 struct frame_info *))
795{
796 struct dwarf2_frame_ops *ops = gdbarch_data (gdbarch, dwarf2_frame_data);
797
798 ops->signal_frame_p = signal_frame_p;
799}
800
801/* Query the architecture-specific signal frame recognizer for
4a4e5149 802 THIS_FRAME. */
3ed09a32
DJ
803
804static int
805dwarf2_frame_signal_frame_p (struct gdbarch *gdbarch,
4a4e5149 806 struct frame_info *this_frame)
3ed09a32
DJ
807{
808 struct dwarf2_frame_ops *ops = gdbarch_data (gdbarch, dwarf2_frame_data);
809
810 if (ops->signal_frame_p == NULL)
811 return 0;
4a4e5149 812 return ops->signal_frame_p (gdbarch, this_frame);
3ed09a32 813}
4bf8967c 814
4fc771b8
DJ
815/* Set the architecture-specific adjustment of .eh_frame and .debug_frame
816 register numbers. */
4bf8967c
AS
817
818void
4fc771b8
DJ
819dwarf2_frame_set_adjust_regnum (struct gdbarch *gdbarch,
820 int (*adjust_regnum) (struct gdbarch *,
821 int, int))
4bf8967c
AS
822{
823 struct dwarf2_frame_ops *ops = gdbarch_data (gdbarch, dwarf2_frame_data);
824
4fc771b8 825 ops->adjust_regnum = adjust_regnum;
4bf8967c
AS
826}
827
4fc771b8
DJ
828/* Translate a .eh_frame register to DWARF register, or adjust a .debug_frame
829 register. */
4bf8967c 830
4fc771b8
DJ
831static int
832dwarf2_frame_adjust_regnum (struct gdbarch *gdbarch, int regnum, int eh_frame_p)
4bf8967c
AS
833{
834 struct dwarf2_frame_ops *ops = gdbarch_data (gdbarch, dwarf2_frame_data);
835
4fc771b8 836 if (ops->adjust_regnum == NULL)
4bf8967c 837 return regnum;
4fc771b8 838 return ops->adjust_regnum (gdbarch, regnum, eh_frame_p);
4bf8967c 839}
303b6f5d
DJ
840
841static void
842dwarf2_frame_find_quirks (struct dwarf2_frame_state *fs,
843 struct dwarf2_fde *fde)
844{
303b6f5d
DJ
845 struct symtab *s;
846
847 s = find_pc_symtab (fs->pc);
a6c727b2 848 if (s == NULL)
303b6f5d
DJ
849 return;
850
a6c727b2
DJ
851 if (producer_is_realview (s->producer))
852 {
853 if (fde->cie->version == 1)
854 fs->armcc_cfa_offsets_sf = 1;
855
856 if (fde->cie->version == 1)
857 fs->armcc_cfa_offsets_reversed = 1;
858
859 /* The reversed offset problem is present in some compilers
860 using DWARF3, but it was eventually fixed. Check the ARM
861 defined augmentations, which are in the format "armcc" followed
862 by a list of one-character options. The "+" option means
863 this problem is fixed (no quirk needed). If the armcc
864 augmentation is missing, the quirk is needed. */
865 if (fde->cie->version == 3
866 && (strncmp (fde->cie->augmentation, "armcc", 5) != 0
867 || strchr (fde->cie->augmentation + 5, '+') == NULL))
868 fs->armcc_cfa_offsets_reversed = 1;
869
870 return;
871 }
303b6f5d 872}
8f22cb90
MK
873\f
874
875struct dwarf2_frame_cache
876{
877 /* DWARF Call Frame Address. */
878 CORE_ADDR cfa;
879
0228dfb9
DJ
880 /* Set if the return address column was marked as undefined. */
881 int undefined_retaddr;
882
8f22cb90
MK
883 /* Saved registers, indexed by GDB register number, not by DWARF
884 register number. */
885 struct dwarf2_frame_state_reg *reg;
8d5a9abc
MK
886
887 /* Return address register. */
888 struct dwarf2_frame_state_reg retaddr_reg;
ae0d2f24
UW
889
890 /* Target address size in bytes. */
891 int addr_size;
8f22cb90 892};
05cbe71a 893
b9362cc7 894static struct dwarf2_frame_cache *
4a4e5149 895dwarf2_frame_cache (struct frame_info *this_frame, void **this_cache)
cfc14b3a
MK
896{
897 struct cleanup *old_chain;
4a4e5149 898 struct gdbarch *gdbarch = get_frame_arch (this_frame);
ad010def
UW
899 const int num_regs = gdbarch_num_regs (gdbarch)
900 + gdbarch_num_pseudo_regs (gdbarch);
cfc14b3a
MK
901 struct dwarf2_frame_cache *cache;
902 struct dwarf2_frame_state *fs;
903 struct dwarf2_fde *fde;
cfc14b3a
MK
904
905 if (*this_cache)
906 return *this_cache;
907
908 /* Allocate a new cache. */
909 cache = FRAME_OBSTACK_ZALLOC (struct dwarf2_frame_cache);
910 cache->reg = FRAME_OBSTACK_CALLOC (num_regs, struct dwarf2_frame_state_reg);
911
912 /* Allocate and initialize the frame state. */
913 fs = XMALLOC (struct dwarf2_frame_state);
914 memset (fs, 0, sizeof (struct dwarf2_frame_state));
915 old_chain = make_cleanup (dwarf2_frame_state_free, fs);
916
917 /* Unwind the PC.
918
4a4e5149 919 Note that if the next frame is never supposed to return (i.e. a call
cfc14b3a 920 to abort), the compiler might optimize away the instruction at
4a4e5149 921 its return address. As a result the return address will
cfc14b3a 922 point at some random instruction, and the CFI for that
e4e9607c 923 instruction is probably worthless to us. GCC's unwinder solves
cfc14b3a
MK
924 this problem by substracting 1 from the return address to get an
925 address in the middle of a presumed call instruction (or the
926 instruction in the associated delay slot). This should only be
927 done for "normal" frames and not for resume-type frames (signal
e4e9607c 928 handlers, sentinel frames, dummy frames). The function
ad1193e7 929 get_frame_address_in_block does just this. It's not clear how
e4e9607c
MK
930 reliable the method is though; there is the potential for the
931 register state pre-call being different to that on return. */
4a4e5149 932 fs->pc = get_frame_address_in_block (this_frame);
cfc14b3a
MK
933
934 /* Find the correct FDE. */
935 fde = dwarf2_frame_find_fde (&fs->pc);
936 gdb_assert (fde != NULL);
937
938 /* Extract any interesting information from the CIE. */
939 fs->data_align = fde->cie->data_alignment_factor;
940 fs->code_align = fde->cie->code_alignment_factor;
941 fs->retaddr_column = fde->cie->return_address_register;
ae0d2f24 942 cache->addr_size = fde->cie->addr_size;
cfc14b3a 943
303b6f5d
DJ
944 /* Check for "quirks" - known bugs in producers. */
945 dwarf2_frame_find_quirks (fs, fde);
946
cfc14b3a 947 /* First decode all the insns in the CIE. */
ae0d2f24 948 execute_cfa_program (fde, fde->cie->initial_instructions,
4a4e5149 949 fde->cie->end, this_frame, fs);
cfc14b3a
MK
950
951 /* Save the initialized register set. */
952 fs->initial = fs->regs;
953 fs->initial.reg = dwarf2_frame_state_copy_regs (&fs->regs);
954
955 /* Then decode the insns in the FDE up to our target PC. */
4a4e5149 956 execute_cfa_program (fde, fde->instructions, fde->end, this_frame, fs);
cfc14b3a 957
938f5214 958 /* Calculate the CFA. */
2fd481e1 959 switch (fs->regs.cfa_how)
cfc14b3a
MK
960 {
961 case CFA_REG_OFFSET:
2fd481e1 962 cache->cfa = read_reg (this_frame, fs->regs.cfa_reg);
303b6f5d 963 if (fs->armcc_cfa_offsets_reversed)
2fd481e1 964 cache->cfa -= fs->regs.cfa_offset;
303b6f5d 965 else
2fd481e1 966 cache->cfa += fs->regs.cfa_offset;
cfc14b3a
MK
967 break;
968
969 case CFA_EXP:
970 cache->cfa =
2fd481e1 971 execute_stack_op (fs->regs.cfa_exp, fs->regs.cfa_exp_len,
44353522 972 cache->addr_size, this_frame, 0, 0);
cfc14b3a
MK
973 break;
974
975 default:
e2e0b3e5 976 internal_error (__FILE__, __LINE__, _("Unknown CFA rule."));
cfc14b3a
MK
977 }
978
05cbe71a 979 /* Initialize the register state. */
3e2c4033
AC
980 {
981 int regnum;
e4e9607c 982
3e2c4033 983 for (regnum = 0; regnum < num_regs; regnum++)
4a4e5149 984 dwarf2_frame_init_reg (gdbarch, regnum, &cache->reg[regnum], this_frame);
3e2c4033
AC
985 }
986
987 /* Go through the DWARF2 CFI generated table and save its register
79c4cb80
MK
988 location information in the cache. Note that we don't skip the
989 return address column; it's perfectly all right for it to
990 correspond to a real register. If it doesn't correspond to a
991 real register, or if we shouldn't treat it as such,
055d23b8 992 gdbarch_dwarf2_reg_to_regnum should be defined to return a number outside
f57d151a 993 the range [0, gdbarch_num_regs). */
3e2c4033
AC
994 {
995 int column; /* CFI speak for "register number". */
e4e9607c 996
3e2c4033
AC
997 for (column = 0; column < fs->regs.num_regs; column++)
998 {
3e2c4033 999 /* Use the GDB register number as the destination index. */
ad010def 1000 int regnum = gdbarch_dwarf2_reg_to_regnum (gdbarch, column);
3e2c4033
AC
1001
1002 /* If there's no corresponding GDB register, ignore it. */
1003 if (regnum < 0 || regnum >= num_regs)
1004 continue;
1005
1006 /* NOTE: cagney/2003-09-05: CFI should specify the disposition
e4e9607c
MK
1007 of all debug info registers. If it doesn't, complain (but
1008 not too loudly). It turns out that GCC assumes that an
3e2c4033
AC
1009 unspecified register implies "same value" when CFI (draft
1010 7) specifies nothing at all. Such a register could equally
1011 be interpreted as "undefined". Also note that this check
e4e9607c
MK
1012 isn't sufficient; it only checks that all registers in the
1013 range [0 .. max column] are specified, and won't detect
3e2c4033 1014 problems when a debug info register falls outside of the
e4e9607c 1015 table. We need a way of iterating through all the valid
3e2c4033 1016 DWARF2 register numbers. */
05cbe71a 1017 if (fs->regs.reg[column].how == DWARF2_FRAME_REG_UNSPECIFIED)
f059bf6f
AC
1018 {
1019 if (cache->reg[regnum].how == DWARF2_FRAME_REG_UNSPECIFIED)
e2e0b3e5 1020 complaint (&symfile_complaints, _("\
5af949e3 1021incomplete CFI data; unspecified registers (e.g., %s) at %s"),
f059bf6f 1022 gdbarch_register_name (gdbarch, regnum),
5af949e3 1023 paddress (gdbarch, fs->pc));
f059bf6f 1024 }
35889917
MK
1025 else
1026 cache->reg[regnum] = fs->regs.reg[column];
3e2c4033
AC
1027 }
1028 }
cfc14b3a 1029
8d5a9abc
MK
1030 /* Eliminate any DWARF2_FRAME_REG_RA rules, and save the information
1031 we need for evaluating DWARF2_FRAME_REG_RA_OFFSET rules. */
35889917
MK
1032 {
1033 int regnum;
1034
1035 for (regnum = 0; regnum < num_regs; regnum++)
1036 {
8d5a9abc
MK
1037 if (cache->reg[regnum].how == DWARF2_FRAME_REG_RA
1038 || cache->reg[regnum].how == DWARF2_FRAME_REG_RA_OFFSET)
35889917 1039 {
05cbe71a
MK
1040 struct dwarf2_frame_state_reg *retaddr_reg =
1041 &fs->regs.reg[fs->retaddr_column];
1042
d4f10bf2
MK
1043 /* It seems rather bizarre to specify an "empty" column as
1044 the return adress column. However, this is exactly
1045 what GCC does on some targets. It turns out that GCC
1046 assumes that the return address can be found in the
1047 register corresponding to the return address column.
8d5a9abc
MK
1048 Incidentally, that's how we should treat a return
1049 address column specifying "same value" too. */
d4f10bf2 1050 if (fs->retaddr_column < fs->regs.num_regs
05cbe71a
MK
1051 && retaddr_reg->how != DWARF2_FRAME_REG_UNSPECIFIED
1052 && retaddr_reg->how != DWARF2_FRAME_REG_SAME_VALUE)
8d5a9abc
MK
1053 {
1054 if (cache->reg[regnum].how == DWARF2_FRAME_REG_RA)
1055 cache->reg[regnum] = *retaddr_reg;
1056 else
1057 cache->retaddr_reg = *retaddr_reg;
1058 }
35889917
MK
1059 else
1060 {
8d5a9abc
MK
1061 if (cache->reg[regnum].how == DWARF2_FRAME_REG_RA)
1062 {
1063 cache->reg[regnum].loc.reg = fs->retaddr_column;
1064 cache->reg[regnum].how = DWARF2_FRAME_REG_SAVED_REG;
1065 }
1066 else
1067 {
1068 cache->retaddr_reg.loc.reg = fs->retaddr_column;
1069 cache->retaddr_reg.how = DWARF2_FRAME_REG_SAVED_REG;
1070 }
35889917
MK
1071 }
1072 }
1073 }
1074 }
cfc14b3a 1075
0228dfb9
DJ
1076 if (fs->retaddr_column < fs->regs.num_regs
1077 && fs->regs.reg[fs->retaddr_column].how == DWARF2_FRAME_REG_UNDEFINED)
1078 cache->undefined_retaddr = 1;
1079
cfc14b3a
MK
1080 do_cleanups (old_chain);
1081
1082 *this_cache = cache;
1083 return cache;
1084}
1085
1086static void
4a4e5149 1087dwarf2_frame_this_id (struct frame_info *this_frame, void **this_cache,
cfc14b3a
MK
1088 struct frame_id *this_id)
1089{
1090 struct dwarf2_frame_cache *cache =
4a4e5149 1091 dwarf2_frame_cache (this_frame, this_cache);
cfc14b3a 1092
0228dfb9
DJ
1093 if (cache->undefined_retaddr)
1094 return;
1095
4a4e5149 1096 (*this_id) = frame_id_build (cache->cfa, get_frame_func (this_frame));
93d42b30
DJ
1097}
1098
4a4e5149
DJ
1099static struct value *
1100dwarf2_frame_prev_register (struct frame_info *this_frame, void **this_cache,
1101 int regnum)
93d42b30 1102{
4a4e5149 1103 struct gdbarch *gdbarch = get_frame_arch (this_frame);
93d42b30 1104 struct dwarf2_frame_cache *cache =
4a4e5149
DJ
1105 dwarf2_frame_cache (this_frame, this_cache);
1106 CORE_ADDR addr;
1107 int realnum;
cfc14b3a
MK
1108
1109 switch (cache->reg[regnum].how)
1110 {
05cbe71a 1111 case DWARF2_FRAME_REG_UNDEFINED:
3e2c4033 1112 /* If CFI explicitly specified that the value isn't defined,
e4e9607c 1113 mark it as optimized away; the value isn't available. */
4a4e5149 1114 return frame_unwind_got_optimized (this_frame, regnum);
cfc14b3a 1115
05cbe71a 1116 case DWARF2_FRAME_REG_SAVED_OFFSET:
4a4e5149
DJ
1117 addr = cache->cfa + cache->reg[regnum].loc.offset;
1118 return frame_unwind_got_memory (this_frame, regnum, addr);
cfc14b3a 1119
05cbe71a 1120 case DWARF2_FRAME_REG_SAVED_REG:
4a4e5149
DJ
1121 realnum
1122 = gdbarch_dwarf2_reg_to_regnum (gdbarch, cache->reg[regnum].loc.reg);
1123 return frame_unwind_got_register (this_frame, regnum, realnum);
cfc14b3a 1124
05cbe71a 1125 case DWARF2_FRAME_REG_SAVED_EXP:
4a4e5149
DJ
1126 addr = execute_stack_op (cache->reg[regnum].loc.exp,
1127 cache->reg[regnum].exp_len,
44353522 1128 cache->addr_size, this_frame, cache->cfa, 1);
4a4e5149 1129 return frame_unwind_got_memory (this_frame, regnum, addr);
cfc14b3a 1130
46ea248b 1131 case DWARF2_FRAME_REG_SAVED_VAL_OFFSET:
4a4e5149
DJ
1132 addr = cache->cfa + cache->reg[regnum].loc.offset;
1133 return frame_unwind_got_constant (this_frame, regnum, addr);
46ea248b
AO
1134
1135 case DWARF2_FRAME_REG_SAVED_VAL_EXP:
4a4e5149
DJ
1136 addr = execute_stack_op (cache->reg[regnum].loc.exp,
1137 cache->reg[regnum].exp_len,
44353522 1138 cache->addr_size, this_frame, cache->cfa, 1);
4a4e5149 1139 return frame_unwind_got_constant (this_frame, regnum, addr);
46ea248b 1140
05cbe71a 1141 case DWARF2_FRAME_REG_UNSPECIFIED:
3e2c4033
AC
1142 /* GCC, in its infinite wisdom decided to not provide unwind
1143 information for registers that are "same value". Since
1144 DWARF2 (3 draft 7) doesn't define such behavior, said
1145 registers are actually undefined (which is different to CFI
1146 "undefined"). Code above issues a complaint about this.
1147 Here just fudge the books, assume GCC, and that the value is
1148 more inner on the stack. */
4a4e5149 1149 return frame_unwind_got_register (this_frame, regnum, regnum);
3e2c4033 1150
05cbe71a 1151 case DWARF2_FRAME_REG_SAME_VALUE:
4a4e5149 1152 return frame_unwind_got_register (this_frame, regnum, regnum);
cfc14b3a 1153
05cbe71a 1154 case DWARF2_FRAME_REG_CFA:
4a4e5149 1155 return frame_unwind_got_address (this_frame, regnum, cache->cfa);
35889917 1156
ea7963f0 1157 case DWARF2_FRAME_REG_CFA_OFFSET:
4a4e5149
DJ
1158 addr = cache->cfa + cache->reg[regnum].loc.offset;
1159 return frame_unwind_got_address (this_frame, regnum, addr);
ea7963f0 1160
8d5a9abc 1161 case DWARF2_FRAME_REG_RA_OFFSET:
4a4e5149
DJ
1162 addr = cache->reg[regnum].loc.offset;
1163 regnum = gdbarch_dwarf2_reg_to_regnum
1164 (gdbarch, cache->retaddr_reg.loc.reg);
1165 addr += get_frame_register_unsigned (this_frame, regnum);
1166 return frame_unwind_got_address (this_frame, regnum, addr);
8d5a9abc 1167
b39cc962
DJ
1168 case DWARF2_FRAME_REG_FN:
1169 return cache->reg[regnum].loc.fn (this_frame, this_cache, regnum);
1170
cfc14b3a 1171 default:
e2e0b3e5 1172 internal_error (__FILE__, __LINE__, _("Unknown register rule."));
cfc14b3a
MK
1173 }
1174}
1175
4a4e5149
DJ
1176static int
1177dwarf2_frame_sniffer (const struct frame_unwind *self,
1178 struct frame_info *this_frame, void **this_cache)
cfc14b3a 1179{
1ce5d6dd 1180 /* Grab an address that is guarenteed to reside somewhere within the
4a4e5149 1181 function. get_frame_pc(), with a no-return next function, can
93d42b30
DJ
1182 end up returning something past the end of this function's body.
1183 If the frame we're sniffing for is a signal frame whose start
1184 address is placed on the stack by the OS, its FDE must
4a4e5149
DJ
1185 extend one byte before its start address or we could potentially
1186 select the FDE of the previous function. */
1187 CORE_ADDR block_addr = get_frame_address_in_block (this_frame);
56c987f6
AO
1188 struct dwarf2_fde *fde = dwarf2_frame_find_fde (&block_addr);
1189 if (!fde)
4a4e5149 1190 return 0;
3ed09a32
DJ
1191
1192 /* On some targets, signal trampolines may have unwind information.
1193 We need to recognize them so that we set the frame type
1194 correctly. */
1195
56c987f6 1196 if (fde->cie->signal_frame
4a4e5149
DJ
1197 || dwarf2_frame_signal_frame_p (get_frame_arch (this_frame),
1198 this_frame))
1199 return self->type == SIGTRAMP_FRAME;
1200
1201 return self->type != SIGTRAMP_FRAME;
1202}
1203
1204static const struct frame_unwind dwarf2_frame_unwind =
1205{
1206 NORMAL_FRAME,
1207 dwarf2_frame_this_id,
1208 dwarf2_frame_prev_register,
1209 NULL,
1210 dwarf2_frame_sniffer
1211};
1212
1213static const struct frame_unwind dwarf2_signal_frame_unwind =
1214{
1215 SIGTRAMP_FRAME,
1216 dwarf2_frame_this_id,
1217 dwarf2_frame_prev_register,
1218 NULL,
1219 dwarf2_frame_sniffer
1220};
cfc14b3a 1221
4a4e5149
DJ
1222/* Append the DWARF-2 frame unwinders to GDBARCH's list. */
1223
1224void
1225dwarf2_append_unwinders (struct gdbarch *gdbarch)
1226{
1227 frame_unwind_append_unwinder (gdbarch, &dwarf2_frame_unwind);
1228 frame_unwind_append_unwinder (gdbarch, &dwarf2_signal_frame_unwind);
cfc14b3a
MK
1229}
1230\f
1231
1232/* There is no explicitly defined relationship between the CFA and the
1233 location of frame's local variables and arguments/parameters.
1234 Therefore, frame base methods on this page should probably only be
1235 used as a last resort, just to avoid printing total garbage as a
1236 response to the "info frame" command. */
1237
1238static CORE_ADDR
4a4e5149 1239dwarf2_frame_base_address (struct frame_info *this_frame, void **this_cache)
cfc14b3a
MK
1240{
1241 struct dwarf2_frame_cache *cache =
4a4e5149 1242 dwarf2_frame_cache (this_frame, this_cache);
cfc14b3a
MK
1243
1244 return cache->cfa;
1245}
1246
1247static const struct frame_base dwarf2_frame_base =
1248{
1249 &dwarf2_frame_unwind,
1250 dwarf2_frame_base_address,
1251 dwarf2_frame_base_address,
1252 dwarf2_frame_base_address
1253};
1254
1255const struct frame_base *
4a4e5149 1256dwarf2_frame_base_sniffer (struct frame_info *this_frame)
cfc14b3a 1257{
4a4e5149 1258 CORE_ADDR block_addr = get_frame_address_in_block (this_frame);
93d42b30 1259 if (dwarf2_frame_find_fde (&block_addr))
cfc14b3a
MK
1260 return &dwarf2_frame_base;
1261
1262 return NULL;
1263}
e7802207
TT
1264
1265/* Compute the CFA for THIS_FRAME, but only if THIS_FRAME came from
1266 the DWARF unwinder. This is used to implement
1267 DW_OP_call_frame_cfa. */
1268
1269CORE_ADDR
1270dwarf2_frame_cfa (struct frame_info *this_frame)
1271{
1272 while (get_frame_type (this_frame) == INLINE_FRAME)
1273 this_frame = get_prev_frame (this_frame);
1274 /* This restriction could be lifted if other unwinders are known to
1275 compute the frame base in a way compatible with the DWARF
1276 unwinder. */
1277 if (! frame_unwinder_is (this_frame, &dwarf2_frame_unwind))
1278 error (_("can't compute CFA for this frame"));
1279 return get_frame_base (this_frame);
1280}
cfc14b3a 1281\f
8f22cb90 1282const struct objfile_data *dwarf2_frame_objfile_data;
0d0e1a63 1283
cfc14b3a 1284static unsigned int
852483bc 1285read_1_byte (bfd *abfd, gdb_byte *buf)
cfc14b3a 1286{
852483bc 1287 return bfd_get_8 (abfd, buf);
cfc14b3a
MK
1288}
1289
1290static unsigned int
852483bc 1291read_4_bytes (bfd *abfd, gdb_byte *buf)
cfc14b3a 1292{
852483bc 1293 return bfd_get_32 (abfd, buf);
cfc14b3a
MK
1294}
1295
1296static ULONGEST
852483bc 1297read_8_bytes (bfd *abfd, gdb_byte *buf)
cfc14b3a 1298{
852483bc 1299 return bfd_get_64 (abfd, buf);
cfc14b3a
MK
1300}
1301
1302static ULONGEST
852483bc 1303read_unsigned_leb128 (bfd *abfd, gdb_byte *buf, unsigned int *bytes_read_ptr)
cfc14b3a
MK
1304{
1305 ULONGEST result;
1306 unsigned int num_read;
1307 int shift;
852483bc 1308 gdb_byte byte;
cfc14b3a
MK
1309
1310 result = 0;
1311 shift = 0;
1312 num_read = 0;
1313
1314 do
1315 {
1316 byte = bfd_get_8 (abfd, (bfd_byte *) buf);
1317 buf++;
1318 num_read++;
1319 result |= ((byte & 0x7f) << shift);
1320 shift += 7;
1321 }
1322 while (byte & 0x80);
1323
1324 *bytes_read_ptr = num_read;
1325
1326 return result;
1327}
1328
1329static LONGEST
852483bc 1330read_signed_leb128 (bfd *abfd, gdb_byte *buf, unsigned int *bytes_read_ptr)
cfc14b3a
MK
1331{
1332 LONGEST result;
1333 int shift;
1334 unsigned int num_read;
852483bc 1335 gdb_byte byte;
cfc14b3a
MK
1336
1337 result = 0;
1338 shift = 0;
1339 num_read = 0;
1340
1341 do
1342 {
1343 byte = bfd_get_8 (abfd, (bfd_byte *) buf);
1344 buf++;
1345 num_read++;
1346 result |= ((byte & 0x7f) << shift);
1347 shift += 7;
1348 }
1349 while (byte & 0x80);
1350
77e0b926
DJ
1351 if (shift < 8 * sizeof (result) && (byte & 0x40))
1352 result |= -(((LONGEST)1) << shift);
cfc14b3a
MK
1353
1354 *bytes_read_ptr = num_read;
1355
1356 return result;
1357}
1358
1359static ULONGEST
852483bc 1360read_initial_length (bfd *abfd, gdb_byte *buf, unsigned int *bytes_read_ptr)
cfc14b3a
MK
1361{
1362 LONGEST result;
1363
852483bc 1364 result = bfd_get_32 (abfd, buf);
cfc14b3a
MK
1365 if (result == 0xffffffff)
1366 {
852483bc 1367 result = bfd_get_64 (abfd, buf + 4);
cfc14b3a
MK
1368 *bytes_read_ptr = 12;
1369 }
1370 else
1371 *bytes_read_ptr = 4;
1372
1373 return result;
1374}
1375\f
1376
1377/* Pointer encoding helper functions. */
1378
1379/* GCC supports exception handling based on DWARF2 CFI. However, for
1380 technical reasons, it encodes addresses in its FDE's in a different
1381 way. Several "pointer encodings" are supported. The encoding
1382 that's used for a particular FDE is determined by the 'R'
1383 augmentation in the associated CIE. The argument of this
1384 augmentation is a single byte.
1385
1386 The address can be encoded as 2 bytes, 4 bytes, 8 bytes, or as a
1387 LEB128. This is encoded in bits 0, 1 and 2. Bit 3 encodes whether
1388 the address is signed or unsigned. Bits 4, 5 and 6 encode how the
1389 address should be interpreted (absolute, relative to the current
1390 position in the FDE, ...). Bit 7, indicates that the address
1391 should be dereferenced. */
1392
852483bc 1393static gdb_byte
cfc14b3a
MK
1394encoding_for_size (unsigned int size)
1395{
1396 switch (size)
1397 {
1398 case 2:
1399 return DW_EH_PE_udata2;
1400 case 4:
1401 return DW_EH_PE_udata4;
1402 case 8:
1403 return DW_EH_PE_udata8;
1404 default:
e2e0b3e5 1405 internal_error (__FILE__, __LINE__, _("Unsupported address size"));
cfc14b3a
MK
1406 }
1407}
1408
cfc14b3a 1409static CORE_ADDR
852483bc 1410read_encoded_value (struct comp_unit *unit, gdb_byte encoding,
ae0d2f24
UW
1411 int ptr_len, gdb_byte *buf, unsigned int *bytes_read_ptr,
1412 CORE_ADDR func_base)
cfc14b3a 1413{
68f6cf99 1414 ptrdiff_t offset;
cfc14b3a
MK
1415 CORE_ADDR base;
1416
1417 /* GCC currently doesn't generate DW_EH_PE_indirect encodings for
1418 FDE's. */
1419 if (encoding & DW_EH_PE_indirect)
1420 internal_error (__FILE__, __LINE__,
e2e0b3e5 1421 _("Unsupported encoding: DW_EH_PE_indirect"));
cfc14b3a 1422
68f6cf99
MK
1423 *bytes_read_ptr = 0;
1424
cfc14b3a
MK
1425 switch (encoding & 0x70)
1426 {
1427 case DW_EH_PE_absptr:
1428 base = 0;
1429 break;
1430 case DW_EH_PE_pcrel:
f2fec864 1431 base = bfd_get_section_vma (unit->abfd, unit->dwarf_frame_section);
852483bc 1432 base += (buf - unit->dwarf_frame_buffer);
cfc14b3a 1433 break;
0912c7f2
MK
1434 case DW_EH_PE_datarel:
1435 base = unit->dbase;
1436 break;
0fd85043
CV
1437 case DW_EH_PE_textrel:
1438 base = unit->tbase;
1439 break;
03ac2a74 1440 case DW_EH_PE_funcrel:
ae0d2f24 1441 base = func_base;
03ac2a74 1442 break;
68f6cf99
MK
1443 case DW_EH_PE_aligned:
1444 base = 0;
852483bc 1445 offset = buf - unit->dwarf_frame_buffer;
68f6cf99
MK
1446 if ((offset % ptr_len) != 0)
1447 {
1448 *bytes_read_ptr = ptr_len - (offset % ptr_len);
1449 buf += *bytes_read_ptr;
1450 }
1451 break;
cfc14b3a 1452 default:
e2e0b3e5 1453 internal_error (__FILE__, __LINE__, _("Invalid or unsupported encoding"));
cfc14b3a
MK
1454 }
1455
b04de778 1456 if ((encoding & 0x07) == 0x00)
f2fec864
DJ
1457 {
1458 encoding |= encoding_for_size (ptr_len);
1459 if (bfd_get_sign_extend_vma (unit->abfd))
1460 encoding |= DW_EH_PE_signed;
1461 }
cfc14b3a
MK
1462
1463 switch (encoding & 0x0f)
1464 {
a81b10ae
MK
1465 case DW_EH_PE_uleb128:
1466 {
1467 ULONGEST value;
852483bc 1468 gdb_byte *end_buf = buf + (sizeof (value) + 1) * 8 / 7;
a7289609 1469 *bytes_read_ptr += read_uleb128 (buf, end_buf, &value) - buf;
a81b10ae
MK
1470 return base + value;
1471 }
cfc14b3a 1472 case DW_EH_PE_udata2:
68f6cf99 1473 *bytes_read_ptr += 2;
cfc14b3a
MK
1474 return (base + bfd_get_16 (unit->abfd, (bfd_byte *) buf));
1475 case DW_EH_PE_udata4:
68f6cf99 1476 *bytes_read_ptr += 4;
cfc14b3a
MK
1477 return (base + bfd_get_32 (unit->abfd, (bfd_byte *) buf));
1478 case DW_EH_PE_udata8:
68f6cf99 1479 *bytes_read_ptr += 8;
cfc14b3a 1480 return (base + bfd_get_64 (unit->abfd, (bfd_byte *) buf));
a81b10ae
MK
1481 case DW_EH_PE_sleb128:
1482 {
1483 LONGEST value;
852483bc 1484 gdb_byte *end_buf = buf + (sizeof (value) + 1) * 8 / 7;
a7289609 1485 *bytes_read_ptr += read_sleb128 (buf, end_buf, &value) - buf;
a81b10ae
MK
1486 return base + value;
1487 }
cfc14b3a 1488 case DW_EH_PE_sdata2:
68f6cf99 1489 *bytes_read_ptr += 2;
cfc14b3a
MK
1490 return (base + bfd_get_signed_16 (unit->abfd, (bfd_byte *) buf));
1491 case DW_EH_PE_sdata4:
68f6cf99 1492 *bytes_read_ptr += 4;
cfc14b3a
MK
1493 return (base + bfd_get_signed_32 (unit->abfd, (bfd_byte *) buf));
1494 case DW_EH_PE_sdata8:
68f6cf99 1495 *bytes_read_ptr += 8;
cfc14b3a
MK
1496 return (base + bfd_get_signed_64 (unit->abfd, (bfd_byte *) buf));
1497 default:
e2e0b3e5 1498 internal_error (__FILE__, __LINE__, _("Invalid or unsupported encoding"));
cfc14b3a
MK
1499 }
1500}
1501\f
1502
b01c8410
PP
1503static int
1504bsearch_cie_cmp (const void *key, const void *element)
cfc14b3a 1505{
b01c8410
PP
1506 ULONGEST cie_pointer = *(ULONGEST *) key;
1507 struct dwarf2_cie *cie = *(struct dwarf2_cie **) element;
cfc14b3a 1508
b01c8410
PP
1509 if (cie_pointer == cie->cie_pointer)
1510 return 0;
cfc14b3a 1511
b01c8410
PP
1512 return (cie_pointer < cie->cie_pointer) ? -1 : 1;
1513}
1514
1515/* Find CIE with the given CIE_POINTER in CIE_TABLE. */
1516static struct dwarf2_cie *
1517find_cie (struct dwarf2_cie_table *cie_table, ULONGEST cie_pointer)
1518{
1519 struct dwarf2_cie **p_cie;
cfc14b3a 1520
65a97ab3
PP
1521 /* The C standard (ISO/IEC 9899:TC2) requires the BASE argument to
1522 bsearch be non-NULL. */
1523 if (cie_table->entries == NULL)
1524 {
1525 gdb_assert (cie_table->num_entries == 0);
1526 return NULL;
1527 }
1528
b01c8410
PP
1529 p_cie = bsearch (&cie_pointer, cie_table->entries, cie_table->num_entries,
1530 sizeof (cie_table->entries[0]), bsearch_cie_cmp);
1531 if (p_cie != NULL)
1532 return *p_cie;
cfc14b3a
MK
1533 return NULL;
1534}
1535
b01c8410 1536/* Add a pointer to new CIE to the CIE_TABLE, allocating space for it. */
cfc14b3a 1537static void
b01c8410 1538add_cie (struct dwarf2_cie_table *cie_table, struct dwarf2_cie *cie)
cfc14b3a 1539{
b01c8410
PP
1540 const int n = cie_table->num_entries;
1541
1542 gdb_assert (n < 1
1543 || cie_table->entries[n - 1]->cie_pointer < cie->cie_pointer);
1544
1545 cie_table->entries =
1546 xrealloc (cie_table->entries, (n + 1) * sizeof (cie_table->entries[0]));
1547 cie_table->entries[n] = cie;
1548 cie_table->num_entries = n + 1;
1549}
1550
1551static int
1552bsearch_fde_cmp (const void *key, const void *element)
1553{
1554 CORE_ADDR seek_pc = *(CORE_ADDR *) key;
1555 struct dwarf2_fde *fde = *(struct dwarf2_fde **) element;
1556 if (seek_pc < fde->initial_location)
1557 return -1;
1558 if (seek_pc < fde->initial_location + fde->address_range)
1559 return 0;
1560 return 1;
cfc14b3a
MK
1561}
1562
1563/* Find the FDE for *PC. Return a pointer to the FDE, and store the
1564 inital location associated with it into *PC. */
1565
1566static struct dwarf2_fde *
1567dwarf2_frame_find_fde (CORE_ADDR *pc)
1568{
1569 struct objfile *objfile;
1570
1571 ALL_OBJFILES (objfile)
1572 {
b01c8410
PP
1573 struct dwarf2_fde_table *fde_table;
1574 struct dwarf2_fde **p_fde;
cfc14b3a 1575 CORE_ADDR offset;
b01c8410 1576 CORE_ADDR seek_pc;
cfc14b3a 1577
b01c8410
PP
1578 fde_table = objfile_data (objfile, dwarf2_frame_objfile_data);
1579 if (fde_table == NULL)
be391dca
TT
1580 {
1581 dwarf2_build_frame_info (objfile);
1582 fde_table = objfile_data (objfile, dwarf2_frame_objfile_data);
1583 }
1584 gdb_assert (fde_table != NULL);
1585
1586 if (fde_table->num_entries == 0)
4ae9ee8e
DJ
1587 continue;
1588
1589 gdb_assert (objfile->section_offsets);
1590 offset = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
1591
b01c8410
PP
1592 gdb_assert (fde_table->num_entries > 0);
1593 if (*pc < offset + fde_table->entries[0]->initial_location)
1594 continue;
1595
1596 seek_pc = *pc - offset;
1597 p_fde = bsearch (&seek_pc, fde_table->entries, fde_table->num_entries,
1598 sizeof (fde_table->entries[0]), bsearch_fde_cmp);
1599 if (p_fde != NULL)
1600 {
1601 *pc = (*p_fde)->initial_location + offset;
1602 return *p_fde;
1603 }
cfc14b3a 1604 }
cfc14b3a
MK
1605 return NULL;
1606}
1607
b01c8410 1608/* Add a pointer to new FDE to the FDE_TABLE, allocating space for it. */
cfc14b3a 1609static void
b01c8410 1610add_fde (struct dwarf2_fde_table *fde_table, struct dwarf2_fde *fde)
cfc14b3a 1611{
b01c8410
PP
1612 if (fde->address_range == 0)
1613 /* Discard useless FDEs. */
1614 return;
1615
1616 fde_table->num_entries += 1;
1617 fde_table->entries =
1618 xrealloc (fde_table->entries,
1619 fde_table->num_entries * sizeof (fde_table->entries[0]));
1620 fde_table->entries[fde_table->num_entries - 1] = fde;
cfc14b3a
MK
1621}
1622
1623#ifdef CC_HAS_LONG_LONG
1624#define DW64_CIE_ID 0xffffffffffffffffULL
1625#else
1626#define DW64_CIE_ID ~0
1627#endif
1628
852483bc 1629static gdb_byte *decode_frame_entry (struct comp_unit *unit, gdb_byte *start,
b01c8410
PP
1630 int eh_frame_p,
1631 struct dwarf2_cie_table *cie_table,
1632 struct dwarf2_fde_table *fde_table);
cfc14b3a 1633
6896c0c7
RH
1634/* Decode the next CIE or FDE. Return NULL if invalid input, otherwise
1635 the next byte to be processed. */
852483bc 1636static gdb_byte *
b01c8410
PP
1637decode_frame_entry_1 (struct comp_unit *unit, gdb_byte *start, int eh_frame_p,
1638 struct dwarf2_cie_table *cie_table,
1639 struct dwarf2_fde_table *fde_table)
cfc14b3a 1640{
5e2b427d 1641 struct gdbarch *gdbarch = get_objfile_arch (unit->objfile);
852483bc 1642 gdb_byte *buf, *end;
cfc14b3a
MK
1643 LONGEST length;
1644 unsigned int bytes_read;
6896c0c7
RH
1645 int dwarf64_p;
1646 ULONGEST cie_id;
cfc14b3a 1647 ULONGEST cie_pointer;
cfc14b3a 1648
6896c0c7 1649 buf = start;
cfc14b3a
MK
1650 length = read_initial_length (unit->abfd, buf, &bytes_read);
1651 buf += bytes_read;
1652 end = buf + length;
1653
6896c0c7
RH
1654 /* Are we still within the section? */
1655 if (end > unit->dwarf_frame_buffer + unit->dwarf_frame_size)
1656 return NULL;
1657
cfc14b3a
MK
1658 if (length == 0)
1659 return end;
1660
6896c0c7
RH
1661 /* Distinguish between 32 and 64-bit encoded frame info. */
1662 dwarf64_p = (bytes_read == 12);
cfc14b3a 1663
6896c0c7 1664 /* In a .eh_frame section, zero is used to distinguish CIEs from FDEs. */
cfc14b3a
MK
1665 if (eh_frame_p)
1666 cie_id = 0;
1667 else if (dwarf64_p)
1668 cie_id = DW64_CIE_ID;
6896c0c7
RH
1669 else
1670 cie_id = DW_CIE_ID;
cfc14b3a
MK
1671
1672 if (dwarf64_p)
1673 {
1674 cie_pointer = read_8_bytes (unit->abfd, buf);
1675 buf += 8;
1676 }
1677 else
1678 {
1679 cie_pointer = read_4_bytes (unit->abfd, buf);
1680 buf += 4;
1681 }
1682
1683 if (cie_pointer == cie_id)
1684 {
1685 /* This is a CIE. */
1686 struct dwarf2_cie *cie;
1687 char *augmentation;
28ba0b33 1688 unsigned int cie_version;
cfc14b3a
MK
1689
1690 /* Record the offset into the .debug_frame section of this CIE. */
1691 cie_pointer = start - unit->dwarf_frame_buffer;
1692
1693 /* Check whether we've already read it. */
b01c8410 1694 if (find_cie (cie_table, cie_pointer))
cfc14b3a
MK
1695 return end;
1696
1697 cie = (struct dwarf2_cie *)
8b92e4d5 1698 obstack_alloc (&unit->objfile->objfile_obstack,
cfc14b3a
MK
1699 sizeof (struct dwarf2_cie));
1700 cie->initial_instructions = NULL;
1701 cie->cie_pointer = cie_pointer;
1702
1703 /* The encoding for FDE's in a normal .debug_frame section
32b05c07
MK
1704 depends on the target address size. */
1705 cie->encoding = DW_EH_PE_absptr;
cfc14b3a 1706
ae0d2f24
UW
1707 /* The target address size. For .eh_frame FDEs this is considered
1708 equal to the size of a target pointer. For .dwarf_frame FDEs,
1709 this is supposed to be the target address size from the associated
1710 CU header. FIXME: We do not have a good way to determine the
1711 latter. Always use the target pointer size for now. */
5e2b427d 1712 cie->addr_size = gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT;
ae0d2f24 1713
56c987f6
AO
1714 /* We'll determine the final value later, but we need to
1715 initialize it conservatively. */
1716 cie->signal_frame = 0;
1717
cfc14b3a 1718 /* Check version number. */
28ba0b33 1719 cie_version = read_1_byte (unit->abfd, buf);
2dc7f7b3 1720 if (cie_version != 1 && cie_version != 3 && cie_version != 4)
6896c0c7 1721 return NULL;
303b6f5d 1722 cie->version = cie_version;
cfc14b3a
MK
1723 buf += 1;
1724
1725 /* Interpret the interesting bits of the augmentation. */
303b6f5d 1726 cie->augmentation = augmentation = (char *) buf;
852483bc 1727 buf += (strlen (augmentation) + 1);
cfc14b3a 1728
303b6f5d
DJ
1729 /* Ignore armcc augmentations. We only use them for quirks,
1730 and that doesn't happen until later. */
1731 if (strncmp (augmentation, "armcc", 5) == 0)
1732 augmentation += strlen (augmentation);
1733
cfc14b3a
MK
1734 /* The GCC 2.x "eh" augmentation has a pointer immediately
1735 following the augmentation string, so it must be handled
1736 first. */
1737 if (augmentation[0] == 'e' && augmentation[1] == 'h')
1738 {
1739 /* Skip. */
5e2b427d 1740 buf += gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT;
cfc14b3a
MK
1741 augmentation += 2;
1742 }
1743
2dc7f7b3
TT
1744 if (cie->version >= 4)
1745 {
1746 /* FIXME: check that this is the same as from the CU header. */
1747 cie->addr_size = read_1_byte (unit->abfd, buf);
1748 ++buf;
1749 cie->segment_size = read_1_byte (unit->abfd, buf);
1750 ++buf;
1751 }
1752 else
1753 {
1754 cie->addr_size = gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT;
1755 cie->segment_size = 0;
1756 }
1757
cfc14b3a
MK
1758 cie->code_alignment_factor =
1759 read_unsigned_leb128 (unit->abfd, buf, &bytes_read);
1760 buf += bytes_read;
1761
1762 cie->data_alignment_factor =
1763 read_signed_leb128 (unit->abfd, buf, &bytes_read);
1764 buf += bytes_read;
1765
28ba0b33
PB
1766 if (cie_version == 1)
1767 {
1768 cie->return_address_register = read_1_byte (unit->abfd, buf);
1769 bytes_read = 1;
1770 }
1771 else
1772 cie->return_address_register = read_unsigned_leb128 (unit->abfd, buf,
1773 &bytes_read);
4fc771b8 1774 cie->return_address_register
5e2b427d 1775 = dwarf2_frame_adjust_regnum (gdbarch,
4fc771b8
DJ
1776 cie->return_address_register,
1777 eh_frame_p);
4bf8967c 1778
28ba0b33 1779 buf += bytes_read;
cfc14b3a 1780
7131cb6e
RH
1781 cie->saw_z_augmentation = (*augmentation == 'z');
1782 if (cie->saw_z_augmentation)
cfc14b3a
MK
1783 {
1784 ULONGEST length;
1785
1786 length = read_unsigned_leb128 (unit->abfd, buf, &bytes_read);
1787 buf += bytes_read;
6896c0c7
RH
1788 if (buf > end)
1789 return NULL;
cfc14b3a
MK
1790 cie->initial_instructions = buf + length;
1791 augmentation++;
1792 }
1793
1794 while (*augmentation)
1795 {
1796 /* "L" indicates a byte showing how the LSDA pointer is encoded. */
1797 if (*augmentation == 'L')
1798 {
1799 /* Skip. */
1800 buf++;
1801 augmentation++;
1802 }
1803
1804 /* "R" indicates a byte indicating how FDE addresses are encoded. */
1805 else if (*augmentation == 'R')
1806 {
1807 cie->encoding = *buf++;
1808 augmentation++;
1809 }
1810
1811 /* "P" indicates a personality routine in the CIE augmentation. */
1812 else if (*augmentation == 'P')
1813 {
1234d960 1814 /* Skip. Avoid indirection since we throw away the result. */
852483bc 1815 gdb_byte encoding = (*buf++) & ~DW_EH_PE_indirect;
ae0d2f24
UW
1816 read_encoded_value (unit, encoding, cie->addr_size,
1817 buf, &bytes_read, 0);
f724bf08 1818 buf += bytes_read;
cfc14b3a
MK
1819 augmentation++;
1820 }
1821
56c987f6
AO
1822 /* "S" indicates a signal frame, such that the return
1823 address must not be decremented to locate the call frame
1824 info for the previous frame; it might even be the first
1825 instruction of a function, so decrementing it would take
1826 us to a different function. */
1827 else if (*augmentation == 'S')
1828 {
1829 cie->signal_frame = 1;
1830 augmentation++;
1831 }
1832
3e9a2e52
DJ
1833 /* Otherwise we have an unknown augmentation. Assume that either
1834 there is no augmentation data, or we saw a 'z' prefix. */
cfc14b3a
MK
1835 else
1836 {
3e9a2e52
DJ
1837 if (cie->initial_instructions)
1838 buf = cie->initial_instructions;
cfc14b3a
MK
1839 break;
1840 }
1841 }
1842
1843 cie->initial_instructions = buf;
1844 cie->end = end;
b01c8410 1845 cie->unit = unit;
cfc14b3a 1846
b01c8410 1847 add_cie (cie_table, cie);
cfc14b3a
MK
1848 }
1849 else
1850 {
1851 /* This is a FDE. */
1852 struct dwarf2_fde *fde;
1853
6896c0c7
RH
1854 /* In an .eh_frame section, the CIE pointer is the delta between the
1855 address within the FDE where the CIE pointer is stored and the
1856 address of the CIE. Convert it to an offset into the .eh_frame
1857 section. */
cfc14b3a
MK
1858 if (eh_frame_p)
1859 {
cfc14b3a
MK
1860 cie_pointer = buf - unit->dwarf_frame_buffer - cie_pointer;
1861 cie_pointer -= (dwarf64_p ? 8 : 4);
1862 }
1863
6896c0c7
RH
1864 /* In either case, validate the result is still within the section. */
1865 if (cie_pointer >= unit->dwarf_frame_size)
1866 return NULL;
1867
cfc14b3a 1868 fde = (struct dwarf2_fde *)
8b92e4d5 1869 obstack_alloc (&unit->objfile->objfile_obstack,
cfc14b3a 1870 sizeof (struct dwarf2_fde));
b01c8410 1871 fde->cie = find_cie (cie_table, cie_pointer);
cfc14b3a
MK
1872 if (fde->cie == NULL)
1873 {
1874 decode_frame_entry (unit, unit->dwarf_frame_buffer + cie_pointer,
b01c8410
PP
1875 eh_frame_p, cie_table, fde_table);
1876 fde->cie = find_cie (cie_table, cie_pointer);
cfc14b3a
MK
1877 }
1878
1879 gdb_assert (fde->cie != NULL);
1880
1881 fde->initial_location =
ae0d2f24
UW
1882 read_encoded_value (unit, fde->cie->encoding, fde->cie->addr_size,
1883 buf, &bytes_read, 0);
cfc14b3a
MK
1884 buf += bytes_read;
1885
1886 fde->address_range =
ae0d2f24
UW
1887 read_encoded_value (unit, fde->cie->encoding & 0x0f,
1888 fde->cie->addr_size, buf, &bytes_read, 0);
cfc14b3a
MK
1889 buf += bytes_read;
1890
7131cb6e
RH
1891 /* A 'z' augmentation in the CIE implies the presence of an
1892 augmentation field in the FDE as well. The only thing known
1893 to be in here at present is the LSDA entry for EH. So we
1894 can skip the whole thing. */
1895 if (fde->cie->saw_z_augmentation)
1896 {
1897 ULONGEST length;
1898
1899 length = read_unsigned_leb128 (unit->abfd, buf, &bytes_read);
1900 buf += bytes_read + length;
6896c0c7
RH
1901 if (buf > end)
1902 return NULL;
7131cb6e
RH
1903 }
1904
cfc14b3a
MK
1905 fde->instructions = buf;
1906 fde->end = end;
1907
4bf8967c
AS
1908 fde->eh_frame_p = eh_frame_p;
1909
b01c8410 1910 add_fde (fde_table, fde);
cfc14b3a
MK
1911 }
1912
1913 return end;
1914}
6896c0c7
RH
1915
1916/* Read a CIE or FDE in BUF and decode it. */
852483bc 1917static gdb_byte *
b01c8410
PP
1918decode_frame_entry (struct comp_unit *unit, gdb_byte *start, int eh_frame_p,
1919 struct dwarf2_cie_table *cie_table,
1920 struct dwarf2_fde_table *fde_table)
6896c0c7
RH
1921{
1922 enum { NONE, ALIGN4, ALIGN8, FAIL } workaround = NONE;
852483bc 1923 gdb_byte *ret;
6896c0c7
RH
1924 const char *msg;
1925 ptrdiff_t start_offset;
1926
1927 while (1)
1928 {
b01c8410
PP
1929 ret = decode_frame_entry_1 (unit, start, eh_frame_p,
1930 cie_table, fde_table);
6896c0c7
RH
1931 if (ret != NULL)
1932 break;
1933
1934 /* We have corrupt input data of some form. */
1935
1936 /* ??? Try, weakly, to work around compiler/assembler/linker bugs
1937 and mismatches wrt padding and alignment of debug sections. */
1938 /* Note that there is no requirement in the standard for any
1939 alignment at all in the frame unwind sections. Testing for
1940 alignment before trying to interpret data would be incorrect.
1941
1942 However, GCC traditionally arranged for frame sections to be
1943 sized such that the FDE length and CIE fields happen to be
1944 aligned (in theory, for performance). This, unfortunately,
1945 was done with .align directives, which had the side effect of
1946 forcing the section to be aligned by the linker.
1947
1948 This becomes a problem when you have some other producer that
1949 creates frame sections that are not as strictly aligned. That
1950 produces a hole in the frame info that gets filled by the
1951 linker with zeros.
1952
1953 The GCC behaviour is arguably a bug, but it's effectively now
1954 part of the ABI, so we're now stuck with it, at least at the
1955 object file level. A smart linker may decide, in the process
1956 of compressing duplicate CIE information, that it can rewrite
1957 the entire output section without this extra padding. */
1958
1959 start_offset = start - unit->dwarf_frame_buffer;
1960 if (workaround < ALIGN4 && (start_offset & 3) != 0)
1961 {
1962 start += 4 - (start_offset & 3);
1963 workaround = ALIGN4;
1964 continue;
1965 }
1966 if (workaround < ALIGN8 && (start_offset & 7) != 0)
1967 {
1968 start += 8 - (start_offset & 7);
1969 workaround = ALIGN8;
1970 continue;
1971 }
1972
1973 /* Nothing left to try. Arrange to return as if we've consumed
1974 the entire input section. Hopefully we'll get valid info from
1975 the other of .debug_frame/.eh_frame. */
1976 workaround = FAIL;
1977 ret = unit->dwarf_frame_buffer + unit->dwarf_frame_size;
1978 break;
1979 }
1980
1981 switch (workaround)
1982 {
1983 case NONE:
1984 break;
1985
1986 case ALIGN4:
1987 complaint (&symfile_complaints,
e2e0b3e5 1988 _("Corrupt data in %s:%s; align 4 workaround apparently succeeded"),
6896c0c7
RH
1989 unit->dwarf_frame_section->owner->filename,
1990 unit->dwarf_frame_section->name);
1991 break;
1992
1993 case ALIGN8:
1994 complaint (&symfile_complaints,
e2e0b3e5 1995 _("Corrupt data in %s:%s; align 8 workaround apparently succeeded"),
6896c0c7
RH
1996 unit->dwarf_frame_section->owner->filename,
1997 unit->dwarf_frame_section->name);
1998 break;
1999
2000 default:
2001 complaint (&symfile_complaints,
e2e0b3e5 2002 _("Corrupt data in %s:%s"),
6896c0c7
RH
2003 unit->dwarf_frame_section->owner->filename,
2004 unit->dwarf_frame_section->name);
2005 break;
2006 }
2007
2008 return ret;
2009}
cfc14b3a
MK
2010\f
2011
cfc14b3a 2012/* Imported from dwarf2read.c. */
dce234bc
PP
2013extern void dwarf2_get_section_info (struct objfile *, const char *, asection **,
2014 gdb_byte **, bfd_size_type *);
cfc14b3a 2015
b01c8410
PP
2016static int
2017qsort_fde_cmp (const void *a, const void *b)
2018{
2019 struct dwarf2_fde *aa = *(struct dwarf2_fde **)a;
2020 struct dwarf2_fde *bb = *(struct dwarf2_fde **)b;
e5af178f 2021
b01c8410 2022 if (aa->initial_location == bb->initial_location)
e5af178f
PP
2023 {
2024 if (aa->address_range != bb->address_range
2025 && aa->eh_frame_p == 0 && bb->eh_frame_p == 0)
2026 /* Linker bug, e.g. gold/10400.
2027 Work around it by keeping stable sort order. */
2028 return (a < b) ? -1 : 1;
2029 else
2030 /* Put eh_frame entries after debug_frame ones. */
2031 return aa->eh_frame_p - bb->eh_frame_p;
2032 }
b01c8410
PP
2033
2034 return (aa->initial_location < bb->initial_location) ? -1 : 1;
2035}
2036
cfc14b3a
MK
2037void
2038dwarf2_build_frame_info (struct objfile *objfile)
2039{
ae0d2f24 2040 struct comp_unit *unit;
852483bc 2041 gdb_byte *frame_ptr;
b01c8410
PP
2042 struct dwarf2_cie_table cie_table;
2043 struct dwarf2_fde_table fde_table;
be391dca 2044 struct dwarf2_fde_table *fde_table2;
b01c8410
PP
2045
2046 cie_table.num_entries = 0;
2047 cie_table.entries = NULL;
2048
2049 fde_table.num_entries = 0;
2050 fde_table.entries = NULL;
cfc14b3a
MK
2051
2052 /* Build a minimal decoding of the DWARF2 compilation unit. */
ae0d2f24
UW
2053 unit = (struct comp_unit *) obstack_alloc (&objfile->objfile_obstack,
2054 sizeof (struct comp_unit));
2055 unit->abfd = objfile->obfd;
2056 unit->objfile = objfile;
2057 unit->dbase = 0;
2058 unit->tbase = 0;
cfc14b3a 2059
dce234bc
PP
2060 dwarf2_get_section_info (objfile, ".eh_frame",
2061 &unit->dwarf_frame_section,
2062 &unit->dwarf_frame_buffer,
2063 &unit->dwarf_frame_size);
2064 if (unit->dwarf_frame_size)
cfc14b3a 2065 {
0fd85043 2066 asection *got, *txt;
0912c7f2 2067
0912c7f2 2068 /* FIXME: kettenis/20030602: This is the DW_EH_PE_datarel base
37b517aa
MK
2069 that is used for the i386/amd64 target, which currently is
2070 the only target in GCC that supports/uses the
2071 DW_EH_PE_datarel encoding. */
ae0d2f24 2072 got = bfd_get_section_by_name (unit->abfd, ".got");
0912c7f2 2073 if (got)
ae0d2f24 2074 unit->dbase = got->vma;
0912c7f2 2075
22c7ba1a
MK
2076 /* GCC emits the DW_EH_PE_textrel encoding type on sh and ia64
2077 so far. */
ae0d2f24 2078 txt = bfd_get_section_by_name (unit->abfd, ".text");
0fd85043 2079 if (txt)
ae0d2f24 2080 unit->tbase = txt->vma;
0fd85043 2081
ae0d2f24
UW
2082 frame_ptr = unit->dwarf_frame_buffer;
2083 while (frame_ptr < unit->dwarf_frame_buffer + unit->dwarf_frame_size)
b01c8410
PP
2084 frame_ptr = decode_frame_entry (unit, frame_ptr, 1,
2085 &cie_table, &fde_table);
2086
2087 if (cie_table.num_entries != 0)
2088 {
2089 /* Reinit cie_table: debug_frame has different CIEs. */
2090 xfree (cie_table.entries);
2091 cie_table.num_entries = 0;
2092 cie_table.entries = NULL;
2093 }
cfc14b3a
MK
2094 }
2095
dce234bc
PP
2096 dwarf2_get_section_info (objfile, ".debug_frame",
2097 &unit->dwarf_frame_section,
2098 &unit->dwarf_frame_buffer,
2099 &unit->dwarf_frame_size);
2100 if (unit->dwarf_frame_size)
cfc14b3a 2101 {
ae0d2f24
UW
2102 frame_ptr = unit->dwarf_frame_buffer;
2103 while (frame_ptr < unit->dwarf_frame_buffer + unit->dwarf_frame_size)
b01c8410
PP
2104 frame_ptr = decode_frame_entry (unit, frame_ptr, 0,
2105 &cie_table, &fde_table);
2106 }
2107
2108 /* Discard the cie_table, it is no longer needed. */
2109 if (cie_table.num_entries != 0)
2110 {
2111 xfree (cie_table.entries);
2112 cie_table.entries = NULL; /* Paranoia. */
2113 cie_table.num_entries = 0; /* Paranoia. */
2114 }
2115
be391dca
TT
2116 /* Copy fde_table to obstack: it is needed at runtime. */
2117 fde_table2 = (struct dwarf2_fde_table *)
2118 obstack_alloc (&objfile->objfile_obstack, sizeof (*fde_table2));
2119
2120 if (fde_table.num_entries == 0)
2121 {
2122 fde_table2->entries = NULL;
2123 fde_table2->num_entries = 0;
2124 }
2125 else
b01c8410 2126 {
875cdfbb
PA
2127 struct dwarf2_fde *fde_prev = NULL;
2128 struct dwarf2_fde *first_non_zero_fde = NULL;
2129 int i;
b01c8410
PP
2130
2131 /* Prepare FDE table for lookups. */
2132 qsort (fde_table.entries, fde_table.num_entries,
2133 sizeof (fde_table.entries[0]), qsort_fde_cmp);
2134
875cdfbb
PA
2135 /* Check for leftovers from --gc-sections. The GNU linker sets
2136 the relevant symbols to zero, but doesn't zero the FDE *end*
2137 ranges because there's no relocation there. It's (offset,
2138 length), not (start, end). On targets where address zero is
2139 just another valid address this can be a problem, since the
2140 FDEs appear to be non-empty in the output --- we could pick
2141 out the wrong FDE. To work around this, when overlaps are
2142 detected, we prefer FDEs that do not start at zero.
2143
2144 Start by finding the first FDE with non-zero start. Below
2145 we'll discard all FDEs that start at zero and overlap this
2146 one. */
2147 for (i = 0; i < fde_table.num_entries; i++)
2148 {
2149 struct dwarf2_fde *fde = fde_table.entries[i];
b01c8410 2150
875cdfbb
PA
2151 if (fde->initial_location != 0)
2152 {
2153 first_non_zero_fde = fde;
2154 break;
2155 }
2156 }
2157
2158 /* Since we'll be doing bsearch, squeeze out identical (except
2159 for eh_frame_p) fde entries so bsearch result is predictable.
2160 Also discard leftovers from --gc-sections. */
be391dca 2161 fde_table2->num_entries = 0;
875cdfbb
PA
2162 for (i = 0; i < fde_table.num_entries; i++)
2163 {
2164 struct dwarf2_fde *fde = fde_table.entries[i];
2165
2166 if (fde->initial_location == 0
2167 && first_non_zero_fde != NULL
2168 && (first_non_zero_fde->initial_location
2169 < fde->initial_location + fde->address_range))
2170 continue;
2171
2172 if (fde_prev != NULL
2173 && fde_prev->initial_location == fde->initial_location)
2174 continue;
2175
2176 obstack_grow (&objfile->objfile_obstack, &fde_table.entries[i],
2177 sizeof (fde_table.entries[0]));
2178 ++fde_table2->num_entries;
2179 fde_prev = fde;
2180 }
b01c8410 2181 fde_table2->entries = obstack_finish (&objfile->objfile_obstack);
b01c8410
PP
2182
2183 /* Discard the original fde_table. */
2184 xfree (fde_table.entries);
cfc14b3a 2185 }
be391dca
TT
2186
2187 set_objfile_data (objfile, dwarf2_frame_objfile_data, fde_table2);
cfc14b3a 2188}
0d0e1a63
MK
2189
2190/* Provide a prototype to silence -Wmissing-prototypes. */
2191void _initialize_dwarf2_frame (void);
2192
2193void
2194_initialize_dwarf2_frame (void)
2195{
030f20e1 2196 dwarf2_frame_data = gdbarch_data_register_pre_init (dwarf2_frame_init);
8f22cb90 2197 dwarf2_frame_objfile_data = register_objfile_data ();
0d0e1a63 2198}
This page took 0.573378 seconds and 4 git commands to generate.