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");
        // send process description
        SBProcess process = SBProcess::GetProcessFromEvent(event);
        if (!process.IsValid())
            throw Exception("process is not valid");
        if (SBProcess::GetStateFromEvent(event) != lldb::eStateStopped || SBProcess::GetRestartedFromEvent(event))
            continue; // Only interested in "stopped" events.

        SBStream description;

        for (int i = 0; i < process.GetNumThreads(); ++i) {
            // send each thread description
            SBThread thread = process.GetThreadAtIndex(i);
            // send each frame function name
            uint32_t num_frames = thread.GetNumFrames();
            for(int j = 0; j < num_frames; ++j) {
                const char* function_name = thread.GetFrameAtIndex(j).GetSymbol().GetName();
                if (function_name)
                    g_frame_functions.push(string(function_name));
            }
        }
    }
  }
}
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");

      // send process description
      SBProcess process = SBProcess::GetProcessFromEvent(event);
      SBStream description;

      for (int i = 0; i < process.GetNumThreads(); ++i) {
        // send each thread description
        description.Clear();
        SBThread thread = process.GetThreadAtIndex(i);
        thread.GetDescription(description);
        g_thread_descriptions.push(description.GetData());

        // send each frame function name
        uint32_t num_frames = thread.GetNumFrames();
        for(int j = 0; j < num_frames; ++j) {
          const char* function_name = thread.GetFrameAtIndex(j).GetSymbol().GetName();
          if (function_name)
            g_frame_functions.push(function_name);
        }
      }
    }
  }
}
示例#3
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);
		}
	}
}
示例#4
0
SBThread
Xcode::GetThreadWithStopReason (SBProcess process, StopReason reason)
{
	auto threads_count = process.GetNumThreads();
	for (auto thread_num = 0; thread_num < threads_count; thread_num++)
	{
		SBThread thread(process.GetThreadAtIndex(thread_num));
		if (thread.GetStopReason() == reason)
		{
			return thread;
		}
	}
	return SBThread();
}