[Lldb-commits] [PATCH] D96666: [lldb] Remove unused ThreadPlan tracer utilities (NFC)

2021-02-14 Thread Dave Lee via Phabricator via lldb-commits
kastiglione created this revision.
kastiglione added a reviewer: jingham.
kastiglione requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Delete unused `EnableTracer()` and `SetTracer()` functions on `Thread`. By 
deleting
these, their `ThreadPlan` counterparts also become unused.

Then, by deleting `ThreadPlanStack::EnableTracer`, `EnableSingleStep` becomes 
unused.
With no more callers to `EnableSingleStep`, the value `m_single_step` is always 
true and
can be removed as well.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D9

Files:
  lldb/include/lldb/Target/Thread.h
  lldb/include/lldb/Target/ThreadPlanStack.h
  lldb/include/lldb/Target/ThreadPlanTracer.h
  lldb/source/Target/Thread.cpp
  lldb/source/Target/ThreadPlan.cpp
  lldb/source/Target/ThreadPlanStack.cpp
  lldb/source/Target/ThreadPlanTracer.cpp

Index: lldb/source/Target/ThreadPlanTracer.cpp
===
--- lldb/source/Target/ThreadPlanTracer.cpp
+++ lldb/source/Target/ThreadPlanTracer.cpp
@@ -35,11 +35,11 @@
 
 ThreadPlanTracer::ThreadPlanTracer(Thread &thread, lldb::StreamSP &stream_sp)
 : m_process(*thread.GetProcess().get()), m_tid(thread.GetID()),
-  m_single_step(true), m_enabled(false), m_stream_sp(stream_sp) {}
+  m_enabled(false), m_stream_sp(stream_sp) {}
 
 ThreadPlanTracer::ThreadPlanTracer(Thread &thread)
 : m_process(*thread.GetProcess().get()), m_tid(thread.GetID()),
-  m_single_step(true), m_enabled(false), m_stream_sp() {}
+  m_enabled(false), m_stream_sp() {}
 
 Stream *ThreadPlanTracer::GetLogStream() {
   if (m_stream_sp)
@@ -75,7 +75,7 @@
 }
 
 bool ThreadPlanTracer::TracerExplainsStop() {
-  if (m_enabled && m_single_step) {
+  if (m_enabled) {
 lldb::StopInfoSP stop_info = GetThread().GetStopInfo();
 return (stop_info->GetStopReason() == eStopReasonTrace);
   } else
Index: lldb/source/Target/ThreadPlanStack.cpp
===
--- lldb/source/Target/ThreadPlanStack.cpp
+++ lldb/source/Target/ThreadPlanStack.cpp
@@ -124,20 +124,6 @@
   }
 }
 
-void ThreadPlanStack::EnableTracer(bool value, bool single_stepping) {
-  for (ThreadPlanSP plan : m_plans) {
-if (plan->GetThreadPlanTracer()) {
-  plan->GetThreadPlanTracer()->EnableTracing(value);
-  plan->GetThreadPlanTracer()->EnableSingleStep(single_stepping);
-}
-  }
-}
-
-void ThreadPlanStack::SetTracer(lldb::ThreadPlanTracerSP &tracer_sp) {
-  for (ThreadPlanSP plan : m_plans)
-plan->SetThreadPlanTracer(tracer_sp);
-}
-
 void ThreadPlanStack::PushPlan(lldb::ThreadPlanSP new_plan_sp) {
   // If the thread plan doesn't already have a tracer, give it its parent's
   // tracer:
Index: lldb/source/Target/ThreadPlan.cpp
===
--- lldb/source/Target/ThreadPlan.cpp
+++ lldb/source/Target/ThreadPlan.cpp
@@ -158,8 +158,7 @@
 }
 
 lldb::StateType ThreadPlan::RunState() {
-  if (m_tracer_sp && m_tracer_sp->TracingEnabled() &&
-  m_tracer_sp->SingleStepEnabled())
+  if (m_tracer_sp && m_tracer_sp->TracingEnabled())
 return eStateStepping;
   else
 return GetPlanRunState();
Index: lldb/source/Target/Thread.cpp
===
--- lldb/source/Target/Thread.cpp
+++ lldb/source/Target/Thread.cpp
@@ -1181,14 +1181,6 @@
   return status;
 }
 
-void Thread::EnableTracer(bool value, bool single_stepping) {
-  GetPlans().EnableTracer(value, single_stepping);
-}
-
-void Thread::SetTracer(lldb::ThreadPlanTracerSP &tracer_sp) {
-  GetPlans().SetTracer(tracer_sp);
-}
-
 bool Thread::DiscardUserThreadPlansUpToIndex(uint32_t plan_index) {
   // Count the user thread plans from the back end to get the number of the one
   // we want to discard:
Index: lldb/include/lldb/Target/ThreadPlanTracer.h
===
--- lldb/include/lldb/Target/ThreadPlanTracer.h
+++ lldb/include/lldb/Target/ThreadPlanTracer.h
@@ -50,14 +50,6 @@
 
   bool TracingEnabled() { return m_enabled; }
 
-  bool EnableSingleStep(bool value) {
-bool old_value = m_single_step;
-m_single_step = value;
-return old_value;
-  }
-
-  bool SingleStepEnabled() { return m_single_step; }
-  
   Thread &GetThread();
 
 protected:
@@ -71,7 +63,6 @@
 private:
   bool TracerExplainsStop();
 
-  bool m_single_step;
   bool m_enabled;
   lldb::StreamSP m_stream_sp;
   Thread *m_thread;
Index: lldb/include/lldb/Target/ThreadPlanStack.h
===
--- lldb/include/lldb/Target/ThreadPlanStack.h
+++ lldb/include/lldb/Target/ThreadPlanStack.h
@@ -48,10 +48,6 @@
 
   void ThreadDestroyed(Thread *thread);
 
-  void EnableTracer(bool value, bool single_stepping);
-
-  void SetTracer(lldb::ThreadPlanTracerSP &tracer_sp);
-
   void PushPlan(lldb::ThreadPlanSP new_plan_sp);
 
   lldb:

[Lldb-commits] [PATCH] D95601: [lldb][AArch64] Add MTE memory tag reading to lldb-server

2021-02-14 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
omjavaid added a comment.

This patch looks quite neat overall I have a few minor questions, comments and 
suggestions.

1. To get the review going consider further splitting up these patches into 
separate chunks containing, for example MemoryTagHandler API and related unit 
tests, GDB remote addons, ptrace work etc. Also add reference to GDB mailing 
list discussion where design of qMemTag packet has been discussed.

2. Soft suggestion to rename MemoryTagHandler, IMO it sounds more like a 
routine rather than a set of helpers used for manipulating memory tags. Also 
lldb/include/lldb/Target doesnt seem like a good place for helper functions as 
MemoryTagHandler is not used as Memory Tag container class. May be consider 
putting it under source/Plugins/Process/Utility

3. Changes to lldb/packages/Python/lldbsuite/test/decorators.py look reasonable 
and can be committed right away with a small caveat.

Some other minor comments inline as well.




Comment at: lldb/packages/Python/lldbsuite/test/decorators.py:825
 
+def skipUnlessAArch64MTELinuxToolchain(func):
+"""Decorate the item to skip test unless MTE is supported by the test 
compiler/toolchain."""

Consider using Compiler instead of Toolchain to keep terminology consistent 
with rest of the code in this file.



Comment at: lldb/packages/Python/lldbsuite/test/decorators.py:858
+
+
 def _get_bool_config(key, fail_value = True):

Omit one space.



Comment at: lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp:1518
+  Status error = NativeProcessLinux::PtraceWrapper(
+  details->ptrace_read_req, GetID(),
+  reinterpret_cast(range.GetRangeBase()),

Do you think future architectures will have any different 
ptrace_read_req/ptrace_write_req than PTRACE_PEEKMTETAGS/PTRACE_POKEMTETAGS.

If not then there is is no advantage of putting them inside MemoryTaggingDetails



Comment at: lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h:60
 
+  struct MemoryTaggingDetails {
+std::unique_ptr handler;

Add comment about MemoryTaggingDetails



Comment at: lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h:66
+  virtual llvm::Expected
+  GetMemoryTaggingDetails(int32_t type) {
+return llvm::createStringError(

Can type be negative. Does gdb remote protocol specifies type as int32? 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95601/new/

https://reviews.llvm.org/D95601

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 011791d - [lldb] [Process/FreeBSDRemote] Fix clang-formatting on ppc commit

2021-02-14 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2021-02-14T22:34:25+01:00
New Revision: 011791dda43c55cd9d5e53b6119b0cf40c183c48

URL: 
https://github.com/llvm/llvm-project/commit/011791dda43c55cd9d5e53b6119b0cf40c183c48
DIFF: 
https://github.com/llvm/llvm-project/commit/011791dda43c55cd9d5e53b6119b0cf40c183c48.diff

LOG: [lldb] [Process/FreeBSDRemote] Fix clang-formatting on ppc commit

Added: 


Modified: 

lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_powerpc.cpp

lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_powerpc.h
lldb/unittests/Process/Utility/RegisterContextFreeBSDTest.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_powerpc.cpp
 
b/lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_powerpc.cpp
index f923507b595d..98daa256424d 100644
--- 
a/lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_powerpc.cpp
+++ 
b/lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_powerpc.cpp
@@ -88,7 +88,8 @@ 
NativeRegisterContextFreeBSD_powerpc::NativeRegisterContextFreeBSD_powerpc(
 
 RegisterContextFreeBSD_powerpc &
 NativeRegisterContextFreeBSD_powerpc::GetRegisterInfo() const {
-  return static_cast(*m_register_info_interface_up);
+  return static_cast(
+  *m_register_info_interface_up);
 }
 
 uint32_t NativeRegisterContextFreeBSD_powerpc::GetRegisterSetCount() const {
@@ -122,7 +123,6 @@ NativeRegisterContextFreeBSD_powerpc::GetSetForNativeRegNum(
   llvm_unreachable("Register does not belong to any register set");
 }
 
-
 uint32_t NativeRegisterContextFreeBSD_powerpc::GetUserRegisterCount() const {
   uint32_t count = 0;
   for (uint32_t set_index = 0; set_index < GetRegisterSetCount(); ++set_index)
@@ -136,8 +136,8 @@ Status 
NativeRegisterContextFreeBSD_powerpc::ReadRegisterSet(RegSetKind set) {
 return NativeProcessFreeBSD::PtraceWrapper(PT_GETREGS, m_thread.GetID(),
m_reg_data.data());
   case FPRegSet:
-return NativeProcessFreeBSD::PtraceWrapper(
-PT_GETFPREGS, m_thread.GetID(), m_reg_data.data() + sizeof(reg));
+return NativeProcessFreeBSD::PtraceWrapper(PT_GETFPREGS, m_thread.GetID(),
+   m_reg_data.data() + 
sizeof(reg));
   }
   llvm_unreachable("NativeRegisterContextFreeBSD_powerpc::ReadRegisterSet");
 }
@@ -148,15 +148,15 @@ Status 
NativeRegisterContextFreeBSD_powerpc::WriteRegisterSet(RegSetKind set) {
 return NativeProcessFreeBSD::PtraceWrapper(PT_SETREGS, m_thread.GetID(),
m_reg_data.data());
   case FPRegSet:
-return NativeProcessFreeBSD::PtraceWrapper(
-PT_SETFPREGS, m_thread.GetID(), m_reg_data.data() + sizeof(reg));
+return NativeProcessFreeBSD::PtraceWrapper(PT_SETFPREGS, m_thread.GetID(),
+   m_reg_data.data() + 
sizeof(reg));
   }
   llvm_unreachable("NativeRegisterContextFreeBSD_powerpc::WriteRegisterSet");
 }
 
 Status
 NativeRegisterContextFreeBSD_powerpc::ReadRegister(const RegisterInfo 
*reg_info,
-   RegisterValue ®_value) {
+   RegisterValue ®_value) {
   Status error;
 
   if (!reg_info) {

diff  --git 
a/lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_powerpc.h
 
b/lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_powerpc.h
index d76fdae1d2e0..456ea30b0029 100644
--- 
a/lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_powerpc.h
+++ 
b/lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_powerpc.h
@@ -26,10 +26,11 @@ namespace process_freebsd {
 
 class NativeProcessFreeBSD;
 
-class NativeRegisterContextFreeBSD_powerpc : public 
NativeRegisterContextFreeBSD {
+class NativeRegisterContextFreeBSD_powerpc
+: public NativeRegisterContextFreeBSD {
 public:
   NativeRegisterContextFreeBSD_powerpc(const ArchSpec &target_arch,
-   NativeThreadProtocol &native_thread);
+   NativeThreadProtocol &native_thread);
 
   uint32_t GetRegisterSetCount() const override;
 

diff  --git a/lldb/unittests/Process/Utility/RegisterContextFreeBSDTest.cpp 
b/lldb/unittests/Process/Utility/RegisterContextFreeBSDTest.cpp
index 548830d19a52..f14dc8faaea3 100644
--- a/lldb/unittests/Process/Utility/RegisterContextFreeBSDTest.cpp
+++ b/lldb/unittests/Process/Utility/RegisterContextFreeBSDTest.cpp
@@ -463,12 +463,11 @@ TEST(RegisterContextFreeBSDTest, mips64) {
 
 #if defined(__powerpc__)
 
-#define EXPECT_GPR_PPC(lldb_reg, fbsd_reg)\
-  EXPECT_THAT(GetRegParams(reg_ctx, gpr_##lldb_reg##_powerpc), 
 \
-  ::testing::Pair(offsetof(reg, fbsd_reg)

[Lldb-commits] [PATCH] D96555: [lldb] Remove the legacy FreeBSD plugin

2021-02-14 Thread Ed Maste via Phabricator via lldb-commits
emaste added a comment.

Not sure if you're missing something, but removing the old plugin LGTM




Comment at: lldb/tools/lldb-server/CMakeLists.txt:13
 if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
-  list(APPEND LLDB_PLUGINS
-lldbPluginProcessFreeBSDRemote
-lldbPluginProcessFreeBSD)
+  list(APPEND LLDB_PLUGINS lldbPluginProcessFreeBSDRemote)
 endif()

Should we rename this after?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96555/new/

https://reviews.llvm.org/D96555

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D96555: [lldb] Remove the legacy FreeBSD plugin

2021-02-14 Thread Ed Maste via Phabricator via lldb-commits
emaste added inline comments.



Comment at: lldb/tools/lldb-server/CMakeLists.txt:13
 if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
-  list(APPEND LLDB_PLUGINS
-lldbPluginProcessFreeBSDRemote
-lldbPluginProcessFreeBSD)
+  list(APPEND LLDB_PLUGINS lldbPluginProcessFreeBSDRemote)
 endif()

emaste wrote:
> Should we rename this after?
Ah I see D96557


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96555/new/

https://reviews.llvm.org/D96555

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D96680: [lldb-vscode] Emit the breakpoint changed event on location resolved

2021-02-14 Thread António Afonso via Phabricator via lldb-commits
aadsm created this revision.
aadsm added reviewers: clayborg, labath, wallace, kusmour.
aadsm requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

VSCode was not being informed whenever a location had been resolved (after 
being initated as non-resolved), so even though it was actually resolved, the 
IDE would show a hollow dot (instead of a red dot) because it didn't know about 
the change.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96680

Files:
  lldb/tools/lldb-vscode/lldb-vscode.cpp


Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -417,7 +417,8 @@
   // of wether the locations were added or removed, the breakpoint
   // ins't going away, so we the reason is always "changed".
   if ((event_type & lldb::eBreakpointEventTypeLocationsAdded ||
-   event_type & lldb::eBreakpointEventTypeLocationsRemoved) &&
+   event_type & lldb::eBreakpointEventTypeLocationsRemoved ||
+   event_type & lldb::eBreakpointEventTypeLocationsResolved) &&
   bp.MatchesName(BreakpointBase::GetBreakpointLabel())) {
 auto bp_event = CreateEventObject("breakpoint");
 llvm::json::Object body;


Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -417,7 +417,8 @@
   // of wether the locations were added or removed, the breakpoint
   // ins't going away, so we the reason is always "changed".
   if ((event_type & lldb::eBreakpointEventTypeLocationsAdded ||
-   event_type & lldb::eBreakpointEventTypeLocationsRemoved) &&
+   event_type & lldb::eBreakpointEventTypeLocationsRemoved ||
+   event_type & lldb::eBreakpointEventTypeLocationsResolved) &&
   bp.MatchesName(BreakpointBase::GetBreakpointLabel())) {
 auto bp_event = CreateEventObject("breakpoint");
 llvm::json::Object body;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D96687: [lldb] Lower GetRealStopInfo into ThreadPlanCallFunction (NFC)

2021-02-14 Thread Dave Lee via Phabricator via lldb-commits
kastiglione created this revision.
kastiglione added a reviewer: jingham.
kastiglione requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

`GetRealStopInfo` has only one call site, and in that call site a reference to 
the
concrete thread plan is available (`ThreadPlanCallUserExpression`), from which
`GetRealStopInfo` can be called.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96687

Files:
  lldb/include/lldb/Target/ThreadPlan.h
  lldb/include/lldb/Target/ThreadPlanCallFunction.h
  lldb/source/Expression/LLVMUserExpression.cpp


Index: lldb/source/Expression/LLVMUserExpression.cpp
===
--- lldb/source/Expression/LLVMUserExpression.cpp
+++ lldb/source/Expression/LLVMUserExpression.cpp
@@ -188,9 +188,8 @@
 execution_result == lldb::eExpressionHitBreakpoint) {
   const char *error_desc = nullptr;
 
-  if (call_plan_sp) {
-lldb::StopInfoSP real_stop_info_sp = call_plan_sp->GetRealStopInfo();
-if (real_stop_info_sp)
+  if (user_expression_plan) {
+if (auto real_stop_info_sp = user_expression_plan->GetRealStopInfo())
   error_desc = real_stop_info_sp->GetDescription();
   }
   if (error_desc)
Index: lldb/include/lldb/Target/ThreadPlanCallFunction.h
===
--- lldb/include/lldb/Target/ThreadPlanCallFunction.h
+++ lldb/include/lldb/Target/ThreadPlanCallFunction.h
@@ -79,7 +79,7 @@
   // stop reason. But if something bad goes wrong, it is nice to be able to
   // tell the user what really happened.
 
-  lldb::StopInfoSP GetRealStopInfo() override {
+  virtual lldb::StopInfoSP GetRealStopInfo() {
 if (m_real_stop_info_sp)
   return m_real_stop_info_sp;
 else
Index: lldb/include/lldb/Target/ThreadPlan.h
===
--- lldb/include/lldb/Target/ThreadPlan.h
+++ lldb/include/lldb/Target/ThreadPlan.h
@@ -429,15 +429,6 @@
   m_tracer_sp->Log();
   }
 
-  // Some thread plans hide away the actual stop info which caused any
-  // particular stop.  For instance the ThreadPlanCallFunction restores the
-  // original stop reason so that stopping and calling a few functions won't
-  // lose the history of the run. This call can be implemented to get you back
-  // to the real stop info.
-  virtual lldb::StopInfoSP GetRealStopInfo() { 
-return GetThread().GetStopInfo();
-  }
-
   // If the completion of the thread plan stepped out of a function, the return
   // value of the function might have been captured by the thread plan
   // (currently only ThreadPlanStepOut does this.) If so, the ReturnValueObject


Index: lldb/source/Expression/LLVMUserExpression.cpp
===
--- lldb/source/Expression/LLVMUserExpression.cpp
+++ lldb/source/Expression/LLVMUserExpression.cpp
@@ -188,9 +188,8 @@
 execution_result == lldb::eExpressionHitBreakpoint) {
   const char *error_desc = nullptr;
 
-  if (call_plan_sp) {
-lldb::StopInfoSP real_stop_info_sp = call_plan_sp->GetRealStopInfo();
-if (real_stop_info_sp)
+  if (user_expression_plan) {
+if (auto real_stop_info_sp = user_expression_plan->GetRealStopInfo())
   error_desc = real_stop_info_sp->GetDescription();
   }
   if (error_desc)
Index: lldb/include/lldb/Target/ThreadPlanCallFunction.h
===
--- lldb/include/lldb/Target/ThreadPlanCallFunction.h
+++ lldb/include/lldb/Target/ThreadPlanCallFunction.h
@@ -79,7 +79,7 @@
   // stop reason. But if something bad goes wrong, it is nice to be able to
   // tell the user what really happened.
 
-  lldb::StopInfoSP GetRealStopInfo() override {
+  virtual lldb::StopInfoSP GetRealStopInfo() {
 if (m_real_stop_info_sp)
   return m_real_stop_info_sp;
 else
Index: lldb/include/lldb/Target/ThreadPlan.h
===
--- lldb/include/lldb/Target/ThreadPlan.h
+++ lldb/include/lldb/Target/ThreadPlan.h
@@ -429,15 +429,6 @@
   m_tracer_sp->Log();
   }
 
-  // Some thread plans hide away the actual stop info which caused any
-  // particular stop.  For instance the ThreadPlanCallFunction restores the
-  // original stop reason so that stopping and calling a few functions won't
-  // lose the history of the run. This call can be implemented to get you back
-  // to the real stop info.
-  virtual lldb::StopInfoSP GetRealStopInfo() { 
-return GetThread().GetStopInfo();
-  }
-
   // If the completion of the thread plan stepped out of a function, the return
   // value of the function might have been captured by the thread plan
   // (currently only ThreadPlanStepOut does this.) If so, the ReturnValueObject
___
lldb-commits mailing list
lldb-

[Lldb-commits] [PATCH] D96688: [lldb] Minor refinements to ThreadPlan::RestoreThreadState (NFC)

2021-02-14 Thread Dave Lee via Phabricator via lldb-commits
kastiglione created this revision.
kastiglione added a reviewer: jingham.
kastiglione requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Correct `RestoreThreadState` to a `void` return type. Also, update the 
signature of its
callee, `Thread::RestoreThreadStateFromCheckpoint`, by updating it to a `void` 
return
type, and making it non-`virtual`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96688

Files:
  lldb/include/lldb/Target/Thread.h
  lldb/include/lldb/Target/ThreadPlan.h
  lldb/include/lldb/Target/ThreadPlanCallFunction.h
  lldb/source/Target/Thread.cpp
  lldb/source/Target/ThreadPlanCallFunction.cpp


Index: lldb/source/Target/ThreadPlanCallFunction.cpp
===
--- lldb/source/Target/ThreadPlanCallFunction.cpp
+++ lldb/source/Target/ThreadPlanCallFunction.cpp
@@ -452,8 +452,8 @@
   m_subplan_sp->SetStopOthers(new_value);
 }
 
-bool ThreadPlanCallFunction::RestoreThreadState() {
-  return GetThread().RestoreThreadStateFromCheckpoint(m_stored_thread_state);
+void ThreadPlanCallFunction::RestoreThreadState() {
+  GetThread().RestoreThreadStateFromCheckpoint(m_stored_thread_state);
 }
 
 void ThreadPlanCallFunction::SetReturnValue() {
Index: lldb/source/Target/Thread.cpp
===
--- lldb/source/Target/Thread.cpp
+++ lldb/source/Target/Thread.cpp
@@ -530,7 +530,7 @@
   return false;
 }
 
-bool Thread::RestoreThreadStateFromCheckpoint(
+void Thread::RestoreThreadStateFromCheckpoint(
 ThreadStateCheckpoint &saved_state) {
   if (saved_state.stop_info_sp)
 saved_state.stop_info_sp->MakeStopInfoValid();
@@ -539,7 +539,6 @@
   saved_state.current_inlined_depth);
   GetPlans().RestoreCompletedPlanCheckpoint(
   saved_state.m_completed_plan_checkpoint);
-  return true;
 }
 
 StateType Thread::GetState() const {
Index: lldb/include/lldb/Target/ThreadPlanCallFunction.h
===
--- lldb/include/lldb/Target/ThreadPlanCallFunction.h
+++ lldb/include/lldb/Target/ThreadPlanCallFunction.h
@@ -88,7 +88,7 @@
 
   lldb::addr_t GetStopAddress() { return m_stop_address; }
 
-  bool RestoreThreadState() override;
+  void RestoreThreadState() override;
 
   void ThreadDestroyed() override { m_takedown_done = true; }
 
Index: lldb/include/lldb/Target/ThreadPlan.h
===
--- lldb/include/lldb/Target/ThreadPlan.h
+++ lldb/include/lldb/Target/ThreadPlan.h
@@ -462,10 +462,7 @@
   // to restore the state when it is done.  This will do that job. This is
   // mostly useful for artificial plans like CallFunction plans.
 
-  virtual bool RestoreThreadState() {
-// Nothing to do in general.
-return true;
-  }
+  virtual void RestoreThreadState() {}
 
   virtual bool IsVirtualStep() { return false; }
 
Index: lldb/include/lldb/Target/Thread.h
===
--- lldb/include/lldb/Target/Thread.h
+++ lldb/include/lldb/Target/Thread.h
@@ -1050,8 +1050,7 @@
   virtual bool
   RestoreRegisterStateFromCheckpoint(ThreadStateCheckpoint &saved_state);
 
-  virtual bool
-  RestoreThreadStateFromCheckpoint(ThreadStateCheckpoint &saved_state);
+  void RestoreThreadStateFromCheckpoint(ThreadStateCheckpoint &saved_state);
 
   // Get the thread index ID. The index ID that is guaranteed to not be re-used
   // by a process. They start at 1 and increase with each new thread. This


Index: lldb/source/Target/ThreadPlanCallFunction.cpp
===
--- lldb/source/Target/ThreadPlanCallFunction.cpp
+++ lldb/source/Target/ThreadPlanCallFunction.cpp
@@ -452,8 +452,8 @@
   m_subplan_sp->SetStopOthers(new_value);
 }
 
-bool ThreadPlanCallFunction::RestoreThreadState() {
-  return GetThread().RestoreThreadStateFromCheckpoint(m_stored_thread_state);
+void ThreadPlanCallFunction::RestoreThreadState() {
+  GetThread().RestoreThreadStateFromCheckpoint(m_stored_thread_state);
 }
 
 void ThreadPlanCallFunction::SetReturnValue() {
Index: lldb/source/Target/Thread.cpp
===
--- lldb/source/Target/Thread.cpp
+++ lldb/source/Target/Thread.cpp
@@ -530,7 +530,7 @@
   return false;
 }
 
-bool Thread::RestoreThreadStateFromCheckpoint(
+void Thread::RestoreThreadStateFromCheckpoint(
 ThreadStateCheckpoint &saved_state) {
   if (saved_state.stop_info_sp)
 saved_state.stop_info_sp->MakeStopInfoValid();
@@ -539,7 +539,6 @@
   saved_state.current_inlined_depth);
   GetPlans().RestoreCompletedPlanCheckpoint(
   saved_state.m_completed_plan_checkpoint);
-  return true;
 }
 
 StateType Thread::GetState() const {
Index: lldb/include/lldb/Target/ThreadPlanCallFunction.h
===
--- lldb/include/lldb/Targe

[Lldb-commits] [PATCH] D96689: [lldb] Remove ThreadPlan::ShouldAutoContinue (NFC)

2021-02-14 Thread Dave Lee via Phabricator via lldb-commits
kastiglione created this revision.
kastiglione added a reviewer: jingham.
kastiglione requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Remove `ShouldAutoContinue`, implemented in only one subclass.

In the `ShouldAutoContinue::ShouldAutoContinue`, the value will always be the 
inverse of
`ShouldStop`. In the one call site of `ShouldAutoContinue`, its value only 
matters if
`ShouldStop` is also true. Since that can never be the case, this function 
doesn't need
to exist.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96689

Files:
  lldb/include/lldb/Target/ThreadPlan.h
  lldb/include/lldb/Target/ThreadPlanStepOverBreakpoint.h
  lldb/source/Target/Thread.cpp
  lldb/source/Target/ThreadPlanStepOverBreakpoint.cpp


Index: lldb/source/Target/ThreadPlanStepOverBreakpoint.cpp
===
--- lldb/source/Target/ThreadPlanStepOverBreakpoint.cpp
+++ lldb/source/Target/ThreadPlanStepOverBreakpoint.cpp
@@ -107,7 +107,7 @@
 }
 
 bool ThreadPlanStepOverBreakpoint::ShouldStop(Event *event_ptr) {
-  return !ShouldAutoContinue(event_ptr);
+  return !m_auto_continue;
 }
 
 bool ThreadPlanStepOverBreakpoint::StopOthers() { return true; }
@@ -173,10 +173,6 @@
   m_auto_continue = do_it;
 }
 
-bool ThreadPlanStepOverBreakpoint::ShouldAutoContinue(Event *event_ptr) {
-  return m_auto_continue;
-}
-
 bool ThreadPlanStepOverBreakpoint::IsPlanStale() {
   return GetThread().GetRegisterContext()->GetPC() != m_breakpoint_addr;
 }
Index: lldb/source/Target/Thread.cpp
===
--- lldb/source/Target/Thread.cpp
+++ lldb/source/Target/Thread.cpp
@@ -861,10 +861,7 @@
   }
 
   if (!done_processing_current_plan) {
-bool over_ride_stop = current_plan->ShouldAutoContinue(event_ptr);
-
-LLDB_LOGF(log, "Plan %s explains stop, auto-continue %i.",
-  current_plan->GetName(), over_ride_stop);
+LLDB_LOGF(log, "Plan %s explains stop.", current_plan->GetName());
 
 // We're starting from the base plan, so just let it decide;
 if (current_plan->IsBasePlan()) {
@@ -905,9 +902,6 @@
 }
   }
 }
-
-if (over_ride_stop)
-  should_stop = false;
   }
 
   // One other potential problem is that we set up a master plan, then stop in
Index: lldb/include/lldb/Target/ThreadPlanStepOverBreakpoint.h
===
--- lldb/include/lldb/Target/ThreadPlanStepOverBreakpoint.h
+++ lldb/include/lldb/Target/ThreadPlanStepOverBreakpoint.h
@@ -30,7 +30,6 @@
   bool MischiefManaged() override;
   void ThreadDestroyed() override;
   void SetAutoContinue(bool do_it);
-  bool ShouldAutoContinue(Event *event_ptr) override;
   bool IsPlanStale() override;
 
   lldb::addr_t GetBreakpointLoadAddress() const { return m_breakpoint_addr; }
Index: lldb/include/lldb/Target/ThreadPlan.h
===
--- lldb/include/lldb/Target/ThreadPlan.h
+++ lldb/include/lldb/Target/ThreadPlan.h
@@ -360,8 +360,6 @@
 
   virtual bool ShouldStop(Event *event_ptr) = 0;
 
-  virtual bool ShouldAutoContinue(Event *event_ptr) { return false; }
-
   // Whether a "stop class" event should be reported to the "outside world".
   // In general if a thread plan is active, events should not be reported.
 


Index: lldb/source/Target/ThreadPlanStepOverBreakpoint.cpp
===
--- lldb/source/Target/ThreadPlanStepOverBreakpoint.cpp
+++ lldb/source/Target/ThreadPlanStepOverBreakpoint.cpp
@@ -107,7 +107,7 @@
 }
 
 bool ThreadPlanStepOverBreakpoint::ShouldStop(Event *event_ptr) {
-  return !ShouldAutoContinue(event_ptr);
+  return !m_auto_continue;
 }
 
 bool ThreadPlanStepOverBreakpoint::StopOthers() { return true; }
@@ -173,10 +173,6 @@
   m_auto_continue = do_it;
 }
 
-bool ThreadPlanStepOverBreakpoint::ShouldAutoContinue(Event *event_ptr) {
-  return m_auto_continue;
-}
-
 bool ThreadPlanStepOverBreakpoint::IsPlanStale() {
   return GetThread().GetRegisterContext()->GetPC() != m_breakpoint_addr;
 }
Index: lldb/source/Target/Thread.cpp
===
--- lldb/source/Target/Thread.cpp
+++ lldb/source/Target/Thread.cpp
@@ -861,10 +861,7 @@
   }
 
   if (!done_processing_current_plan) {
-bool over_ride_stop = current_plan->ShouldAutoContinue(event_ptr);
-
-LLDB_LOGF(log, "Plan %s explains stop, auto-continue %i.",
-  current_plan->GetName(), over_ride_stop);
+LLDB_LOGF(log, "Plan %s explains stop.", current_plan->GetName());
 
 // We're starting from the base plan, so just let it decide;
 if (current_plan->IsBasePlan()) {
@@ -905,9 +902,6 @@
 }
   }
 }
-
-if (over_ride_stop)
-  should_stop = false;
   }
 
   // One other potential problem is that we set up a master plan, then stop in
Index: lldb/include