void listener_func() {
  while (!g_done) {
    SBEvent event;
    bool got_event = g_listener.WaitForEvent(1, event);
    if (got_event) {
      if (!event.IsValid())
        throw Exception("event is not valid in listener thread");

      SBProcess process = SBProcess::GetProcessFromEvent(event);
      if (process.GetState() == eStateStopped) {
        SBError error = process.Continue();
        if (!error.Success())
          throw Exception(string("Cannot continue process from listener thread: ")
                          + error.GetCString());
        g_process_started.push(true);
      }
    }
  }
}
예제 #2
0
void
Xcode::FetchFrames(SBProcess process, bool variables, bool verbose)
{
	auto pCount = process.GetNumThreads();
	for (int p = 0; p < pCount; p++)
	{
		SBThread thread(process.GetThreadAtIndex(p));
		auto tCount = thread.GetNumFrames ();
		if (verbose)
			printf("%s %d %d {%d}\n",thread.GetQueueName(),tCount,thread.GetStopReason(),eStopReasonBreakpoint);
		for (int t = 0; t < tCount; t++)
		{
			SBFrame frame(thread.GetFrameAtIndex(t));
			auto fp = frame.GetFP();
			SBThread thread_dup = frame.GetThread();
			SBFileSpec filespec(process.GetTarget().GetExecutable());
			std::string path(1024,0);
			filespec.GetPath(&path[0],1024);
			auto state = process.GetState();
			auto pCount_dup = process.GetNumThreads();
			auto byte_size = process.GetAddressByteSize();
			auto pc = frame.GetPC();
			SBSymbolContext context(frame.GetSymbolContext(0x0000006e));
			SBModule module(context.GetModule());
			SBLineEntry entry(context.GetLineEntry());
			SBFileSpec entry_filespec(process.GetTarget().GetExecutable());
			std::string entry_path(1024,0);
			entry_filespec.GetPath(&entry_path[0],1024);
			auto line_1 = entry.GetLine();
			auto line_2 = entry.GetLine();
			auto fname = frame.GetFunctionName();
			if (verbose)
				printf("%llu %s %d %d %llu %s %d %s\n",fp,path.c_str(),state,byte_size,pc,entry_path.c_str(),line_1,fname);
			if (variables)
				FetchVariables (frame, 0, verbose);
		}
	}
}
예제 #3
0
size_t
Driver::EditLineInputReaderCallback 
(
    void *baton, 
    SBInputReader *reader, 
    InputReaderAction notification,
    const char *bytes, 
    size_t bytes_len
)
{
    Driver *driver = (Driver *)baton;

    switch (notification)
    {
    case eInputReaderActivate:
        break;

    case eInputReaderReactivate:
        driver->ReadyForCommand();
        break;

    case eInputReaderDeactivate:
        break;
        
    case eInputReaderAsynchronousOutputWritten:
        if (driver->m_io_channel_ap.get() != NULL)
            driver->m_io_channel_ap->RefreshPrompt();
        break;

    case eInputReaderInterrupt:
        if (driver->m_io_channel_ap.get() != NULL)
        {
            SBProcess process = driver->GetDebugger().GetSelectedTarget().GetProcess();
            if (!driver->m_io_channel_ap->EditLineHasCharacters()
                &&  process.IsValid() && process.GetState() == lldb::eStateRunning)
            {
                process.Stop();
            }
            else
            {
                driver->m_io_channel_ap->OutWrite ("^C\n", 3, NO_ASYNC);
                // I wish I could erase the entire input line, but there's no public API for that.
                driver->m_io_channel_ap->EraseCharsBeforeCursor();
                driver->m_io_channel_ap->RefreshPrompt();
            }
        }
        break;
        
    case eInputReaderEndOfFile:
        if (driver->m_io_channel_ap.get() != NULL)
        {
            driver->m_io_channel_ap->OutWrite ("^D\n", 3, NO_ASYNC);
            driver->m_io_channel_ap->RefreshPrompt ();
        }
#ifdef __unix__
        write (driver->m_editline_pty.GetMasterFileDescriptor(), "quit\n", 5);
#endif
        break;

    case eInputReaderGotToken:
#ifdef __unix__
        write (driver->m_editline_pty.GetMasterFileDescriptor(), bytes, bytes_len);
#endif
        break;
        
    case eInputReaderDone:
        break;
    }
    return bytes_len;
}