apolyakov updated this revision to Diff 150913.
apolyakov added a comment.

Some readability improvements(more comments). I think that we should keep 
`StepOver` signature as

  void StepOver(SBError &error, lldb::RunMode stop_other_threads);

since it seems that in SBThread methods SBError paramater is the last 
non-optional one, as @aprantl said.


https://reviews.llvm.org/D47991

Files:
  include/lldb/API/SBThread.h
  scripts/interface/SBThread.i
  source/API/SBThread.cpp

Index: source/API/SBThread.cpp
===================================================================
--- source/API/SBThread.cpp
+++ source/API/SBThread.cpp
@@ -632,7 +632,14 @@
   return sb_error;
 }
 
-void SBThread::StepOver(lldb::RunMode stop_other_threads) {
+void SBThread::StepOver(lldb::RunMode stop_other_threads
+                        /* = lldb::eOnlyDuringStepping */) {
+  SBError error; // Ignored
+  StepOver(error, stop_other_threads);
+}
+
+void SBThread::StepOver(SBError &error, lldb::RunMode stop_other_threads
+                                        /* = lldb::eOnlyDuringStepping */) {
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
 
   std::unique_lock<std::recursive_mutex> lock;
@@ -662,23 +669,25 @@
       }
     }
 
-    // This returns an error, we should use it!
-    ResumeNewPlan(exe_ctx, new_plan_sp.get());
-  }
+    error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
+  } else error.SetErrorString("this SBThread object is invalid");
 }
 
-void SBThread::StepInto(lldb::RunMode stop_other_threads) {
+void SBThread::StepInto(lldb::RunMode stop_other_threads
+                        /* = lldb::eOnlyDuringStepping */) {
   StepInto(NULL, stop_other_threads);
 }
 
 void SBThread::StepInto(const char *target_name,
-                        lldb::RunMode stop_other_threads) {
-  SBError error;
+                        lldb::RunMode stop_other_threads
+                        /* = lldb::eOnlyDuringStepping*/) {
+  SBError error; // Ignored
   StepInto(target_name, LLDB_INVALID_LINE_NUMBER, error, stop_other_threads);
 }
 
 void SBThread::StepInto(const char *target_name, uint32_t end_line,
-                        SBError &error, lldb::RunMode stop_other_threads) {
+                        SBError &error, lldb::RunMode stop_other_threads
+                                        /* = lldb::eOnlyDuringStepping */) {
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
 
   std::unique_lock<std::recursive_mutex> lock;
@@ -722,10 +731,15 @@
     }
 
     error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
-  }
+  } else error.SetErrorString("this SBThread object is invalid");
 }
 
 void SBThread::StepOut() {
+  SBError error; // Ignored
+  StepOut(error);
+}
+
+void SBThread::StepOut(SBError &error) {
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
 
   std::unique_lock<std::recursive_mutex> lock;
@@ -746,12 +760,16 @@
         abort_other_plans, NULL, false, stop_other_threads, eVoteYes,
         eVoteNoOpinion, 0, avoid_no_debug));
 
-    // This returns an error, we should use it!
-    ResumeNewPlan(exe_ctx, new_plan_sp.get());
-  }
+    error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
+  } else error.SetErrorString("this SBThread object is invalid");
+}
+
+void SBThread::StepOutOfFrame(SBFrame &sb_frame) {
+  SBError error; // Ignored
+  StepOutOfFrame(sb_frame, error);
 }
 
-void SBThread::StepOutOfFrame(lldb::SBFrame &sb_frame) {
+void SBThread::StepOutOfFrame(SBFrame &sb_frame, SBError &error) {
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
 
   std::unique_lock<std::recursive_mutex> lock;
@@ -789,12 +807,16 @@
         abort_other_plans, NULL, false, stop_other_threads, eVoteYes,
         eVoteNoOpinion, frame_sp->GetFrameIndex()));
 
-    // This returns an error, we should use it!
-    ResumeNewPlan(exe_ctx, new_plan_sp.get());
-  }
+    error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
+  } else error.SetErrorString("this SBThread object is invalid");
 }
 
 void SBThread::StepInstruction(bool step_over) {
+  SBError error; // Ignored
+  StepInstruction(step_over, error);
+}
+
+void SBThread::StepInstruction(bool step_over, SBError &error) {
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
 
   std::unique_lock<std::recursive_mutex> lock;
@@ -809,12 +831,16 @@
     ThreadPlanSP new_plan_sp(
         thread->QueueThreadPlanForStepSingleInstruction(step_over, true, true));
 
-    // This returns an error, we should use it!
-    ResumeNewPlan(exe_ctx, new_plan_sp.get());
-  }
+    error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
+  } else error.SetErrorString("this SBThread object is invalid");
 }
 
 void SBThread::RunToAddress(lldb::addr_t addr) {
+  SBError error; // Ignored
+  RunToAddress(addr, error);
+}
+
+void SBThread::RunToAddress(lldb::addr_t addr, SBError &error) {
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
 
   std::unique_lock<std::recursive_mutex> lock;
@@ -835,9 +861,8 @@
     ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForRunToAddress(
         abort_other_plans, target_addr, stop_other_threads));
 
-    // This returns an error, we should use it!
-    ResumeNewPlan(exe_ctx, new_plan_sp.get());
-  }
+    error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
+  } else error.SetErrorString("this SBThread object is invalid");
 }
 
 SBError SBThread::StepOverUntil(lldb::SBFrame &sb_frame,
@@ -1082,6 +1107,11 @@
 }
 
 bool SBThread::Suspend() {
+  SBError error; // Ignored
+  return Suspend(error);
+}
+
+bool SBThread::Suspend(SBError &error) {
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
   std::unique_lock<std::recursive_mutex> lock;
   ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
@@ -1097,14 +1127,19 @@
         log->Printf("SBThread(%p)::Suspend() => error: process is running",
                     static_cast<void *>(exe_ctx.GetThreadPtr()));
     }
-  }
+  } else error.SetErrorString("this SBThread object is invalid");
   if (log)
     log->Printf("SBThread(%p)::Suspend() => %i",
                 static_cast<void *>(exe_ctx.GetThreadPtr()), result);
   return result;
 }
 
 bool SBThread::Resume() {
+  SBError error; // Ignored
+  return Resume(error);
+}
+
+bool SBThread::Resume(SBError &error) {
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
   std::unique_lock<std::recursive_mutex> lock;
   ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
@@ -1121,7 +1156,7 @@
         log->Printf("SBThread(%p)::Resume() => error: process is running",
                     static_cast<void *>(exe_ctx.GetThreadPtr()));
     }
-  }
+  } else error.SetErrorString("this SBThread object is invalid");
   if (log)
     log->Printf("SBThread(%p)::Resume() => %i",
                 static_cast<void *>(exe_ctx.GetThreadPtr()), result);
Index: scripts/interface/SBThread.i
===================================================================
--- scripts/interface/SBThread.i
+++ scripts/interface/SBThread.i
@@ -211,6 +211,12 @@
     void
     StepOver (lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping);
 
+    %feature("autodoc",
+    "Do a source level single step over in the currently selected thread.") StepOver;
+    void
+    StepOver (SBError &error,
+              lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping);
+
     void
     StepInto (lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping);
 
@@ -231,12 +237,28 @@
     void
     StepOut ();
 
+    %feature("autodoc",
+    "Step out of the currently selected thread.") StepOut;
+    void
+    StepOut (SBError &error);
+
+    void
+    StepOutOfFrame (SBFrame &frame);
+
+    %feature("autodoc",
+    "Step out of the specified frame.") StepOutOfFrame;
     void
-    StepOutOfFrame (lldb::SBFrame &frame);
+    StepOutOfFrame (SBFrame &frame, SBError &error);
 
     void
     StepInstruction(bool step_over);
 
+    %feature("autodoc",
+    "Do a instruction level single step in the currently selected thread.
+    ") StepInstruction;
+    void
+    StepInstruction(bool step_over, SBError &error);
+
     SBError
     StepOverUntil (lldb::SBFrame &frame,
                    lldb::SBFileSpec &file_spec,
@@ -254,6 +276,9 @@
     void
     RunToAddress (lldb::addr_t addr);
 
+    void
+    RunToAddress (lldb::addr_t addr, SBError &error);
+
     %feature("autodoc", "
     Force a return from the frame passed in (and any frames younger than it)
     without executing any more code in those frames.  If return_value contains
@@ -297,9 +322,15 @@
     ") Suspend;
     bool
     Suspend();
+
+    bool
+    Suspend(SBError &error);
     
     bool
     Resume ();
+
+    bool
+    Resume (SBError &error);
     
     bool
     IsSuspended();
Index: include/lldb/API/SBThread.h
===================================================================
--- include/lldb/API/SBThread.h
+++ include/lldb/API/SBThread.h
@@ -93,6 +93,9 @@
 
   void StepOver(lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping);
 
+  void StepOver(SBError &error,
+                lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping);
+
   void StepInto(lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping);
 
   void StepInto(const char *target_name,
@@ -103,10 +106,16 @@
 
   void StepOut();
 
-  void StepOutOfFrame(lldb::SBFrame &frame);
+  void StepOut(SBError &error);
+
+  void StepOutOfFrame(SBFrame &frame);
+
+  void StepOutOfFrame(SBFrame &frame, SBError &error);
 
   void StepInstruction(bool step_over);
 
+  void StepInstruction(bool step_over, SBError &error);
+
   SBError StepOverUntil(lldb::SBFrame &frame, lldb::SBFileSpec &file_spec,
                         uint32_t line);
 
@@ -119,6 +128,8 @@
 
   void RunToAddress(lldb::addr_t addr);
 
+  void RunToAddress(lldb::addr_t addr, SBError &error);
+
   SBError ReturnFromFrame(SBFrame &frame, SBValue &return_value);
 
   SBError UnwindInnermostExpression();
@@ -146,8 +157,12 @@
   //--------------------------------------------------------------------------
   bool Suspend();
 
+  bool Suspend(SBError &error);
+
   bool Resume();
 
+  bool Resume(SBError &error);
+
   bool IsSuspended();
 
   bool IsStopped();
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to