From: Pedro Alves Date: Wed, 5 Apr 2017 18:21:34 +0000 (+0100) Subject: -Wwrite-strings: Constify target_pid_to_str and target_thread_extra_thread_info X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7a1149643d8621541025e2c70e6391e901c8c7ef;p=binutils-gdb.git -Wwrite-strings: Constify target_pid_to_str and target_thread_extra_thread_info -Wwrite-strings flagged a missing cast for example here: static char * ravenscar_extra_thread_info (struct target_ops *self, struct thread_info *tp) { return "Ravenscar task"; Since callers are not supposed to free the string returned by these methods, change the methods' signature to return const strings. gdb/ChangeLog: 2017-04-05 Pedro Alves * aix-thread.c (aix_thread_pid_to_str) (aix_thread_extra_thread_info): Constify. * bsd-kvm.c (bsd_kvm_pid_to_str): Constify. * bsd-uthread.c (bsd_uthread_extra_thread_info) (bsd_uthread_pid_to_str): Constify. * corelow.c (core_pid_to_str): Constify. * darwin-nat.c (darwin_pid_to_str): Constify. * fbsd-nat.c (fbsd_pid_to_str): Constify. * fbsd-tdep.c (fbsd_core_pid_to_str, gdbarch_core_pid_to_str): Constify. * gnu-nat.c (gnu_pid_to_str): Constify. * go32-nat.c (go32_pid_to_str): Constify. * i386-cygwin-tdep.c (i386_windows_core_pid_to_str): Constify. * inf-ptrace.c (inf_ptrace_pid_to_str): Constify. * inferior.c (inferior_pid_to_str): Constify. * linux-nat.c (linux_nat_pid_to_str): Constify. * linux-tdep.c (linux_core_pid_to_str): Constify. * linux-thread-db.c (thread_db_pid_to_str) (thread_db_extra_thread_info): Constify. * nto-tdep.c (nto_extra_thread_info): Constify. * nto-tdep.h (nto_extra_thread_info): Constify. * obsd-nat.c (obsd_pid_to_str): Constify. * procfs.c (procfs_pid_to_str): Constify. * ravenscar-thread.c (ravenscar_extra_thread_info) (ravenscar_pid_to_str): Constify. * remote-sim.c (gdbsim_pid_to_str): Constify. * remote.c (remote_threads_extra_info, remote_pid_to_str): Constify. * sol-thread.c (solaris_pid_to_str): Constify. * sol2-tdep.c (sol2_core_pid_to_str): Constify. * sol2-tdep.h (sol2_core_pid_to_str): Constify. * target.c (default_pid_to_str, target_pid_to_str) (normal_pid_to_str, default_pid_to_str): Constify. * target.h (target_ops::to_pid_to_str) (target_ops::to_extra_thread_info): Constify. (target_pid_to_str, normal_pid_to_str): Constify. * windows-nat.c (windows_pid_to_str): Constify. * gdbarch.sh (core_pid_to_str): Constify. * target-delegates.c: Regenerate. * gdbarch.h, gdbarch.c: Regenerate. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index f07927d468c..f0219682c50 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,46 @@ +2017-04-05 Pedro Alves + + * aix-thread.c (aix_thread_pid_to_str) + (aix_thread_extra_thread_info): Constify. + * bsd-kvm.c (bsd_kvm_pid_to_str): Constify. + * bsd-uthread.c (bsd_uthread_extra_thread_info) + (bsd_uthread_pid_to_str): Constify. + * corelow.c (core_pid_to_str): Constify. + * darwin-nat.c (darwin_pid_to_str): Constify. + * fbsd-nat.c (fbsd_pid_to_str): Constify. + * fbsd-tdep.c (fbsd_core_pid_to_str, gdbarch_core_pid_to_str): + Constify. + * gnu-nat.c (gnu_pid_to_str): Constify. + * go32-nat.c (go32_pid_to_str): Constify. + * i386-cygwin-tdep.c (i386_windows_core_pid_to_str): Constify. + * inf-ptrace.c (inf_ptrace_pid_to_str): Constify. + * inferior.c (inferior_pid_to_str): Constify. + * linux-nat.c (linux_nat_pid_to_str): Constify. + * linux-tdep.c (linux_core_pid_to_str): Constify. + * linux-thread-db.c (thread_db_pid_to_str) + (thread_db_extra_thread_info): Constify. + * nto-tdep.c (nto_extra_thread_info): Constify. + * nto-tdep.h (nto_extra_thread_info): Constify. + * obsd-nat.c (obsd_pid_to_str): Constify. + * procfs.c (procfs_pid_to_str): Constify. + * ravenscar-thread.c (ravenscar_extra_thread_info) + (ravenscar_pid_to_str): Constify. + * remote-sim.c (gdbsim_pid_to_str): Constify. + * remote.c (remote_threads_extra_info, remote_pid_to_str): + Constify. + * sol-thread.c (solaris_pid_to_str): Constify. + * sol2-tdep.c (sol2_core_pid_to_str): Constify. + * sol2-tdep.h (sol2_core_pid_to_str): Constify. + * target.c (default_pid_to_str, target_pid_to_str) + (normal_pid_to_str, default_pid_to_str): Constify. + * target.h (target_ops::to_pid_to_str) + (target_ops::to_extra_thread_info): Constify. + (target_pid_to_str, normal_pid_to_str): Constify. + * windows-nat.c (windows_pid_to_str): Constify. + * gdbarch.sh (core_pid_to_str): Constify. + * target-delegates.c: Regenerate. + * gdbarch.h, gdbarch.c: Regenerate. + 2017-04-05 Pedro Alves * main.c (captured_main_1): Use gdb::unique_xmalloc_ptr to manage diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c index 3fbe96a7360..05024dfcc7e 100644 --- a/gdb/aix-thread.c +++ b/gdb/aix-thread.c @@ -1725,7 +1725,7 @@ aix_thread_thread_alive (struct target_ops *ops, ptid_t ptid) /* Return a printable representation of composite PID for use in "info threads" output. */ -static char * +static const char * aix_thread_pid_to_str (struct target_ops *ops, ptid_t ptid) { static char *ret = NULL; @@ -1745,7 +1745,7 @@ aix_thread_pid_to_str (struct target_ops *ops, ptid_t ptid) /* Return a printable representation of extra information about THREAD, for use in "info threads" output. */ -static char * +static const char * aix_thread_extra_thread_info (struct target_ops *self, struct thread_info *thread) { diff --git a/gdb/bsd-kvm.c b/gdb/bsd-kvm.c index 9f4f9e71edf..98e242836d9 100644 --- a/gdb/bsd-kvm.c +++ b/gdb/bsd-kvm.c @@ -329,7 +329,7 @@ bsd_kvm_thread_alive (struct target_ops *ops, return 1; } -static char * +static const char * bsd_kvm_pid_to_str (struct target_ops *ops, ptid_t ptid) { static char buf[64]; diff --git a/gdb/bsd-uthread.c b/gdb/bsd-uthread.c index 08b8f36969c..5d4775c0f0b 100644 --- a/gdb/bsd-uthread.c +++ b/gdb/bsd-uthread.c @@ -491,7 +491,7 @@ static char *bsd_uthread_state[] = /* Return a string describing th state of the thread specified by INFO. */ -static char * +static const char * bsd_uthread_extra_thread_info (struct target_ops *self, struct thread_info *info) { @@ -511,7 +511,7 @@ bsd_uthread_extra_thread_info (struct target_ops *self, return NULL; } -static char * +static const char * bsd_uthread_pid_to_str (struct target_ops *ops, ptid_t ptid) { if (ptid_get_tid (ptid) != 0) diff --git a/gdb/corelow.c b/gdb/corelow.c index 656c7541a0b..3267c37843e 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -965,7 +965,7 @@ core_read_description (struct target_ops *target) return target->beneath->to_read_description (target->beneath); } -static char * +static const char * core_pid_to_str (struct target_ops *ops, ptid_t ptid) { static char buf[64]; diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c index edee1be8589..e5092401f87 100644 --- a/gdb/darwin-nat.c +++ b/gdb/darwin-nat.c @@ -107,7 +107,7 @@ static void darwin_create_inferior (struct target_ops *ops, char *exec_file, static void darwin_files_info (struct target_ops *ops); -static char *darwin_pid_to_str (struct target_ops *ops, ptid_t tpid); +static const char *darwin_pid_to_str (struct target_ops *ops, ptid_t tpid); static int darwin_thread_alive (struct target_ops *ops, ptid_t tpid); @@ -1970,7 +1970,7 @@ darwin_files_info (struct target_ops *ops) { } -static char * +static const char * darwin_pid_to_str (struct target_ops *ops, ptid_t ptid) { static char buf[80]; diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c index 25952c3a69b..5c4408b4aa6 100644 --- a/gdb/fbsd-nat.c +++ b/gdb/fbsd-nat.c @@ -368,7 +368,7 @@ fbsd_thread_alive (struct target_ops *ops, ptid_t ptid) /* Convert PTID to a string. Returns the string in a static buffer. */ -static char * +static const char * fbsd_pid_to_str (struct target_ops *ops, ptid_t ptid) { lwpid_t lwp; diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c index 46875d8efd1..b834ce38b45 100644 --- a/gdb/fbsd-tdep.c +++ b/gdb/fbsd-tdep.c @@ -32,7 +32,7 @@ /* This is how we want PTIDs from core files to be printed. */ -static char * +static const char * fbsd_core_pid_to_str (struct gdbarch *gdbarch, ptid_t ptid) { static char buf[80]; diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index 87eafb2ab65..6debb10f594 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -3691,7 +3691,7 @@ gdbarch_core_pid_to_str_p (struct gdbarch *gdbarch) return gdbarch->core_pid_to_str != NULL; } -char * +const char * gdbarch_core_pid_to_str (struct gdbarch *gdbarch, ptid_t ptid) { gdb_assert (gdbarch != NULL); diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h index 34f82a719aa..3264c44711f 100644 --- a/gdb/gdbarch.h +++ b/gdb/gdbarch.h @@ -906,8 +906,8 @@ extern void set_gdbarch_core_xfer_shared_libraries_aix (struct gdbarch *gdbarch, extern int gdbarch_core_pid_to_str_p (struct gdbarch *gdbarch); -typedef char * (gdbarch_core_pid_to_str_ftype) (struct gdbarch *gdbarch, ptid_t ptid); -extern char * gdbarch_core_pid_to_str (struct gdbarch *gdbarch, ptid_t ptid); +typedef const char * (gdbarch_core_pid_to_str_ftype) (struct gdbarch *gdbarch, ptid_t ptid); +extern const char * gdbarch_core_pid_to_str (struct gdbarch *gdbarch, ptid_t ptid); extern void set_gdbarch_core_pid_to_str (struct gdbarch *gdbarch, gdbarch_core_pid_to_str_ftype *core_pid_to_str); /* How the core target extracts the name of a thread from a core file. */ diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh index 39b1f9477c2..c471b73cb10 100755 --- a/gdb/gdbarch.sh +++ b/gdb/gdbarch.sh @@ -745,7 +745,7 @@ M:ULONGEST:core_xfer_shared_libraries:gdb_byte *readbuf, ULONGEST offset, ULONGE M:ULONGEST:core_xfer_shared_libraries_aix:gdb_byte *readbuf, ULONGEST offset, ULONGEST len:readbuf, offset, len # How the core target converts a PTID from a core file to a string. -M:char *:core_pid_to_str:ptid_t ptid:ptid +M:const char *:core_pid_to_str:ptid_t ptid:ptid # How the core target extracts the name of a thread from a core file. M:const char *:core_thread_name:struct thread_info *thr:thr diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c index 7efb3c17b39..b2a975dead7 100644 --- a/gdb/gnu-nat.c +++ b/gdb/gnu-nat.c @@ -2652,7 +2652,7 @@ proc_string (struct proc *proc) return tid_str; } -static char * +static const char * gnu_pid_to_str (struct target_ops *ops, ptid_t ptid) { struct inf *inf = gnu_current_inf; diff --git a/gdb/go32-nat.c b/gdb/go32-nat.c index 1fca8e2e53f..d2d8d7affaa 100644 --- a/gdb/go32-nat.c +++ b/gdb/go32-nat.c @@ -941,7 +941,7 @@ go32_thread_alive (struct target_ops *ops, ptid_t ptid) return !ptid_equal (ptid, null_ptid); } -static char * +static const char * go32_pid_to_str (struct target_ops *ops, ptid_t ptid) { return normal_pid_to_str (ptid); diff --git a/gdb/i386-cygwin-tdep.c b/gdb/i386-cygwin-tdep.c index f200d39f2de..c8139ff047b 100644 --- a/gdb/i386-cygwin-tdep.c +++ b/gdb/i386-cygwin-tdep.c @@ -178,7 +178,7 @@ windows_core_xfer_shared_libraries (struct gdbarch *gdbarch, /* This is how we want PTIDs from core files to be printed. */ -static char * +static const char * i386_windows_core_pid_to_str (struct gdbarch *gdbarch, ptid_t ptid) { static char buf[80]; diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c index f912d28088e..c91100134b1 100644 --- a/gdb/inf-ptrace.c +++ b/gdb/inf-ptrace.c @@ -619,7 +619,7 @@ inf_ptrace_files_info (struct target_ops *ignore) target_pid_to_str (inferior_ptid)); } -static char * +static const char * inf_ptrace_pid_to_str (struct target_ops *ops, ptid_t ptid) { return normal_pid_to_str (ptid); diff --git a/gdb/inferior.c b/gdb/inferior.c index c4ab6d7d7f6..4ae265edab3 100644 --- a/gdb/inferior.c +++ b/gdb/inferior.c @@ -542,7 +542,7 @@ number_of_inferiors (void) /* Converts an inferior process id to a string. Like target_pid_to_str, but special cases the null process. */ -static char * +static const char * inferior_pid_to_str (int pid) { if (pid != 0) diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index dff0da568a7..b06e400fdc2 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -3940,7 +3940,7 @@ linux_nat_update_thread_list (struct target_ops *ops) } } -static char * +static const char * linux_nat_pid_to_str (struct target_ops *ops, ptid_t ptid) { static char buf[64]; diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c index 1a3e48d83d9..016aadff6b4 100644 --- a/gdb/linux-tdep.c +++ b/gdb/linux-tdep.c @@ -407,7 +407,7 @@ linux_has_shared_address_space (struct gdbarch *gdbarch) /* This is how we want PTIDs from core files to be printed. */ -static char * +static const char * linux_core_pid_to_str (struct gdbarch *gdbarch, ptid_t ptid) { static char buf[80]; diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c index b131fc20a9a..0e2607b5d96 100644 --- a/gdb/linux-thread-db.c +++ b/gdb/linux-thread-db.c @@ -1372,7 +1372,7 @@ thread_db_update_thread_list (struct target_ops *ops) ops->beneath->to_update_thread_list (ops->beneath); } -static char * +static const char * thread_db_pid_to_str (struct target_ops *ops, ptid_t ptid) { struct thread_info *thread_info = find_thread_ptid (ptid); @@ -1397,7 +1397,7 @@ thread_db_pid_to_str (struct target_ops *ops, ptid_t ptid) /* Return a string describing the state of the thread specified by INFO. */ -static char * +static const char * thread_db_extra_thread_info (struct target_ops *self, struct thread_info *info) { diff --git a/gdb/nto-tdep.c b/gdb/nto-tdep.c index 96a3af325a1..04ad06c431a 100644 --- a/gdb/nto-tdep.c +++ b/gdb/nto-tdep.c @@ -408,7 +408,7 @@ static const char *nto_thread_state_str[] = "NET_REPLY" /* 20 0x14 */ }; -char * +const char * nto_extra_thread_info (struct target_ops *self, struct thread_info *ti) { if (ti && ti->priv diff --git a/gdb/nto-tdep.h b/gdb/nto-tdep.h index 457bbc904ff..afe3452d345 100644 --- a/gdb/nto-tdep.h +++ b/gdb/nto-tdep.h @@ -176,7 +176,7 @@ void nto_dummy_supply_regset (struct regcache *regcache, char *regs); int nto_in_dynsym_resolve_code (CORE_ADDR pc); -char *nto_extra_thread_info (struct target_ops *self, struct thread_info *); +const char *nto_extra_thread_info (struct target_ops *self, struct thread_info *); LONGEST nto_read_auxv_from_initial_stack (CORE_ADDR inital_stack, gdb_byte *readbuf, diff --git a/gdb/obsd-nat.c b/gdb/obsd-nat.c index 3a73cbdd272..e2336a0579e 100644 --- a/gdb/obsd-nat.c +++ b/gdb/obsd-nat.c @@ -35,7 +35,7 @@ #ifdef PT_GET_THREAD_FIRST -static char * +static const char * obsd_pid_to_str (struct target_ops *ops, ptid_t ptid) { if (ptid_get_lwp (ptid) != 0) diff --git a/gdb/procfs.c b/gdb/procfs.c index b860f1699e7..71d4b643d96 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -135,7 +135,7 @@ static target_xfer_partial_ftype procfs_xfer_partial; static int procfs_thread_alive (struct target_ops *ops, ptid_t); static void procfs_update_thread_list (struct target_ops *ops); -static char *procfs_pid_to_str (struct target_ops *, ptid_t); +static const char *procfs_pid_to_str (struct target_ops *, ptid_t); static int proc_find_memory_regions (struct target_ops *self, find_memory_region_ftype, void *); @@ -4691,7 +4691,7 @@ procfs_thread_alive (struct target_ops *ops, ptid_t ptid) /* Convert PTID to a string. Returns the string in a static buffer. */ -static char * +static const char * procfs_pid_to_str (struct target_ops *ops, ptid_t ptid) { static char buf[80]; diff --git a/gdb/ravenscar-thread.c b/gdb/ravenscar-thread.c index d1bd97f3a65..1f89ea23a9d 100644 --- a/gdb/ravenscar-thread.c +++ b/gdb/ravenscar-thread.c @@ -54,8 +54,8 @@ static const char ravenscar_runtime_initializer[] = static void ravenscar_update_thread_list (struct target_ops *ops); static ptid_t ravenscar_running_thread (void); -static char *ravenscar_extra_thread_info (struct target_ops *self, - struct thread_info *tp); +static const char *ravenscar_extra_thread_info (struct target_ops *self, + struct thread_info *tp); static int ravenscar_thread_alive (struct target_ops *ops, ptid_t ptid); static void ravenscar_fetch_registers (struct target_ops *ops, struct regcache *regcache, int regnum); @@ -241,7 +241,7 @@ ravenscar_running_thread (void) return ptid_build (ptid_get_pid (base_ptid), 0, tid); } -static char * +static const char * ravenscar_extra_thread_info (struct target_ops *self, struct thread_info *tp) { return "Ravenscar task"; @@ -254,7 +254,7 @@ ravenscar_thread_alive (struct target_ops *ops, ptid_t ptid) return 1; } -static char * +static const char * ravenscar_pid_to_str (struct target_ops *ops, ptid_t ptid) { static char buf[30]; diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c index 0e8d65779f6..4396d4bcfe4 100644 --- a/gdb/remote-sim.c +++ b/gdb/remote-sim.c @@ -1270,7 +1270,7 @@ gdbsim_thread_alive (struct target_ops *ops, ptid_t ptid) /* Convert a thread ID to a string. Returns the string in a static buffer. */ -static char * +static const char * gdbsim_pid_to_str (struct target_ops *ops, ptid_t ptid) { return normal_pid_to_str (ptid); diff --git a/gdb/remote.c b/gdb/remote.c index 73a2e5124e5..30cd47ac8bf 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -3354,7 +3354,7 @@ remote_update_thread_list (struct target_ops *ops) * Optional: targets are not required to implement this function. */ -static char * +static const char * remote_threads_extra_info (struct target_ops *self, struct thread_info *tp) { struct remote_state *rs = get_remote_state (); @@ -10946,7 +10946,7 @@ init_remote_threadtests (void) /* Convert a thread ID to a string. Returns the string in a static buffer. */ -static char * +static const char * remote_pid_to_str (struct target_ops *ops, ptid_t ptid) { static char buf[64]; diff --git a/gdb/sol-thread.c b/gdb/sol-thread.c index 7c1620a0f68..39dae864a39 100644 --- a/gdb/sol-thread.c +++ b/gdb/sol-thread.c @@ -1021,7 +1021,7 @@ ps_lgetLDT (gdb_ps_prochandle_t ph, lwpid_t lwpid, /* Convert PTID to printable form. */ -static char * +static const char * solaris_pid_to_str (struct target_ops *ops, ptid_t ptid) { static char buf[100]; diff --git a/gdb/sol2-tdep.c b/gdb/sol2-tdep.c index 89eda53768b..7a06aa7a0d9 100644 --- a/gdb/sol2-tdep.c +++ b/gdb/sol2-tdep.c @@ -40,7 +40,7 @@ sol2_skip_solib_resolver (struct gdbarch *gdbarch, CORE_ADDR pc) /* This is how we want PTIDs from Solaris core files to be printed. */ -char * +const char * sol2_core_pid_to_str (struct gdbarch *gdbarch, ptid_t ptid) { static char buf[80]; diff --git a/gdb/sol2-tdep.h b/gdb/sol2-tdep.h index d2382e39a5f..56dd898be54 100644 --- a/gdb/sol2-tdep.h +++ b/gdb/sol2-tdep.h @@ -24,6 +24,6 @@ struct gdbarch; CORE_ADDR sol2_skip_solib_resolver (struct gdbarch *, CORE_ADDR); -char *sol2_core_pid_to_str (struct gdbarch *gdbarch, ptid_t ptid); +const char *sol2_core_pid_to_str (struct gdbarch *gdbarch, ptid_t ptid); #endif /* sol2-tdep.h */ diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c index 470b7e44d87..88e3e0b9940 100644 --- a/gdb/target-delegates.c +++ b/gdb/target-delegates.c @@ -1502,17 +1502,17 @@ debug_update_thread_list (struct target_ops *self) fputs_unfiltered (")\n", gdb_stdlog); } -static char * +static const char * delegate_pid_to_str (struct target_ops *self, ptid_t arg1) { self = self->beneath; return self->to_pid_to_str (self, arg1); } -static char * +static const char * debug_pid_to_str (struct target_ops *self, ptid_t arg1) { - char * result; + const char * result; fprintf_unfiltered (gdb_stdlog, "-> %s->to_pid_to_str (...)\n", debug_target.to_shortname); result = debug_target.to_pid_to_str (&debug_target, arg1); fprintf_unfiltered (gdb_stdlog, "<- %s->to_pid_to_str (", debug_target.to_shortname); @@ -1520,28 +1520,28 @@ debug_pid_to_str (struct target_ops *self, ptid_t arg1) fputs_unfiltered (", ", gdb_stdlog); target_debug_print_ptid_t (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; } -static char * +static const char * delegate_extra_thread_info (struct target_ops *self, struct thread_info *arg1) { self = self->beneath; return self->to_extra_thread_info (self, arg1); } -static char * +static const char * tdefault_extra_thread_info (struct target_ops *self, struct thread_info *arg1) { return NULL; } -static char * +static const char * debug_extra_thread_info (struct target_ops *self, struct thread_info *arg1) { - char * result; + const char * result; fprintf_unfiltered (gdb_stdlog, "-> %s->to_extra_thread_info (...)\n", debug_target.to_shortname); result = debug_target.to_extra_thread_info (&debug_target, arg1); fprintf_unfiltered (gdb_stdlog, "<- %s->to_extra_thread_info (", debug_target.to_shortname); @@ -1549,7 +1549,7 @@ debug_extra_thread_info (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; } diff --git a/gdb/target.c b/gdb/target.c index 7c286ab6bf8..fd9181ee30d 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -103,7 +103,7 @@ static int dummy_find_memory_regions (struct target_ops *self, static char *dummy_make_corefile_notes (struct target_ops *self, bfd *ignore1, int *ignore2); -static char *default_pid_to_str (struct target_ops *ops, ptid_t ptid); +static const char *default_pid_to_str (struct target_ops *ops, ptid_t ptid); static enum exec_direction_kind default_execution_direction (struct target_ops *self); @@ -2303,7 +2303,7 @@ default_target_wait (struct target_ops *ops, return minus_one_ptid; } -char * +const char * target_pid_to_str (ptid_t ptid) { return (*current_target.to_pid_to_str) (¤t_target, ptid); @@ -3344,7 +3344,7 @@ generic_mourn_inferior (void) /* Convert a normal process ID to a string. Returns the string in a static buffer. */ -char * +const char * normal_pid_to_str (ptid_t ptid) { static char buf[32]; @@ -3353,7 +3353,7 @@ normal_pid_to_str (ptid_t ptid) return buf; } -static char * +static const char * default_pid_to_str (struct target_ops *ops, ptid_t ptid) { return normal_pid_to_str (ptid); diff --git a/gdb/target.h b/gdb/target.h index 943a0e2e1a0..6553f491b29 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -639,9 +639,9 @@ struct target_ops TARGET_DEFAULT_RETURN (0); void (*to_update_thread_list) (struct target_ops *) TARGET_DEFAULT_IGNORE (); - char *(*to_pid_to_str) (struct target_ops *, ptid_t) + const char *(*to_pid_to_str) (struct target_ops *, ptid_t) TARGET_DEFAULT_FUNC (default_pid_to_str); - char *(*to_extra_thread_info) (struct target_ops *, struct thread_info *) + const char *(*to_extra_thread_info) (struct target_ops *, struct thread_info *) TARGET_DEFAULT_RETURN (NULL); const char *(*to_thread_name) (struct target_ops *, struct thread_info *) TARGET_DEFAULT_RETURN (NULL); @@ -1851,9 +1851,9 @@ extern int target_is_non_stop_p (void); `process xyz', but on some systems it may contain `process xyz thread abc'. */ -extern char *target_pid_to_str (ptid_t ptid); +extern const char *target_pid_to_str (ptid_t ptid); -extern char *normal_pid_to_str (ptid_t ptid); +extern const char *normal_pid_to_str (ptid_t ptid); /* Return a short string describing extra information about PID, e.g. "sleeping", "runnable", "running on LWP 3". Null return value diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index 76313db9891..85f2030214e 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -2807,7 +2807,7 @@ windows_close (struct target_ops *self) } /* Convert pid to printable format. */ -static char * +static const char * windows_pid_to_str (struct target_ops *ops, ptid_t ptid) { static char buf[80];