gdbserver: make target_pid_to_str return std::string

I wanted to write a warning that included two target_pid_to_str calls,
like this:

    warning (_("Blabla %s, blabla %s"),
	     target_pid_to_str (ptid1),
	     target_pid_to_str (ptid2));

This doesn't work, because target_pid_to_str stores its result in a
static buffer, so my message would show twice the same ptid.  Change
target_pid_to_str to return an std::string to avoid this.  I don't think
we save much by using a static buffer, but it is more error-prone.

Change-Id: Ie3f649627686b84930529cc5c7c691ccf5d36dc2
This commit is contained in:
Simon Marchi
2021-10-25 14:33:55 -04:00
parent b3a9fe6f51
commit 61d7f128e6
6 changed files with 50 additions and 51 deletions

View File

@@ -4408,7 +4408,7 @@ tracepoint_finished_step (struct thread_info *tinfo, CORE_ADDR stop_pc)
wstep_link = &tinfo->while_stepping;
trace_debug ("Thread %s finished a single-step for tracepoint %d at 0x%s",
target_pid_to_str (tinfo->id),
target_pid_to_str (tinfo->id).c_str (),
wstep->tp_number, paddress (wstep->tp_address));
ctx.base.type = trap_tracepoint;
@@ -4421,7 +4421,7 @@ tracepoint_finished_step (struct thread_info *tinfo, CORE_ADDR stop_pc)
{
trace_debug ("NO TRACEPOINT %d at 0x%s FOR THREAD %s!",
wstep->tp_number, paddress (wstep->tp_address),
target_pid_to_str (tinfo->id));
target_pid_to_str (tinfo->id).c_str ());
/* Unlink. */
*wstep_link = wstep->next;
@@ -4441,7 +4441,7 @@ tracepoint_finished_step (struct thread_info *tinfo, CORE_ADDR stop_pc)
{
/* The requested numbers of steps have occurred. */
trace_debug ("Thread %s done stepping for tracepoint %d at 0x%s",
target_pid_to_str (tinfo->id),
target_pid_to_str (tinfo->id).c_str (),
wstep->tp_number, paddress (wstep->tp_address));
/* Unlink the wstep. */
@@ -4588,7 +4588,7 @@ tracepoint_was_hit (struct thread_info *tinfo, CORE_ADDR stop_pc)
&& tpoint->type != static_tracepoint)
{
trace_debug ("Thread %s at address of tracepoint %d at 0x%s",
target_pid_to_str (tinfo->id),
target_pid_to_str (tinfo->id).c_str (),
tpoint->number, paddress (tpoint->address));
/* Test the condition if present, and collect if true. */