+ if (producer_is_realview (s->producer))
+ {
+ if (fde->cie->version == 1)
+ fs->armcc_cfa_offsets_sf = 1;
+
+ if (fde->cie->version == 1)
+ fs->armcc_cfa_offsets_reversed = 1;
+
+ /* The reversed offset problem is present in some compilers
+ using DWARF3, but it was eventually fixed. Check the ARM
+ defined augmentations, which are in the format "armcc" followed
+ by a list of one-character options. The "+" option means
+ this problem is fixed (no quirk needed). If the armcc
+ augmentation is missing, the quirk is needed. */
+ if (fde->cie->version == 3
+ && (strncmp (fde->cie->augmentation, "armcc", 5) != 0
+ || strchr (fde->cie->augmentation + 5, '+') == NULL))
+ fs->armcc_cfa_offsets_reversed = 1;
+
+ return;
+ }
+}
+\f
+
+void
+dwarf2_compile_cfa_to_ax (struct agent_expr *expr, struct axs_value *loc,
+ struct gdbarch *gdbarch,
+ CORE_ADDR pc,
+ struct dwarf2_per_cu_data *data)
+{
+ const int num_regs = gdbarch_num_regs (gdbarch)
+ + gdbarch_num_pseudo_regs (gdbarch);
+ struct dwarf2_fde *fde;
+ CORE_ADDR text_offset, cfa;
+ struct dwarf2_frame_state fs;
+ int addr_size;
+
+ memset (&fs, 0, sizeof (struct dwarf2_frame_state));
+
+ fs.pc = pc;
+
+ /* Find the correct FDE. */
+ fde = dwarf2_frame_find_fde (&fs.pc, &text_offset);
+ if (fde == NULL)
+ error (_("Could not compute CFA; needed to translate this expression"));
+
+ /* Extract any interesting information from the CIE. */
+ fs.data_align = fde->cie->data_alignment_factor;
+ fs.code_align = fde->cie->code_alignment_factor;
+ fs.retaddr_column = fde->cie->return_address_register;
+ addr_size = fde->cie->addr_size;
+
+ /* Check for "quirks" - known bugs in producers. */
+ dwarf2_frame_find_quirks (&fs, fde);
+
+ /* First decode all the insns in the CIE. */
+ execute_cfa_program (fde, fde->cie->initial_instructions,
+ fde->cie->end, gdbarch, pc, &fs);
+
+ /* Save the initialized register set. */
+ fs.initial = fs.regs;
+ fs.initial.reg = dwarf2_frame_state_copy_regs (&fs.regs);
+
+ /* Then decode the insns in the FDE up to our target PC. */
+ execute_cfa_program (fde, fde->instructions, fde->end, gdbarch, pc, &fs);
+
+ /* Calculate the CFA. */
+ switch (fs.regs.cfa_how)
+ {
+ case CFA_REG_OFFSET: