aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog16
-rw-r--r--gdb/python/py-auto-load.c4
-rw-r--r--gdb/python/py-block.c2
-rw-r--r--gdb/python/py-breakpoint.c2
-rw-r--r--gdb/python/py-cmd.c6
-rw-r--r--gdb/python/py-function.c2
-rw-r--r--gdb/python/py-lazy-string.c4
-rw-r--r--gdb/python/py-objfile.c5
-rw-r--r--gdb/python/py-param.c4
-rw-r--r--gdb/python/py-prettyprint.c1
-rw-r--r--gdb/python/py-progspace.c6
-rw-r--r--gdb/python/py-symtab.c4
-rw-r--r--gdb/python/py-type.c7
-rw-r--r--gdb/python/py-utils.c1
-rw-r--r--gdb/python/py-value.c6
-rw-r--r--gdb/python/python.c15
16 files changed, 82 insertions, 3 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index a05f867..cd91d9d 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,21 @@
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-env.c: White space.
* mi/mi-cmds.c: White space.
diff --git a/gdb/python/py-auto-load.c b/gdb/python/py-auto-load.c
index 932ae68..044d968 100644
--- a/gdb/python/py-auto-load.c
+++ b/gdb/python/py-auto-load.c
@@ -128,6 +128,7 @@ static hashval_t
hash_loaded_script_entry (const void *data)
{
const struct loaded_script_entry *e = data;
+
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 *eb = b;
+
return strcmp (ea->name, eb->name) == 0;
}
@@ -202,6 +204,7 @@ source_section_scripts (struct objfile *objfile, const char *source_name,
if (p == end)
{
char *buf = alloca (p - file + 1);
+
memcpy (buf, file, p - file);
buf[p - file] = '\0';
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)
{
char *p;
+
*slot = xmalloc (sizeof (**slot)
+ strlen (file) + 1
+ (opened ? (strlen (full_path) + 1) : 0));
diff --git a/gdb/python/py-block.c b/gdb/python/py-block.c
index 4055174..8d7fb79 100644
--- a/gdb/python/py-block.c
+++ b/gdb/python/py-block.c
@@ -259,6 +259,7 @@ static void
blpy_block_syms_dealloc (PyObject *obj)
{
block_syms_iterator_object *iter_obj = (block_syms_iterator_object *) obj;
+
Py_XDECREF (iter_obj->source);
}
@@ -300,6 +301,7 @@ static void
del_objfile_blocks (struct objfile *objfile, void *datum)
{
block_object *obj = datum;
+
while (obj)
{
block_object *next = obj->next;
diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c
index 24eebb7..fb96b54 100644
--- a/gdb/python/py-breakpoint.c
+++ b/gdb/python/py-breakpoint.c
@@ -642,6 +642,7 @@ gdbpy_breakpoints (PyObject *self, PyObject *args)
if (result)
{
int i, out = 0;
+
for (i = 0; out < bppy_live; ++i)
{
if (! bppy_breakpoints[i])
@@ -684,6 +685,7 @@ gdbpy_breakpoint_created (int num)
if (num >= bppy_slots)
{
int old = bppy_slots;
+
bppy_slots = bppy_slots * 2 + 10;
bppy_breakpoints
= (breakpoint_object **) xrealloc (bppy_breakpoints,
diff --git a/gdb/python/py-cmd.c b/gdb/python/py-cmd.c
index 677a03d..f9a4130 100644
--- a/gdb/python/py-cmd.c
+++ b/gdb/python/py-cmd.c
@@ -156,8 +156,8 @@ cmdpy_function (struct cmd_list_element *command, char *args, int from_tty)
/* Make a temporary copy of the string data. */
char *s = PyString_AsString (pvalue);
char *copy = alloca (strlen (s) + 1);
- strcpy (copy, s);
+ strcpy (copy, s);
PyErr_Restore (ptype, pvalue, ptraceback);
gdbpy_print_stack ();
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 out;
+
if (len < 0)
goto done;
@@ -224,6 +225,7 @@ cmdpy_completer (struct cmd_list_element *command, char *text, char *word)
for (i = out = 0; i < len; ++i)
{
PyObject *elt = PySequence_GetItem (resultobj, i);
+
if (elt == NULL || ! gdbpy_is_string (elt))
{
/* 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,
thus requesting that sort of completion. */
long value = PyInt_AsLong (resultobj);
+
if (value >= 0 && value < (long) N_COMPLETERS)
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))
{
PyObject *ds_obj = PyObject_GetAttr (self, gdbpy_doc_cst);
+
if (ds_obj && gdbpy_is_string (ds_obj))
docstring = python_string_to_host_string (ds_obj);
}
diff --git a/gdb/python/py-function.c b/gdb/python/py-function.c
index 7286d64..f09c6b4 100644
--- a/gdb/python/py-function.c
+++ b/gdb/python/py-function.c
@@ -38,6 +38,7 @@ convert_values_to_python (int argc, struct value **argv)
{
int i;
PyObject *result = PyTuple_New (argc);
+
for (i = 0; i < argc; ++i)
{
PyObject *elt = value_to_value_object (argv[i]);
@@ -103,6 +104,7 @@ static int
fnpy_init (PyObject *self, PyObject *args, PyObject *kwds)
{
char *name, *docstring = NULL;
+
if (! PyArg_ParseTuple (args, "s", &name))
return -1;
Py_INCREF (self);
diff --git a/gdb/python/py-lazy-string.c b/gdb/python/py-lazy-string.c
index d28aae2..23cf13a 100644
--- a/gdb/python/py-lazy-string.c
+++ b/gdb/python/py-lazy-string.c
@@ -52,6 +52,7 @@ static PyObject *
stpy_get_address (PyObject *self, void *closure)
{
lazy_string_object *self_string = (lazy_string_object *) self;
+
return PyLong_FromUnsignedLongLong (self_string->address);
}
@@ -78,6 +79,7 @@ static PyObject *
stpy_get_length (PyObject *self, void *closure)
{
lazy_string_object *self_string = (lazy_string_object *) self;
+
return PyLong_FromLong (self_string->length);
}
@@ -85,6 +87,7 @@ PyObject *
stpy_get_type (PyObject *self, void *closure)
{
lazy_string_object *str_obj = (lazy_string_object *) self;
+
return type_to_type_object (str_obj->type);
}
@@ -109,6 +112,7 @@ static void
stpy_dealloc (PyObject *self)
{
lazy_string_object *self_string = (lazy_string_object *) self;
+
xfree (self_string->encoding);
}
diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c
index 732edb0..1aa6a4d 100644
--- a/gdb/python/py-objfile.c
+++ b/gdb/python/py-objfile.c
@@ -45,6 +45,7 @@ static PyObject *
objfpy_get_filename (PyObject *self, void *closure)
{
objfile_object *obj = (objfile_object *) self;
+
if (obj->objfile && obj->objfile->name)
return PyString_Decode (obj->objfile->name, strlen (obj->objfile->name),
host_charset (), NULL);
@@ -55,6 +56,7 @@ static void
objfpy_dealloc (PyObject *o)
{
objfile_object *self = (objfile_object *) o;
+
Py_XDECREF (self->printers);
self->ob_type->tp_free ((PyObject *) self);
}
@@ -63,6 +65,7 @@ static PyObject *
objfpy_new (PyTypeObject *type, PyObject *args, PyObject *keywords)
{
objfile_object *self = (objfile_object *) type->tp_alloc (type, 0);
+
if (self)
{
self->objfile = NULL;
@@ -81,6 +84,7 @@ PyObject *
objfpy_get_printers (PyObject *o, void *ignore)
{
objfile_object *self = (objfile_object *) o;
+
Py_INCREF (self->printers);
return self->printers;
}
@@ -90,6 +94,7 @@ objfpy_set_printers (PyObject *o, PyObject *value, void *ignore)
{
PyObject *tmp;
objfile_object *self = (objfile_object *) o;
+
if (! value)
{
PyErr_SetString (PyExc_TypeError,
diff --git a/gdb/python/py-param.c b/gdb/python/py-param.c
index e2319e5..5596eb7 100644
--- a/gdb/python/py-param.c
+++ b/gdb/python/py-param.c
@@ -103,6 +103,7 @@ get_attr (PyObject *obj, PyObject *attr_name)
&& ! strcmp (PyString_AsString (attr_name), "value"))
{
parmpy_object *self = (parmpy_object *) obj;
+
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)
{
PyObject *item = PySequence_GetItem (enum_values, i);
+
if (! item)
return 0;
if (! gdbpy_is_string (item))
@@ -414,9 +416,11 @@ static char *
get_doc_string (PyObject *object, PyObject *attr)
{
char *result = NULL;
+
if (PyObject_HasAttr (object, attr))
{
PyObject *ds_obj = PyObject_GetAttr (object, attr);
+
if (ds_obj && gdbpy_is_string (ds_obj))
result = python_string_to_host_string (ds_obj);
}
diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c
index dcca24d..e678898 100644
--- a/gdb/python/py-prettyprint.c
+++ b/gdb/python/py-prettyprint.c
@@ -319,6 +319,7 @@ py_restore_tstate (void *p)
{
PyFrameObject *frame = p;
PyThreadState *tstate = PyThreadState_GET ();
+
tstate->frame = frame;
}
diff --git a/gdb/python/py-progspace.c b/gdb/python/py-progspace.c
index ead616b..8724532 100644
--- a/gdb/python/py-progspace.c
+++ b/gdb/python/py-progspace.c
@@ -47,9 +47,11 @@ static PyObject *
pspy_get_filename (PyObject *self, void *closure)
{
pspace_object *obj = (pspace_object *) self;
+
if (obj->pspace)
{
struct objfile *objfile = obj->pspace->symfile_object_file;
+
if (objfile && objfile->name)
return PyString_Decode (objfile->name, strlen (objfile->name),
host_charset (), NULL);
@@ -61,6 +63,7 @@ static void
pspy_dealloc (PyObject *self)
{
pspace_object *ps_self = (pspace_object *) self;
+
Py_XDECREF (ps_self->printers);
self->ob_type->tp_free (self);
}
@@ -69,6 +72,7 @@ static PyObject *
pspy_new (PyTypeObject *type, PyObject *args, PyObject *keywords)
{
pspace_object *self = (pspace_object *) type->tp_alloc (type, 0);
+
if (self)
{
self->pspace = NULL;
@@ -87,6 +91,7 @@ PyObject *
pspy_get_printers (PyObject *o, void *ignore)
{
pspace_object *self = (pspace_object *) o;
+
Py_INCREF (self->printers);
return self->printers;
}
@@ -96,6 +101,7 @@ pspy_set_printers (PyObject *o, PyObject *value, void *ignore)
{
PyObject *tmp;
pspace_object *self = (pspace_object *) o;
+
if (! value)
{
PyErr_SetString (PyExc_TypeError,
diff --git a/gdb/python/py-symtab.c b/gdb/python/py-symtab.c
index 6c805b7..5b4294d 100644
--- a/gdb/python/py-symtab.c
+++ b/gdb/python/py-symtab.c
@@ -322,8 +322,8 @@ symtab_and_line_to_sal_object (struct symtab_and_line sal)
{
sal_object *sal_obj;
int success = 0;
- sal_obj = PyObject_New (sal_object, &sal_object_type);
+ sal_obj = PyObject_New (sal_object, &sal_object_type);
if (sal_obj)
{
success = set_sal (sal_obj, sal);
@@ -365,6 +365,7 @@ static void
del_objfile_symtab (struct objfile *objfile, void *datum)
{
symtab_object *obj = datum;
+
while (obj)
{
symtab_object *next = obj->next;
@@ -385,6 +386,7 @@ static void
del_objfile_sal (struct objfile *objfile, void *datum)
{
sal_object *obj = datum;
+
while (obj)
{
sal_object *next = obj->next;
diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c
index ef658df..b901255 100644
--- a/gdb/python/py-type.c
+++ b/gdb/python/py-type.c
@@ -101,6 +101,7 @@ static void
field_dealloc (PyObject *obj)
{
field_object *f = (field_object *) obj;
+
Py_XDECREF (f->dict);
f->ob_type->tp_free (obj);
}
@@ -109,6 +110,7 @@ static PyObject *
field_new (void)
{
field_object *result = PyObject_New (field_object, &field_object_type);
+
if (result)
{
result->dict = PyDict_New ();
@@ -128,6 +130,7 @@ static PyObject *
typy_get_code (PyObject *self, void *closure)
{
struct type *type = ((type_object *) self)->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)
{
PyObject *dict = convert_field (type, i);
+
if (!dict)
{
Py_DECREF (result);
@@ -243,6 +247,7 @@ static PyObject *
typy_get_tag (PyObject *self, void *closure)
{
struct type *type = ((type_object *) self)->type;
+
if (!TYPE_TAG_NAME (type))
Py_RETURN_NONE;
return PyString_FromString (TYPE_TAG_NAME (type));
@@ -439,6 +444,7 @@ typy_lookup_typename (char *type_name, struct block *block)
{
struct type *type = NULL;
volatile struct gdb_exception except;
+
TRY_CATCH (except, RETURN_MASK_ALL)
{
if (!strncmp (type_name, "struct ", 7))
@@ -675,6 +681,7 @@ typy_dealloc (PyObject *obj)
{
/* Must reset head of list. */
struct objfile *objfile = TYPE_OBJFILE (type->type);
+
if (objfile)
set_objfile_data (objfile, typy_objfile_data_key, type->next);
}
diff --git a/gdb/python/py-utils.c b/gdb/python/py-utils.c
index aed8fff..cd11834 100644
--- a/gdb/python/py-utils.c
+++ b/gdb/python/py-utils.c
@@ -29,6 +29,7 @@ static void
py_decref (void *p)
{
PyObject *py = p;
+
/* Note that we need the extra braces in this 'if' to avoid a
warning from gcc. */
if (py)
diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c
index abf50ff..eb20de8 100644
--- a/gdb/python/py-value.c
+++ b/gdb/python/py-value.c
@@ -207,6 +207,7 @@ static PyObject *
valpy_get_type (PyObject *self, void *closure)
{
value_object *obj = (value_object *) self;
+
if (!obj->type)
{
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
type. */
struct value *idx = convert_value_from_python (key);
+
if (idx != NULL)
{
/* Check the value's type is something that can be accessed via
a subscript. */
struct type *type;
+
tmp = coerce_ref (tmp);
type = check_typedef (value_type (tmp));
if (TYPE_CODE (type) != TYPE_CODE_ARRAY
@@ -632,6 +635,7 @@ static PyObject *
valpy_absolute (PyObject *self)
{
struct value *value = ((value_object *) self)->value;
+
if (value_less (value, value_zero (value_type (value), not_lval)))
return valpy_negative (self);
else
@@ -917,6 +921,7 @@ struct value *
value_object_to_value (PyObject *self)
{
value_object *real;
+
if (! PyObject_TypeCheck (self, &value_object_type))
return NULL;
real = (value_object *) self;
@@ -984,6 +989,7 @@ convert_value_from_python (PyObject *obj)
{
PyObject *result;
PyObject *function = PyString_FromString ("value");
+
result = PyObject_CallMethodObjArgs (obj, function, NULL);
value = value_copy (((value_object *) result)->value);
}
diff --git a/gdb/python/python.c b/gdb/python/python.c
index 0f66f67..f03af2e 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -77,6 +77,7 @@ static void
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;
@@ -124,6 +125,7 @@ compute_python_string (struct command_line *l)
for (iter = l; iter; iter = iter->next)
{
int len = strlen (iter->line);
+
strcpy (&script[here], iter->line);
here += len;
script[here++] = '\n';
@@ -165,8 +167,8 @@ static void
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)
@@ -180,6 +182,7 @@ python_command (char *arg, int from_tty)
else
{
struct command_line *l = get_command_line (python_control, "");
+
make_cleanup_free_command_lines (&l);
execute_control_command_untraced (l);
}
@@ -204,6 +207,7 @@ gdbpy_parameter_value (enum var_types type, void *var)
case var_enum:
{
char *str = * (char **) var;
+
if (! str)
str = "";
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:
{
enum auto_boolean ab = * (enum auto_boolean *) var;
+
if (ab == AUTO_BOOLEAN_TRUE)
Py_RETURN_TRUE;
else if (ab == AUTO_BOOLEAN_FALSE)
@@ -238,6 +243,7 @@ gdbpy_parameter_value (enum var_types type, void *var)
case var_uinteger:
{
unsigned int val = * (unsigned int *) var;
+
if (val == UINT_MAX)
Py_RETURN_NONE;
return PyLong_FromUnsignedLong (val);
@@ -286,6 +292,7 @@ static PyObject *
gdbpy_target_charset (PyObject *self, PyObject *args)
{
const char *cset = target_charset (python_gdbarch);
+
return PyUnicode_Decode (cset, strlen (cset), host_charset (), NULL);
}
@@ -295,6 +302,7 @@ static PyObject *
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);
}
@@ -326,6 +334,7 @@ execute_gdb_command (PyObject *self, PyObject *args)
/* 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);
}
@@ -383,6 +392,7 @@ static PyObject *
gdbpy_write (PyObject *self, PyObject *args)
{
char *arg;
+
if (! PyArg_ParseTuple (args, "s", &arg))
return NULL;
printf_filtered ("%s", arg);
@@ -440,6 +450,7 @@ gdbpy_progspaces (PyObject *unused1, PyObject *unused2)
ALL_PSPACES (ps)
{
PyObject *item = pspace_to_pspace_object (ps);
+
if (!item || PyList_Append (list, item) == -1)
{
Py_DECREF (list);
@@ -509,6 +520,7 @@ gdbpy_objfiles (PyObject *unused1, PyObject *unused2)
ALL_OBJFILES (objf)
{
PyObject *item = objfile_to_objfile_object (objf);
+
if (!item || PyList_Append (list, item) == -1)
{
Py_DECREF (list);
@@ -534,6 +546,7 @@ python_command (char *arg, int from_tty)
{
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);
}