- int width;
- int bytes_read;
- gdb_byte *buffer = NULL;
- int errcode = 0;
- CORE_ADDR addr;
- struct gdbarch *gdbarch;
- enum bfd_endian byte_order;
- PyObject *py_len = NULL, *py_encoding = NULL;
- PyObject *py_addr = NULL, *py_type = NULL;
- volatile struct gdb_exception except;
-
- py_len = PyObject_GetAttrString (string, "length");
- py_encoding = PyObject_GetAttrString (string, "encoding");
- py_addr = PyObject_GetAttrString (string, "address");
- py_type = PyObject_GetAttrString (string, "type");
-
- /* A NULL encoding, length, address or type is not ok. */
- if (!py_len || !py_encoding || !py_addr || !py_type)
- goto error;
-
- *length = PyLong_AsLong (py_len);
- addr = PyLong_AsUnsignedLongLong (py_addr);
-
- /* If the user supplies Py_None an encoding, set encoding to NULL.
- This will trigger the resulting LA_PRINT_CALL to automatically
- select an encoding. */
- if (py_encoding == Py_None)
- *encoding = NULL;
- else
- *encoding = xstrdup (PyString_AsString (py_encoding));