Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2016
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.30 KB | None | 0 0
  1. SBListener listener = debugger.GetListener();
  2.  
  3. SBProcess process = target.Launch(listener, args, env, nullptr, nullptr,
  4.                                   nullptr, "/home/dev/helloWorld",
  5.                                   0, true, error);
  6.  
  7. process.GetBroadcaster().AddListener(listener,
  8.         SBProcess::eBroadcastBitStateChanged |
  9. SBProcess::eBroadcastBitSTDOUT);
  10.  
  11. process.Continue();
  12.  
  13. while(true) {
  14.   SBEvent event;
  15.  
  16.   if(listener.WaitForEvent(6, event)) {
  17.     if(!event.IsValid()) {
  18.       break;
  19.     }
  20.  
  21.     SBThread thread = process.GetThreadAtIndex(0);
  22.     StateType state = process.GetStateFromEvent(event);
  23.     SBStream stream;
  24.  
  25.     thread.GetStatus(stream);
  26.     event.GetDescription(stream);
  27.     std::cout << stream.GetData() << std::endl;
  28.  
  29.     auto threadStopReason = thread.GetStopReason();
  30.  
  31.     if(event.GetType() == 1 && state == eStateStopped) {
  32.       if(threadStopReason == eStopReasonBreakpoint) {
  33.         uint64_t bpId = thread.GetStopReasonDataAtIndex(0);
  34.  
  35.         if(bpId == static_cast<uint64_t>(bp1.GetID())) {
  36.           std::cout << "Stopped at breakpoint" << std::endl;
  37.           thread.StepOver();
  38.         }
  39.       } else if (threadStopReason == eStopReasonPlanComplete) {
  40.         std::cout << "Stopped at step" << std::endl;
  41.       }
  42.     }
  43.   } else {
  44.     break;
  45.   }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement