Whitespace cleanup.
* python/py-breakpoint.c: Remove trailing whitespace.
* python/py-cmd.c: Ditto.
* python/py-evts.c: Ditto.
* python/py-finishbreakpoint.c: Ditto.
* python/py-frame.c: Ditto.
* python/py-function.c: Ditto.
* python/py-inferior.c: Ditto.
* python/py-infthread.c: Ditto.
* python/py-param.c: Ditto.
* python/py-prettyprint.c: Ditto.
* python/py-symbol.c: Ditto.
* python/py-type.c: Ditto.
* python/py-utils.c: Ditto.
* python/py-value.c: Ditto.
* python/python-internal.h: Ditto.
* python/python.c: Ditto.
+2013-11-29 Doug Evans <xdje42@gmail.com>
+
+ Whitespace cleanup.
+ * python/py-breakpoint.c: Remove trailing whitespace.
+ * python/py-cmd.c: Ditto.
+ * python/py-evts.c: Ditto.
+ * python/py-finishbreakpoint.c: Ditto.
+ * python/py-frame.c: Ditto.
+ * python/py-function.c: Ditto.
+ * python/py-inferior.c: Ditto.
+ * python/py-infthread.c: Ditto.
+ * python/py-param.c: Ditto.
+ * python/py-prettyprint.c: Ditto.
+ * python/py-symbol.c: Ditto.
+ * python/py-type.c: Ditto.
+ * python/py-utils.c: Ditto.
+ * python/py-value.c: Ditto.
+ * python/python-internal.h: Ditto.
+ * python/python.c: Ditto.
+
2013-11-29 Pedro Alves <palves@redhat.com>
* unwind_stop_reasons.def (UNWIND_NULL_ID): Update comment.
if (newvalue == NULL)
{
- PyErr_SetString (PyExc_TypeError,
+ PyErr_SetString (PyExc_TypeError,
_("Cannot delete `enabled' attribute."));
return -1;
if (newvalue == NULL)
{
- PyErr_SetString (PyExc_TypeError,
+ PyErr_SetString (PyExc_TypeError,
_("Cannot delete `silent' attribute."));
return -1;
}
if (newvalue == NULL)
{
- PyErr_SetString (PyExc_TypeError,
+ PyErr_SetString (PyExc_TypeError,
_("Cannot delete `thread' attribute."));
return -1;
}
if (! valid_thread_id (id))
{
- PyErr_SetString (PyExc_RuntimeError,
+ PyErr_SetString (PyExc_RuntimeError,
_("Invalid thread ID."));
return -1;
}
if (newvalue == NULL)
{
- PyErr_SetString (PyExc_TypeError,
+ PyErr_SetString (PyExc_TypeError,
_("Cannot delete `task' attribute."));
return -1;
}
if (! valid_id)
{
- PyErr_SetString (PyExc_RuntimeError,
+ PyErr_SetString (PyExc_RuntimeError,
_("Invalid task ID."));
return -1;
}
if (newvalue == NULL)
{
- PyErr_SetString (PyExc_TypeError,
+ PyErr_SetString (PyExc_TypeError,
_("Cannot delete `hit_count' attribute."));
return -1;
}
if (newvalue == NULL)
{
- PyErr_SetString (PyExc_TypeError,
+ PyErr_SetString (PyExc_TypeError,
_("Cannot delete `condition' attribute."));
return -1;
}
bppy_pending_object = (gdbpy_breakpoint_object *) self;
bppy_pending_object->number = -1;
bppy_pending_object->bp = NULL;
-
+
TRY_CATCH (except, RETURN_MASK_ALL)
{
char *copy = xstrdup (spec);
struct gdbarch *garch = bp_obj->bp->gdbarch ? bp_obj->bp->gdbarch :
get_current_arch ();
struct cleanup *cleanup = ensure_python_env (garch, current_language);
-
+
if (py_bp != NULL)
has_func = PyObject_HasAttrString (py_bp, stop_func);
if (bp->number < 0 && bppy_pending_object == NULL)
return;
- if (bp->type != bp_breakpoint
+ if (bp->type != bp_breakpoint
&& bp->type != bp_watchpoint
- && bp->type != bp_hardware_watchpoint
+ && bp->type != bp_hardware_watchpoint
&& bp->type != bp_read_watchpoint
&& bp->type != bp_access_watchpoint)
return;
PyObject_GenericSetAttr to allow extra validation of the attribute
being set. */
-static int
+static int
local_setattro (PyObject *self, PyObject *name, PyObject *v)
{
- gdbpy_breakpoint_object *obj = (gdbpy_breakpoint_object *) self;
+ gdbpy_breakpoint_object *obj = (gdbpy_breakpoint_object *) self;
char *attr = python_string_to_host_string (name);
-
+
if (attr == NULL)
return -1;
-
+
/* If the attribute trying to be set is the "stop" method,
but we already have a condition set in the CLI, disallow this
operation. */
if (strcmp (attr, stop_func) == 0 && obj->bp->cond_string)
{
xfree (attr);
- PyErr_SetString (PyExc_RuntimeError,
+ PyErr_SetString (PyExc_RuntimeError,
_("Cannot set 'stop' method. There is an " \
"existing GDB condition attached to the " \
"breakpoint."));
return -1;
}
-
+
xfree (attr);
-
- return PyObject_GenericSetAttr ((PyObject *)self, name, v);
+
+ return PyObject_GenericSetAttr ((PyObject *)self, name, v);
}
static PyGetSetDef breakpoint_object_getset[] = {
/* Helper for cmdpy_init which locates the command list to use and
pulls out the command name.
-
+
NAME is the command name list. The final word in the list is the
name of the new command. All earlier words must be existing prefix
commands.
*BASE_LIST is set to the final prefix command's list of
*sub-commands.
-
+
START_LIST is the list in which the search starts.
This function returns the xmalloc()d name of the new command. On
return -1;
pfx_name = NULL;
- if (is_prefix != NULL)
+ if (is_prefix != NULL)
{
cmp = PyObject_IsTrue (is_prefix);
if (cmp == 1)
{
int i, out;
-
+
/* Make a normalized form of the command name. */
pfx_name = xmalloc (strlen (name) + 2);
-
+
i = 0;
out = 0;
while (name[i])
PyModuleDef_HEAD_INIT,
"gdb.events",
NULL,
- -1,
+ -1,
NULL,
NULL,
NULL,
if (frame == NULL)
{
- PyErr_SetString (PyExc_ValueError,
+ PyErr_SetString (PyExc_ValueError,
_("Invalid ID for the `frame' object."));
}
else
if (internal)
{
internal_bp = PyObject_IsTrue (internal);
- if (internal_bp == -1)
+ if (internal_bp == -1)
{
- PyErr_SetString (PyExc_ValueError,
+ PyErr_SetString (PyExc_ValueError,
_("The value of `internal' must be a boolean."));
return -1;
}
0, 1, internal_bp, 0);
}
GDB_PY_SET_HANDLE_EXCEPTION (except);
-
+
self_bpfinish->py_bp.bp->frame_id = frame_id;
self_bpfinish->py_bp.is_finish_bp = 1;
-
+
/* Bind the breakpoint with the current program space. */
self_bpfinish->py_bp.bp->pspace = current_program_space;
struct breakpoint *bp_stopped = (struct breakpoint *) args;
PyObject *py_bp = (PyObject *) b->py_bp_object;
struct gdbarch *garch = b->gdbarch ? b->gdbarch : get_current_arch ();
-
+
/* Trigger out_of_scope if this is a FinishBreakpoint and its frame is
not anymore in the current callstack. */
if (py_bp != NULL && b->py_bp_object->is_finish_bp)
{
if (PyType_Ready (&finish_breakpoint_object_type) < 0)
return -1;
-
+
if (gdb_pymodule_addobject (gdb_module, "FinishBreakpoint",
(PyObject *) &finish_breakpoint_object_type) < 0)
return -1;
-
+
observer_attach_normal_stop (bpfinishpy_handle_stop);
observer_attach_inferior_exit (bpfinishpy_handle_exit);
struct frame_info *
frame_object_to_frame_info (PyObject *obj)
{
- frame_object *frame_obj = (frame_object *) obj;
+ frame_object *frame_obj = (frame_object *) obj;
struct frame_info *frame;
frame = frame_find_by_id (frame_obj->frame_id);
if (reason < UNWIND_FIRST || reason > UNWIND_LAST)
{
- PyErr_SetString (PyExc_ValueError,
+ PyErr_SetString (PyExc_ValueError,
_("Invalid frame stop reason."));
return NULL;
}
{
int i;
PyObject *result = PyTuple_New (argc);
-
+
if (! result)
return NULL;
struct cleanup *cleanup;
inferior_object *inf_obj;
struct threadlist_entry **entry, *tmp;
-
+
if (!gdb_python_initialized)
return;
{
membuf_object *membuf_obj = (membuf_object *) self;
int ret;
-
+
ret = PyBuffer_FillInfo (buf, self, membuf_obj->buffer,
- membuf_obj->length, 0,
+ membuf_obj->length, 0,
PyBUF_CONTIG);
buf->format = "c";
pattern_size = pybuf.len;
#else
PyObject *pattern;
-
+
if (! PyArg_ParseTupleAndKeywords (args, kw, "OOO", keywords,
&start_addr_obj, &length_obj,
&pattern))
if (get_addr_from_python (start_addr_obj, &start_addr) < 0)
goto fail;
-
+
if (get_addr_from_python (length_obj, &length) < 0)
goto fail;
if (newvalue == NULL)
{
- PyErr_SetString (PyExc_TypeError,
+ PyErr_SetString (PyExc_TypeError,
_("Cannot delete `name' attribute."));
return -1;
}
&& (self->type == var_filename
|| value != Py_None))
{
- PyErr_SetString (PyExc_RuntimeError,
+ PyErr_SetString (PyExc_RuntimeError,
_("String required for filename."));
return -1;
if (! gdbpy_is_string (value))
{
- PyErr_SetString (PyExc_RuntimeError,
+ PyErr_SetString (PyExc_RuntimeError,
_("ENUM arguments must be a string."));
return -1;
}
case var_boolean:
if (! PyBool_Check (value))
{
- PyErr_SetString (PyExc_RuntimeError,
+ PyErr_SetString (PyExc_RuntimeError,
_("A boolean argument is required."));
return -1;
}
cmp = PyObject_IsTrue (value);
- if (cmp < 0)
+ if (cmp < 0)
return -1;
self->value.intval = cmp;
break;
{
cmp = PyObject_IsTrue (value);
if (cmp < 0 )
- return -1;
+ return -1;
if (cmp == 1)
self->value.autoboolval = AUTO_BOOLEAN_TRUE;
- else
+ else
self->value.autoboolval = AUTO_BOOLEAN_FALSE;
}
break;
if (! PyInt_Check (value))
{
- PyErr_SetString (PyExc_RuntimeError,
+ PyErr_SetString (PyExc_RuntimeError,
_("The value must be integer."));
return -1;
}
if (! ok)
{
- PyErr_SetString (PyExc_RuntimeError,
+ PyErr_SetString (PyExc_RuntimeError,
_("Range exceeded."));
return -1;
}
}
default:
- PyErr_SetString (PyExc_RuntimeError,
+ PyErr_SetString (PyExc_RuntimeError,
_("Unhandled type in parameter value."));
return -1;
}
if (! PySequence_Check (enum_values))
{
- PyErr_SetString (PyExc_RuntimeError,
+ PyErr_SetString (PyExc_RuntimeError,
_("The enumeration is not a sequence."));
return 0;
}
return 0;
if (size == 0)
{
- PyErr_SetString (PyExc_RuntimeError,
+ PyErr_SetString (PyExc_RuntimeError,
_("The enumeration is empty."));
return 0;
}
{
Py_DECREF (item);
do_cleanups (back_to);
- PyErr_SetString (PyExc_RuntimeError,
+ PyErr_SetString (PyExc_RuntimeError,
_("The enumeration item not a string."));
return 0;
}
if (function != Py_None)
return function;
-
+
Py_DECREF (function);
}
result = PyObject_CallMethodObjArgs (printer, gdbpy_to_string_cst, NULL);
if (result)
{
- if (! gdbpy_is_string (result) && ! gdbpy_is_lazy_string (result)
+ if (! gdbpy_is_string (result) && ! gdbpy_is_lazy_string (result)
&& result != Py_None)
{
*out_value = convert_value_from_python (result);
print_stack_unless_memory_error (stream);
/* Set a flag so we can know whether we printed all the
available elements. */
- else
+ else
done_flag = 1;
break;
}
val_obj = value_to_value_object (value);
if (! val_obj)
goto done;
-
+
/* Find the constructor. */
printer = find_pretty_printer (val_obj);
Py_DECREF (val_obj);
/* Find a pretty-printer object for the varobj module. Returns a new
reference to the object if successful; returns NULL if not. VALUE
- is the value for which a printer tests to determine if it
+ is the value for which a printer tests to determine if it
can pretty-print the value. */
PyObject *
gdbpy_get_varobj_pretty_printer (struct value *value)
value = value_copy (value);
}
GDB_PY_HANDLE_EXCEPTION (except);
-
+
val_obj = value_to_value_object (value);
if (! val_obj)
return NULL;
value = value_object_to_value (val_obj);
if (! value)
{
- PyErr_SetString (PyExc_TypeError,
+ PyErr_SetString (PyExc_TypeError,
_("Argument must be a gdb.Value."));
return NULL;
}
if (frame_info == NULL)
error (_("invalid frame"));
}
-
+
if (symbol_read_needs_frame (symbol) && frame_info == NULL)
error (_("symbol requires a frame to compute its value"));
gdb_assert_not_reached ("invalid gdbpy_iter_kind");
}
return item;
-
+
fail:
Py_XDECREF (key);
Py_XDECREF (value);
}
/* Return a sequence of all fields. Each field is a gdb.Field object.
- This method is similar to typy_values, except where the supplied
+ This method is similar to typy_values, except where the supplied
gdb.Type is an array, in which case it returns a list of one entry
which is a gdb.Field object for a range (the array bounds). */
{
struct type *type = ((type_object *) self)->type;
PyObject *r, *rl;
-
+
if (TYPE_CODE (type) != TYPE_CODE_ARRAY)
return typy_fields_items (self, iter_values);
r = convert_field (type, 0);
if (r == NULL)
return NULL;
-
+
rl = Py_BuildValue ("[O]", r);
Py_DECREF (r);
return typy_fields_items (self, iter_keys);
}
-/* Return a sequence of all (name, fields) pairs. Each field is a
+/* Return a sequence of all (name, fields) pairs. Each field is a
gdb.Field object. */
static PyObject *
/* If this is not a struct, union, or enum type, raise TypeError
exception. */
- if (TYPE_CODE (type) != TYPE_CODE_STRUCT
+ if (TYPE_CODE (type) != TYPE_CODE_STRUCT
&& TYPE_CODE (type) != TYPE_CODE_UNION
&& TYPE_CODE (type) != TYPE_CODE_ENUM)
{
"Type is not a structure, union, or enum type.");
return NULL;
}
-
+
return type;
}
return NULL;
}
return result;
-
+
failarg:
Py_XDECREF (high_bound);
Py_XDECREF (low_bound);
if (!TYPE_TARGET_TYPE (type))
{
- PyErr_SetString (PyExc_RuntimeError,
+ PyErr_SetString (PyExc_RuntimeError,
_("Type does not have a target."));
return NULL;
}
}
GDB_PY_HANDLE_EXCEPTION (except);
}
-
+
/* If we have a type from the switch statement above, just return
that. */
if (rtype)
return rtype;
-
+
/* We don't have a type, so lookup the type. */
type_name = cp_comp_to_string (demangled, 10);
type = typy_lookup_typename (type_name, block);
}
/* Implements boolean evaluation of gdb.Type. Handle this like other
- Python objects that don't have a meaningful truth value -- all
+ Python objects that don't have a meaningful truth value -- all
values are true. */
static int
if (field == NULL)
return NULL;
- /* We want just fields of this type, not of base types, so instead of
+ /* We want just fields of this type, not of base types, so instead of
using lookup_struct_elt_type, portions of that function are
copied here. */
type = typy_get_composite (type);
if (type == NULL)
return NULL;
-
+
for (i = 0; i < TYPE_NFIELDS (type); i++)
{
const char *t_field_name = TYPE_FIELD_NAME (type, i);
return NULL;
}
-/* Implement the "get" method on the type object. This is the
+/* Implement the "get" method on the type object. This is the
same as getitem if the key is present, but returns the supplied
default value or None if the key is not found. */
typy_get (PyObject *self, PyObject *args)
{
PyObject *key, *defval = Py_None, *result;
-
+
if (!PyArg_UnpackTuple (args, "get", 1, 2, &key, &defval))
return NULL;
-
+
result = typy_getitem (self, key);
if (result != NULL)
return result;
-
+
/* typy_getitem returned error status. If the exception is
KeyError, clear the exception status and return the defval
instead. Otherwise return the exception unchanged. */
if (!PyErr_ExceptionMatches (PyExc_KeyError))
return NULL;
-
+
PyErr_Clear ();
Py_INCREF (defval);
return defval;
if (!PyArg_ParseTuple (args, "s", &field))
return NULL;
- /* We want just fields of this type, not of base types, so instead of
+ /* We want just fields of this type, not of base types, so instead of
using lookup_struct_elt_type, portions of that function are
copied here. */
/* Check that "self" is a structure or union type. */
if (typy_get_composite (((type_object *) self)->type) == NULL)
return NULL;
-
+
typy_iter_obj = PyObject_New (typy_iterator_object,
&type_iterator_object_type);
if (typy_iter_obj == NULL)
typy_iterator_object *iter_obj = (typy_iterator_object *) self;
struct type *type = iter_obj->source->type;
PyObject *result;
-
+
if (iter_obj->field < TYPE_NFIELDS (type))
{
result = make_fielditem (type, iter_obj->field, iter_obj->kind);
As an added bonus, the functions accepts a unicode string and returns it
right away, so callers don't need to check which kind of string they've
- got. In Python 3, all strings are Unicode so this case is always the
+ got. In Python 3, all strings are Unicode so this case is always the
one that applies.
If the given object is not one of the mentioned string types, NULL is
if (str == NULL)
return NULL;
- result = unicode_to_encoded_string (str, host_charset ());
+ result = unicode_to_encoded_string (str, host_charset ());
Py_DECREF (str);
return result;
}
}
/* Convert a GDB exception to the appropriate Python exception.
-
+
This sets the Python error indicator. */
void
type = type_object_to_type (type_obj);
if (! type)
{
- PyErr_SetString (PyExc_RuntimeError,
+ PyErr_SetString (PyExc_RuntimeError,
_("Argument must be a type."));
return NULL;
}
PyObject *result = NULL;
if (gdbpy_is_string (key))
- {
+ {
field = python_string_to_host_string (key);
if (field == NULL)
return NULL;
/* Calculate and return the address of the PyObject as the value of
the builtin __hash__ call. */
-static long
+static long
valpy_hash (PyObject *self)
{
return (long) (intptr_t) self;
TRY_CATCH (except, RETURN_MASK_ALL)
{
- if (PyBool_Check (obj))
+ if (PyBool_Check (obj))
{
cmp = PyObject_IsTrue (obj);
if (cmp >= 0)
{ "string", (PyCFunction) valpy_string, METH_VARARGS | METH_KEYWORDS,
"string ([encoding] [, errors] [, length]) -> string\n\
Return Unicode string representation of the value." },
- { "fetch_lazy", valpy_fetch_lazy, METH_NOARGS,
+ { "fetch_lazy", valpy_fetch_lazy, METH_NOARGS,
"Fetches the value from the inferior, if it was lazy." },
{NULL} /* Sentinel */
};
#undef Py_DECREF
#define Py_DECREF(op) gdb_Py_DECREF (op)
-/* In order to be able to parse symtab_and_line_to_sal_object function
+/* In order to be able to parse symtab_and_line_to_sal_object function
a real symtab_and_line structure is needed. */
#include "symtab.h"
int gdbpy_is_lazy_string (PyObject *result);
void gdbpy_extract_lazy_string (PyObject *string, CORE_ADDR *addr,
- struct type **str_type,
+ struct type **str_type,
long *length, char **encoding);
int gdbpy_is_value_object (PyObject *obj);
/* Save it and ensure ! PyErr_Occurred () afterwards. */
PyErr_Fetch (&env->error_type, &env->error_value, &env->error_traceback);
-
+
return make_cleanup (restore_python_env, env);
}
gdbpy_print_stack ();
error (_("Error while opening file: %s"), full_path);
}
-
+
make_cleanup_py_decref (python_file);
PyRun_SimpleFile (PyFile_AsFile (python_file), filename);
do_cleanups (cleanup);
}
}
- return PyErr_Format (PyExc_RuntimeError,
+ return PyErr_Format (PyExc_RuntimeError,
_("Programmer error: unhandled type."));
}
_("Could not find parameter `%s'."), arg);
if (! cmd->var)
- return PyErr_Format (PyExc_RuntimeError,
+ return PyErr_Format (PyExc_RuntimeError,
_("`%s' is not a parameter."), arg);
return gdbpy_parameter_value (cmd->var_type, cmd->var);
}
if (!PyCallable_Check (func))
{
- PyErr_SetString (PyExc_RuntimeError,
+ PyErr_SetString (PyExc_RuntimeError,
_("Posted event is not callable"));
return NULL;
}
static char *keywords[] = {"text", "stream", NULL };
int stream_type = 0;
volatile struct gdb_exception except;
-
+
if (! PyArg_ParseTupleAndKeywords (args, kw, "s|i", keywords, &arg,
&stream_type))
return NULL;
}
}
GDB_PY_HANDLE_EXCEPTION (except);
-
+
Py_RETURN_NONE;
}
{
static char *keywords[] = {"stream", NULL };
int stream_type = 0;
-
+
if (! PyArg_ParseTupleAndKeywords (args, kw, "|i", keywords,
&stream_type))
return NULL;
default:
gdb_flush (gdb_stdout);
}
-
+
Py_RETURN_NONE;
}
#endif
sys_path = PySys_GetObject ("path");
}
- if (sys_path && PyList_Check (sys_path))
+ if (sys_path && PyList_Check (sys_path))
{
PyObject *pythondir;
int err;
PyModuleDef_HEAD_INIT,
"_gdb",
NULL,
- -1,
+ -1,
GdbMethods,
NULL,
NULL,