What does this piece of hijack code do?

Hey guys,

In the local MacOSX debugging case when PlatformDarwin::Attach () is eventually called, what is this piece of code really doing?

ListenerSP listener_sp (new Listener(“lldb.PlatformDarwin.attach.hijack”));

attach_info.SetHijackListener(listener_sp);
process_sp->HijackProcessEvents(listener_sp.get());

What will be that hijacker’s responsibility?

Thanks!

It will get all process events delivered to it (like the initial eStateStopped event) to make sure the attach succeeded. The it will likely re-post the event after unhijacking the process events so LLDB knows about it.

Attach either succeeds or fails immediately (when attaching to a pid or name), or waits when attaching to the next process by name. This can be interrupted by CTRL+C and there is some logic that deals with that.

Greg

Ok, thanks.

So if I’m doing this for local Linux llgs-based debugging, I would want to do the same thing on the PlatformLinux side. Is there any significance to the name? For example, I’m using this code right now:

ListenerSP listener_sp (new Listener(“lldb.PlatformLinux.attach.hijack”)

-Todd

So if I'm doing this for local Linux llgs-based debugging, I would want to do the same thing on the PlatformLinux side. Is there any significance to the name?

No, it is for readability in crash logs, samples and when debugging.

For example, I'm using this code right now:

ListenerSP listener_sp (new Listener("lldb.PlatformLinux.attach.hijack")

That is fine.

Great, thanks.