diff options
author | Pedro Alves <palves@redhat.com> | 2009-08-14 00:32:33 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2009-08-14 00:32:33 +0000 |
commit | 759ef83693911e20efd389b20cbf8f3a8eec30eb (patch) | |
tree | 7e7de1542d7ae1e9bef5d8ca15956af47858f0d2 /gdb | |
parent | 4da0d875114aa6b8c919e2e36dc17ef3cab1dc69 (diff) | |
download | gdb-759ef83693911e20efd389b20cbf8f3a8eec30eb.zip gdb-759ef83693911e20efd389b20cbf8f3a8eec30eb.tar.gz gdb-759ef83693911e20efd389b20cbf8f3a8eec30eb.tar.bz2 |
* ui-file.h (ui_file_xstrdup): Mention that the length argument
may be NULL.
* ui-file.c (ui_file_xstrdup): Don't dereference LENGTH if it is
NULL.
* aix-thread.c (aix_thread_extra_thread_info): Pass NULL as length
parameter to ui_file_xstrdup.
* arm-tdep.c (_initialize_arm_tdep): Ditto.
* infrun.c (print_target_wait_results): Ditto.
* language.c (add_language): Ditto.
* linespec.c (cplusplus_error): Ditto.
* remote.c (escape_buffer): Ditto.
* typeprint.c (type_to_string): Ditto.
* utils.c (error_stream): Ditto.
* varobj.c (value_get_print_value): Ditto.
* xtensa-tdep.c (xtensa_verify_config): Replace `dummy' local with
`length' local. Pass it to ui_file_xstrdup, and avoid an strlen
call.
* gdbarch.sh (verify_gdbarch): Ditto.
* gdbarch.c: Regenerate.
* cli/cli-setshow.c (do_setshow_command): Pass NULL as length
parameter to ui_file_xstrdup.
* python/python-frame.c (frapy_str): Ditto.
* python/python-type.c (typy_str): Use the length local instead of
calling strlen.
* python/python-value.c (valpy_str): Pass NULL as length parameter
to ui_file_xstrdup.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 29 | ||||
-rw-r--r-- | gdb/aix-thread.c | 3 | ||||
-rw-r--r-- | gdb/arm-tdep.c | 2 | ||||
-rw-r--r-- | gdb/cli/cli-setshow.c | 3 | ||||
-rw-r--r-- | gdb/gdbarch.c | 6 | ||||
-rwxr-xr-x | gdb/gdbarch.sh | 6 | ||||
-rw-r--r-- | gdb/infrun.c | 3 | ||||
-rw-r--r-- | gdb/language.c | 3 | ||||
-rw-r--r-- | gdb/linespec.c | 7 | ||||
-rw-r--r-- | gdb/python/python-frame.c | 3 | ||||
-rw-r--r-- | gdb/python/python-type.c | 4 | ||||
-rw-r--r-- | gdb/python/python-value.c | 3 | ||||
-rw-r--r-- | gdb/remote.c | 3 | ||||
-rw-r--r-- | gdb/typeprint.c | 3 | ||||
-rw-r--r-- | gdb/ui-file.c | 6 | ||||
-rw-r--r-- | gdb/ui-file.h | 4 | ||||
-rw-r--r-- | gdb/utils.c | 3 | ||||
-rw-r--r-- | gdb/varobj.c | 3 | ||||
-rw-r--r-- | gdb/xtensa-tdep.c | 6 |
19 files changed, 59 insertions, 41 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index ee829d1..2a42ffe 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,32 @@ +2009-08-14 Pedro Alves <pedro@codesourcery.com> + + * ui-file.h (ui_file_xstrdup): Mention that the length argument + may be NULL. + * ui-file.c (ui_file_xstrdup): Don't dereference LENGTH if it is + NULL. + * aix-thread.c (aix_thread_extra_thread_info): Pass NULL as length + parameter to ui_file_xstrdup. + * arm-tdep.c (_initialize_arm_tdep): Ditto. + * infrun.c (print_target_wait_results): Ditto. + * language.c (add_language): Ditto. + * linespec.c (cplusplus_error): Ditto. + * remote.c (escape_buffer): Ditto. + * typeprint.c (type_to_string): Ditto. + * utils.c (error_stream): Ditto. + * varobj.c (value_get_print_value): Ditto. + * xtensa-tdep.c (xtensa_verify_config): Replace `dummy' local with + `length' local. Pass it to ui_file_xstrdup, and avoid an strlen + call. + * gdbarch.sh (verify_gdbarch): Ditto. + * gdbarch.c: Regenerate. + * cli/cli-setshow.c (do_setshow_command): Pass NULL as length + parameter to ui_file_xstrdup. + * python/python-frame.c (frapy_str): Ditto. + * python/python-type.c (typy_str): Use the length local instead of + calling strlen. + * python/python-value.c (valpy_str): Pass NULL as length parameter + to ui_file_xstrdup. + 2009-08-13 Doug Evans <dje@google.com> * utils.c (gnu_debuglink_crc32): Store crc32_table as unsigned int diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c index 92e434c..f1b34d5 100644 --- a/gdb/aix-thread.c +++ b/gdb/aix-thread.c @@ -1734,7 +1734,6 @@ aix_thread_extra_thread_info (struct thread_info *thread) pthdb_suspendstate_t suspendstate; pthdb_detachstate_t detachstate; int cancelpend; - long length; static char *ret = NULL; if (!PD_TID (thread->ptid)) @@ -1775,7 +1774,7 @@ aix_thread_extra_thread_info (struct thread_info *thread) xfree (ret); /* Free old buffer. */ - ret = ui_file_xstrdup (buf, &length); + ret = ui_file_xstrdup (buf, NULL); ui_file_delete (buf); return ret; diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index 30b1df6..a2523f5 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -6081,7 +6081,7 @@ _initialize_arm_tdep (void) _("The valid values are:\n"), regdesc, _("The default is \"std\".")); - helptext = ui_file_xstrdup (stb, &length); + helptext = ui_file_xstrdup (stb, NULL); ui_file_delete (stb); add_setshow_enum_cmd("disassembler", no_class, diff --git a/gdb/cli/cli-setshow.c b/gdb/cli/cli-setshow.c index 851f042..ab422a4 100644 --- a/gdb/cli/cli-setshow.c +++ b/gdb/cli/cli-setshow.c @@ -383,8 +383,7 @@ do_setshow_command (char *arg, int from_tty, struct cmd_list_element *c) ui_out_field_stream (uiout, "value", stb); else { - long length; - char *value = ui_file_xstrdup (stb->stream, &length); + char *value = ui_file_xstrdup (stb->stream, NULL); make_cleanup (xfree, value); if (c->show_value_func != NULL) c->show_value_func (gdb_stdout, from_tty, c, value); diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index db71a5c..a20df00 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -507,7 +507,7 @@ verify_gdbarch (struct gdbarch *gdbarch) { struct ui_file *log; struct cleanup *cleanups; - long dummy; + long length; char *buf; log = mem_fileopen (); cleanups = make_cleanup_ui_file_delete (log); @@ -639,9 +639,9 @@ verify_gdbarch (struct gdbarch *gdbarch) /* Skip verify of record_special_symbol, has predicate */ /* Skip verify of has_global_solist, invalid_p == 0 */ /* Skip verify of has_global_breakpoints, invalid_p == 0 */ - buf = ui_file_xstrdup (log, &dummy); + buf = ui_file_xstrdup (log, &length); make_cleanup (xfree, buf); - if (strlen (buf) > 0) + if (length > 0) internal_error (__FILE__, __LINE__, _("verify_gdbarch: the following are invalid ...%s"), buf); diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh index 51b8004..491efce 100755 --- a/gdb/gdbarch.sh +++ b/gdb/gdbarch.sh @@ -1417,7 +1417,7 @@ verify_gdbarch (struct gdbarch *gdbarch) { struct ui_file *log; struct cleanup *cleanups; - long dummy; + long length; char *buf; log = mem_fileopen (); cleanups = make_cleanup_ui_file_delete (log); @@ -1463,9 +1463,9 @@ do fi done cat <<EOF - buf = ui_file_xstrdup (log, &dummy); + buf = ui_file_xstrdup (log, &length); make_cleanup (xfree, buf); - if (strlen (buf) > 0) + if (length > 0) internal_error (__FILE__, __LINE__, _("verify_gdbarch: the following are invalid ...%s"), buf); diff --git a/gdb/infrun.c b/gdb/infrun.c index 0bc9fb3..e3eddce 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -1943,7 +1943,6 @@ print_target_wait_results (ptid_t waiton_ptid, ptid_t result_ptid, char *status_string = target_waitstatus_to_string (ws); struct ui_file *tmp_stream = mem_fileopen (); char *text; - long len; /* The text is split over several lines because it was getting too long. Call fprintf_unfiltered (gdb_stdlog) once so that the text is still @@ -1963,7 +1962,7 @@ print_target_wait_results (ptid_t waiton_ptid, ptid_t result_ptid, "infrun: %s\n", status_string); - text = ui_file_xstrdup (tmp_stream, &len); + text = ui_file_xstrdup (tmp_stream, NULL); /* This uses %s in part to handle %'s in the text, but also to avoid a gcc error: the format attribute requires a string literal. */ diff --git a/gdb/language.c b/gdb/language.c index c1c0bcf..d975f23 100644 --- a/gdb/language.c +++ b/gdb/language.c @@ -888,7 +888,6 @@ add_language (const struct language_defn *lang) int i; struct ui_file *tmp_stream; - long len; if (lang->la_magic != LANG_MAGIC) { @@ -945,7 +944,7 @@ local or auto Automatic setting based on source file\n")); } xfree (language_set_doc); - language_set_doc = ui_file_xstrdup (tmp_stream, &len); + language_set_doc = ui_file_xstrdup (tmp_stream, NULL); ui_file_delete (tmp_stream); add_setshow_enum_cmd ("language", class_support, diff --git a/gdb/linespec.c b/gdb/linespec.c index debe86f..3e943a1 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -150,7 +150,6 @@ static NORETURN void cplusplus_error (const char *name, const char *fmt, ...) { struct ui_file *tmp_stream; - long len; char *message; tmp_stream = mem_fileopen (); make_cleanup_ui_file_delete (tmp_stream); @@ -169,9 +168,9 @@ cplusplus_error (const char *name, const char *fmt, ...) "(Note leading single quote.)"), name, name); - message = ui_file_xstrdup (tmp_stream, &len); - make_cleanup (xfree, message); - throw_error (NOT_FOUND_ERROR, "%s", message); + message = ui_file_xstrdup (tmp_stream, NULL); + make_cleanup (xfree, message); + throw_error (NOT_FOUND_ERROR, "%s", message); } /* Return the number of methods described for TYPE, including the diff --git a/gdb/python/python-frame.c b/gdb/python/python-frame.c index a97009f..279415c 100644 --- a/gdb/python/python-frame.c +++ b/gdb/python/python-frame.c @@ -80,13 +80,12 @@ static PyObject * frapy_str (PyObject *self) { char *s; - long len; PyObject *result; struct ui_file *strfile; strfile = mem_fileopen (); fprint_frame_id (strfile, ((frame_object *) self)->frame_id); - s = ui_file_xstrdup (strfile, &len); + s = ui_file_xstrdup (strfile, NULL); result = PyString_FromString (s); xfree (s); diff --git a/gdb/python/python-type.c b/gdb/python/python-type.c index e185112..f23248c 100644 --- a/gdb/python/python-type.c +++ b/gdb/python/python-type.c @@ -494,13 +494,13 @@ typy_str (PyObject *self) { volatile struct gdb_exception except; char *thetype = NULL; + long length = 0; PyObject *result; TRY_CATCH (except, RETURN_MASK_ALL) { struct cleanup *old_chain; struct ui_file *stb; - long length; stb = mem_fileopen (); old_chain = make_cleanup_ui_file_delete (stb); @@ -516,7 +516,7 @@ typy_str (PyObject *self) GDB_PY_HANDLE_EXCEPTION (except); } - result = PyUnicode_Decode (thetype, strlen (thetype), host_charset (), NULL); + result = PyUnicode_Decode (thetype, length, host_charset (), NULL); xfree (thetype); return result; diff --git a/gdb/python/python-value.c b/gdb/python/python-value.c index c73c916..c4217d5 100644 --- a/gdb/python/python-value.c +++ b/gdb/python/python-value.c @@ -348,7 +348,6 @@ static PyObject * valpy_str (PyObject *self) { char *s = NULL; - long dummy; struct ui_file *stb; struct cleanup *old_chain; PyObject *result; @@ -365,7 +364,7 @@ valpy_str (PyObject *self) { common_val_print (((value_object *) self)->value, stb, 0, &opts, python_language); - s = ui_file_xstrdup (stb, &dummy); + s = ui_file_xstrdup (stb, NULL); } GDB_PY_HANDLE_EXCEPTION (except); diff --git a/gdb/remote.c b/gdb/remote.c index 69d1c5f..4c58abb 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -5947,13 +5947,12 @@ escape_buffer (const char *buf, int n) struct cleanup *old_chain; struct ui_file *stb; char *str; - long length; stb = mem_fileopen (); old_chain = make_cleanup_ui_file_delete (stb); fputstrn_unfiltered (buf, n, 0, stb); - str = ui_file_xstrdup (stb, &length); + str = ui_file_xstrdup (stb, NULL); do_cleanups (old_chain); return str; } diff --git a/gdb/typeprint.c b/gdb/typeprint.c index 8133ad0..f090231 100644 --- a/gdb/typeprint.c +++ b/gdb/typeprint.c @@ -86,7 +86,6 @@ char * type_to_string (struct type *type) { char *s = NULL; - long dummy; struct ui_file *stb; struct cleanup *old_chain; volatile struct gdb_exception except; @@ -97,7 +96,7 @@ type_to_string (struct type *type) TRY_CATCH (except, RETURN_MASK_ALL) { type_print (type, "", stb, -1); - s = ui_file_xstrdup (stb, &dummy); + s = ui_file_xstrdup (stb, NULL); } if (except.reason < 0) s = NULL; diff --git a/gdb/ui-file.c b/gdb/ui-file.c index 02a0314..527917c 100644 --- a/gdb/ui-file.c +++ b/gdb/ui-file.c @@ -285,8 +285,7 @@ do_ui_file_xstrdup (void *context, const char *buffer, long length) } char * -ui_file_xstrdup (struct ui_file *file, - long *length) +ui_file_xstrdup (struct ui_file *file, long *length) { struct accumulated_ui_file acc; acc.buffer = NULL; @@ -294,7 +293,8 @@ ui_file_xstrdup (struct ui_file *file, ui_file_put (file, do_ui_file_xstrdup, &acc); if (acc.buffer == NULL) acc.buffer = xstrdup (""); - *length = acc.length; + if (length != NULL) + *length = acc.length; return acc.buffer; } diff --git a/gdb/ui-file.h b/gdb/ui-file.h index 1562d5a..bf9915c 100644 --- a/gdb/ui-file.h +++ b/gdb/ui-file.h @@ -73,8 +73,8 @@ extern void ui_file_put (struct ui_file *src, ui_file_put_method_ftype *write, v /* Returns a freshly allocated buffer containing the entire contents of FILE (as determined by ui_file_put()) with a NUL character - appended. LENGTH is set to the size of the buffer minus that - appended NUL. */ + appended. LENGTH, if not NULL, is set to the size of the buffer + minus that appended NUL. */ extern char *ui_file_xstrdup (struct ui_file *file, long *length); diff --git a/gdb/utils.c b/gdb/utils.c index 59d6ff6..5fa2f26 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -838,8 +838,7 @@ fatal (const char *string, ...) NORETURN void error_stream (struct ui_file *stream) { - long len; - char *message = ui_file_xstrdup (stream, &len); + char *message = ui_file_xstrdup (stream, NULL); make_cleanup (xfree, message); error (("%s"), message); } diff --git a/gdb/varobj.c b/gdb/varobj.c index 48d4cfb..fbe8ff8 100644 --- a/gdb/varobj.c +++ b/gdb/varobj.c @@ -2175,7 +2175,6 @@ static char * value_get_print_value (struct value *value, enum varobj_display_formats format, struct varobj *var) { - long dummy; struct ui_file *stb; struct cleanup *old_chain; gdb_byte *thevalue = NULL; @@ -2247,7 +2246,7 @@ value_get_print_value (struct value *value, enum varobj_display_formats format, } else common_val_print (value, stb, 0, &opts, current_language); - thevalue = ui_file_xstrdup (stb, &dummy); + thevalue = ui_file_xstrdup (stb, NULL); do_cleanups (old_chain); return thevalue; diff --git a/gdb/xtensa-tdep.c b/gdb/xtensa-tdep.c index 966a739..0745497 100644 --- a/gdb/xtensa-tdep.c +++ b/gdb/xtensa-tdep.c @@ -2498,7 +2498,7 @@ xtensa_verify_config (struct gdbarch *gdbarch) struct ui_file *log; struct cleanup *cleanups; struct gdbarch_tdep *tdep; - long dummy; + long length; char *buf; tdep = gdbarch_tdep (gdbarch); @@ -2531,9 +2531,9 @@ xtensa_verify_config (struct gdbarch *gdbarch) if (tdep->a0_base == -1) fprintf_unfiltered (log, _("\n\ta0_base: No Ax registers")); - buf = ui_file_xstrdup (log, &dummy); + buf = ui_file_xstrdup (log, &length); make_cleanup (xfree, buf); - if (strlen (buf) > 0) + if (length > 0) internal_error (__FILE__, __LINE__, _("the following are invalid: %s"), buf); do_cleanups (cleanups); |