2010-05-17 Michael Snyder <msnyder@vmware.com>

* python/py-auto-load.c: White space.
	* python/py-block.c: White space.
	* python/py-breakpoint.c: White space.
	* python/py-cmd.c: White space.
	* python/py-function.c: White space.
	* python/py-lazy-string.c: White space.
	* python/py-objfile.c: White space.
	* python/py-param.c: White space.
	* python/py-prettyprint.c: White space.
	* python/py-progspace.c: White space.
	* python/py-symtab.c: White space.
	* python/python.c: White space.
	* python/py-type.c: White space.
	* python/py-utils.c: White space.
	* python/py-value.c: White space.
This commit is contained in:
Michael Snyder 2010-05-17 21:23:25 +00:00
parent 102040f0d0
commit d59b6f6c38
16 changed files with 82 additions and 3 deletions

View file

@ -1,5 +1,21 @@
2010-05-17 Michael Snyder <msnyder@vmware.com> 2010-05-17 Michael Snyder <msnyder@vmware.com>
* python/py-auto-load.c: White space.
* python/py-block.c: White space.
* python/py-breakpoint.c: White space.
* python/py-cmd.c: White space.
* python/py-function.c: White space.
* python/py-lazy-string.c: White space.
* python/py-objfile.c: White space.
* python/py-param.c: White space.
* python/py-prettyprint.c: White space.
* python/py-progspace.c: White space.
* python/py-symtab.c: White space.
* python/python.c: White space.
* python/py-type.c: White space.
* python/py-utils.c: White space.
* python/py-value.c: White space.
* mi/mi-cmd-break.c: White space. * mi/mi-cmd-break.c: White space.
* mi/mi-cmd-env.c: White space. * mi/mi-cmd-env.c: White space.
* mi/mi-cmds.c: White space. * mi/mi-cmds.c: White space.

View file

@ -128,6 +128,7 @@ static hashval_t
hash_loaded_script_entry (const void *data) hash_loaded_script_entry (const void *data)
{ {
const struct loaded_script_entry *e = data; const struct loaded_script_entry *e = data;
return htab_hash_string (e->name); return htab_hash_string (e->name);
} }
@ -138,6 +139,7 @@ eq_loaded_script_entry (const void *a, const void *b)
{ {
const struct loaded_script_entry *ea = a; const struct loaded_script_entry *ea = a;
const struct loaded_script_entry *eb = b; const struct loaded_script_entry *eb = b;
return strcmp (ea->name, eb->name) == 0; return strcmp (ea->name, eb->name) == 0;
} }
@ -202,6 +204,7 @@ source_section_scripts (struct objfile *objfile, const char *source_name,
if (p == end) if (p == end)
{ {
char *buf = alloca (p - file + 1); char *buf = alloca (p - file + 1);
memcpy (buf, file, p - file); memcpy (buf, file, p - file);
buf[p - file] = '\0'; buf[p - file] = '\0';
warning (_("Non-null-terminated path in %s: %s"), warning (_("Non-null-terminated path in %s: %s"),
@ -236,6 +239,7 @@ source_section_scripts (struct objfile *objfile, const char *source_name,
if (! in_hash_table) if (! in_hash_table)
{ {
char *p; char *p;
*slot = xmalloc (sizeof (**slot) *slot = xmalloc (sizeof (**slot)
+ strlen (file) + 1 + strlen (file) + 1
+ (opened ? (strlen (full_path) + 1) : 0)); + (opened ? (strlen (full_path) + 1) : 0));

View file

@ -259,6 +259,7 @@ static void
blpy_block_syms_dealloc (PyObject *obj) blpy_block_syms_dealloc (PyObject *obj)
{ {
block_syms_iterator_object *iter_obj = (block_syms_iterator_object *) obj; block_syms_iterator_object *iter_obj = (block_syms_iterator_object *) obj;
Py_XDECREF (iter_obj->source); Py_XDECREF (iter_obj->source);
} }
@ -300,6 +301,7 @@ static void
del_objfile_blocks (struct objfile *objfile, void *datum) del_objfile_blocks (struct objfile *objfile, void *datum)
{ {
block_object *obj = datum; block_object *obj = datum;
while (obj) while (obj)
{ {
block_object *next = obj->next; block_object *next = obj->next;

View file

@ -642,6 +642,7 @@ gdbpy_breakpoints (PyObject *self, PyObject *args)
if (result) if (result)
{ {
int i, out = 0; int i, out = 0;
for (i = 0; out < bppy_live; ++i) for (i = 0; out < bppy_live; ++i)
{ {
if (! bppy_breakpoints[i]) if (! bppy_breakpoints[i])
@ -684,6 +685,7 @@ gdbpy_breakpoint_created (int num)
if (num >= bppy_slots) if (num >= bppy_slots)
{ {
int old = bppy_slots; int old = bppy_slots;
bppy_slots = bppy_slots * 2 + 10; bppy_slots = bppy_slots * 2 + 10;
bppy_breakpoints bppy_breakpoints
= (breakpoint_object **) xrealloc (bppy_breakpoints, = (breakpoint_object **) xrealloc (bppy_breakpoints,

View file

@ -156,8 +156,8 @@ cmdpy_function (struct cmd_list_element *command, char *args, int from_tty)
/* Make a temporary copy of the string data. */ /* Make a temporary copy of the string data. */
char *s = PyString_AsString (pvalue); char *s = PyString_AsString (pvalue);
char *copy = alloca (strlen (s) + 1); char *copy = alloca (strlen (s) + 1);
strcpy (copy, s);
strcpy (copy, s);
PyErr_Restore (ptype, pvalue, ptraceback); PyErr_Restore (ptype, pvalue, ptraceback);
gdbpy_print_stack (); gdbpy_print_stack ();
error (_("Error occurred in Python command: %s"), copy); error (_("Error occurred in Python command: %s"), copy);
@ -217,6 +217,7 @@ cmdpy_completer (struct cmd_list_element *command, char *text, char *word)
{ {
Py_ssize_t i, len = PySequence_Size (resultobj); Py_ssize_t i, len = PySequence_Size (resultobj);
Py_ssize_t out; Py_ssize_t out;
if (len < 0) if (len < 0)
goto done; goto done;
@ -224,6 +225,7 @@ cmdpy_completer (struct cmd_list_element *command, char *text, char *word)
for (i = out = 0; i < len; ++i) for (i = out = 0; i < len; ++i)
{ {
PyObject *elt = PySequence_GetItem (resultobj, i); PyObject *elt = PySequence_GetItem (resultobj, i);
if (elt == NULL || ! gdbpy_is_string (elt)) if (elt == NULL || ! gdbpy_is_string (elt))
{ {
/* Skip problem elements. */ /* Skip problem elements. */
@ -240,6 +242,7 @@ cmdpy_completer (struct cmd_list_element *command, char *text, char *word)
/* User code may also return one of the completion constants, /* User code may also return one of the completion constants,
thus requesting that sort of completion. */ thus requesting that sort of completion. */
long value = PyInt_AsLong (resultobj); long value = PyInt_AsLong (resultobj);
if (value >= 0 && value < (long) N_COMPLETERS) if (value >= 0 && value < (long) N_COMPLETERS)
result = completers[value].completer (command, text, word); result = completers[value].completer (command, text, word);
} }
@ -438,6 +441,7 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kw)
if (PyObject_HasAttr (self, gdbpy_doc_cst)) if (PyObject_HasAttr (self, gdbpy_doc_cst))
{ {
PyObject *ds_obj = PyObject_GetAttr (self, gdbpy_doc_cst); PyObject *ds_obj = PyObject_GetAttr (self, gdbpy_doc_cst);
if (ds_obj && gdbpy_is_string (ds_obj)) if (ds_obj && gdbpy_is_string (ds_obj))
docstring = python_string_to_host_string (ds_obj); docstring = python_string_to_host_string (ds_obj);
} }

View file

@ -38,6 +38,7 @@ convert_values_to_python (int argc, struct value **argv)
{ {
int i; int i;
PyObject *result = PyTuple_New (argc); PyObject *result = PyTuple_New (argc);
for (i = 0; i < argc; ++i) for (i = 0; i < argc; ++i)
{ {
PyObject *elt = value_to_value_object (argv[i]); PyObject *elt = value_to_value_object (argv[i]);
@ -103,6 +104,7 @@ static int
fnpy_init (PyObject *self, PyObject *args, PyObject *kwds) fnpy_init (PyObject *self, PyObject *args, PyObject *kwds)
{ {
char *name, *docstring = NULL; char *name, *docstring = NULL;
if (! PyArg_ParseTuple (args, "s", &name)) if (! PyArg_ParseTuple (args, "s", &name))
return -1; return -1;
Py_INCREF (self); Py_INCREF (self);

View file

@ -52,6 +52,7 @@ static PyObject *
stpy_get_address (PyObject *self, void *closure) stpy_get_address (PyObject *self, void *closure)
{ {
lazy_string_object *self_string = (lazy_string_object *) self; lazy_string_object *self_string = (lazy_string_object *) self;
return PyLong_FromUnsignedLongLong (self_string->address); return PyLong_FromUnsignedLongLong (self_string->address);
} }
@ -78,6 +79,7 @@ static PyObject *
stpy_get_length (PyObject *self, void *closure) stpy_get_length (PyObject *self, void *closure)
{ {
lazy_string_object *self_string = (lazy_string_object *) self; lazy_string_object *self_string = (lazy_string_object *) self;
return PyLong_FromLong (self_string->length); return PyLong_FromLong (self_string->length);
} }
@ -85,6 +87,7 @@ PyObject *
stpy_get_type (PyObject *self, void *closure) stpy_get_type (PyObject *self, void *closure)
{ {
lazy_string_object *str_obj = (lazy_string_object *) self; lazy_string_object *str_obj = (lazy_string_object *) self;
return type_to_type_object (str_obj->type); return type_to_type_object (str_obj->type);
} }
@ -109,6 +112,7 @@ static void
stpy_dealloc (PyObject *self) stpy_dealloc (PyObject *self)
{ {
lazy_string_object *self_string = (lazy_string_object *) self; lazy_string_object *self_string = (lazy_string_object *) self;
xfree (self_string->encoding); xfree (self_string->encoding);
} }

View file

@ -45,6 +45,7 @@ static PyObject *
objfpy_get_filename (PyObject *self, void *closure) objfpy_get_filename (PyObject *self, void *closure)
{ {
objfile_object *obj = (objfile_object *) self; objfile_object *obj = (objfile_object *) self;
if (obj->objfile && obj->objfile->name) if (obj->objfile && obj->objfile->name)
return PyString_Decode (obj->objfile->name, strlen (obj->objfile->name), return PyString_Decode (obj->objfile->name, strlen (obj->objfile->name),
host_charset (), NULL); host_charset (), NULL);
@ -55,6 +56,7 @@ static void
objfpy_dealloc (PyObject *o) objfpy_dealloc (PyObject *o)
{ {
objfile_object *self = (objfile_object *) o; objfile_object *self = (objfile_object *) o;
Py_XDECREF (self->printers); Py_XDECREF (self->printers);
self->ob_type->tp_free ((PyObject *) self); self->ob_type->tp_free ((PyObject *) self);
} }
@ -63,6 +65,7 @@ static PyObject *
objfpy_new (PyTypeObject *type, PyObject *args, PyObject *keywords) objfpy_new (PyTypeObject *type, PyObject *args, PyObject *keywords)
{ {
objfile_object *self = (objfile_object *) type->tp_alloc (type, 0); objfile_object *self = (objfile_object *) type->tp_alloc (type, 0);
if (self) if (self)
{ {
self->objfile = NULL; self->objfile = NULL;
@ -81,6 +84,7 @@ PyObject *
objfpy_get_printers (PyObject *o, void *ignore) objfpy_get_printers (PyObject *o, void *ignore)
{ {
objfile_object *self = (objfile_object *) o; objfile_object *self = (objfile_object *) o;
Py_INCREF (self->printers); Py_INCREF (self->printers);
return self->printers; return self->printers;
} }
@ -90,6 +94,7 @@ objfpy_set_printers (PyObject *o, PyObject *value, void *ignore)
{ {
PyObject *tmp; PyObject *tmp;
objfile_object *self = (objfile_object *) o; objfile_object *self = (objfile_object *) o;
if (! value) if (! value)
{ {
PyErr_SetString (PyExc_TypeError, PyErr_SetString (PyExc_TypeError,

View file

@ -103,6 +103,7 @@ get_attr (PyObject *obj, PyObject *attr_name)
&& ! strcmp (PyString_AsString (attr_name), "value")) && ! strcmp (PyString_AsString (attr_name), "value"))
{ {
parmpy_object *self = (parmpy_object *) obj; parmpy_object *self = (parmpy_object *) obj;
return gdbpy_parameter_value (self->type, &self->value); return gdbpy_parameter_value (self->type, &self->value);
} }
@ -394,6 +395,7 @@ compute_enum_values (parmpy_object *self, PyObject *enum_values)
for (i = 0; i < size; ++i) for (i = 0; i < size; ++i)
{ {
PyObject *item = PySequence_GetItem (enum_values, i); PyObject *item = PySequence_GetItem (enum_values, i);
if (! item) if (! item)
return 0; return 0;
if (! gdbpy_is_string (item)) if (! gdbpy_is_string (item))
@ -414,9 +416,11 @@ static char *
get_doc_string (PyObject *object, PyObject *attr) get_doc_string (PyObject *object, PyObject *attr)
{ {
char *result = NULL; char *result = NULL;
if (PyObject_HasAttr (object, attr)) if (PyObject_HasAttr (object, attr))
{ {
PyObject *ds_obj = PyObject_GetAttr (object, attr); PyObject *ds_obj = PyObject_GetAttr (object, attr);
if (ds_obj && gdbpy_is_string (ds_obj)) if (ds_obj && gdbpy_is_string (ds_obj))
result = python_string_to_host_string (ds_obj); result = python_string_to_host_string (ds_obj);
} }

View file

@ -319,6 +319,7 @@ py_restore_tstate (void *p)
{ {
PyFrameObject *frame = p; PyFrameObject *frame = p;
PyThreadState *tstate = PyThreadState_GET (); PyThreadState *tstate = PyThreadState_GET ();
tstate->frame = frame; tstate->frame = frame;
} }

View file

@ -47,9 +47,11 @@ static PyObject *
pspy_get_filename (PyObject *self, void *closure) pspy_get_filename (PyObject *self, void *closure)
{ {
pspace_object *obj = (pspace_object *) self; pspace_object *obj = (pspace_object *) self;
if (obj->pspace) if (obj->pspace)
{ {
struct objfile *objfile = obj->pspace->symfile_object_file; struct objfile *objfile = obj->pspace->symfile_object_file;
if (objfile && objfile->name) if (objfile && objfile->name)
return PyString_Decode (objfile->name, strlen (objfile->name), return PyString_Decode (objfile->name, strlen (objfile->name),
host_charset (), NULL); host_charset (), NULL);
@ -61,6 +63,7 @@ static void
pspy_dealloc (PyObject *self) pspy_dealloc (PyObject *self)
{ {
pspace_object *ps_self = (pspace_object *) self; pspace_object *ps_self = (pspace_object *) self;
Py_XDECREF (ps_self->printers); Py_XDECREF (ps_self->printers);
self->ob_type->tp_free (self); self->ob_type->tp_free (self);
} }
@ -69,6 +72,7 @@ static PyObject *
pspy_new (PyTypeObject *type, PyObject *args, PyObject *keywords) pspy_new (PyTypeObject *type, PyObject *args, PyObject *keywords)
{ {
pspace_object *self = (pspace_object *) type->tp_alloc (type, 0); pspace_object *self = (pspace_object *) type->tp_alloc (type, 0);
if (self) if (self)
{ {
self->pspace = NULL; self->pspace = NULL;
@ -87,6 +91,7 @@ PyObject *
pspy_get_printers (PyObject *o, void *ignore) pspy_get_printers (PyObject *o, void *ignore)
{ {
pspace_object *self = (pspace_object *) o; pspace_object *self = (pspace_object *) o;
Py_INCREF (self->printers); Py_INCREF (self->printers);
return self->printers; return self->printers;
} }
@ -96,6 +101,7 @@ pspy_set_printers (PyObject *o, PyObject *value, void *ignore)
{ {
PyObject *tmp; PyObject *tmp;
pspace_object *self = (pspace_object *) o; pspace_object *self = (pspace_object *) o;
if (! value) if (! value)
{ {
PyErr_SetString (PyExc_TypeError, PyErr_SetString (PyExc_TypeError,

View file

@ -322,8 +322,8 @@ symtab_and_line_to_sal_object (struct symtab_and_line sal)
{ {
sal_object *sal_obj; sal_object *sal_obj;
int success = 0; int success = 0;
sal_obj = PyObject_New (sal_object, &sal_object_type);
sal_obj = PyObject_New (sal_object, &sal_object_type);
if (sal_obj) if (sal_obj)
{ {
success = set_sal (sal_obj, sal); success = set_sal (sal_obj, sal);
@ -365,6 +365,7 @@ static void
del_objfile_symtab (struct objfile *objfile, void *datum) del_objfile_symtab (struct objfile *objfile, void *datum)
{ {
symtab_object *obj = datum; symtab_object *obj = datum;
while (obj) while (obj)
{ {
symtab_object *next = obj->next; symtab_object *next = obj->next;
@ -385,6 +386,7 @@ static void
del_objfile_sal (struct objfile *objfile, void *datum) del_objfile_sal (struct objfile *objfile, void *datum)
{ {
sal_object *obj = datum; sal_object *obj = datum;
while (obj) while (obj)
{ {
sal_object *next = obj->next; sal_object *next = obj->next;

View file

@ -101,6 +101,7 @@ static void
field_dealloc (PyObject *obj) field_dealloc (PyObject *obj)
{ {
field_object *f = (field_object *) obj; field_object *f = (field_object *) obj;
Py_XDECREF (f->dict); Py_XDECREF (f->dict);
f->ob_type->tp_free (obj); f->ob_type->tp_free (obj);
} }
@ -109,6 +110,7 @@ static PyObject *
field_new (void) field_new (void)
{ {
field_object *result = PyObject_New (field_object, &field_object_type); field_object *result = PyObject_New (field_object, &field_object_type);
if (result) if (result)
{ {
result->dict = PyDict_New (); result->dict = PyDict_New ();
@ -128,6 +130,7 @@ static PyObject *
typy_get_code (PyObject *self, void *closure) typy_get_code (PyObject *self, void *closure)
{ {
struct type *type = ((type_object *) self)->type; struct type *type = ((type_object *) self)->type;
return PyInt_FromLong (TYPE_CODE (type)); return PyInt_FromLong (TYPE_CODE (type));
} }
@ -222,6 +225,7 @@ typy_fields (PyObject *self, PyObject *args)
for (i = 0; i < TYPE_NFIELDS (type); ++i) for (i = 0; i < TYPE_NFIELDS (type); ++i)
{ {
PyObject *dict = convert_field (type, i); PyObject *dict = convert_field (type, i);
if (!dict) if (!dict)
{ {
Py_DECREF (result); Py_DECREF (result);
@ -243,6 +247,7 @@ static PyObject *
typy_get_tag (PyObject *self, void *closure) typy_get_tag (PyObject *self, void *closure)
{ {
struct type *type = ((type_object *) self)->type; struct type *type = ((type_object *) self)->type;
if (!TYPE_TAG_NAME (type)) if (!TYPE_TAG_NAME (type))
Py_RETURN_NONE; Py_RETURN_NONE;
return PyString_FromString (TYPE_TAG_NAME (type)); return PyString_FromString (TYPE_TAG_NAME (type));
@ -439,6 +444,7 @@ typy_lookup_typename (char *type_name, struct block *block)
{ {
struct type *type = NULL; struct type *type = NULL;
volatile struct gdb_exception except; volatile struct gdb_exception except;
TRY_CATCH (except, RETURN_MASK_ALL) TRY_CATCH (except, RETURN_MASK_ALL)
{ {
if (!strncmp (type_name, "struct ", 7)) if (!strncmp (type_name, "struct ", 7))
@ -675,6 +681,7 @@ typy_dealloc (PyObject *obj)
{ {
/* Must reset head of list. */ /* Must reset head of list. */
struct objfile *objfile = TYPE_OBJFILE (type->type); struct objfile *objfile = TYPE_OBJFILE (type->type);
if (objfile) if (objfile)
set_objfile_data (objfile, typy_objfile_data_key, type->next); set_objfile_data (objfile, typy_objfile_data_key, type->next);
} }

View file

@ -29,6 +29,7 @@ static void
py_decref (void *p) py_decref (void *p)
{ {
PyObject *py = p; PyObject *py = p;
/* Note that we need the extra braces in this 'if' to avoid a /* Note that we need the extra braces in this 'if' to avoid a
warning from gcc. */ warning from gcc. */
if (py) if (py)

View file

@ -207,6 +207,7 @@ static PyObject *
valpy_get_type (PyObject *self, void *closure) valpy_get_type (PyObject *self, void *closure)
{ {
value_object *obj = (value_object *) self; value_object *obj = (value_object *) self;
if (!obj->type) if (!obj->type)
{ {
obj->type = type_to_type_object (value_type (obj->value)); obj->type = type_to_type_object (value_type (obj->value));
@ -356,11 +357,13 @@ valpy_getitem (PyObject *self, PyObject *key)
value code throw an exception if the index has an invalid value code throw an exception if the index has an invalid
type. */ type. */
struct value *idx = convert_value_from_python (key); struct value *idx = convert_value_from_python (key);
if (idx != NULL) if (idx != NULL)
{ {
/* Check the value's type is something that can be accessed via /* Check the value's type is something that can be accessed via
a subscript. */ a subscript. */
struct type *type; struct type *type;
tmp = coerce_ref (tmp); tmp = coerce_ref (tmp);
type = check_typedef (value_type (tmp)); type = check_typedef (value_type (tmp));
if (TYPE_CODE (type) != TYPE_CODE_ARRAY if (TYPE_CODE (type) != TYPE_CODE_ARRAY
@ -632,6 +635,7 @@ static PyObject *
valpy_absolute (PyObject *self) valpy_absolute (PyObject *self)
{ {
struct value *value = ((value_object *) self)->value; struct value *value = ((value_object *) self)->value;
if (value_less (value, value_zero (value_type (value), not_lval))) if (value_less (value, value_zero (value_type (value), not_lval)))
return valpy_negative (self); return valpy_negative (self);
else else
@ -917,6 +921,7 @@ struct value *
value_object_to_value (PyObject *self) value_object_to_value (PyObject *self)
{ {
value_object *real; value_object *real;
if (! PyObject_TypeCheck (self, &value_object_type)) if (! PyObject_TypeCheck (self, &value_object_type))
return NULL; return NULL;
real = (value_object *) self; real = (value_object *) self;
@ -984,6 +989,7 @@ convert_value_from_python (PyObject *obj)
{ {
PyObject *result; PyObject *result;
PyObject *function = PyString_FromString ("value"); PyObject *function = PyString_FromString ("value");
result = PyObject_CallMethodObjArgs (obj, function, NULL); result = PyObject_CallMethodObjArgs (obj, function, NULL);
value = value_copy (((value_object *) result)->value); value = value_copy (((value_object *) result)->value);
} }

View file

@ -77,6 +77,7 @@ static void
restore_python_env (void *p) restore_python_env (void *p)
{ {
struct python_env *env = (struct python_env *)p; struct python_env *env = (struct python_env *)p;
PyGILState_Release (env->state); PyGILState_Release (env->state);
python_gdbarch = env->gdbarch; python_gdbarch = env->gdbarch;
python_language = env->language; python_language = env->language;
@ -124,6 +125,7 @@ compute_python_string (struct command_line *l)
for (iter = l; iter; iter = iter->next) for (iter = l; iter; iter = iter->next)
{ {
int len = strlen (iter->line); int len = strlen (iter->line);
strcpy (&script[here], iter->line); strcpy (&script[here], iter->line);
here += len; here += len;
script[here++] = '\n'; script[here++] = '\n';
@ -165,8 +167,8 @@ static void
python_command (char *arg, int from_tty) python_command (char *arg, int from_tty)
{ {
struct cleanup *cleanup; 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)) while (arg && *arg && isspace (*arg))
++arg; ++arg;
if (arg && *arg) if (arg && *arg)
@ -180,6 +182,7 @@ python_command (char *arg, int from_tty)
else else
{ {
struct command_line *l = get_command_line (python_control, ""); struct command_line *l = get_command_line (python_control, "");
make_cleanup_free_command_lines (&l); make_cleanup_free_command_lines (&l);
execute_control_command_untraced (l); execute_control_command_untraced (l);
} }
@ -204,6 +207,7 @@ gdbpy_parameter_value (enum var_types type, void *var)
case var_enum: case var_enum:
{ {
char *str = * (char **) var; char *str = * (char **) var;
if (! str) if (! str)
str = ""; str = "";
return PyString_Decode (str, strlen (str), host_charset (), NULL); return PyString_Decode (str, strlen (str), host_charset (), NULL);
@ -220,6 +224,7 @@ gdbpy_parameter_value (enum var_types type, void *var)
case var_auto_boolean: case var_auto_boolean:
{ {
enum auto_boolean ab = * (enum auto_boolean *) var; enum auto_boolean ab = * (enum auto_boolean *) var;
if (ab == AUTO_BOOLEAN_TRUE) if (ab == AUTO_BOOLEAN_TRUE)
Py_RETURN_TRUE; Py_RETURN_TRUE;
else if (ab == AUTO_BOOLEAN_FALSE) else if (ab == AUTO_BOOLEAN_FALSE)
@ -238,6 +243,7 @@ gdbpy_parameter_value (enum var_types type, void *var)
case var_uinteger: case var_uinteger:
{ {
unsigned int val = * (unsigned int *) var; unsigned int val = * (unsigned int *) var;
if (val == UINT_MAX) if (val == UINT_MAX)
Py_RETURN_NONE; Py_RETURN_NONE;
return PyLong_FromUnsignedLong (val); return PyLong_FromUnsignedLong (val);
@ -286,6 +292,7 @@ static PyObject *
gdbpy_target_charset (PyObject *self, PyObject *args) gdbpy_target_charset (PyObject *self, PyObject *args)
{ {
const char *cset = target_charset (python_gdbarch); const char *cset = target_charset (python_gdbarch);
return PyUnicode_Decode (cset, strlen (cset), host_charset (), NULL); return PyUnicode_Decode (cset, strlen (cset), host_charset (), NULL);
} }
@ -295,6 +302,7 @@ static PyObject *
gdbpy_target_wide_charset (PyObject *self, PyObject *args) gdbpy_target_wide_charset (PyObject *self, PyObject *args)
{ {
const char *cset = target_wide_charset (python_gdbarch); const char *cset = target_wide_charset (python_gdbarch);
return PyUnicode_Decode (cset, strlen (cset), host_charset (), NULL); return PyUnicode_Decode (cset, strlen (cset), host_charset (), NULL);
} }
@ -326,6 +334,7 @@ execute_gdb_command (PyObject *self, PyObject *args)
/* Copy the argument text in case the command modifies it. */ /* Copy the argument text in case the command modifies it. */
char *copy = xstrdup (arg); char *copy = xstrdup (arg);
struct cleanup *cleanup = make_cleanup (xfree, copy); struct cleanup *cleanup = make_cleanup (xfree, copy);
execute_command (copy, from_tty); execute_command (copy, from_tty);
do_cleanups (cleanup); do_cleanups (cleanup);
} }
@ -383,6 +392,7 @@ static PyObject *
gdbpy_write (PyObject *self, PyObject *args) gdbpy_write (PyObject *self, PyObject *args)
{ {
char *arg; char *arg;
if (! PyArg_ParseTuple (args, "s", &arg)) if (! PyArg_ParseTuple (args, "s", &arg))
return NULL; return NULL;
printf_filtered ("%s", arg); printf_filtered ("%s", arg);
@ -440,6 +450,7 @@ gdbpy_progspaces (PyObject *unused1, PyObject *unused2)
ALL_PSPACES (ps) ALL_PSPACES (ps)
{ {
PyObject *item = pspace_to_pspace_object (ps); PyObject *item = pspace_to_pspace_object (ps);
if (!item || PyList_Append (list, item) == -1) if (!item || PyList_Append (list, item) == -1)
{ {
Py_DECREF (list); Py_DECREF (list);
@ -509,6 +520,7 @@ gdbpy_objfiles (PyObject *unused1, PyObject *unused2)
ALL_OBJFILES (objf) ALL_OBJFILES (objf)
{ {
PyObject *item = objfile_to_objfile_object (objf); PyObject *item = objfile_to_objfile_object (objf);
if (!item || PyList_Append (list, item) == -1) if (!item || PyList_Append (list, item) == -1)
{ {
Py_DECREF (list); Py_DECREF (list);
@ -534,6 +546,7 @@ python_command (char *arg, int from_tty)
{ {
struct command_line *l = get_command_line (python_control, ""); struct command_line *l = get_command_line (python_control, "");
struct cleanup *cleanups = make_cleanup_free_command_lines (&l); struct cleanup *cleanups = make_cleanup_free_command_lines (&l);
execute_control_command_untraced (l); execute_control_command_untraced (l);
do_cleanups (cleanups); do_cleanups (cleanups);
} }