[PATCH 06/18] -Wwrite-strings: Constify target_pid_to_str and target_thread_extra_thread_info

Pedro Alves
2017-04-04T17:26:11Z

-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:
yyyy-mm-dd Pedro Alves <palves@redhat.com>

* 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.
---
gdb/aix-thread.c | 4 ++--
gdb/bsd-kvm.c | 2 +-
gdb/bsd-uthread.c | 4 ++--
gdb/corelow.c | 2 +-
gdb/darwin-nat.c | 4 ++--
gdb/fbsd-nat.c | 2 +-
gdb/fbsd-tdep.c | 2 +-
gdb/gdbarch.c | 2 +-
gdb/gdbarch.h | 4 ++--
gdb/gdbarch.sh | 2 +-
gdb/gnu-nat.c | 2 +-
gdb/go32-nat.c | 2 +-
gdb/i386-cygwin-tdep.c | 2 +-
gdb/inf-ptrace.c | 2 +-
gdb/inferior.c | 2 +-
gdb/linux-nat.c | 2 +-
gdb/linux-tdep.c | 2 +-
gdb/linux-thread-db.c | 4 ++--
gdb/nto-tdep.c | 2 +-
gdb/nto-tdep.h | 2 +-
gdb/obsd-nat.c | 2 +-
gdb/procfs.c | 4 ++--
gdb/ravenscar-thread.c | 8 ++++----
gdb/remote-sim.c | 2 +-
gdb/remote.c | 4 ++--
gdb/sol-thread.c | 2 +-
gdb/sol2-tdep.c | 2 +-
gdb/sol2-tdep.h | 2 +-
gdb/target-delegates.c | 18 +++++++++---------
gdb/target.c | 8 ++++----
gdb/target.h | 8 ++++----
gdb/windows-nat.c | 2 +-
32 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c
index 3fbe96a..05024df 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 9f4f9e7..98e2428 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 08b8f36..5d4775c 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 656c754..3267c37 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 edee1be..e509240 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 d99f436..96781cd 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 46875d8..b834ce3 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 87eafb2..6debb10 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 34f82a7..3264c44 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 39b1f94..c471b73 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 7efb3c1..b2a975d 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 1fca8e2..d2d8d7a 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 f200d39..c8139ff 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 f912d28..c911001 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 c4ab6d7..4ae265e 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 dff0da5..b06e400 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 1a3e48d..016aadf 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 b131fc2..0e2607b 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 96a3af3..04ad06c 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 457bbc9..afe3452 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 3a73cbd..e2336a0 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 b860f16..71d4b64 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 d1bd97f..1f89ea2 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 0e8d657..4396d4b 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 2791ac8..956645a 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 7c1620a..39dae86 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 89eda53..7a06aa7 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 d2382e3..56dd898 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 470b7e4..88e3e0b 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 7c286ab..fd9181e 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) (&current_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 943a0e2..6553f49 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 76313db..85f2030 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];
--
2.5.5