From 73ede76585a987a07fbd67a7474b193e4ca05517 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Thu, 26 Nov 2015 09:49:03 -0500 Subject: Constify thread name return path Since this code path returns a string owned by the target (we don't know how it's allocated, could be a static read-only string), it's safer if we return a constant string. If, for some reasons, the caller wishes to modify the string, it should make itself a copy. gdb/ChangeLog: * linux-nat.c (linux_nat_thread_name): Constify return value. * target.h (struct target_ops) : Likewise. (target_thread_name): Likewise. * target.c (target_thread_name): Likewise. * target-delegates.c (debug_thread_name): Regenerate. * python/py-infthread.c (thpy_get_name): Constify local variables. * thread.c (print_thread_info): Likewise. (thread_find_command): Likewise. --- gdb/target-delegates.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'gdb/target-delegates.c') diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c index 253c9d7..b41b316 100644 --- a/gdb/target-delegates.c +++ b/gdb/target-delegates.c @@ -1530,23 +1530,23 @@ debug_extra_thread_info (struct target_ops *self, struct thread_info *arg1) return result; } -static char * +static const char * delegate_thread_name (struct target_ops *self, struct thread_info *arg1) { self = self->beneath; return self->to_thread_name (self, arg1); } -static char * +static const char * tdefault_thread_name (struct target_ops *self, struct thread_info *arg1) { return NULL; } -static char * +static const char * debug_thread_name (struct target_ops *self, struct thread_info *arg1) { - char * result; + const char * result; fprintf_unfiltered (gdb_stdlog, "-> %s->to_thread_name (...)\n", debug_target.to_shortname); result = debug_target.to_thread_name (&debug_target, arg1); fprintf_unfiltered (gdb_stdlog, "<- %s->to_thread_name (", debug_target.to_shortname); @@ -1554,7 +1554,7 @@ debug_thread_name (struct target_ops *self, struct thread_info *arg1) fputs_unfiltered (", ", gdb_stdlog); target_debug_print_struct_thread_info_p (arg1); fputs_unfiltered (") = ", gdb_stdlog); - target_debug_print_char_p (result); + target_debug_print_const_char_p (result); fputs_unfiltered ("\n", gdb_stdlog); return result; } -- cgit v1.1