* 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.
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.
hash_loaded_script_entry (const void *data)
{
const struct loaded_script_entry *e = data;
+
return htab_hash_string (e->name);
}
{
const struct loaded_script_entry *ea = a;
const struct loaded_script_entry *eb = b;
+
return strcmp (ea->name, eb->name) == 0;
}
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"),
if (! in_hash_table)
{
char *p;
+
*slot = xmalloc (sizeof (**slot)
+ strlen (file) + 1
+ (opened ? (strlen (full_path) + 1) : 0));
blpy_block_syms_dealloc (PyObject *obj)
{
block_syms_iterator_object *iter_obj = (block_syms_iterator_object *) obj;
+
Py_XDECREF (iter_obj->source);
}
del_objfile_blocks (struct objfile *objfile, void *datum)
{
block_object *obj = datum;
+
while (obj)
{
block_object *next = obj->next;
if (result)
{
int i, out = 0;
+
for (i = 0; out < bppy_live; ++i)
{
if (! bppy_breakpoints[i])
if (num >= bppy_slots)
{
int old = bppy_slots;
+
bppy_slots = bppy_slots * 2 + 10;
bppy_breakpoints
= (breakpoint_object **) xrealloc (bppy_breakpoints,
/* 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);
{
Py_ssize_t i, len = PySequence_Size (resultobj);
Py_ssize_t out;
+
if (len < 0)
goto done;
for (i = out = 0; i < len; ++i)
{
PyObject *elt = PySequence_GetItem (resultobj, i);
+
if (elt == NULL || ! gdbpy_is_string (elt))
{
/* Skip problem elements. */
/* 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);
}
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);
}
{
int i;
PyObject *result = PyTuple_New (argc);
+
for (i = 0; i < argc; ++i)
{
PyObject *elt = value_to_value_object (argv[i]);
fnpy_init (PyObject *self, PyObject *args, PyObject *kwds)
{
char *name, *docstring = NULL;
+
if (! PyArg_ParseTuple (args, "s", &name))
return -1;
Py_INCREF (self);
stpy_get_address (PyObject *self, void *closure)
{
lazy_string_object *self_string = (lazy_string_object *) self;
+
return PyLong_FromUnsignedLongLong (self_string->address);
}
stpy_get_length (PyObject *self, void *closure)
{
lazy_string_object *self_string = (lazy_string_object *) self;
+
return PyLong_FromLong (self_string->length);
}
stpy_get_type (PyObject *self, void *closure)
{
lazy_string_object *str_obj = (lazy_string_object *) self;
+
return type_to_type_object (str_obj->type);
}
stpy_dealloc (PyObject *self)
{
lazy_string_object *self_string = (lazy_string_object *) self;
+
xfree (self_string->encoding);
}
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);
objfpy_dealloc (PyObject *o)
{
objfile_object *self = (objfile_object *) o;
+
Py_XDECREF (self->printers);
self->ob_type->tp_free ((PyObject *) self);
}
objfpy_new (PyTypeObject *type, PyObject *args, PyObject *keywords)
{
objfile_object *self = (objfile_object *) type->tp_alloc (type, 0);
+
if (self)
{
self->objfile = NULL;
objfpy_get_printers (PyObject *o, void *ignore)
{
objfile_object *self = (objfile_object *) o;
+
Py_INCREF (self->printers);
return self->printers;
}
{
PyObject *tmp;
objfile_object *self = (objfile_object *) o;
+
if (! value)
{
PyErr_SetString (PyExc_TypeError,
&& ! strcmp (PyString_AsString (attr_name), "value"))
{
parmpy_object *self = (parmpy_object *) obj;
+
return gdbpy_parameter_value (self->type, &self->value);
}
for (i = 0; i < size; ++i)
{
PyObject *item = PySequence_GetItem (enum_values, i);
+
if (! item)
return 0;
if (! gdbpy_is_string (item))
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);
}
{
PyFrameObject *frame = p;
PyThreadState *tstate = PyThreadState_GET ();
+
tstate->frame = frame;
}
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);
pspy_dealloc (PyObject *self)
{
pspace_object *ps_self = (pspace_object *) self;
+
Py_XDECREF (ps_self->printers);
self->ob_type->tp_free (self);
}
pspy_new (PyTypeObject *type, PyObject *args, PyObject *keywords)
{
pspace_object *self = (pspace_object *) type->tp_alloc (type, 0);
+
if (self)
{
self->pspace = NULL;
pspy_get_printers (PyObject *o, void *ignore)
{
pspace_object *self = (pspace_object *) o;
+
Py_INCREF (self->printers);
return self->printers;
}
{
PyObject *tmp;
pspace_object *self = (pspace_object *) o;
+
if (! value)
{
PyErr_SetString (PyExc_TypeError,
{
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);
del_objfile_symtab (struct objfile *objfile, void *datum)
{
symtab_object *obj = datum;
+
while (obj)
{
symtab_object *next = obj->next;
del_objfile_sal (struct objfile *objfile, void *datum)
{
sal_object *obj = datum;
+
while (obj)
{
sal_object *next = obj->next;
field_dealloc (PyObject *obj)
{
field_object *f = (field_object *) obj;
+
Py_XDECREF (f->dict);
f->ob_type->tp_free (obj);
}
field_new (void)
{
field_object *result = PyObject_New (field_object, &field_object_type);
+
if (result)
{
result->dict = PyDict_New ();
typy_get_code (PyObject *self, void *closure)
{
struct type *type = ((type_object *) self)->type;
+
return PyInt_FromLong (TYPE_CODE (type));
}
for (i = 0; i < TYPE_NFIELDS (type); ++i)
{
PyObject *dict = convert_field (type, i);
+
if (!dict)
{
Py_DECREF (result);
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));
{
struct type *type = NULL;
volatile struct gdb_exception except;
+
TRY_CATCH (except, RETURN_MASK_ALL)
{
if (!strncmp (type_name, "struct ", 7))
{
/* Must reset head of list. */
struct objfile *objfile = TYPE_OBJFILE (type->type);
+
if (objfile)
set_objfile_data (objfile, typy_objfile_data_key, type->next);
}
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)
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));
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
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
value_object_to_value (PyObject *self)
{
value_object *real;
+
if (! PyObject_TypeCheck (self, &value_object_type))
return NULL;
real = (value_object *) self;
{
PyObject *result;
PyObject *function = PyString_FromString ("value");
+
result = PyObject_CallMethodObjArgs (obj, function, NULL);
value = value_copy (((value_object *) result)->value);
}
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);
}