diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 78fd713f91..6416c12a49 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2017-12-11 Simon Marchi + + PR gdb/22556 + * remote.c (remote_thread_name): Return NULL if name is empty. + (remote_threads_extra_info): Return NULL if extra info is empty. + 2017-12-11 Pedro Alves * defs.h (elf_sym_fns_lazy_psyms, elf_sym_fns_gdb_index) diff --git a/gdb/remote.c b/gdb/remote.c index fe2771316c..852fdef490 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -2268,7 +2268,10 @@ static const char * remote_thread_name (struct target_ops *ops, struct thread_info *info) { if (info->priv != NULL) - return get_remote_thread_info (info)->name.c_str (); + { + const std::string &name = get_remote_thread_info (info)->name; + return !name.empty () ? name.c_str () : NULL; + } return NULL; } @@ -3319,7 +3322,10 @@ remote_threads_extra_info (struct target_ops *self, struct thread_info *tp) struct thread_info *info = find_thread_ptid (tp->ptid); if (info != NULL && info->priv != NULL) - return get_remote_thread_info (info)->extra.c_str (); + { + const std::string &extra = get_remote_thread_info (info)->extra; + return !extra.empty () ? extra.c_str () : NULL; + } else return NULL; }