This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
RE: [PATCH] btrace: avoid tp != NULL assertion
- From: "Metzger, Markus T" <markus dot t dot metzger at intel dot com>
- To: Pedro Alves <palves at redhat dot com>
- Cc: "gdb-patches at sourceware dot org" <gdb-patches at sourceware dot org>
- Date: Tue, 3 Mar 2015 12:25:20 +0000
- Subject: RE: [PATCH] btrace: avoid tp != NULL assertion
- Authentication-results: sourceware.org; auth=none
- References: <1423473902-2286-1-git-send-email-markus dot t dot metzger at intel dot com> <54F4DF9D dot 3060400 at redhat dot com> <A78C989F6D9628469189715575E55B231E6EEF71 at IRSMSX104 dot ger dot corp dot intel dot com> <54F5A12F dot 9000702 at redhat dot com>
> -----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