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

Metzger, Markus T
2013-03-07T15:22:19Z

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

Thanks for bearing with me on this.

[..]

> > 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.
>
> to_close can be called in controlled (such as "record stop") or uncontrolled
> (inferior dies / gets killed). In the first case "record stop" should
> explicitly disable the tracing before calling to_close. In the second case it
> does not matter when the tracing disable happens, it just needs to happen.
>
> For the second case there must be always someone who does the munmap + close.
> In the linux-nat case it can be easily done from btrace's to_close. In the
> gdbserver case it is gdbserver's responsibility (where it actually already
> works).

I assume you mean from a new target to_teardown_btrace method and not
from btrace's to_close. That's where it currently is and where we want it moved
away from.

To summarize:
1. add a new target method to_teardown_btrace
1.1. disable btrace for native targets
1.2. only clear the trace and free the btrace_target_info for remote targets
2. call target_teardown_btrace from clear_thread_inferior_resources
3. add new target method to_stop_recording
3.1. disable btrace in record-btrace target
3.2. undefined in other record targets - may later split record-full's to_close.
4. call target_stop_recording in "record stop" before unpushing the record target
5. call target_stop_recording in record_mourn_inferior before unpushing the record target
6. call target_stop_recording in record_detach before unpushing the record target
7. call target_stop_recording in record_disconnect before unpushing the record target
8. call target_stop_recording in record_kill before unpushing the record target
9. remove btrace disable from record_btrace_to_close

This will make record_btrace_to_close empty. I must not touch the per-thread
btrace configuration since this is needed later in 2.

I'll make this a separate patch for easier review. I can later split it and merge
the pieces into the respective btrace patches.

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