+/* Implementation of gdb.Frame.read_register (self, register) -> gdb.Value.
+ Returns the value of a register in this frame. */
+
+static PyObject *
+frapy_read_register (PyObject *self, PyObject *args)
+{
+ const char *regnum_str;
+ struct value *val = NULL;
+
+ if (!PyArg_ParseTuple (args, "s", ®num_str))
+ return NULL;
+
+ try
+ {
+ struct frame_info *frame;
+ int regnum;
+
+ FRAPY_REQUIRE_VALID (self, frame);
+
+ regnum = user_reg_map_name_to_regnum (get_frame_arch (frame),
+ regnum_str,
+ strlen (regnum_str));
+ if (regnum >= 0)
+ val = value_of_register (regnum, frame);
+
+ if (val == NULL)
+ PyErr_SetString (PyExc_ValueError, _("Unknown register."));
+ }
+ catch (const gdb_exception &except)
+ {
+ GDB_PY_HANDLE_EXCEPTION (except);
+ }
+
+ return val == NULL ? NULL : value_to_value_object (val);
+}
+