2010-04-29 15:45:57 +00:00
|
|
|
|
/* GDB parameters implemented in Python
|
|
|
|
|
|
2016-01-01 04:33:14 +00:00
|
|
|
|
Copyright (C) 2008-2016 Free Software Foundation, Inc.
|
2010-04-29 15:45:57 +00:00
|
|
|
|
|
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "defs.h"
|
|
|
|
|
#include "value.h"
|
|
|
|
|
#include "python-internal.h"
|
|
|
|
|
#include "charset.h"
|
|
|
|
|
#include "gdbcmd.h"
|
|
|
|
|
#include "cli/cli-decode.h"
|
|
|
|
|
#include "completer.h"
|
2011-03-10 12:29:08 +00:00
|
|
|
|
#include "language.h"
|
|
|
|
|
#include "arch-utils.h"
|
2010-04-29 15:45:57 +00:00
|
|
|
|
|
|
|
|
|
/* Parameter constants and their values. */
|
|
|
|
|
struct parm_constant
|
|
|
|
|
{
|
|
|
|
|
char *name;
|
|
|
|
|
int value;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct parm_constant parm_constants[] =
|
|
|
|
|
{
|
2010-04-30 16:22:42 +00:00
|
|
|
|
{ "PARAM_BOOLEAN", var_boolean }, /* ARI: var_boolean */
|
2010-04-29 15:45:57 +00:00
|
|
|
|
{ "PARAM_AUTO_BOOLEAN", var_auto_boolean },
|
|
|
|
|
{ "PARAM_UINTEGER", var_uinteger },
|
|
|
|
|
{ "PARAM_INTEGER", var_integer },
|
|
|
|
|
{ "PARAM_STRING", var_string },
|
|
|
|
|
{ "PARAM_STRING_NOESCAPE", var_string_noescape },
|
|
|
|
|
{ "PARAM_OPTIONAL_FILENAME", var_optional_filename },
|
|
|
|
|
{ "PARAM_FILENAME", var_filename },
|
|
|
|
|
{ "PARAM_ZINTEGER", var_zinteger },
|
|
|
|
|
{ "PARAM_ENUM", var_enum },
|
|
|
|
|
{ NULL, 0 }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* A union that can hold anything described by enum var_types. */
|
|
|
|
|
union parmpy_variable
|
|
|
|
|
{
|
|
|
|
|
/* Hold an integer value, for boolean and integer types. */
|
|
|
|
|
int intval;
|
|
|
|
|
|
|
|
|
|
/* Hold an auto_boolean. */
|
|
|
|
|
enum auto_boolean autoboolval;
|
|
|
|
|
|
|
|
|
|
/* Hold an unsigned integer value, for uinteger. */
|
|
|
|
|
unsigned int uintval;
|
|
|
|
|
|
|
|
|
|
/* Hold a string, for the various string types. */
|
|
|
|
|
char *stringval;
|
|
|
|
|
|
|
|
|
|
/* Hold a string, for enums. */
|
|
|
|
|
const char *cstringval;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* A GDB parameter. */
|
|
|
|
|
struct parmpy_object
|
|
|
|
|
{
|
|
|
|
|
PyObject_HEAD
|
|
|
|
|
|
|
|
|
|
/* The type of the parameter. */
|
|
|
|
|
enum var_types type;
|
|
|
|
|
|
|
|
|
|
/* The value of the parameter. */
|
|
|
|
|
union parmpy_variable value;
|
|
|
|
|
|
|
|
|
|
/* For an enum command, the possible values. The vector is
|
|
|
|
|
allocated with xmalloc, as is each element. It is
|
|
|
|
|
NULL-terminated. */
|
|
|
|
|
const char **enumeration;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
typedef struct parmpy_object parmpy_object;
|
|
|
|
|
|
Fix redefinition errors in C++ mode
In C, we can forward declare static structure instances. That doesn't
work in C++ though. C++ treats these as definitions. So then the
compiler complains about symbol redefinition, like:
src/gdb/elfread.c:1569:29: error: redefinition of ‘const sym_fns elf_sym_fns_lazy_psyms’
src/gdb/elfread.c:53:29: error: ‘const sym_fns elf_sym_fns_lazy_psyms’ previously declared here
The intent of static here is naturally to avoid making these objects
visible outside the compilation unit. The equivalent in C++ would be
to instead define the objects in the anonymous namespace. But given
that it's desirable to leave the codebase compiling as both C and C++
for a while, this just makes the objects extern.
(base_breakpoint_ops is already declared in breakpoint.h, so we can
just remove the forward declare from breakpoint.c)
gdb/ChangeLog:
2015-02-11 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
* breakpoint.c (base_breakpoint_ops): Delete.
* dwarf2loc.c (dwarf_expr_ctx_funcs): Make extern.
* elfread.c (elf_sym_fns_gdb_index, elf_sym_fns_lazy_psyms): Make extern.
* guile/guile.c (guile_extension_script_ops, guile_extension_ops): Make extern.
* ppcnbsd-tdep.c (ppcnbsd2_sigtramp): Make extern.
* python/py-arch.c (arch_object_type): Make extern.
* python/py-block.c (block_syms_iterator_object_type): Make extern.
* python/py-bpevent.c (breakpoint_event_object_type): Make extern.
* python/py-cmd.c (cmdpy_object_type): Make extern.
* python/py-continueevent.c (continue_event_object_type)
* python/py-event.h (GDBPY_NEW_EVENT_TYPE): Remove 'qual'
parameter. Update all callers.
* python/py-evtregistry.c (eventregistry_object_type): Make extern.
* python/py-exitedevent.c (exited_event_object_type): Make extern.
* python/py-finishbreakpoint.c (finish_breakpoint_object_type): Make extern.
* python/py-function.c (fnpy_object_type): Make extern.
* python/py-inferior.c (inferior_object_type, membuf_object_type): Make extern.
* python/py-infevents.c (call_pre_event_object_type)
(inferior_call_post_event_object_type).
(memory_changed_event_object_type): Make extern.
* python/py-infthread.c (thread_object_type): Make extern.
* python/py-lazy-string.c (lazy_string_object_type): Make extern.
* python/py-linetable.c (linetable_entry_object_type)
(linetable_object_type, ltpy_iterator_object_type): Make extern.
* python/py-newobjfileevent.c (new_objfile_event_object_type)
(clear_objfiles_event_object_type): Make extern.
* python/py-objfile.c (objfile_object_type): Make extern.
* python/py-param.c (parmpy_object_type): Make extern.
* python/py-progspace.c (pspace_object_type): Make extern.
* python/py-signalevent.c (signal_event_object_type): Make extern.
* python/py-symtab.c (symtab_object_type, sal_object_type): Make extern.
* python/py-type.c (type_object_type, field_object_type)
(type_iterator_object_type): Make extern.
* python/python.c (python_extension_script_ops)
(python_extension_ops): Make extern.
* stap-probe.c (stap_probe_ops): Make extern.
2015-02-11 11:20:21 +00:00
|
|
|
|
extern PyTypeObject parmpy_object_type
|
2013-05-20 20:09:01 +00:00
|
|
|
|
CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("parmpy_object");
|
2010-04-29 15:45:57 +00:00
|
|
|
|
|
|
|
|
|
/* Some handy string constants. */
|
|
|
|
|
static PyObject *set_doc_cst;
|
|
|
|
|
static PyObject *show_doc_cst;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Get an attribute. */
|
|
|
|
|
static PyObject *
|
|
|
|
|
get_attr (PyObject *obj, PyObject *attr_name)
|
|
|
|
|
{
|
|
|
|
|
if (PyString_Check (attr_name)
|
2012-12-12 16:47:30 +00:00
|
|
|
|
#ifdef IS_PY3K
|
|
|
|
|
&& ! PyUnicode_CompareWithASCIIString (attr_name, "value"))
|
|
|
|
|
#else
|
2010-04-29 15:45:57 +00:00
|
|
|
|
&& ! strcmp (PyString_AsString (attr_name), "value"))
|
2012-12-12 16:47:30 +00:00
|
|
|
|
#endif
|
2010-04-29 15:45:57 +00:00
|
|
|
|
{
|
|
|
|
|
parmpy_object *self = (parmpy_object *) obj;
|
2010-05-17 21:23:25 +00:00
|
|
|
|
|
2010-04-29 15:45:57 +00:00
|
|
|
|
return gdbpy_parameter_value (self->type, &self->value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return PyObject_GenericGetAttr (obj, attr_name);
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-13 13:24:40 +00:00
|
|
|
|
/* Set a parameter value from a Python value. Return 0 on success. Returns
|
|
|
|
|
-1 on error, with a python exception set. */
|
2010-04-29 15:45:57 +00:00
|
|
|
|
static int
|
|
|
|
|
set_parameter_value (parmpy_object *self, PyObject *value)
|
|
|
|
|
{
|
|
|
|
|
int cmp;
|
|
|
|
|
|
|
|
|
|
switch (self->type)
|
|
|
|
|
{
|
|
|
|
|
case var_string:
|
|
|
|
|
case var_string_noescape:
|
|
|
|
|
case var_optional_filename:
|
|
|
|
|
case var_filename:
|
|
|
|
|
if (! gdbpy_is_string (value)
|
|
|
|
|
&& (self->type == var_filename
|
|
|
|
|
|| value != Py_None))
|
|
|
|
|
{
|
2013-11-29 20:00:47 +00:00
|
|
|
|
PyErr_SetString (PyExc_RuntimeError,
|
2010-04-29 15:45:57 +00:00
|
|
|
|
_("String required for filename."));
|
|
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
if (value == Py_None)
|
|
|
|
|
{
|
2010-10-13 13:24:40 +00:00
|
|
|
|
xfree (self->value.stringval);
|
2010-04-29 15:45:57 +00:00
|
|
|
|
if (self->type == var_optional_filename)
|
|
|
|
|
self->value.stringval = xstrdup ("");
|
|
|
|
|
else
|
|
|
|
|
self->value.stringval = NULL;
|
|
|
|
|
}
|
|
|
|
|
else
|
2010-10-13 13:24:40 +00:00
|
|
|
|
{
|
|
|
|
|
char *string;
|
|
|
|
|
|
|
|
|
|
string = python_string_to_host_string (value);
|
|
|
|
|
if (string == NULL)
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
xfree (self->value.stringval);
|
|
|
|
|
self->value.stringval = string;
|
|
|
|
|
}
|
2010-04-29 15:45:57 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case var_enum:
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
char *str;
|
|
|
|
|
|
|
|
|
|
if (! gdbpy_is_string (value))
|
|
|
|
|
{
|
2013-11-29 20:00:47 +00:00
|
|
|
|
PyErr_SetString (PyExc_RuntimeError,
|
2010-04-29 15:45:57 +00:00
|
|
|
|
_("ENUM arguments must be a string."));
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
str = python_string_to_host_string (value);
|
2010-10-13 13:24:40 +00:00
|
|
|
|
if (str == NULL)
|
|
|
|
|
return -1;
|
2010-04-29 15:45:57 +00:00
|
|
|
|
for (i = 0; self->enumeration[i]; ++i)
|
|
|
|
|
if (! strcmp (self->enumeration[i], str))
|
|
|
|
|
break;
|
|
|
|
|
xfree (str);
|
|
|
|
|
if (! self->enumeration[i])
|
|
|
|
|
{
|
|
|
|
|
PyErr_SetString (PyExc_RuntimeError,
|
|
|
|
|
_("The value must be member of an enumeration."));
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
self->value.cstringval = self->enumeration[i];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case var_boolean:
|
|
|
|
|
if (! PyBool_Check (value))
|
|
|
|
|
{
|
2013-11-29 20:00:47 +00:00
|
|
|
|
PyErr_SetString (PyExc_RuntimeError,
|
2010-04-29 15:45:57 +00:00
|
|
|
|
_("A boolean argument is required."));
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
cmp = PyObject_IsTrue (value);
|
2013-11-29 20:00:47 +00:00
|
|
|
|
if (cmp < 0)
|
2010-04-29 15:45:57 +00:00
|
|
|
|
return -1;
|
|
|
|
|
self->value.intval = cmp;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case var_auto_boolean:
|
|
|
|
|
if (! PyBool_Check (value) && value != Py_None)
|
|
|
|
|
{
|
|
|
|
|
PyErr_SetString (PyExc_RuntimeError,
|
|
|
|
|
_("A boolean or None is required"));
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (value == Py_None)
|
|
|
|
|
self->value.autoboolval = AUTO_BOOLEAN_AUTO;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
cmp = PyObject_IsTrue (value);
|
|
|
|
|
if (cmp < 0 )
|
2013-11-29 20:00:47 +00:00
|
|
|
|
return -1;
|
2010-04-29 15:45:57 +00:00
|
|
|
|
if (cmp == 1)
|
|
|
|
|
self->value.autoboolval = AUTO_BOOLEAN_TRUE;
|
2013-11-29 20:00:47 +00:00
|
|
|
|
else
|
2010-04-29 15:45:57 +00:00
|
|
|
|
self->value.autoboolval = AUTO_BOOLEAN_FALSE;
|
|
|
|
|
}
|
2011-02-28 18:28:19 +00:00
|
|
|
|
break;
|
2010-04-29 15:45:57 +00:00
|
|
|
|
|
|
|
|
|
case var_integer:
|
|
|
|
|
case var_zinteger:
|
|
|
|
|
case var_uinteger:
|
|
|
|
|
{
|
|
|
|
|
long l;
|
|
|
|
|
int ok;
|
|
|
|
|
|
|
|
|
|
if (! PyInt_Check (value))
|
|
|
|
|
{
|
2013-11-29 20:00:47 +00:00
|
|
|
|
PyErr_SetString (PyExc_RuntimeError,
|
2010-04-29 15:45:57 +00:00
|
|
|
|
_("The value must be integer."));
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-26 20:53:45 +00:00
|
|
|
|
if (! gdb_py_int_as_long (value, &l))
|
|
|
|
|
return -1;
|
|
|
|
|
|
2010-04-29 15:45:57 +00:00
|
|
|
|
if (self->type == var_uinteger)
|
|
|
|
|
{
|
|
|
|
|
ok = (l >= 0 && l <= UINT_MAX);
|
|
|
|
|
if (l == 0)
|
|
|
|
|
l = UINT_MAX;
|
|
|
|
|
}
|
|
|
|
|
else if (self->type == var_integer)
|
|
|
|
|
{
|
|
|
|
|
ok = (l >= INT_MIN && l <= INT_MAX);
|
|
|
|
|
if (l == 0)
|
|
|
|
|
l = INT_MAX;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
ok = (l >= INT_MIN && l <= INT_MAX);
|
|
|
|
|
|
|
|
|
|
if (! ok)
|
|
|
|
|
{
|
2013-11-29 20:00:47 +00:00
|
|
|
|
PyErr_SetString (PyExc_RuntimeError,
|
2010-04-29 15:45:57 +00:00
|
|
|
|
_("Range exceeded."));
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
self->value.intval = (int) l;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
default:
|
2013-11-29 20:00:47 +00:00
|
|
|
|
PyErr_SetString (PyExc_RuntimeError,
|
2010-04-29 15:45:57 +00:00
|
|
|
|
_("Unhandled type in parameter value."));
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-13 13:24:40 +00:00
|
|
|
|
/* Set an attribute. Returns -1 on error, with a python exception set. */
|
2010-04-29 15:45:57 +00:00
|
|
|
|
static int
|
|
|
|
|
set_attr (PyObject *obj, PyObject *attr_name, PyObject *val)
|
|
|
|
|
{
|
|
|
|
|
if (PyString_Check (attr_name)
|
2012-12-12 16:47:30 +00:00
|
|
|
|
#ifdef IS_PY3K
|
|
|
|
|
&& ! PyUnicode_CompareWithASCIIString (attr_name, "value"))
|
|
|
|
|
#else
|
2010-04-29 15:45:57 +00:00
|
|
|
|
&& ! strcmp (PyString_AsString (attr_name), "value"))
|
2012-12-12 16:47:30 +00:00
|
|
|
|
#endif
|
2010-04-29 15:45:57 +00:00
|
|
|
|
{
|
|
|
|
|
if (!val)
|
|
|
|
|
{
|
|
|
|
|
PyErr_SetString (PyExc_RuntimeError,
|
|
|
|
|
_("Cannot delete a parameter's value."));
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
return set_parameter_value ((parmpy_object *) obj, val);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return PyObject_GenericSetAttr (obj, attr_name, val);
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-10 12:29:08 +00:00
|
|
|
|
/* A helper function which returns a documentation string for an
|
|
|
|
|
object. */
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
if (result == NULL)
|
|
|
|
|
gdbpy_print_stack ();
|
|
|
|
|
}
|
|
|
|
|
Py_XDECREF (ds_obj);
|
|
|
|
|
}
|
|
|
|
|
if (! result)
|
|
|
|
|
result = xstrdup (_("This command is not documented."));
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Helper function which will execute a METHOD in OBJ passing the
|
|
|
|
|
argument ARG. ARG can be NULL. METHOD should return a Python
|
|
|
|
|
string. If this function returns NULL, there has been an error and
|
|
|
|
|
the appropriate exception set. */
|
|
|
|
|
static char *
|
|
|
|
|
call_doc_function (PyObject *obj, PyObject *method, PyObject *arg)
|
|
|
|
|
{
|
|
|
|
|
char *data = NULL;
|
|
|
|
|
PyObject *result = PyObject_CallMethodObjArgs (obj, method, arg, NULL);
|
|
|
|
|
|
|
|
|
|
if (! result)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
if (gdbpy_is_string (result))
|
|
|
|
|
{
|
|
|
|
|
data = python_string_to_host_string (result);
|
2011-10-24 11:39:50 +00:00
|
|
|
|
Py_DECREF (result);
|
2011-03-10 12:29:08 +00:00
|
|
|
|
if (! data)
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
PyErr_SetString (PyExc_RuntimeError,
|
|
|
|
|
_("Parameter must return a string value."));
|
2011-10-24 11:39:50 +00:00
|
|
|
|
Py_DECREF (result);
|
2011-03-10 12:29:08 +00:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* A callback function that is registered against the respective
|
|
|
|
|
add_setshow_* set_doc prototype. This function will either call
|
|
|
|
|
the Python function "get_set_string" or extract the Python
|
|
|
|
|
attribute "set_doc" and return the contents as a string. If
|
|
|
|
|
neither exist, insert a string indicating the Parameter is not
|
|
|
|
|
documented. */
|
|
|
|
|
static void
|
|
|
|
|
get_set_value (char *args, int from_tty,
|
|
|
|
|
struct cmd_list_element *c)
|
|
|
|
|
{
|
|
|
|
|
PyObject *obj = (PyObject *) get_cmd_context (c);
|
|
|
|
|
char *set_doc_string;
|
|
|
|
|
struct cleanup *cleanup = ensure_python_env (get_current_arch (),
|
|
|
|
|
current_language);
|
|
|
|
|
PyObject *set_doc_func = PyString_FromString ("get_set_string");
|
|
|
|
|
|
|
|
|
|
if (! set_doc_func)
|
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
|
|
if (PyObject_HasAttr (obj, set_doc_func))
|
|
|
|
|
{
|
|
|
|
|
set_doc_string = call_doc_function (obj, set_doc_func, NULL);
|
|
|
|
|
if (! set_doc_string)
|
|
|
|
|
goto error;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* We have to preserve the existing < GDB 7.3 API. If a
|
|
|
|
|
callback function does not exist, then attempt to read the
|
|
|
|
|
set_doc attribute. */
|
|
|
|
|
set_doc_string = get_doc_string (obj, set_doc_cst);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
make_cleanup (xfree, set_doc_string);
|
|
|
|
|
fprintf_filtered (gdb_stdout, "%s\n", set_doc_string);
|
|
|
|
|
|
2013-05-20 20:34:49 +00:00
|
|
|
|
Py_XDECREF (set_doc_func);
|
2011-03-10 12:29:08 +00:00
|
|
|
|
do_cleanups (cleanup);
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
error:
|
2013-05-20 20:34:49 +00:00
|
|
|
|
Py_XDECREF (set_doc_func);
|
2011-03-10 12:29:08 +00:00
|
|
|
|
gdbpy_print_stack ();
|
|
|
|
|
do_cleanups (cleanup);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* A callback function that is registered against the respective
|
|
|
|
|
add_setshow_* show_doc prototype. This function will either call
|
|
|
|
|
the Python function "get_show_string" or extract the Python
|
|
|
|
|
attribute "show_doc" and return the contents as a string. If
|
|
|
|
|
neither exist, insert a string indicating the Parameter is not
|
|
|
|
|
documented. */
|
|
|
|
|
static void
|
|
|
|
|
get_show_value (struct ui_file *file, int from_tty,
|
|
|
|
|
struct cmd_list_element *c,
|
|
|
|
|
const char *value)
|
|
|
|
|
{
|
|
|
|
|
PyObject *obj = (PyObject *) get_cmd_context (c);
|
|
|
|
|
char *show_doc_string = NULL;
|
|
|
|
|
struct cleanup *cleanup = ensure_python_env (get_current_arch (),
|
|
|
|
|
current_language);
|
|
|
|
|
PyObject *show_doc_func = PyString_FromString ("get_show_string");
|
|
|
|
|
|
|
|
|
|
if (! show_doc_func)
|
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
|
|
if (PyObject_HasAttr (obj, show_doc_func))
|
|
|
|
|
{
|
|
|
|
|
PyObject *val_obj = PyString_FromString (value);
|
|
|
|
|
|
|
|
|
|
if (! val_obj)
|
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
|
|
show_doc_string = call_doc_function (obj, show_doc_func, val_obj);
|
2013-05-20 20:34:49 +00:00
|
|
|
|
Py_DECREF (val_obj);
|
2011-03-10 12:29:08 +00:00
|
|
|
|
if (! show_doc_string)
|
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
|
|
make_cleanup (xfree, show_doc_string);
|
|
|
|
|
|
|
|
|
|
fprintf_filtered (file, "%s\n", show_doc_string);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* We have to preserve the existing < GDB 7.3 API. If a
|
|
|
|
|
callback function does not exist, then attempt to read the
|
|
|
|
|
show_doc attribute. */
|
|
|
|
|
show_doc_string = get_doc_string (obj, show_doc_cst);
|
|
|
|
|
make_cleanup (xfree, show_doc_string);
|
|
|
|
|
fprintf_filtered (file, "%s %s\n", show_doc_string, value);
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-20 20:34:49 +00:00
|
|
|
|
Py_XDECREF (show_doc_func);
|
2011-03-10 12:29:08 +00:00
|
|
|
|
do_cleanups (cleanup);
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
error:
|
2013-05-20 20:34:49 +00:00
|
|
|
|
Py_XDECREF (show_doc_func);
|
2011-03-10 12:29:08 +00:00
|
|
|
|
gdbpy_print_stack ();
|
|
|
|
|
do_cleanups (cleanup);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2010-04-29 15:45:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* A helper function that dispatches to the appropriate add_setshow
|
|
|
|
|
function. */
|
|
|
|
|
static void
|
|
|
|
|
add_setshow_generic (int parmclass, enum command_class cmdclass,
|
|
|
|
|
char *cmd_name, parmpy_object *self,
|
|
|
|
|
char *set_doc, char *show_doc, char *help_doc,
|
|
|
|
|
struct cmd_list_element **set_list,
|
|
|
|
|
struct cmd_list_element **show_list)
|
|
|
|
|
{
|
2011-03-10 12:29:08 +00:00
|
|
|
|
struct cmd_list_element *param = NULL;
|
Constify strings in tracepoint.c, lookup_cmd and the completers.
This is sort of a continuation of Keith's parse_exp_1 constification
patch. It started out by undoing these bits:
@@ -754,9 +754,12 @@ validate_actionline (char **line, struct
tmp_p = p;
for (loc = t->base.loc; loc; loc = loc->next)
{
- p = tmp_p;
- exp = parse_exp_1 (&p, loc->address,
+ const char *q;
+
+ q = tmp_p;
+ exp = parse_exp_1 (&q, loc->address,
block_for_pc (loc->address), 1);
+ p = (char *) q;
and progressively making more things const upwards, fixing fallout,
rinse repeat, until GDB built again (--enable-targets=all).
That ended up constifying lookup_cmd/add_cmd and (lots of) friends,
and the completers.
I didn't try to constify the command hooks themselves, because I know
upfront there are commands that write to the command string argument,
and I think I managed to stop at a nice non-hacky split point already.
I think the only non-really-super-obvious changes are
tracepoint.c:validate_actionline, and tracepoint.c:trace_dump_actions.
The rest is just mostly about 'char *' => 'const char *', 'char **'=>
'const char **', and the occasional (e.g., deprecated_cmd_warning)
case of 'char **'=> 'const char *', where/when I noticed that nothing
actually cares about the pointer to pointer output.
Tested on x86_64 Fedora 17, native and gdbserver.
gdb/
2013-03-13 Pedro Alves <palves@redhat.com>
* ada-lang.c (struct add_partial_datum) <text, text0, word>: Make
fields const.
(ada_make_symbol_completion_list): Make "text0" parameter const.
* ax-gdb.c (agent_eval_command_one): Make "exp" parameter const.
* breakpoint.c (condition_completer): Make "text" and "word"
parameters const. Adjust.
(check_tracepoint_command): Adjust to validate_actionline
prototype change.
(catch_syscall_completer): Make "text" and "word" parameters
const.
* cli/cli-cmds.c (show_user): Make "comname" local const.
(valid_command_p): Make "command" parameter const.
(alias_command): Make "alias_prefix" and "command_prefix" locals
const.
* cli/cli-decode.c (add_cmd): Make "name" parameter const.
(add_alias_cmd): Make "name" and "oldname" parameters const.
Adjust. No longer make copy of OLDNAME.
(add_prefix_cmd, add_abbrev_prefix_cmd, add_set_or_show_cmd)
(add_setshow_cmd_full, add_setshow_enum_cmd)
(add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd)
(add_setshow_filename_cmd, add_setshow_string_cmd)
(add_setshow_string_noescape_cmd)
(add_setshow_optional_filename_cmd, add_setshow_integer_cmd)
(add_setshow_uinteger_cmd, add_setshow_zinteger_cmd)
(add_setshow_zuinteger_unlimited_cmd, add_setshow_zuinteger_cmd)
(delete_cmd, add_info, add_info_alias, add_com, add_com_alias):
Make "name" parameter const.
(help_cmd): Rename "command" parameter to "arg". New const local
"command".
(find_cmd): Make "command" parameter const.
(lookup_cmd_1): Make "text" parameter pointer to const. Adjust to
deprecated_cmd_warning prototype change.
(undef_cmd_error): Make "cmdtype" parameter const.
(lookup_cmd): Make "line" parameter const.
(deprecated_cmd_warning): Change type of "text" parameter to
pointer to const char, from pointer to pointer to char. Adjust.
(lookup_cmd_composition): Make "text" parameter const.
(complete_on_cmdlist, complete_on_enum): Make "text" and "word"
parameters const.
* cli/cli-decode.h (struct cmd_list_element) <name>: Make field
const.
* cli/cli-script.c (validate_comname): Make "tem" local const.
(define_command): New const local "tem_c". Use it in calls to
lookup_cmd.
(document_command): Make "tem" and "comfull" locals const.
(show_user_1): Make "prefix" and "name" parameters const.
* cli-script.h (show_user_1): Make "prefix" and "name" parameters
const.
* command.h (add_cmd, add_alias_cmd, add_prefix_cmd)
(add_abbrev_prefix_cmd, completer_ftype, lookup_cmd, lookup_cmd_1)
(deprecated_cmd_warning, lookup_cmd_composition, add_com)
(add_com_alias, add_info, add_info_alias, complete_on_cmdlist)
(complete_on_enum, add_setshow_enum_cmd)
(add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd)
(add_setshow_filename_cmd, add_setshow_string_cmd)
(add_setshow_string_noescape_cmd)
(add_setshow_optional_filename_cmd, add_setshow_integer_cmd)
(add_setshow_uinteger_cmd, add_setshow_zinteger_cmd)
(add_setshow_zuinteger_cmd, add_setshow_zuinteger_unlimited_cmd):
Change prototypes, constifying strings.
* completer.c (noop_completer, filename_completer): Make "text"
and "prefix" parameters const.
(location_completer, expression_completer)
(complete_line_internal): Make "text" and "prefix" parameters
const and adjust.
(command_completer, signal_completer): Make "text" and "prefix"
parameters const.
* completer.h (noop_completer, filename_completer)
(expression_completer, location_completer, command_completer)
(signal_completer): Change prototypes.
* corefile.c (complete_set_gnutarget): Make "text" and "word"
parameters const.
* cp-abi.c (cp_abi_completer): Likewise.
* expression.h (parse_expression_for_completion): Change
prototype.
* f-lang.c (f_make_symbol_completion_list): Make "text" and "word"
parameters const.
* infcmd.c (_initialize_infcmd): Make "cmd_name" local const.
* infrun.c (handle_completer): Make "text" and "word" parameters
const.
* interps.c (interpreter_completer): Make "text" and "word"
parameters const.
* language.h (struct language_defn)
<la_make_symbol_completion_list>: Make "text" and "word"
parameters const.
* parse.c (parse_exp_1): Move const hack to parse_exp_in_context.
(parse_exp_in_context): Rename to ...
(parse_exp_in_context_1): ... this.
(parse_exp_in_context): Reimplement, with const hack from
parse_exp_1.
(parse_expression_for_completion): Make "string" parameter const.
* printcmd.c (decode_format): Make "string_ptr" parameter pointer
to pointer to const char. Adjust.
(print_command_1): Make "exp" parameter const.
(output_command): Rename to ...
(output_command_const): ... this. Make "exp" parameter const.
(output_command): Reimplement.
(x_command): Adjust.
(display_command): Rename "exp" parameter to "arg". New "exp"
local, const version of "arg".
* python/py-auto-load.c (gdbpy_initialize_auto_load): Make
"cmd_name" local const.
* python/py-cmd.c (cmdpy_destroyer): Cast const away in xfree
call.
(cmdpy_completer): Make "text" and "word" parameters const.
(gdbpy_parse_command_name): Make "prefix_text2" local const.
* python/py-param.c (add_setshow_generic): Make "tmp_name" local
const.
* remote.c (_initialize_remote): Make "cmd_name" local const.
* symtab.c (language_search_unquoted_string): Make "text" and "p"
parameters const. Adjust.
(completion_list_add_fields): Make "sym_text", "text" and "word"
parameters const.
(struct add_name_data) <sym_text, text, word>: Make fields const.
(default_make_symbol_completion_list_break_on): Make "text" and
"word" parameters const. Adjust locals.
(default_make_symbol_completion_list)
(make_symbol_completion_list, make_symbol_completion_type)
(make_symbol_completion_list_fn): Make "text" and "word"
parameters const.
(make_file_symbol_completion_list): Make "text", "word" and
"srcfile" parameters const. Adjust locals.
(add_filename_to_list): Make "text" and "word" parameters const.
(struct add_partial_filename_data) <text, word>: Make fields
const.
(make_source_files_completion_list): Make "text" and "word"
parameters const.
* symtab.h (default_make_symbol_completion_list_break_on)
(default_make_symbol_completion_list, make_symbol_completion_list)
(make_symbol_completion_type enum type_code)
(make_symbol_completion_list_fn make_file_symbol_completion_list)
(make_source_files_completion_list): Change prototype.
* top.c (execute_command): Adjust to pass pointer to pointer to
const char to lookup_cmd, and to deprecated_cmd_warning prototype
change.
(set_verbose): Make "cmdname" local const.
* tracepoint.c (decode_agent_options): Make "exp" parameter const,
and adjust.
(validate_actionline): Make "line" parameter a pointer to const
char, and adjust.
(encode_actions_1): Make "action_exp" local const, and adjust.
(encode_actions): Adjust.
(replace_comma): Delete.
(trace_dump_actions): Make "action_exp" and "next_comma" locals
const, and adjust. Don't frob the action string while splitting
it at commas. Instead, make a copy of each split substring in
turn.
(trace_dump_command): Adjust to validate_actionline prototype
change.
* tracepoint.h (decode_agent_options, decode_agent_options)
(encode_actions, validate_actionline): Change prototypes.
* valprint.h (output_command): Delete declaration.
(output_command_const): Declare.
* value.c (function_destroyer): Cast const away in xfree call.
2013-03-13 18:34:55 +00:00
|
|
|
|
const char *tmp_name = NULL;
|
2011-03-10 12:29:08 +00:00
|
|
|
|
|
2010-04-29 15:45:57 +00:00
|
|
|
|
switch (parmclass)
|
|
|
|
|
{
|
|
|
|
|
case var_boolean:
|
2011-03-10 12:29:08 +00:00
|
|
|
|
|
|
|
|
|
add_setshow_boolean_cmd (cmd_name, cmdclass,
|
|
|
|
|
&self->value.intval, set_doc, show_doc,
|
|
|
|
|
help_doc, get_set_value, get_show_value,
|
|
|
|
|
set_list, show_list);
|
|
|
|
|
|
2010-04-29 15:45:57 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case var_auto_boolean:
|
|
|
|
|
add_setshow_auto_boolean_cmd (cmd_name, cmdclass,
|
|
|
|
|
&self->value.autoboolval,
|
|
|
|
|
set_doc, show_doc, help_doc,
|
2011-03-10 12:29:08 +00:00
|
|
|
|
get_set_value, get_show_value,
|
|
|
|
|
set_list, show_list);
|
2010-04-29 15:45:57 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case var_uinteger:
|
2011-03-10 12:29:08 +00:00
|
|
|
|
add_setshow_uinteger_cmd (cmd_name, cmdclass,
|
|
|
|
|
&self->value.uintval, set_doc, show_doc,
|
|
|
|
|
help_doc, get_set_value, get_show_value,
|
|
|
|
|
set_list, show_list);
|
2010-04-29 15:45:57 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case var_integer:
|
2011-03-10 12:29:08 +00:00
|
|
|
|
add_setshow_integer_cmd (cmd_name, cmdclass,
|
|
|
|
|
&self->value.intval, set_doc, show_doc,
|
|
|
|
|
help_doc, get_set_value, get_show_value,
|
|
|
|
|
set_list, show_list); break;
|
2010-04-29 15:45:57 +00:00
|
|
|
|
|
|
|
|
|
case var_string:
|
2011-03-10 12:29:08 +00:00
|
|
|
|
add_setshow_string_cmd (cmd_name, cmdclass,
|
|
|
|
|
&self->value.stringval, set_doc, show_doc,
|
|
|
|
|
help_doc, get_set_value, get_show_value,
|
|
|
|
|
set_list, show_list); break;
|
2010-04-29 15:45:57 +00:00
|
|
|
|
|
|
|
|
|
case var_string_noescape:
|
|
|
|
|
add_setshow_string_noescape_cmd (cmd_name, cmdclass,
|
|
|
|
|
&self->value.stringval,
|
|
|
|
|
set_doc, show_doc, help_doc,
|
2011-03-10 12:29:08 +00:00
|
|
|
|
get_set_value, get_show_value,
|
|
|
|
|
set_list, show_list);
|
|
|
|
|
|
2010-04-29 15:45:57 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case var_optional_filename:
|
|
|
|
|
add_setshow_optional_filename_cmd (cmd_name, cmdclass,
|
2011-03-10 12:29:08 +00:00
|
|
|
|
&self->value.stringval, set_doc,
|
|
|
|
|
show_doc, help_doc, get_set_value,
|
|
|
|
|
get_show_value, set_list,
|
|
|
|
|
show_list);
|
2010-04-29 15:45:57 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case var_filename:
|
2011-03-10 12:29:08 +00:00
|
|
|
|
add_setshow_filename_cmd (cmd_name, cmdclass,
|
|
|
|
|
&self->value.stringval, set_doc, show_doc,
|
|
|
|
|
help_doc, get_set_value, get_show_value,
|
|
|
|
|
set_list, show_list); break;
|
2010-04-29 15:45:57 +00:00
|
|
|
|
|
|
|
|
|
case var_zinteger:
|
2011-03-10 12:29:08 +00:00
|
|
|
|
add_setshow_zinteger_cmd (cmd_name, cmdclass,
|
|
|
|
|
&self->value.intval, set_doc, show_doc,
|
|
|
|
|
help_doc, get_set_value, get_show_value,
|
|
|
|
|
set_list, show_list);
|
2010-04-29 15:45:57 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case var_enum:
|
|
|
|
|
add_setshow_enum_cmd (cmd_name, cmdclass, self->enumeration,
|
2011-03-10 12:29:08 +00:00
|
|
|
|
&self->value.cstringval, set_doc, show_doc,
|
|
|
|
|
help_doc, get_set_value, get_show_value,
|
|
|
|
|
set_list, show_list);
|
2010-04-29 15:45:57 +00:00
|
|
|
|
/* Initialize the value, just in case. */
|
|
|
|
|
self->value.cstringval = self->enumeration[0];
|
|
|
|
|
break;
|
|
|
|
|
}
|
2011-03-10 12:29:08 +00:00
|
|
|
|
|
|
|
|
|
/* Lookup created parameter, and register Python object against the
|
|
|
|
|
parameter context. Perform this task against both lists. */
|
|
|
|
|
tmp_name = cmd_name;
|
|
|
|
|
param = lookup_cmd (&tmp_name, *show_list, "", 0, 1);
|
|
|
|
|
if (param)
|
|
|
|
|
set_cmd_context (param, self);
|
|
|
|
|
|
|
|
|
|
tmp_name = cmd_name;
|
|
|
|
|
param = lookup_cmd (&tmp_name, *set_list, "", 0, 1);
|
|
|
|
|
if (param)
|
|
|
|
|
set_cmd_context (param, self);
|
2010-04-29 15:45:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-10-13 13:24:40 +00:00
|
|
|
|
/* A helper which computes enum values. Returns 1 on success. Returns 0 on
|
|
|
|
|
error, with a python exception set. */
|
2010-04-29 15:45:57 +00:00
|
|
|
|
static int
|
|
|
|
|
compute_enum_values (parmpy_object *self, PyObject *enum_values)
|
|
|
|
|
{
|
|
|
|
|
Py_ssize_t size, i;
|
2010-10-13 13:24:40 +00:00
|
|
|
|
struct cleanup *back_to;
|
2010-04-29 15:45:57 +00:00
|
|
|
|
|
|
|
|
|
if (! enum_values)
|
|
|
|
|
{
|
|
|
|
|
PyErr_SetString (PyExc_RuntimeError,
|
|
|
|
|
_("An enumeration is required for PARAM_ENUM."));
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (! PySequence_Check (enum_values))
|
|
|
|
|
{
|
2013-11-29 20:00:47 +00:00
|
|
|
|
PyErr_SetString (PyExc_RuntimeError,
|
2010-04-29 15:45:57 +00:00
|
|
|
|
_("The enumeration is not a sequence."));
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
size = PySequence_Size (enum_values);
|
|
|
|
|
if (size < 0)
|
|
|
|
|
return 0;
|
|
|
|
|
if (size == 0)
|
|
|
|
|
{
|
2013-11-29 20:00:47 +00:00
|
|
|
|
PyErr_SetString (PyExc_RuntimeError,
|
2010-04-29 15:45:57 +00:00
|
|
|
|
_("The enumeration is empty."));
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
Replace some xmalloc-family functions with XNEW-family ones
This patch is part of the make-gdb-buildable-in-C++ effort. The idea is
to change some calls to the xmalloc family of functions to calls to the
equivalents in the XNEW family. This avoids adding an explicit cast, so
it keeps the code a bit more readable. Some of them also map relatively
well to a C++ equivalent (XNEW (struct foo) -> new foo), so it will be
possible to do scripted replacements if needed.
I only changed calls that were obviously allocating memory for one or
multiple "objects". Allocation of variable sizes (such as strings or
buffer handling) will be for later (and won't use XNEW).
- xmalloc (sizeof (struct foo)) -> XNEW (struct foo)
- xmalloc (num * sizeof (struct foo)) -> XNEWVEC (struct foo, num)
- xcalloc (1, sizeof (struct foo)) -> XCNEW (struct foo)
- xcalloc (num, sizeof (struct foo)) -> XCNEWVEC (struct foo, num)
- xrealloc (p, num * sizeof (struct foo) -> XRESIZEVEC (struct foo, p, num)
- obstack_alloc (ob, sizeof (struct foo)) -> XOBNEW (ob, struct foo)
- obstack_alloc (ob, num * sizeof (struct foo)) -> XOBNEWVEC (ob, struct foo, num)
- alloca (sizeof (struct foo)) -> XALLOCA (struct foo)
- alloca (num * sizeof (struct foo)) -> XALLOCAVEC (struct foo, num)
Some instances of xmalloc followed by memset to zero the buffer were
replaced by XCNEW or XCNEWVEC.
I regtested on x86-64, Ubuntu 14.04, but the patch touches many
architecture-specific files. For those I'll have to rely on the
buildbot or people complaining that I broke their gdb.
gdb/ChangeLog:
* aarch64-linux-nat.c (aarch64_add_process): Likewise.
* aarch64-tdep.c (aarch64_gdbarch_init): Likewise.
* ada-exp.y (write_ambiguous_var): Likewise.
* ada-lang.c (resolve_subexp): Likewise.
(user_select_syms): Likewise.
(assign_aggregate): Likewise.
(ada_evaluate_subexp): Likewise.
(cache_symbol): Likewise.
* addrmap.c (allocate_key): Likewise.
(addrmap_create_mutable): Likewise.
* aix-thread.c (sync_threadlists): Likewise.
* alpha-tdep.c (alpha_push_dummy_call): Likewise.
(alpha_gdbarch_init): Likewise.
* amd64-windows-tdep.c (amd64_windows_push_arguments): Likewise.
* arm-linux-nat.c (arm_linux_add_process): Likewise.
* arm-linux-tdep.c (arm_linux_displaced_step_copy_insn): Likewise.
* arm-tdep.c (push_stack_item): Likewise.
(arm_displaced_step_copy_insn): Likewise.
(arm_gdbarch_init): Likewise.
(_initialize_arm_tdep): Likewise.
* avr-tdep.c (push_stack_item): Likewise.
* ax-general.c (new_agent_expr): Likewise.
* block.c (block_initialize_namespace): Likewise.
* breakpoint.c (alloc_counted_command_line): Likewise.
(update_dprintf_command_list): Likewise.
(parse_breakpoint_sals): Likewise.
(decode_static_tracepoint_spec): Likewise.
(until_break_command): Likewise.
(clear_command): Likewise.
(update_global_location_list): Likewise.
(get_breakpoint_objfile_data) Likewise.
* btrace.c (ftrace_new_function): Likewise.
(btrace_set_insn_history): Likewise.
(btrace_set_call_history): Likewise.
* buildsym.c (add_symbol_to_list): Likewise.
(record_pending_block): Likewise.
(start_subfile): Likewise.
(start_buildsym_compunit): Likewise.
(push_subfile): Likewise.
(end_symtab_get_static_block): Likewise.
(buildsym_init): Likewise.
* cli/cli-cmds.c (source_command): Likewise.
* cli/cli-decode.c (add_cmd): Likewise.
* cli/cli-script.c (build_command_line): Likewise.
(setup_user_args): Likewise.
(realloc_body_list): Likewise.
(process_next_line): Likewise.
(copy_command_lines): Likewise.
* cli/cli-setshow.c (do_set_command): Likewise.
* coff-pe-read.c (read_pe_exported_syms): Likewise.
* coffread.c (coff_locate_sections): Likewise.
(coff_symtab_read): Likewise.
(coff_read_struct_type): Likewise.
* common/cleanups.c (make_my_cleanup2): Likewise.
* common/common-exceptions.c (throw_it): Likewise.
* common/filestuff.c (make_cleanup_close): Likewise.
* common/format.c (parse_format_string): Likewise.
* common/queue.h (DEFINE_QUEUE_P): Likewise.
* compile/compile-object-load.c (munmap_list_add): Likewise.
(compile_object_load): Likewise.
* compile/compile-object-run.c (compile_object_run): Likewise.
* compile/compile.c (append_args): Likewise.
* corefile.c (specify_exec_file_hook): Likewise.
* cp-support.c (make_symbol_overload_list): Likewise.
* cris-tdep.c (push_stack_item): Likewise.
(cris_gdbarch_init): Likewise.
* ctf.c (ctf_trace_file_writer_new): Likewise.
* dbxread.c (init_header_files): Likewise.
(add_new_header_file): Likewise.
(init_bincl_list): Likewise.
(dbx_end_psymtab): Likewise.
(start_psymtab): Likewise.
(dbx_end_psymtab): Likewise.
* dcache.c (dcache_init): Likewise.
* dictionary.c (dict_create_hashed): Likewise.
(dict_create_hashed_expandable): Likewise.
(dict_create_linear): Likewise.
(dict_create_linear_expandable): Likewise.
* dtrace-probe.c (dtrace_process_dof_probe): Likewise.
* dummy-frame.c (register_dummy_frame_dtor): Likewise.
* dwarf2-frame-tailcall.c (cache_new_ref1): Likewise.
* dwarf2-frame.c (dwarf2_build_frame_info): Likewise.
(decode_frame_entry_1): Likewise.
* dwarf2expr.c (new_dwarf_expr_context): Likewise.
* dwarf2loc.c (dwarf2_compile_expr_to_ax): Likewise.
* dwarf2read.c (dwarf2_has_info): Likewise.
(create_signatured_type_table_from_index): Likewise.
(dwarf2_read_index): Likewise.
(dw2_get_file_names_reader): Likewise.
(create_all_type_units): Likewise.
(read_cutu_die_from_dwo): Likewise.
(init_tu_and_read_dwo_dies): Likewise.
(init_cutu_and_read_dies): Likewise.
(create_all_comp_units): Likewise.
(queue_comp_unit): Likewise.
(inherit_abstract_dies): Likewise.
(read_call_site_scope): Likewise.
(dwarf2_add_field): Likewise.
(dwarf2_add_typedef): Likewise.
(dwarf2_add_member_fn): Likewise.
(attr_to_dynamic_prop): Likewise.
(abbrev_table_alloc_abbrev): Likewise.
(abbrev_table_read_table): Likewise.
(add_include_dir): Likewise.
(add_file_name): Likewise.
(dwarf_decode_line_header): Likewise.
(dwarf2_const_value_attr): Likewise.
(dwarf_alloc_block): Likewise.
(parse_macro_definition): Likewise.
(set_die_type): Likewise.
(write_psymtabs_to_index): Likewise.
(create_cus_from_index): Likewise.
(dwarf2_create_include_psymtab): Likewise.
(process_psymtab_comp_unit_reader): Likewise.
(build_type_psymtab_dependencies): Likewise.
(read_comp_units_from_section): Likewise.
(compute_compunit_symtab_includes): Likewise.
(create_dwo_unit_in_dwp_v1): Likewise.
(create_dwo_unit_in_dwp_v2): Likewise.
(read_func_scope): Likewise.
(process_structure_scope): Likewise.
(mark_common_block_symbol_computed): Likewise.
(load_partial_dies): Likewise.
(dwarf2_symbol_mark_computed): Likewise.
* elfread.c (elf_symfile_segments): Likewise.
(elf_read_minimal_symbols): Likewise.
* environ.c (make_environ): Likewise.
* eval.c (evaluate_subexp_standard): Likewise.
* event-loop.c (create_file_handler): Likewise.
(create_async_signal_handler): Likewise.
(create_async_event_handler): Likewise.
(create_timer): Likewise.
* exec.c (build_section_table): Likewise.
* fbsd-nat.c (fbsd_remember_child): Likewise.
* fork-child.c (fork_inferior): Likewise.
* frv-tdep.c (new_variant): Likewise.
* gdbarch.sh (gdbarch_alloc): Likewise.
(append_name): Likewise.
* gdbtypes.c (rank_function): Likewise.
(copy_type_recursive): Likewise.
(add_dyn_prop): Likewise.
* gnu-nat.c (make_proc): Likewise.
(make_inf): Likewise.
(gnu_write_inferior): Likewise.
* gnu-v3-abi.c (build_gdb_vtable_type): Likewise.
(build_std_type_info_type): Likewise.
* guile/scm-param.c (compute_enum_list): Likewise.
* guile/scm-utils.c (gdbscm_parse_function_args): Likewise.
* guile/scm-value.c (gdbscm_value_call): Likewise.
* h8300-tdep.c (h8300_gdbarch_init): Likewise.
* hppa-tdep.c (hppa_init_objfile_priv_data): Likewise.
(read_unwind_info): Likewise.
* ia64-tdep.c (ia64_gdbarch_init): Likewise.
* infcall.c (dummy_frame_context_saver_setup): Likewise.
(call_function_by_hand_dummy): Likewise.
* infcmd.c (step_once): Likewise.
(finish_forward): Likewise.
(attach_command): Likewise.
(notice_new_inferior): Likewise.
* inferior.c (add_inferior_silent): Likewise.
* infrun.c (add_displaced_stepping_state): Likewise.
(save_infcall_control_state): Likewise.
(save_inferior_ptid): Likewise.
(_initialize_infrun): Likewise.
* jit.c (bfd_open_from_target_memory): Likewise.
(jit_gdbarch_data_init): Likewise.
* language.c (add_language): Likewise.
* linespec.c (decode_line_2): Likewise.
* linux-nat.c (add_to_pid_list): Likewise.
(add_initial_lwp): Likewise.
* linux-thread-db.c (add_thread_db_info): Likewise.
(record_thread): Likewise.
(info_auto_load_libthread_db): Likewise.
* m32c-tdep.c (m32c_gdbarch_init): Likewise.
* m68hc11-tdep.c (m68hc11_gdbarch_init): Likewise.
* m68k-tdep.c (m68k_gdbarch_init): Likewise.
* m88k-tdep.c (m88k_analyze_prologue): Likewise.
* macrocmd.c (macro_define_command): Likewise.
* macroexp.c (gather_arguments): Likewise.
* macroscope.c (sal_macro_scope): Likewise.
* macrotab.c (new_macro_table): Likewise.
* mdebugread.c (push_parse_stack): Likewise.
(parse_partial_symbols): Likewise.
(parse_symbol): Likewise.
(psymtab_to_symtab_1): Likewise.
(new_block): Likewise.
(new_psymtab): Likewise.
(mdebug_build_psymtabs): Likewise.
(add_pending): Likewise.
(elfmdebug_build_psymtabs): Likewise.
* mep-tdep.c (mep_gdbarch_init): Likewise.
* mi/mi-main.c (mi_execute_command): Likewise.
* mi/mi-parse.c (mi_parse_argv): Likewise.
* minidebug.c (lzma_open): Likewise.
* minsyms.c (terminate_minimal_symbol_table): Likewise.
* mips-linux-nat.c (mips_linux_insert_watchpoint): Likewise.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* mn10300-tdep.c (mn10300_gdbarch_init): Likewise.
* msp430-tdep.c (msp430_gdbarch_init): Likewise.
* mt-tdep.c (mt_registers_info): Likewise.
* nat/aarch64-linux.c (aarch64_linux_new_thread): Likewise.
* nat/linux-btrace.c (linux_enable_bts): Likewise.
(linux_enable_pt): Likewise.
* nat/linux-osdata.c (linux_xfer_osdata_processes): Likewise.
(linux_xfer_osdata_processgroups): Likewise.
* nios2-tdep.c (nios2_gdbarch_init): Likewise.
* nto-procfs.c (procfs_meminfo): Likewise.
* objc-lang.c (start_msglist): Likewise.
(selectors_info): Likewise.
(classes_info): Likewise.
(find_methods): Likewise.
* objfiles.c (allocate_objfile): Likewise.
(update_section_map): Likewise.
* osabi.c (gdbarch_register_osabi): Likewise.
(gdbarch_register_osabi_sniffer): Likewise.
* parse.c (start_arglist): Likewise.
* ppc-linux-nat.c (hwdebug_find_thread_points_by_tid): Likewise.
(hwdebug_insert_point): Likewise.
* printcmd.c (display_command): Likewise.
(ui_printf): Likewise.
* procfs.c (create_procinfo): Likewise.
(load_syscalls): Likewise.
(proc_get_LDT_entry): Likewise.
(proc_update_threads): Likewise.
* prologue-value.c (make_pv_area): Likewise.
(pv_area_store): Likewise.
* psymtab.c (extend_psymbol_list): Likewise.
(init_psymbol_list): Likewise.
(allocate_psymtab): Likewise.
* python/py-inferior.c (add_thread_object): Likewise.
* python/py-param.c (compute_enum_values): Likewise.
* python/py-value.c (valpy_call): Likewise.
* python/py-varobj.c (py_varobj_iter_next): Likewise.
* python/python.c (ensure_python_env): Likewise.
* record-btrace.c (record_btrace_start_replaying): Likewise.
* record-full.c (record_full_reg_alloc): Likewise.
(record_full_mem_alloc): Likewise.
(record_full_end_alloc): Likewise.
(record_full_core_xfer_partial): Likewise.
* regcache.c (get_thread_arch_aspace_regcache): Likewise.
* remote-fileio.c (remote_fileio_init_fd_map): Likewise.
* remote-notif.c (remote_notif_state_allocate): Likewise.
* remote.c (demand_private_info): Likewise.
(remote_notif_stop_alloc_reply): Likewise.
(remote_enable_btrace): Likewise.
* reverse.c (save_bookmark_command): Likewise.
* rl78-tdep.c (rl78_gdbarch_init): Likewise.
* rx-tdep.c (rx_gdbarch_init): Likewise.
* s390-linux-nat.c (s390_insert_watchpoint): Likewise.
* ser-go32.c (dos_get_tty_state): Likewise.
(dos_copy_tty_state): Likewise.
* ser-mingw.c (ser_windows_open): Likewise.
(ser_console_wait_handle): Likewise.
(ser_console_get_tty_state): Likewise.
(make_pipe_state): Likewise.
(net_windows_open): Likewise.
* ser-unix.c (hardwire_get_tty_state): Likewise.
(hardwire_copy_tty_state): Likewise.
* solib-aix.c (solib_aix_new_lm_info): Likewise.
* solib-dsbt.c (dsbt_current_sos): Likewise.
(dsbt_relocate_main_executable): Likewise.
* solib-frv.c (frv_current_sos): Likewise.
(frv_relocate_main_executable): Likewise.
* solib-spu.c (spu_bfd_fopen): Likewise.
* solib-svr4.c (lm_info_read): Likewise.
(svr4_copy_library_list): Likewise.
(svr4_default_sos): Likewise.
* source.c (find_source_lines): Likewise.
(line_info): Likewise.
(add_substitute_path_rule): Likewise.
* spu-linux-nat.c (spu_bfd_open): Likewise.
* spu-tdep.c (info_spu_dma_cmdlist): Likewise.
* stabsread.c (dbx_lookup_type): Likewise.
(read_type): Likewise.
(read_member_functions): Likewise.
(read_struct_fields): Likewise.
(read_baseclasses): Likewise.
(read_args): Likewise.
(_initialize_stabsread): Likewise.
* stack.c (func_command): Likewise.
* stap-probe.c (handle_stap_probe): Likewise.
* symfile.c (addrs_section_sort): Likewise.
(addr_info_make_relative): Likewise.
(load_section_callback): Likewise.
(add_symbol_file_command): Likewise.
(init_filename_language_table): Likewise.
* symtab.c (create_filename_seen_cache): Likewise.
(sort_search_symbols_remove_dups): Likewise.
(search_symbols): Likewise.
* target.c (make_cleanup_restore_target_terminal): Likewise.
* thread.c (new_thread): Likewise.
(enable_thread_stack_temporaries): Likewise.
(make_cleanup_restore_current_thread): Likewise.
(thread_apply_all_command): Likewise.
* tic6x-tdep.c (tic6x_gdbarch_init): Likewise.
* top.c (gdb_readline_wrapper): Likewise.
* tracefile-tfile.c (tfile_trace_file_writer_new): Likewise.
* tracepoint.c (trace_find_line_command): Likewise.
(all_tracepoint_actions_and_cleanup): Likewise.
(make_cleanup_restore_current_traceframe): Likewise.
(get_uploaded_tp): Likewise.
(get_uploaded_tsv): Likewise.
* tui/tui-data.c (tui_alloc_generic_win_info): Likewise.
(tui_alloc_win_info): Likewise.
(tui_alloc_content): Likewise.
(tui_add_content_elements): Likewise.
* tui/tui-disasm.c (tui_find_disassembly_address): Likewise.
(tui_set_disassem_content): Likewise.
* ui-file.c (ui_file_new): Likewise.
(stdio_file_new): Likewise.
(tee_file_new): Likewise.
* utils.c (make_cleanup_restore_integer): Likewise.
(add_internal_problem_command): Likewise.
* v850-tdep.c (v850_gdbarch_init): Likewise.
* valops.c (find_oload_champ): Likewise.
* value.c (allocate_value_lazy): Likewise.
(record_latest_value): Likewise.
(create_internalvar): Likewise.
* varobj.c (install_variable): Likewise.
(new_variable): Likewise.
(new_root_variable): Likewise.
(cppush): Likewise.
(_initialize_varobj): Likewise.
* windows-nat.c (windows_make_so): Likewise.
* x86-nat.c (x86_add_process): Likewise.
* xcoffread.c (arrange_linetable): Likewise.
(allocate_include_entry): Likewise.
(process_linenos): Likewise.
(SYMBOL_DUP): Likewise.
(xcoff_start_psymtab): Likewise.
(xcoff_end_psymtab): Likewise.
* xml-support.c (gdb_xml_parse_attr_ulongest): Likewise.
* xtensa-tdep.c (xtensa_register_type): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
gdb/gdbserver/ChangeLog:
* ax.c (gdb_parse_agent_expr): Likewise.
(compile_bytecodes): Likewise.
* dll.c (loaded_dll): Likewise.
* event-loop.c (append_callback_event): Likewise.
(create_file_handler): Likewise.
(create_file_event): Likewise.
* hostio.c (handle_open): Likewise.
* inferiors.c (add_thread): Likewise.
(add_process): Likewise.
* linux-aarch64-low.c (aarch64_linux_new_process): Likewise.
* linux-arm-low.c (arm_new_process): Likewise.
(arm_new_thread): Likewise.
* linux-low.c (add_to_pid_list): Likewise.
(linux_add_process): Likewise.
(handle_extended_wait): Likewise.
(add_lwp): Likewise.
(enqueue_one_deferred_signal): Likewise.
(enqueue_pending_signal): Likewise.
(linux_resume_one_lwp_throw): Likewise.
(linux_resume_one_thread): Likewise.
(linux_read_memory): Likewise.
(linux_write_memory): Likewise.
* linux-mips-low.c (mips_linux_new_process): Likewise.
(mips_linux_new_thread): Likewise.
(mips_add_watchpoint): Likewise.
* linux-x86-low.c (initialize_low_arch): Likewise.
* lynx-low.c (lynx_add_process): Likewise.
* mem-break.c (set_raw_breakpoint_at): Likewise.
(set_breakpoint): Likewise.
(add_condition_to_breakpoint): Likewise.
(add_commands_to_breakpoint): Likewise.
(clone_agent_expr): Likewise.
(clone_one_breakpoint): Likewise.
* regcache.c (new_register_cache): Likewise.
* remote-utils.c (look_up_one_symbol): Likewise.
* server.c (queue_stop_reply): Likewise.
(start_inferior): Likewise.
(queue_stop_reply_callback): Likewise.
(handle_target_event): Likewise.
* spu-low.c (fetch_ppc_memory): Likewise.
(store_ppc_memory): Likewise.
* target.c (set_target_ops): Likewise.
* thread-db.c (thread_db_load_search): Likewise.
(try_thread_db_load_1): Likewise.
* tracepoint.c (add_tracepoint): Likewise.
(add_tracepoint_action): Likewise.
(create_trace_state_variable): Likewise.
(cmd_qtdpsrc): Likewise.
(cmd_qtro): Likewise.
(add_while_stepping_state): Likewise.
* win32-low.c (child_add_thread): Likewise.
(get_image_name): Likewise.
2015-08-26 21:16:07 +00:00
|
|
|
|
self->enumeration = XCNEWVEC (const char *, size + 1);
|
2010-10-13 13:24:40 +00:00
|
|
|
|
back_to = make_cleanup (free_current_contents, &self->enumeration);
|
2010-04-29 15:45:57 +00:00
|
|
|
|
|
|
|
|
|
for (i = 0; i < size; ++i)
|
|
|
|
|
{
|
|
|
|
|
PyObject *item = PySequence_GetItem (enum_values, i);
|
2010-05-17 21:23:25 +00:00
|
|
|
|
|
2010-04-29 15:45:57 +00:00
|
|
|
|
if (! item)
|
2010-10-13 13:24:40 +00:00
|
|
|
|
{
|
|
|
|
|
do_cleanups (back_to);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2010-04-29 15:45:57 +00:00
|
|
|
|
if (! gdbpy_is_string (item))
|
|
|
|
|
{
|
2013-05-20 20:30:24 +00:00
|
|
|
|
Py_DECREF (item);
|
2010-10-13 13:24:40 +00:00
|
|
|
|
do_cleanups (back_to);
|
2013-11-29 20:00:47 +00:00
|
|
|
|
PyErr_SetString (PyExc_RuntimeError,
|
2010-04-29 15:45:57 +00:00
|
|
|
|
_("The enumeration item not a string."));
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
self->enumeration[i] = python_string_to_host_string (item);
|
2013-05-20 20:30:24 +00:00
|
|
|
|
Py_DECREF (item);
|
2010-10-13 13:24:40 +00:00
|
|
|
|
if (self->enumeration[i] == NULL)
|
|
|
|
|
{
|
|
|
|
|
do_cleanups (back_to);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
make_cleanup (xfree, (char *) self->enumeration[i]);
|
2010-04-29 15:45:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-10-13 13:24:40 +00:00
|
|
|
|
discard_cleanups (back_to);
|
2010-04-29 15:45:57 +00:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Object initializer; sets up gdb-side structures for command.
|
|
|
|
|
|
|
|
|
|
Use: __init__(NAME, CMDCLASS, PARMCLASS, [ENUM])
|
|
|
|
|
|
|
|
|
|
NAME is the name of the parameter. It may consist of multiple
|
|
|
|
|
words, in which case the final word is the name of the new command,
|
|
|
|
|
and earlier words must be prefix commands.
|
|
|
|
|
|
|
|
|
|
CMDCLASS is the kind of command. It should be one of the COMMAND_*
|
|
|
|
|
constants defined in the gdb module.
|
|
|
|
|
|
|
|
|
|
PARMCLASS is the type of the parameter. It should be one of the
|
|
|
|
|
PARAM_* constants defined in the gdb module.
|
|
|
|
|
|
|
|
|
|
If PARMCLASS is PARAM_ENUM, then the final argument should be a
|
|
|
|
|
collection of strings. These strings are the valid values for this
|
|
|
|
|
parameter.
|
|
|
|
|
|
|
|
|
|
The documentation for the parameter is taken from the doc string
|
|
|
|
|
for the python class.
|
2010-10-13 13:24:40 +00:00
|
|
|
|
|
|
|
|
|
Returns -1 on error, with a python exception set. */
|
|
|
|
|
|
2010-04-29 15:45:57 +00:00
|
|
|
|
static int
|
|
|
|
|
parmpy_init (PyObject *self, PyObject *args, PyObject *kwds)
|
|
|
|
|
{
|
|
|
|
|
parmpy_object *obj = (parmpy_object *) self;
|
2011-06-24 19:47:37 +00:00
|
|
|
|
const char *name;
|
2010-04-29 15:45:57 +00:00
|
|
|
|
char *set_doc, *show_doc, *doc;
|
|
|
|
|
char *cmd_name;
|
|
|
|
|
int parmclass, cmdtype;
|
|
|
|
|
PyObject *enum_values = NULL;
|
|
|
|
|
struct cmd_list_element **set_list, **show_list;
|
|
|
|
|
|
|
|
|
|
if (! PyArg_ParseTuple (args, "sii|O", &name, &cmdtype, &parmclass,
|
|
|
|
|
&enum_values))
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
if (cmdtype != no_class && cmdtype != class_run
|
|
|
|
|
&& cmdtype != class_vars && cmdtype != class_stack
|
|
|
|
|
&& cmdtype != class_files && cmdtype != class_support
|
|
|
|
|
&& cmdtype != class_info && cmdtype != class_breakpoint
|
|
|
|
|
&& cmdtype != class_trace && cmdtype != class_obscure
|
|
|
|
|
&& cmdtype != class_maintenance)
|
|
|
|
|
{
|
|
|
|
|
PyErr_Format (PyExc_RuntimeError, _("Invalid command class argument."));
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-30 16:22:42 +00:00
|
|
|
|
if (parmclass != var_boolean /* ARI: var_boolean */
|
|
|
|
|
&& parmclass != var_auto_boolean
|
2010-04-29 15:45:57 +00:00
|
|
|
|
&& parmclass != var_uinteger && parmclass != var_integer
|
|
|
|
|
&& parmclass != var_string && parmclass != var_string_noescape
|
|
|
|
|
&& parmclass != var_optional_filename && parmclass != var_filename
|
|
|
|
|
&& parmclass != var_zinteger && parmclass != var_enum)
|
|
|
|
|
{
|
2011-01-06 00:57:05 +00:00
|
|
|
|
PyErr_SetString (PyExc_RuntimeError,
|
|
|
|
|
_("Invalid parameter class argument."));
|
2010-04-29 15:45:57 +00:00
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (enum_values && parmclass != var_enum)
|
|
|
|
|
{
|
|
|
|
|
PyErr_SetString (PyExc_RuntimeError,
|
|
|
|
|
_("Only PARAM_ENUM accepts a fourth argument."));
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
if (parmclass == var_enum)
|
|
|
|
|
{
|
|
|
|
|
if (! compute_enum_values (obj, enum_values))
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
obj->enumeration = NULL;
|
|
|
|
|
obj->type = (enum var_types) parmclass;
|
|
|
|
|
memset (&obj->value, 0, sizeof (obj->value));
|
|
|
|
|
|
2011-09-08 19:51:27 +00:00
|
|
|
|
cmd_name = gdbpy_parse_command_name (name, &set_list,
|
2010-04-29 15:45:57 +00:00
|
|
|
|
&setlist);
|
|
|
|
|
|
|
|
|
|
if (! cmd_name)
|
2011-09-08 19:51:27 +00:00
|
|
|
|
return -1;
|
2010-04-29 15:45:57 +00:00
|
|
|
|
xfree (cmd_name);
|
2011-09-08 19:51:27 +00:00
|
|
|
|
cmd_name = gdbpy_parse_command_name (name, &show_list,
|
2010-04-29 15:45:57 +00:00
|
|
|
|
&showlist);
|
|
|
|
|
if (! cmd_name)
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
set_doc = get_doc_string (self, set_doc_cst);
|
|
|
|
|
show_doc = get_doc_string (self, show_doc_cst);
|
|
|
|
|
doc = get_doc_string (self, gdbpy_doc_cst);
|
|
|
|
|
|
|
|
|
|
Py_INCREF (self);
|
|
|
|
|
|
Split TRY_CATCH into TRY + CATCH
This patch splits the TRY_CATCH macro into three, so that we go from
this:
~~~
volatile gdb_exception ex;
TRY_CATCH (ex, RETURN_MASK_ERROR)
{
}
if (ex.reason < 0)
{
}
~~~
to this:
~~~
TRY
{
}
CATCH (ex, RETURN_MASK_ERROR)
{
}
END_CATCH
~~~
Thus, we'll be getting rid of the local volatile exception object, and
declaring the caught exception in the catch block.
This allows reimplementing TRY/CATCH in terms of C++ exceptions when
building in C++ mode, while still allowing to build GDB in C mode
(using setjmp/longjmp), as a transition step.
TBC, after this patch, is it _not_ valid to have code between the TRY
and the CATCH blocks, like:
TRY
{
}
// some code here.
CATCH (ex, RETURN_MASK_ERROR)
{
}
END_CATCH
Just like it isn't valid to do that with C++'s native try/catch.
By switching to creating the exception object inside the CATCH block
scope, we can get rid of all the explicitly allocated volatile
exception objects all over the tree, and map the CATCH block more
directly to C++'s catch blocks.
The majority of the TRY_CATCH -> TRY+CATCH+END_CATCH conversion was
done with a script, rerun from scratch at every rebase, no manual
editing involved. After the mechanical conversion, a few places
needed manual intervention, to fix preexisting cases where we were
using the exception object outside of the TRY_CATCH block, and cases
where we were using "else" after a 'if (ex.reason) < 0)' [a CATCH
after this patch]. The result was folded into this patch so that GDB
still builds at each incremental step.
END_CATCH is necessary for two reasons:
First, because we name the exception object in the CATCH block, which
requires creating a scope, which in turn must be closed somewhere.
Declaring the exception variable in the initializer field of a for
block, like:
#define CATCH(EXCEPTION, mask) \
for (struct gdb_exception EXCEPTION; \
exceptions_state_mc_catch (&EXCEPTION, MASK); \
EXCEPTION = exception_none)
would avoid needing END_CATCH, but alas, in C mode, we build with C90,
which doesn't allow mixed declarations and code.
Second, because when TRY/CATCH are wired to real C++ try/catch, as
long as we need to handle cleanup chains, even if there's no CATCH
block that wants to catch the exception, we need for stop at every
frame in the unwind chain and run cleanups, then rethrow. That will
be done in END_CATCH.
After we require C++, we'll still need TRY/CATCH/END_CATCH until
cleanups are completely phased out -- TRY/CATCH in C++ mode will
save/restore the current cleanup chain, like in C mode, and END_CATCH
catches otherwise uncaugh exceptions, runs cleanups and rethrows, so
that C++ cleanups and exceptions can coexist.
IMO, this still makes the TRY/CATCH code look a bit more like a
newcomer would expect, so IMO worth it even if we weren't considering
C++.
gdb/ChangeLog.
2015-03-07 Pedro Alves <palves@redhat.com>
* common/common-exceptions.c (struct catcher) <exception>: No
longer a pointer to volatile exception. Now an exception value.
<mask>: Delete field.
(exceptions_state_mc_init): Remove all parameters. Adjust.
(exceptions_state_mc): No longer pop the catcher here.
(exceptions_state_mc_catch): New function.
(throw_exception): Adjust.
* common/common-exceptions.h (exceptions_state_mc_init): Remove
all parameters.
(exceptions_state_mc_catch): Declare.
(TRY_CATCH): Rename to ...
(TRY): ... this. Remove EXCEPTION and MASK parameters.
(CATCH, END_CATCH): New.
All callers adjusted.
gdb/gdbserver/ChangeLog:
2015-03-07 Pedro Alves <palves@redhat.com>
Adjust all callers of TRY_CATCH to use TRY/CATCH/END_CATCH
instead.
2015-03-07 15:14:14 +00:00
|
|
|
|
TRY
|
2010-04-29 15:45:57 +00:00
|
|
|
|
{
|
|
|
|
|
add_setshow_generic (parmclass, (enum command_class) cmdtype,
|
|
|
|
|
cmd_name, obj,
|
|
|
|
|
set_doc, show_doc,
|
|
|
|
|
doc, set_list, show_list);
|
|
|
|
|
}
|
Split TRY_CATCH into TRY + CATCH
This patch splits the TRY_CATCH macro into three, so that we go from
this:
~~~
volatile gdb_exception ex;
TRY_CATCH (ex, RETURN_MASK_ERROR)
{
}
if (ex.reason < 0)
{
}
~~~
to this:
~~~
TRY
{
}
CATCH (ex, RETURN_MASK_ERROR)
{
}
END_CATCH
~~~
Thus, we'll be getting rid of the local volatile exception object, and
declaring the caught exception in the catch block.
This allows reimplementing TRY/CATCH in terms of C++ exceptions when
building in C++ mode, while still allowing to build GDB in C mode
(using setjmp/longjmp), as a transition step.
TBC, after this patch, is it _not_ valid to have code between the TRY
and the CATCH blocks, like:
TRY
{
}
// some code here.
CATCH (ex, RETURN_MASK_ERROR)
{
}
END_CATCH
Just like it isn't valid to do that with C++'s native try/catch.
By switching to creating the exception object inside the CATCH block
scope, we can get rid of all the explicitly allocated volatile
exception objects all over the tree, and map the CATCH block more
directly to C++'s catch blocks.
The majority of the TRY_CATCH -> TRY+CATCH+END_CATCH conversion was
done with a script, rerun from scratch at every rebase, no manual
editing involved. After the mechanical conversion, a few places
needed manual intervention, to fix preexisting cases where we were
using the exception object outside of the TRY_CATCH block, and cases
where we were using "else" after a 'if (ex.reason) < 0)' [a CATCH
after this patch]. The result was folded into this patch so that GDB
still builds at each incremental step.
END_CATCH is necessary for two reasons:
First, because we name the exception object in the CATCH block, which
requires creating a scope, which in turn must be closed somewhere.
Declaring the exception variable in the initializer field of a for
block, like:
#define CATCH(EXCEPTION, mask) \
for (struct gdb_exception EXCEPTION; \
exceptions_state_mc_catch (&EXCEPTION, MASK); \
EXCEPTION = exception_none)
would avoid needing END_CATCH, but alas, in C mode, we build with C90,
which doesn't allow mixed declarations and code.
Second, because when TRY/CATCH are wired to real C++ try/catch, as
long as we need to handle cleanup chains, even if there's no CATCH
block that wants to catch the exception, we need for stop at every
frame in the unwind chain and run cleanups, then rethrow. That will
be done in END_CATCH.
After we require C++, we'll still need TRY/CATCH/END_CATCH until
cleanups are completely phased out -- TRY/CATCH in C++ mode will
save/restore the current cleanup chain, like in C mode, and END_CATCH
catches otherwise uncaugh exceptions, runs cleanups and rethrows, so
that C++ cleanups and exceptions can coexist.
IMO, this still makes the TRY/CATCH code look a bit more like a
newcomer would expect, so IMO worth it even if we weren't considering
C++.
gdb/ChangeLog.
2015-03-07 Pedro Alves <palves@redhat.com>
* common/common-exceptions.c (struct catcher) <exception>: No
longer a pointer to volatile exception. Now an exception value.
<mask>: Delete field.
(exceptions_state_mc_init): Remove all parameters. Adjust.
(exceptions_state_mc): No longer pop the catcher here.
(exceptions_state_mc_catch): New function.
(throw_exception): Adjust.
* common/common-exceptions.h (exceptions_state_mc_init): Remove
all parameters.
(exceptions_state_mc_catch): Declare.
(TRY_CATCH): Rename to ...
(TRY): ... this. Remove EXCEPTION and MASK parameters.
(CATCH, END_CATCH): New.
All callers adjusted.
gdb/gdbserver/ChangeLog:
2015-03-07 Pedro Alves <palves@redhat.com>
Adjust all callers of TRY_CATCH to use TRY/CATCH/END_CATCH
instead.
2015-03-07 15:14:14 +00:00
|
|
|
|
CATCH (except, RETURN_MASK_ALL)
|
2010-04-29 15:45:57 +00:00
|
|
|
|
{
|
|
|
|
|
xfree (cmd_name);
|
|
|
|
|
xfree (set_doc);
|
|
|
|
|
xfree (show_doc);
|
|
|
|
|
xfree (doc);
|
|
|
|
|
Py_DECREF (self);
|
|
|
|
|
PyErr_Format (except.reason == RETURN_QUIT
|
|
|
|
|
? PyExc_KeyboardInterrupt : PyExc_RuntimeError,
|
|
|
|
|
"%s", except.message);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
Split TRY_CATCH into TRY + CATCH
This patch splits the TRY_CATCH macro into three, so that we go from
this:
~~~
volatile gdb_exception ex;
TRY_CATCH (ex, RETURN_MASK_ERROR)
{
}
if (ex.reason < 0)
{
}
~~~
to this:
~~~
TRY
{
}
CATCH (ex, RETURN_MASK_ERROR)
{
}
END_CATCH
~~~
Thus, we'll be getting rid of the local volatile exception object, and
declaring the caught exception in the catch block.
This allows reimplementing TRY/CATCH in terms of C++ exceptions when
building in C++ mode, while still allowing to build GDB in C mode
(using setjmp/longjmp), as a transition step.
TBC, after this patch, is it _not_ valid to have code between the TRY
and the CATCH blocks, like:
TRY
{
}
// some code here.
CATCH (ex, RETURN_MASK_ERROR)
{
}
END_CATCH
Just like it isn't valid to do that with C++'s native try/catch.
By switching to creating the exception object inside the CATCH block
scope, we can get rid of all the explicitly allocated volatile
exception objects all over the tree, and map the CATCH block more
directly to C++'s catch blocks.
The majority of the TRY_CATCH -> TRY+CATCH+END_CATCH conversion was
done with a script, rerun from scratch at every rebase, no manual
editing involved. After the mechanical conversion, a few places
needed manual intervention, to fix preexisting cases where we were
using the exception object outside of the TRY_CATCH block, and cases
where we were using "else" after a 'if (ex.reason) < 0)' [a CATCH
after this patch]. The result was folded into this patch so that GDB
still builds at each incremental step.
END_CATCH is necessary for two reasons:
First, because we name the exception object in the CATCH block, which
requires creating a scope, which in turn must be closed somewhere.
Declaring the exception variable in the initializer field of a for
block, like:
#define CATCH(EXCEPTION, mask) \
for (struct gdb_exception EXCEPTION; \
exceptions_state_mc_catch (&EXCEPTION, MASK); \
EXCEPTION = exception_none)
would avoid needing END_CATCH, but alas, in C mode, we build with C90,
which doesn't allow mixed declarations and code.
Second, because when TRY/CATCH are wired to real C++ try/catch, as
long as we need to handle cleanup chains, even if there's no CATCH
block that wants to catch the exception, we need for stop at every
frame in the unwind chain and run cleanups, then rethrow. That will
be done in END_CATCH.
After we require C++, we'll still need TRY/CATCH/END_CATCH until
cleanups are completely phased out -- TRY/CATCH in C++ mode will
save/restore the current cleanup chain, like in C mode, and END_CATCH
catches otherwise uncaugh exceptions, runs cleanups and rethrows, so
that C++ cleanups and exceptions can coexist.
IMO, this still makes the TRY/CATCH code look a bit more like a
newcomer would expect, so IMO worth it even if we weren't considering
C++.
gdb/ChangeLog.
2015-03-07 Pedro Alves <palves@redhat.com>
* common/common-exceptions.c (struct catcher) <exception>: No
longer a pointer to volatile exception. Now an exception value.
<mask>: Delete field.
(exceptions_state_mc_init): Remove all parameters. Adjust.
(exceptions_state_mc): No longer pop the catcher here.
(exceptions_state_mc_catch): New function.
(throw_exception): Adjust.
* common/common-exceptions.h (exceptions_state_mc_init): Remove
all parameters.
(exceptions_state_mc_catch): Declare.
(TRY_CATCH): Rename to ...
(TRY): ... this. Remove EXCEPTION and MASK parameters.
(CATCH, END_CATCH): New.
All callers adjusted.
gdb/gdbserver/ChangeLog:
2015-03-07 Pedro Alves <palves@redhat.com>
Adjust all callers of TRY_CATCH to use TRY/CATCH/END_CATCH
instead.
2015-03-07 15:14:14 +00:00
|
|
|
|
END_CATCH
|
|
|
|
|
|
2010-04-29 15:45:57 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Initialize the 'parameters' module. */
|
* python/py-arch.c (gdbpy_initialize_arch): Return 'int'.
Check errors.
* python/py-auto-load.c (gdbpy_initialize_auto_load): Return 'int'.
* python/py-block.c (gdbpy_initialize_blocks): Return 'int'.
Check errors.
* python/py-breakpoint.c (gdbpy_initialize_breakpoints): Return 'int'.
Check errors.
* python/py-cmd.c (gdbpy_initialize_commands): Return 'int'.
Check errors.
* python/py-event.c (gdbpy_initialize_event): Return 'int'.
Check errors.
* python/py-event.h (GDBPY_NEW_EVENT_TYPE): Change generated
init function to return 'int'.
* python/py-evtregistry.c (gdbpy_initialize_eventregistry):
Return 'int'. Check errors.
* python/py-evts.c (gdbpy_initialize_py_events): Return 'int'.
Check errors.
* python/py-finishbreakpoint.c (gdbpy_initialize_finishbreakpoints):
Return 'int'. Check errors.
* python/py-frame.c (gdbpy_initialize_frames): Return 'int'.
Check errors.
* python/py-function.c (gdbpy_initialize_functions): Return 'int'.
Check errors.
* python/py-gdb-readline.c (gdbpy_initialize_gdb_readline):
Check errors.
* python/py-inferior.c (gdbpy_initialize_inferior): Return 'int'.
Check errors.
* python/py-infthread.c (gdbpy_initialize_thread): Return 'int'.
Check errors.
* python/py-lazy-string.c (gdbpy_initialize_lazy_string): Return 'int'.
Check errors.
* python/py-objfile.c (gdbpy_initialize_objfile): Return 'int'.
Check errors.
* python/py-param.c (gdbpy_initialize_parameters): Return 'int'.
Check errors.
* python/py-progspace.c (gdbpy_initialize_pspace): Return 'int'.
Check errors.
* python/py-symbol.c (gdbpy_initialize_symbols): Return 'int'.
Check errors.
* python/py-symtab.c (gdbpy_initialize_symtabs): Return 'int'.
Check errors.
* python/py-type.c (gdbpy_initialize_types): Return 'int'.
Check errors.
* python/py-value.c (gdbpy_initialize_values): Return 'int'.
Check errors.
* python/python-internal.h (gdbpy_initialize_auto_load,
gdbpy_initialize_values, gdbpy_initialize_frames,
gdbpy_initialize_symtabs, gdbpy_initialize_commands,
gdbpy_initialize_symbols, gdbpy_initialize_symtabs,
gdbpy_initialize_blocks, gdbpy_initialize_types,
gdbpy_initialize_functions, gdbpy_initialize_pspace,
gdbpy_initialize_objfile, gdbpy_initialize_breakpoints,
gdbpy_initialize_finishbreakpoints,
gdbpy_initialize_lazy_string, gdbpy_initialize_parameters,
gdbpy_initialize_thread, gdbpy_initialize_inferior,
gdbpy_initialize_eventregistry, gdbpy_initialize_event,
gdbpy_initialize_py_events, gdbpy_initialize_stop_event,
gdbpy_initialize_signal_event,
gdbpy_initialize_breakpoint_event,
gdbpy_initialize_continue_event,
gdbpy_initialize_exited_event, gdbpy_initialize_thread_event,
gdbpy_initialize_new_objfile_event, gdbpy_initialize_arch):
Update. Use CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION.
* python/python.c (gdb_python_initialized): New global.
(gdbpy_initialize_events): Return 'int'. Check errors.
(_initialize_python): Check errors. Set
gdb_python_initialized.
2013-05-20 20:28:52 +00:00
|
|
|
|
int
|
2010-04-29 15:45:57 +00:00
|
|
|
|
gdbpy_initialize_parameters (void)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
2011-08-05 14:24:10 +00:00
|
|
|
|
parmpy_object_type.tp_new = PyType_GenericNew;
|
2010-04-29 15:45:57 +00:00
|
|
|
|
if (PyType_Ready (&parmpy_object_type) < 0)
|
* python/py-arch.c (gdbpy_initialize_arch): Return 'int'.
Check errors.
* python/py-auto-load.c (gdbpy_initialize_auto_load): Return 'int'.
* python/py-block.c (gdbpy_initialize_blocks): Return 'int'.
Check errors.
* python/py-breakpoint.c (gdbpy_initialize_breakpoints): Return 'int'.
Check errors.
* python/py-cmd.c (gdbpy_initialize_commands): Return 'int'.
Check errors.
* python/py-event.c (gdbpy_initialize_event): Return 'int'.
Check errors.
* python/py-event.h (GDBPY_NEW_EVENT_TYPE): Change generated
init function to return 'int'.
* python/py-evtregistry.c (gdbpy_initialize_eventregistry):
Return 'int'. Check errors.
* python/py-evts.c (gdbpy_initialize_py_events): Return 'int'.
Check errors.
* python/py-finishbreakpoint.c (gdbpy_initialize_finishbreakpoints):
Return 'int'. Check errors.
* python/py-frame.c (gdbpy_initialize_frames): Return 'int'.
Check errors.
* python/py-function.c (gdbpy_initialize_functions): Return 'int'.
Check errors.
* python/py-gdb-readline.c (gdbpy_initialize_gdb_readline):
Check errors.
* python/py-inferior.c (gdbpy_initialize_inferior): Return 'int'.
Check errors.
* python/py-infthread.c (gdbpy_initialize_thread): Return 'int'.
Check errors.
* python/py-lazy-string.c (gdbpy_initialize_lazy_string): Return 'int'.
Check errors.
* python/py-objfile.c (gdbpy_initialize_objfile): Return 'int'.
Check errors.
* python/py-param.c (gdbpy_initialize_parameters): Return 'int'.
Check errors.
* python/py-progspace.c (gdbpy_initialize_pspace): Return 'int'.
Check errors.
* python/py-symbol.c (gdbpy_initialize_symbols): Return 'int'.
Check errors.
* python/py-symtab.c (gdbpy_initialize_symtabs): Return 'int'.
Check errors.
* python/py-type.c (gdbpy_initialize_types): Return 'int'.
Check errors.
* python/py-value.c (gdbpy_initialize_values): Return 'int'.
Check errors.
* python/python-internal.h (gdbpy_initialize_auto_load,
gdbpy_initialize_values, gdbpy_initialize_frames,
gdbpy_initialize_symtabs, gdbpy_initialize_commands,
gdbpy_initialize_symbols, gdbpy_initialize_symtabs,
gdbpy_initialize_blocks, gdbpy_initialize_types,
gdbpy_initialize_functions, gdbpy_initialize_pspace,
gdbpy_initialize_objfile, gdbpy_initialize_breakpoints,
gdbpy_initialize_finishbreakpoints,
gdbpy_initialize_lazy_string, gdbpy_initialize_parameters,
gdbpy_initialize_thread, gdbpy_initialize_inferior,
gdbpy_initialize_eventregistry, gdbpy_initialize_event,
gdbpy_initialize_py_events, gdbpy_initialize_stop_event,
gdbpy_initialize_signal_event,
gdbpy_initialize_breakpoint_event,
gdbpy_initialize_continue_event,
gdbpy_initialize_exited_event, gdbpy_initialize_thread_event,
gdbpy_initialize_new_objfile_event, gdbpy_initialize_arch):
Update. Use CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION.
* python/python.c (gdb_python_initialized): New global.
(gdbpy_initialize_events): Return 'int'. Check errors.
(_initialize_python): Check errors. Set
gdb_python_initialized.
2013-05-20 20:28:52 +00:00
|
|
|
|
return -1;
|
2010-04-29 15:45:57 +00:00
|
|
|
|
|
|
|
|
|
set_doc_cst = PyString_FromString ("set_doc");
|
|
|
|
|
if (! set_doc_cst)
|
* python/py-arch.c (gdbpy_initialize_arch): Return 'int'.
Check errors.
* python/py-auto-load.c (gdbpy_initialize_auto_load): Return 'int'.
* python/py-block.c (gdbpy_initialize_blocks): Return 'int'.
Check errors.
* python/py-breakpoint.c (gdbpy_initialize_breakpoints): Return 'int'.
Check errors.
* python/py-cmd.c (gdbpy_initialize_commands): Return 'int'.
Check errors.
* python/py-event.c (gdbpy_initialize_event): Return 'int'.
Check errors.
* python/py-event.h (GDBPY_NEW_EVENT_TYPE): Change generated
init function to return 'int'.
* python/py-evtregistry.c (gdbpy_initialize_eventregistry):
Return 'int'. Check errors.
* python/py-evts.c (gdbpy_initialize_py_events): Return 'int'.
Check errors.
* python/py-finishbreakpoint.c (gdbpy_initialize_finishbreakpoints):
Return 'int'. Check errors.
* python/py-frame.c (gdbpy_initialize_frames): Return 'int'.
Check errors.
* python/py-function.c (gdbpy_initialize_functions): Return 'int'.
Check errors.
* python/py-gdb-readline.c (gdbpy_initialize_gdb_readline):
Check errors.
* python/py-inferior.c (gdbpy_initialize_inferior): Return 'int'.
Check errors.
* python/py-infthread.c (gdbpy_initialize_thread): Return 'int'.
Check errors.
* python/py-lazy-string.c (gdbpy_initialize_lazy_string): Return 'int'.
Check errors.
* python/py-objfile.c (gdbpy_initialize_objfile): Return 'int'.
Check errors.
* python/py-param.c (gdbpy_initialize_parameters): Return 'int'.
Check errors.
* python/py-progspace.c (gdbpy_initialize_pspace): Return 'int'.
Check errors.
* python/py-symbol.c (gdbpy_initialize_symbols): Return 'int'.
Check errors.
* python/py-symtab.c (gdbpy_initialize_symtabs): Return 'int'.
Check errors.
* python/py-type.c (gdbpy_initialize_types): Return 'int'.
Check errors.
* python/py-value.c (gdbpy_initialize_values): Return 'int'.
Check errors.
* python/python-internal.h (gdbpy_initialize_auto_load,
gdbpy_initialize_values, gdbpy_initialize_frames,
gdbpy_initialize_symtabs, gdbpy_initialize_commands,
gdbpy_initialize_symbols, gdbpy_initialize_symtabs,
gdbpy_initialize_blocks, gdbpy_initialize_types,
gdbpy_initialize_functions, gdbpy_initialize_pspace,
gdbpy_initialize_objfile, gdbpy_initialize_breakpoints,
gdbpy_initialize_finishbreakpoints,
gdbpy_initialize_lazy_string, gdbpy_initialize_parameters,
gdbpy_initialize_thread, gdbpy_initialize_inferior,
gdbpy_initialize_eventregistry, gdbpy_initialize_event,
gdbpy_initialize_py_events, gdbpy_initialize_stop_event,
gdbpy_initialize_signal_event,
gdbpy_initialize_breakpoint_event,
gdbpy_initialize_continue_event,
gdbpy_initialize_exited_event, gdbpy_initialize_thread_event,
gdbpy_initialize_new_objfile_event, gdbpy_initialize_arch):
Update. Use CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION.
* python/python.c (gdb_python_initialized): New global.
(gdbpy_initialize_events): Return 'int'. Check errors.
(_initialize_python): Check errors. Set
gdb_python_initialized.
2013-05-20 20:28:52 +00:00
|
|
|
|
return -1;
|
2010-04-29 15:45:57 +00:00
|
|
|
|
show_doc_cst = PyString_FromString ("show_doc");
|
|
|
|
|
if (! show_doc_cst)
|
* python/py-arch.c (gdbpy_initialize_arch): Return 'int'.
Check errors.
* python/py-auto-load.c (gdbpy_initialize_auto_load): Return 'int'.
* python/py-block.c (gdbpy_initialize_blocks): Return 'int'.
Check errors.
* python/py-breakpoint.c (gdbpy_initialize_breakpoints): Return 'int'.
Check errors.
* python/py-cmd.c (gdbpy_initialize_commands): Return 'int'.
Check errors.
* python/py-event.c (gdbpy_initialize_event): Return 'int'.
Check errors.
* python/py-event.h (GDBPY_NEW_EVENT_TYPE): Change generated
init function to return 'int'.
* python/py-evtregistry.c (gdbpy_initialize_eventregistry):
Return 'int'. Check errors.
* python/py-evts.c (gdbpy_initialize_py_events): Return 'int'.
Check errors.
* python/py-finishbreakpoint.c (gdbpy_initialize_finishbreakpoints):
Return 'int'. Check errors.
* python/py-frame.c (gdbpy_initialize_frames): Return 'int'.
Check errors.
* python/py-function.c (gdbpy_initialize_functions): Return 'int'.
Check errors.
* python/py-gdb-readline.c (gdbpy_initialize_gdb_readline):
Check errors.
* python/py-inferior.c (gdbpy_initialize_inferior): Return 'int'.
Check errors.
* python/py-infthread.c (gdbpy_initialize_thread): Return 'int'.
Check errors.
* python/py-lazy-string.c (gdbpy_initialize_lazy_string): Return 'int'.
Check errors.
* python/py-objfile.c (gdbpy_initialize_objfile): Return 'int'.
Check errors.
* python/py-param.c (gdbpy_initialize_parameters): Return 'int'.
Check errors.
* python/py-progspace.c (gdbpy_initialize_pspace): Return 'int'.
Check errors.
* python/py-symbol.c (gdbpy_initialize_symbols): Return 'int'.
Check errors.
* python/py-symtab.c (gdbpy_initialize_symtabs): Return 'int'.
Check errors.
* python/py-type.c (gdbpy_initialize_types): Return 'int'.
Check errors.
* python/py-value.c (gdbpy_initialize_values): Return 'int'.
Check errors.
* python/python-internal.h (gdbpy_initialize_auto_load,
gdbpy_initialize_values, gdbpy_initialize_frames,
gdbpy_initialize_symtabs, gdbpy_initialize_commands,
gdbpy_initialize_symbols, gdbpy_initialize_symtabs,
gdbpy_initialize_blocks, gdbpy_initialize_types,
gdbpy_initialize_functions, gdbpy_initialize_pspace,
gdbpy_initialize_objfile, gdbpy_initialize_breakpoints,
gdbpy_initialize_finishbreakpoints,
gdbpy_initialize_lazy_string, gdbpy_initialize_parameters,
gdbpy_initialize_thread, gdbpy_initialize_inferior,
gdbpy_initialize_eventregistry, gdbpy_initialize_event,
gdbpy_initialize_py_events, gdbpy_initialize_stop_event,
gdbpy_initialize_signal_event,
gdbpy_initialize_breakpoint_event,
gdbpy_initialize_continue_event,
gdbpy_initialize_exited_event, gdbpy_initialize_thread_event,
gdbpy_initialize_new_objfile_event, gdbpy_initialize_arch):
Update. Use CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION.
* python/python.c (gdb_python_initialized): New global.
(gdbpy_initialize_events): Return 'int'. Check errors.
(_initialize_python): Check errors. Set
gdb_python_initialized.
2013-05-20 20:28:52 +00:00
|
|
|
|
return -1;
|
2010-04-29 15:45:57 +00:00
|
|
|
|
|
|
|
|
|
for (i = 0; parm_constants[i].name; ++i)
|
|
|
|
|
{
|
|
|
|
|
if (PyModule_AddIntConstant (gdb_module,
|
|
|
|
|
parm_constants[i].name,
|
|
|
|
|
parm_constants[i].value) < 0)
|
* python/py-arch.c (gdbpy_initialize_arch): Return 'int'.
Check errors.
* python/py-auto-load.c (gdbpy_initialize_auto_load): Return 'int'.
* python/py-block.c (gdbpy_initialize_blocks): Return 'int'.
Check errors.
* python/py-breakpoint.c (gdbpy_initialize_breakpoints): Return 'int'.
Check errors.
* python/py-cmd.c (gdbpy_initialize_commands): Return 'int'.
Check errors.
* python/py-event.c (gdbpy_initialize_event): Return 'int'.
Check errors.
* python/py-event.h (GDBPY_NEW_EVENT_TYPE): Change generated
init function to return 'int'.
* python/py-evtregistry.c (gdbpy_initialize_eventregistry):
Return 'int'. Check errors.
* python/py-evts.c (gdbpy_initialize_py_events): Return 'int'.
Check errors.
* python/py-finishbreakpoint.c (gdbpy_initialize_finishbreakpoints):
Return 'int'. Check errors.
* python/py-frame.c (gdbpy_initialize_frames): Return 'int'.
Check errors.
* python/py-function.c (gdbpy_initialize_functions): Return 'int'.
Check errors.
* python/py-gdb-readline.c (gdbpy_initialize_gdb_readline):
Check errors.
* python/py-inferior.c (gdbpy_initialize_inferior): Return 'int'.
Check errors.
* python/py-infthread.c (gdbpy_initialize_thread): Return 'int'.
Check errors.
* python/py-lazy-string.c (gdbpy_initialize_lazy_string): Return 'int'.
Check errors.
* python/py-objfile.c (gdbpy_initialize_objfile): Return 'int'.
Check errors.
* python/py-param.c (gdbpy_initialize_parameters): Return 'int'.
Check errors.
* python/py-progspace.c (gdbpy_initialize_pspace): Return 'int'.
Check errors.
* python/py-symbol.c (gdbpy_initialize_symbols): Return 'int'.
Check errors.
* python/py-symtab.c (gdbpy_initialize_symtabs): Return 'int'.
Check errors.
* python/py-type.c (gdbpy_initialize_types): Return 'int'.
Check errors.
* python/py-value.c (gdbpy_initialize_values): Return 'int'.
Check errors.
* python/python-internal.h (gdbpy_initialize_auto_load,
gdbpy_initialize_values, gdbpy_initialize_frames,
gdbpy_initialize_symtabs, gdbpy_initialize_commands,
gdbpy_initialize_symbols, gdbpy_initialize_symtabs,
gdbpy_initialize_blocks, gdbpy_initialize_types,
gdbpy_initialize_functions, gdbpy_initialize_pspace,
gdbpy_initialize_objfile, gdbpy_initialize_breakpoints,
gdbpy_initialize_finishbreakpoints,
gdbpy_initialize_lazy_string, gdbpy_initialize_parameters,
gdbpy_initialize_thread, gdbpy_initialize_inferior,
gdbpy_initialize_eventregistry, gdbpy_initialize_event,
gdbpy_initialize_py_events, gdbpy_initialize_stop_event,
gdbpy_initialize_signal_event,
gdbpy_initialize_breakpoint_event,
gdbpy_initialize_continue_event,
gdbpy_initialize_exited_event, gdbpy_initialize_thread_event,
gdbpy_initialize_new_objfile_event, gdbpy_initialize_arch):
Update. Use CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION.
* python/python.c (gdb_python_initialized): New global.
(gdbpy_initialize_events): Return 'int'. Check errors.
(_initialize_python): Check errors. Set
gdb_python_initialized.
2013-05-20 20:28:52 +00:00
|
|
|
|
return -1;
|
2010-04-29 15:45:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-05-20 20:36:19 +00:00
|
|
|
|
return gdb_pymodule_addobject (gdb_module, "Parameter",
|
|
|
|
|
(PyObject *) &parmpy_object_type);
|
2010-04-29 15:45:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Fix redefinition errors in C++ mode
In C, we can forward declare static structure instances. That doesn't
work in C++ though. C++ treats these as definitions. So then the
compiler complains about symbol redefinition, like:
src/gdb/elfread.c:1569:29: error: redefinition of ‘const sym_fns elf_sym_fns_lazy_psyms’
src/gdb/elfread.c:53:29: error: ‘const sym_fns elf_sym_fns_lazy_psyms’ previously declared here
The intent of static here is naturally to avoid making these objects
visible outside the compilation unit. The equivalent in C++ would be
to instead define the objects in the anonymous namespace. But given
that it's desirable to leave the codebase compiling as both C and C++
for a while, this just makes the objects extern.
(base_breakpoint_ops is already declared in breakpoint.h, so we can
just remove the forward declare from breakpoint.c)
gdb/ChangeLog:
2015-02-11 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
* breakpoint.c (base_breakpoint_ops): Delete.
* dwarf2loc.c (dwarf_expr_ctx_funcs): Make extern.
* elfread.c (elf_sym_fns_gdb_index, elf_sym_fns_lazy_psyms): Make extern.
* guile/guile.c (guile_extension_script_ops, guile_extension_ops): Make extern.
* ppcnbsd-tdep.c (ppcnbsd2_sigtramp): Make extern.
* python/py-arch.c (arch_object_type): Make extern.
* python/py-block.c (block_syms_iterator_object_type): Make extern.
* python/py-bpevent.c (breakpoint_event_object_type): Make extern.
* python/py-cmd.c (cmdpy_object_type): Make extern.
* python/py-continueevent.c (continue_event_object_type)
* python/py-event.h (GDBPY_NEW_EVENT_TYPE): Remove 'qual'
parameter. Update all callers.
* python/py-evtregistry.c (eventregistry_object_type): Make extern.
* python/py-exitedevent.c (exited_event_object_type): Make extern.
* python/py-finishbreakpoint.c (finish_breakpoint_object_type): Make extern.
* python/py-function.c (fnpy_object_type): Make extern.
* python/py-inferior.c (inferior_object_type, membuf_object_type): Make extern.
* python/py-infevents.c (call_pre_event_object_type)
(inferior_call_post_event_object_type).
(memory_changed_event_object_type): Make extern.
* python/py-infthread.c (thread_object_type): Make extern.
* python/py-lazy-string.c (lazy_string_object_type): Make extern.
* python/py-linetable.c (linetable_entry_object_type)
(linetable_object_type, ltpy_iterator_object_type): Make extern.
* python/py-newobjfileevent.c (new_objfile_event_object_type)
(clear_objfiles_event_object_type): Make extern.
* python/py-objfile.c (objfile_object_type): Make extern.
* python/py-param.c (parmpy_object_type): Make extern.
* python/py-progspace.c (pspace_object_type): Make extern.
* python/py-signalevent.c (signal_event_object_type): Make extern.
* python/py-symtab.c (symtab_object_type, sal_object_type): Make extern.
* python/py-type.c (type_object_type, field_object_type)
(type_iterator_object_type): Make extern.
* python/python.c (python_extension_script_ops)
(python_extension_ops): Make extern.
* stap-probe.c (stap_probe_ops): Make extern.
2015-02-11 11:20:21 +00:00
|
|
|
|
PyTypeObject parmpy_object_type =
|
2010-04-29 15:45:57 +00:00
|
|
|
|
{
|
2012-12-12 16:47:30 +00:00
|
|
|
|
PyVarObject_HEAD_INIT (NULL, 0)
|
2010-04-29 15:45:57 +00:00
|
|
|
|
"gdb.Parameter", /*tp_name*/
|
|
|
|
|
sizeof (parmpy_object), /*tp_basicsize*/
|
|
|
|
|
0, /*tp_itemsize*/
|
|
|
|
|
0, /*tp_dealloc*/
|
|
|
|
|
0, /*tp_print*/
|
|
|
|
|
0, /*tp_getattr*/
|
|
|
|
|
0, /*tp_setattr*/
|
|
|
|
|
0, /*tp_compare*/
|
|
|
|
|
0, /*tp_repr*/
|
|
|
|
|
0, /*tp_as_number*/
|
|
|
|
|
0, /*tp_as_sequence*/
|
|
|
|
|
0, /*tp_as_mapping*/
|
|
|
|
|
0, /*tp_hash */
|
|
|
|
|
0, /*tp_call*/
|
|
|
|
|
0, /*tp_str*/
|
|
|
|
|
get_attr, /*tp_getattro*/
|
|
|
|
|
set_attr, /*tp_setattro*/
|
|
|
|
|
0, /*tp_as_buffer*/
|
|
|
|
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
|
|
|
|
|
"GDB parameter object", /* tp_doc */
|
|
|
|
|
0, /* tp_traverse */
|
|
|
|
|
0, /* tp_clear */
|
|
|
|
|
0, /* tp_richcompare */
|
|
|
|
|
0, /* tp_weaklistoffset */
|
|
|
|
|
0, /* tp_iter */
|
|
|
|
|
0, /* tp_iternext */
|
|
|
|
|
0, /* tp_methods */
|
|
|
|
|
0, /* tp_members */
|
|
|
|
|
0, /* tp_getset */
|
|
|
|
|
0, /* tp_base */
|
|
|
|
|
0, /* tp_dict */
|
|
|
|
|
0, /* tp_descr_get */
|
|
|
|
|
0, /* tp_descr_set */
|
|
|
|
|
0, /* tp_dictoffset */
|
|
|
|
|
parmpy_init, /* tp_init */
|
|
|
|
|
0, /* tp_alloc */
|
|
|
|
|
};
|