[lldb-dev] SBTarget::AttachToProcessWithID hangs

Philippe Lavoie via lldb-dev lldb-dev at lists.llvm.org
Wed Sep 16 13:41:53 PDT 2015


It is the AttachToProcessWithID that hangs and never returns, so I cannot use my listener yet.

-Philippe
________________________________________
From: jingham at apple.com [jingham at apple.com]
Sent: Wednesday, September 16, 2015 3:34 PM
To: Philippe Lavoie
Cc: lldb-dev at lists.llvm.org
Subject: Re: [lldb-dev] SBTarget::AttachToProcessWithID hangs

Did you try waiting for an event on the listener you've passed to AttachToProcess?  The last event after everything is done should be the notification to the public listener (i.e. your test_listener) that the process you attached to has stopped, and nobody is fetching that.

Jim

> On Sep 16, 2015, at 11:59 AM, Philippe Lavoie via lldb-dev <lldb-dev at lists.llvm.org> wrote:
>
>
> I am trying to attach to a stopped process on our dsp target using the SBTarget interface but the call hangs.
> What I understand is that it is waiting for events on the "lldb.process" broadcaster using the "lldb.Target.Attach.attach.hijack" listener.
>
> Enabling the logs, I see that the process is attached successfully and that the stop event is generated. It just seems that the event is not seen by the listener.
>
> 1442428969.321000000 004B9590 Listener::WaitForEventsInternal (timeout = { 00000000 }) for lldb.Target.Attach.attach.hijack
> 1442428969.321000000 004BC7F4 Broadcaster("opus.remote")::BroadcastEvent (event_sp = {00A72050 Event: broadcaster = 004BC7F4 (opus.remote), type = 0x00010000, data = <NULL>}, unique =0) hijack = 00000000
> 1442428969.341000000 0049AC50 Broadcaster("lldb.target")::BroadcastEvent (event_sp = {00A70C78 Event: broadcaster = 0049AC50 (lldb.target), type = 0x00000002 (modules-loaded), data = {}}, unique =0) hijack = 00000000
> 1442428969.341000000 004BC7F4 Broadcaster("opus.remote")::BroadcastEvent (event_sp = {00A723C8 Event: broadcaster = 004BC7F4 (opus.remote), type = 0x00010000, data = <NULL>}, unique =0) hijack = 00000000
> 1442428969.450000000 004BC394 Broadcaster("lldb.process.internal_state_broadcaster")::BroadcastEvent (event_sp = {00A723C8 Event: broadcaster = 004BC394 (lldb.process.internal_state_broadcaster), type = 0x00000001, data = { process = 004BC308 (pid = 1), state = stopped}}, unique =0) hijack = 00000000
> 1442428969.452000000 004BC42C Listener('lldb.process.internal_state_listener')::AddEvent (event_sp = {00A723C8})
> 1442428969.453000000 031CF700 Listener::WaitForEventsInternal (timeout = { 00000000 }) for ProcessOpusRemote::AsyncThread
> 1442428969.453000000 004BC42C 'lldb.process.internal_state_listener' Listener::FindNextEventInternal(broadcaster=00000000, broadcaster_names=00000000[0], event_type_mask=0x00000000, remove=1) event 00A723C8
> 1442428969.459000000 0309F8D4 Listener::StartListeningForEvents (broadcaster = 004BC5F4, mask = 0x00000020) acquired_mask = 0x00000020 for Communication::SyncronizeWithReadThread
> 1442428969.470000000 Process::ShouldBroadcastEvent (00A723C8) => new state: stopped, last broadcast state: stopped - YES
> 1442428969.471000000 004BC318 Broadcaster("lldb.process")::BroadcastEvent (event_sp = {00A723C8 Event: broadcaster = 004BC318 (lldb.process), type = 0x00000001(state-changed), data = { process = 004BC308 (pid = 1), state = stopped}}, unique =0) hijack = 00000000
> 1442428969.473000000 00402598 Listener('lldb.Debugger')::AddEvent (event_sp = {00A723C8})
> 1442428969.474000000 004BC42C Listener::WaitForEventsInternal (timeout = { 00000000 }) for lldb.process.internal_state_listener
>
> Here's the code I use to attach.
>
> SBDebugger::Initialize();
>
> SBDebugger debugger = lldb::SBDebugger::Create(false);
> debugger.SetAsync(true);
>
> const char* categories [] = { "process", "events", 0 };
> if (!debugger.EnableLog("lldb", categories))
> return -1;
>
> pid_t pid = 1;
>
> SBTarget target = debugger.CreateTargetWithFileAndArch(elffile_name, "opus2");
>
> SBError error;
> SBListener listener("test_listener");
>
> SBProcess process = target.AttachToProcessWithID(listener, pid, error);
>
> if (!process.IsValid())
> {
>    ...
>
>
> I would be grateful for any insight on the cause of this behavior.
>
> Thanks,
> -Philippe
> _______________________________________________
> lldb-dev mailing list
> lldb-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev



More information about the lldb-dev mailing list