/* Saved registers array item. */
-typedef struct
+struct saved_reg
{
+ saved_reg (int n, gdbpy_ref<> &&v)
+ : number (n),
+ value (std::move (v))
+ {
+ }
+
int number;
- PyObject *value;
-} saved_reg;
-DEF_VEC_O (saved_reg);
+ gdbpy_ref<> value;
+};
/* The data we keep for the PyUnwindInfo: pending_frame, saved registers
and frame ID. */
struct frame_id frame_id;
/* Saved registers array. */
- VEC (saved_reg) *saved_regs;
+ std::vector<saved_reg> *saved_regs;
} unwind_info_object;
/* The data we keep for a frame we can unwind: frame ID and an array of
fprint_frame_id (&stb, unwind_info->frame_id);
{
const char *sep = "";
- int i;
struct value_print_options opts;
- saved_reg *reg;
get_user_print_options (&opts);
stb.printf ("\nSaved registers: (");
- for (i = 0; VEC_iterate (saved_reg, unwind_info->saved_regs, i, reg); i++)
+ for (const saved_reg ® : *unwind_info->saved_regs)
{
- struct value *value = value_object_to_value (reg->value);
+ struct value *value = value_object_to_value (reg.value.get ());
- stb.printf ("%s(%d, ", sep, reg->number);
+ stb.printf ("%s(%d, ", sep, reg.number);
if (value != NULL)
{
TRY
unwind_info->frame_id = frame_id;
Py_INCREF (pyo_pending_frame);
unwind_info->pending_frame = pyo_pending_frame;
- unwind_info->saved_regs = VEC_alloc (saved_reg, 4);
+ unwind_info->saved_regs = new std::vector<saved_reg>;
return (PyObject *) unwind_info;
}
}
}
{
- int i;
- saved_reg *reg;
-
- for (i = 0; VEC_iterate (saved_reg, unwind_info->saved_regs, i, reg); i++)
+ gdbpy_ref<> new_value = gdbpy_ref<>::new_reference (pyo_reg_value);
+ bool found = false;
+ for (saved_reg ® : *unwind_info->saved_regs)
{
- if (regnum == reg->number)
+ if (regnum == reg.number)
{
- Py_DECREF (reg->value);
+ found = true;
+ reg.value = std::move (new_value);
break;
}
}
- if (reg == NULL)
- {
- reg = VEC_safe_push (saved_reg, unwind_info->saved_regs, NULL);
- reg->number = regnum;
- }
- Py_INCREF (pyo_reg_value);
- reg->value = pyo_reg_value;
+ if (!found)
+ unwind_info->saved_regs->emplace_back (regnum, std::move (new_value));
}
Py_RETURN_NONE;
}
saved_reg *reg;
Py_XDECREF (unwind_info->pending_frame);
- for (i = 0; VEC_iterate (saved_reg, unwind_info->saved_regs, i, reg); i++)
- Py_DECREF (reg->value);
- VEC_free (saved_reg, unwind_info->saved_regs);
+ delete unwind_info->saved_regs;
Py_TYPE (self)->tp_free (self);
}
{
unwind_info_object *unwind_info =
(unwind_info_object *) pyo_unwind_info.get ();
- int reg_count = VEC_length (saved_reg, unwind_info->saved_regs);
- saved_reg *reg;
- int i;
+ int reg_count = unwind_info->saved_regs->size ();
cached_frame
= ((cached_frame_info *)
cached_frame->reg_count = reg_count;
/* Populate registers array. */
- for (i = 0; VEC_iterate (saved_reg, unwind_info->saved_regs, i, reg); i++)
+ for (int i = 0; i < unwind_info->saved_regs->size (); ++i)
{
- struct value *value = value_object_to_value (reg->value);
+ saved_reg *reg = &(*unwind_info->saved_regs)[i];
+
+ struct value *value = value_object_to_value (reg->value.get ());
size_t data_size = register_size (gdbarch, reg->number);
cached_frame->reg[i].num = reg->number;