-Wwrite-strings: Add a PyArg_ParseTupleAndKeywords "const char *" overload
-Wwrite-strings flags code like: static char *keywords[] = {"command", "from_tty", "to_string", NULL }; as needing "(char *)" casts, because string literals are "const char []". We can get rid of the casts by changing the array type like this: - static char *keywords[] = {"command", "from_tty", "to_string", NULL }; + static const char *keywords[] = {"command", "from_tty", "to_string", NULL }; However, passing the such array to PyArg_ParseTupleAndKeywords no longer works OOTB, because PyArg_ParseTupleAndKeywords expects a "char **": PyArg_ParseTupleAndKeywords(PyObject *args, PyObject *kw, const char *format, char *keywords[], ...); and "const char **" is not implicitly convertible to "char **". C++ is more tolerant that C here WRT aliasing, and a const_cast<char **> is fine. However, to avoid having all callers do the cast themselves, this commit defines a gdb_PyArg_ParseTupleAndKeywords function here with a corresponding 'keywords' parameter type that does the cast in a single place. gdb/ChangeLog: 2017-04-05 Pedro Alves <palves@redhat.com> * python/python-internal.h (gdb_PyArg_ParseTupleAndKeywords): New static inline function. * python/py-arch.c (archpy_disassemble): Constify 'keywords' array and use gdb_PyArg_ParseTupleAndKeywords. * python/py-cmd.c (cmdpy_init): Likewise. * python/py-finishbreakpoint.c (bpfinishpy_init): Likewise. * python/py-inferior.c (infpy_read_memory, infpy_write_memory) (infpy_search_memory): Likewise. * python/py-objfile.c (objfpy_add_separate_debug_file) (gdbpy_lookup_objfile): Likewise. * python/py-symbol.c (gdbpy_lookup_symbol) (gdbpy_lookup_global_symbol): Likewise. * python/py-type.c (gdbpy_lookup_type): Likewise. * python/py-value.c (valpy_lazy_string, valpy_string): Likewise. * python/python.c (execute_gdb_command, gdbpy_write, gdbpy_flush): Likewise.
This commit is contained in:
parent
0d1f4ceb39
commit
2adadf5170
12 changed files with 111 additions and 63 deletions
|
@ -1,3 +1,22 @@
|
||||||
|
2017-04-05 Pedro Alves <palves@redhat.com>
|
||||||
|
|
||||||
|
* python/python-internal.h (gdb_PyArg_ParseTupleAndKeywords): New
|
||||||
|
static inline function.
|
||||||
|
* python/py-arch.c (archpy_disassemble): Constify 'keywords'
|
||||||
|
array and use gdb_PyArg_ParseTupleAndKeywords.
|
||||||
|
* python/py-cmd.c (cmdpy_init): Likewise.
|
||||||
|
* python/py-finishbreakpoint.c (bpfinishpy_init): Likewise.
|
||||||
|
* python/py-inferior.c (infpy_read_memory, infpy_write_memory)
|
||||||
|
(infpy_search_memory): Likewise.
|
||||||
|
* python/py-objfile.c (objfpy_add_separate_debug_file)
|
||||||
|
(gdbpy_lookup_objfile): Likewise.
|
||||||
|
* python/py-symbol.c (gdbpy_lookup_symbol)
|
||||||
|
(gdbpy_lookup_global_symbol): Likewise.
|
||||||
|
* python/py-type.c (gdbpy_lookup_type): Likewise.
|
||||||
|
* python/py-value.c (valpy_lazy_string, valpy_string): Likewise.
|
||||||
|
* python/python.c (execute_gdb_command, gdbpy_write, gdbpy_flush):
|
||||||
|
Likewise.
|
||||||
|
|
||||||
2017-04-05 Pedro Alves <palves@redhat.com>
|
2017-04-05 Pedro Alves <palves@redhat.com>
|
||||||
|
|
||||||
* python/python-internal.h (gdb_PyGetSetDef): New type.
|
* python/python-internal.h (gdb_PyGetSetDef): New type.
|
||||||
|
|
|
@ -116,7 +116,7 @@ archpy_name (PyObject *self, PyObject *args)
|
||||||
static PyObject *
|
static PyObject *
|
||||||
archpy_disassemble (PyObject *self, PyObject *args, PyObject *kw)
|
archpy_disassemble (PyObject *self, PyObject *args, PyObject *kw)
|
||||||
{
|
{
|
||||||
static char *keywords[] = { "start_pc", "end_pc", "count", NULL };
|
static const char *keywords[] = { "start_pc", "end_pc", "count", NULL };
|
||||||
CORE_ADDR start, end = 0;
|
CORE_ADDR start, end = 0;
|
||||||
CORE_ADDR pc;
|
CORE_ADDR pc;
|
||||||
gdb_py_ulongest start_temp;
|
gdb_py_ulongest start_temp;
|
||||||
|
@ -126,8 +126,9 @@ archpy_disassemble (PyObject *self, PyObject *args, PyObject *kw)
|
||||||
|
|
||||||
ARCHPY_REQUIRE_VALID (self, gdbarch);
|
ARCHPY_REQUIRE_VALID (self, gdbarch);
|
||||||
|
|
||||||
if (!PyArg_ParseTupleAndKeywords (args, kw, GDB_PY_LLU_ARG "|OO", keywords,
|
if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, GDB_PY_LLU_ARG "|OO",
|
||||||
&start_temp, &end_obj, &count_obj))
|
keywords, &start_temp, &end_obj,
|
||||||
|
&count_obj))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
start = start_temp;
|
start = start_temp;
|
||||||
|
|
|
@ -637,8 +637,8 @@ bppy_get_ignore_count (PyObject *self, void *closure)
|
||||||
static int
|
static int
|
||||||
bppy_init (PyObject *self, PyObject *args, PyObject *kwargs)
|
bppy_init (PyObject *self, PyObject *args, PyObject *kwargs)
|
||||||
{
|
{
|
||||||
static char *keywords[] = { "spec", "type", "wp_class", "internal",
|
static const char *keywords[] = { "spec", "type", "wp_class", "internal",
|
||||||
"temporary", NULL };
|
"temporary", NULL };
|
||||||
const char *spec;
|
const char *spec;
|
||||||
int type = bp_breakpoint;
|
int type = bp_breakpoint;
|
||||||
int access_type = hw_write;
|
int access_type = hw_write;
|
||||||
|
@ -647,9 +647,9 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs)
|
||||||
int internal_bp = 0;
|
int internal_bp = 0;
|
||||||
int temporary_bp = 0;
|
int temporary_bp = 0;
|
||||||
|
|
||||||
if (! PyArg_ParseTupleAndKeywords (args, kwargs, "s|iiOO", keywords,
|
if (!gdb_PyArg_ParseTupleAndKeywords (args, kwargs, "s|iiOO", keywords,
|
||||||
&spec, &type, &access_type,
|
&spec, &type, &access_type,
|
||||||
&internal, &temporary))
|
&internal, &temporary))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (internal)
|
if (internal)
|
||||||
|
|
|
@ -490,8 +490,8 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kw)
|
||||||
char *docstring = NULL;
|
char *docstring = NULL;
|
||||||
struct cmd_list_element **cmd_list;
|
struct cmd_list_element **cmd_list;
|
||||||
char *cmd_name, *pfx_name;
|
char *cmd_name, *pfx_name;
|
||||||
static char *keywords[] = { "name", "command_class", "completer_class",
|
static const char *keywords[] = { "name", "command_class", "completer_class",
|
||||||
"prefix", NULL };
|
"prefix", NULL };
|
||||||
PyObject *is_prefix = NULL;
|
PyObject *is_prefix = NULL;
|
||||||
int cmp;
|
int cmp;
|
||||||
|
|
||||||
|
@ -504,9 +504,9 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kw)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! PyArg_ParseTupleAndKeywords (args, kw, "si|iO",
|
if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "si|iO",
|
||||||
keywords, &name, &cmdtype,
|
keywords, &name, &cmdtype,
|
||||||
&completetype, &is_prefix))
|
&completetype, &is_prefix))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (cmdtype != no_class && cmdtype != class_run
|
if (cmdtype != no_class && cmdtype != class_run
|
||||||
|
|
|
@ -156,7 +156,7 @@ bpfinishpy_post_stop_hook (struct gdbpy_breakpoint_object *bp_obj)
|
||||||
static int
|
static int
|
||||||
bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs)
|
bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs)
|
||||||
{
|
{
|
||||||
static char *keywords[] = { "frame", "internal", NULL };
|
static const char *keywords[] = { "frame", "internal", NULL };
|
||||||
struct finish_breakpoint_object *self_bpfinish =
|
struct finish_breakpoint_object *self_bpfinish =
|
||||||
(struct finish_breakpoint_object *) self;
|
(struct finish_breakpoint_object *) self;
|
||||||
PyObject *frame_obj = NULL;
|
PyObject *frame_obj = NULL;
|
||||||
|
@ -169,8 +169,8 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs)
|
||||||
CORE_ADDR pc;
|
CORE_ADDR pc;
|
||||||
struct symbol *function;
|
struct symbol *function;
|
||||||
|
|
||||||
if (!PyArg_ParseTupleAndKeywords (args, kwargs, "|OO", keywords,
|
if (!gdb_PyArg_ParseTupleAndKeywords (args, kwargs, "|OO", keywords,
|
||||||
&frame_obj, &internal))
|
&frame_obj, &internal))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
TRY
|
TRY
|
||||||
|
|
|
@ -435,10 +435,10 @@ infpy_read_memory (PyObject *self, PyObject *args, PyObject *kw)
|
||||||
CORE_ADDR addr, length;
|
CORE_ADDR addr, length;
|
||||||
gdb_byte *buffer = NULL;
|
gdb_byte *buffer = NULL;
|
||||||
PyObject *addr_obj, *length_obj, *result;
|
PyObject *addr_obj, *length_obj, *result;
|
||||||
static char *keywords[] = { "address", "length", NULL };
|
static const char *keywords[] = { "address", "length", NULL };
|
||||||
|
|
||||||
if (! PyArg_ParseTupleAndKeywords (args, kw, "OO", keywords,
|
if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "OO", keywords,
|
||||||
&addr_obj, &length_obj))
|
&addr_obj, &length_obj))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (get_addr_from_python (addr_obj, &addr) < 0
|
if (get_addr_from_python (addr_obj, &addr) < 0
|
||||||
|
@ -494,21 +494,20 @@ infpy_write_memory (PyObject *self, PyObject *args, PyObject *kw)
|
||||||
const gdb_byte *buffer;
|
const gdb_byte *buffer;
|
||||||
CORE_ADDR addr, length;
|
CORE_ADDR addr, length;
|
||||||
PyObject *addr_obj, *length_obj = NULL;
|
PyObject *addr_obj, *length_obj = NULL;
|
||||||
static char *keywords[] = { "address", "buffer", "length", NULL };
|
static const char *keywords[] = { "address", "buffer", "length", NULL };
|
||||||
#ifdef IS_PY3K
|
#ifdef IS_PY3K
|
||||||
Py_buffer pybuf;
|
Py_buffer pybuf;
|
||||||
|
|
||||||
if (! PyArg_ParseTupleAndKeywords (args, kw, "Os*|O", keywords,
|
if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "Os*|O", keywords,
|
||||||
&addr_obj, &pybuf,
|
&addr_obj, &pybuf, &length_obj))
|
||||||
&length_obj))
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
buffer = (const gdb_byte *) pybuf.buf;
|
buffer = (const gdb_byte *) pybuf.buf;
|
||||||
buf_len = pybuf.len;
|
buf_len = pybuf.len;
|
||||||
#else
|
#else
|
||||||
if (! PyArg_ParseTupleAndKeywords (args, kw, "Os#|O", keywords,
|
if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "Os#|O", keywords,
|
||||||
&addr_obj, &buffer, &buf_len,
|
&addr_obj, &buffer, &buf_len,
|
||||||
&length_obj))
|
&length_obj))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
buffer = (const gdb_byte *) buffer;
|
buffer = (const gdb_byte *) buffer;
|
||||||
|
@ -643,7 +642,7 @@ infpy_search_memory (PyObject *self, PyObject *args, PyObject *kw)
|
||||||
{
|
{
|
||||||
struct gdb_exception except = exception_none;
|
struct gdb_exception except = exception_none;
|
||||||
CORE_ADDR start_addr, length;
|
CORE_ADDR start_addr, length;
|
||||||
static char *keywords[] = { "address", "length", "pattern", NULL };
|
static const char *keywords[] = { "address", "length", "pattern", NULL };
|
||||||
PyObject *start_addr_obj, *length_obj;
|
PyObject *start_addr_obj, *length_obj;
|
||||||
Py_ssize_t pattern_size;
|
Py_ssize_t pattern_size;
|
||||||
const gdb_byte *buffer;
|
const gdb_byte *buffer;
|
||||||
|
@ -652,9 +651,9 @@ infpy_search_memory (PyObject *self, PyObject *args, PyObject *kw)
|
||||||
#ifdef IS_PY3K
|
#ifdef IS_PY3K
|
||||||
Py_buffer pybuf;
|
Py_buffer pybuf;
|
||||||
|
|
||||||
if (! PyArg_ParseTupleAndKeywords (args, kw, "OOs*", keywords,
|
if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "OOs*", keywords,
|
||||||
&start_addr_obj, &length_obj,
|
&start_addr_obj, &length_obj,
|
||||||
&pybuf))
|
&pybuf))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
buffer = (const gdb_byte *) pybuf.buf;
|
buffer = (const gdb_byte *) pybuf.buf;
|
||||||
|
@ -663,9 +662,9 @@ infpy_search_memory (PyObject *self, PyObject *args, PyObject *kw)
|
||||||
PyObject *pattern;
|
PyObject *pattern;
|
||||||
const void *vbuffer;
|
const void *vbuffer;
|
||||||
|
|
||||||
if (! PyArg_ParseTupleAndKeywords (args, kw, "OOO", keywords,
|
if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "OOO", keywords,
|
||||||
&start_addr_obj, &length_obj,
|
&start_addr_obj, &length_obj,
|
||||||
&pattern))
|
&pattern))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!PyObject_CheckReadBuffer (pattern))
|
if (!PyObject_CheckReadBuffer (pattern))
|
||||||
|
|
|
@ -432,13 +432,13 @@ objfpy_is_valid (PyObject *self, PyObject *args)
|
||||||
static PyObject *
|
static PyObject *
|
||||||
objfpy_add_separate_debug_file (PyObject *self, PyObject *args, PyObject *kw)
|
objfpy_add_separate_debug_file (PyObject *self, PyObject *args, PyObject *kw)
|
||||||
{
|
{
|
||||||
static char *keywords[] = { "file_name", NULL };
|
static const char *keywords[] = { "file_name", NULL };
|
||||||
objfile_object *obj = (objfile_object *) self;
|
objfile_object *obj = (objfile_object *) self;
|
||||||
const char *file_name;
|
const char *file_name;
|
||||||
|
|
||||||
OBJFPY_REQUIRE_VALID (obj);
|
OBJFPY_REQUIRE_VALID (obj);
|
||||||
|
|
||||||
if (!PyArg_ParseTupleAndKeywords (args, kw, "s", keywords, &file_name))
|
if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "s", keywords, &file_name))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
TRY
|
TRY
|
||||||
|
@ -559,14 +559,14 @@ objfpy_lookup_objfile_by_build_id (const char *build_id)
|
||||||
PyObject *
|
PyObject *
|
||||||
gdbpy_lookup_objfile (PyObject *self, PyObject *args, PyObject *kw)
|
gdbpy_lookup_objfile (PyObject *self, PyObject *args, PyObject *kw)
|
||||||
{
|
{
|
||||||
static char *keywords[] = { "name", "by_build_id", NULL };
|
static const char *keywords[] = { "name", "by_build_id", NULL };
|
||||||
const char *name;
|
const char *name;
|
||||||
PyObject *by_build_id_obj = NULL;
|
PyObject *by_build_id_obj = NULL;
|
||||||
int by_build_id;
|
int by_build_id;
|
||||||
struct objfile *objfile;
|
struct objfile *objfile;
|
||||||
|
|
||||||
if (! PyArg_ParseTupleAndKeywords (args, kw, "s|O!", keywords,
|
if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "s|O!", keywords,
|
||||||
&name, &PyBool_Type, &by_build_id_obj))
|
&name, &PyBool_Type, &by_build_id_obj))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
by_build_id = 0;
|
by_build_id = 0;
|
||||||
|
|
|
@ -373,13 +373,14 @@ gdbpy_lookup_symbol (PyObject *self, PyObject *args, PyObject *kw)
|
||||||
int domain = VAR_DOMAIN;
|
int domain = VAR_DOMAIN;
|
||||||
struct field_of_this_result is_a_field_of_this;
|
struct field_of_this_result is_a_field_of_this;
|
||||||
const char *name;
|
const char *name;
|
||||||
static char *keywords[] = { "name", "block", "domain", NULL };
|
static const char *keywords[] = { "name", "block", "domain", NULL };
|
||||||
struct symbol *symbol = NULL;
|
struct symbol *symbol = NULL;
|
||||||
PyObject *block_obj = NULL, *sym_obj, *bool_obj;
|
PyObject *block_obj = NULL, *sym_obj, *bool_obj;
|
||||||
const struct block *block = NULL;
|
const struct block *block = NULL;
|
||||||
|
|
||||||
if (! PyArg_ParseTupleAndKeywords (args, kw, "s|O!i", keywords, &name,
|
if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "s|O!i", keywords, &name,
|
||||||
&block_object_type, &block_obj, &domain))
|
&block_object_type, &block_obj,
|
||||||
|
&domain))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (block_obj)
|
if (block_obj)
|
||||||
|
@ -443,12 +444,12 @@ gdbpy_lookup_global_symbol (PyObject *self, PyObject *args, PyObject *kw)
|
||||||
{
|
{
|
||||||
int domain = VAR_DOMAIN;
|
int domain = VAR_DOMAIN;
|
||||||
const char *name;
|
const char *name;
|
||||||
static char *keywords[] = { "name", "domain", NULL };
|
static const char *keywords[] = { "name", "domain", NULL };
|
||||||
struct symbol *symbol = NULL;
|
struct symbol *symbol = NULL;
|
||||||
PyObject *sym_obj;
|
PyObject *sym_obj;
|
||||||
|
|
||||||
if (! PyArg_ParseTupleAndKeywords (args, kw, "s|i", keywords, &name,
|
if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "s|i", keywords, &name,
|
||||||
&domain))
|
&domain))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
TRY
|
TRY
|
||||||
|
|
|
@ -1347,14 +1347,14 @@ type_object_to_type (PyObject *obj)
|
||||||
PyObject *
|
PyObject *
|
||||||
gdbpy_lookup_type (PyObject *self, PyObject *args, PyObject *kw)
|
gdbpy_lookup_type (PyObject *self, PyObject *args, PyObject *kw)
|
||||||
{
|
{
|
||||||
static char *keywords[] = { "name", "block", NULL };
|
static const char *keywords[] = { "name", "block", NULL };
|
||||||
const char *type_name = NULL;
|
const char *type_name = NULL;
|
||||||
struct type *type = NULL;
|
struct type *type = NULL;
|
||||||
PyObject *block_obj = NULL;
|
PyObject *block_obj = NULL;
|
||||||
const struct block *block = NULL;
|
const struct block *block = NULL;
|
||||||
|
|
||||||
if (! PyArg_ParseTupleAndKeywords (args, kw, "s|O", keywords,
|
if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "s|O", keywords,
|
||||||
&type_name, &block_obj))
|
&type_name, &block_obj))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (block_obj)
|
if (block_obj)
|
||||||
|
|
|
@ -431,11 +431,11 @@ valpy_lazy_string (PyObject *self, PyObject *args, PyObject *kw)
|
||||||
gdb_py_longest length = -1;
|
gdb_py_longest length = -1;
|
||||||
struct value *value = ((value_object *) self)->value;
|
struct value *value = ((value_object *) self)->value;
|
||||||
const char *user_encoding = NULL;
|
const char *user_encoding = NULL;
|
||||||
static char *keywords[] = { "encoding", "length", NULL };
|
static const char *keywords[] = { "encoding", "length", NULL };
|
||||||
PyObject *str_obj = NULL;
|
PyObject *str_obj = NULL;
|
||||||
|
|
||||||
if (!PyArg_ParseTupleAndKeywords (args, kw, "|s" GDB_PY_LL_ARG, keywords,
|
if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "|s" GDB_PY_LL_ARG,
|
||||||
&user_encoding, &length))
|
keywords, &user_encoding, &length))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (length < -1)
|
if (length < -1)
|
||||||
|
@ -526,10 +526,10 @@ valpy_string (PyObject *self, PyObject *args, PyObject *kw)
|
||||||
const char *user_encoding = NULL;
|
const char *user_encoding = NULL;
|
||||||
const char *la_encoding = NULL;
|
const char *la_encoding = NULL;
|
||||||
struct type *char_type;
|
struct type *char_type;
|
||||||
static char *keywords[] = { "encoding", "errors", "length", NULL };
|
static const char *keywords[] = { "encoding", "errors", "length", NULL };
|
||||||
|
|
||||||
if (!PyArg_ParseTupleAndKeywords (args, kw, "|ssi", keywords,
|
if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "|ssi", keywords,
|
||||||
&user_encoding, &errors, &length))
|
&user_encoding, &errors, &length))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
TRY
|
TRY
|
||||||
|
|
|
@ -316,6 +316,34 @@ struct gdb_PyGetSetDef : PyGetSetDef
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* The 'keywords' parameter of PyArg_ParseTupleAndKeywords has type
|
||||||
|
'char **'. However, string literals are const in C++, and so to
|
||||||
|
avoid casting at every keyword array definition, we'll need to make
|
||||||
|
the keywords array an array of 'const char *'. To avoid having all
|
||||||
|
callers add a 'const_cast<char **>' themselves when passing such an
|
||||||
|
array through 'char **', we define our own version of
|
||||||
|
PyArg_ParseTupleAndKeywords here with a corresponding 'keywords'
|
||||||
|
parameter type that does the cast in a single place. (This is not
|
||||||
|
an overload of PyArg_ParseTupleAndKeywords in order to make it
|
||||||
|
clearer that we're calling our own function instead of a function
|
||||||
|
that exists in some newer Python version.) */
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
gdb_PyArg_ParseTupleAndKeywords (PyObject *args, PyObject *kw,
|
||||||
|
const char *format, const char **keywords, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
int res;
|
||||||
|
|
||||||
|
va_start (ap, keywords);
|
||||||
|
res = PyArg_VaParseTupleAndKeywords (args, kw, format,
|
||||||
|
const_cast<char **> (keywords),
|
||||||
|
ap);
|
||||||
|
va_end (ap);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
/* 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. */
|
a real symtab_and_line structure is needed. */
|
||||||
#include "symtab.h"
|
#include "symtab.h"
|
||||||
|
|
|
@ -572,11 +572,11 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw)
|
||||||
const char *arg;
|
const char *arg;
|
||||||
PyObject *from_tty_obj = NULL, *to_string_obj = NULL;
|
PyObject *from_tty_obj = NULL, *to_string_obj = NULL;
|
||||||
int from_tty, to_string;
|
int from_tty, to_string;
|
||||||
static char *keywords[] = {"command", "from_tty", "to_string", NULL };
|
static const char *keywords[] = { "command", "from_tty", "to_string", NULL };
|
||||||
|
|
||||||
if (! PyArg_ParseTupleAndKeywords (args, kw, "s|O!O!", keywords, &arg,
|
if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "s|O!O!", keywords, &arg,
|
||||||
&PyBool_Type, &from_tty_obj,
|
&PyBool_Type, &from_tty_obj,
|
||||||
&PyBool_Type, &to_string_obj))
|
&PyBool_Type, &to_string_obj))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
from_tty = 0;
|
from_tty = 0;
|
||||||
|
@ -1047,11 +1047,11 @@ static PyObject *
|
||||||
gdbpy_write (PyObject *self, PyObject *args, PyObject *kw)
|
gdbpy_write (PyObject *self, PyObject *args, PyObject *kw)
|
||||||
{
|
{
|
||||||
const char *arg;
|
const char *arg;
|
||||||
static char *keywords[] = {"text", "stream", NULL };
|
static const char *keywords[] = { "text", "stream", NULL };
|
||||||
int stream_type = 0;
|
int stream_type = 0;
|
||||||
|
|
||||||
if (! PyArg_ParseTupleAndKeywords (args, kw, "s|i", keywords, &arg,
|
if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "s|i", keywords, &arg,
|
||||||
&stream_type))
|
&stream_type))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
TRY
|
TRY
|
||||||
|
@ -1088,11 +1088,11 @@ gdbpy_write (PyObject *self, PyObject *args, PyObject *kw)
|
||||||
static PyObject *
|
static PyObject *
|
||||||
gdbpy_flush (PyObject *self, PyObject *args, PyObject *kw)
|
gdbpy_flush (PyObject *self, PyObject *args, PyObject *kw)
|
||||||
{
|
{
|
||||||
static char *keywords[] = {"stream", NULL };
|
static const char *keywords[] = { "stream", NULL };
|
||||||
int stream_type = 0;
|
int stream_type = 0;
|
||||||
|
|
||||||
if (! PyArg_ParseTupleAndKeywords (args, kw, "|i", keywords,
|
if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "|i", keywords,
|
||||||
&stream_type))
|
&stream_type))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
switch (stream_type)
|
switch (stream_type)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue