RE: Crash of GDB with gdbserver btrace enabled [Re: [patch v9 00/23] branch tracing support for Atom]

Metzger, Markus T
2013-03-07T12:33:56Z

> -----Original Message-----
> From: Jan Kratochvil [mailto:jan.kratochvil@redhat.com]
> Sent: Thursday, March 07, 2013 1:07 PM

> > > OK, I agree target_close seems excessive here, it also does not correspond to
> > > the current description of target_close:
> > > This routine is automatically always called after popping the target
> > > off the target stack
> > >
> > > While it is nice cleanup I find it a separate patch, not required for btrace.
> >
> > With this patch, the crash is gone with only minimal changes to btrace.
>
> It is only a coincidence and workaround of it.

Hmmm, if we must no longer call methods in a certain target, why is
removing that target a workaround?

Pedro already moved the target_close call after removing the target in
http://sourceware.org/ml/gdb-patches/2012-01/msg00701.html.

He just did not consider the extra target_close call in pop_target, which
is not only closing the target twice but also breaking his attempt to
reorder target removing and closing.

If we removed disabling btrace from to_close, we would need to add a
separate path for "record stop". This means adding two new target
methods in total - one for clear/teardown and one for record stop. It
would further break the symmetry with to_open. Tracing would be
enabled in to_open but it would not be disabled in to_close, any more.

We also must not clear btrace in to_close since this would prevent btrace
from actually being disabled when the threads are discarded sometime
after the record target has been unpushed. We would thus leave threads
traced after the record target is gone and rely on thread cleanup to do
the actual disabling. This does not feel right.

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