From 7c543f7b07678f69f22772bd2780602be67731d7 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Fri, 9 Oct 2015 10:08:23 -0400 Subject: Change some void* to gdb_byte* There are a bunch of places where a void* is implicitely casted into a gdb_byte*. The auto-insert-casts script added explicit casts at those places. However, in many cases, it makes more sense to just change the void* to a gdb_byte*. gdb/ChangeLog: * aarch64-tdep.c (stack_item_t): Change type of data to gdb_byte*. * arm-tdep.c (struct stack_item): Likewise. (push_stack_item): Add gdb_byte* cast. * avr-tdep.c (struct stack_item): Change type of data to gdb_byte*. (push_stack_item): Add gdb_byte* cast. * cli/cli-dump.c (dump_memory_to_file): Change type of buf to gdb_byte* and add cast. * cris-tdep.c (struct stack_item): Change type of data to gdb_byte*. (push_stack_item): Add gdb_byte* cast. * gcore.c (gcore_copy_callback): Change type of memhunk to gdb_byte* and add cast. * gdbtypes.h (print_scalar_formatted): Change type of first parameter to gdb_byte*. * h8300-tdep.c (h8300_extract_return_value): Change type of valbuf to gdb_byte* and remove unnecessary cast. (h8300h_extract_return_value): Likewise. (h8300_store_return_value): Change type of valbuf to gdb_byte*. (h8300h_store_return_value): Likewise. * iq2000-tdep.c (iq2000_extract_return_value): Change type of valbuf to gdb_byte* and remove unnecessary cast. * jit.c (jit_reader_try_read_symtab): Change type of gdb_mem to gdb_byte* and add cast. * m32r-tdep.c (m32r_store_return_value): Change type of valbuf to gdb_byte* and remove unnecessary cast. (m32r_extract_return_value): Change type of dst to gdb_byte* and remove valbuf. * mep-tdep.c (mep_pseudo_cr32_read): Change type of buf to gdb_byte*. (mep_pseudo_cr64_read): Likewise. (mep_pseudo_csr_write): Likewise. (mep_pseudo_cr32_write): Likewise. (mep_pseudo_cr64_write): Likewise. * mi/mi-main.c (mi_cmd_data_write_memory): Change type of buffer to gdb_byte* and add cast. * moxie-tdep.c (moxie_store_return_value): Change type of valbuf to gdb_byte* and remove unnecessary cast. (moxie_extract_return_value): Change type of dst to gdb_byte* and remove valbuf. * p-valprint.c (print_scalar_formatted): Change type of valaddr to gdb_byte*. * printcmd.c (void): Likewise. * python/py-inferior.c (infpy_read_memory): Change type of buffer to gdb_byte* and add cast. (infpy_write_memory): Likewise. (infpy_search_memory): Likewise. * regcache.c (regcache_raw_write_signed): Change type of buf to gdb_byte* and add cast. (regcache_raw_write_unsigned): Likewise. (regcache_cooked_write_signed): Likewise. (regcache_cooked_write_unsigned): Likewise. * sh64-tdep.c (h64_extract_return_value): Change type of valbuf to gdb_byte*. --- gdb/python/py-inferior.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'gdb/python') diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c index dbc197e..c506ccd 100644 --- a/gdb/python/py-inferior.c +++ b/gdb/python/py-inferior.c @@ -505,7 +505,7 @@ static PyObject * infpy_read_memory (PyObject *self, PyObject *args, PyObject *kw) { CORE_ADDR addr, length; - void *buffer = NULL; + gdb_byte *buffer = NULL; membuf_object *membuf_obj; PyObject *addr_obj, *length_obj, *result; static char *keywords[] = { "address", "length", NULL }; @@ -520,7 +520,7 @@ infpy_read_memory (PyObject *self, PyObject *args, PyObject *kw) TRY { - buffer = xmalloc (length); + buffer = (gdb_byte *) xmalloc (length); read_memory (addr, buffer, length); } @@ -564,7 +564,7 @@ infpy_write_memory (PyObject *self, PyObject *args, PyObject *kw) { struct gdb_exception except = exception_none; Py_ssize_t buf_len; - const char *buffer; + const gdb_byte *buffer; CORE_ADDR addr, length; PyObject *addr_obj, *length_obj = NULL; static char *keywords[] = { "address", "buffer", "length", NULL }; @@ -576,13 +576,17 @@ infpy_write_memory (PyObject *self, PyObject *args, PyObject *kw) &length_obj)) return NULL; - buffer = pybuf.buf; + buffer = (const gdb_byte *) pybuf.buf; buf_len = pybuf.len; #else + const void *vbuffer; + if (! PyArg_ParseTupleAndKeywords (args, kw, "Os#|O", keywords, &addr_obj, &buffer, &buf_len, &length_obj)) return NULL; + + buffer = (const gdb_byte *) buffer; #endif if (get_addr_from_python (addr_obj, &addr) < 0) @@ -595,7 +599,7 @@ infpy_write_memory (PyObject *self, PyObject *args, PyObject *kw) TRY { - write_memory_with_notification (addr, (gdb_byte *) buffer, length); + write_memory_with_notification (addr, buffer, length); } CATCH (ex, RETURN_MASK_ALL) { @@ -717,7 +721,7 @@ infpy_search_memory (PyObject *self, PyObject *args, PyObject *kw) static char *keywords[] = { "address", "length", "pattern", NULL }; PyObject *start_addr_obj, *length_obj; Py_ssize_t pattern_size; - const void *buffer; + const gdb_byte *buffer; CORE_ADDR found_addr; int found = 0; #ifdef IS_PY3K @@ -728,10 +732,11 @@ infpy_search_memory (PyObject *self, PyObject *args, PyObject *kw) &pybuf)) return NULL; - buffer = pybuf.buf; + buffer = (const gdb_byte *) pybuf.buf; pattern_size = pybuf.len; #else PyObject *pattern; + const void *vbuffer; if (! PyArg_ParseTupleAndKeywords (args, kw, "OOO", keywords, &start_addr_obj, &length_obj, @@ -746,8 +751,10 @@ infpy_search_memory (PyObject *self, PyObject *args, PyObject *kw) return NULL; } - if (PyObject_AsReadBuffer (pattern, &buffer, &pattern_size) == -1) + if (PyObject_AsReadBuffer (pattern, &vbuffer, &pattern_size) == -1) return NULL; + + buffer = (const gdb_byte *) vbuffer; #endif if (get_addr_from_python (start_addr_obj, &start_addr) < 0) -- cgit v1.1