[PATCH] btrace: avoid tp != NULL assertion

Metzger, Markus T markus.t.metzger@intel.com
Tue Mar 3 12:25:00 GMT 2015


> -----Original Message-----
> From: Pedro Alves [mailto:palves@redhat.com]
> Sent: Tuesday, March 3, 2015 12:55 PM
> To: Metzger, Markus T
> Cc: gdb-patches@sourceware.org
> Subject: Re: [PATCH] btrace: avoid tp != NULL assertion


> Frame #7 where we convert the ptid to something inf-ptrace.c understands.
> 
> The fix is just to stop losing information.  This also improves
> performance a tiny bit, as currently we fetch registers out of ptrace
> twice, once for {pid,lwp} in linux-nat.c, and another for {pid,0} in
> inf-ptrace/i386-linux-nat.c.  We'll now use a single regcache object
> everywhere.
> 
> Please try the patch below.

It works.  Thanks.  I'll drop my patch, then.


> Note that this in your patch:
> 
> +  lwp = ptid_get_lwp (ptid);
> +  if (lwp == 0)
> +    {
> +      int pid;
> +
> +      /* Not a threaded program.  Use the PID as LWP ID.  */
> +      pid = ptid_get_pid (ptid);
> +      ptid = ptid_build (pid, pid, 0);
> +    }
> +
> +  return find_thread_ptid (ptid);
> +}
> +
> 
> is wrong because when debugging a multi-threaded program, you'll
> have e.g. ({pid,lwp}) {1,1}, {1,2}, {1,3}, etc.  Your patch makes
> btrace look for {2,2}, {3,3}, etc. in the thread list, which just
> aren't there, and thus return NULL.  I assume that that's why you
> needed to downgrade the asserts to errors.

No, that wasn't the reason for replacing the assert.  There are no such
errors in the gdb.btrace suite (which is mostly single-threaded) with my
patch and I have not seen any such errors otherwise, either.  I just found
it safer and more user-friendly in case we run into further problems in
this area.

I see what you mean, though...

> -  /* Convert to something the lower layer understands.  */
> -  ptid = pid_to_ptid (ptid_get_lwp (lp->ptid));
> -  linux_ops->to_resume (linux_ops, ptid, step, signo);


Regards,
Markus.

Intel GmbH
Dornacher Strasse 1
85622 Feldkirchen/Muenchen, Deutschland
Sitz der Gesellschaft: Feldkirchen bei Muenchen
Geschaeftsfuehrer: Christian Lamprechter, Hannes Schwaderer, Douglas Lusk
Registergericht: Muenchen HRB 47456
Ust.-IdNr./VAT Registration No.: DE129385895
Citibank Frankfurt a.M. (BLZ 502 109 00) 600119052



More information about the Gdb-patches mailing list