restore_python_env (void *p)
{
struct python_env *env = (struct python_env *)p;
+
PyGILState_Release (env->state);
python_gdbarch = env->gdbarch;
python_language = env->language;
for (iter = l; iter; iter = iter->next)
{
int len = strlen (iter->line);
+
strcpy (&script[here], iter->line);
here += len;
script[here++] = '\n';
python_command (char *arg, int from_tty)
{
struct cleanup *cleanup;
- cleanup = ensure_python_env (get_current_arch (), current_language);
+ cleanup = ensure_python_env (get_current_arch (), current_language);
while (arg && *arg && isspace (*arg))
++arg;
if (arg && *arg)
else
{
struct command_line *l = get_command_line (python_control, "");
+
make_cleanup_free_command_lines (&l);
execute_control_command_untraced (l);
}
case var_enum:
{
char *str = * (char **) var;
+
if (! str)
str = "";
return PyString_Decode (str, strlen (str), host_charset (), NULL);
case var_auto_boolean:
{
enum auto_boolean ab = * (enum auto_boolean *) var;
+
if (ab == AUTO_BOOLEAN_TRUE)
Py_RETURN_TRUE;
else if (ab == AUTO_BOOLEAN_FALSE)
case var_uinteger:
{
unsigned int val = * (unsigned int *) var;
+
if (val == UINT_MAX)
Py_RETURN_NONE;
return PyLong_FromUnsignedLong (val);
gdbpy_target_charset (PyObject *self, PyObject *args)
{
const char *cset = target_charset (python_gdbarch);
+
return PyUnicode_Decode (cset, strlen (cset), host_charset (), NULL);
}
gdbpy_target_wide_charset (PyObject *self, PyObject *args)
{
const char *cset = target_wide_charset (python_gdbarch);
+
return PyUnicode_Decode (cset, strlen (cset), host_charset (), NULL);
}
/* Copy the argument text in case the command modifies it. */
char *copy = xstrdup (arg);
struct cleanup *cleanup = make_cleanup (xfree, copy);
+
execute_command (copy, from_tty);
do_cleanups (cleanup);
}
gdbpy_write (PyObject *self, PyObject *args)
{
char *arg;
+
if (! PyArg_ParseTuple (args, "s", &arg))
return NULL;
printf_filtered ("%s", arg);
ALL_PSPACES (ps)
{
PyObject *item = pspace_to_pspace_object (ps);
+
if (!item || PyList_Append (list, item) == -1)
{
Py_DECREF (list);
ALL_OBJFILES (objf)
{
PyObject *item = objfile_to_objfile_object (objf);
+
if (!item || PyList_Append (list, item) == -1)
{
Py_DECREF (list);
{
struct command_line *l = get_command_line (python_control, "");
struct cleanup *cleanups = make_cleanup_free_command_lines (&l);
+
execute_control_command_untraced (l);
do_cleanups (cleanups);
}