[Lldb-commits] [PATCH] D114862: Replace StackID's operator "<" with a function returning FrameComparison

2021-12-01 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha created this revision.
tatyana-krasnukha added reviewers: labath, jasonmolenda.
tatyana-krasnukha added a project: LLDB.
Herald added a subscriber: JDevlieghere.
tatyana-krasnukha requested review of this revision.
Herald added a subscriber: lldb-commits.

"false" result of the operator can imply not only "the frame is not younger". 
When CFAs are equal, StackID's operator "<" can only compare symbol contexts of 
the same function. Otherwise, it also returns false.

In the case I described in D114861 , two 
different frames can have the same CFA, and then the operator's result may be 
incorrect. "thread step-*" commands get broken in this case.

This patch replaces the operator that can return only boolean value with the 
function that returns a value of lldb::FrameComparison type. It also updates 
thread plans to use this function instead of the operator.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114862

Files:
  lldb/include/lldb/Target/StackID.h
  lldb/include/lldb/Target/ThreadPlanStepOut.h
  lldb/source/Target/StackFrameList.cpp
  lldb/source/Target/StackID.cpp
  lldb/source/Target/ThreadPlanStepInstruction.cpp
  lldb/source/Target/ThreadPlanStepOut.cpp
  lldb/source/Target/ThreadPlanStepRange.cpp
  lldb/source/Target/ThreadPlanStepUntil.cpp

Index: lldb/source/Target/ThreadPlanStepUntil.cpp
===
--- lldb/source/Target/ThreadPlanStepUntil.cpp
+++ lldb/source/Target/ThreadPlanStepUntil.cpp
@@ -173,7 +173,7 @@
 bool done;
 StackID cur_frame_zero_id;
 
-done = (m_stack_id < cur_frame_zero_id);
+done = m_stack_id.CompareTo(cur_frame_zero_id) == eFrameCompareYounger;
 
 if (done) {
   m_stepped_out = true;
@@ -197,11 +197,13 @@
 StackID frame_zero_id =
 thread.GetStackFrameAtIndex(0)->GetStackID();
 
-if (frame_zero_id == m_stack_id)
+auto frame_compare = frame_zero_id.CompareTo(m_stack_id);
+
+if (frame_compare == eFrameCompareEqual)
   done = true;
-else if (frame_zero_id < m_stack_id)
+else if (frame_compare == eFrameCompareYounger)
   done = false;
-else {
+else if (frame_compare == eFrameCompareOlder) {
   StackFrameSP older_frame_sp = thread.GetStackFrameAtIndex(1);
 
   // But if we can't even unwind one frame we should just get out
@@ -216,7 +218,8 @@
 done = (older_context == stack_context);
   } else
 done = false;
-}
+} else
+  done = thread.GetRegisterContext()->GetPC(0) == m_return_addr;
 
 if (done)
   SetPlanComplete();
Index: lldb/source/Target/ThreadPlanStepRange.cpp
===
--- lldb/source/Target/ThreadPlanStepRange.cpp
+++ lldb/source/Target/ThreadPlanStepRange.cpp
@@ -213,25 +213,21 @@
 // to the current list.
 
 lldb::FrameComparison ThreadPlanStepRange::CompareCurrentFrameToStartFrame() {
-  FrameComparison frame_order;
   Thread &thread = GetThread();
   StackID cur_frame_id = thread.GetStackFrameAtIndex(0)->GetStackID();
 
-  if (cur_frame_id == m_stack_id) {
-frame_order = eFrameCompareEqual;
-  } else if (cur_frame_id < m_stack_id) {
-frame_order = eFrameCompareYounger;
-  } else {
-StackFrameSP cur_parent_frame = thread.GetStackFrameAtIndex(1);
-StackID cur_parent_id;
-if (cur_parent_frame)
-  cur_parent_id = cur_parent_frame->GetStackID();
+  auto frame_order = cur_frame_id.CompareTo(m_stack_id);
+  if (frame_order != eFrameCompareUnknown)
+return frame_order;
+
+  StackFrameSP cur_parent_frame = thread.GetStackFrameAtIndex(1);
+  if (cur_parent_frame) {
+StackID cur_parent_id = cur_parent_frame->GetStackID();
 if (m_parent_stack_id.IsValid() && cur_parent_id.IsValid() &&
 m_parent_stack_id == cur_parent_id)
   frame_order = eFrameCompareSameParent;
-else
-  frame_order = eFrameCompareOlder;
   }
+
   return frame_order;
 }
 
Index: lldb/source/Target/ThreadPlanStepOut.cpp
===
--- lldb/source/Target/ThreadPlanStepOut.cpp
+++ lldb/source/Target/ThreadPlanStepOut.cpp
@@ -293,22 +293,7 @@
   BreakpointSiteSP site_sp(
   m_process.GetBreakpointSiteList().FindByID(stop_info_sp->GetValue()));
   if (site_sp && site_sp->IsBreakpointAtThisSite(m_return_bp_id)) {
-bool done;
-
-StackID frame_zero_id =
-GetThread().GetStackFrameAtIndex(0)->GetStackID();
-
-if (m_step_out_to_id == frame_zero_id)
-  done = true;
-else if (m_step_out_to_id < frame_zero_id) {
-  // Either we stepped past the breakpoint, or the stack ID calculation
-  // was incorrect and we should probably stop.
-  

[Lldb-commits] [PATCH] D114861: Don't consider frames with different PCs as a loop

2021-12-01 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha created this revision.
tatyana-krasnukha added reviewers: labath, jasonmolenda.
tatyana-krasnukha added a project: LLDB.
Herald added a subscriber: JDevlieghere.
tatyana-krasnukha requested review of this revision.
Herald added a subscriber: lldb-commits.

A compiler can produce FDE records with no CFA offset if it doesn't save 
anything on stack for a frame. This is what the MetaWare compiler does for some 
functions - it doesn't update CFA since it saves return address to a register.
In this case LLDB fails to unwind the stack complaining about a loop. This 
patch checks also the return addresses of the frames, there is no loop if they 
differ.

This is also consistent with how UnwindLLDB::GetOneMoreFrame identifies 
infinite loops.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114861

Files:
  lldb/source/Target/RegisterContextUnwind.cpp


Index: lldb/source/Target/RegisterContextUnwind.cpp
===
--- lldb/source/Target/RegisterContextUnwind.cpp
+++ lldb/source/Target/RegisterContextUnwind.cpp
@@ -690,28 +690,29 @@
   // -- or even more devious, we can actually oscillate between two CFA values.
   // Detect that here and break out to avoid a possible infinite loop in lldb
   // trying to unwind the stack. To detect when we have the same CFA value
-  // multiple times, we compare the
-  // CFA of the current
-  // frame with the 2nd next frame because in some specail case (e.g. signal
-  // hanlders, hand written assembly without ABI compliance) we can have 2
-  // frames with the same
-  // CFA (in theory we
-  // can have arbitrary number of frames with the same CFA, but more then 2 is
-  // very very unlikely)
+  // multiple times, we compare the CFA of the current frame with the 2nd next
+  // frame because in some specail case (e.g. signal hanlders, hand written
+  // assembly without ABI compiance) we can have 2 frames with the same CFA (in
+  // theory we can have arbitrary number of frames with the same CFA, but more
+  // then 2 is very very unlikely).
 
   RegisterContextUnwind::SharedPtr next_frame = GetNextFrame();
-  if (next_frame) {
-RegisterContextUnwind::SharedPtr next_next_frame =
-next_frame->GetNextFrame();
-addr_t next_next_frame_cfa = LLDB_INVALID_ADDRESS;
-if (next_next_frame && next_next_frame->GetCFA(next_next_frame_cfa)) {
-  if (next_next_frame_cfa == m_cfa) {
-// We have a loop in the stack unwind
-return true;
-  }
-}
-  }
-  return false;
+  if (!next_frame)
+return false;
+
+  RegisterContextUnwind::SharedPtr next_next_frame = 
next_frame->GetNextFrame();
+  if (!next_next_frame)
+return false;
+
+  // Since the return address value can be restored not only from the stack but
+  // also from a register, don't consider frames with the same CFAs and 
different
+  // PCs as a loop.
+  if (m_current_pc.IsValid() && (m_current_pc != next_next_frame->GetPC()))
+return false;
+
+  addr_t next_next_frame_cfa = LLDB_INVALID_ADDRESS;
+  return next_next_frame->GetCFA(next_next_frame_cfa) &&
+ next_next_frame_cfa == m_cfa;
 }
 
 bool RegisterContextUnwind::IsFrameZero() const { return m_frame_number == 0; }


Index: lldb/source/Target/RegisterContextUnwind.cpp
===
--- lldb/source/Target/RegisterContextUnwind.cpp
+++ lldb/source/Target/RegisterContextUnwind.cpp
@@ -690,28 +690,29 @@
   // -- or even more devious, we can actually oscillate between two CFA values.
   // Detect that here and break out to avoid a possible infinite loop in lldb
   // trying to unwind the stack. To detect when we have the same CFA value
-  // multiple times, we compare the
-  // CFA of the current
-  // frame with the 2nd next frame because in some specail case (e.g. signal
-  // hanlders, hand written assembly without ABI compliance) we can have 2
-  // frames with the same
-  // CFA (in theory we
-  // can have arbitrary number of frames with the same CFA, but more then 2 is
-  // very very unlikely)
+  // multiple times, we compare the CFA of the current frame with the 2nd next
+  // frame because in some specail case (e.g. signal hanlders, hand written
+  // assembly without ABI compiance) we can have 2 frames with the same CFA (in
+  // theory we can have arbitrary number of frames with the same CFA, but more
+  // then 2 is very very unlikely).
 
   RegisterContextUnwind::SharedPtr next_frame = GetNextFrame();
-  if (next_frame) {
-RegisterContextUnwind::SharedPtr next_next_frame =
-next_frame->GetNextFrame();
-addr_t next_next_frame_cfa = LLDB_INVALID_ADDRESS;
-if (next_next_frame && next_next_frame->GetCFA(next_next_frame_cfa)) {
-  if (next_next_frame_cfa == m_cfa) {
-// We have a loop in the stack unwind
-return true;
-  }
-}
-  }
-  return false;
+  if (!next_frame)
+return false;
+
+  RegisterContextUnwind::SharedPtr 

[Lldb-commits] [PATCH] D111899: LLDB tests modification for hardware breakpoints

2021-10-25 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha accepted this revision.
tatyana-krasnukha added a comment.
This revision is now accepted and ready to land.

LGTM, but I would wait for one more approve.


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

https://reviews.llvm.org/D111899

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


[Lldb-commits] [PATCH] D111899: LLDB tests modification for hardware breakpoints

2021-10-20 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha added inline comments.



Comment at: 
lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py:269
 self.expect(side_effect.bp_loc, exe=False,
-patterns=["1.* where = .*main .* resolved, hit count = 1"])
+patterns=["1.* where = .*main .* resolved,( hardware,)? hit 
count = 1"])
 

jingham wrote:
> Why didn't you change this one to use your new function?
`check_breakpoint` checks the correctness of a breakpoint and its locations, 
whereas this test seems to be checking that `side_effect` is correctly updated 
inside the breakpoint command script.


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

https://reviews.llvm.org/D111899

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


[Lldb-commits] [PATCH] D111209: Don't push null ExecutionContext on CommandInterpreter exectx stack

2021-10-07 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha added a comment.

Added inline comment




Comment at: lldb/source/Interpreter/CommandInterpreter.cpp:2842
 
-  OverrideExecutionContext(m_debugger.GetSelectedExecutionContext());
-  auto finalize = llvm::make_scope_exit([this]() {
-RestoreExecutionContext();
+  ExecutionContext exe_ctx = m_debugger.GetSelectedExecutionContext();
+  bool pushed_exe_ctx = false;

The intention of overriding the context here with the currently selected one 
was to have the same context during `HandleCommand` and `GetProcessOutput`. 
However, this logic looks wrong to me now. `HandleCommand` may change the 
context and `GetProcessOutput` should use the new one. I think that you can 
safely remove this piece of code (untill `IOHandlerInputComplete` doesn't allow 
overriding execution context).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111209

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


[Lldb-commits] [PATCH] D96817: Fix deep copying for OptionValue classes

2021-02-28 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha abandoned this revision.
tatyana-krasnukha added a comment.

D96952  is landed instead.


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

https://reviews.llvm.org/D96817

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


[Lldb-commits] [PATCH] D96952: CRTP-based version of D96817

2021-02-28 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha added inline comments.



Comment at: lldb/source/Interpreter/OptionValueFileSpecList.cpp:169
   std::lock_guard lock(m_mutex);
-  return OptionValueSP(new OptionValueFileSpecList(m_current_value));
+  return std::make_shared(*this);
 }

JDevlieghere wrote:
> I would call the `Clone` from `Cloneable` here, it's a bit messy with the 
> templates but it makes it makes it clear we're not hand-rolling an 
> implementation but instead are just protecting it wiht a mutex. 
Thanks! Did this before landing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96952

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


[Lldb-commits] [PATCH] D96952: CRTP-based version of D96817

2021-02-28 Thread Tatyana Krasnukha via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
tatyana-krasnukha marked 2 inline comments as done.
Closed by commit rGf0f183ee4ad9: [lldb/Interpreter] Fix deep copying for 
OptionValue classes (authored by tatyana-krasnukha).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Changed prior to commit:
  https://reviews.llvm.org/D96952?vs=325093&id=326971#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96952

Files:
  lldb/include/lldb/Interpreter/OptionValue.h
  lldb/include/lldb/Interpreter/OptionValueArch.h
  lldb/include/lldb/Interpreter/OptionValueArgs.h
  lldb/include/lldb/Interpreter/OptionValueArray.h
  lldb/include/lldb/Interpreter/OptionValueBoolean.h
  lldb/include/lldb/Interpreter/OptionValueChar.h
  lldb/include/lldb/Interpreter/OptionValueDictionary.h
  lldb/include/lldb/Interpreter/OptionValueEnumeration.h
  lldb/include/lldb/Interpreter/OptionValueFileColonLine.h
  lldb/include/lldb/Interpreter/OptionValueFileSpec.h
  lldb/include/lldb/Interpreter/OptionValueFileSpecList.h
  lldb/include/lldb/Interpreter/OptionValueFormat.h
  lldb/include/lldb/Interpreter/OptionValueFormatEntity.h
  lldb/include/lldb/Interpreter/OptionValueLanguage.h
  lldb/include/lldb/Interpreter/OptionValuePathMappings.h
  lldb/include/lldb/Interpreter/OptionValueProperties.h
  lldb/include/lldb/Interpreter/OptionValueRegex.h
  lldb/include/lldb/Interpreter/OptionValueSInt64.h
  lldb/include/lldb/Interpreter/OptionValueString.h
  lldb/include/lldb/Interpreter/OptionValueUInt64.h
  lldb/include/lldb/Interpreter/OptionValueUUID.h
  lldb/include/lldb/Utility/Cloneable.h
  lldb/source/Interpreter/OptionValue.cpp
  lldb/source/Interpreter/OptionValueArch.cpp
  lldb/source/Interpreter/OptionValueArray.cpp
  lldb/source/Interpreter/OptionValueBoolean.cpp
  lldb/source/Interpreter/OptionValueChar.cpp
  lldb/source/Interpreter/OptionValueDictionary.cpp
  lldb/source/Interpreter/OptionValueEnumeration.cpp
  lldb/source/Interpreter/OptionValueFileColonLine.cpp
  lldb/source/Interpreter/OptionValueFileSpec.cpp
  lldb/source/Interpreter/OptionValueFileSpecList.cpp
  lldb/source/Interpreter/OptionValueFormat.cpp
  lldb/source/Interpreter/OptionValueFormatEntity.cpp
  lldb/source/Interpreter/OptionValueLanguage.cpp
  lldb/source/Interpreter/OptionValuePathMappings.cpp
  lldb/source/Interpreter/OptionValueProperties.cpp
  lldb/source/Interpreter/OptionValueRegex.cpp
  lldb/source/Interpreter/OptionValueSInt64.cpp
  lldb/source/Interpreter/OptionValueString.cpp
  lldb/source/Interpreter/OptionValueUInt64.cpp
  lldb/source/Interpreter/OptionValueUUID.cpp
  lldb/source/Target/Process.cpp
  lldb/source/Target/Target.cpp
  lldb/source/Target/Thread.cpp
  lldb/test/API/commands/settings/TestSettings.py
  lldb/unittests/Interpreter/CMakeLists.txt
  lldb/unittests/Interpreter/TestOptionValue.cpp

Index: lldb/unittests/Interpreter/TestOptionValue.cpp
===
--- /dev/null
+++ lldb/unittests/Interpreter/TestOptionValue.cpp
@@ -0,0 +1,173 @@
+//===-- TestOptionValue.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "lldb/Interpreter/OptionValues.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+using namespace lldb_private;
+
+class Callback {
+public:
+  virtual void Invoke() const {}
+  void operator()() const { Invoke(); }
+};
+
+class MockCallback : public Callback {
+public:
+  MOCK_CONST_METHOD0(Invoke, void());
+};
+
+// Test a single-value class.
+TEST(OptionValueString, DeepCopy) {
+  OptionValueString str;
+  str.SetValueFromString("ab");
+
+  MockCallback callback;
+  str.SetValueChangedCallback([&callback] { callback(); });
+  EXPECT_CALL(callback, Invoke());
+
+  auto copy_sp = str.DeepCopy(nullptr);
+
+  // Test that the base class data members are copied/set correctly.
+  ASSERT_TRUE(copy_sp);
+  ASSERT_EQ(copy_sp->GetParent().get(), nullptr);
+  ASSERT_TRUE(copy_sp->OptionWasSet());
+  ASSERT_EQ(copy_sp->GetStringValue(), "ab");
+
+  // Trigger the callback.
+  copy_sp->SetValueFromString("c", eVarSetOperationAppend);
+  ASSERT_EQ(copy_sp->GetStringValue(), "abc");
+}
+
+// Test an aggregate class.
+TEST(OptionValueArgs, DeepCopy) {
+  OptionValueArgs args;
+  args.SetValueFromString("A B");
+
+  MockCallback callback;
+  args.SetValueChangedCallback([&callback] { callback(); });
+  EXPECT_CALL(callback, Invoke());
+
+  auto copy_sp = args.DeepCopy(nullptr);
+
+  // Test that the base class data members are copied/set correctly.
+  ASSERT_TRUE(copy_sp);
+  ASSERT_EQ(copy_sp->GetParent(), nullptr);
+  ASSERT_TRUE(copy_sp->Optio

[Lldb-commits] [PATCH] D96548: [lldb] [Process/FreeBSDRemote] Introduce aarch64 hw break/watchpoint support

2021-02-18 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha added a comment.

clang-tidy would not be happy;)




Comment at: lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp:665
+return SetHardwareBreakpoint(addr, size);
   else
 return SetSoftwareBreakpoint(addr, size);

Redundant `else` after `return`.



Comment at: 
lldb/source/Plugins/Process/Utility/NativeRegisterContextBreakWatchpoint_arm64.cpp:441
+return m_hwp_regs[wp_index].real_addr;
+  else
+return LLDB_INVALID_ADDRESS;

Redundant `else` after `return`.



Comment at: 
lldb/source/Plugins/Process/Utility/NativeRegisterContextBreakWatchpoint_arm64.cpp:456
+return m_hwp_regs[wp_index].hit_addr;
+  else
+return LLDB_INVALID_ADDRESS;

Redundant `else` after `return`.


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

https://reviews.llvm.org/D96548

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


[Lldb-commits] [PATCH] D96817: Fix deep copying for OptionValue classes

2021-02-18 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha added a comment.

I created D96817  - a demonstrative example of 
the CRTP-based version of this patch. Please, take a look.


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

https://reviews.llvm.org/D96817

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


[Lldb-commits] [PATCH] D96817: Fix deep copying for OptionValue classes

2021-02-17 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha updated this revision to Diff 324435.
tatyana-krasnukha added a comment.

Removed explicit conversions to StringRef from the test with respect to D96861 
.


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

https://reviews.llvm.org/D96817

Files:
  lldb/include/lldb/Interpreter/OptionValue.h
  lldb/include/lldb/Interpreter/OptionValueArch.h
  lldb/include/lldb/Interpreter/OptionValueArgs.h
  lldb/include/lldb/Interpreter/OptionValueArray.h
  lldb/include/lldb/Interpreter/OptionValueBoolean.h
  lldb/include/lldb/Interpreter/OptionValueChar.h
  lldb/include/lldb/Interpreter/OptionValueDictionary.h
  lldb/include/lldb/Interpreter/OptionValueEnumeration.h
  lldb/include/lldb/Interpreter/OptionValueFileColonLine.h
  lldb/include/lldb/Interpreter/OptionValueFileSpec.h
  lldb/include/lldb/Interpreter/OptionValueFileSpecList.h
  lldb/include/lldb/Interpreter/OptionValueFormat.h
  lldb/include/lldb/Interpreter/OptionValueFormatEntity.h
  lldb/include/lldb/Interpreter/OptionValueLanguage.h
  lldb/include/lldb/Interpreter/OptionValuePathMappings.h
  lldb/include/lldb/Interpreter/OptionValueProperties.h
  lldb/include/lldb/Interpreter/OptionValueRegex.h
  lldb/include/lldb/Interpreter/OptionValueSInt64.h
  lldb/include/lldb/Interpreter/OptionValueString.h
  lldb/include/lldb/Interpreter/OptionValueUInt64.h
  lldb/include/lldb/Interpreter/OptionValueUUID.h
  lldb/include/lldb/Target/Target.h
  lldb/source/Interpreter/OptionValue.cpp
  lldb/source/Interpreter/OptionValueArch.cpp
  lldb/source/Interpreter/OptionValueArgs.cpp
  lldb/source/Interpreter/OptionValueArray.cpp
  lldb/source/Interpreter/OptionValueBoolean.cpp
  lldb/source/Interpreter/OptionValueChar.cpp
  lldb/source/Interpreter/OptionValueDictionary.cpp
  lldb/source/Interpreter/OptionValueEnumeration.cpp
  lldb/source/Interpreter/OptionValueFileColonLine.cpp
  lldb/source/Interpreter/OptionValueFileSpec.cpp
  lldb/source/Interpreter/OptionValueFileSpecList.cpp
  lldb/source/Interpreter/OptionValueFormat.cpp
  lldb/source/Interpreter/OptionValueFormatEntity.cpp
  lldb/source/Interpreter/OptionValueLanguage.cpp
  lldb/source/Interpreter/OptionValuePathMappings.cpp
  lldb/source/Interpreter/OptionValueProperties.cpp
  lldb/source/Interpreter/OptionValueRegex.cpp
  lldb/source/Interpreter/OptionValueSInt64.cpp
  lldb/source/Interpreter/OptionValueString.cpp
  lldb/source/Interpreter/OptionValueUInt64.cpp
  lldb/source/Interpreter/OptionValueUUID.cpp
  lldb/source/Target/Process.cpp
  lldb/source/Target/Target.cpp
  lldb/source/Target/Thread.cpp
  lldb/test/API/commands/settings/TestSettings.py
  lldb/unittests/Interpreter/CMakeLists.txt
  lldb/unittests/Interpreter/TestOptionValue.cpp

Index: lldb/unittests/Interpreter/TestOptionValue.cpp
===
--- /dev/null
+++ lldb/unittests/Interpreter/TestOptionValue.cpp
@@ -0,0 +1,173 @@
+//===-- TestOptionValue.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "lldb/Interpreter/OptionValues.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+using namespace lldb_private;
+
+class Callback {
+public:
+  virtual void Invoke() const {}
+  void operator()() const { Invoke(); }
+};
+
+class MockCallback : public Callback {
+public:
+  MOCK_CONST_METHOD0(Invoke, void());
+};
+
+// Test a single-value class.
+TEST(OptionValueString, DeepCopy) {
+  OptionValueString str;
+  str.SetValueFromString("ab");
+
+  MockCallback callback;
+  str.SetValueChangedCallback([&callback] { callback(); });
+  EXPECT_CALL(callback, Invoke());
+
+  auto copy_sp = str.DeepCopy(nullptr);
+
+  // Test that the base class data members are copied/set correctly.
+  ASSERT_TRUE(copy_sp);
+  ASSERT_EQ(copy_sp->GetParent().get(), nullptr);
+  ASSERT_TRUE(copy_sp->OptionWasSet());
+  ASSERT_EQ(copy_sp->GetStringValue(), "ab");
+
+  // Trigger the callback.
+  copy_sp->SetValueFromString("c", eVarSetOperationAppend);
+  ASSERT_EQ(copy_sp->GetStringValue(), "abc");
+}
+
+// Test an aggregate class.
+TEST(OptionValueArgs, DeepCopy) {
+  OptionValueArgs args;
+  args.SetValueFromString("A B");
+
+  MockCallback callback;
+  args.SetValueChangedCallback([&callback] { callback(); });
+  EXPECT_CALL(callback, Invoke());
+
+  auto copy_sp = args.DeepCopy(nullptr);
+
+  // Test that the base class data members are copied/set correctly.
+  ASSERT_TRUE(copy_sp);
+  ASSERT_EQ(copy_sp->GetParent(), nullptr);
+  ASSERT_TRUE(copy_sp->OptionWasSet());
+
+  auto *args_copy_ptr = copy_sp->GetAsArgs();
+  ASSERT_EQ(args_copy_ptr->GetSize(), 2U);
+  ASSERT_EQ((*args_copy_ptr)[0]->GetParent(), copy_sp);
+  ASSERT_EQ((*args_copy_ptr)[0]->G

[Lldb-commits] [PATCH] D96817: Fix deep copying for OptionValue classes

2021-02-17 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha added a comment.

CRTP was my first implementation, however, I discarded it as more bug-prone. 
Virtual Clone function at the interface is so common that, I believe, everyone 
knows it must be overridden by a new derived class. The necessity of inheriting 
from base_clone_helper is not so obvious.




Comment at: lldb/unittests/Interpreter/TestOptionValue.cpp:173
+  // Trigger the callback second time.
+  file_list_copy_ptr->SetValueFromString(llvm::StringRef("0 another/path"),
+ eVarSetOperationReplace);

dblaikie wrote:
> Generally it shouldn't be necessary to write `llvm::StringRef(...)` around a 
> string literal - StringRef is implicitly convertible from a string literal.
OptionValueProperties and OptionValueFileSpecList enforce using StringRef 
explicitly by specifying the overload SetValueFromString(const char*) as 
deleted.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96817

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


[Lldb-commits] [PATCH] D96817: Fix deep copying for OptionValue classes

2021-02-16 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha created this revision.
tatyana-krasnukha added reviewers: clayborg, JDevlieghere, labath, teemperor.
tatyana-krasnukha added a project: LLDB.
Herald added a subscriber: mgorny.
tatyana-krasnukha requested review of this revision.
Herald added a subscriber: lldb-commits.

Some implementations of the DeepCopy function called the copy constructor that 
copied m_parent member instead of setting a new parent. Others just lived the 
base class's members (m_parent, m_callback, m_was_set) empty.
One more problem is that not all classes override this function, e.g. 
OptionValueArgs::DeepCopy produces OptionValueArray instance, and 
Target[Process/Thread]ValueProperty::DeepCopy produces OptionValueProperty. 
This makes downcasting via static_cast invalid.

This patch adds a virtual Clone function, which implements well-known idiom 
"virtual constructor", and overrides it in every derived class. DeepCopy calls 
Clone to instantiate an object of a correct type. It also sets valid m_parent.
Add a test that checks DeepCopy for correct copying/setting all data members of 
the base class.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96817

Files:
  lldb/include/lldb/Interpreter/OptionValue.h
  lldb/include/lldb/Interpreter/OptionValueArch.h
  lldb/include/lldb/Interpreter/OptionValueArgs.h
  lldb/include/lldb/Interpreter/OptionValueArray.h
  lldb/include/lldb/Interpreter/OptionValueBoolean.h
  lldb/include/lldb/Interpreter/OptionValueChar.h
  lldb/include/lldb/Interpreter/OptionValueDictionary.h
  lldb/include/lldb/Interpreter/OptionValueEnumeration.h
  lldb/include/lldb/Interpreter/OptionValueFileColonLine.h
  lldb/include/lldb/Interpreter/OptionValueFileSpec.h
  lldb/include/lldb/Interpreter/OptionValueFileSpecList.h
  lldb/include/lldb/Interpreter/OptionValueFormat.h
  lldb/include/lldb/Interpreter/OptionValueFormatEntity.h
  lldb/include/lldb/Interpreter/OptionValueLanguage.h
  lldb/include/lldb/Interpreter/OptionValuePathMappings.h
  lldb/include/lldb/Interpreter/OptionValueProperties.h
  lldb/include/lldb/Interpreter/OptionValueRegex.h
  lldb/include/lldb/Interpreter/OptionValueSInt64.h
  lldb/include/lldb/Interpreter/OptionValueString.h
  lldb/include/lldb/Interpreter/OptionValueUInt64.h
  lldb/include/lldb/Interpreter/OptionValueUUID.h
  lldb/include/lldb/Target/Target.h
  lldb/source/Interpreter/OptionValue.cpp
  lldb/source/Interpreter/OptionValueArch.cpp
  lldb/source/Interpreter/OptionValueArgs.cpp
  lldb/source/Interpreter/OptionValueArray.cpp
  lldb/source/Interpreter/OptionValueBoolean.cpp
  lldb/source/Interpreter/OptionValueChar.cpp
  lldb/source/Interpreter/OptionValueDictionary.cpp
  lldb/source/Interpreter/OptionValueEnumeration.cpp
  lldb/source/Interpreter/OptionValueFileColonLine.cpp
  lldb/source/Interpreter/OptionValueFileSpec.cpp
  lldb/source/Interpreter/OptionValueFileSpecList.cpp
  lldb/source/Interpreter/OptionValueFormat.cpp
  lldb/source/Interpreter/OptionValueFormatEntity.cpp
  lldb/source/Interpreter/OptionValueLanguage.cpp
  lldb/source/Interpreter/OptionValuePathMappings.cpp
  lldb/source/Interpreter/OptionValueProperties.cpp
  lldb/source/Interpreter/OptionValueRegex.cpp
  lldb/source/Interpreter/OptionValueSInt64.cpp
  lldb/source/Interpreter/OptionValueString.cpp
  lldb/source/Interpreter/OptionValueUInt64.cpp
  lldb/source/Interpreter/OptionValueUUID.cpp
  lldb/source/Target/Process.cpp
  lldb/source/Target/Target.cpp
  lldb/source/Target/Thread.cpp
  lldb/test/API/commands/settings/TestSettings.py
  lldb/unittests/Interpreter/CMakeLists.txt
  lldb/unittests/Interpreter/TestOptionValue.cpp

Index: lldb/unittests/Interpreter/TestOptionValue.cpp
===
--- /dev/null
+++ lldb/unittests/Interpreter/TestOptionValue.cpp
@@ -0,0 +1,175 @@
+//===-- TestOptionValue.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "lldb/Interpreter/OptionValues.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+using namespace lldb_private;
+
+class Callback {
+public:
+  virtual void Invoke() const {}
+  void operator()() const { Invoke(); }
+};
+
+class MockCallback : public Callback {
+public:
+  MOCK_CONST_METHOD0(Invoke, void());
+};
+
+// Test a single-value class.
+TEST(OptionValueString, DeepCopy) {
+  OptionValueString str;
+  str.SetValueFromString(llvm::StringRef("ab"));
+
+  MockCallback callback;
+  str.SetValueChangedCallback([&callback] { callback(); });
+  EXPECT_CALL(callback, Invoke());
+
+  auto copy_sp = str.DeepCopy(nullptr);
+
+  // Test that the base class data members are copied/set correctly.
+  ASSERT_TRUE(copy_sp);
+  ASSERT_EQ(copy_sp->GetParent().get(), nullptr);
+  

[Lldb-commits] [PATCH] D92164: Make CommandInterpreter's execution context the same as debugger's one.

2021-02-02 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha added a comment.

In D92164#2536036 , @werat wrote:

> I think your test case is even better, the one in D95761 
>  doesn't try to run commands.

Ok, then I'll replace it if you don't mind.


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

https://reviews.llvm.org/D92164

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


[Lldb-commits] [PATCH] D92164: Make CommandInterpreter's execution context the same as debugger's one.

2021-02-01 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha updated this revision to Diff 320560.
tatyana-krasnukha added a comment.

Removed test since the same case was added by D95761 
.


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

https://reviews.llvm.org/D92164

Files:
  lldb/include/lldb/Interpreter/CommandInterpreter.h
  lldb/source/API/SBCommandInterpreter.cpp
  lldb/source/Breakpoint/BreakpointOptions.cpp
  lldb/source/Commands/CommandObjectCommands.cpp
  lldb/source/Commands/CommandObjectExpression.cpp
  lldb/source/Commands/CommandObjectProcess.cpp
  lldb/source/Commands/CommandObjectRegexCommand.cpp
  lldb/source/Commands/CommandObjectSettings.cpp
  lldb/source/Commands/CommandObjectWatchpointCommand.cpp
  lldb/source/Core/Debugger.cpp
  lldb/source/Core/IOHandlerCursesGUI.cpp
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/source/Target/Target.cpp

Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -3349,7 +3349,7 @@
   // Force Async:
   bool old_async = debugger.GetAsyncExecution();
   debugger.SetAsyncExecution(true);
-  debugger.GetCommandInterpreter().HandleCommands(GetCommands(), &exc_ctx,
+  debugger.GetCommandInterpreter().HandleCommands(GetCommands(), exc_ctx,
   options, result);
   debugger.SetAsyncExecution(old_async);
   lldb::ReturnStatus status = result.GetStatus();
Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -76,6 +76,7 @@
 #include "lldb/Target/UnixSignals.h"
 
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/ScopeExit.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Support/FormatAdapters.h"
 #include "llvm/Support/Path.h"
@@ -1631,12 +1632,18 @@
 
 bool CommandInterpreter::HandleCommand(const char *command_line,
LazyBool lazy_add_to_history,
-   CommandReturnObject &result,
-   ExecutionContext *override_context,
-   bool repeat_on_empty_command,
-   bool no_context_switching)
+   const ExecutionContext &override_context,
+   CommandReturnObject &result) {
+
+  OverrideExecutionContext(override_context);
+  bool status = HandleCommand(command_line, lazy_add_to_history, result);
+  RestoreExecutionContext();
+  return status;
+}
 
-{
+bool CommandInterpreter::HandleCommand(const char *command_line,
+   LazyBool lazy_add_to_history,
+   CommandReturnObject &result) {
 
   std::string command_string(command_line);
   std::string original_command_string(command_line);
@@ -1648,9 +1655,6 @@
   LLDB_LOGF(log, "Processing command: %s", command_line);
   LLDB_SCOPED_TIMERF("Processing command: %s.", command_line);
 
-  if (!no_context_switching)
-UpdateExecutionContext(override_context);
-
   if (WasInterrupted()) {
 result.AppendError("interrupted");
 result.SetStatus(eReturnStatusFailed);
@@ -1696,26 +1700,22 @@
   }
 
   if (empty_command) {
-if (repeat_on_empty_command) {
-  if (m_command_history.IsEmpty()) {
-result.AppendError("empty command");
-result.SetStatus(eReturnStatusFailed);
-return false;
-  } else {
-command_line = m_repeat_command.c_str();
-command_string = command_line;
-original_command_string = command_line;
-if (m_repeat_command.empty()) {
-  result.AppendError("No auto repeat.");
-  result.SetStatus(eReturnStatusFailed);
-  return false;
-}
-  }
-  add_to_history = false;
-} else {
-  result.SetStatus(eReturnStatusSuccessFinishNoResult);
-  return true;
+if (m_command_history.IsEmpty()) {
+  result.AppendError("empty command");
+  result.SetStatus(eReturnStatusFailed);
+  return false;
+}
+
+command_line = m_repeat_command.c_str();
+command_string = command_line;
+original_command_string = command_line;
+if (m_repeat_command.empty()) {
+  result.AppendError("No auto repeat.");
+  result.SetStatus(eReturnStatusFailed);
+  return false;
 }
+
+add_to_history = false;
   } else if (comment_command) {
 result.SetStatus(eReturnStatusSuccessFinishNoResult);
 return true;
@@ -1852,8 +1852,6 @@
 
 void CommandInterpreter::HandleCompletion(CompletionRequest &request) {
 
-  UpdateExecutionContext(nullptr);
-
   // Don't complete comments, and if the line we are completing is just the
   // history repeat character, substitute the appropriate history line.
   llvm::StringRef fi

[Lldb-commits] [PATCH] D92164: Make CommandInterpreter's execution context the same as debugger's one.

2021-02-01 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha updated this revision to Diff 320548.
tatyana-krasnukha edited the summary of this revision.
tatyana-krasnukha added a comment.

It turns out that the Debugger recalculated the selected stack frame without 
taking the Process's run lock. I replaced the whole context evaluation with 
creating ExecutionContextRef which does these things right.

@labath, I would appreciate it if you check that the latest version works for 
you too (I ran TestGuiBasicDebug.py 100 times on Linux and it succeeded all the 
time).


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

https://reviews.llvm.org/D92164

Files:
  lldb/include/lldb/Interpreter/CommandInterpreter.h
  lldb/source/API/SBCommandInterpreter.cpp
  lldb/source/Breakpoint/BreakpointOptions.cpp
  lldb/source/Commands/CommandObjectCommands.cpp
  lldb/source/Commands/CommandObjectExpression.cpp
  lldb/source/Commands/CommandObjectProcess.cpp
  lldb/source/Commands/CommandObjectRegexCommand.cpp
  lldb/source/Commands/CommandObjectSettings.cpp
  lldb/source/Commands/CommandObjectWatchpointCommand.cpp
  lldb/source/Core/Debugger.cpp
  lldb/source/Core/IOHandlerCursesGUI.cpp
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/source/Target/Target.cpp
  lldb/test/API/python_api/debugger/Makefile
  lldb/test/API/python_api/debugger/TestDebuggerAPI.py
  lldb/test/API/python_api/debugger/main.cpp

Index: lldb/test/API/python_api/debugger/main.cpp
===
--- /dev/null
+++ lldb/test/API/python_api/debugger/main.cpp
@@ -0,0 +1,9 @@
+// This simple program is to test the lldb Python API SBDebugger.
+
+int func(int val) {
+return val - 1;
+}
+
+int main (int argc, char const *argv[]) {
+return func(argc);
+}
Index: lldb/test/API/python_api/debugger/TestDebuggerAPI.py
===
--- lldb/test/API/python_api/debugger/TestDebuggerAPI.py
+++ lldb/test/API/python_api/debugger/TestDebuggerAPI.py
@@ -43,3 +43,54 @@
 target = lldb.SBTarget()
 self.assertFalse(target.IsValid())
 self.dbg.DeleteTarget(target)
+
+def test_debugger_internal_variable(self):
+"""Ensure that SBDebugger reachs the same instance of properties
+   regardless CommandInterpreter's context initialization"""
+self.build()
+exe = self.getBuildArtifact("a.out")
+
+# Create a target by the debugger.
+target = self.dbg.CreateTarget(exe)
+self.assertTrue(target, VALID_TARGET)
+
+property_name = "target.process.memory-cache-line-size"
+
+def get_cache_line_size():
+value_list = lldb.SBStringList()
+value_list = self.dbg.GetInternalVariableValue(property_name,
+   self.dbg.GetInstanceName())
+
+self.assertEqual(value_list.GetSize(), 1)
+try:
+return int(value_list.GetStringAtIndex(0))
+except ValueError as error:
+self.fail("Value is not a number: " + error)
+
+# Get global property value while there are no processes.
+global_cache_line_size = get_cache_line_size()
+
+# Run a process via SB interface. CommandInterpreter's execution context
+# remains empty.
+error = lldb.SBError()
+launch_info = lldb.SBLaunchInfo(None)
+launch_info.SetLaunchFlags(lldb.eLaunchFlagStopAtEntry)
+process = target.Launch(launch_info, error)
+self.assertTrue(process, PROCESS_IS_VALID)
+
+# This should change the value of a process's local property.
+new_cache_line_size = global_cache_line_size + 512
+error = self.dbg.SetInternalVariable(property_name,
+ str(new_cache_line_size),
+ self.dbg.GetInstanceName())
+self.assertTrue(error.Success(),
+property_name + " value was changed successfully")
+
+# Check that it was set actually.
+self.assertEqual(get_cache_line_size(), new_cache_line_size)
+
+# Run any command to initialize CommandInterpreter's execution context.
+self.runCmd("target list")
+
+# Test the local property again, is it set to new_cache_line_size?
+self.assertEqual(get_cache_line_size(), new_cache_line_size)
Index: lldb/test/API/python_api/debugger/Makefile
===
--- /dev/null
+++ lldb/test/API/python_api/debugger/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -3351,7 +3351,7 @@
   // Force Async:
   bool old_async = debugger.GetAsyncExecution();
   debugger.SetAsyncExecution(true);
-  debugger.GetCommandInter

[Lldb-commits] [PATCH] D94997: [lldb][lldb-vscode] Updated implementation of 'launch' and 'attach' requests to not create auxiliary target in case "launchCommands" and "attachCommands" are provided.

2021-01-20 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha added a comment.

D92164  was intended for fixing the "settings 
set" issue, however, it revealed some deadlocks and data races, and had to be 
reverted temporarily. Currently, I'm working on those multithreading issues and 
will submit a patch as soon as possible.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94997

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


[Lldb-commits] [PATCH] D92164: Make CommandInterpreter's execution context the same as debugger's one.

2020-12-19 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha added a comment.

In D92164#2463734 , @labath wrote:

> With this version of the patch, I am unable to reproduce the issue using the 
> approach I described in the previous comment. However, it still reproduces 
> when issuing the equivalent commands via the "gui" (either "by hand" or by 
> running TestGuiBasicDebug.py).

Could you send logs, please? I cannot reproduce the issue on available 
platforms.


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

https://reviews.llvm.org/D92164

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


[Lldb-commits] [PATCH] D92164: Make CommandInterpreter's execution context the same as debugger's one.

2020-12-18 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha updated this revision to Diff 312770.
tatyana-krasnukha added a comment.

Fixed CommandInterpreter::GetProcessOutput to avoid deadlock in Windows process 
plugin. This should also fix the problem @labath described above.

Pavel, could you please check whether it works for you?


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

https://reviews.llvm.org/D92164

Files:
  lldb/include/lldb/Interpreter/CommandInterpreter.h
  lldb/source/API/SBCommandInterpreter.cpp
  lldb/source/Breakpoint/BreakpointOptions.cpp
  lldb/source/Commands/CommandObjectCommands.cpp
  lldb/source/Commands/CommandObjectExpression.cpp
  lldb/source/Commands/CommandObjectProcess.cpp
  lldb/source/Commands/CommandObjectRegexCommand.cpp
  lldb/source/Commands/CommandObjectSettings.cpp
  lldb/source/Commands/CommandObjectWatchpointCommand.cpp
  lldb/source/Core/IOHandlerCursesGUI.cpp
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/source/Target/Target.cpp
  lldb/test/API/python_api/debugger/Makefile
  lldb/test/API/python_api/debugger/TestDebuggerAPI.py
  lldb/test/API/python_api/debugger/main.cpp

Index: lldb/test/API/python_api/debugger/main.cpp
===
--- /dev/null
+++ lldb/test/API/python_api/debugger/main.cpp
@@ -0,0 +1,9 @@
+// This simple program is to test the lldb Python API SBDebugger.
+
+int func(int val) {
+return val - 1;
+}
+
+int main (int argc, char const *argv[]) {
+return func(argc);
+}
Index: lldb/test/API/python_api/debugger/TestDebuggerAPI.py
===
--- lldb/test/API/python_api/debugger/TestDebuggerAPI.py
+++ lldb/test/API/python_api/debugger/TestDebuggerAPI.py
@@ -43,3 +43,54 @@
 target = lldb.SBTarget()
 self.assertFalse(target.IsValid())
 self.dbg.DeleteTarget(target)
+
+def test_debugger_internal_variable(self):
+"""Ensure that SBDebugger reachs the same instance of properties
+   regardless CommandInterpreter's context initialization"""
+self.build()
+exe = self.getBuildArtifact("a.out")
+
+# Create a target by the debugger.
+target = self.dbg.CreateTarget(exe)
+self.assertTrue(target, VALID_TARGET)
+
+property_name = "target.process.memory-cache-line-size"
+
+def get_cache_line_size():
+value_list = lldb.SBStringList()
+value_list = self.dbg.GetInternalVariableValue(property_name,
+   self.dbg.GetInstanceName())
+
+self.assertEqual(value_list.GetSize(), 1)
+try:
+return int(value_list.GetStringAtIndex(0))
+except ValueError as error:
+self.fail("Value is not a number: " + error)
+
+# Get global property value while there are no processes.
+global_cache_line_size = get_cache_line_size()
+
+# Run a process via SB interface. CommandInterpreter's execution context
+# remains empty.
+error = lldb.SBError()
+launch_info = lldb.SBLaunchInfo(None)
+launch_info.SetLaunchFlags(lldb.eLaunchFlagStopAtEntry)
+process = target.Launch(launch_info, error)
+self.assertTrue(process, PROCESS_IS_VALID)
+
+# This should change the value of a process's local property.
+new_cache_line_size = global_cache_line_size + 512
+error = self.dbg.SetInternalVariable(property_name,
+ str(new_cache_line_size),
+ self.dbg.GetInstanceName())
+self.assertTrue(error.Success(),
+property_name + " value was changed successfully")
+
+# Check that it was set actually.
+self.assertEqual(get_cache_line_size(), new_cache_line_size)
+
+# Run any command to initialize CommandInterpreter's execution context.
+self.runCmd("target list")
+
+# Test the local property again, is it set to new_cache_line_size?
+self.assertEqual(get_cache_line_size(), new_cache_line_size)
Index: lldb/test/API/python_api/debugger/Makefile
===
--- /dev/null
+++ lldb/test/API/python_api/debugger/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -3351,7 +3351,7 @@
   // Force Async:
   bool old_async = debugger.GetAsyncExecution();
   debugger.SetAsyncExecution(true);
-  debugger.GetCommandInterpreter().HandleCommands(GetCommands(), &exc_ctx,
+  debugger.GetCommandInterpreter().HandleCommands(GetCommands(), exc_ctx,
   options, result);
   debugger.SetAsyncExecution(old_async);
   lldb::ReturnStatus status = 

[Lldb-commits] [PATCH] D92164: Make CommandInterpreter's execution context the same as debugger's one.

2020-12-12 Thread Tatyana Krasnukha via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa01b26fb51c7: [lldb] Make CommandInterpreter's 
execution context the same as debugger's one. (authored by 
tatyana-krasnukha).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92164

Files:
  lldb/include/lldb/Interpreter/CommandInterpreter.h
  lldb/source/API/SBCommandInterpreter.cpp
  lldb/source/Breakpoint/BreakpointOptions.cpp
  lldb/source/Commands/CommandObjectCommands.cpp
  lldb/source/Commands/CommandObjectExpression.cpp
  lldb/source/Commands/CommandObjectProcess.cpp
  lldb/source/Commands/CommandObjectRegexCommand.cpp
  lldb/source/Commands/CommandObjectSettings.cpp
  lldb/source/Commands/CommandObjectWatchpointCommand.cpp
  lldb/source/Core/IOHandlerCursesGUI.cpp
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/source/Target/Target.cpp
  lldb/test/API/python_api/debugger/Makefile
  lldb/test/API/python_api/debugger/TestDebuggerAPI.py
  lldb/test/API/python_api/debugger/main.cpp

Index: lldb/test/API/python_api/debugger/main.cpp
===
--- /dev/null
+++ lldb/test/API/python_api/debugger/main.cpp
@@ -0,0 +1,9 @@
+// This simple program is to test the lldb Python API SBDebugger.
+
+int func(int val) {
+return val - 1;
+}
+
+int main (int argc, char const *argv[]) {
+return func(argc);
+}
Index: lldb/test/API/python_api/debugger/TestDebuggerAPI.py
===
--- lldb/test/API/python_api/debugger/TestDebuggerAPI.py
+++ lldb/test/API/python_api/debugger/TestDebuggerAPI.py
@@ -43,3 +43,54 @@
 target = lldb.SBTarget()
 self.assertFalse(target.IsValid())
 self.dbg.DeleteTarget(target)
+
+def test_debugger_internal_variable(self):
+"""Ensure that SBDebugger reachs the same instance of properties
+   regardless CommandInterpreter's context initialization"""
+self.build()
+exe = self.getBuildArtifact("a.out")
+
+# Create a target by the debugger.
+target = self.dbg.CreateTarget(exe)
+self.assertTrue(target, VALID_TARGET)
+
+property_name = "target.process.memory-cache-line-size"
+
+def get_cache_line_size():
+value_list = lldb.SBStringList()
+value_list = self.dbg.GetInternalVariableValue(property_name,
+   self.dbg.GetInstanceName())
+
+self.assertEqual(value_list.GetSize(), 1)
+try:
+return int(value_list.GetStringAtIndex(0))
+except ValueError as error:
+self.fail("Value is not a number: " + error)
+
+# Get global property value while there are no processes.
+global_cache_line_size = get_cache_line_size()
+
+# Run a process via SB interface. CommandInterpreter's execution context
+# remains empty.
+error = lldb.SBError()
+launch_info = lldb.SBLaunchInfo(None)
+launch_info.SetLaunchFlags(lldb.eLaunchFlagStopAtEntry)
+process = target.Launch(launch_info, error)
+self.assertTrue(process, PROCESS_IS_VALID)
+
+# This should change the value of a process's local property.
+new_cache_line_size = global_cache_line_size + 512
+error = self.dbg.SetInternalVariable(property_name,
+ str(new_cache_line_size),
+ self.dbg.GetInstanceName())
+self.assertTrue(error.Success(),
+property_name + " value was changed successfully")
+
+# Check that it was set actually.
+self.assertEqual(get_cache_line_size(), new_cache_line_size)
+
+# Run any command to initialize CommandInterpreter's execution context.
+self.runCmd("target list")
+
+# Test the local property again, is it set to new_cache_line_size?
+self.assertEqual(get_cache_line_size(), new_cache_line_size)
Index: lldb/test/API/python_api/debugger/Makefile
===
--- /dev/null
+++ lldb/test/API/python_api/debugger/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -3351,7 +3351,7 @@
   // Force Async:
   bool old_async = debugger.GetAsyncExecution();
   debugger.SetAsyncExecution(true);
-  debugger.GetCommandInterpreter().HandleCommands(GetCommands(), &exc_ctx,
+  debugger.GetCommandInterpreter().HandleCommands(GetCommands(), exc_ctx,
   options, result);
   debugger.SetAsyncExecution(old_async);
   lldb::ReturnStatus status = result.GetStatus();
Index: lldb/sourc

[Lldb-commits] [PATCH] D93052: "target create" shouldn't save target if the command failed

2020-12-12 Thread Tatyana Krasnukha via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2634ec6ce900: [lldb] "target create" 
shouldn't save target if the command failed (authored by 
tatyana-krasnukha).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93052

Files:
  lldb/include/lldb/Target/TargetList.h
  lldb/source/API/SBDebugger.cpp
  lldb/source/Commands/CommandObjectProcess.cpp
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
  lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
  lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
  lldb/source/Target/Platform.cpp
  lldb/source/Target/TargetList.cpp
  lldb/source/Target/TraceSessionFileParser.cpp
  lldb/unittests/Process/ProcessEventDataTest.cpp
  lldb/unittests/Thread/ThreadTest.cpp

Index: lldb/unittests/Thread/ThreadTest.cpp
===
--- lldb/unittests/Thread/ThreadTest.cpp
+++ lldb/unittests/Thread/ThreadTest.cpp
@@ -83,16 +83,11 @@
 } // namespace
 
 TargetSP CreateTarget(DebuggerSP &debugger_sp, ArchSpec &arch) {
-  Status error;
   PlatformSP platform_sp;
   TargetSP target_sp;
-  error = debugger_sp->GetTargetList().CreateTarget(
+  debugger_sp->GetTargetList().CreateTarget(
   *debugger_sp, "", arch, eLoadDependentsNo, platform_sp, target_sp);
 
-  if (target_sp) {
-debugger_sp->GetTargetList().SetSelectedTarget(target_sp.get());
-  }
-
   return target_sp;
 }
 
Index: lldb/unittests/Process/ProcessEventDataTest.cpp
===
--- lldb/unittests/Process/ProcessEventDataTest.cpp
+++ lldb/unittests/Process/ProcessEventDataTest.cpp
@@ -112,16 +112,11 @@
 typedef std::shared_ptr EventSP;
 
 TargetSP CreateTarget(DebuggerSP &debugger_sp, ArchSpec &arch) {
-  Status error;
   PlatformSP platform_sp;
   TargetSP target_sp;
-  error = debugger_sp->GetTargetList().CreateTarget(
+  debugger_sp->GetTargetList().CreateTarget(
   *debugger_sp, "", arch, eLoadDependentsNo, platform_sp, target_sp);
 
-  if (target_sp) {
-debugger_sp->GetTargetList().SetSelectedTarget(target_sp.get());
-  }
-
   return target_sp;
 }
 
Index: lldb/source/Target/TraceSessionFileParser.cpp
===
--- lldb/source/Target/TraceSessionFileParser.cpp
+++ lldb/source/Target/TraceSessionFileParser.cpp
@@ -123,8 +123,6 @@
   ParsedProcess parsed_process;
   parsed_process.target_sp = target_sp;
 
-  m_debugger.GetTargetList().SetSelectedTarget(target_sp.get());
-
   ProcessSP process_sp = target_sp->CreateProcess(
   /*listener*/ nullptr, "trace",
   /*crash_file*/ nullptr,
Index: lldb/source/Target/TargetList.cpp
===
--- lldb/source/Target/TargetList.cpp
+++ lldb/source/Target/TargetList.cpp
@@ -48,9 +48,13 @@
 LoadDependentFiles load_dependent_files,
 const OptionGroupPlatform *platform_options,
 TargetSP &target_sp) {
-  return CreateTargetInternal(debugger, user_exe_path, triple_str,
-  load_dependent_files, platform_options,
-  target_sp);
+  auto result = TargetList::CreateTargetInternal(
+  debugger, user_exe_path, triple_str, load_dependent_files,
+  platform_options, target_sp);
+
+  if (target_sp && result.Success())
+AddTargetInternal(target_sp, /*do_select*/ true);
+  return result;
 }
 
 Status TargetList::CreateTarget(Debugger &debugger,
@@ -58,8 +62,13 @@
 const ArchSpec &specified_arch,
 LoadDependentFiles load_dependent_files,
 PlatformSP &platform_sp, TargetSP &target_sp) {
-  return CreateTargetInternal(debugger, user_exe_path, specified_arch,
-  load_dependent_files, platform_sp, target_sp);
+  auto result = TargetList::CreateTargetInternal(
+  debugger, user_exe_path, specified_arch, load_dependent_files,
+  platform_sp, target_sp);
+
+  if (target_sp && result.Success())
+AddTargetInternal(target_sp, /*do_select*/ true);
+  return result;
 }
 
 Status TargetList::CreateTargetInternal(
@@ -388,9 +397,6 @@
 target_sp->AppendExecutableSearchPaths(file_dir);
   }
 
-  std::lock_guard guard(m_target_list_mutex);
-  m_selected_target_idx = m_target_list.size();
-  m_target_list.push_back(target_sp);
   // Now prime this from the dummy target:
   target_sp->PrimeFromDummyTarget(debugger.GetDummyTarget());
 
@@ -552,18 +558,29 @@
   return UINT32_MAX;
 }
 
-uint32_t TargetList::SetSelectedTarget(Target *target) {
+void TargetList::AddTargetInternal(TargetSP target_sp, bool do_select) {
+  lldbassert(std::find(m_target_list.begin(), m_target_list.end(),

[Lldb-commits] [PATCH] D93052: "target create" shouldn't save target if the command failed

2020-12-11 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha updated this revision to Diff 311128.
tatyana-krasnukha added a comment.

Removed `do_select`'s default value.


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

https://reviews.llvm.org/D93052

Files:
  lldb/include/lldb/Target/TargetList.h
  lldb/source/API/SBDebugger.cpp
  lldb/source/Commands/CommandObjectProcess.cpp
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
  lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
  lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
  lldb/source/Target/Platform.cpp
  lldb/source/Target/TargetList.cpp
  lldb/source/Target/TraceSessionFileParser.cpp
  lldb/unittests/Process/ProcessEventDataTest.cpp
  lldb/unittests/Thread/ThreadTest.cpp

Index: lldb/unittests/Thread/ThreadTest.cpp
===
--- lldb/unittests/Thread/ThreadTest.cpp
+++ lldb/unittests/Thread/ThreadTest.cpp
@@ -83,16 +83,11 @@
 } // namespace
 
 TargetSP CreateTarget(DebuggerSP &debugger_sp, ArchSpec &arch) {
-  Status error;
   PlatformSP platform_sp;
   TargetSP target_sp;
-  error = debugger_sp->GetTargetList().CreateTarget(
+  debugger_sp->GetTargetList().CreateTarget(
   *debugger_sp, "", arch, eLoadDependentsNo, platform_sp, target_sp);
 
-  if (target_sp) {
-debugger_sp->GetTargetList().SetSelectedTarget(target_sp.get());
-  }
-
   return target_sp;
 }
 
Index: lldb/unittests/Process/ProcessEventDataTest.cpp
===
--- lldb/unittests/Process/ProcessEventDataTest.cpp
+++ lldb/unittests/Process/ProcessEventDataTest.cpp
@@ -111,16 +111,11 @@
 typedef std::shared_ptr EventSP;
 
 TargetSP CreateTarget(DebuggerSP &debugger_sp, ArchSpec &arch) {
-  Status error;
   PlatformSP platform_sp;
   TargetSP target_sp;
-  error = debugger_sp->GetTargetList().CreateTarget(
+  debugger_sp->GetTargetList().CreateTarget(
   *debugger_sp, "", arch, eLoadDependentsNo, platform_sp, target_sp);
 
-  if (target_sp) {
-debugger_sp->GetTargetList().SetSelectedTarget(target_sp.get());
-  }
-
   return target_sp;
 }
 
Index: lldb/source/Target/TraceSessionFileParser.cpp
===
--- lldb/source/Target/TraceSessionFileParser.cpp
+++ lldb/source/Target/TraceSessionFileParser.cpp
@@ -123,8 +123,6 @@
   ParsedProcess parsed_process;
   parsed_process.target_sp = target_sp;
 
-  m_debugger.GetTargetList().SetSelectedTarget(target_sp.get());
-
   ProcessSP process_sp = target_sp->CreateProcess(
   /*listener*/ nullptr, "trace",
   /*crash_file*/ nullptr,
Index: lldb/source/Target/TargetList.cpp
===
--- lldb/source/Target/TargetList.cpp
+++ lldb/source/Target/TargetList.cpp
@@ -48,9 +48,13 @@
 LoadDependentFiles load_dependent_files,
 const OptionGroupPlatform *platform_options,
 TargetSP &target_sp) {
-  return CreateTargetInternal(debugger, user_exe_path, triple_str,
-  load_dependent_files, platform_options,
-  target_sp);
+  auto result = TargetList::CreateTargetInternal(
+  debugger, user_exe_path, triple_str, load_dependent_files,
+  platform_options, target_sp);
+
+  if (target_sp && result.Success())
+AddTargetInternal(target_sp, /*do_select*/ true);
+  return result;
 }
 
 Status TargetList::CreateTarget(Debugger &debugger,
@@ -58,8 +62,13 @@
 const ArchSpec &specified_arch,
 LoadDependentFiles load_dependent_files,
 PlatformSP &platform_sp, TargetSP &target_sp) {
-  return CreateTargetInternal(debugger, user_exe_path, specified_arch,
-  load_dependent_files, platform_sp, target_sp);
+  auto result = TargetList::CreateTargetInternal(
+  debugger, user_exe_path, specified_arch, load_dependent_files,
+  platform_sp, target_sp);
+
+  if (target_sp && result.Success())
+AddTargetInternal(target_sp, /*do_select*/ true);
+  return result;
 }
 
 Status TargetList::CreateTargetInternal(
@@ -388,9 +397,6 @@
 target_sp->AppendExecutableSearchPaths(file_dir);
   }
 
-  std::lock_guard guard(m_target_list_mutex);
-  m_selected_target_idx = m_target_list.size();
-  m_target_list.push_back(target_sp);
   // Now prime this from the dummy target:
   target_sp->PrimeFromDummyTarget(debugger.GetDummyTarget());
 
@@ -552,18 +558,29 @@
   return UINT32_MAX;
 }
 
-uint32_t TargetList::SetSelectedTarget(Target *target) {
+void TargetList::AddTargetInternal(TargetSP target_sp, bool do_select) {
+  lldbassert(std::find(m_target_list.begin(), m_target_list.end(), target_sp) ==
+ m_target_list.end() &&
+ "target already exists it the list");
+  m_targe

[Lldb-commits] [PATCH] D92164: Make CommandInterpreter's execution context the same as debugger's one.

2020-12-10 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha updated this revision to Diff 31.
tatyana-krasnukha added a comment.

Thanks for pointing to the nested command problem! Replaced pointer to the 
execution context with the stack of contexts.


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

https://reviews.llvm.org/D92164

Files:
  lldb/include/lldb/Interpreter/CommandInterpreter.h
  lldb/source/API/SBCommandInterpreter.cpp
  lldb/source/Breakpoint/BreakpointOptions.cpp
  lldb/source/Commands/CommandObjectCommands.cpp
  lldb/source/Commands/CommandObjectExpression.cpp
  lldb/source/Commands/CommandObjectProcess.cpp
  lldb/source/Commands/CommandObjectRegexCommand.cpp
  lldb/source/Commands/CommandObjectSettings.cpp
  lldb/source/Commands/CommandObjectWatchpointCommand.cpp
  lldb/source/Core/IOHandlerCursesGUI.cpp
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/source/Target/Target.cpp
  lldb/test/API/python_api/debugger/Makefile
  lldb/test/API/python_api/debugger/TestDebuggerAPI.py
  lldb/test/API/python_api/debugger/main.cpp

Index: lldb/test/API/python_api/debugger/main.cpp
===
--- /dev/null
+++ lldb/test/API/python_api/debugger/main.cpp
@@ -0,0 +1,9 @@
+// This simple program is to test the lldb Python API SBDebugger.
+
+int func(int val) {
+return val - 1;
+}
+
+int main (int argc, char const *argv[]) {
+return func(argc);
+}
Index: lldb/test/API/python_api/debugger/TestDebuggerAPI.py
===
--- lldb/test/API/python_api/debugger/TestDebuggerAPI.py
+++ lldb/test/API/python_api/debugger/TestDebuggerAPI.py
@@ -43,3 +43,54 @@
 target = lldb.SBTarget()
 self.assertFalse(target.IsValid())
 self.dbg.DeleteTarget(target)
+
+def test_debugger_internal_variable(self):
+"""Ensure that SBDebugger reachs the same instance of properties
+   regardless CommandInterpreter's context initialization"""
+self.build()
+exe = self.getBuildArtifact("a.out")
+
+# Create a target by the debugger.
+target = self.dbg.CreateTarget(exe)
+self.assertTrue(target, VALID_TARGET)
+
+property_name = "target.process.memory-cache-line-size"
+
+def get_cache_line_size():
+value_list = lldb.SBStringList()
+value_list = self.dbg.GetInternalVariableValue(property_name,
+   self.dbg.GetInstanceName())
+
+self.assertEqual(value_list.GetSize(), 1)
+try:
+return int(value_list.GetStringAtIndex(0))
+except ValueError as error:
+self.fail("Value is not a number: " + error)
+
+# Get global property value while there are no processes.
+global_cache_line_size = get_cache_line_size()
+
+# Run a process via SB interface. CommandInterpreter's execution context
+# remains empty.
+error = lldb.SBError()
+launch_info = lldb.SBLaunchInfo(None)
+launch_info.SetLaunchFlags(lldb.eLaunchFlagStopAtEntry)
+process = target.Launch(launch_info, error)
+self.assertTrue(process, PROCESS_IS_VALID)
+
+# This should change the value of a process's local property.
+new_cache_line_size = global_cache_line_size + 512
+error = self.dbg.SetInternalVariable(property_name,
+ str(new_cache_line_size),
+ self.dbg.GetInstanceName())
+self.assertTrue(error.Success(),
+property_name + " value was changed successfully")
+
+# Check that it was set actually.
+self.assertEqual(get_cache_line_size(), new_cache_line_size)
+
+# Run any command to initialize CommandInterpreter's execution context.
+self.runCmd("target list")
+
+# Test the local property again, is it set to new_cache_line_size?
+self.assertEqual(get_cache_line_size(), new_cache_line_size)
Index: lldb/test/API/python_api/debugger/Makefile
===
--- /dev/null
+++ lldb/test/API/python_api/debugger/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -3351,7 +3351,7 @@
   // Force Async:
   bool old_async = debugger.GetAsyncExecution();
   debugger.SetAsyncExecution(true);
-  debugger.GetCommandInterpreter().HandleCommands(GetCommands(), &exc_ctx,
+  debugger.GetCommandInterpreter().HandleCommands(GetCommands(), exc_ctx,
   options, result);
   debugger.SetAsyncExecution(old_async);
   lldb::ReturnStatus status = result.GetStatus();
Index: lldb/source/Interpreter/CommandInterpreter.cpp

[Lldb-commits] [PATCH] D93052: "target create" shouldn't save target if the command failed

2020-12-10 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha created this revision.
tatyana-krasnukha added reviewers: clayborg, JDevlieghere, jingham, teemperor.
tatyana-krasnukha added a project: LLDB.
Herald added a subscriber: emaste.
tatyana-krasnukha requested review of this revision.
Herald added a subscriber: lldb-commits.

TargetList::CreateTarget automatically adds created target to the list, 
however, CommandObjectTargetCreate does some additional preparation after 
creating a target and which can fail.
The command should remove the created target if it failed. Since the function 
has many ways to return, scope guard does this safer.

Changes to the TargetList make target adding and selection more transparent by 
splitting CreateTarget into two parts: creation and adding to the list.

Other changes remove unnecessary SetSelectedTarget calls after CreateTarget.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93052

Files:
  lldb/include/lldb/Target/TargetList.h
  lldb/source/API/SBDebugger.cpp
  lldb/source/Commands/CommandObjectProcess.cpp
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
  lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
  lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
  lldb/source/Target/Platform.cpp
  lldb/source/Target/TargetList.cpp
  lldb/source/Target/TraceSessionFileParser.cpp
  lldb/unittests/Process/ProcessEventDataTest.cpp
  lldb/unittests/Thread/ThreadTest.cpp

Index: lldb/unittests/Thread/ThreadTest.cpp
===
--- lldb/unittests/Thread/ThreadTest.cpp
+++ lldb/unittests/Thread/ThreadTest.cpp
@@ -83,16 +83,11 @@
 } // namespace
 
 TargetSP CreateTarget(DebuggerSP &debugger_sp, ArchSpec &arch) {
-  Status error;
   PlatformSP platform_sp;
   TargetSP target_sp;
-  error = debugger_sp->GetTargetList().CreateTarget(
+  debugger_sp->GetTargetList().CreateTarget(
   *debugger_sp, "", arch, eLoadDependentsNo, platform_sp, target_sp);
 
-  if (target_sp) {
-debugger_sp->GetTargetList().SetSelectedTarget(target_sp.get());
-  }
-
   return target_sp;
 }
 
Index: lldb/unittests/Process/ProcessEventDataTest.cpp
===
--- lldb/unittests/Process/ProcessEventDataTest.cpp
+++ lldb/unittests/Process/ProcessEventDataTest.cpp
@@ -111,16 +111,11 @@
 typedef std::shared_ptr EventSP;
 
 TargetSP CreateTarget(DebuggerSP &debugger_sp, ArchSpec &arch) {
-  Status error;
   PlatformSP platform_sp;
   TargetSP target_sp;
-  error = debugger_sp->GetTargetList().CreateTarget(
+  debugger_sp->GetTargetList().CreateTarget(
   *debugger_sp, "", arch, eLoadDependentsNo, platform_sp, target_sp);
 
-  if (target_sp) {
-debugger_sp->GetTargetList().SetSelectedTarget(target_sp.get());
-  }
-
   return target_sp;
 }
 
Index: lldb/source/Target/TraceSessionFileParser.cpp
===
--- lldb/source/Target/TraceSessionFileParser.cpp
+++ lldb/source/Target/TraceSessionFileParser.cpp
@@ -123,8 +123,6 @@
   ParsedProcess parsed_process;
   parsed_process.target_sp = target_sp;
 
-  m_debugger.GetTargetList().SetSelectedTarget(target_sp.get());
-
   ProcessSP process_sp = target_sp->CreateProcess(
   /*listener*/ nullptr, "trace",
   /*crash_file*/ nullptr,
Index: lldb/source/Target/TargetList.cpp
===
--- lldb/source/Target/TargetList.cpp
+++ lldb/source/Target/TargetList.cpp
@@ -48,9 +48,12 @@
 LoadDependentFiles load_dependent_files,
 const OptionGroupPlatform *platform_options,
 TargetSP &target_sp) {
-  return CreateTargetInternal(debugger, user_exe_path, triple_str,
-  load_dependent_files, platform_options,
-  target_sp);
+  auto result = TargetList::CreateTargetInternal(debugger, user_exe_path,
+  triple_str, load_dependent_files, platform_options, target_sp);
+
+  if (target_sp && result.Success())
+AddTargetInternal(target_sp, /*do_select*/ true);
+  return result;
 }
 
 Status TargetList::CreateTarget(Debugger &debugger,
@@ -58,8 +61,12 @@
 const ArchSpec &specified_arch,
 LoadDependentFiles load_dependent_files,
 PlatformSP &platform_sp, TargetSP &target_sp) {
-  return CreateTargetInternal(debugger, user_exe_path, specified_arch,
-  load_dependent_files, platform_sp, target_sp);
+  auto result = TargetList::CreateTargetInternal(debugger, user_exe_path,
+  specified_arch, load_dependent_files, platform_sp, target_sp);
+
+  if (target_sp && result.Success())
+AddTargetInternal(target_sp, /*do_select*/ true);
+  return result;
 }
 
 Status TargetList::CreateTargetInternal(
@@ -388,9 +395,6 @@
   

[Lldb-commits] [PATCH] D92164: Make CommandInterpreter's execution context the same as debugger's one.

2020-12-10 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha updated this revision to Diff 310927.
tatyana-krasnukha retitled this revision from "Make SBDebugger internal 
variable getter and setter not use CommandInterpreter's context" to "Make 
CommandInterpreter's execution context the same as debugger's one.".
tatyana-krasnukha edited the summary of this revision.
tatyana-krasnukha added a comment.

Addressed comments


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

https://reviews.llvm.org/D92164

Files:
  lldb/include/lldb/Interpreter/CommandInterpreter.h
  lldb/source/API/SBCommandInterpreter.cpp
  lldb/source/Breakpoint/BreakpointOptions.cpp
  lldb/source/Commands/CommandObjectCommands.cpp
  lldb/source/Commands/CommandObjectExpression.cpp
  lldb/source/Commands/CommandObjectProcess.cpp
  lldb/source/Commands/CommandObjectRegexCommand.cpp
  lldb/source/Commands/CommandObjectSettings.cpp
  lldb/source/Commands/CommandObjectWatchpointCommand.cpp
  lldb/source/Core/IOHandlerCursesGUI.cpp
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/source/Target/Target.cpp
  lldb/test/API/python_api/debugger/Makefile
  lldb/test/API/python_api/debugger/TestDebuggerAPI.py
  lldb/test/API/python_api/debugger/main.cpp

Index: lldb/test/API/python_api/debugger/main.cpp
===
--- /dev/null
+++ lldb/test/API/python_api/debugger/main.cpp
@@ -0,0 +1,9 @@
+// This simple program is to test the lldb Python API SBDebugger.
+
+int func(int val) {
+return val - 1;
+}
+
+int main (int argc, char const *argv[]) {
+return func(argc);
+}
Index: lldb/test/API/python_api/debugger/TestDebuggerAPI.py
===
--- lldb/test/API/python_api/debugger/TestDebuggerAPI.py
+++ lldb/test/API/python_api/debugger/TestDebuggerAPI.py
@@ -43,3 +43,54 @@
 target = lldb.SBTarget()
 self.assertFalse(target.IsValid())
 self.dbg.DeleteTarget(target)
+
+def test_debugger_internal_variable(self):
+"""Ensure that SBDebugger reachs the same instance of properties
+   regardless CommandInterpreter's context initialization"""
+self.build()
+exe = self.getBuildArtifact("a.out")
+
+# Create a target by the debugger.
+target = self.dbg.CreateTarget(exe)
+self.assertTrue(target, VALID_TARGET)
+
+property_name = "target.process.memory-cache-line-size"
+
+def get_cache_line_size():
+value_list = lldb.SBStringList()
+value_list = self.dbg.GetInternalVariableValue(property_name,
+   self.dbg.GetInstanceName())
+
+self.assertEqual(value_list.GetSize(), 1)
+try:
+return int(value_list.GetStringAtIndex(0))
+except ValueError as error:
+self.fail("Value is not a number: " + error)
+
+# Get global property value while there are no processes.
+global_cache_line_size = get_cache_line_size()
+
+# Run a process via SB interface. CommandInterpreter's execution context
+# remains empty.
+error = lldb.SBError()
+launch_info = lldb.SBLaunchInfo(None)
+launch_info.SetLaunchFlags(lldb.eLaunchFlagStopAtEntry)
+process = target.Launch(launch_info, error)
+self.assertTrue(process, PROCESS_IS_VALID)
+
+# This should change the value of a process's local property.
+new_cache_line_size = global_cache_line_size + 512
+error = self.dbg.SetInternalVariable(property_name,
+ str(new_cache_line_size),
+ self.dbg.GetInstanceName())
+self.assertTrue(error.Success(),
+property_name + " value was changed successfully")
+
+# Check that it was set actually.
+self.assertEqual(get_cache_line_size(), new_cache_line_size)
+
+# Run any command to initialize CommandInterpreter's execution context.
+self.runCmd("target list")
+
+# Test the local property again, is it set to new_cache_line_size?
+self.assertEqual(get_cache_line_size(), new_cache_line_size)
Index: lldb/test/API/python_api/debugger/Makefile
===
--- /dev/null
+++ lldb/test/API/python_api/debugger/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -3351,7 +3351,7 @@
   // Force Async:
   bool old_async = debugger.GetAsyncExecution();
   debugger.SetAsyncExecution(true);
-  debugger.GetCommandInterpreter().HandleCommands(GetCommands(), &exc_ctx,
+  debugger.GetCommandInterpreter().HandleCommands(GetCommands(), exc_ctx,
   opti

[Lldb-commits] [PATCH] D92164: Make SBDebugger internal variable getter and setter not use CommandInterpreter's context

2020-11-30 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha updated this revision to Diff 308325.
tatyana-krasnukha added a comment.

Removed refactoring to make the changes clearer.


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

https://reviews.llvm.org/D92164

Files:
  lldb/packages/Python/lldbsuite/test/python_api/debugger/Makefile
  lldb/packages/Python/lldbsuite/test/python_api/debugger/main.cpp
  lldb/source/API/SBDebugger.cpp
  lldb/test/API/python_api/debugger/TestDebuggerAPI.py

Index: lldb/test/API/python_api/debugger/TestDebuggerAPI.py
===
--- lldb/test/API/python_api/debugger/TestDebuggerAPI.py
+++ lldb/test/API/python_api/debugger/TestDebuggerAPI.py
@@ -43,3 +43,54 @@
 target = lldb.SBTarget()
 self.assertFalse(target.IsValid())
 self.dbg.DeleteTarget(target)
+
+def test_debugger_internal_variable(self):
+"""Ensure that SBDebugger reachs the same instance of properties
+   regardless CommandInterpreter's context initialization"""
+self.build()
+exe = self.getBuildArtifact("a.out")
+
+# Create a target by the debugger.
+target = self.dbg.CreateTarget(exe)
+self.assertTrue(target, VALID_TARGET)
+
+property_name = "target.process.memory-cache-line-size"
+
+def get_cache_line_size():
+value_list = lldb.SBStringList()
+value_list = self.dbg.GetInternalVariableValue(property_name,
+   self.dbg.GetInstanceName())
+
+self.assertEqual(value_list.GetSize(), 1)
+try:
+return int(value_list.GetStringAtIndex(0))
+except ValueError as error:
+self.fail("Value is not a number: " + error)
+
+# Get global property value while there are no processes.
+global_cache_line_size = get_cache_line_size()
+
+# Run a process via SB interface. CommandInterpreter's execution context
+# remains empty.
+error = lldb.SBError()
+launch_info = lldb.SBLaunchInfo(None)
+launch_info.SetLaunchFlags(lldb.eLaunchFlagStopAtEntry)
+process = target.Launch(launch_info, error)
+self.assertTrue(process, PROCESS_IS_VALID)
+
+# This should change the value of a process's local property.
+new_cache_line_size = global_cache_line_size + 512
+error = self.dbg.SetInternalVariable(property_name,
+ str(new_cache_line_size),
+ self.dbg.GetInstanceName())
+self.assertTrue(error.Success(),
+property_name + " value was changed successfully")
+
+# Check that it was set actually.
+self.assertEqual(get_cache_line_size(), new_cache_line_size)
+
+# Run any command to initialize CommandInterpreter's execution context.
+self.runCmd("target list")
+
+# Test the local property again, is it set to new_cache_line_size?
+self.assertEqual(get_cache_line_size(), new_cache_line_size)
Index: lldb/source/API/SBDebugger.cpp
===
--- lldb/source/API/SBDebugger.cpp
+++ lldb/source/API/SBDebugger.cpp
@@ -1270,13 +1270,12 @@
   ConstString(debugger_instance_name)));
   Status error;
   if (debugger_sp) {
-ExecutionContext exe_ctx(
-debugger_sp->GetCommandInterpreter().GetExecutionContext());
+ExecutionContext exe_ctx(debugger_sp->GetSelectedTarget(), true);
 error = debugger_sp->SetPropertyValue(&exe_ctx, eVarSetOperationAssign,
   var_name, value);
   } else {
-error.SetErrorStringWithFormat("invalid debugger instance name '%s'",
-   debugger_instance_name);
+error.SetErrorStringWithFormatv("invalid debugger instance name {0}",
+debugger_instance_name);
   }
   if (error.Fail())
 sb_error.SetError(error);
@@ -1295,8 +1294,7 @@
   ConstString(debugger_instance_name)));
   Status error;
   if (debugger_sp) {
-ExecutionContext exe_ctx(
-debugger_sp->GetCommandInterpreter().GetExecutionContext());
+ExecutionContext exe_ctx(debugger_sp->GetSelectedTarget(), true);
 lldb::OptionValueSP value_sp(
 debugger_sp->GetPropertyValue(&exe_ctx, var_name, false, error));
 if (value_sp) {
@@ -1308,7 +1306,15 @@
 string_list.SplitIntoLines(value_str);
 return LLDB_RECORD_RESULT(SBStringList(&string_list));
   }
+} else {
+  Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+  LLDB_LOG_ERROR(log, error.ToError(), "cannot get property value: {0}");
 }
+  } else {
+Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+error.SetErrorStringWithFormatv("invalid debugger instance name {0}",
+debugger_instance_name);
+LLDB_LOG_E

[Lldb-commits] [PATCH] D92164: Make SBDebugger internal variable getter and setter not use CommandInterpreter's context

2020-11-26 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha created this revision.
tatyana-krasnukha added reviewers: jingham, JDevlieghere, labath.
tatyana-krasnukha added a project: LLDB.
Herald added a subscriber: lldb-commits.
tatyana-krasnukha requested review of this revision.

SBDebugger asks CommandInterpreter for execution context, however, the 
interpreter's context will not be updated until a command will be executed (may 
never happen when using SB API). It means that the behavior of these functions 
depends on previous user actions. The context can stay uninitialized, point to 
a currently selected target, or point to one of the previously selected targets.

This patch makes SBDebugger use execution context built upon the selected 
target. Notice, that even SBCommandInterpreter::GetProcess doesn't use 
CommandInterpreter's execution context.
Also, add error logging to GetInternalVariableValue.

Added test reproduces the issue. Without this fix, the last assertion fails 
because the interpreter's execution context is empty until running "target 
list", so, the value of the global property was updated instead of the 
process's local instance.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92164

Files:
  lldb/packages/Python/lldbsuite/test/python_api/debugger/Makefile
  lldb/packages/Python/lldbsuite/test/python_api/debugger/main.cpp
  lldb/source/API/SBDebugger.cpp
  lldb/test/API/python_api/debugger/TestDebuggerAPI.py

Index: lldb/test/API/python_api/debugger/TestDebuggerAPI.py
===
--- lldb/test/API/python_api/debugger/TestDebuggerAPI.py
+++ lldb/test/API/python_api/debugger/TestDebuggerAPI.py
@@ -43,3 +43,54 @@
 target = lldb.SBTarget()
 self.assertFalse(target.IsValid())
 self.dbg.DeleteTarget(target)
+
+def test_debugger_internal_variable(self):
+"""Ensure that SBDebugger reachs the same instance of properties
+   regardless CommandInterpreter's context initialization"""
+self.build()
+exe = self.getBuildArtifact("a.out")
+
+# Create a target by the debugger.
+target = self.dbg.CreateTarget(exe)
+self.assertTrue(target, VALID_TARGET)
+
+property_name = "target.process.memory-cache-line-size"
+
+def get_cache_line_size():
+value_list = lldb.SBStringList()
+value_list = self.dbg.GetInternalVariableValue(property_name,
+   self.dbg.GetInstanceName())
+
+self.assertEqual(value_list.GetSize(), 1)
+try:
+return int(value_list.GetStringAtIndex(0))
+except ValueError as error:
+self.fail("Value is not a number: " + error)
+
+# Get global property value while there are no processes.
+global_cache_line_size = get_cache_line_size()
+
+# Run a process via SB interface. CommandInterpreter's execution context
+# remains empty.
+error = lldb.SBError()
+launch_info = lldb.SBLaunchInfo(None)
+launch_info.SetLaunchFlags(lldb.eLaunchFlagStopAtEntry)
+process = target.Launch(launch_info, error)
+self.assertTrue(process, PROCESS_IS_VALID)
+
+# This should change the value of a process's local property.
+new_cache_line_size = global_cache_line_size + 512
+error = self.dbg.SetInternalVariable(property_name,
+ str(new_cache_line_size),
+ self.dbg.GetInstanceName())
+self.assertTrue(error.Success(),
+property_name + " value was changed successfully")
+
+# Check that it was set actually.
+self.assertEqual(get_cache_line_size(), new_cache_line_size)
+
+# Run any command to initialize CommandInterpreter's execution context.
+self.runCmd("target list")
+
+# Test the local property again, is it set to new_cache_line_size?
+self.assertEqual(get_cache_line_size(), new_cache_line_size)
Index: lldb/source/API/SBDebugger.cpp
===
--- lldb/source/API/SBDebugger.cpp
+++ lldb/source/API/SBDebugger.cpp
@@ -1268,16 +1268,18 @@
   SBError sb_error;
   DebuggerSP debugger_sp(Debugger::FindDebuggerWithInstanceName(
   ConstString(debugger_instance_name)));
-  Status error;
-  if (debugger_sp) {
-ExecutionContext exe_ctx(
-debugger_sp->GetCommandInterpreter().GetExecutionContext());
-error = debugger_sp->SetPropertyValue(&exe_ctx, eVarSetOperationAssign,
-  var_name, value);
-  } else {
-error.SetErrorStringWithFormat("invalid debugger instance name '%s'",
-   debugger_instance_name);
+
+  if (!debugger_sp) {
+sb_error.SetErrorStringWithFormat("invalid debugger instance name '%s'",
+  debugger_i

[Lldb-commits] [PATCH] D88769: [trace] Scaffold "thread trace dump instructions"

2020-10-06 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha added inline comments.



Comment at: lldb/source/Plugins/Process/Trace/ProcessTrace.h:18
+
+class ProcessTrace : public lldb_private::Process {
+public:

clayborg wrote:
> So one issue is how do we eventually deal with debugging a live process that 
> enables tracing. In that case we already have a real process class: 
> ProcessGDBRemote most likely. We should avoid putting anything custom that is 
> required from a process in this ProcessTrace class for when we actually have 
> a real process class already. If we need to add anything, we will need to 
> have virtual functions on the lldb_private::Process class that can call 
> through to the Trace plug-in via its virtual functions as well to implement 
> any functionality we might need.
> 
> Is this class solely going to be used for "trace load"?
One option is to implement [[ 
https://sourceware.org/gdb/current/onlinedocs/gdb/Branch-Trace-Format.html | 
btrace ]] request in the ProcessGDBRemote and make remote stubs support it.

I'm also interested in live tracing for a custom process plugin which obtains 
instruction history in its own way. So, it would be good if a real 
process/thread provides data to the tracing plug-in.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88769

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


[Lldb-commits] [PATCH] D88906: [lldb/docs] Clarify python/swig version incompatibility

2020-10-06 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha accepted this revision.
tatyana-krasnukha added a comment.
This revision is now accepted and ready to land.

I used Swig 3.0.12 + cherry-picked commit that fixes that bug 
(https://github.com/swig/swig/issues/1321) on Windows. It worked well  with 
both Python 3.7 and 3.8.

The only issue I still have with Python 3.8 and later is importing liblldb.dll 
from a python script (https://llvm.org/pr46891) while running the test-suite.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88906

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


[Lldb-commits] [PATCH] D84957: [lldb/Process/Windows] Attempt to kill exited/detached process in not error

2020-08-03 Thread Tatyana Krasnukha via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe97c693bb0ec: [lldb/Process/Windows] Attempting to kill 
exited/detached process in not an… (authored by tatyana-krasnukha).

Changed prior to commit:
  https://reviews.llvm.org/D84957?vs=281989&id=282556#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84957

Files:
  lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp


Index: lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp
+++ lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp
@@ -227,22 +227,20 @@
 debugger_thread = m_session_data->m_debugger;
   }
 
-  Status error;
-  if (state != eStateExited && state != eStateDetached) {
-LLDB_LOG(
-log, "Shutting down process {0}.",
-debugger_thread->GetProcess().GetNativeProcess().GetSystemHandle());
-error = debugger_thread->StopDebugging(true);
-
-// By the time StopDebugging returns, there is no more debugger thread, so
-// we can be assured that no other thread will race for the session data.
-m_session_data.reset();
-  } else {
-error.SetErrorStringWithFormat("cannot destroy process %" PRIx64
-   " while state = %d",
-   GetDebuggedProcessId(), state);
-LLDB_LOG(log, "error: {0}", error);
+  if (state == eStateExited || state == eStateDetached) {
+LLDB_LOG(log, "warning: cannot destroy process {0} while state = {1}.",
+ GetDebuggedProcessId(), state);
+return Status();
   }
+
+  LLDB_LOG(log, "Shutting down process {0}.",
+   debugger_thread->GetProcess().GetNativeProcess().GetSystemHandle());
+  auto error = debugger_thread->StopDebugging(true);
+
+  // By the time StopDebugging returns, there is no more debugger thread, so
+  // we can be assured that no other thread will race for the session data.
+  m_session_data.reset();
+
   return error;
 }
 


Index: lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp
+++ lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp
@@ -227,22 +227,20 @@
 debugger_thread = m_session_data->m_debugger;
   }
 
-  Status error;
-  if (state != eStateExited && state != eStateDetached) {
-LLDB_LOG(
-log, "Shutting down process {0}.",
-debugger_thread->GetProcess().GetNativeProcess().GetSystemHandle());
-error = debugger_thread->StopDebugging(true);
-
-// By the time StopDebugging returns, there is no more debugger thread, so
-// we can be assured that no other thread will race for the session data.
-m_session_data.reset();
-  } else {
-error.SetErrorStringWithFormat("cannot destroy process %" PRIx64
-   " while state = %d",
-   GetDebuggedProcessId(), state);
-LLDB_LOG(log, "error: {0}", error);
+  if (state == eStateExited || state == eStateDetached) {
+LLDB_LOG(log, "warning: cannot destroy process {0} while state = {1}.",
+ GetDebuggedProcessId(), state);
+return Status();
   }
+
+  LLDB_LOG(log, "Shutting down process {0}.",
+   debugger_thread->GetProcess().GetNativeProcess().GetSystemHandle());
+  auto error = debugger_thread->StopDebugging(true);
+
+  // By the time StopDebugging returns, there is no more debugger thread, so
+  // we can be assured that no other thread will race for the session data.
+  m_session_data.reset();
+
   return error;
 }
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D84957: [lldb/Process/Windows] Attempt to kill exited/detached process in not error

2020-08-03 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha added a comment.

Thank you! I fixed the commit title and description as you suggested.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84957

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


[Lldb-commits] [PATCH] D84954: [lldb] Make Target::CleanupProcess consistent for breakpoints and watchpoints

2020-07-30 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha updated this revision to Diff 282030.
tatyana-krasnukha added a comment.

TestAddressBreakpoints.py fails on the last check - it expects hit count to be 
saved after re-launching the process. Removed that check.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84954

Files:
  lldb/include/lldb/Breakpoint/Breakpoint.h
  lldb/include/lldb/Breakpoint/BreakpointList.h
  lldb/include/lldb/Breakpoint/BreakpointLocation.h
  lldb/include/lldb/Breakpoint/BreakpointLocationList.h
  lldb/include/lldb/Breakpoint/WatchpointList.h
  lldb/include/lldb/Target/Target.h
  lldb/source/Breakpoint/Breakpoint.cpp
  lldb/source/Breakpoint/BreakpointList.cpp
  lldb/source/Breakpoint/BreakpointLocationList.cpp
  lldb/source/Breakpoint/WatchpointList.cpp
  lldb/source/Target/Target.cpp
  
lldb/test/API/functionalities/breakpoint/address_breakpoints/TestAddressBreakpoints.py
  
lldb/test/API/functionalities/breakpoint/breakpoint_hit_count/TestBreakpointHitCount.py

Index: lldb/test/API/functionalities/breakpoint/breakpoint_hit_count/TestBreakpointHitCount.py
===
--- lldb/test/API/functionalities/breakpoint/breakpoint_hit_count/TestBreakpointHitCount.py
+++ lldb/test/API/functionalities/breakpoint/breakpoint_hit_count/TestBreakpointHitCount.py
@@ -19,15 +19,32 @@
 def test_breakpoint_location_hit_count(self):
 """Use Python APIs to check breakpoint hit count."""
 self.build()
-self.do_test_breakpoint_location_hit_count()
+target = self.create_target()
+breakpoint = self.create_breakpoint(target)
+process = self.launch_process(target)
+self.do_test_breakpoint_location_hit_count(process, breakpoint)
+
+def test_breakpoint_hit_count_cleanup(self):
+"""Use Python APIs to check that breakpoint hit count is cleared
+   as well as locations hit counts when process dies."""
+self.build()
+target = self.create_target()
+breakpoint = self.create_breakpoint(target)
+process = self.launch_process(target)
+self.do_test_breakpoint_location_hit_count(process, breakpoint)
+
+# Kill the process and launch a new one.
+status = process.Kill()
+self.assertTrue(status, "The process was killed.")
+new_process = self.launch_process(target)
+
+# Test hit location of the existing breakpoint. It should be like we didn't have hits before.
+self.do_test_breakpoint_location_hit_count(new_process, breakpoint)
 
 def test_breakpoint_one_shot(self):
 """Check that one-shot breakpoints trigger only once."""
 self.build()
-
-exe = self.getBuildArtifact("a.out")
-target = self.dbg.CreateTarget(exe)
-self.assertTrue(target, VALID_TARGET)
+target = self.create_target()
 
 self.runCmd("tb a")
 process = target.LaunchSimple(
@@ -54,13 +71,14 @@
 self.a_float_body_line_no = line_number(
 'main.cpp', '// Breakpoint Location 2')
 
-def do_test_breakpoint_location_hit_count(self):
-"""Use Python APIs to check breakpoint hit count."""
+def create_target(self):
 exe = self.getBuildArtifact("a.out")
 
 target = self.dbg.CreateTarget(exe)
 self.assertTrue(target, VALID_TARGET)
+return target
 
+def create_breakpoint(self, target):
 # Create a breakpoint in main.cpp by name 'a',
 # there should be two locations.
 breakpoint = target.BreakpointCreateByName('a', 'a.out')
@@ -79,11 +97,19 @@
 location2.IsEnabled(),
 VALID_BREAKPOINT_LOCATION)
 
+return breakpoint
+
+def launch_process(self, target):
 # Launch the process, and do not stop at entry point.
 process = target.LaunchSimple(
 None, None, self.get_process_working_directory())
 self.assertTrue(process, PROCESS_IS_VALID)
 
+return process
+
+def do_test_breakpoint_location_hit_count(self, process, breakpoint):
+"""Use Python APIs to check breakpoint hit count."""
+
 # Verify 1st breakpoint location is hit.
 from lldbsuite.test.lldbutil import get_stopped_thread
 thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)
@@ -129,5 +155,3 @@
 self.assertEqual(location2.GetHitCount(), 2)
 self.assertEqual(location1.GetHitCount(), 1)
 self.assertEqual(breakpoint.GetHitCount(), 3)
-
-process.Continue()
Index: lldb/test/API/functionalities/breakpoint/address_breakpoints/TestAddressBreakpoints.py
===
--- lldb/test/API/functionalities/breakpoint/address_breakpoints/TestAddressBreakpoints.py
+++ lldb/test/API/functionalities/breakpoint/address_breakpoints/TestAddressBreakpoints.py
@@ -72,20 +72,3 @@
 

[Lldb-commits] [PATCH] D84957: [lldb/Process/Windows] Trying to kill exited/detached process in not error

2020-07-30 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha created this revision.
tatyana-krasnukha added a reviewer: asmith.
tatyana-krasnukha added a project: LLDB.
Herald added subscribers: lldb-commits, JDevlieghere.
tatyana-krasnukha requested review of this revision.

Don't report an error, just log this happened.
This fixes a lot of "CLEANUP ERROR"s for the test-suite on Windows and makes 
ProcessWindows consistent with the other processes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84957

Files:
  lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp


Index: lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp
+++ lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp
@@ -227,22 +227,21 @@
 debugger_thread = m_session_data->m_debugger;
   }
 
-  Status error;
-  if (state != eStateExited && state != eStateDetached) {
-LLDB_LOG(
-log, "Shutting down process {0}.",
-debugger_thread->GetProcess().GetNativeProcess().GetSystemHandle());
-error = debugger_thread->StopDebugging(true);
-
-// By the time StopDebugging returns, there is no more debugger thread, so
-// we can be assured that no other thread will race for the session data.
-m_session_data.reset();
-  } else {
-error.SetErrorStringWithFormat("cannot destroy process %" PRIx64
-   " while state = %d",
-   GetDebuggedProcessId(), state);
-LLDB_LOG(log, "error: {0}", error);
+  if (state == eStateExited || state == eStateDetached) {
+LLDB_LOG(log, "warning: cannot destroy process {0}  while state = {1}",
+GetDebuggedProcessId(), state);
+return Status();
   }
+
+  LLDB_LOG(
+  log, "Shutting down process {0}.",
+  debugger_thread->GetProcess().GetNativeProcess().GetSystemHandle());
+  auto error = debugger_thread->StopDebugging(true);
+
+  // By the time StopDebugging returns, there is no more debugger thread, so
+  // we can be assured that no other thread will race for the session data.
+  m_session_data.reset();
+
   return error;
 }
 


Index: lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp
+++ lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp
@@ -227,22 +227,21 @@
 debugger_thread = m_session_data->m_debugger;
   }
 
-  Status error;
-  if (state != eStateExited && state != eStateDetached) {
-LLDB_LOG(
-log, "Shutting down process {0}.",
-debugger_thread->GetProcess().GetNativeProcess().GetSystemHandle());
-error = debugger_thread->StopDebugging(true);
-
-// By the time StopDebugging returns, there is no more debugger thread, so
-// we can be assured that no other thread will race for the session data.
-m_session_data.reset();
-  } else {
-error.SetErrorStringWithFormat("cannot destroy process %" PRIx64
-   " while state = %d",
-   GetDebuggedProcessId(), state);
-LLDB_LOG(log, "error: {0}", error);
+  if (state == eStateExited || state == eStateDetached) {
+LLDB_LOG(log, "warning: cannot destroy process {0}  while state = {1}",
+GetDebuggedProcessId(), state);
+return Status();
   }
+
+  LLDB_LOG(
+  log, "Shutting down process {0}.",
+  debugger_thread->GetProcess().GetNativeProcess().GetSystemHandle());
+  auto error = debugger_thread->StopDebugging(true);
+
+  // By the time StopDebugging returns, there is no more debugger thread, so
+  // we can be assured that no other thread will race for the session data.
+  m_session_data.reset();
+
   return error;
 }
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D84954: [lldb] Make Target::CleanupProcess consistent for breakpoints and watchpoints

2020-07-30 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha created this revision.
tatyana-krasnukha added a reviewer: jingham.
tatyana-krasnukha added a project: LLDB.
Herald added subscribers: lldb-commits, JDevlieghere.
tatyana-krasnukha requested review of this revision.

Target clears watchpoints hit count but doesn't do the same for breakpoints. As 
was discussed in D84527 , this behavior should 
be unified.

Now responsibility for cleanup lies on *List symmetrically for breakpoints and 
watchpoints.

The test case verifies that hit counts are reset to 0 after killing the process.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84954

Files:
  lldb/include/lldb/Breakpoint/Breakpoint.h
  lldb/include/lldb/Breakpoint/BreakpointList.h
  lldb/include/lldb/Breakpoint/BreakpointLocation.h
  lldb/include/lldb/Breakpoint/BreakpointLocationList.h
  lldb/include/lldb/Breakpoint/WatchpointList.h
  lldb/include/lldb/Target/Target.h
  lldb/source/Breakpoint/Breakpoint.cpp
  lldb/source/Breakpoint/BreakpointList.cpp
  lldb/source/Breakpoint/BreakpointLocationList.cpp
  lldb/source/Breakpoint/WatchpointList.cpp
  lldb/source/Target/Target.cpp
  
lldb/test/API/functionalities/breakpoint/breakpoint_hit_count/TestBreakpointHitCount.py

Index: lldb/test/API/functionalities/breakpoint/breakpoint_hit_count/TestBreakpointHitCount.py
===
--- lldb/test/API/functionalities/breakpoint/breakpoint_hit_count/TestBreakpointHitCount.py
+++ lldb/test/API/functionalities/breakpoint/breakpoint_hit_count/TestBreakpointHitCount.py
@@ -19,15 +19,32 @@
 def test_breakpoint_location_hit_count(self):
 """Use Python APIs to check breakpoint hit count."""
 self.build()
-self.do_test_breakpoint_location_hit_count()
+target = self.create_target()
+breakpoint = self.create_breakpoint(target)
+process = self.launch_process(target)
+self.do_test_breakpoint_location_hit_count(process, breakpoint)
+
+def test_breakpoint_hit_count_cleanup(self):
+"""Use Python APIs to check that breakpoint hit count is cleared
+   as well as locations hit counts when process dies."""
+self.build()
+target = self.create_target()
+breakpoint = self.create_breakpoint(target)
+process = self.launch_process(target)
+self.do_test_breakpoint_location_hit_count(process, breakpoint)
+
+# Kill the process and launch a new one.
+status = process.Kill()
+self.assertTrue(status, "The process was killed.")
+new_process = self.launch_process(target)
+
+# Test hit location of the existing breakpoint. It should be like we didn't have hits before.
+self.do_test_breakpoint_location_hit_count(new_process, breakpoint)
 
 def test_breakpoint_one_shot(self):
 """Check that one-shot breakpoints trigger only once."""
 self.build()
-
-exe = self.getBuildArtifact("a.out")
-target = self.dbg.CreateTarget(exe)
-self.assertTrue(target, VALID_TARGET)
+target = self.create_target()
 
 self.runCmd("tb a")
 process = target.LaunchSimple(
@@ -54,13 +71,14 @@
 self.a_float_body_line_no = line_number(
 'main.cpp', '// Breakpoint Location 2')
 
-def do_test_breakpoint_location_hit_count(self):
-"""Use Python APIs to check breakpoint hit count."""
+def create_target(self):
 exe = self.getBuildArtifact("a.out")
 
 target = self.dbg.CreateTarget(exe)
 self.assertTrue(target, VALID_TARGET)
+return target
 
+def create_breakpoint(self, target):
 # Create a breakpoint in main.cpp by name 'a',
 # there should be two locations.
 breakpoint = target.BreakpointCreateByName('a', 'a.out')
@@ -79,11 +97,19 @@
 location2.IsEnabled(),
 VALID_BREAKPOINT_LOCATION)
 
+return breakpoint
+
+def launch_process(self, target):
 # Launch the process, and do not stop at entry point.
 process = target.LaunchSimple(
 None, None, self.get_process_working_directory())
 self.assertTrue(process, PROCESS_IS_VALID)
 
+return process
+
+def do_test_breakpoint_location_hit_count(self, process, breakpoint):
+"""Use Python APIs to check breakpoint hit count."""
+
 # Verify 1st breakpoint location is hit.
 from lldbsuite.test.lldbutil import get_stopped_thread
 thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)
@@ -129,5 +155,3 @@
 self.assertEqual(location2.GetHitCount(), 2)
 self.assertEqual(location1.GetHitCount(), 1)
 self.assertEqual(breakpoint.GetHitCount(), 3)
-
-process.Continue()
Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@

[Lldb-commits] [PATCH] D84527: Rename StoppointLocation to StoppointSite and drop its relationship with BreakpointLocation

2020-07-29 Thread Tatyana Krasnukha via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGda0bba5c9abb: [lldb/Breakpoint] Rename StoppointLocation to 
StoppointSite and drop its… (authored by tatyana-krasnukha).

Changed prior to commit:
  https://reviews.llvm.org/D84527?vs=281600&id=281701#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84527

Files:
  lldb/include/lldb/Breakpoint/Breakpoint.h
  lldb/include/lldb/Breakpoint/BreakpointLocation.h
  lldb/include/lldb/Breakpoint/BreakpointSite.h
  lldb/include/lldb/Breakpoint/StoppointHitCounter.h
  lldb/include/lldb/Breakpoint/StoppointLocation.h
  lldb/include/lldb/Breakpoint/StoppointSite.h
  lldb/include/lldb/Breakpoint/Watchpoint.h
  lldb/include/lldb/lldb-forward.h
  lldb/source/Breakpoint/Breakpoint.cpp
  lldb/source/Breakpoint/BreakpointLocation.cpp
  lldb/source/Breakpoint/BreakpointSite.cpp
  lldb/source/Breakpoint/CMakeLists.txt
  lldb/source/Breakpoint/StoppointLocation.cpp
  lldb/source/Breakpoint/StoppointSite.cpp
  lldb/source/Breakpoint/Watchpoint.cpp

Index: lldb/source/Breakpoint/Watchpoint.cpp
===
--- lldb/source/Breakpoint/Watchpoint.cpp
+++ lldb/source/Breakpoint/Watchpoint.cpp
@@ -25,7 +25,7 @@
 
 Watchpoint::Watchpoint(Target &target, lldb::addr_t addr, uint32_t size,
const CompilerType *type, bool hardware)
-: StoppointLocation(0, addr, size, hardware), m_target(target),
+: StoppointSite(0, addr, size, hardware), m_target(target),
   m_enabled(false), m_is_hardware(hardware), m_is_watch_variable(false),
   m_is_ephemeral(false), m_disabled_count(0), m_watch_read(0),
   m_watch_write(0), m_watch_was_read(0), m_watch_was_written(0),
@@ -93,8 +93,6 @@
   m_watch_spec_str = str;
 }
 
-// Override default impl of StoppointLocation::IsHardware() since m_is_hardware
-// member field is more accurate.
 bool Watchpoint::IsHardware() const {
   lldbassert(m_is_hardware || !HardwareRequired());
   return m_is_hardware;
@@ -126,12 +124,12 @@
 void Watchpoint::IncrementFalseAlarmsAndReviseHitCount() {
   ++m_false_alarms;
   if (m_false_alarms) {
-if (m_hit_count >= m_false_alarms) {
-  m_hit_count -= m_false_alarms;
+if (m_hit_counter.GetValue() >= m_false_alarms) {
+  m_hit_counter.Decrement(m_false_alarms);
   m_false_alarms = 0;
 } else {
-  m_false_alarms -= m_hit_count;
-  m_hit_count = 0;
+  m_false_alarms -= m_hit_counter.GetValue();
+  m_hit_counter.Reset();
 }
   }
 }
@@ -140,7 +138,7 @@
 // should continue.
 
 bool Watchpoint::ShouldStop(StoppointCallbackContext *context) {
-  IncrementHitCount();
+  m_hit_counter.Increment();
 
   return IsEnabled();
 }
Index: lldb/source/Breakpoint/StoppointSite.cpp
===
--- /dev/null
+++ lldb/source/Breakpoint/StoppointSite.cpp
@@ -0,0 +1,23 @@
+//===-- StoppointSite.cpp -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "lldb/Breakpoint/StoppointSite.h"
+
+
+using namespace lldb;
+using namespace lldb_private;
+
+StoppointSite::StoppointSite(break_id_t id, addr_t addr, bool hardware)
+: m_id(id), m_addr(addr), m_is_hardware_required(hardware),
+  m_hardware_index(LLDB_INVALID_INDEX32), m_byte_size(0), m_hit_counter() {}
+
+StoppointSite::StoppointSite(break_id_t id, addr_t addr,
+ uint32_t byte_size, bool hardware)
+: m_id(id), m_addr(addr), m_is_hardware_required(hardware),
+  m_hardware_index(LLDB_INVALID_INDEX32), m_byte_size(byte_size),
+  m_hit_counter() {}
Index: lldb/source/Breakpoint/StoppointLocation.cpp
===
--- lldb/source/Breakpoint/StoppointLocation.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-//===-- StoppointLocation.cpp -===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-
-#include "lldb/Breakpoint/StoppointLocation.h"
-
-
-using namespace lldb;
-using namespace lldb_private;
-
-// StoppointLocation constructor
-StoppointLocation::StoppointLocation(break_id_t bid, addr_t addr, bool hardware)
-: m_loc_id(bid), m_addr(addr), m_hardware(hardware),
-  m_hardware_index(LLDB_INVALID_INDEX32), m_byte_size(0), m_hit_count(0) {}
-
-StoppointL

[Lldb-commits] [PATCH] D84257: [lldb] Don't use hardware index to determine whether a breakpoint site is hardware

2020-07-29 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha added a comment.

Ups... Pushed it occationaly with the other patchs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84257

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


[Lldb-commits] [PATCH] D84257: [lldb] Don't use hardware index to determine whether a breakpoint site is hardware

2020-07-29 Thread Tatyana Krasnukha via Phabricator via lldb-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGebaa8b1c6074: [lldb] Don't use hardware index to 
determine whether a breakpoint site is… (authored by tatyana-krasnukha).

Changed prior to commit:
  https://reviews.llvm.org/D84257?vs=280448&id=281685#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84257

Files:
  lldb/include/lldb/Breakpoint/BreakpointLocation.h
  lldb/include/lldb/Breakpoint/BreakpointSite.h
  lldb/include/lldb/Breakpoint/StoppointLocation.h
  lldb/source/Breakpoint/BreakpointLocation.cpp
  lldb/source/Breakpoint/Watchpoint.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  
lldb/test/API/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py

Index: lldb/test/API/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py
===
--- lldb/test/API/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py
+++ lldb/test/API/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py
@@ -17,27 +17,6 @@
 def does_not_support_hw_breakpoints(self):
 return not super().supports_hw_breakpoints()
 
-# LLDB on linux supports hardware breakpoints for arm and aarch64
-# architectures.
-@skipUnlessPlatform(oslist=['linux'])
-@skipTestIfFn(does_not_support_hw_breakpoints)
-def test_hw_break_set_delete_multi_thread_linux(self):
-self.build()
-self.setTearDownCleanup()
-self.break_multi_thread('delete', False) # llvm.org/PR44659
-
-# LLDB on linux supports hardware breakpoints for arm and aarch64
-# architectures.
-@skipUnlessPlatform(oslist=['linux'])
-@skipTestIfFn(does_not_support_hw_breakpoints)
-def test_hw_break_set_disable_multi_thread_linux(self):
-self.build()
-self.setTearDownCleanup()
-self.break_multi_thread('disable', False) # llvm.org/PR44659
-
-# LLDB on darwin supports hardware breakpoints for x86_64 and i386
-# architectures.
-@skipUnlessDarwin
 @skipIfOutOfTreeDebugserver
 @skipTestIfFn(does_not_support_hw_breakpoints)
 def test_hw_break_set_delete_multi_thread_macos(self):
@@ -45,9 +24,6 @@
 self.setTearDownCleanup()
 self.break_multi_thread('delete')
 
-# LLDB on darwin supports hardware breakpoints for x86_64 and i386
-# architectures.
-@skipUnlessDarwin
 @skipIfOutOfTreeDebugserver
 @skipTestIfFn(does_not_support_hw_breakpoints)
 def test_hw_break_set_disable_multi_thread_macos(self):
@@ -55,7 +31,6 @@
 self.setTearDownCleanup()
 self.break_multi_thread('disable')
 
-
 def setUp(self):
 # Call super's setUp().
 TestBase.setUp(self)
@@ -65,7 +40,7 @@
 self.first_stop = line_number(
 self.source, 'Starting thread creation with hardware breakpoint set')
 
-def break_multi_thread(self, removal_type, check_hw_bp=True):
+def break_multi_thread(self, removal_type):
 """Test that lldb hardware breakpoints work for multiple threads."""
 self.runCmd("file " + self.getBuildArtifact("a.out"),
 CURRENT_EXECUTABLE_SET)
@@ -109,10 +84,9 @@
 # Continue the loop and test that we are stopped 4 times.
 count += 1
 
-if check_hw_bp:
-# Check the breakpoint list.
-self.expect("breakpoint list", substrs=['hw_break_function', 'hardware'])
-self.expect("breakpoint list -v", substrs=['function = hw_break_function', 'hardware = true'])
+# Check the breakpoint list.
+self.expect("breakpoint list", substrs=['hw_break_function', 'hardware'])
+self.expect("breakpoint list -v", substrs=['function = hw_break_function', 'hardware = true'])
 
 if removal_type == 'delete':
 self.runCmd("settings set auto-confirm true")
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -3204,14 +3204,8 @@
   break;
 
 case BreakpointSite::eExternal: {
-  GDBStoppointType stoppoint_type;
-  if (bp_site->IsHardware())
-stoppoint_type = eBreakpointHardware;
-  else
-stoppoint_type = eBreakpointSoftware;
-
-  if (m_gdb_comm.SendGDBStoppointTypePacket(stoppoint_type, false, addr,
-bp_op_size))
+  if (m_gdb_

[Lldb-commits] [PATCH] D84255: [lldb] Make process plugins check whether a hardware breakpoint is required

2020-07-29 Thread Tatyana Krasnukha via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb352e62feadd: [lldb] Make process plugins check whether a 
hardware breakpoint is required (authored by tatyana-krasnukha).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84255

Files:
  lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
  lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
  lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
  
lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/TestRequireHWBreakpoints.py


Index: 
lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/TestRequireHWBreakpoints.py
===
--- 
lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/TestRequireHWBreakpoints.py
+++ 
lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/TestRequireHWBreakpoints.py
@@ -27,7 +27,6 @@
 breakpoint = target.BreakpointCreateByLocation("main.c", 1)
 self.assertTrue(breakpoint.IsHardware())
 
-@skipIfWindows
 @expectedFailure(supports_hw_breakpoints)
 def test_step_range(self):
 """Test stepping when hardware breakpoints are required."""
@@ -49,7 +48,6 @@
 self.assertTrue("Could not create hardware breakpoint for thread plan"
 in error.GetCString())
 
-@skipIfWindows
 @expectedFailure(supports_hw_breakpoints)
 def test_step_out(self):
 """Test stepping out when hardware breakpoints are required."""
@@ -70,7 +68,6 @@
 self.assertTrue("Could not create hardware breakpoint for thread plan"
 in error.GetCString())
 
-@skipIfWindows
 @expectedFailure(supports_hw_breakpoints)
 def test_step_over(self):
 """Test stepping over when hardware breakpoints are required."""
@@ -89,7 +86,6 @@
 'error: Could not create hardware breakpoint for thread plan.'
 ])
 
-@skipIfWindows
 @expectedFailure(supports_hw_breakpoints)
 def test_step_until(self):
 """Test stepping until when hardware breakpoints are required."""
Index: lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
+++ lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
@@ -150,6 +150,9 @@
 uint32_t ProcessWindows::GetPluginVersion() { return 1; }
 
 Status ProcessWindows::EnableBreakpointSite(BreakpointSite *bp_site) {
+  if (bp_site->HardwareRequired())
+return Status("Hardware breakpoints are not supported.");
+
   Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_BREAKPOINTS);
   LLDB_LOG(log, "bp_site = {0:x}, id={1}, addr={2:x}", bp_site,
bp_site->GetID(), bp_site->GetLoadAddress());
Index: lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
===
--- lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
+++ lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
@@ -644,6 +644,9 @@
 }
 
 Status ProcessKDP::EnableBreakpointSite(BreakpointSite *bp_site) {
+  if (bp_site->HardwareRequired())
+return Status("Hardware breakpoints are not supported.");
+
   if (m_comm.LocalBreakpointsAreSupported()) {
 Status error;
 if (!bp_site->IsEnabled()) {
Index: lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
===
--- lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
+++ lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
@@ -683,6 +683,9 @@
 }
 
 Status ProcessFreeBSD::EnableBreakpointSite(BreakpointSite *bp_site) {
+  if (bp_site->HardwareRequired())
+return Status("Hardware breakpoints are not supported.");
+
   return EnableSoftwareBreakpoint(bp_site);
 }
 


Index: lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/TestRequireHWBreakpoints.py
===
--- lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/TestRequireHWBreakpoints.py
+++ lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/TestRequireHWBreakpoints.py
@@ -27,7 +27,6 @@
 breakpoint = target.BreakpointCreateByLocation("main.c", 1)
 self.assertTrue(breakpoint.IsHardware())
 
-@skipIfWindows
 @expectedFailure(supports_hw_breakpoints)
 def test_step_range(self):
 """Test stepping when hardware breakpoints are required."""
@@ -49,7 +48,6 @@
 self.assertTrue("Could not create hardware breakpoint for thread plan"
 in err

[Lldb-commits] [PATCH] D84254: [lldb] Skip overlapping hardware and external breakpoints when writing memory

2020-07-29 Thread Tatyana Krasnukha via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf7ec3e3be70d: [lldb] Skip overlapping hardware and external 
breakpoints when writing memory (authored by tatyana-krasnukha).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84254

Files:
  lldb/source/Breakpoint/BreakpointSite.cpp
  lldb/source/Target/Process.cpp
  
lldb/test/API/functionalities/breakpoint/hardware_breakpoints/write_memory_with_hw_breakpoint/Makefile
  
lldb/test/API/functionalities/breakpoint/hardware_breakpoints/write_memory_with_hw_breakpoint/TestWriteMemoryWithHWBreakpoint.py
  
lldb/test/API/functionalities/breakpoint/hardware_breakpoints/write_memory_with_hw_breakpoint/main.cpp

Index: lldb/test/API/functionalities/breakpoint/hardware_breakpoints/write_memory_with_hw_breakpoint/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/breakpoint/hardware_breakpoints/write_memory_with_hw_breakpoint/main.cpp
@@ -0,0 +1,9 @@
+static volatile int num = 1;
+
+bool hw_break_function (int i) {
+  return num == i;
+}
+
+int main (int argc, char const *argv[]) {
+  return hw_break_function(argc) ? 0 : 1;
+}
Index: lldb/test/API/functionalities/breakpoint/hardware_breakpoints/write_memory_with_hw_breakpoint/TestWriteMemoryWithHWBreakpoint.py
===
--- /dev/null
+++ lldb/test/API/functionalities/breakpoint/hardware_breakpoints/write_memory_with_hw_breakpoint/TestWriteMemoryWithHWBreakpoint.py
@@ -0,0 +1,51 @@
+"""
+Test that writing memory does't affect hardware breakpoints.
+"""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+from functionalities.breakpoint.hardware_breakpoints.base import *
+
+class WriteMemoryWithHWBreakpoint(HardwareBreakpointTestBase):
+mydir = TestBase.compute_mydir(__file__)
+
+def does_not_support_hw_breakpoints(self):
+return not super().supports_hw_breakpoints()
+
+@skipTestIfFn(does_not_support_hw_breakpoints)
+def test_copy_memory_with_hw_break(self):
+self.build()
+exe = self.getBuildArtifact("a.out")
+
+# Create a target by the debugger.
+target = self.dbg.CreateTarget(exe)
+self.assertTrue(target, VALID_TARGET)
+
+# Run the program and stop at entry.
+self.expect("process launch --stop-at-entry",
+patterns=["Process .* launched: .*a.out"])
+
+process = target.GetProcess()
+self.assertTrue(process, PROCESS_IS_VALID)
+
+# Set a hardware breakpoint.
+bp_id = lldbutil.run_break_set_by_symbol(self, "hw_break_function",
+ extra_options="--hardware")
+
+# Get breakpoint location from the breakpoint.
+location = target.FindBreakpointByID(bp_id).GetLocationAtIndex(0)
+self.assertTrue(location and location.IsResolved(),
+VALID_BREAKPOINT_LOCATION)
+
+# Check that writing overlapping memory doesn't crash.
+address = location.GetLoadAddress()
+data = str("\x01\x02\x03\x04")
+error = lldb.SBError()
+
+result = process.WriteMemory(address, data, error)
+self.assertTrue(error.Success() and result == len(bytes))
Index: lldb/test/API/functionalities/breakpoint/hardware_breakpoints/write_memory_with_hw_breakpoint/Makefile
===
--- /dev/null
+++ lldb/test/API/functionalities/breakpoint/hardware_breakpoints/write_memory_with_hw_breakpoint/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: lldb/source/Target/Process.cpp
===
--- lldb/source/Target/Process.cpp
+++ lldb/source/Target/Process.cpp
@@ -2291,6 +2291,9 @@
 if (error.Fail())
   return;
 
+if (bp->GetType() != BreakpointSite::eSoftware)
+  return;
+
 addr_t intersect_addr;
 size_t intersect_size;
 size_t opcode_offset;
Index: lldb/source/Breakpoint/BreakpointSite.cpp
===
--- lldb/source/Breakpoint/BreakpointSite.cpp
+++ lldb/source/Breakpoint/BreakpointSite.cpp
@@ -167,40 +167,39 @@
  lldb::addr_t *intersect_addr,
  size_t *intersect_size,
  size_t *opcode_offset) const {
-  // We only use software traps for software breakpoints
-  if (!IsHardware()) {
-if (m_byte_size > 0) {
-  const lldb::addr_t bp_end_addr = m_addr + m_byte_size;
-  const lldb::addr_t end_addr = addr + size;
-  // Is the breakpoint end address before the passed in start address?
- 

[Lldb-commits] [PATCH] D84311: [lldb/test] Put hardware breakpoint tests together, NFC

2020-07-29 Thread Tatyana Krasnukha via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc114352edfe0: [lldb/test] Put hardware breakpoint tests 
together, NFC (authored by tatyana-krasnukha).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84311

Files:
  lldb/test/API/functionalities/breakpoint/hardware_breakpoints/base.py
  
lldb/test/API/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py
  
lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/Makefile
  
lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/TestRequireHWBreakpoints.py
  
lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/main.c
  lldb/test/API/functionalities/breakpoint/require_hw_breakpoints/Makefile
  
lldb/test/API/functionalities/breakpoint/require_hw_breakpoints/TestRequireHWBreakpoints.py
  lldb/test/API/functionalities/breakpoint/require_hw_breakpoints/main.c

Index: lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/TestRequireHWBreakpoints.py
===
--- lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/TestRequireHWBreakpoints.py
+++ lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/TestRequireHWBreakpoints.py
@@ -8,20 +8,13 @@
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
 
+from functionalities.breakpoint.hardware_breakpoints.base import *
 
-class BreakpointLocationsTestCase(TestBase):
-NO_DEBUG_INFO_TESTCASE = True
+class BreakpointLocationsTestCase(HardwareBreakpointTestBase):
 mydir = TestBase.compute_mydir(__file__)
 
 def supports_hw_breakpoints(self):
-self.build()
-self.runCmd("file " + self.getBuildArtifact("a.out"),
-CURRENT_EXECUTABLE_SET)
-self.runCmd("breakpoint set -b main --hardware")
-self.runCmd("run")
-if 'stopped' in self.res.GetOutput():
-return 'Hardware breakpoints are supported'
-return None
+return super().supports_hw_breakpoints()
 
 def test_breakpoint(self):
 """Test regular breakpoints when hardware breakpoints are required."""
Index: lldb/test/API/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py
===
--- lldb/test/API/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py
+++ lldb/test/API/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py
@@ -9,15 +9,18 @@
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
 
-class HardwareBreakpointMultiThreadTestCase(TestBase):
-NO_DEBUG_INFO_TESTCASE = True
+from functionalities.breakpoint.hardware_breakpoints.base import *
 
+class HardwareBreakpointMultiThreadTestCase(HardwareBreakpointTestBase):
 mydir = TestBase.compute_mydir(__file__)
 
+def does_not_support_hw_breakpoints(self):
+return not super().supports_hw_breakpoints()
+
 # LLDB on linux supports hardware breakpoints for arm and aarch64
 # architectures.
 @skipUnlessPlatform(oslist=['linux'])
-@skipIf(archs=no_match(['arm', 'aarch64']))
+@skipTestIfFn(does_not_support_hw_breakpoints)
 def test_hw_break_set_delete_multi_thread_linux(self):
 self.build()
 self.setTearDownCleanup()
@@ -26,7 +29,7 @@
 # LLDB on linux supports hardware breakpoints for arm and aarch64
 # architectures.
 @skipUnlessPlatform(oslist=['linux'])
-@skipIf(archs=no_match(['arm', 'aarch64']))
+@skipTestIfFn(does_not_support_hw_breakpoints)
 def test_hw_break_set_disable_multi_thread_linux(self):
 self.build()
 self.setTearDownCleanup()
@@ -36,7 +39,7 @@
 # architectures.
 @skipUnlessDarwin
 @skipIfOutOfTreeDebugserver
-@expectedFailureAll(archs=["arm64"])
+@skipTestIfFn(does_not_support_hw_breakpoints)
 def test_hw_break_set_delete_multi_thread_macos(self):
 self.build()
 self.setTearDownCleanup()
@@ -46,7 +49,7 @@
 # architectures.
 @skipUnlessDarwin
 @skipIfOutOfTreeDebugserver
-@expectedFailureAll(archs=["arm64"])
+@skipTestIfFn(does_not_support_hw_breakpoints)
 def test_hw_break_set_disable_multi_thread_macos(self):
 self.build()
 self.setTearDownCleanup()
Index: lldb/test/API/functionalities/breakpoint/hardware_breakpoints/base.py
===
--- /dev/null
+++ lldb/test/API/functionalities/breakpoint/hardware_breakpoints/ba

[Lldb-commits] [PATCH] D84527: Rename StoppointLocation to StoppointSite and drop its relationship with BreakpointLocation

2020-07-29 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha updated this revision to Diff 281600.
tatyana-krasnukha added reviewers: JDevlieghere, jingham.
tatyana-krasnukha added a comment.

Addressed comments.

> It's also a little weird that we're clearing watchpoint hit counts when a 
> process dies, but not breakpoint hit counts. If we do one we should do the 
> other...

BreakpointSites die with the Process, so there is no need to reset their hit 
count. I'm not sure what logic Breakpoint should follow (as it lives without a 
process). If we are going to change it, I would do it in a different revision.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84527

Files:
  lldb/include/lldb/Breakpoint/Breakpoint.h
  lldb/include/lldb/Breakpoint/BreakpointLocation.h
  lldb/include/lldb/Breakpoint/BreakpointSite.h
  lldb/include/lldb/Breakpoint/StoppointHitCounter.h
  lldb/include/lldb/Breakpoint/StoppointLocation.h
  lldb/include/lldb/Breakpoint/StoppointSite.h
  lldb/include/lldb/Breakpoint/Watchpoint.h
  lldb/include/lldb/lldb-forward.h
  lldb/source/Breakpoint/Breakpoint.cpp
  lldb/source/Breakpoint/BreakpointLocation.cpp
  lldb/source/Breakpoint/BreakpointSite.cpp
  lldb/source/Breakpoint/CMakeLists.txt
  lldb/source/Breakpoint/StoppointLocation.cpp
  lldb/source/Breakpoint/StoppointSite.cpp
  lldb/source/Breakpoint/Watchpoint.cpp

Index: lldb/source/Breakpoint/Watchpoint.cpp
===
--- lldb/source/Breakpoint/Watchpoint.cpp
+++ lldb/source/Breakpoint/Watchpoint.cpp
@@ -25,7 +25,7 @@
 
 Watchpoint::Watchpoint(Target &target, lldb::addr_t addr, uint32_t size,
const CompilerType *type, bool hardware)
-: StoppointLocation(0, addr, size, hardware), m_target(target),
+: StoppointSite(0, addr, size, hardware), m_target(target),
   m_enabled(false), m_is_hardware(hardware), m_is_watch_variable(false),
   m_is_ephemeral(false), m_disabled_count(0), m_watch_read(0),
   m_watch_write(0), m_watch_was_read(0), m_watch_was_written(0),
@@ -93,8 +93,6 @@
   m_watch_spec_str = str;
 }
 
-// Override default impl of StoppointLocation::IsHardware() since m_is_hardware
-// member field is more accurate.
 bool Watchpoint::IsHardware() const {
   lldbassert(m_is_hardware || GetHardwareIndex() == LLDB_INVALID_INDEX32);
   lldbassert(m_is_hardware || !HardwareRequired());
@@ -127,12 +125,12 @@
 void Watchpoint::IncrementFalseAlarmsAndReviseHitCount() {
   ++m_false_alarms;
   if (m_false_alarms) {
-if (m_hit_count >= m_false_alarms) {
-  m_hit_count -= m_false_alarms;
+if (m_hit_counter.GetValue() >= m_false_alarms) {
+  m_hit_counter.Decrement(m_false_alarms);
   m_false_alarms = 0;
 } else {
-  m_false_alarms -= m_hit_count;
-  m_hit_count = 0;
+  m_false_alarms -= m_hit_counter.GetValue();
+  m_hit_counter.Reset();
 }
   }
 }
@@ -141,7 +139,7 @@
 // should continue.
 
 bool Watchpoint::ShouldStop(StoppointCallbackContext *context) {
-  IncrementHitCount();
+  m_hit_counter.Increment();
 
   return IsEnabled();
 }
Index: lldb/source/Breakpoint/StoppointSite.cpp
===
--- /dev/null
+++ lldb/source/Breakpoint/StoppointSite.cpp
@@ -0,0 +1,23 @@
+//===-- StoppointSite.cpp -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "lldb/Breakpoint/StoppointSite.h"
+
+
+using namespace lldb;
+using namespace lldb_private;
+
+StoppointSite::StoppointSite(break_id_t id, addr_t addr, bool hardware)
+: m_id(id), m_addr(addr), m_is_hardware_required(hardware),
+  m_hardware_index(LLDB_INVALID_INDEX32), m_byte_size(0), m_hit_counter() {}
+
+StoppointSite::StoppointSite(break_id_t id, addr_t addr,
+ uint32_t byte_size, bool hardware)
+: m_id(id), m_addr(addr), m_is_hardware_required(hardware),
+  m_hardware_index(LLDB_INVALID_INDEX32), m_byte_size(byte_size),
+  m_hit_counter() {}
Index: lldb/source/Breakpoint/StoppointLocation.cpp
===
--- lldb/source/Breakpoint/StoppointLocation.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-//===-- StoppointLocation.cpp -===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-
-#include "lldb/Breakpoint/StoppointLocation.h"
-
-
-using namespace lldb;
-using namespace lldb_private

[Lldb-commits] [PATCH] D84255: [lldb] Make process plugins check whether a hardware breakpoint is required

2020-07-29 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha updated this revision to Diff 281598.
tatyana-krasnukha added reviewers: labath, JDevlieghere.
tatyana-krasnukha added a comment.

Un-skip TestRequireHWBreakpoints.py on Windows, now it works as expected.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84255

Files:
  lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
  lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
  lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
  
lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/TestRequireHWBreakpoints.py


Index: 
lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/TestRequireHWBreakpoints.py
===
--- 
lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/TestRequireHWBreakpoints.py
+++ 
lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/TestRequireHWBreakpoints.py
@@ -27,7 +27,6 @@
 breakpoint = target.BreakpointCreateByLocation("main.c", 1)
 self.assertTrue(breakpoint.IsHardware())
 
-@skipIfWindows
 @expectedFailure(supports_hw_breakpoints)
 def test_step_range(self):
 """Test stepping when hardware breakpoints are required."""
@@ -49,7 +48,6 @@
 self.assertTrue("Could not create hardware breakpoint for thread plan"
 in error.GetCString())
 
-@skipIfWindows
 @expectedFailure(supports_hw_breakpoints)
 def test_step_out(self):
 """Test stepping out when hardware breakpoints are required."""
@@ -70,7 +68,6 @@
 self.assertTrue("Could not create hardware breakpoint for thread plan"
 in error.GetCString())
 
-@skipIfWindows
 @expectedFailure(supports_hw_breakpoints)
 def test_step_over(self):
 """Test stepping over when hardware breakpoints are required."""
@@ -89,7 +86,6 @@
 'error: Could not create hardware breakpoint for thread plan.'
 ])
 
-@skipIfWindows
 @expectedFailure(supports_hw_breakpoints)
 def test_step_until(self):
 """Test stepping until when hardware breakpoints are required."""
Index: lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
+++ lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
@@ -150,6 +150,9 @@
 uint32_t ProcessWindows::GetPluginVersion() { return 1; }
 
 Status ProcessWindows::EnableBreakpointSite(BreakpointSite *bp_site) {
+  if (bp_site->HardwareRequired())
+return Status("Hardware breakpoints are not supported.");
+
   Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_BREAKPOINTS);
   LLDB_LOG(log, "bp_site = {0:x}, id={1}, addr={2:x}", bp_site,
bp_site->GetID(), bp_site->GetLoadAddress());
Index: lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
===
--- lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
+++ lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
@@ -644,6 +644,9 @@
 }
 
 Status ProcessKDP::EnableBreakpointSite(BreakpointSite *bp_site) {
+  if (bp_site->HardwareRequired())
+return Status("Hardware breakpoints are not supported.");
+
   if (m_comm.LocalBreakpointsAreSupported()) {
 Status error;
 if (!bp_site->IsEnabled()) {
Index: lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
===
--- lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
+++ lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
@@ -683,6 +683,9 @@
 }
 
 Status ProcessFreeBSD::EnableBreakpointSite(BreakpointSite *bp_site) {
+  if (bp_site->HardwareRequired())
+return Status("Hardware breakpoints are not supported.");
+
   return EnableSoftwareBreakpoint(bp_site);
 }
 


Index: lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/TestRequireHWBreakpoints.py
===
--- lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/TestRequireHWBreakpoints.py
+++ lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/TestRequireHWBreakpoints.py
@@ -27,7 +27,6 @@
 breakpoint = target.BreakpointCreateByLocation("main.c", 1)
 self.assertTrue(breakpoint.IsHardware())
 
-@skipIfWindows
 @expectedFailure(supports_hw_breakpoints)
 def test_step_range(self):
 """Test stepping when hardware breakpoints are required."""
@@ -49,7 +48,6 @@
 self.assertTrue("Could not create hardware breakpoint for thread plan"
 in error.GetCString())
 
-@skipIfWindows
 @expe

[Lldb-commits] [PATCH] D84257: [lldb] Don't use hardware index to determine whether a breakpoint site is hardware

2020-07-24 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha added a comment.

I went further than just moving m_hardware_index from StoppointLocation. 
Please, take a look at D84527  and let me know 
what you think about that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84257



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


[Lldb-commits] [PATCH] D84257: [lldb] Don't use hardware index to determine whether a breakpoint site is hardware

2020-07-24 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha updated this revision to Diff 280448.
tatyana-krasnukha added a comment.

@omjavaid, thank you for verifying this!

Added the checks that IsHardware is consistent with m_hardware_index.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84257

Files:
  lldb/include/lldb/Breakpoint/BreakpointLocation.h
  lldb/include/lldb/Breakpoint/BreakpointSite.h
  lldb/include/lldb/Breakpoint/StoppointLocation.h
  lldb/source/Breakpoint/BreakpointLocation.cpp
  lldb/source/Breakpoint/Watchpoint.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  
lldb/test/API/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py

Index: lldb/test/API/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py
===
--- lldb/test/API/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py
+++ lldb/test/API/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py
@@ -17,27 +17,6 @@
 def does_not_support_hw_breakpoints(self):
 return not super().supports_hw_breakpoints()
 
-# LLDB on linux supports hardware breakpoints for arm and aarch64
-# architectures.
-@skipUnlessPlatform(oslist=['linux'])
-@skipTestIfFn(does_not_support_hw_breakpoints)
-def test_hw_break_set_delete_multi_thread_linux(self):
-self.build()
-self.setTearDownCleanup()
-self.break_multi_thread('delete', False) # llvm.org/PR44659
-
-# LLDB on linux supports hardware breakpoints for arm and aarch64
-# architectures.
-@skipUnlessPlatform(oslist=['linux'])
-@skipTestIfFn(does_not_support_hw_breakpoints)
-def test_hw_break_set_disable_multi_thread_linux(self):
-self.build()
-self.setTearDownCleanup()
-self.break_multi_thread('disable', False) # llvm.org/PR44659
-
-# LLDB on darwin supports hardware breakpoints for x86_64 and i386
-# architectures.
-@skipUnlessDarwin
 @skipIfOutOfTreeDebugserver
 @skipTestIfFn(does_not_support_hw_breakpoints)
 def test_hw_break_set_delete_multi_thread_macos(self):
@@ -45,9 +24,6 @@
 self.setTearDownCleanup()
 self.break_multi_thread('delete')
 
-# LLDB on darwin supports hardware breakpoints for x86_64 and i386
-# architectures.
-@skipUnlessDarwin
 @skipIfOutOfTreeDebugserver
 @skipTestIfFn(does_not_support_hw_breakpoints)
 def test_hw_break_set_disable_multi_thread_macos(self):
@@ -55,7 +31,6 @@
 self.setTearDownCleanup()
 self.break_multi_thread('disable')
 
-
 def setUp(self):
 # Call super's setUp().
 TestBase.setUp(self)
@@ -65,7 +40,7 @@
 self.first_stop = line_number(
 self.source, 'Starting thread creation with hardware breakpoint set')
 
-def break_multi_thread(self, removal_type, check_hw_bp=True):
+def break_multi_thread(self, removal_type):
 """Test that lldb hardware breakpoints work for multiple threads."""
 self.runCmd("file " + self.getBuildArtifact("a.out"),
 CURRENT_EXECUTABLE_SET)
@@ -109,10 +84,9 @@
 # Continue the loop and test that we are stopped 4 times.
 count += 1
 
-if check_hw_bp:
-# Check the breakpoint list.
-self.expect("breakpoint list", substrs=['hw_break_function', 'hardware'])
-self.expect("breakpoint list -v", substrs=['function = hw_break_function', 'hardware = true'])
+# Check the breakpoint list.
+self.expect("breakpoint list", substrs=['hw_break_function', 'hardware'])
+self.expect("breakpoint list -v", substrs=['function = hw_break_function', 'hardware = true'])
 
 if removal_type == 'delete':
 self.runCmd("settings set auto-confirm true")
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -3204,14 +3204,8 @@
   break;
 
 case BreakpointSite::eExternal: {
-  GDBStoppointType stoppoint_type;
-  if (bp_site->IsHardware())
-stoppoint_type = eBreakpointHardware;
-  else
-stoppoint_type = eBreakpointSoftware;
-
-  if (m_gdb_comm.SendGDBStoppointTypePacket(stoppoint_type, false, addr,
-bp_op_size))
+  if (m_gdb_comm.SendGDBStoppointTypePacket(eBreakpointSoftware, false,
+addr, bp_op_size))
 error.SetErrorToGenericError();
 } break;
 }
Index: lldb/source/Breakpoint/Watchpoint.cpp

[Lldb-commits] [PATCH] D84527: Rename StoppointLocation to StoppointSite and drop its relationship with BreakpointLocation

2020-07-24 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha created this revision.
Herald added subscribers: lldb-commits, yaxunl, mgorny.
Herald added a project: LLDB.

Working on the patch  D84257  I noticed that 
both BreakpointLocation and BreakpointSite were inherited from 
StoppointLocation. Also, I noticed that they have not so much in common, except 
the //id// and hit counting logic.
There is no polymorphic code that uses a pointer/reference to StoppointLocation 
to handle one of BreakpointLocation and BreakpointSite either.

The patch renames  StoppointLocation to StoppointSite and stops 
BreakpointLocation's inheriting from it.
Hit counting is encapsulated into StoppointHitCounter which is re-used it in 
StoppointSite, BreakpointLocation, and Breakpoint.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84527

Files:
  lldb/include/lldb/Breakpoint/Breakpoint.h
  lldb/include/lldb/Breakpoint/BreakpointLocation.h
  lldb/include/lldb/Breakpoint/BreakpointSite.h
  lldb/include/lldb/Breakpoint/StoppointHitCounter.h
  lldb/include/lldb/Breakpoint/StoppointLocation.h
  lldb/include/lldb/Breakpoint/StoppointSite.h
  lldb/include/lldb/Breakpoint/Watchpoint.h
  lldb/source/Breakpoint/Breakpoint.cpp
  lldb/source/Breakpoint/BreakpointLocation.cpp
  lldb/source/Breakpoint/BreakpointSite.cpp
  lldb/source/Breakpoint/CMakeLists.txt
  lldb/source/Breakpoint/StoppointLocation.cpp
  lldb/source/Breakpoint/StoppointSite.cpp
  lldb/source/Breakpoint/Watchpoint.cpp
  lldb/source/Target/Target.cpp

Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -1233,7 +1233,7 @@
 if (!wp_sp)
   return false;
 
-wp_sp->ResetHitCount();
+wp_sp->m_hit_counter.Reset();
   }
   return true; // Success!
 }
Index: lldb/source/Breakpoint/Watchpoint.cpp
===
--- lldb/source/Breakpoint/Watchpoint.cpp
+++ lldb/source/Breakpoint/Watchpoint.cpp
@@ -25,7 +25,7 @@
 
 Watchpoint::Watchpoint(Target &target, lldb::addr_t addr, uint32_t size,
const CompilerType *type, bool hardware)
-: StoppointLocation(0, addr, size, hardware), m_target(target),
+: StoppointSite(0, addr, size, hardware), m_target(target),
   m_enabled(false), m_is_hardware(hardware), m_is_watch_variable(false),
   m_is_ephemeral(false), m_disabled_count(0), m_watch_read(0),
   m_watch_write(0), m_watch_was_read(0), m_watch_was_written(0),
@@ -93,8 +93,6 @@
   m_watch_spec_str = str;
 }
 
-// Override default impl of StoppointLocation::IsHardware() since m_is_hardware
-// member field is more accurate.
 bool Watchpoint::IsHardware() const {
   lldbassert(m_is_hardware || GetHardwareIndex() == LLDB_INVALID_INDEX32);
   lldbassert(m_is_hardware || !HardwareRequired());
@@ -127,12 +125,12 @@
 void Watchpoint::IncrementFalseAlarmsAndReviseHitCount() {
   ++m_false_alarms;
   if (m_false_alarms) {
-if (m_hit_count >= m_false_alarms) {
-  m_hit_count -= m_false_alarms;
+if (m_hit_counter.GetValue() >= m_false_alarms) {
+  m_hit_counter.Decrement(m_false_alarms);
   m_false_alarms = 0;
 } else {
-  m_false_alarms -= m_hit_count;
-  m_hit_count = 0;
+  m_false_alarms -= m_hit_counter.GetValue();
+  m_hit_counter.Reset();
 }
   }
 }
@@ -141,7 +139,7 @@
 // should continue.
 
 bool Watchpoint::ShouldStop(StoppointCallbackContext *context) {
-  IncrementHitCount();
+  m_hit_counter.Increment();
 
   return IsEnabled();
 }
Index: lldb/source/Breakpoint/StoppointSite.cpp
===
--- /dev/null
+++ lldb/source/Breakpoint/StoppointSite.cpp
@@ -0,0 +1,24 @@
+//===-- StoppointSite.cpp -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "lldb/Breakpoint/StoppointSite.h"
+
+
+using namespace lldb;
+using namespace lldb_private;
+
+// StoppointSite constructor
+StoppointSite::StoppointSite(break_id_t id, addr_t addr, bool hardware)
+: m_id(id), m_addr(addr), m_is_hardware_required(hardware),
+  m_hardware_index(LLDB_INVALID_INDEX32), m_byte_size(0), m_hit_counter() {}
+
+StoppointSite::StoppointSite(break_id_t id, addr_t addr,
+ uint32_t byte_size, bool hardware)
+: m_id(id), m_addr(addr), m_is_hardware_required(hardware),
+  m_hardware_index(LLDB_INVALID_INDEX32), m_byte_size(byte_size),
+  m_hit_counter() {}
Index: lldb/source/Breakpoint/StoppointLocation.cpp
===
--- lldb/source/Breakpoint/StoppointLocation.cpp
+++ /dev/null
@@ -1,32 +0

[Lldb-commits] [PATCH] D84311: [lldb/test] Put hardware breakpoint tests together, NFC

2020-07-22 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha created this revision.
tatyana-krasnukha added reviewers: JDevlieghere, labath.
tatyana-krasnukha added a project: LLDB.
Herald added a subscriber: lldb-commits.

Create a common base class for them to re-use supports_hw_breakpoints function 
in decorators.

This is a preparatory patch for the D84254  
which adds one more test with hardware breakpoints.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84311

Files:
  lldb/test/API/functionalities/breakpoint/hardware_breakpoints/base.py
  
lldb/test/API/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py
  
lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/Makefile
  
lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/TestRequireHWBreakpoints.py
  
lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/main.c
  lldb/test/API/functionalities/breakpoint/require_hw_breakpoints/Makefile
  
lldb/test/API/functionalities/breakpoint/require_hw_breakpoints/TestRequireHWBreakpoints.py
  lldb/test/API/functionalities/breakpoint/require_hw_breakpoints/main.c

Index: lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/TestRequireHWBreakpoints.py
===
--- lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/TestRequireHWBreakpoints.py
+++ lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/TestRequireHWBreakpoints.py
@@ -8,20 +8,13 @@
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
 
+from functionalities.breakpoint.hardware_breakpoints.base import *
 
-class BreakpointLocationsTestCase(TestBase):
-NO_DEBUG_INFO_TESTCASE = True
+class BreakpointLocationsTestCase(HardwareBreakpointTestBase):
 mydir = TestBase.compute_mydir(__file__)
 
 def supports_hw_breakpoints(self):
-self.build()
-self.runCmd("file " + self.getBuildArtifact("a.out"),
-CURRENT_EXECUTABLE_SET)
-self.runCmd("breakpoint set -b main --hardware")
-self.runCmd("run")
-if 'stopped' in self.res.GetOutput():
-return 'Hardware breakpoints are supported'
-return None
+return super().supports_hw_breakpoints()
 
 def test_breakpoint(self):
 """Test regular breakpoints when hardware breakpoints are required."""
Index: lldb/test/API/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py
===
--- lldb/test/API/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py
+++ lldb/test/API/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py
@@ -9,15 +9,18 @@
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
 
-class HardwareBreakpointMultiThreadTestCase(TestBase):
-NO_DEBUG_INFO_TESTCASE = True
+from functionalities.breakpoint.hardware_breakpoints.base import *
 
+class HardwareBreakpointMultiThreadTestCase(HardwareBreakpointTestBase):
 mydir = TestBase.compute_mydir(__file__)
 
+def does_not_support_hw_breakpoints(self):
+return not super().supports_hw_breakpoints()
+
 # LLDB on linux supports hardware breakpoints for arm and aarch64
 # architectures.
 @skipUnlessPlatform(oslist=['linux'])
-@skipIf(archs=no_match(['arm', 'aarch64']))
+@skipTestIfFn(does_not_support_hw_breakpoints)
 def test_hw_break_set_delete_multi_thread_linux(self):
 self.build()
 self.setTearDownCleanup()
@@ -26,7 +29,7 @@
 # LLDB on linux supports hardware breakpoints for arm and aarch64
 # architectures.
 @skipUnlessPlatform(oslist=['linux'])
-@skipIf(archs=no_match(['arm', 'aarch64']))
+@skipTestIfFn(does_not_support_hw_breakpoints)
 def test_hw_break_set_disable_multi_thread_linux(self):
 self.build()
 self.setTearDownCleanup()
@@ -36,7 +39,7 @@
 # architectures.
 @skipUnlessDarwin
 @skipIfOutOfTreeDebugserver
-@expectedFailureAll(archs=["arm64"])
+@skipTestIfFn(does_not_support_hw_breakpoints)
 def test_hw_break_set_delete_multi_thread_macos(self):
 self.build()
 self.setTearDownCleanup()
@@ -46,7 +49,7 @@
 # architectures.
 @skipUnlessDarwin
 @skipIfOutOfTreeDebugserver
-@expectedFailureAll(archs=["arm64"])
+@skipTestIfFn(does_not_support_hw_breakpoints)
 def test_hw_break_set_disable_multi_thread_macos(self):
 self.build()
 self.setTearDownCleanup()
Index: lldb/test/API/functionalities/breakpoint/hardware_breakpoints/base.py
=

[Lldb-commits] [PATCH] D84254: [lldb] Skip overlapping hardware and external breakpoints when writing memory

2020-07-22 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha updated this revision to Diff 279777.
tatyana-krasnukha added a comment.

`BreakpointSite::IntersectsRange` returns `false` for hardware breakpoints, 
that's why the assertion fails.

Since my bare-metal target loads process's memory via Process::WriteMemory, I 
have 200+ unresolved tests without this change.

The added test should reproduce the issue for other targets too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84254

Files:
  lldb/source/Breakpoint/BreakpointSite.cpp
  lldb/source/Target/Process.cpp
  
lldb/test/API/functionalities/breakpoint/hardware_breakpoints/write_memory_with_hw_breakpoint/Makefile
  
lldb/test/API/functionalities/breakpoint/hardware_breakpoints/write_memory_with_hw_breakpoint/TestWriteMemoryWithHWBreakpoint.py
  
lldb/test/API/functionalities/breakpoint/hardware_breakpoints/write_memory_with_hw_breakpoint/main.cpp

Index: lldb/test/API/functionalities/breakpoint/hardware_breakpoints/write_memory_with_hw_breakpoint/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/breakpoint/hardware_breakpoints/write_memory_with_hw_breakpoint/main.cpp
@@ -0,0 +1,9 @@
+static volatile int num = 1;
+
+bool hw_break_function (int i) {
+  return num == i;
+}
+
+int main (int argc, char const *argv[]) {
+  return hw_break_function(argc) ? 0 : 1;
+}
Index: lldb/test/API/functionalities/breakpoint/hardware_breakpoints/write_memory_with_hw_breakpoint/TestWriteMemoryWithHWBreakpoint.py
===
--- /dev/null
+++ lldb/test/API/functionalities/breakpoint/hardware_breakpoints/write_memory_with_hw_breakpoint/TestWriteMemoryWithHWBreakpoint.py
@@ -0,0 +1,51 @@
+"""
+Test that writing memory does't affect hardware breakpoints.
+"""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+from functionalities.breakpoint.hardware_breakpoints.base import *
+
+class WriteMemoryWithHWBreakpoint(HardwareBreakpointTestBase):
+mydir = TestBase.compute_mydir(__file__)
+
+def does_not_support_hw_breakpoints(self):
+return not super().supports_hw_breakpoints()
+
+@skipTestIfFn(does_not_support_hw_breakpoints)
+def test_copy_memory_with_hw_break(self):
+self.build()
+exe = self.getBuildArtifact("a.out")
+
+# Create a target by the debugger.
+target = self.dbg.CreateTarget(exe)
+self.assertTrue(target, VALID_TARGET)
+
+# Run the program and stop at entry.
+self.expect("process launch --stop-at-entry",
+patterns=["Process .* launched: .*a.out"])
+
+process = target.GetProcess()
+self.assertTrue(process, PROCESS_IS_VALID)
+
+# Set a hardware breakpoint.
+bp_id = lldbutil.run_break_set_by_symbol(self, "hw_break_function",
+ extra_options="--hardware")
+
+# Get breakpoint location from the breakpoint.
+location = target.FindBreakpointByID(bp_id).GetLocationAtIndex(0)
+self.assertTrue(location and location.IsResolved(),
+VALID_BREAKPOINT_LOCATION)
+
+# Check that writing overlapping memory doesn't crash.
+address = location.GetLoadAddress()
+data = str("\x01\x02\x03\x04")
+error = lldb.SBError()
+
+result = process.WriteMemory(address, data, error)
+self.assertTrue(error.Success() and result == len(bytes))
Index: lldb/test/API/functionalities/breakpoint/hardware_breakpoints/write_memory_with_hw_breakpoint/Makefile
===
--- /dev/null
+++ lldb/test/API/functionalities/breakpoint/hardware_breakpoints/write_memory_with_hw_breakpoint/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: lldb/source/Target/Process.cpp
===
--- lldb/source/Target/Process.cpp
+++ lldb/source/Target/Process.cpp
@@ -2291,6 +2291,9 @@
 if (error.Fail())
   return;
 
+if (bp->GetType() != BreakpointSite::eSoftware)
+  return;
+
 addr_t intersect_addr;
 size_t intersect_size;
 size_t opcode_offset;
Index: lldb/source/Breakpoint/BreakpointSite.cpp
===
--- lldb/source/Breakpoint/BreakpointSite.cpp
+++ lldb/source/Breakpoint/BreakpointSite.cpp
@@ -167,40 +167,39 @@
  lldb::addr_t *intersect_addr,
  size_t *intersect_size,
  size_t *opcode_offset) const {
-  // We only use software traps for software breakpoints
-  if (!IsHardware()) {
-if (m_byte_size > 0) {
-  const lldb::addr_t bp_end_addr = m_addr + m_byte_size;
-  

[Lldb-commits] [PATCH] D84257: [lldb] Don't use hardware index to determine whether a breakpoint site is hardware

2020-07-22 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha added a comment.






Comment at: lldb/source/Breakpoint/BreakpointLocation.cpp:73
+  if (m_bp_site_sp)
+return m_bp_site_sp->IsHardware();
+

JDevlieghere wrote:
> Should we sanity check that this is true when `m_hardware_index != 
> LLDB_INVALID_INDEX32`? 
> 
> ```lldbassert(m_hardware_index == LLDB_INVALID_INDEX32 || 
> m_bp_site_sp->IsHardware());```
This is a good point. Though, should we check BreakpointLocation's 
m_hardware_index or BreakpointSite's m_hardware_index? Both of them inherit 
this member from StoppointLocation. To be honest, I don't think that 
BreakpointLocation should have software/hardware trait at all.



Comment at: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp:3208
 case BreakpointSite::eExternal: {
-  GDBStoppointType stoppoint_type;
-  if (bp_site->IsHardware())
-stoppoint_type = eBreakpointHardware;
-  else
-stoppoint_type = eBreakpointSoftware;
-
-  if (m_gdb_comm.SendGDBStoppointTypePacket(stoppoint_type, false, addr,
-bp_op_size))
+  if (m_gdb_comm.SendGDBStoppointTypePacket(eBreakpointSoftware, false,
+addr, bp_op_size))

>>! In D84257#2166081, @labath wrote:
> Could you clarify what's the functional change here? Does this change the 
> kind of breakpoint that lldb sets, or just how it gets reported? E.g., does 
> the `ProcessGDBRemote` acutally cause lldb to send a different packet, or is 
> that just reacting to the change in the semantics of other code?

In the `ProcessGDBRemote::EnableBreakpointSite` (lines 3098 - 3103) it always 
creates external breakpoint with `eBreakpointSoftware`, so nothing is going to 
be changed in ProcessGDBRemote behavior. And now, when `bp_site->IsHardware()` 
checks whether BreakpontSite::Type is BreakpointSite::eHardware , the condition 
`if (bp_site->IsHardware())` doesn't make sense here anymore.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84257



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


[Lldb-commits] [PATCH] D84257: [lldb] Don't use hardware index to determine whether a breakpoint site is hardware

2020-07-21 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha added a comment.

Probably fixes llvm.org/PR44659, though I cannot check on arm/aarch64.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84257



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


[Lldb-commits] [PATCH] D84257: [lldb] Don't use hardware index to determine whether a breakpoint site is hardware

2020-07-21 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha created this revision.
tatyana-krasnukha added reviewers: clayborg, labath, JDevlieghere.
tatyana-krasnukha added a project: LLDB.
Herald added subscribers: lldb-commits, arphaman.

Most process plugins (if not all) don't set hardware index for breakpoints. 
They even are not able to determine this index.
This patch makes StoppointLocation::IsHardware pure virtual and lets 
BreakpointSite override it using more accurate BreakpointSite::Type.

It also adds assertions to be sure that a breakpoint site is hardware when this 
is required.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84257

Files:
  lldb/include/lldb/Breakpoint/BreakpointLocation.h
  lldb/include/lldb/Breakpoint/BreakpointSite.h
  lldb/include/lldb/Breakpoint/StoppointLocation.h
  lldb/source/Breakpoint/BreakpointLocation.cpp
  lldb/source/Breakpoint/Watchpoint.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp

Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -3205,14 +3205,8 @@
   break;
 
 case BreakpointSite::eExternal: {
-  GDBStoppointType stoppoint_type;
-  if (bp_site->IsHardware())
-stoppoint_type = eBreakpointHardware;
-  else
-stoppoint_type = eBreakpointSoftware;
-
-  if (m_gdb_comm.SendGDBStoppointTypePacket(stoppoint_type, false, addr,
-bp_op_size))
+  if (m_gdb_comm.SendGDBStoppointTypePacket(eBreakpointSoftware, false,
+addr, bp_op_size))
 error.SetErrorToGenericError();
 } break;
 }
Index: lldb/source/Breakpoint/Watchpoint.cpp
===
--- lldb/source/Breakpoint/Watchpoint.cpp
+++ lldb/source/Breakpoint/Watchpoint.cpp
@@ -95,7 +95,10 @@
 
 // Override default impl of StoppointLocation::IsHardware() since m_is_hardware
 // member field is more accurate.
-bool Watchpoint::IsHardware() const { return m_is_hardware; }
+bool Watchpoint::IsHardware() const {
+  lldbassert(m_is_hardware || !HardwareRequired());
+  return m_is_hardware;
+}
 
 bool Watchpoint::IsWatchVariable() const { return m_is_watch_variable; }
 
Index: lldb/source/Breakpoint/BreakpointLocation.cpp
===
--- lldb/source/Breakpoint/BreakpointLocation.cpp
+++ lldb/source/Breakpoint/BreakpointLocation.cpp
@@ -68,6 +68,14 @@
 
 Target &BreakpointLocation::GetTarget() { return m_owner.GetTarget(); }
 
+bool BreakpointLocation::IsHardware() const {
+  if (m_bp_site_sp)
+return m_bp_site_sp->IsHardware();
+
+  // If breakpoint location is not resolved yet, it cannot be hardware.
+  return false;
+}
+
 bool BreakpointLocation::IsEnabled() const {
   if (!m_owner.IsEnabled())
 return false;
Index: lldb/include/lldb/Breakpoint/StoppointLocation.h
===
--- lldb/include/lldb/Breakpoint/StoppointLocation.h
+++ lldb/include/lldb/Breakpoint/StoppointLocation.h
@@ -40,9 +40,7 @@
 
   bool HardwareRequired() const { return m_hardware; }
 
-  virtual bool IsHardware() const {
-return m_hardware_index != LLDB_INVALID_INDEX32;
-  }
+  virtual bool IsHardware() const = 0;
 
   virtual bool ShouldStop(StoppointCallbackContext *context) { return true; }
 
Index: lldb/include/lldb/Breakpoint/BreakpointSite.h
===
--- lldb/include/lldb/Breakpoint/BreakpointSite.h
+++ lldb/include/lldb/Breakpoint/BreakpointSite.h
@@ -15,6 +15,7 @@
 
 #include "lldb/Breakpoint/BreakpointLocationCollection.h"
 #include "lldb/Breakpoint/StoppointLocation.h"
+#include "lldb/Utility/LLDBAssert.h"
 #include "lldb/Utility/UserID.h"
 #include "lldb/lldb-forward.h"
 
@@ -184,6 +185,12 @@
   /// \b false otherwise.
   bool IsInternal() const;
 
+  bool IsHardware() const override {
+lldbassert(BreakpointSite::Type::eHardware == GetType() ||
+   !HardwareRequired());
+return BreakpointSite::Type::eHardware == GetType();
+  }
+
   BreakpointSite::Type GetType() const { return m_type; }
 
   void SetType(BreakpointSite::Type type) { m_type = type; }
Index: lldb/include/lldb/Breakpoint/BreakpointLocation.h
===
--- lldb/include/lldb/Breakpoint/BreakpointLocation.h
+++ lldb/include/lldb/Breakpoint/BreakpointLocation.h
@@ -76,6 +76,12 @@
   /// \b true if the breakpoint is enabled, \b false if disabled.
   bool IsEnabled() const;
 
+  /// Check if it is a hardware breakpoint.
+  ///
+  /// \return
+  /// \b true if the breakpoint is a harware breakpoint.
+  bool IsHardware() const override;
+
   /// If \a auto_continue is \b true, set the breakpoint to cont

[Lldb-commits] [PATCH] D84255: [lldb] Make process plugins check whether a hardware breakpoint is required

2020-07-21 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha created this revision.
tatyana-krasnukha added a reviewer: clayborg.
tatyana-krasnukha added a project: LLDB.
Herald added subscribers: lldb-commits, emaste.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84255

Files:
  lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
  lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
  lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp


Index: lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
+++ lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
@@ -150,6 +150,9 @@
 uint32_t ProcessWindows::GetPluginVersion() { return 1; }
 
 Status ProcessWindows::EnableBreakpointSite(BreakpointSite *bp_site) {
+  if (bp_site->HardwareRequired())
+return Status("Hardware breakpoints are not supported.");
+
   Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_BREAKPOINTS);
   LLDB_LOG(log, "bp_site = {0:x}, id={1}, addr={2:x}", bp_site,
bp_site->GetID(), bp_site->GetLoadAddress());
Index: lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
===
--- lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
+++ lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
@@ -644,6 +644,9 @@
 }
 
 Status ProcessKDP::EnableBreakpointSite(BreakpointSite *bp_site) {
+  if (bp_site->HardwareRequired())
+return Status("Hardware breakpoints are not supported.");
+
   if (m_comm.LocalBreakpointsAreSupported()) {
 Status error;
 if (!bp_site->IsEnabled()) {
Index: lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
===
--- lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
+++ lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
@@ -683,6 +683,9 @@
 }
 
 Status ProcessFreeBSD::EnableBreakpointSite(BreakpointSite *bp_site) {
+  if (bp_site->HardwareRequired())
+return Status("Hardware breakpoints are not supported.");
+
   return EnableSoftwareBreakpoint(bp_site);
 }
 


Index: lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
+++ lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
@@ -150,6 +150,9 @@
 uint32_t ProcessWindows::GetPluginVersion() { return 1; }
 
 Status ProcessWindows::EnableBreakpointSite(BreakpointSite *bp_site) {
+  if (bp_site->HardwareRequired())
+return Status("Hardware breakpoints are not supported.");
+
   Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_BREAKPOINTS);
   LLDB_LOG(log, "bp_site = {0:x}, id={1}, addr={2:x}", bp_site,
bp_site->GetID(), bp_site->GetLoadAddress());
Index: lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
===
--- lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
+++ lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
@@ -644,6 +644,9 @@
 }
 
 Status ProcessKDP::EnableBreakpointSite(BreakpointSite *bp_site) {
+  if (bp_site->HardwareRequired())
+return Status("Hardware breakpoints are not supported.");
+
   if (m_comm.LocalBreakpointsAreSupported()) {
 Status error;
 if (!bp_site->IsEnabled()) {
Index: lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
===
--- lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
+++ lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
@@ -683,6 +683,9 @@
 }
 
 Status ProcessFreeBSD::EnableBreakpointSite(BreakpointSite *bp_site) {
+  if (bp_site->HardwareRequired())
+return Status("Hardware breakpoints are not supported.");
+
   return EnableSoftwareBreakpoint(bp_site);
 }
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D84254: [lldb] Skip overlapping hardware and external breakpoints when writing memory

2020-07-21 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha created this revision.
tatyana-krasnukha added a reviewer: clayborg.
tatyana-krasnukha added a project: LLDB.
Herald added a subscriber: lldb-commits.

This fixes the assertion `assert(intersects);` in the Process::WriteMemory 
function.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84254

Files:
  lldb/source/Breakpoint/BreakpointSite.cpp
  lldb/source/Target/Process.cpp


Index: lldb/source/Target/Process.cpp
===
--- lldb/source/Target/Process.cpp
+++ lldb/source/Target/Process.cpp
@@ -2291,6 +2291,9 @@
 if (error.Fail())
   return;
 
+if (bp->GetType() != BreakpointSite::eSoftware)
+  return;
+
 addr_t intersect_addr;
 size_t intersect_size;
 size_t opcode_offset;
Index: lldb/source/Breakpoint/BreakpointSite.cpp
===
--- lldb/source/Breakpoint/BreakpointSite.cpp
+++ lldb/source/Breakpoint/BreakpointSite.cpp
@@ -167,40 +167,39 @@
  lldb::addr_t *intersect_addr,
  size_t *intersect_size,
  size_t *opcode_offset) const {
-  // We only use software traps for software breakpoints
-  if (!IsHardware()) {
-if (m_byte_size > 0) {
-  const lldb::addr_t bp_end_addr = m_addr + m_byte_size;
-  const lldb::addr_t end_addr = addr + size;
-  // Is the breakpoint end address before the passed in start address?
-  if (bp_end_addr <= addr)
-return false;
-  // Is the breakpoint start address after passed in end address?
-  if (end_addr <= m_addr)
-return false;
-  if (intersect_addr || intersect_size || opcode_offset) {
-if (m_addr < addr) {
-  if (intersect_addr)
-*intersect_addr = addr;
-  if (intersect_size)
-*intersect_size =
-std::min(bp_end_addr, end_addr) - addr;
-  if (opcode_offset)
-*opcode_offset = addr - m_addr;
-} else {
-  if (intersect_addr)
-*intersect_addr = m_addr;
-  if (intersect_size)
-*intersect_size =
-std::min(bp_end_addr, end_addr) - m_addr;
-  if (opcode_offset)
-*opcode_offset = 0;
-}
+  // The function should be called only for software breakpoints.
+  lldbassert(GetType() == Type::eSoftware);
+
+  if (m_byte_size > 0) {
+const lldb::addr_t bp_end_addr = m_addr + m_byte_size;
+const lldb::addr_t end_addr = addr + size;
+// Is the breakpoint end address before the passed in start address?
+if (bp_end_addr <= addr)
+  return false;
+// Is the breakpoint start address after passed in end address?
+if (end_addr <= m_addr)
+  return false;
+if (intersect_addr || intersect_size || opcode_offset) {
+  if (m_addr < addr) {
+if (intersect_addr)
+  *intersect_addr = addr;
+if (intersect_size)
+  *intersect_size =
+  std::min(bp_end_addr, end_addr) - addr;
+if (opcode_offset)
+  *opcode_offset = addr - m_addr;
+  } else {
+if (intersect_addr)
+  *intersect_addr = m_addr;
+if (intersect_size)
+  *intersect_size =
+  std::min(bp_end_addr, end_addr) - m_addr;
+if (opcode_offset)
+  *opcode_offset = 0;
   }
-  return true;
 }
+return true;
   }
-  return false;
 }
 
 size_t


Index: lldb/source/Target/Process.cpp
===
--- lldb/source/Target/Process.cpp
+++ lldb/source/Target/Process.cpp
@@ -2291,6 +2291,9 @@
 if (error.Fail())
   return;
 
+if (bp->GetType() != BreakpointSite::eSoftware)
+  return;
+
 addr_t intersect_addr;
 size_t intersect_size;
 size_t opcode_offset;
Index: lldb/source/Breakpoint/BreakpointSite.cpp
===
--- lldb/source/Breakpoint/BreakpointSite.cpp
+++ lldb/source/Breakpoint/BreakpointSite.cpp
@@ -167,40 +167,39 @@
  lldb::addr_t *intersect_addr,
  size_t *intersect_size,
  size_t *opcode_offset) const {
-  // We only use software traps for software breakpoints
-  if (!IsHardware()) {
-if (m_byte_size > 0) {
-  const lldb::addr_t bp_end_addr = m_addr + m_byte_size;
-  const lldb::addr_t end_addr = addr + size;
-  // Is the breakpoint end address before the passed in start address?
-  if (bp_end_addr <= addr)
-return false;
-  // Is the breakpoint start address after passed in end address?
-  if (end_addr <= m_addr)
-return false;
-  if (intersect_addr || intersect_size || opcode_offset) {
-if (m_addr < addr) {
-  if (intersect_addr)
-*intersect_addr = addr;
-  

[Lldb-commits] [PATCH] D76593: [lldb-vscode] Convert launch_info and attach_info to local variables

2020-03-26 Thread Tatyana Krasnukha via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa92673fe9a08: [lldb-vscode] Convert launch_info and 
attach_info to local variables (authored by anton.kolesov, committed by 
tatyana-krasnukha).

Changed prior to commit:
  https://reviews.llvm.org/D76593?vs=252503&id=252873#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76593

Files:
  lldb/tools/lldb-vscode/VSCode.cpp
  lldb/tools/lldb-vscode/VSCode.h
  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
@@ -508,13 +508,14 @@
   llvm::json::Object response;
   lldb::SBError error;
   FillResponse(request, response);
+  lldb::SBAttachInfo attach_info;
   auto arguments = request.getObject("arguments");
   const lldb::pid_t pid =
   GetUnsigned(arguments, "pid", LLDB_INVALID_PROCESS_ID);
   if (pid != LLDB_INVALID_PROCESS_ID)
-g_vsc.attach_info.SetProcessID(pid);
+attach_info.SetProcessID(pid);
   const auto wait_for = GetBoolean(arguments, "waitFor", false);
-  g_vsc.attach_info.SetWaitForLaunch(wait_for, false /*async*/);
+  attach_info.SetWaitForLaunch(wait_for, false /*async*/);
   g_vsc.init_commands = GetStrings(arguments, "initCommands");
   g_vsc.pre_run_commands = GetStrings(arguments, "preRunCommands");
   g_vsc.stop_commands = GetStrings(arguments, "stopCommands");
@@ -547,20 +548,19 @@
   g_vsc.RunPreRunCommands();
 
   if (pid == LLDB_INVALID_PROCESS_ID && wait_for) {
-char attach_info[256];
-auto attach_info_len =
-snprintf(attach_info, sizeof(attach_info),
- "Waiting to attach to \"%s\"...",
- g_vsc.target.GetExecutable().GetFilename());
-g_vsc.SendOutput(OutputType::Console, llvm::StringRef(attach_info,
-  attach_info_len));
+char attach_msg[256];
+auto attach_msg_len = snprintf(attach_msg, sizeof(attach_msg),
+   "Waiting to attach to \"%s\"...",
+   g_vsc.target.GetExecutable().GetFilename());
+g_vsc.SendOutput(OutputType::Console,
+ llvm::StringRef(attach_msg, attach_msg_len));
   }
   if (attachCommands.empty()) {
 // No "attachCommands", just attach normally.
 // Disable async events so the attach will be successful when we return from
 // the launch call and the launch will happen synchronously
 g_vsc.debugger.SetAsync(false);
-g_vsc.target.Attach(g_vsc.attach_info, error);
+g_vsc.target.Attach(attach_info, error);
 // Reenable async events
 g_vsc.debugger.SetAsync(true);
   } else {
@@ -1381,26 +1381,26 @@
   }
 
   // Instantiate a launch info instance for the target.
-  g_vsc.launch_info = g_vsc.target.GetLaunchInfo();
+  auto launch_info = g_vsc.target.GetLaunchInfo();
 
   // Grab the current working directory if there is one and set it in the
   // launch info.
   const auto cwd = GetString(arguments, "cwd");
   if (!cwd.empty())
-g_vsc.launch_info.SetWorkingDirectory(cwd.data());
+launch_info.SetWorkingDirectory(cwd.data());
 
   // Extract any extra arguments and append them to our program arguments for
   // when we launch
   auto args = GetStrings(arguments, "args");
   if (!args.empty())
-g_vsc.launch_info.SetArguments(MakeArgv(args).data(), true);
+launch_info.SetArguments(MakeArgv(args).data(), true);
 
   // Pass any environment variables along that the user specified.
   auto envs = GetStrings(arguments, "env");
   if (!envs.empty())
-g_vsc.launch_info.SetEnvironmentEntries(MakeArgv(envs).data(), true);
+launch_info.SetEnvironmentEntries(MakeArgv(envs).data(), true);
 
-  auto flags = g_vsc.launch_info.GetLaunchFlags();
+  auto flags = launch_info.GetLaunchFlags();
 
   if (GetBoolean(arguments, "disableASLR", true))
 flags |= lldb::eLaunchFlagDisableASLR;
@@ -1409,9 +1409,9 @@
   if (GetBoolean(arguments, "shellExpandArguments", false))
 flags |= lldb::eLaunchFlagShellExpandArguments;
   const bool detatchOnError = GetBoolean(arguments, "detachOnError", false);
-  g_vsc.launch_info.SetDetachOnError(detatchOnError);
-  g_vsc.launch_info.SetLaunchFlags(flags | lldb::eLaunchFlagDebug |
-   lldb::eLaunchFlagStopAtEntry);
+  launch_info.SetDetachOnError(detatchOnError);
+  launch_info.SetLaunchFlags(flags | lldb::eLaunchFlagDebug |
+ lldb::eLaunchFlagStopAtEntry);
 
   // Run any pre run LLDB commands the user specified in the launch.json
   g_vsc.RunPreRunCommands();
@@ -1419,7 +1419,7 @@
 // Disable async events so the launch will be successful when we return from
 // the launch call and the launch will happen synchronously
 g_vsc.debugger.SetAsync(false);
-g

[Lldb-commits] [PATCH] D76351: [lldb-vscode] Don't use SBLaunchInfo in request_attach

2020-03-20 Thread Tatyana Krasnukha via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0b18b568e91a: [lldb-vscode] Don't use SBLaunchInfo in 
request_attach (authored by anton.kolesov, committed by tatyana-krasnukha).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76351

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
@@ -543,9 +543,6 @@
 return;
   }
 
-  const bool detatchOnError = GetBoolean(arguments, "detachOnError", false);
-  g_vsc.launch_info.SetDetachOnError(detatchOnError);
-
   // Run any pre run LLDB commands the user specified in the launch.json
   g_vsc.RunPreRunCommands();
 


Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -543,9 +543,6 @@
 return;
   }
 
-  const bool detatchOnError = GetBoolean(arguments, "detachOnError", false);
-  g_vsc.launch_info.SetDetachOnError(detatchOnError);
-
   // Run any pre run LLDB commands the user specified in the launch.json
   g_vsc.RunPreRunCommands();
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D75979: [lldb] Remove unimplemented StackFrame::BehavesLikeZerothFrame

2020-03-16 Thread Tatyana Krasnukha via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG332edcc6bd1d: [lldb] Remove unimplemented 
StackFrame::BehavesLikeZerothFrame (authored by tatyana-krasnukha).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75979

Files:
  lldb/include/lldb/Target/StackFrame.h


Index: lldb/include/lldb/Target/StackFrame.h
===
--- lldb/include/lldb/Target/StackFrame.h
+++ lldb/include/lldb/Target/StackFrame.h
@@ -367,12 +367,6 @@
   /// may have limited support for inspecting variables.
   bool IsArtificial() const;
 
-  /// Query whether this frame behaves like the zeroth frame, in the sense
-  /// that its pc value might not immediately follow a call (and thus might
-  /// be the first address of its function).  True for actual frame zero as
-  /// well as any other frame with the same trait.
-  bool BehavesLikeZerothFrame() const;
-
   /// Query this frame to find what frame it is in this Thread's
   /// StackFrameList.
   ///
@@ -517,6 +511,11 @@
   bool m_cfa_is_valid; // Does this frame have a CFA?  Different from CFA ==
// LLDB_INVALID_ADDRESS
   Kind m_stack_frame_kind;
+
+  // Whether this frame behaves like the zeroth frame, in the sense
+  // that its pc value might not immediately follow a call (and thus might
+  // be the first address of its function). True for actual frame zero as
+  // well as any other frame with the same trait.
   bool m_behaves_like_zeroth_frame;
   lldb::VariableListSP m_variable_list_sp;
   ValueObjectList m_variable_list_value_objects; // Value objects for each


Index: lldb/include/lldb/Target/StackFrame.h
===
--- lldb/include/lldb/Target/StackFrame.h
+++ lldb/include/lldb/Target/StackFrame.h
@@ -367,12 +367,6 @@
   /// may have limited support for inspecting variables.
   bool IsArtificial() const;
 
-  /// Query whether this frame behaves like the zeroth frame, in the sense
-  /// that its pc value might not immediately follow a call (and thus might
-  /// be the first address of its function).  True for actual frame zero as
-  /// well as any other frame with the same trait.
-  bool BehavesLikeZerothFrame() const;
-
   /// Query this frame to find what frame it is in this Thread's
   /// StackFrameList.
   ///
@@ -517,6 +511,11 @@
   bool m_cfa_is_valid; // Does this frame have a CFA?  Different from CFA ==
// LLDB_INVALID_ADDRESS
   Kind m_stack_frame_kind;
+
+  // Whether this frame behaves like the zeroth frame, in the sense
+  // that its pc value might not immediately follow a call (and thus might
+  // be the first address of its function). True for actual frame zero as
+  // well as any other frame with the same trait.
   bool m_behaves_like_zeroth_frame;
   lldb::VariableListSP m_variable_list_sp;
   ValueObjectList m_variable_list_value_objects; // Value objects for each
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D75975: [lldb] Copy m_behaves_like_zeroth_frame on stack frame update

2020-03-16 Thread Tatyana Krasnukha via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0a840ef80059: [lldb] Copy m_behaves_like_zeroth_frame on 
stack frame update (authored by tatyana-krasnukha).

Changed prior to commit:
  https://reviews.llvm.org/D75975?vs=249561&id=250549#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75975

Files:
  lldb/source/Target/StackFrame.cpp
  lldb/test/API/functionalities/unwind/zeroth_frame/Makefile
  lldb/test/API/functionalities/unwind/zeroth_frame/TestZerothFrame.py
  lldb/test/API/functionalities/unwind/zeroth_frame/main.c

Index: lldb/test/API/functionalities/unwind/zeroth_frame/main.c
===
--- /dev/null
+++ lldb/test/API/functionalities/unwind/zeroth_frame/main.c
@@ -0,0 +1,8 @@
+void func_inner() {
+int a = 1;  // Set breakpoint 1 here
+}
+
+int main() {
+func_inner();
+return 0; // Set breakpoint 2 here
+}
Index: lldb/test/API/functionalities/unwind/zeroth_frame/TestZerothFrame.py
===
--- /dev/null
+++ lldb/test/API/functionalities/unwind/zeroth_frame/TestZerothFrame.py
@@ -0,0 +1,96 @@
+"""
+Test that line information is recalculated properly for a frame when it moves
+from the middle of the backtrace to a zero index.
+
+This is a regression test for a StackFrame bug, where whether frame is zero or
+not depends on an internal field. When LLDB was updating its frame list value
+of the field wasn't copied into existing StackFrame instances, so those
+StackFrame instances, would use an incorrect line entry evaluation logic in
+situations if it was in the middle of the stack frame list (not zeroth), and
+then moved to the top position. The difference in logic is that for zeroth
+frames line entry is returned for program counter, while for other frame
+(except for those that "behave like zeroth") it is for the instruction
+preceding PC, as PC points to the next instruction after function call. When
+the bug is present, when execution stops at the second breakpoint
+SBFrame.GetLineEntry() returns line entry for the previous line, rather than
+the one with a breakpoint. Note that this is specific to
+SBFrame.GetLineEntry(), SBFrame.GetPCAddress().GetLineEntry() would return
+correct entry.
+
+This bug doesn't reproduce through an LLDB interpretator, however it happens
+when using API directly, for example in LLDB-MI.
+"""
+
+from __future__ import print_function
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class ZerothFrame(TestBase):
+mydir = TestBase.compute_mydir(__file__)
+
+def test(self):
+"""
+Test that line information is recalculated properly for a frame when it moves
+from the middle of the backtrace to a zero index.
+"""
+self.build()
+self.setTearDownCleanup()
+
+exe = self.getBuildArtifact("a.out")
+target = self.dbg.CreateTarget(exe)
+self.assertTrue(target, VALID_TARGET)
+
+bp1_line = line_number('main.c', '// Set breakpoint 1 here')
+bp2_line = line_number('main.c', '// Set breakpoint 2 here')
+
+lldbutil.run_break_set_by_file_and_line(
+self,
+'main.c',
+bp1_line,
+num_expected_locations=1)
+lldbutil.run_break_set_by_file_and_line(
+self,
+'main.c',
+bp2_line,
+num_expected_locations=1)
+
+process = target.LaunchSimple(
+None, None, self.get_process_working_directory())
+self.assertTrue(process, VALID_PROCESS)
+
+thread = process.GetThreadAtIndex(0)
+if self.TraceOn():
+print("Backtrace at the first breakpoint:")
+for f in thread.frames:
+print(f)
+# Check that we have stopped at correct breakpoint.
+self.assertEqual(
+process.GetThreadAtIndex(0).frame[0].GetLineEntry().GetLine(),
+bp1_line,
+"LLDB reported incorrect line number.")
+
+# Important to use SBProcess::Continue() instead of
+# self.runCmd('continue'), because the problem doesn't reproduce with
+# 'continue' command.
+process.Continue()
+
+thread = process.GetThreadAtIndex(0)
+if self.TraceOn():
+print("Backtrace at the second breakpoint:")
+for f in thread.frames:
+print(f)
+# Check that we have stopped at the breakpoint
+self.assertEqual(
+thread.frame[0].GetLineEntry().GetLine(),
+bp2_line,
+"LLDB reported incorrect line number.")
+# Double-check with GetPCAddress()
+self.assertEqual(
+thread.frame[0].GetLineEntry().GetLine(),
+thread.frame[0].GetPCAddress(

[Lldb-commits] [PATCH] D75537: Clear all settings during a test's setUp

2020-03-12 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha added a comment.

`platform.module-cache-directory` should be fixed by rGfe74df01a909 
.

Regarding `script-lang`, its default value is `eScriptLanguagePython` in 
CoreProperties.td and I'm not sure that I should change it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75537



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


[Lldb-commits] [PATCH] D75537: Clear all settings during a test's setUp

2020-03-12 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha added a comment.

Thank you for details, I'm looking at these failures, however, I'm not able to 
debug on the macOS.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75537



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


[Lldb-commits] [PATCH] D75537: Clear all settings during a test's setUp

2020-03-12 Thread Tatyana Krasnukha via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdf90a15b1ac9: [lldb] Clear all settings during a test's 
setUp (authored by tatyana-krasnukha).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75537

Files:
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/source/Commands/CommandObjectSettings.cpp
  lldb/source/Commands/Options.td
  lldb/test/API/commands/settings/TestSettings.py

Index: lldb/test/API/commands/settings/TestSettings.py
===
--- lldb/test/API/commands/settings/TestSettings.py
+++ lldb/test/API/commands/settings/TestSettings.py
@@ -520,6 +520,32 @@
 self.expect("settings remove ''", error=True,
 substrs=["'settings remove' command requires a valid variable name"])
 
+def test_settings_clear_all(self):
+# Change a dictionary.
+self.runCmd("settings set target.env-vars a=1 b=2 c=3")
+# Change an array.
+self.runCmd("settings set target.run-args a1 b2 c3")
+# Change a single boolean value.
+self.runCmd("settings set auto-confirm true")
+# Change a single integer value.
+self.runCmd("settings set tab-size 2")
+
+# Clear everything.
+self.runCmd("settings clear --all")
+
+# Check that settings have their default values after clearing.
+self.expect("settings show target.env-vars", patterns=['^target.env-vars \(dictionary of strings\) =\s*$'])
+self.expect("settings show target.run-args", patterns=['^target.run-args \(arguments\) =\s*$'])
+self.expect("settings show auto-confirm", substrs=["false"])
+self.expect("settings show tab-size", substrs=["4"])
+
+# Check that the command fails if we combine '--all' option with any arguments.
+self.expect(
+"settings clear --all auto-confirm",
+COMMAND_FAILED_AS_EXPECTED,
+error=True,
+substrs=["'settings clear --all' doesn't take any arguments"])
+
 def test_all_settings_exist(self):
 self.expect("settings show",
 substrs=["auto-confirm",
Index: lldb/source/Commands/Options.td
===
--- lldb/source/Commands/Options.td
+++ lldb/source/Commands/Options.td
@@ -39,6 +39,11 @@
 Desc<"The file from which to read the settings.">;
 }
 
+let Command = "settings clear" in {
+  def setclear_all : Option<"all", "a">,
+Desc<"Clear all settings.">;
+}
+
 let Command = "breakpoint list" in {
   // FIXME: We need to add an "internal" command, and then add this sort of
   // thing to it. But I need to see it for now, and don't want to wait.
Index: lldb/source/Commands/CommandObjectSettings.cpp
===
--- lldb/source/Commands/CommandObjectSettings.cpp
+++ lldb/source/Commands/CommandObjectSettings.cpp
@@ -1043,13 +1043,16 @@
 };
 
 // CommandObjectSettingsClear
+#define LLDB_OPTIONS_settings_clear
+#include "CommandOptions.inc"
 
 class CommandObjectSettingsClear : public CommandObjectParsed {
 public:
   CommandObjectSettingsClear(CommandInterpreter &interpreter)
   : CommandObjectParsed(
 interpreter, "settings clear",
-"Clear a debugger setting array, dictionary, or string.", nullptr) {
+"Clear a debugger setting array, dictionary, or string. "
+"If '-a' option is specified, it clears all settings.", nullptr) {
 CommandArgumentEntry arg;
 CommandArgumentData var_name_arg;
 
@@ -1077,11 +1080,53 @@
   request, nullptr);
   }
 
+   Options *GetOptions() override { return &m_options; }
+
+  class CommandOptions : public Options {
+  public:
+CommandOptions() = default;
+
+~CommandOptions() override = default;
+
+Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
+  ExecutionContext *execution_context) override {
+  const int short_option = m_getopt_table[option_idx].val;
+  switch (short_option) {
+  case 'a':
+m_clear_all = true;
+break;
+  default:
+llvm_unreachable("Unimplemented option");
+  }
+  return Status();
+}
+
+void OptionParsingStarting(ExecutionContext *execution_context) override {
+  m_clear_all = false;
+}
+
+llvm::ArrayRef GetDefinitions() override {
+  return llvm::makeArrayRef(g_settings_clear_options);
+}
+
+bool m_clear_all = false;
+  };
+
 protected:
   bool DoExecute(Args &command, CommandReturnObject &result) override {
 result.SetStatus(eReturnStatusSuccessFinishNoResult);
 const size_t argc = command.GetArgumentCount();
 
+if (m_options.m_clear_all) {
+  if (argc != 0) {
+result.AppendError("'settings clear --all' doesn't take any arguments");
+resul

[Lldb-commits] [PATCH] D75537: Clear all settings during a test's setUp

2020-03-12 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha updated this revision to Diff 249902.
tatyana-krasnukha added a comment.

Addressed comments


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D75537

Files:
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/source/Commands/CommandObjectSettings.cpp
  lldb/source/Commands/Options.td
  lldb/test/API/commands/settings/TestSettings.py

Index: lldb/test/API/commands/settings/TestSettings.py
===
--- lldb/test/API/commands/settings/TestSettings.py
+++ lldb/test/API/commands/settings/TestSettings.py
@@ -520,6 +520,32 @@
 self.expect("settings remove ''", error=True,
 substrs=["'settings remove' command requires a valid variable name"])
 
+def test_settings_clear_all(self):
+# Change a dictionary.
+self.runCmd("settings set target.env-vars a=1 b=2 c=3")
+# Change an array.
+self.runCmd("settings set target.run-args a1 b2 c3")
+# Change a single boolean value.
+self.runCmd("settings set auto-confirm true")
+# Change a single integer value.
+self.runCmd("settings set tab-size 2")
+
+# Clear everything.
+self.runCmd("settings clear --all")
+
+# Check that settings have their default values after clearing.
+self.expect("settings show target.env-vars", patterns=['^target.env-vars \(dictionary of strings\) =\s*$'])
+self.expect("settings show target.run-args", patterns=['^target.run-args \(arguments\) =\s*$'])
+self.expect("settings show auto-confirm", substrs=["false"])
+self.expect("settings show tab-size", substrs=["4"])
+
+# Check that the command fails if we combine '--all' option with any arguments.
+self.expect(
+"settings clear --all auto-confirm",
+COMMAND_FAILED_AS_EXPECTED,
+error=True,
+substrs=["'settings clear --all' doesn't take any arguments"])
+
 def test_all_settings_exist(self):
 self.expect("settings show",
 substrs=["auto-confirm",
Index: lldb/source/Commands/Options.td
===
--- lldb/source/Commands/Options.td
+++ lldb/source/Commands/Options.td
@@ -39,6 +39,11 @@
 Desc<"The file from which to read the settings.">;
 }
 
+let Command = "settings clear" in {
+  def setclear_all : Option<"all", "a">,
+Desc<"Clear all settings.">;
+}
+
 let Command = "breakpoint list" in {
   // FIXME: We need to add an "internal" command, and then add this sort of
   // thing to it. But I need to see it for now, and don't want to wait.
Index: lldb/source/Commands/CommandObjectSettings.cpp
===
--- lldb/source/Commands/CommandObjectSettings.cpp
+++ lldb/source/Commands/CommandObjectSettings.cpp
@@ -1043,13 +1043,16 @@
 };
 
 // CommandObjectSettingsClear
+#define LLDB_OPTIONS_settings_clear
+#include "CommandOptions.inc"
 
 class CommandObjectSettingsClear : public CommandObjectParsed {
 public:
   CommandObjectSettingsClear(CommandInterpreter &interpreter)
   : CommandObjectParsed(
 interpreter, "settings clear",
-"Clear a debugger setting array, dictionary, or string.", nullptr) {
+"Clear a debugger setting array, dictionary, or string. "
+"If '-a' option is specified, it clears all settings.", nullptr) {
 CommandArgumentEntry arg;
 CommandArgumentData var_name_arg;
 
@@ -1077,11 +1080,53 @@
   request, nullptr);
   }
 
+   Options *GetOptions() override { return &m_options; }
+
+  class CommandOptions : public Options {
+  public:
+CommandOptions() = default;
+
+~CommandOptions() override = default;
+
+Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
+  ExecutionContext *execution_context) override {
+  const int short_option = m_getopt_table[option_idx].val;
+  switch (short_option) {
+  case 'a':
+m_clear_all = true;
+break;
+  default:
+llvm_unreachable("Unimplemented option");
+  }
+  return Status();
+}
+
+void OptionParsingStarting(ExecutionContext *execution_context) override {
+  m_clear_all = false;
+}
+
+llvm::ArrayRef GetDefinitions() override {
+  return llvm::makeArrayRef(g_settings_clear_options);
+}
+
+bool m_clear_all = false;
+  };
+
 protected:
   bool DoExecute(Args &command, CommandReturnObject &result) override {
 result.SetStatus(eReturnStatusSuccessFinishNoResult);
 const size_t argc = command.GetArgumentCount();
 
+if (m_options.m_clear_all) {
+  if (argc != 0) {
+result.AppendError("'settings clear --all' doesn't take any arguments");
+result.SetStatus(eReturnStatusFailed);
+return false;
+  }
+  GetDebugger().Get

[Lldb-commits] [PATCH] D75537: Clear all settings during a test's setUp

2020-03-05 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha updated this revision to Diff 248404.
tatyana-krasnukha added a comment.

Removed TestFixIts.py as those changes relate to the parent revision.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D75537

Files:
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/source/Commands/CommandObjectSettings.cpp
  lldb/source/Commands/Options.td
  lldb/test/API/commands/settings/TestSettings.py

Index: lldb/test/API/commands/settings/TestSettings.py
===
--- lldb/test/API/commands/settings/TestSettings.py
+++ lldb/test/API/commands/settings/TestSettings.py
@@ -522,6 +522,36 @@
 self.expect("settings remove ''", error=True,
 substrs=["'settings remove' command requires a valid variable name"])
 
+def test_settings_clear_all(self):
+# Save the initial state of settings.
+command_interpreter = self.dbg.GetCommandInterpreter()
+self.assertTrue(command_interpreter, VALID_COMMAND_INTERPRETER)
+result = lldb.SBCommandReturnObject()
+command_interpreter.HandleCommand("settings show", result)
+default_values = result.GetOutput()
+
+# Change a dictionary.
+self.runCmd("settings set target.env-vars a=1 b=2 c=3")
+# Change an array.
+self.runCmd("settings set target.run-args a b c")
+# Change a single boolean value.
+self.runCmd("settings set auto-confirm true")
+# Change a single integer value.
+self.runCmd("settings set term-width 120")
+
+# Clear everything.
+self.runCmd("settings clear --all")
+
+# Apply Setup commands again.
+for s in self.setUpCommands():
+self.runCmd(s)
+
+# Check that settings have their default values after clearing.
+command_interpreter.HandleCommand("settings show", result)
+after_clear = result.GetOutput()
+self.maxDiff = None # Disable diff limit to compare setting dumps.
+self.assertEqual(default_values, after_clear)
+
 def test_all_settings_exist(self):
 self.expect("settings show",
 substrs=["auto-confirm",
Index: lldb/source/Commands/Options.td
===
--- lldb/source/Commands/Options.td
+++ lldb/source/Commands/Options.td
@@ -39,6 +39,11 @@
 Desc<"The file from which to read the settings.">;
 }
 
+let Command = "settings clear" in {
+  def setclear_all : Option<"all", "a">,
+Desc<"Clear all settings.">;
+}
+
 let Command = "breakpoint list" in {
   // FIXME: We need to add an "internal" command, and then add this sort of
   // thing to it. But I need to see it for now, and don't want to wait.
Index: lldb/source/Commands/CommandObjectSettings.cpp
===
--- lldb/source/Commands/CommandObjectSettings.cpp
+++ lldb/source/Commands/CommandObjectSettings.cpp
@@ -1043,13 +1043,16 @@
 };
 
 // CommandObjectSettingsClear
+#define LLDB_OPTIONS_settings_clear
+#include "CommandOptions.inc"
 
 class CommandObjectSettingsClear : public CommandObjectParsed {
 public:
   CommandObjectSettingsClear(CommandInterpreter &interpreter)
   : CommandObjectParsed(
 interpreter, "settings clear",
-"Clear a debugger setting array, dictionary, or string.", nullptr) {
+"Clear a debugger setting array, dictionary, or string. "
+"If '-a' option is specified, it clears all settings.", nullptr) {
 CommandArgumentEntry arg;
 CommandArgumentData var_name_arg;
 
@@ -1077,9 +1080,47 @@
   request, nullptr);
   }
 
+   Options *GetOptions() override { return &m_options; }
+
+  class CommandOptions : public Options {
+  public:
+CommandOptions() = default;
+
+~CommandOptions() override = default;
+
+Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
+  ExecutionContext *execution_context) override {
+  const int short_option = m_getopt_table[option_idx].val;
+  switch (short_option) {
+  case 'a':
+m_clear_all = true;
+break;
+  default:
+llvm_unreachable("Unimplemented option");
+  }
+  return Status();
+}
+
+void OptionParsingStarting(ExecutionContext *execution_context) override {
+  m_clear_all = false;
+}
+
+llvm::ArrayRef GetDefinitions() override {
+  return llvm::makeArrayRef(g_settings_clear_options);
+}
+
+bool m_clear_all = false;
+  };
+
 protected:
   bool DoExecute(Args &command, CommandReturnObject &result) override {
 result.SetStatus(eReturnStatusSuccessFinishNoResult);
+
+if (m_options.m_clear_all) {
+  GetDebugger().GetValueProperties()->Clear();
+  return result.Succeeded();
+}
+
 const size_t argc = command.GetArgumentCount();
 
 if (argc != 1) {
@@ 

[Lldb-commits] [PATCH] D74903: [lldb][testsuite] Create a SBDebugger instance for each test

2020-03-04 Thread Tatyana Krasnukha via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa31130f6fcf2: [lldb][testsuite] Create a SBDebugger instance 
for each test (authored by tatyana-krasnukha).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74903

Files:
  lldb/bindings/interface/SBPlatform.i
  lldb/include/lldb/API/SBPlatform.h
  lldb/packages/Python/lldbsuite/test/decorators.py
  lldb/packages/Python/lldbsuite/test/dotest.py
  lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/source/API/SBPlatform.cpp
  
lldb/test/API/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py
  
lldb/test/API/functionalities/breakpoint/breakpoint_in_delayslot/TestAvoidBreakpointInDelaySlot.py
  
lldb/test/API/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
  lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
  lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteLoad.py
  lldb/test/API/functionalities/gdb_remote_client/TestWasm.py
  lldb/test/API/functionalities/gdb_remote_client/TestWriteMemory.py
  lldb/test/API/functionalities/gdb_remote_client/TestqOffsets.py
  lldb/test/API/functionalities/plugins/command_plugin/TestPluginCommands.py
  lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
  lldb/test/API/functionalities/postmortem/elf-core/gcore/TestGCore.py
  
lldb/test/API/functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py
  lldb/test/API/functionalities/postmortem/mach-core/TestMachCore.py
  lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
  lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py
  lldb/test/API/functionalities/postmortem/netbsd-core/TestNetBSDCore.py
  lldb/test/API/functionalities/thread/backtrace_all/TestBacktraceAll.py
  
lldb/test/API/functionalities/unwind/noreturn/module-end/TestNoReturnModuleEnd.py
  lldb/test/API/macosx/load-kext/TestLoadKext.py
  lldb/test/API/python_api/file_handle/TestFileHandle.py
  
lldb/test/API/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py

Index: lldb/test/API/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py
===
--- lldb/test/API/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py
+++ lldb/test/API/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py
@@ -10,14 +10,6 @@
 class TestPlatformProcessConnect(gdbremote_testcase.GdbRemoteTestCaseBase):
 mydir = TestBase.compute_mydir(__file__)
 
-def setUp(self):
-super(TestPlatformProcessConnect, self).setUp()
-self._initial_platform = lldb.DBG.GetSelectedPlatform()
-
-def tearDown(self):
-lldb.DBG.SetSelectedPlatform(self._initial_platform)
-super(TestPlatformProcessConnect, self).tearDown()
-
 @llgs_test
 @no_debug_info_test
 @skipIf(remote=False)
@@ -66,16 +58,10 @@
 
 socket_id = lldbutil.wait_for_file_on_target(self, port_file)
 
-new_debugger = lldb.SBDebugger.Create()
-new_debugger.SetAsync(False)
-
-def del_debugger(new_debugger=new_debugger):
-del new_debugger
-self.addTearDownHook(del_debugger)
+self.dbg.SetAsync(False)
 
 new_platform = lldb.SBPlatform(lldb.remote_platform.GetName())
-new_debugger.SetSelectedPlatform(new_platform)
-new_interpreter = new_debugger.GetCommandInterpreter()
+self.dbg.SetSelectedPlatform(new_platform)
 
 if unix_protocol:
 connect_url = "%s://%s%s" % (protocol, hostname, socket_id)
@@ -84,13 +70,13 @@
 
 command = "platform connect %s" % (connect_url)
 result = lldb.SBCommandReturnObject()
-new_interpreter.HandleCommand(command, result)
+self.dbg.GetCommandInterpreter().HandleCommand(command, result)
 self.assertTrue(
 result.Succeeded(),
 "platform process connect failed: %s" %
 result.GetOutput())
 
-target = new_debugger.GetSelectedTarget()
+target = self.dbg.GetSelectedTarget()
 process = target.GetProcess()
 thread = process.GetThreadAtIndex(0)
 
Index: lldb/test/API/python_api/file_handle/TestFileHandle.py
===
--- lldb/test/API/python_api/file_handle/TestFileHandle.py
+++ lldb/test/API/python_api/file_handle/TestFileHandle.py
@@ -82,12 +82,7 @@
 NO_DEBUG_INFO_TESTCASE = True
 mydir = lldbtest.Base.compute_mydir(__file__)
 
-# The way this class interacts with the debugger is different
-# than normal.   Most of these test cases will mess with the
-# debugger I/O streams, so we want a fresh debugger for each
-# test so those mutations don't interfere with each other.

[Lldb-commits] [PATCH] D75537: Clear all settings during a test's setUp

2020-03-04 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha updated this revision to Diff 248213.
tatyana-krasnukha added a comment.

Added `--all` property to `settings clear` + added a test


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D75537

Files:
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/source/Commands/CommandObjectSettings.cpp
  lldb/source/Commands/Options.td
  lldb/test/API/commands/expression/fixits/TestFixIts.py
  lldb/test/API/commands/settings/TestSettings.py

Index: lldb/test/API/commands/settings/TestSettings.py
===
--- lldb/test/API/commands/settings/TestSettings.py
+++ lldb/test/API/commands/settings/TestSettings.py
@@ -522,6 +522,36 @@
 self.expect("settings remove ''", error=True,
 substrs=["'settings remove' command requires a valid variable name"])
 
+def test_settings_clear_all(self):
+# Save the initial state of settings.
+command_interpreter = self.dbg.GetCommandInterpreter()
+self.assertTrue(command_interpreter, VALID_COMMAND_INTERPRETER)
+result = lldb.SBCommandReturnObject()
+command_interpreter.HandleCommand("settings show", result)
+default_values = result.GetOutput()
+
+# Change a dictionary.
+self.runCmd("settings set target.env-vars a=1 b=2 c=3")
+# Change an array.
+self.runCmd("settings set target.run-args a b c")
+# Change a single boolean value.
+self.runCmd("settings set auto-confirm true")
+# Change a single integer value.
+self.runCmd("settings set term-width 120")
+
+# Clear everything.
+self.runCmd("settings clear --all")
+
+# Apply Setup commands again.
+for s in self.setUpCommands():
+self.runCmd(s)
+
+# Check that settings have their default values after clearing.
+command_interpreter.HandleCommand("settings show", result)
+after_clear = result.GetOutput()
+self.maxDiff = None # Disable diff limit to compare setting dumps.
+self.assertEqual(default_values, after_clear)
+
 def test_all_settings_exist(self):
 self.expect("settings show",
 substrs=["auto-confirm",
Index: lldb/test/API/commands/expression/fixits/TestFixIts.py
===
--- lldb/test/API/commands/expression/fixits/TestFixIts.py
+++ lldb/test/API/commands/expression/fixits/TestFixIts.py
@@ -29,6 +29,10 @@
 
 def test_with_dummy_target(self):
 """Test calling expressions in the dummy target with errors that can be fixed by the FixIts."""
+
+# Enable fix-its as they were intentionally disabled by TestBase.setUp.
+self.runCmd("settings set target.auto-apply-fixits true")
+
 ret_val = lldb.SBCommandReturnObject()
 result = self.dbg.GetCommandInterpreter().HandleCommand("expression ((1 << 16) - 1))", ret_val)
 self.assertEqual(result, lldb.eReturnStatusSuccessFinishResult, "The expression was successful.")
Index: lldb/source/Commands/Options.td
===
--- lldb/source/Commands/Options.td
+++ lldb/source/Commands/Options.td
@@ -39,6 +39,11 @@
 Desc<"The file from which to read the settings.">;
 }
 
+let Command = "settings clear" in {
+  def setclear_all : Option<"all", "a">,
+Desc<"Clear all settings.">;
+}
+
 let Command = "breakpoint list" in {
   // FIXME: We need to add an "internal" command, and then add this sort of
   // thing to it. But I need to see it for now, and don't want to wait.
Index: lldb/source/Commands/CommandObjectSettings.cpp
===
--- lldb/source/Commands/CommandObjectSettings.cpp
+++ lldb/source/Commands/CommandObjectSettings.cpp
@@ -1043,13 +1043,16 @@
 };
 
 // CommandObjectSettingsClear
+#define LLDB_OPTIONS_settings_clear
+#include "CommandOptions.inc"
 
 class CommandObjectSettingsClear : public CommandObjectParsed {
 public:
   CommandObjectSettingsClear(CommandInterpreter &interpreter)
   : CommandObjectParsed(
 interpreter, "settings clear",
-"Clear a debugger setting array, dictionary, or string.", nullptr) {
+"Clear a debugger setting array, dictionary, or string. "
+"If '-a' option is specified, it clears all settings.", nullptr) {
 CommandArgumentEntry arg;
 CommandArgumentData var_name_arg;
 
@@ -1077,9 +1080,47 @@
   request, nullptr);
   }
 
+   Options *GetOptions() override { return &m_options; }
+
+  class CommandOptions : public Options {
+  public:
+CommandOptions() = default;
+
+~CommandOptions() override = default;
+
+Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
+  ExecutionContext *execution_context) override {
+  const int short_o

[Lldb-commits] [PATCH] D74557: [lldb] Make BreakpointResolver hold weak_ptr instead of raw pointer to breakpoint

2020-03-04 Thread Tatyana Krasnukha via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6c17cc531f9f: [lldb] Make BreakpointResolver hold weak_ptr 
instead of raw pointer to… (authored by tatyana-krasnukha).

Changed prior to commit:
  https://reviews.llvm.org/D74557?vs=244727&id=248166#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74557

Files:
  lldb/include/lldb/Breakpoint/BreakpointResolver.h
  lldb/include/lldb/Breakpoint/BreakpointResolverAddress.h
  lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h
  lldb/include/lldb/Breakpoint/BreakpointResolverFileRegex.h
  lldb/include/lldb/Breakpoint/BreakpointResolverName.h
  lldb/include/lldb/Breakpoint/BreakpointResolverScripted.h
  lldb/include/lldb/Target/LanguageRuntime.h
  lldb/source/Breakpoint/Breakpoint.cpp
  lldb/source/Breakpoint/BreakpointResolver.cpp
  lldb/source/Breakpoint/BreakpointResolverAddress.cpp
  lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
  lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
  lldb/source/Breakpoint/BreakpointResolverName.cpp
  lldb/source/Breakpoint/BreakpointResolverScripted.cpp
  
lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
  
lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
  lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
  lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
  
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
  
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
  lldb/source/Target/LanguageRuntime.cpp
  lldb/source/Target/Target.cpp

Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -622,7 +622,7 @@
 const bool hardware = request_hardware || GetRequireHardwareBreakpoints();
 bp_sp.reset(new Breakpoint(*this, filter_sp, resolver_sp, hardware,
resolve_indirect_symbols));
-resolver_sp->SetBreakpoint(bp_sp.get());
+resolver_sp->SetBreakpoint(bp_sp);
 AddBreakpoint(bp_sp, internal);
   }
   return bp_sp;
Index: lldb/source/Target/LanguageRuntime.cpp
===
--- lldb/source/Target/LanguageRuntime.cpp
+++ lldb/source/Target/LanguageRuntime.cpp
@@ -153,17 +153,17 @@
   }
 
 protected:
-  BreakpointResolverSP CopyForBreakpoint(Breakpoint &breakpoint) override {
+  BreakpointResolverSP CopyForBreakpoint(BreakpointSP &breakpoint) override {
 BreakpointResolverSP ret_sp(
 new ExceptionBreakpointResolver(m_language, m_catch_bp, m_throw_bp));
-ret_sp->SetBreakpoint(&breakpoint);
+ret_sp->SetBreakpoint(breakpoint);
 return ret_sp;
   }
 
   bool SetActualResolver() {
-ProcessSP process_sp;
-if (m_breakpoint) {
-  process_sp = m_breakpoint->GetTarget().GetProcessSP();
+BreakpointSP breakpoint_sp = GetBreakpoint();
+if (breakpoint_sp) {
+  ProcessSP process_sp = breakpoint_sp->GetTarget().GetProcessSP();
   if (process_sp) {
 bool refreash_resolver = !m_actual_resolver_sp;
 if (m_language_runtime == nullptr) {
@@ -180,7 +180,7 @@
 
 if (refreash_resolver && m_language_runtime) {
   m_actual_resolver_sp = m_language_runtime->CreateExceptionResolver(
-  m_breakpoint, m_catch_bp, m_throw_bp);
+  breakpoint_sp, m_catch_bp, m_throw_bp);
 }
   } else {
 m_actual_resolver_sp.reset();
Index: lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
===
--- lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
+++ lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
@@ -58,7 +58,7 @@
 // for .expand kernels as a fallback.
 class RSBreakpointResolver : public BreakpointResolver {
 public:
-  RSBreakpointResolver(Breakpoint *bp, ConstString name)
+  RSBreakpointResolver(const lldb::BreakpointSP &bp, ConstString name)
   : BreakpointResolver(bp, BreakpointResolver::NameResolver),
 m_kernel_name(name) {}
 
@@ -77,9 +77,9 @@
   lldb::SearchDepth GetDepth() override { return lldb::eSearchDepthModule; }
 
   lldb::BreakpointResolverSP
-  CopyForBreakpoint(Breakpoint &breakpoint) override {
+  CopyForBreakpoint(lldb::BreakpointSP &breakpoint) override {
 lldb::BreakpointResolverSP ret_sp(
-new RSBreakpointResolver(&breakpoint, m_kernel_name));
+new RSBreakpointResolver(breakpo

[Lldb-commits] [PATCH] D74903: [lldb][testsuite] Create a SBDebugger instance for each test

2020-03-03 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha updated this revision to Diff 247928.
tatyana-krasnukha added a comment.

Moved settings clearing to the separate patch D75537 



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

https://reviews.llvm.org/D74903

Files:
  lldb/bindings/interface/SBPlatform.i
  lldb/include/lldb/API/SBPlatform.h
  lldb/packages/Python/lldbsuite/test/decorators.py
  lldb/packages/Python/lldbsuite/test/dotest.py
  lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/source/API/SBPlatform.cpp
  
lldb/test/API/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py
  
lldb/test/API/functionalities/breakpoint/breakpoint_in_delayslot/TestAvoidBreakpointInDelaySlot.py
  
lldb/test/API/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
  lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
  lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteLoad.py
  lldb/test/API/functionalities/gdb_remote_client/TestWasm.py
  lldb/test/API/functionalities/gdb_remote_client/TestWriteMemory.py
  lldb/test/API/functionalities/gdb_remote_client/TestqOffsets.py
  lldb/test/API/functionalities/plugins/command_plugin/TestPluginCommands.py
  lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
  lldb/test/API/functionalities/postmortem/elf-core/gcore/TestGCore.py
  
lldb/test/API/functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py
  lldb/test/API/functionalities/postmortem/mach-core/TestMachCore.py
  lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
  lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py
  lldb/test/API/functionalities/postmortem/netbsd-core/TestNetBSDCore.py
  lldb/test/API/functionalities/thread/backtrace_all/TestBacktraceAll.py
  
lldb/test/API/functionalities/unwind/noreturn/module-end/TestNoReturnModuleEnd.py
  lldb/test/API/macosx/load-kext/TestLoadKext.py
  lldb/test/API/python_api/file_handle/TestFileHandle.py
  
lldb/test/API/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py

Index: lldb/test/API/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py
===
--- lldb/test/API/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py
+++ lldb/test/API/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py
@@ -10,14 +10,6 @@
 class TestPlatformProcessConnect(gdbremote_testcase.GdbRemoteTestCaseBase):
 mydir = TestBase.compute_mydir(__file__)
 
-def setUp(self):
-super(TestPlatformProcessConnect, self).setUp()
-self._initial_platform = lldb.DBG.GetSelectedPlatform()
-
-def tearDown(self):
-lldb.DBG.SetSelectedPlatform(self._initial_platform)
-super(TestPlatformProcessConnect, self).tearDown()
-
 @llgs_test
 @no_debug_info_test
 @skipIf(remote=False)
@@ -66,16 +58,10 @@
 
 socket_id = lldbutil.wait_for_file_on_target(self, port_file)
 
-new_debugger = lldb.SBDebugger.Create()
-new_debugger.SetAsync(False)
-
-def del_debugger(new_debugger=new_debugger):
-del new_debugger
-self.addTearDownHook(del_debugger)
+self.dbg.SetAsync(False)
 
 new_platform = lldb.SBPlatform(lldb.remote_platform.GetName())
-new_debugger.SetSelectedPlatform(new_platform)
-new_interpreter = new_debugger.GetCommandInterpreter()
+self.dbg.SetSelectedPlatform(new_platform)
 
 if unix_protocol:
 connect_url = "%s://%s%s" % (protocol, hostname, socket_id)
@@ -84,13 +70,13 @@
 
 command = "platform connect %s" % (connect_url)
 result = lldb.SBCommandReturnObject()
-new_interpreter.HandleCommand(command, result)
+self.dbg.GetCommandInterpreter().HandleCommand(command, result)
 self.assertTrue(
 result.Succeeded(),
 "platform process connect failed: %s" %
 result.GetOutput())
 
-target = new_debugger.GetSelectedTarget()
+target = self.dbg.GetSelectedTarget()
 process = target.GetProcess()
 thread = process.GetThreadAtIndex(0)
 
Index: lldb/test/API/python_api/file_handle/TestFileHandle.py
===
--- lldb/test/API/python_api/file_handle/TestFileHandle.py
+++ lldb/test/API/python_api/file_handle/TestFileHandle.py
@@ -82,12 +82,7 @@
 NO_DEBUG_INFO_TESTCASE = True
 mydir = lldbtest.Base.compute_mydir(__file__)
 
-# The way this class interacts with the debugger is different
-# than normal.   Most of these test cases will mess with the
-# debugger I/O streams, so we want a fresh debugger for each
-# test so those mutations don't interfere with each other.
-#
-# Also, the way normal tests evaluate debugger c

[Lldb-commits] [PATCH] D75537: Clear all settings during a test's setUp

2020-03-03 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha created this revision.
tatyana-krasnukha added a reviewer: labath.
tatyana-krasnukha added a project: LLDB.
Herald added subscribers: lldb-commits, JDevlieghere.
tatyana-krasnukha added a parent revision: D74903: [lldb][testsuite] Create a 
SBDebugger instance for each test.

Moved from D74903 


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D75537

Files:
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/source/Commands/CommandObjectSettings.cpp


Index: lldb/source/Commands/CommandObjectSettings.cpp
===
--- lldb/source/Commands/CommandObjectSettings.cpp
+++ lldb/source/Commands/CommandObjectSettings.cpp
@@ -1049,7 +1049,8 @@
   CommandObjectSettingsClear(CommandInterpreter &interpreter)
   : CommandObjectParsed(
 interpreter, "settings clear",
-"Clear a debugger setting array, dictionary, or string.", nullptr) 
{
+"Clear a debugger setting array, dictionary, or string. "
+"Clear all settings if no arguments were specified.", nullptr) {
 CommandArgumentEntry arg;
 CommandArgumentData var_name_arg;
 
@@ -1082,8 +1083,13 @@
 result.SetStatus(eReturnStatusSuccessFinishNoResult);
 const size_t argc = command.GetArgumentCount();
 
+if (argc == 0)  {
+  GetDebugger().GetValueProperties()->Clear();
+  return result.Succeeded();
+}
+
 if (argc != 1) {
-  result.AppendError("'settings clear' takes exactly one argument");
+  result.AppendError("'settings clear' takes at most one argument");
   result.SetStatus(eReturnStatusFailed);
   return false;
 }
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -687,6 +687,9 @@
 @classmethod
 def setUpCommands(cls):
 commands = [
+# First of all, clear all settings to have clean state of global 
properties.
+"settings clear",
+
 # Disable Spotlight lookup. The testsuite creates
 # different binaries with the same UUID, because they only
 # differ in the debug info, which is not being hashed.


Index: lldb/source/Commands/CommandObjectSettings.cpp
===
--- lldb/source/Commands/CommandObjectSettings.cpp
+++ lldb/source/Commands/CommandObjectSettings.cpp
@@ -1049,7 +1049,8 @@
   CommandObjectSettingsClear(CommandInterpreter &interpreter)
   : CommandObjectParsed(
 interpreter, "settings clear",
-"Clear a debugger setting array, dictionary, or string.", nullptr) {
+"Clear a debugger setting array, dictionary, or string. "
+"Clear all settings if no arguments were specified.", nullptr) {
 CommandArgumentEntry arg;
 CommandArgumentData var_name_arg;
 
@@ -1082,8 +1083,13 @@
 result.SetStatus(eReturnStatusSuccessFinishNoResult);
 const size_t argc = command.GetArgumentCount();
 
+if (argc == 0)  {
+  GetDebugger().GetValueProperties()->Clear();
+  return result.Succeeded();
+}
+
 if (argc != 1) {
-  result.AppendError("'settings clear' takes exactly one argument");
+  result.AppendError("'settings clear' takes at most one argument");
   result.SetStatus(eReturnStatusFailed);
   return false;
 }
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -687,6 +687,9 @@
 @classmethod
 def setUpCommands(cls):
 commands = [
+# First of all, clear all settings to have clean state of global properties.
+"settings clear",
+
 # Disable Spotlight lookup. The testsuite creates
 # different binaries with the same UUID, because they only
 # differ in the debug info, which is not being hashed.
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D74903: [lldb][testsuite] Create a SBDebugger instance for each test

2020-03-03 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha updated this revision to Diff 247908.
tatyana-krasnukha added a comment.

Clear all settings during a test's setUp


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D74903

Files:
  lldb/bindings/interface/SBPlatform.i
  lldb/include/lldb/API/SBPlatform.h
  lldb/packages/Python/lldbsuite/test/decorators.py
  lldb/packages/Python/lldbsuite/test/dotest.py
  lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/source/API/SBPlatform.cpp
  lldb/source/Commands/CommandObjectSettings.cpp
  
lldb/test/API/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py
  
lldb/test/API/functionalities/breakpoint/breakpoint_in_delayslot/TestAvoidBreakpointInDelaySlot.py
  
lldb/test/API/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
  lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
  lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteLoad.py
  lldb/test/API/functionalities/gdb_remote_client/TestWasm.py
  lldb/test/API/functionalities/gdb_remote_client/TestWriteMemory.py
  lldb/test/API/functionalities/gdb_remote_client/TestqOffsets.py
  lldb/test/API/functionalities/plugins/command_plugin/TestPluginCommands.py
  lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
  lldb/test/API/functionalities/postmortem/elf-core/gcore/TestGCore.py
  
lldb/test/API/functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py
  lldb/test/API/functionalities/postmortem/mach-core/TestMachCore.py
  lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
  lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py
  lldb/test/API/functionalities/postmortem/netbsd-core/TestNetBSDCore.py
  lldb/test/API/functionalities/thread/backtrace_all/TestBacktraceAll.py
  
lldb/test/API/functionalities/unwind/noreturn/module-end/TestNoReturnModuleEnd.py
  lldb/test/API/macosx/load-kext/TestLoadKext.py
  lldb/test/API/python_api/file_handle/TestFileHandle.py
  
lldb/test/API/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py

Index: lldb/test/API/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py
===
--- lldb/test/API/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py
+++ lldb/test/API/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py
@@ -10,14 +10,6 @@
 class TestPlatformProcessConnect(gdbremote_testcase.GdbRemoteTestCaseBase):
 mydir = TestBase.compute_mydir(__file__)
 
-def setUp(self):
-super(TestPlatformProcessConnect, self).setUp()
-self._initial_platform = lldb.DBG.GetSelectedPlatform()
-
-def tearDown(self):
-lldb.DBG.SetSelectedPlatform(self._initial_platform)
-super(TestPlatformProcessConnect, self).tearDown()
-
 @llgs_test
 @no_debug_info_test
 @skipIf(remote=False)
@@ -66,16 +58,10 @@
 
 socket_id = lldbutil.wait_for_file_on_target(self, port_file)
 
-new_debugger = lldb.SBDebugger.Create()
-new_debugger.SetAsync(False)
-
-def del_debugger(new_debugger=new_debugger):
-del new_debugger
-self.addTearDownHook(del_debugger)
+self.dbg.SetAsync(False)
 
 new_platform = lldb.SBPlatform(lldb.remote_platform.GetName())
-new_debugger.SetSelectedPlatform(new_platform)
-new_interpreter = new_debugger.GetCommandInterpreter()
+self.dbg.SetSelectedPlatform(new_platform)
 
 if unix_protocol:
 connect_url = "%s://%s%s" % (protocol, hostname, socket_id)
@@ -84,13 +70,13 @@
 
 command = "platform connect %s" % (connect_url)
 result = lldb.SBCommandReturnObject()
-new_interpreter.HandleCommand(command, result)
+self.dbg.GetCommandInterpreter().HandleCommand(command, result)
 self.assertTrue(
 result.Succeeded(),
 "platform process connect failed: %s" %
 result.GetOutput())
 
-target = new_debugger.GetSelectedTarget()
+target = self.dbg.GetSelectedTarget()
 process = target.GetProcess()
 thread = process.GetThreadAtIndex(0)
 
Index: lldb/test/API/python_api/file_handle/TestFileHandle.py
===
--- lldb/test/API/python_api/file_handle/TestFileHandle.py
+++ lldb/test/API/python_api/file_handle/TestFileHandle.py
@@ -82,12 +82,7 @@
 NO_DEBUG_INFO_TESTCASE = True
 mydir = lldbtest.Base.compute_mydir(__file__)
 
-# The way this class interacts with the debugger is different
-# than normal.   Most of these test cases will mess with the
-# debugger I/O streams, so we want a fresh debugger for each
-# test so those mutations don't interfere with each other.
-#
-# Also, the way norm

[Lldb-commits] [PATCH] D74903: [lldb][testsuite] Create a SBDebugger instance for each test

2020-03-03 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha planned changes to this revision.
tatyana-krasnukha added a comment.

As Pavel wrote, there are global properties that all debuggers share. That's 
why this approach doesn't work for me.
I'm going to add `settings clear` mode without arguments that will revert all 
the settings to their default values.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D74903



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


[Lldb-commits] [PATCH] D74903: [lldb][testsuite] Create a SBDebugger instance for each test

2020-03-03 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha updated this revision to Diff 247842.
tatyana-krasnukha retitled this revision from "[lldb][test] Add two wrapper 
functions to manage settings in test-suite" to "[lldb][testsuite] Create a 
SBDebugger instance for each test".
tatyana-krasnukha edited the summary of this revision.
Herald added subscribers: abidh, aheejin, sbc100.

Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D74903

Files:
  lldb/bindings/interface/SBPlatform.i
  lldb/include/lldb/API/SBPlatform.h
  lldb/packages/Python/lldbsuite/test/decorators.py
  lldb/packages/Python/lldbsuite/test/dotest.py
  lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/source/API/SBPlatform.cpp
  
lldb/test/API/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py
  
lldb/test/API/functionalities/breakpoint/breakpoint_in_delayslot/TestAvoidBreakpointInDelaySlot.py
  
lldb/test/API/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
  lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
  lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteLoad.py
  lldb/test/API/functionalities/gdb_remote_client/TestWasm.py
  lldb/test/API/functionalities/gdb_remote_client/TestWriteMemory.py
  lldb/test/API/functionalities/gdb_remote_client/TestqOffsets.py
  lldb/test/API/functionalities/plugins/command_plugin/TestPluginCommands.py
  lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
  lldb/test/API/functionalities/postmortem/elf-core/gcore/TestGCore.py
  
lldb/test/API/functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py
  lldb/test/API/functionalities/postmortem/mach-core/TestMachCore.py
  lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
  lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py
  lldb/test/API/functionalities/postmortem/netbsd-core/TestNetBSDCore.py
  lldb/test/API/functionalities/thread/backtrace_all/TestBacktraceAll.py
  
lldb/test/API/functionalities/unwind/noreturn/module-end/TestNoReturnModuleEnd.py
  lldb/test/API/macosx/load-kext/TestLoadKext.py
  lldb/test/API/python_api/file_handle/TestFileHandle.py
  
lldb/test/API/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py

Index: lldb/test/API/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py
===
--- lldb/test/API/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py
+++ lldb/test/API/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py
@@ -10,14 +10,6 @@
 class TestPlatformProcessConnect(gdbremote_testcase.GdbRemoteTestCaseBase):
 mydir = TestBase.compute_mydir(__file__)
 
-def setUp(self):
-super(TestPlatformProcessConnect, self).setUp()
-self._initial_platform = lldb.DBG.GetSelectedPlatform()
-
-def tearDown(self):
-lldb.DBG.SetSelectedPlatform(self._initial_platform)
-super(TestPlatformProcessConnect, self).tearDown()
-
 @llgs_test
 @no_debug_info_test
 @skipIf(remote=False)
@@ -66,16 +58,10 @@
 
 socket_id = lldbutil.wait_for_file_on_target(self, port_file)
 
-new_debugger = lldb.SBDebugger.Create()
-new_debugger.SetAsync(False)
-
-def del_debugger(new_debugger=new_debugger):
-del new_debugger
-self.addTearDownHook(del_debugger)
+self.dbg.SetAsync(False)
 
 new_platform = lldb.SBPlatform(lldb.remote_platform.GetName())
-new_debugger.SetSelectedPlatform(new_platform)
-new_interpreter = new_debugger.GetCommandInterpreter()
+self.dbg.SetSelectedPlatform(new_platform)
 
 if unix_protocol:
 connect_url = "%s://%s%s" % (protocol, hostname, socket_id)
@@ -84,13 +70,13 @@
 
 command = "platform connect %s" % (connect_url)
 result = lldb.SBCommandReturnObject()
-new_interpreter.HandleCommand(command, result)
+self.dbg.GetCommandInterpreter().HandleCommand(command, result)
 self.assertTrue(
 result.Succeeded(),
 "platform process connect failed: %s" %
 result.GetOutput())
 
-target = new_debugger.GetSelectedTarget()
+target = self.dbg.GetSelectedTarget()
 process = target.GetProcess()
 thread = process.GetThreadAtIndex(0)
 
Index: lldb/test/API/python_api/file_handle/TestFileHandle.py
===
--- lldb/test/API/python_api/file_handle/TestFileHandle.py
+++ lldb/test/API/python_api/file_handle/TestFileHandle.py
@@ -82,12 +82,7 @@
 NO_DEBUG_INFO_TESTCASE = True
 mydir = lldbtest.Base.compute_mydir(__file__)
 
-# The way this class interacts with the debugger is different
-# than normal.   Most of these test cases will mess with

[Lldb-commits] [PATCH] D74557: [lldb] Make BreakpointResolver hold weak_ptr instead of raw pointer to breakpoint

2020-03-03 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha added a comment.

@jingham Is it Ok with you?


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

https://reviews.llvm.org/D74557



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


[Lldb-commits] [PATCH] D74903: [lldb][test] Add two wrapper functions to manage settings in test-suite

2020-02-21 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha added a comment.

I like this idea and ready to implement, but I'm not aware of the reasons why 
the current implementation was chosen. Suppose that initializing the Debugger 
for each test will slow down the test-suite significantly.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D74903



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


[Lldb-commits] [PATCH] D74903: [lldb][test] Add two wrapper-functions to manage settings in test-suite

2020-02-20 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha created this revision.
tatyana-krasnukha added reviewers: JDevlieghere, labath.
tatyana-krasnukha added a project: LLDB.
Herald added subscribers: lldb-commits, teemperor.

Some tests set settings and don't clean them up, this leads to side effects in 
other tests.

The patch adds wrappers that will set/append a setting and add a tear-down hook 
to clean/remove/restore its old value during the cleanup.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D74903

Files:
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/test/API/api/check_public_api_headers/TestPublicAPIHeaders.py
  lldb/test/API/benchmarks/continue/TestBenchmarkContinue.py
  lldb/test/API/benchmarks/libcxxlist/TestBenchmarkLibcxxList.py
  lldb/test/API/benchmarks/libcxxmap/TestBenchmarkLibcxxMap.py
  
lldb/test/API/commands/expression/import-std-module/basic/TestImportStdModule.py
  
lldb/test/API/commands/expression/import-std-module/conflicts/TestStdModuleWithConflicts.py
  
lldb/test/API/commands/expression/import-std-module/deque-basic/TestDequeFromStdModule.py
  
lldb/test/API/commands/expression/import-std-module/deque-dbg-info-content/TestDbgInfoContentDequeFromStdModule.py
  
lldb/test/API/commands/expression/import-std-module/empty-module/TestEmptyStdModule.py
  
lldb/test/API/commands/expression/import-std-module/forward_list-dbg-info-content/TestDbgInfoContentForwardListFromStdModule.py
  
lldb/test/API/commands/expression/import-std-module/forward_list/TestForwardListFromStdModule.py
  
lldb/test/API/commands/expression/import-std-module/list-dbg-info-content/TestDbgInfoContentListFromStdModule.py
  
lldb/test/API/commands/expression/import-std-module/list/TestListFromStdModule.py
  
lldb/test/API/commands/expression/import-std-module/no-std-module/TestMissingStdModule.py
  
lldb/test/API/commands/expression/import-std-module/queue/TestQueueFromStdModule.py
  
lldb/test/API/commands/expression/import-std-module/shared_ptr-dbg-info-content/TestSharedPtrDbgInfoContentFromStdModule.py
  
lldb/test/API/commands/expression/import-std-module/shared_ptr/TestSharedPtrFromStdModule.py
  
lldb/test/API/commands/expression/import-std-module/stack/TestStackFromStdModule.py
  
lldb/test/API/commands/expression/import-std-module/sysroot/TestStdModuleSysroot.py
  
lldb/test/API/commands/expression/import-std-module/unique_ptr-dbg-info-content/TestUniquePtrDbgInfoContent.py
  
lldb/test/API/commands/expression/import-std-module/unique_ptr/TestUniquePtrFromStdModule.py
  
lldb/test/API/commands/expression/import-std-module/vector-bool/TestVectorBoolFromStdModule.py
  
lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py
  
lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py
  
lldb/test/API/commands/expression/import-std-module/vector/TestVectorFromStdModule.py
  
lldb/test/API/commands/expression/import-std-module/weak_ptr-dbg-info-content/TestDbgInfoContentWeakPtrFromStdModule.py
  
lldb/test/API/commands/expression/import-std-module/weak_ptr/TestWeakPtrFromStdModule.py
  lldb/test/API/commands/expression/ir-interpreter/TestIRInterpreter.py
  lldb/test/API/commands/expression/save_jit_objects/TestSaveJITObjects.py
  lldb/test/API/commands/expression/test/TestExprs.py
  lldb/test/API/commands/expression/top-level/TestTopLevelExprs.py
  lldb/test/API/commands/expression/weak_symbols/TestWeakSymbols.py
  lldb/test/API/commands/help/TestHelp.py
  lldb/test/API/commands/process/launch/TestProcessLaunch.py
  lldb/test/API/commands/watchpoints/watchpoint_size/TestWatchpointSizes.py
  
lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
  
lldb/test/API/functionalities/breakpoint/breakpoint_options/TestBreakpointOptions.py
  
lldb/test/API/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py
  lldb/test/API/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py
  
lldb/test/API/functionalities/breakpoint/inlined_breakpoints/TestInlinedBreakpoints.py
  
lldb/test/API/functionalities/breakpoint/require_hw_breakpoints/TestRequireHWBreakpoints.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/TestDataFormatterLibccMultiMap.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/TestDataFormatterLibcxxMultiSet.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/set/TestDataFormatterLibcxxSet.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
  
lldb/test/API/functionalities/data-form

[Lldb-commits] [PATCH] D74558: [lldb] Make shared_from_this-related code safer

2020-02-18 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha closed this revision.
tatyana-krasnukha added a comment.

Closed by commit b624b7dfd087 



Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D74558



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


[Lldb-commits] [PATCH] D74556: [lldb] Don't call CopyForBreakpoint from a Breakpoint's constructor

2020-02-18 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha closed this revision.
tatyana-krasnukha added a comment.

Closed by commit 185ef697ef5c 



Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D74556



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


[Lldb-commits] [PATCH] D74557: [lldb] Make BreakpointResolver hold weak_ptr instead of raw pointer to breakpoint

2020-02-14 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha updated this revision to Diff 244727.
tatyana-krasnukha added a reviewer: jingham.
tatyana-krasnukha added a comment.

Just realized that BreakpointResolverScripted::CreateImplementationIfNeeded 
should work when m_breakpoint == nullptr.
GetBreakpoint with assertion is not suitable here, so I pass the breakpoint as 
a parameter.


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

https://reviews.llvm.org/D74557

Files:
  lldb/include/lldb/Breakpoint/BreakpointResolver.h
  lldb/include/lldb/Breakpoint/BreakpointResolverAddress.h
  lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h
  lldb/include/lldb/Breakpoint/BreakpointResolverFileRegex.h
  lldb/include/lldb/Breakpoint/BreakpointResolverName.h
  lldb/include/lldb/Breakpoint/BreakpointResolverScripted.h
  lldb/include/lldb/Target/LanguageRuntime.h
  lldb/source/Breakpoint/Breakpoint.cpp
  lldb/source/Breakpoint/BreakpointResolver.cpp
  lldb/source/Breakpoint/BreakpointResolverAddress.cpp
  lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
  lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
  lldb/source/Breakpoint/BreakpointResolverName.cpp
  lldb/source/Breakpoint/BreakpointResolverScripted.cpp
  
lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
  
lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
  lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
  lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
  
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
  
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
  lldb/source/Target/LanguageRuntime.cpp
  lldb/source/Target/Target.cpp

Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -621,7 +621,7 @@
 const bool hardware = request_hardware || GetRequireHardwareBreakpoints();
 bp_sp.reset(new Breakpoint(*this, filter_sp, resolver_sp, hardware,
resolve_indirect_symbols));
-resolver_sp->SetBreakpoint(bp_sp.get());
+resolver_sp->SetBreakpoint(bp_sp);
 AddBreakpoint(bp_sp, internal);
   }
   return bp_sp;
Index: lldb/source/Target/LanguageRuntime.cpp
===
--- lldb/source/Target/LanguageRuntime.cpp
+++ lldb/source/Target/LanguageRuntime.cpp
@@ -154,17 +154,17 @@
   }
 
 protected:
-  BreakpointResolverSP CopyForBreakpoint(Breakpoint &breakpoint) override {
+  BreakpointResolverSP CopyForBreakpoint(BreakpointSP &breakpoint) override {
 BreakpointResolverSP ret_sp(
 new ExceptionBreakpointResolver(m_language, m_catch_bp, m_throw_bp));
-ret_sp->SetBreakpoint(&breakpoint);
+ret_sp->SetBreakpoint(breakpoint);
 return ret_sp;
   }
 
   bool SetActualResolver() {
-ProcessSP process_sp;
-if (m_breakpoint) {
-  process_sp = m_breakpoint->GetTarget().GetProcessSP();
+BreakpointSP breakpoint_sp = GetBreakpoint();
+if (breakpoint_sp) {
+  ProcessSP process_sp = breakpoint_sp->GetTarget().GetProcessSP();
   if (process_sp) {
 bool refreash_resolver = !m_actual_resolver_sp;
 if (m_language_runtime == nullptr) {
@@ -181,7 +181,7 @@
 
 if (refreash_resolver && m_language_runtime) {
   m_actual_resolver_sp = m_language_runtime->CreateExceptionResolver(
-  m_breakpoint, m_catch_bp, m_throw_bp);
+  breakpoint_sp, m_catch_bp, m_throw_bp);
 }
   } else {
 m_actual_resolver_sp.reset();
Index: lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
===
--- lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
+++ lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
@@ -58,7 +58,7 @@
 // for .expand kernels as a fallback.
 class RSBreakpointResolver : public BreakpointResolver {
 public:
-  RSBreakpointResolver(Breakpoint *bp, ConstString name)
+  RSBreakpointResolver(const lldb::BreakpointSP &bp, ConstString name)
   : BreakpointResolver(bp, BreakpointResolver::NameResolver),
 m_kernel_name(name) {}
 
@@ -77,9 +77,9 @@
   lldb::SearchDepth GetDepth() override { return lldb::eSearchDepthModule; }
 
   lldb::BreakpointResolverSP
-  CopyForBreakpoint(Breakpoint &breakpoint) override {
+  CopyForBreakpoint(lldb::BreakpointSP &breakpoint) override {
 lldb::BreakpointResolverSP ret_sp(
-new RSBreakpointResolver(&breakpoint, m_kernel_name));
+new RSBreakpointRe

[Lldb-commits] [PATCH] D74557: [lldb] Make BreakpointResolver hold weak_ptr instead of raw pointer to breakpoint

2020-02-14 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha updated this revision to Diff 244645.
tatyana-krasnukha added a comment.

Moved assertion into GetBreakpoint().

> Were there any places you found where it was legit to ask for the Breakpoint 
> for a resolver and not have one?

I didn't find any, however, it seems to be possible in theory as 
BreakpointResolver is allowed to be constructed with `nullptr` instead of 
breakpoint (it is expected to call SetBreakpoint later).


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

https://reviews.llvm.org/D74557

Files:
  lldb/include/lldb/Breakpoint/BreakpointResolver.h
  lldb/include/lldb/Breakpoint/BreakpointResolverAddress.h
  lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h
  lldb/include/lldb/Breakpoint/BreakpointResolverFileRegex.h
  lldb/include/lldb/Breakpoint/BreakpointResolverName.h
  lldb/include/lldb/Breakpoint/BreakpointResolverScripted.h
  lldb/include/lldb/Target/LanguageRuntime.h
  lldb/source/Breakpoint/Breakpoint.cpp
  lldb/source/Breakpoint/BreakpointResolver.cpp
  lldb/source/Breakpoint/BreakpointResolverAddress.cpp
  lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
  lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
  lldb/source/Breakpoint/BreakpointResolverName.cpp
  lldb/source/Breakpoint/BreakpointResolverScripted.cpp
  
lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
  
lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
  lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
  lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
  
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
  
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
  lldb/source/Target/LanguageRuntime.cpp
  lldb/source/Target/Target.cpp

Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -621,7 +621,7 @@
 const bool hardware = request_hardware || GetRequireHardwareBreakpoints();
 bp_sp.reset(new Breakpoint(*this, filter_sp, resolver_sp, hardware,
resolve_indirect_symbols));
-resolver_sp->SetBreakpoint(bp_sp.get());
+resolver_sp->SetBreakpoint(bp_sp);
 AddBreakpoint(bp_sp, internal);
   }
   return bp_sp;
Index: lldb/source/Target/LanguageRuntime.cpp
===
--- lldb/source/Target/LanguageRuntime.cpp
+++ lldb/source/Target/LanguageRuntime.cpp
@@ -154,17 +154,17 @@
   }
 
 protected:
-  BreakpointResolverSP CopyForBreakpoint(Breakpoint &breakpoint) override {
+  BreakpointResolverSP CopyForBreakpoint(BreakpointSP &breakpoint) override {
 BreakpointResolverSP ret_sp(
 new ExceptionBreakpointResolver(m_language, m_catch_bp, m_throw_bp));
-ret_sp->SetBreakpoint(&breakpoint);
+ret_sp->SetBreakpoint(breakpoint);
 return ret_sp;
   }
 
   bool SetActualResolver() {
-ProcessSP process_sp;
-if (m_breakpoint) {
-  process_sp = m_breakpoint->GetTarget().GetProcessSP();
+BreakpointSP breakpoint_sp = GetBreakpoint();
+if (breakpoint_sp) {
+  ProcessSP process_sp = breakpoint_sp->GetTarget().GetProcessSP();
   if (process_sp) {
 bool refreash_resolver = !m_actual_resolver_sp;
 if (m_language_runtime == nullptr) {
@@ -181,7 +181,7 @@
 
 if (refreash_resolver && m_language_runtime) {
   m_actual_resolver_sp = m_language_runtime->CreateExceptionResolver(
-  m_breakpoint, m_catch_bp, m_throw_bp);
+  breakpoint_sp, m_catch_bp, m_throw_bp);
 }
   } else {
 m_actual_resolver_sp.reset();
Index: lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
===
--- lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
+++ lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
@@ -58,7 +58,7 @@
 // for .expand kernels as a fallback.
 class RSBreakpointResolver : public BreakpointResolver {
 public:
-  RSBreakpointResolver(Breakpoint *bp, ConstString name)
+  RSBreakpointResolver(const lldb::BreakpointSP &bp, ConstString name)
   : BreakpointResolver(bp, BreakpointResolver::NameResolver),
 m_kernel_name(name) {}
 
@@ -77,9 +77,9 @@
   lldb::SearchDepth GetDepth() override { return lldb::eSearchDepthModule; }
 
   lldb::BreakpointResolverSP
-  CopyForBreakpoint(Breakpoint &breakpoint) override {
+  CopyForBreakpoint(lldb::BreakpointSP &breakpoint) override {
 lldb::BreakpointResolverSP ret

[Lldb-commits] [PATCH] D70847: [lldb-vscode] Ensure that target matches the executable file

2020-02-13 Thread Tatyana Krasnukha via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG21d09ccf268d: [lldb-vscode] Ensure that target matches the 
executable file (authored by tatyana-krasnukha).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70847

Files:
  lldb/tools/lldb-vscode/VSCode.cpp
  lldb/tools/lldb-vscode/VSCode.h
  lldb/tools/lldb-vscode/lldb-vscode.cpp
  lldb/tools/lldb-vscode/package.json

Index: lldb/tools/lldb-vscode/package.json
===
--- lldb/tools/lldb-vscode/package.json
+++ lldb/tools/lldb-vscode/package.json
@@ -122,6 +122,14 @@
 "type": "string",
 "description": "Specify a working directory to set the debug adaptor to so relative object files can be located."
 			},
+			"targetTriple": {
+"type": "string",
+"description": "Triplet of the target architecture to override value derived from the program file."
+			},
+			"platformName": {
+"type": "string",
+"description": "Name of the execution platform to override value derived from the program file."
+			},
 			"initCommands": {
 	"type": "array",
 	"description": "Initialization commands executed upon debugger startup.",
@@ -175,6 +183,14 @@
 "type": "string",
 "description": "Specify a working directory to set the debug adaptor to so relative object files can be located."
 			},
+			"targetTriple": {
+"type": "string",
+"description": "Triplet of the target architecture to override value derived from the program file."
+			},
+			"platformName": {
+"type": "string",
+"description": "Name of the execution platform to override value derived from the program file."
+			},
 			"attachCommands": {
 "type": "array",
 "description": "Custom commands that are executed instead of attaching to a process ID or to a process by name. These commands may optionally create a new target and must perform an attach. A valid process must exist after these commands complete or the \"attach\" will fail.",
Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -69,8 +69,6 @@
 
 enum LaunchMethod { Launch, Attach, AttachForSuspendedLaunch };
 
-enum VSCodeBroadcasterBits { eBroadcastBitStopEventThread = 1u << 0 };
-
 SOCKET AcceptConnection(int portno) {
   // Accept a socket connection from any host on "portno".
   SOCKET newsockfd = -1;
@@ -505,25 +503,13 @@
   // Run any initialize LLDB commands the user specified in the launch.json
   g_vsc.RunInitCommands();
 
-  // Grab the name of the program we need to debug and set it as the first
-  // argument that will be passed to the program we will debug.
-  const auto program = GetString(arguments, "program");
-  if (!program.empty()) {
-lldb::SBFileSpec program_fspec(program.data(), true /*resolve_path*/);
-
-g_vsc.launch_info.SetExecutableFile(program_fspec,
-false /*add_as_first_arg*/);
-const char *target_triple = nullptr;
-const char *uuid_cstr = nullptr;
-// Stand alone debug info file if different from executable
-const char *symfile = nullptr;
-g_vsc.target.AddModule(program.data(), target_triple, uuid_cstr, symfile);
-if (error.Fail()) {
-  response["success"] = llvm::json::Value(false);
-  EmplaceSafeString(response, "message", std::string(error.GetCString()));
-  g_vsc.SendJSON(llvm::json::Value(std::move(response)));
-  return;
-}
+  lldb::SBError status;
+  g_vsc.SetTarget(g_vsc.CreateTargetFromArguments(*arguments, status));
+  if (status.Fail()) {
+response["success"] = llvm::json::Value(false);
+EmplaceSafeString(response, "message", status.GetCString());
+g_vsc.SendJSON(llvm::json::Value(std::move(response)));
+return;
   }
 
   const bool detatchOnError = GetBoolean(arguments, "detachOnError", false);
@@ -536,7 +522,8 @@
 char attach_info[256];
 auto attach_info_len =
 snprintf(attach_info, sizeof(attach_info),
- "Waiting to attach to \"%s\"...", program.data());
+ "Waiting to attach to \"%s\"...",
+ g_vsc.target.GetExecutable().GetFilename());
 g_vsc.SendOutput(OutputType::Console, llvm::StringRef(attach_info,
   attach_info_len));
   }
@@ -1210,13 +1197,6 @@
 g_vsc.debugger.SetErrorFileHandle(out, false);
   }
 
-  g_vsc.target = g_vsc.debugger.CreateTarget(nullptr);
-  lldb::SBListener listener = g_vsc.debugger.GetListener();
-  listener.StartListeningForEvents(
-  g_vsc.target.GetBroadcaster(),
-  lldb::SBTarget::eBroadcastBitBreakpointChanged);
-  listener.StartListeningForEven

[Lldb-commits] [PATCH] D74558: [lldb] Make shared_from_this-related code safer

2020-02-13 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha created this revision.
tatyana-krasnukha added reviewers: JDevlieghere, teemperor.
tatyana-krasnukha added a project: LLDB.
Herald added subscribers: lldb-commits, abidh.

The idea is: the fewer classes make an assumption that a target object is 
already managed by a shared_ptr - the fewer ways to make a mistake.

Pass TargetSP to filters' CreateFromStructuredData, don't let them guess 
whether the target object is managed by a shared_ptr.

Make Breakpoint sure that m_target.shared_from_this() is safe by passing 
TargetSP to all its static Create*** member-functions.
This should be enough since Breakpoint's constructors are private/protected and 
never called directly (except by Target itself).

The patch is a consequence of D74556 .


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D74558

Files:
  lldb/include/lldb/Breakpoint/Breakpoint.h
  lldb/include/lldb/Core/SearchFilter.h
  lldb/source/Breakpoint/Breakpoint.cpp
  lldb/source/Core/SearchFilter.cpp
  lldb/source/Target/Target.cpp

Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -131,7 +131,8 @@
 if (breakpoint_sp->IsInternal())
   continue;
 
-BreakpointSP new_bp(Breakpoint::CopyFromBreakpoint(*this, *breakpoint_sp));
+BreakpointSP new_bp(
+Breakpoint::CopyFromBreakpoint(shared_from_this(), *breakpoint_sp));
 AddBreakpoint(std::move(new_bp), false);
   }
 
@@ -1108,8 +1109,8 @@
 !Breakpoint::SerializedBreakpointMatchesNames(bkpt_data_sp, names))
   continue;
 
-BreakpointSP bkpt_sp =
-Breakpoint::CreateFromStructuredData(*this, bkpt_data_sp, error);
+BreakpointSP bkpt_sp = Breakpoint::CreateFromStructuredData(
+shared_from_this(), bkpt_data_sp, error);
 if (!error.Success()) {
   error.SetErrorStringWithFormat(
   "Error restoring breakpoint %zu from %s: %s.", i,
Index: lldb/source/Core/SearchFilter.cpp
===
--- lldb/source/Core/SearchFilter.cpp
+++ lldb/source/Core/SearchFilter.cpp
@@ -75,7 +75,8 @@
 SearchFilter::~SearchFilter() = default;
 
 SearchFilterSP SearchFilter::CreateFromStructuredData(
-Target &target, const StructuredData::Dictionary &filter_dict,
+const lldb::TargetSP& target_sp,
+const StructuredData::Dictionary &filter_dict,
 Status &error) {
   SearchFilterSP result_sp;
   if (!filter_dict.IsValid()) {
@@ -109,19 +110,19 @@
   switch (filter_type) {
   case Unconstrained:
 result_sp = SearchFilterForUnconstrainedSearches::CreateFromStructuredData(
-target, *subclass_options, error);
+target_sp, *subclass_options, error);
 break;
   case ByModule:
 result_sp = SearchFilterByModule::CreateFromStructuredData(
-target, *subclass_options, error);
+target_sp, *subclass_options, error);
 break;
   case ByModules:
 result_sp = SearchFilterByModuleList::CreateFromStructuredData(
-target, *subclass_options, error);
+target_sp, *subclass_options, error);
 break;
   case ByModulesAndCU:
 result_sp = SearchFilterByModuleListAndCU::CreateFromStructuredData(
-target, *subclass_options, error);
+target_sp, *subclass_options, error);
 break;
   case Exception:
 error.SetErrorString("Can't serialize exception breakpoints yet.");
@@ -212,7 +213,7 @@
 searcher.SearchCallback(*this, empty_sc, nullptr);
 return;
   }
-  
+
   DoModuleIteration(empty_sc, searcher);
 }
 
@@ -362,11 +363,11 @@
 //  Selects a shared library matching a given file spec, consulting the targets
 //  "black list".
 SearchFilterSP SearchFilterForUnconstrainedSearches::CreateFromStructuredData(
-Target &target, const StructuredData::Dictionary &data_dict,
+const lldb::TargetSP& target_sp,
+const StructuredData::Dictionary &data_dict,
 Status &error) {
   // No options for an unconstrained search.
-  return std::make_shared(
-  target.shared_from_this());
+  return std::make_shared(target_sp);
 }
 
 StructuredData::ObjectSP
@@ -472,7 +473,8 @@
 }
 
 SearchFilterSP SearchFilterByModule::CreateFromStructuredData(
-Target &target, const StructuredData::Dictionary &data_dict,
+const lldb::TargetSP& target_sp,
+const StructuredData::Dictionary &data_dict,
 Status &error) {
   StructuredData::Array *modules_array;
   bool success = data_dict.GetValueForKeyAsArray(GetKey(OptionNames::ModList),
@@ -497,8 +499,7 @@
   }
   FileSpec module_spec(module);
 
-  return std::make_shared(target.shared_from_this(),
-module_spec);
+  return std::make_shared(target_sp, module_spec);
 }
 
 StructuredData::ObjectSP SearchFilterByModule::SerializeToStructuredData() {
@@ -617,14 +618,15 @@
 }
 
 SearchFilterSP SearchFilterByModuleList::CreateFromStructuredData(
-Target &target, 

[Lldb-commits] [PATCH] D74556: [lldb] Don't call CopyForBreakpoint from a Breakpoint's constructor

2020-02-13 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha created this revision.
tatyana-krasnukha added reviewers: JDevlieghere, teemperor.
tatyana-krasnukha added a project: LLDB.
Herald added a subscriber: lldb-commits.

Some implementations (BreakpointResolverScripted) try calling the breakpoint's 
shared_from_this(),
that makes LLDB crash.

Added a test case that reproduced the issue.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D74556

Files:
  lldb/include/lldb/Breakpoint/Breakpoint.h
  
lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/scripted_bkpt/TestScriptedResolver.py
  lldb/source/Breakpoint/Breakpoint.cpp
  lldb/source/Target/Target.cpp

Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -127,12 +127,12 @@
 
   m_stop_hooks = target->m_stop_hooks;
 
-  for (BreakpointSP breakpoint_sp : target->m_breakpoint_list.Breakpoints()) {
+  for (const auto &breakpoint_sp : target->m_breakpoint_list.Breakpoints()) {
 if (breakpoint_sp->IsInternal())
   continue;
 
-BreakpointSP new_bp(new Breakpoint(*this, *breakpoint_sp.get()));
-AddBreakpoint(new_bp, false);
+BreakpointSP new_bp(Breakpoint::CopyFromBreakpoint(*this, *breakpoint_sp));
+AddBreakpoint(std::move(new_bp), false);
   }
 
   for (auto bp_name_entry : target->m_breakpoint_names) {
Index: lldb/source/Breakpoint/Breakpoint.cpp
===
--- lldb/source/Breakpoint/Breakpoint.cpp
+++ lldb/source/Breakpoint/Breakpoint.cpp
@@ -55,21 +55,26 @@
   m_being_created = false;
 }
 
-Breakpoint::Breakpoint(Target &new_target, Breakpoint &source_bp)
+Breakpoint::Breakpoint(Target &new_target, const Breakpoint &source_bp)
 : m_being_created(true), m_hardware(source_bp.m_hardware),
   m_target(new_target), m_name_list(source_bp.m_name_list),
   m_options_up(new BreakpointOptions(*source_bp.m_options_up)),
   m_locations(*this),
   m_resolve_indirect_symbols(source_bp.m_resolve_indirect_symbols),
-  m_hit_count(0) {
-  // Now go through and copy the filter & resolver:
-  m_resolver_sp = source_bp.m_resolver_sp->CopyForBreakpoint(*this);
-  m_filter_sp = source_bp.m_filter_sp->CopyForBreakpoint(*this);
-}
+  m_hit_count(0) {}
 
 // Destructor
 Breakpoint::~Breakpoint() = default;
 
+BreakpointSP Breakpoint::CopyFromBreakpoint(Target& new_target,
+const Breakpoint& bp_to_copy_from) {
+  BreakpointSP bp(new Breakpoint(new_target, bp_to_copy_from));
+  // Now go through and copy the filter & resolver:
+  bp->m_resolver_sp = bp_to_copy_from.m_resolver_sp->CopyForBreakpoint(*bp);
+  bp->m_filter_sp = bp_to_copy_from.m_filter_sp->CopyForBreakpoint(*bp);
+  return bp;
+}
+
 // Serialization
 StructuredData::ObjectSP Breakpoint::SerializeToStructuredData() {
   // Serialize the resolver:
Index: lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/scripted_bkpt/TestScriptedResolver.py
===
--- lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/scripted_bkpt/TestScriptedResolver.py
+++ lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/scripted_bkpt/TestScriptedResolver.py
@@ -40,8 +40,21 @@
 self.build()
 self.do_test_bad_options()
 
+@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24528")
+def test_copy_from_dummy_target(self):
+"""Make sure we don't crash during scripted breakpoint copy from dummy target"""
+self.build()
+self.do_test_copy_from_dummy_target()
+
 def make_target_and_import(self):
-target = lldbutil.run_to_breakpoint_make_target(self)
+target = self.make_target()
+self.import_resolver_script()
+return target
+
+def make_target(self):
+return lldbutil.run_to_breakpoint_make_target(self)
+
+def import_resolver_script(self):
 interp = self.dbg.GetCommandInterpreter()
 error = lldb.SBError()
 
@@ -52,7 +65,6 @@
 result = lldb.SBCommandReturnObject()
 interp.HandleCommand(command, result)
 self.assertTrue(result.Succeeded(), "com scr imp failed: %s"%(result.GetError()))
-return target
 
 def make_extra_args(self):
 json_string = '{"symbol":"break_on_me", "test1": "value1"}'
@@ -222,3 +234,23 @@
substrs=['Value: "a_value" missing matching key'])
 self.expect("break set -P resolver.Resolver -k a_key -k a_key -v another_value", error = True, msg="Missing value among args",
substrs=['Key: "a_key" missing value'])
+
+def do_test_copy_from_dummy_target(self):
+# Import breakpoint scripted resolver.
+self.import_resolver_script()
+
+# Create a scripted breakpoint.
+self.runCmd("breakpoint set -P resolver.Resolver -k symbol -v break_on_me",
+BREAKPOINT_CREATED)
+
+# This is the function to

[Lldb-commits] [PATCH] D74557: [lldb] Make BreakpointResolver hold weak_ptr instead of raw pointer to breakpoint

2020-02-13 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha created this revision.
tatyana-krasnukha added reviewers: JDevlieghere, teemperor.
tatyana-krasnukha added a project: LLDB.
Herald added a subscriber: lldb-commits.

This prevents calling Breakpoint::shared_from_this of an object that is not 
owned by any shared_ptr.

The patch is a consequence of D74556 


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D74557

Files:
  lldb/include/lldb/Breakpoint/BreakpointResolver.h
  lldb/include/lldb/Breakpoint/BreakpointResolverAddress.h
  lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h
  lldb/include/lldb/Breakpoint/BreakpointResolverFileRegex.h
  lldb/include/lldb/Breakpoint/BreakpointResolverName.h
  lldb/include/lldb/Breakpoint/BreakpointResolverScripted.h
  lldb/include/lldb/Target/LanguageRuntime.h
  lldb/source/Breakpoint/Breakpoint.cpp
  lldb/source/Breakpoint/BreakpointResolver.cpp
  lldb/source/Breakpoint/BreakpointResolverAddress.cpp
  lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
  lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
  lldb/source/Breakpoint/BreakpointResolverName.cpp
  lldb/source/Breakpoint/BreakpointResolverScripted.cpp
  
lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
  
lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
  lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
  lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
  
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
  
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
  lldb/source/Target/LanguageRuntime.cpp
  lldb/source/Target/Target.cpp

Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -621,7 +621,7 @@
 const bool hardware = request_hardware || GetRequireHardwareBreakpoints();
 bp_sp.reset(new Breakpoint(*this, filter_sp, resolver_sp, hardware,
resolve_indirect_symbols));
-resolver_sp->SetBreakpoint(bp_sp.get());
+resolver_sp->SetBreakpoint(bp_sp);
 AddBreakpoint(bp_sp, internal);
   }
   return bp_sp;
Index: lldb/source/Target/LanguageRuntime.cpp
===
--- lldb/source/Target/LanguageRuntime.cpp
+++ lldb/source/Target/LanguageRuntime.cpp
@@ -154,17 +154,17 @@
   }
 
 protected:
-  BreakpointResolverSP CopyForBreakpoint(Breakpoint &breakpoint) override {
+  BreakpointResolverSP CopyForBreakpoint(BreakpointSP &breakpoint) override {
 BreakpointResolverSP ret_sp(
 new ExceptionBreakpointResolver(m_language, m_catch_bp, m_throw_bp));
-ret_sp->SetBreakpoint(&breakpoint);
+ret_sp->SetBreakpoint(breakpoint);
 return ret_sp;
   }
 
   bool SetActualResolver() {
-ProcessSP process_sp;
-if (m_breakpoint) {
-  process_sp = m_breakpoint->GetTarget().GetProcessSP();
+BreakpointSP breakpoint_sp = GetBreakpoint();
+if (breakpoint_sp) {
+  ProcessSP process_sp = breakpoint_sp->GetTarget().GetProcessSP();
   if (process_sp) {
 bool refreash_resolver = !m_actual_resolver_sp;
 if (m_language_runtime == nullptr) {
@@ -181,7 +181,7 @@
 
 if (refreash_resolver && m_language_runtime) {
   m_actual_resolver_sp = m_language_runtime->CreateExceptionResolver(
-  m_breakpoint, m_catch_bp, m_throw_bp);
+  breakpoint_sp, m_catch_bp, m_throw_bp);
 }
   } else {
 m_actual_resolver_sp.reset();
Index: lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
===
--- lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
+++ lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
@@ -58,7 +58,7 @@
 // for .expand kernels as a fallback.
 class RSBreakpointResolver : public BreakpointResolver {
 public:
-  RSBreakpointResolver(Breakpoint *bp, ConstString name)
+  RSBreakpointResolver(const lldb::BreakpointSP &bp, ConstString name)
   : BreakpointResolver(bp, BreakpointResolver::NameResolver),
 m_kernel_name(name) {}
 
@@ -77,9 +77,9 @@
   lldb::SearchDepth GetDepth() override { return lldb::eSearchDepthModule; }
 
   lldb::BreakpointResolverSP
-  CopyForBreakpoint(Breakpoint &breakpoint) override {
+  CopyForBreakpoint(lldb::BreakpointSP &breakpoint) override {
 lldb::BreakpointResolverSP ret_sp(
-new RSBreakpointResolver(&breakpoint, m_kernel_name));
+new RSBreakpointResolver(breakpoint, m_kernel_nam

[Lldb-commits] [PATCH] D74244: [lldb] Delete register info definitions in the x86_64 ABI classes

2020-02-10 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha added inline comments.



Comment at: lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp:938
+  .Case("R8", LLDB_REGNUM_GENERIC_ARG5)
+  .Case("r9", LLDB_REGNUM_GENERIC_ARG6)
+  .Default(LLDB_INVALID_REGNUM);

Typo? It should be uppercase, I think.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74244



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


[Lldb-commits] [PATCH] D71906: [lldb][tests] Make it possible to expect failure for a whole category

2020-01-10 Thread Tatyana Krasnukha via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3eea082535e2: [lldb][tests] Make it possible to expect 
failure for a whole category (authored by tatyana-krasnukha).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71906

Files:
  lldb/packages/Python/lldbsuite/test/configuration.py
  lldb/packages/Python/lldbsuite/test/dotest.py
  lldb/packages/Python/lldbsuite/test/dotest_args.py
  lldb/packages/Python/lldbsuite/test/test_result.py


Index: lldb/packages/Python/lldbsuite/test/test_result.py
===
--- lldb/packages/Python/lldbsuite/test/test_result.py
+++ lldb/packages/Python/lldbsuite/test/test_result.py
@@ -164,6 +164,10 @@
 return True
 return False
 
+def checkCategoryExclusion(self, exclusion_list, test):
+return not set(exclusion_list).isdisjoint(
+self.getCategoriesForTest(test))
+
 def startTest(self, test):
 if configuration.shouldSkipBecauseOfCategories(
 self.getCategoriesForTest(test)):
@@ -182,8 +186,10 @@
 EventBuilder.event_for_start(test))
 
 def addSuccess(self, test):
-if self.checkExclusion(
-configuration.xfail_tests, test.id()):
+if (self.checkExclusion(
+configuration.xfail_tests, test.id()) or
+self.checkCategoryExclusion(
+configuration.xfail_categories, test)):
 self.addUnexpectedSuccess(test, None)
 return
 
@@ -245,8 +251,10 @@
 test, err))
 
 def addFailure(self, test, err):
-if self.checkExclusion(
-configuration.xfail_tests, test.id()):
+if (self.checkExclusion(
+configuration.xfail_tests, test.id()) or
+self.checkCategoryExclusion(
+configuration.xfail_categories, test)):
 self.addExpectedFailure(test, err, None)
 return
 
Index: lldb/packages/Python/lldbsuite/test/dotest_args.py
===
--- lldb/packages/Python/lldbsuite/test/dotest_args.py
+++ lldb/packages/Python/lldbsuite/test/dotest_args.py
@@ -83,6 +83,12 @@
 action='append',
 dest='skip_categories',
 help=textwrap.dedent('''Specify categories of test cases to skip. 
Takes precedence over -G. Can be specified more than once.'''))
+group.add_argument(
+'--xfail-category',
+metavar='category',
+action='append',
+dest='xfail_categories',
+help=textwrap.dedent('''Specify categories of test cases that are 
expected to fail. Can be specified more than once.'''))
 
 # Configuration options
 group = parser.add_argument_group('Configuration options')
Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -330,6 +330,10 @@
 configuration.skip_categories += test_categories.validate(
 args.skip_categories, False)
 
+if args.xfail_categories:
+configuration.xfail_categories += test_categories.validate(
+args.xfail_categories, False)
+
 if args.E:
 os.environ['CFLAGS_EXTRAS'] = args.E
 
Index: lldb/packages/Python/lldbsuite/test/configuration.py
===
--- lldb/packages/Python/lldbsuite/test/configuration.py
+++ lldb/packages/Python/lldbsuite/test/configuration.py
@@ -30,6 +30,8 @@
 use_categories = False
 # Categories we want to skip
 skip_categories = ["darwin-log"]
+# Categories we expect to fail
+xfail_categories = []
 # use this to track per-category failures
 failures_per_category = {}
 


Index: lldb/packages/Python/lldbsuite/test/test_result.py
===
--- lldb/packages/Python/lldbsuite/test/test_result.py
+++ lldb/packages/Python/lldbsuite/test/test_result.py
@@ -164,6 +164,10 @@
 return True
 return False
 
+def checkCategoryExclusion(self, exclusion_list, test):
+return not set(exclusion_list).isdisjoint(
+self.getCategoriesForTest(test))
+
 def startTest(self, test):
 if configuration.shouldSkipBecauseOfCategories(
 self.getCategoriesForTest(test)):
@@ -182,8 +186,10 @@
 EventBuilder.event_for_start(test))
 
 def addSuccess(self, test):
-if self.checkExclusion(
-configuration.xfail_tests, test.id()):
+if (self.checkExclusion(
+configuration.xfail_tests, test.id()) or
+self.checkCategoryExclusion(
+configuration.xfail_categories, test)):
 self.addUnexpectedSucc

[Lldb-commits] [PATCH] D71905: [lldb][tests] Take into account all parent's categories when traverse folders upwards

2020-01-10 Thread Tatyana Krasnukha via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe4d672971030: [lldb][tests] Take into account all 
parent's categories when traverse folders… (authored by tatyana-krasnukha).

Changed prior to commit:
  https://reviews.llvm.org/D71905?vs=237079&id=237294#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71905

Files:
  lldb/packages/Python/lldbsuite/test/.categories
  lldb/packages/Python/lldbsuite/test/test_result.py


Index: lldb/packages/Python/lldbsuite/test/test_result.py
===
--- lldb/packages/Python/lldbsuite/test/test_result.py
+++ lldb/packages/Python/lldbsuite/test/test_result.py
@@ -106,9 +106,8 @@
 def _getFileBasedCategories(test):
 """
 Returns the list of categories to which this test case belongs by
-looking for a ".categories" file. We start at the folder the test is in
-an traverse the hierarchy upwards - we guarantee a .categories to exist
-at the top level directory so we do not end up looping endlessly.
+collecting values of ".categories" files. We start at the folder the 
test is in
+and traverse the hierarchy upwards until the test-suite root directory.
 """
 import inspect
 import os.path
@@ -120,20 +119,22 @@
 start_path = inspect.getfile(test.__class__)
 
 folder = os.path.dirname(start_path)
-while folder != '/':
+
+from lldbsuite import lldb_test_root as test_root
+if test_root != os.path.commonprefix([folder, test_root]):
+raise Exception("The test file %s is outside the test root 
directory" % start_path)
+
+categories = set()
+while not os.path.samefile(folder, test_root):
 categories_file_name = os.path.join(folder, ".categories")
 if os.path.exists(categories_file_name):
 categories_file = open(categories_file_name, 'r')
-categories = categories_file.readline()
+categories_str = categories_file.readline().strip()
 categories_file.close()
-categories = str.replace(categories, '\n', '')
-categories = str.replace(categories, '\r', '')
-return categories.split(',')
-else:
-folder = os.path.dirname(folder)
-continue
-raise Exception("Did not find a .categories file, starting at: %s" % 
start_path)
+categories.update(categories_str.split(','))
+folder = os.path.dirname(folder)
 
+return list(categories)
 
 def getCategoriesForTest(self, test):
 """


Index: lldb/packages/Python/lldbsuite/test/test_result.py
===
--- lldb/packages/Python/lldbsuite/test/test_result.py
+++ lldb/packages/Python/lldbsuite/test/test_result.py
@@ -106,9 +106,8 @@
 def _getFileBasedCategories(test):
 """
 Returns the list of categories to which this test case belongs by
-looking for a ".categories" file. We start at the folder the test is in
-an traverse the hierarchy upwards - we guarantee a .categories to exist
-at the top level directory so we do not end up looping endlessly.
+collecting values of ".categories" files. We start at the folder the test is in
+and traverse the hierarchy upwards until the test-suite root directory.
 """
 import inspect
 import os.path
@@ -120,20 +119,22 @@
 start_path = inspect.getfile(test.__class__)
 
 folder = os.path.dirname(start_path)
-while folder != '/':
+
+from lldbsuite import lldb_test_root as test_root
+if test_root != os.path.commonprefix([folder, test_root]):
+raise Exception("The test file %s is outside the test root directory" % start_path)
+
+categories = set()
+while not os.path.samefile(folder, test_root):
 categories_file_name = os.path.join(folder, ".categories")
 if os.path.exists(categories_file_name):
 categories_file = open(categories_file_name, 'r')
-categories = categories_file.readline()
+categories_str = categories_file.readline().strip()
 categories_file.close()
-categories = str.replace(categories, '\n', '')
-categories = str.replace(categories, '\r', '')
-return categories.split(',')
-else:
-folder = os.path.dirname(folder)
-continue
-raise Exception("Did not find a .categories file, starting at: %s" % start_path)
+categories.update(categories_str.split(','))
+folder = os.path.dirname(folder)
 
+return list(categories)
 
 def ge

[Lldb-commits] [PATCH] D71905: [lldb][tests] Take into account all parent's categories when traverse folders upwards

2020-01-09 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha updated this revision to Diff 237079.
tatyana-krasnukha added a comment.

Stop iterating when reach the top-level test folder


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D71905

Files:
  lldb/packages/Python/lldbsuite/test/.categories
  lldb/packages/Python/lldbsuite/test/test_result.py


Index: lldb/packages/Python/lldbsuite/test/test_result.py
===
--- lldb/packages/Python/lldbsuite/test/test_result.py
+++ lldb/packages/Python/lldbsuite/test/test_result.py
@@ -106,9 +106,8 @@
 def _getFileBasedCategories(test):
 """
 Returns the list of categories to which this test case belongs by
-looking for a ".categories" file. We start at the folder the test is in
-an traverse the hierarchy upwards - we guarantee a .categories to exist
-at the top level directory so we do not end up looping endlessly.
+collecting values of ".categories" files. We start at the folder the 
test is in
+and traverse the hierarchy upwards until the test-suite root directory.
 """
 import inspect
 import os.path
@@ -120,20 +119,22 @@
 start_path = inspect.getfile(test.__class__)
 
 folder = os.path.dirname(start_path)
-while folder != '/':
+
+from lldbsuite import lldb_test_root as test_root
+if test_root != os.path.commonprefix([folder, test_root]):
+raise Exception("The test file %s is outside the test root 
directory" % start_path)
+
+categories = set()
+while not os.path.samefile(folder, test_root):
 categories_file_name = os.path.join(folder, ".categories")
 if os.path.exists(categories_file_name):
 categories_file = open(categories_file_name, 'r')
-categories = categories_file.readline()
+categories_str = categories_file.readline().strip()
 categories_file.close()
-categories = str.replace(categories, '\n', '')
-categories = str.replace(categories, '\r', '')
-return categories.split(',')
-else:
-folder = os.path.dirname(folder)
-continue
-raise Exception("Did not find a .categories file, starting at: %s" % 
start_path)
+categories.update(categories_str.split(','))
+folder = os.path.dirname(folder)
 
+return list(categories)
 
 def getCategoriesForTest(self, test):
 """


Index: lldb/packages/Python/lldbsuite/test/test_result.py
===
--- lldb/packages/Python/lldbsuite/test/test_result.py
+++ lldb/packages/Python/lldbsuite/test/test_result.py
@@ -106,9 +106,8 @@
 def _getFileBasedCategories(test):
 """
 Returns the list of categories to which this test case belongs by
-looking for a ".categories" file. We start at the folder the test is in
-an traverse the hierarchy upwards - we guarantee a .categories to exist
-at the top level directory so we do not end up looping endlessly.
+collecting values of ".categories" files. We start at the folder the test is in
+and traverse the hierarchy upwards until the test-suite root directory.
 """
 import inspect
 import os.path
@@ -120,20 +119,22 @@
 start_path = inspect.getfile(test.__class__)
 
 folder = os.path.dirname(start_path)
-while folder != '/':
+
+from lldbsuite import lldb_test_root as test_root
+if test_root != os.path.commonprefix([folder, test_root]):
+raise Exception("The test file %s is outside the test root directory" % start_path)
+
+categories = set()
+while not os.path.samefile(folder, test_root):
 categories_file_name = os.path.join(folder, ".categories")
 if os.path.exists(categories_file_name):
 categories_file = open(categories_file_name, 'r')
-categories = categories_file.readline()
+categories_str = categories_file.readline().strip()
 categories_file.close()
-categories = str.replace(categories, '\n', '')
-categories = str.replace(categories, '\r', '')
-return categories.split(',')
-else:
-folder = os.path.dirname(folder)
-continue
-raise Exception("Did not find a .categories file, starting at: %s" % start_path)
+categories.update(categories_str.split(','))
+folder = os.path.dirname(folder)
 
+return list(categories)
 
 def getCategoriesForTest(self, test):
 """
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://l

[Lldb-commits] [PATCH] D71906: [lldb][tests] Make it possible to expect failure for a whole category

2020-01-06 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha updated this revision to Diff 236374.
tatyana-krasnukha added a comment.

Increased number of lines of context.

Jonas, yes, it is.

Pavel, names are consistent (if I understand your comment correctly). The 
"--xfail-category" is singular like the "--skip-category".


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D71906

Files:
  lldb/packages/Python/lldbsuite/test/configuration.py
  lldb/packages/Python/lldbsuite/test/dotest.py
  lldb/packages/Python/lldbsuite/test/dotest_args.py
  lldb/packages/Python/lldbsuite/test/test_result.py


Index: lldb/packages/Python/lldbsuite/test/test_result.py
===
--- lldb/packages/Python/lldbsuite/test/test_result.py
+++ lldb/packages/Python/lldbsuite/test/test_result.py
@@ -156,6 +156,10 @@
 return True
 return False
 
+def checkCategoryExclusion(self, exclusion_list, test):
+return not set(exclusion_list).isdisjoint(
+self.getCategoriesForTest(test))
+
 def startTest(self, test):
 if configuration.shouldSkipBecauseOfCategories(
 self.getCategoriesForTest(test)):
@@ -174,8 +178,10 @@
 EventBuilder.event_for_start(test))
 
 def addSuccess(self, test):
-if self.checkExclusion(
-configuration.xfail_tests, test.id()):
+if (self.checkExclusion(
+configuration.xfail_tests, test.id()) or
+self.checkCategoryExclusion(
+configuration.xfail_categories, test)):
 self.addUnexpectedSuccess(test, None)
 return
 
@@ -245,8 +251,10 @@
 test, err))
 
 def addFailure(self, test, err):
-if self.checkExclusion(
-configuration.xfail_tests, test.id()):
+if (self.checkExclusion(
+configuration.xfail_tests, test.id()) or
+self.checkCategoryExclusion(
+configuration.xfail_categories, test)):
 self.addExpectedFailure(test, err, None)
 return
 
Index: lldb/packages/Python/lldbsuite/test/dotest_args.py
===
--- lldb/packages/Python/lldbsuite/test/dotest_args.py
+++ lldb/packages/Python/lldbsuite/test/dotest_args.py
@@ -84,6 +84,12 @@
 action='append',
 dest='skip_categories',
 help=textwrap.dedent('''Specify categories of test cases to skip. 
Takes precedence over -G. Can be specified more than once.'''))
+group.add_argument(
+'--xfail-category',
+metavar='category',
+action='append',
+dest='xfail_categories',
+help=textwrap.dedent('''Specify categories of test cases that are 
expected to fail. Can be specified more than once.'''))
 
 # Configuration options
 group = parser.add_argument_group('Configuration options')
Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -329,6 +329,10 @@
 configuration.skip_categories += test_categories.validate(
 args.skip_categories, False)
 
+if args.xfail_categories:
+configuration.xfail_categories += test_categories.validate(
+args.xfail_categories, False)
+
 if args.E:
 os.environ['CFLAGS_EXTRAS'] = args.E
 
Index: lldb/packages/Python/lldbsuite/test/configuration.py
===
--- lldb/packages/Python/lldbsuite/test/configuration.py
+++ lldb/packages/Python/lldbsuite/test/configuration.py
@@ -30,6 +30,8 @@
 use_categories = False
 # Categories we want to skip
 skip_categories = ["darwin-log"]
+# Categories we expect to fail
+xfail_categories = []
 # use this to track per-category failures
 failures_per_category = {}
 


Index: lldb/packages/Python/lldbsuite/test/test_result.py
===
--- lldb/packages/Python/lldbsuite/test/test_result.py
+++ lldb/packages/Python/lldbsuite/test/test_result.py
@@ -156,6 +156,10 @@
 return True
 return False
 
+def checkCategoryExclusion(self, exclusion_list, test):
+return not set(exclusion_list).isdisjoint(
+self.getCategoriesForTest(test))
+
 def startTest(self, test):
 if configuration.shouldSkipBecauseOfCategories(
 self.getCategoriesForTest(test)):
@@ -174,8 +178,10 @@
 EventBuilder.event_for_start(test))
 
 def addSuccess(self, test):
-if self.checkExclusion(
-configuration.xfail_tests, test.id()):
+if (self.checkExclusion(
+configuration.xfail_tests, test.id()) or
+self.checkCategoryExclusion(
+configuration

[Lldb-commits] [PATCH] D71905: [lldb][tests] Take into account all parent's categories when traverse folders upwards

2019-12-26 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha created this revision.
tatyana-krasnukha added reviewers: labath, teemperor.
Herald added subscribers: lldb-commits, JDevlieghere.
Herald added a project: LLDB.

This is needed to not "re-write" parent's categories by categories of a nested 
folder,
e.g. commands/expression/completion specify "cmdline" category, however it 
still belongs
to parent's "expression" category.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D71905

Files:
  packages/Python/lldbsuite/test/test_result.py


Index: packages/Python/lldbsuite/test/test_result.py
===
--- packages/Python/lldbsuite/test/test_result.py
+++ packages/Python/lldbsuite/test/test_result.py
@@ -107,26 +107,26 @@
 def _getFileBasedCategories(test):
 """
 Returns the list of categories to which this test case belongs by
-looking for a ".categories" file. We start at the folder the test is in
-an traverse the hierarchy upwards - we guarantee a .categories to exist
+collecting values of ".categories" files. We start at the folder the 
test is in
+and traverse the hierarchy upwards - we guarantee a .categories to 
exist
 at the top level directory so we do not end up looping endlessly.
 """
 import inspect
 import os.path
 folder = inspect.getfile(test.__class__)
 folder = os.path.dirname(folder)
+categories = set()
 while folder != '/':
 categories_file_name = os.path.join(folder, ".categories")
 if os.path.exists(categories_file_name):
 categories_file = open(categories_file_name, 'r')
-categories = categories_file.readline()
+categories_str = categories_file.readline().strip()
 categories_file.close()
-categories = str.replace(categories, '\n', '')
-categories = str.replace(categories, '\r', '')
-return categories.split(',')
-else:
-folder = os.path.dirname(folder)
-continue
+categories.update(categories_str.split(','))
+
+folder = os.path.dirname(folder)
+
+return list(categories)
 
 
 def getCategoriesForTest(self, test):


Index: packages/Python/lldbsuite/test/test_result.py
===
--- packages/Python/lldbsuite/test/test_result.py
+++ packages/Python/lldbsuite/test/test_result.py
@@ -107,26 +107,26 @@
 def _getFileBasedCategories(test):
 """
 Returns the list of categories to which this test case belongs by
-looking for a ".categories" file. We start at the folder the test is in
-an traverse the hierarchy upwards - we guarantee a .categories to exist
+collecting values of ".categories" files. We start at the folder the test is in
+and traverse the hierarchy upwards - we guarantee a .categories to exist
 at the top level directory so we do not end up looping endlessly.
 """
 import inspect
 import os.path
 folder = inspect.getfile(test.__class__)
 folder = os.path.dirname(folder)
+categories = set()
 while folder != '/':
 categories_file_name = os.path.join(folder, ".categories")
 if os.path.exists(categories_file_name):
 categories_file = open(categories_file_name, 'r')
-categories = categories_file.readline()
+categories_str = categories_file.readline().strip()
 categories_file.close()
-categories = str.replace(categories, '\n', '')
-categories = str.replace(categories, '\r', '')
-return categories.split(',')
-else:
-folder = os.path.dirname(folder)
-continue
+categories.update(categories_str.split(','))
+
+folder = os.path.dirname(folder)
+
+return list(categories)
 
 
 def getCategoriesForTest(self, test):
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D71906: [lldb][tests] Make it possible to expect failure for a whole category

2019-12-26 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha created this revision.
tatyana-krasnukha added reviewers: labath, teemperor.
Herald added subscribers: lldb-commits, JDevlieghere.
Herald added a project: LLDB.

There already are decorators and "--excluded" option to mark test-cases/files
as expected to fail. However, when a new test file is added and it relates
to a feature that a target doesn't support, this requires either adding 
decorators
to that file or modifying the file provided as "--excluded" option value.

The purpose of this patch is to avoid any modifications in such cases.
E.g. if a target doesn't support "watchpoints" and passes "--xfail-category 
watchpoint"
to dotest, a testing job will not fail after a new watchpoint-related test file 
is added.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D71906

Files:
  packages/Python/lldbsuite/test/configuration.py
  packages/Python/lldbsuite/test/dotest.py
  packages/Python/lldbsuite/test/dotest_args.py
  packages/Python/lldbsuite/test/test_result.py


Index: packages/Python/lldbsuite/test/test_result.py
===
--- packages/Python/lldbsuite/test/test_result.py
+++ packages/Python/lldbsuite/test/test_result.py
@@ -156,6 +156,10 @@
 return True
 return False
 
+def checkCategoryExclusion(self, exclusion_list, test):
+return not set(exclusion_list).isdisjoint(
+self.getCategoriesForTest(test))
+
 def startTest(self, test):
 if configuration.shouldSkipBecauseOfCategories(
 self.getCategoriesForTest(test)):
@@ -174,8 +178,10 @@
 EventBuilder.event_for_start(test))
 
 def addSuccess(self, test):
-if self.checkExclusion(
-configuration.xfail_tests, test.id()):
+if (self.checkExclusion(
+configuration.xfail_tests, test.id()) or
+self.checkCategoryExclusion(
+configuration.xfail_categories, test)):
 self.addUnexpectedSuccess(test, None)
 return
 
@@ -245,8 +251,10 @@
 test, err))
 
 def addFailure(self, test, err):
-if self.checkExclusion(
-configuration.xfail_tests, test.id()):
+if (self.checkExclusion(
+configuration.xfail_tests, test.id()) or
+self.checkCategoryExclusion(
+configuration.xfail_categories, test)):
 self.addExpectedFailure(test, err, None)
 return
 
Index: packages/Python/lldbsuite/test/dotest_args.py
===
--- packages/Python/lldbsuite/test/dotest_args.py
+++ packages/Python/lldbsuite/test/dotest_args.py
@@ -84,6 +84,12 @@
 action='append',
 dest='skip_categories',
 help=textwrap.dedent('''Specify categories of test cases to skip. 
Takes precedence over -G. Can be specified more than once.'''))
+group.add_argument(
+'--xfail-category',
+metavar='category',
+action='append',
+dest='xfail_categories',
+help=textwrap.dedent('''Specify categories of test cases that are 
expected to fail. Can be specified more than once.'''))
 
 # Configuration options
 group = parser.add_argument_group('Configuration options')
Index: packages/Python/lldbsuite/test/dotest.py
===
--- packages/Python/lldbsuite/test/dotest.py
+++ packages/Python/lldbsuite/test/dotest.py
@@ -329,6 +329,10 @@
 configuration.skip_categories += test_categories.validate(
 args.skip_categories, False)
 
+if args.xfail_categories:
+configuration.xfail_categories += test_categories.validate(
+args.xfail_categories, False)
+
 if args.E:
 os.environ['CFLAGS_EXTRAS'] = args.E
 
Index: packages/Python/lldbsuite/test/configuration.py
===
--- packages/Python/lldbsuite/test/configuration.py
+++ packages/Python/lldbsuite/test/configuration.py
@@ -30,6 +30,8 @@
 use_categories = False
 # Categories we want to skip
 skip_categories = ["darwin-log"]
+# Categories we expect to fail
+xfail_categories = []
 # use this to track per-category failures
 failures_per_category = {}
 


Index: packages/Python/lldbsuite/test/test_result.py
===
--- packages/Python/lldbsuite/test/test_result.py
+++ packages/Python/lldbsuite/test/test_result.py
@@ -156,6 +156,10 @@
 return True
 return False
 
+def checkCategoryExclusion(self, exclusion_list, test):
+return not set(exclusion_list).isdisjoint(
+self.getCategoriesForTest(test))
+
 def startTest(self, test):
 if configuration.shouldSkipBecauseOfCategories(
 self.getCategoriesForTest(test)):
@@ -174,8 +178,10 @@
 EventBuilder.event_for_star

[Lldb-commits] [PATCH] D69589: [lldb] Refactor all POST_BUILD commands into targets

2019-12-05 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha added inline comments.



Comment at: lldb/CMakeLists.txt:114
+  COMMAND ${CMAKE_COMMAND} -E make_directory ${ARG_DEST_DIR})
+foreach(src_file ${ARG_FILES})
+  if(ARG_DEST_FILE_NAME)

This is quite off-topic, but it would be great if this function could handle 
whole directories as well as separate files. So adding a script will not 
require to change this file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69589



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


[Lldb-commits] [PATCH] D67227: [lldb] Extend and document TestIRInterpreter.py

2019-11-01 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha added a comment.

I mean, when a process is not able to allocate memory, it cannot JIT, but still 
can interpret. Should the test report failure in this case?


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

https://reviews.llvm.org/D67227



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


[Lldb-commits] [PATCH] D67227: [lldb] Extend and document TestIRInterpreter.py

2019-11-01 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha added a comment.

Another problem of the `test_ir_interpreter` is that it fails even when JIT 
fails despite it should test the interpreter.


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

https://reviews.llvm.org/D67227



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


[Lldb-commits] [PATCH] D55718: [ARC] Basic support in gdb-remote process plugin

2019-10-17 Thread Tatyana Krasnukha via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfaf6b2543e47: [ARC] Basic support in gdb-remote process 
plugin (authored by tatyana-krasnukha).

Changed prior to commit:
  https://reviews.llvm.org/D55718?vs=225432&id=225437#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D55718

Files:
  lldb/include/lldb/Utility/ArchSpec.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  lldb/source/Target/Platform.cpp
  lldb/source/Target/Thread.cpp
  lldb/source/Utility/ArchSpec.cpp


Index: lldb/source/Utility/ArchSpec.cpp
===
--- lldb/source/Utility/ArchSpec.cpp
+++ lldb/source/Utility/ArchSpec.cpp
@@ -216,6 +216,7 @@
  ArchSpec::eCore_uknownMach32, "unknown-mach-32"},
 {eByteOrderLittle, 8, 4, 4, llvm::Triple::UnknownArch,
  ArchSpec::eCore_uknownMach64, "unknown-mach-64"},
+{eByteOrderLittle, 4, 2, 4, llvm::Triple::arc, ArchSpec::eCore_arc, "arc"}
 };
 
 // Ensure that we have an entry in the g_core_definitions for each core. If you
@@ -442,6 +443,8 @@
  ArchSpec::eMIPSSubType_mips64r6el, 0xu, 0xu}, // 
mips64r6el
 {ArchSpec::eCore_hexagon_generic, llvm::ELF::EM_HEXAGON,
  LLDB_INVALID_CPUTYPE, 0xu, 0xu}, // HEXAGON
+{ArchSpec::eCore_arc, llvm::ELF::EM_ARC_COMPACT2, LLDB_INVALID_CPUTYPE,
+ 0xu, 0xu }, // ARC
 };
 
 static const ArchDefinition g_elf_arch_def = {
Index: lldb/source/Target/Thread.cpp
===
--- lldb/source/Target/Thread.cpp
+++ lldb/source/Target/Thread.cpp
@@ -2061,6 +2061,7 @@
 case llvm::Triple::ppc64le:
 case llvm::Triple::systemz:
 case llvm::Triple::hexagon:
+case llvm::Triple::arc:
   m_unwinder_up.reset(new UnwindLLDB(*this));
   break;
 
Index: lldb/source/Target/Platform.cpp
===
--- lldb/source/Target/Platform.cpp
+++ lldb/source/Target/Platform.cpp
@@ -1823,6 +1823,12 @@
 trap_opcode_size = sizeof(g_aarch64_opcode);
   } break;
 
+  case llvm::Triple::arc: {
+static const uint8_t g_hex_opcode[] = { 0xff, 0x7f };
+trap_opcode = g_hex_opcode;
+trap_opcode_size = sizeof(g_hex_opcode);
+  } break;
+
   // TODO: support big-endian arm and thumb trap codes.
   case llvm::Triple::arm: {
 // The ARM reference recommends the use of 0xe7fddefe and 0xdefe but the
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -339,7 +339,7 @@
   // not, we assume no limit
 
   // build the qSupported packet
-  std::vector features = {"xmlRegisters=i386,arm,mips"};
+  std::vector features = {"xmlRegisters=i386,arm,mips,arc"};
   StreamString packet;
   packet.PutCString("qSupported");
   for (uint32_t i = 0; i < features.size(); ++i) {
Index: lldb/include/lldb/Utility/ArchSpec.h
===
--- lldb/include/lldb/Utility/ArchSpec.h
+++ lldb/include/lldb/Utility/ArchSpec.h
@@ -184,6 +184,8 @@
 eCore_uknownMach32,
 eCore_uknownMach64,
 
+eCore_arc, // little endian ARC
+
 kNumCores,
 
 kCore_invalid,


Index: lldb/source/Utility/ArchSpec.cpp
===
--- lldb/source/Utility/ArchSpec.cpp
+++ lldb/source/Utility/ArchSpec.cpp
@@ -216,6 +216,7 @@
  ArchSpec::eCore_uknownMach32, "unknown-mach-32"},
 {eByteOrderLittle, 8, 4, 4, llvm::Triple::UnknownArch,
  ArchSpec::eCore_uknownMach64, "unknown-mach-64"},
+{eByteOrderLittle, 4, 2, 4, llvm::Triple::arc, ArchSpec::eCore_arc, "arc"}
 };
 
 // Ensure that we have an entry in the g_core_definitions for each core. If you
@@ -442,6 +443,8 @@
  ArchSpec::eMIPSSubType_mips64r6el, 0xu, 0xu}, // mips64r6el
 {ArchSpec::eCore_hexagon_generic, llvm::ELF::EM_HEXAGON,
  LLDB_INVALID_CPUTYPE, 0xu, 0xu}, // HEXAGON
+{ArchSpec::eCore_arc, llvm::ELF::EM_ARC_COMPACT2, LLDB_INVALID_CPUTYPE,
+ 0xu, 0xu }, // ARC
 };
 
 static const ArchDefinition g_elf_arch_def = {
Index: lldb/source/Target/Thread.cpp
===
--- lldb/source/Target/Thread.cpp
+++ lldb/source/Target/Thread.cpp
@@ -2061,6 +2061,7 @@
 case llvm::Triple::ppc64le:
 case llvm::Triple::systemz:
 case llvm::Triple::hexagon:
+case llvm::Triple::arc:
   m_unwinder_up.reset(new UnwindLLDB(*this));
   break;
 
Index: lldb/source/Target/Platform.cpp

[Lldb-commits] [PATCH] D55724: [ARC] Add SystemV ABI

2019-10-17 Thread Tatyana Krasnukha via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG92e498d58cf4: [ARC] Add SystemV ABI (authored by 
tatyana-krasnukha).

Changed prior to commit:
  https://reviews.llvm.org/D55724?vs=225433&id=225438#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D55724

Files:
  lldb/source/API/SystemInitializerFull.cpp
  lldb/source/Plugins/ABI/CMakeLists.txt
  lldb/source/Plugins/ABI/SysV-arc/ABISysV_arc.cpp
  lldb/source/Plugins/ABI/SysV-arc/ABISysV_arc.h
  lldb/source/Plugins/ABI/SysV-arc/CMakeLists.txt

Index: lldb/source/Plugins/ABI/SysV-arc/CMakeLists.txt
===
--- /dev/null
+++ lldb/source/Plugins/ABI/SysV-arc/CMakeLists.txt
@@ -0,0 +1,11 @@
+add_lldb_library(lldbPluginABISysV_arc PLUGIN
+  ABISysV_arc.cpp
+
+  LINK_LIBS
+lldbCore
+lldbSymbol
+lldbTarget
+lldbPluginProcessUtility
+  LINK_COMPONENTS
+Support
+  )
Index: lldb/source/Plugins/ABI/SysV-arc/ABISysV_arc.h
===
--- /dev/null
+++ lldb/source/Plugins/ABI/SysV-arc/ABISysV_arc.h
@@ -0,0 +1,106 @@
+//===-- ArchitectureArc.h ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef liblldb_ABISysV_arc_h_
+#define liblldb_ABISysV_arc_h_
+
+// Other libraries and framework includes
+#include 
+
+// Project includes
+#include "lldb/Target/ABI.h"
+#include "lldb/lldb-private.h"
+
+class ABISysV_arc : public lldb_private::ABI {
+public:
+  ~ABISysV_arc() override = default;
+
+  size_t GetRedZoneSize() const override;
+
+  bool PrepareTrivialCall(lldb_private::Thread &thread, lldb::addr_t sp,
+  lldb::addr_t functionAddress,
+  lldb::addr_t returnAddress,
+  llvm::ArrayRef args) const override;
+
+  // Special thread plan for GDB style non-jit function calls.
+  bool
+  PrepareTrivialCall(lldb_private::Thread &thread, lldb::addr_t sp,
+ lldb::addr_t functionAddress, lldb::addr_t returnAddress,
+ llvm::Type &prototype,
+ llvm::ArrayRef args) const override;
+
+  bool GetArgumentValues(lldb_private::Thread &thread,
+ lldb_private::ValueList &values) const override;
+
+  lldb_private::Status
+  SetReturnValueObject(lldb::StackFrameSP &frame_sp,
+   lldb::ValueObjectSP &new_value) override;
+
+  lldb::ValueObjectSP
+  GetReturnValueObjectImpl(lldb_private::Thread &thread,
+   lldb_private::CompilerType &type) const override;
+
+  // Specialized to work with llvm IR types.
+  lldb::ValueObjectSP GetReturnValueObjectImpl(lldb_private::Thread &thread,
+   llvm::Type &type) const override;
+
+  bool
+  CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override;
+
+  bool CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override;
+
+  bool RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override;
+
+  bool CallFrameAddressIsValid(lldb::addr_t cfa) override {
+// Stack call frame address must be 4 byte aligned.
+return (cfa & 0x3ull) == 0;
+  }
+
+  bool CodeAddressIsValid(lldb::addr_t pc) override {
+// Code addresse must be 2 byte aligned.
+return (pc & 1ull) == 0;
+  }
+
+  const lldb_private::RegisterInfo *
+  GetRegisterInfoArray(uint32_t &count) override;
+
+  //--
+  // Static Functions
+  //--
+
+  static void Initialize();
+
+  static void Terminate();
+
+  static lldb::ABISP CreateInstance(lldb::ProcessSP process_sp,
+const lldb_private::ArchSpec &arch);
+
+  static lldb_private::ConstString GetPluginNameStatic();
+
+  //--
+  // PluginInterface protocol
+  //--
+
+  lldb_private::ConstString GetPluginName() override;
+
+  uint32_t GetPluginVersion() override;
+
+private:
+  lldb::ValueObjectSP
+  GetReturnValueObjectSimple(lldb_private::Thread &thread,
+ lldb_private::CompilerType &ast_type) const;
+
+  bool IsRegisterFileReduced(lldb_private::RegisterContext ®_ctx) const;
+
+  using lldb_private::ABI::ABI; // Call CreateInstance instead.
+
+  using RegisterFileFlag = llvm::Optional;
+  mutable RegisterFileFlag m_is_reg_file_reduced;
+};
+
+#endif // liblldb_ABISysV_arc_h_
Index: ll

[Lldb-commits] [PATCH] D55724: [ARC] Add SystemV ABI

2019-10-17 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha updated this revision to Diff 225433.
tatyana-krasnukha added a comment.
Herald added a subscriber: JDevlieghere.

Rebased on the current trunk.

Updated according to the last revision of D55718 
.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D55724

Files:
  source/API/SystemInitializerFull.cpp
  source/Plugins/ABI/CMakeLists.txt
  source/Plugins/ABI/SysV-arc/ABISysV_arc.cpp
  source/Plugins/ABI/SysV-arc/ABISysV_arc.h
  source/Plugins/ABI/SysV-arc/CMakeLists.txt

Index: source/Plugins/ABI/SysV-arc/CMakeLists.txt
===
--- source/Plugins/ABI/SysV-arc/CMakeLists.txt
+++ source/Plugins/ABI/SysV-arc/CMakeLists.txt
@@ -0,0 +1,11 @@
+add_lldb_library(lldbPluginABISysV_arc PLUGIN
+  ABISysV_arc.cpp
+
+  LINK_LIBS
+lldbCore
+lldbSymbol
+lldbTarget
+lldbPluginProcessUtility
+  LINK_COMPONENTS
+Support
+  )
Index: source/Plugins/ABI/SysV-arc/ABISysV_arc.h
===
--- source/Plugins/ABI/SysV-arc/ABISysV_arc.h
+++ source/Plugins/ABI/SysV-arc/ABISysV_arc.h
@@ -0,0 +1,106 @@
+//===-- ArchitectureArc.h ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef liblldb_ABISysV_arc_h_
+#define liblldb_ABISysV_arc_h_
+
+// Other libraries and framework includes
+#include 
+
+// Project includes
+#include "lldb/Target/ABI.h"
+#include "lldb/lldb-private.h"
+
+class ABISysV_arc : public lldb_private::ABI {
+public:
+  ~ABISysV_arc() override = default;
+
+  size_t GetRedZoneSize() const override;
+
+  bool PrepareTrivialCall(lldb_private::Thread &thread, lldb::addr_t sp,
+  lldb::addr_t functionAddress,
+  lldb::addr_t returnAddress,
+  llvm::ArrayRef args) const override;
+
+  // Special thread plan for GDB style non-jit function calls.
+  bool
+  PrepareTrivialCall(lldb_private::Thread &thread, lldb::addr_t sp,
+ lldb::addr_t functionAddress, lldb::addr_t returnAddress,
+ llvm::Type &prototype,
+ llvm::ArrayRef args) const override;
+
+  bool GetArgumentValues(lldb_private::Thread &thread,
+ lldb_private::ValueList &values) const override;
+
+  lldb_private::Status
+  SetReturnValueObject(lldb::StackFrameSP &frame_sp,
+   lldb::ValueObjectSP &new_value) override;
+
+  lldb::ValueObjectSP
+  GetReturnValueObjectImpl(lldb_private::Thread &thread,
+   lldb_private::CompilerType &type) const override;
+
+  // Specialized to work with llvm IR types.
+  lldb::ValueObjectSP GetReturnValueObjectImpl(lldb_private::Thread &thread,
+   llvm::Type &type) const override;
+
+  bool
+  CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override;
+
+  bool CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override;
+
+  bool RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override;
+
+  bool CallFrameAddressIsValid(lldb::addr_t cfa) override {
+// Stack call frame address must be 4 byte aligned.
+return (cfa & 0x3ull) == 0;
+  }
+
+  bool CodeAddressIsValid(lldb::addr_t pc) override {
+// Code addresse must be 2 byte aligned.
+return (pc & 1ull) == 0;
+  }
+
+  const lldb_private::RegisterInfo *
+  GetRegisterInfoArray(uint32_t &count) override;
+
+  //--
+  // Static Functions
+  //--
+
+  static void Initialize();
+
+  static void Terminate();
+
+  static lldb::ABISP CreateInstance(lldb::ProcessSP process_sp,
+const lldb_private::ArchSpec &arch);
+
+  static lldb_private::ConstString GetPluginNameStatic();
+
+  //--
+  // PluginInterface protocol
+  //--
+
+  lldb_private::ConstString GetPluginName() override;
+
+  uint32_t GetPluginVersion() override;
+
+private:
+  lldb::ValueObjectSP
+  GetReturnValueObjectSimple(lldb_private::Thread &thread,
+ lldb_private::CompilerType &ast_type) const;
+
+  bool IsRegisterFileReduced(lldb_private::RegisterContext ®_ctx) const;
+
+  using lldb_private::ABI::ABI; // Call CreateInstance instead.
+
+  using ConfigurationFlags = llvm::Optional;
+  mutable ConfigurationFlags m_is_reg_file_reduced;
+};
+
+#endif // liblldb_ABISysV_ar

[Lldb-commits] [PATCH] D55718: [ARC] Basic support in gdb-remote process plugin

2019-10-17 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha updated this revision to Diff 225432.
tatyana-krasnukha added a comment.
Herald added a subscriber: wuzish.

Removed any ARC-specific logic from the ProcessGDBRemote.cpp.

It seems, there is nothing to test now;)


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D55718

Files:
  include/lldb/Utility/ArchSpec.h
  source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  source/Target/Platform.cpp
  source/Target/Thread.cpp
  source/Utility/ArchSpec.cpp


Index: include/lldb/Utility/ArchSpec.h
===
--- include/lldb/Utility/ArchSpec.h
+++ include/lldb/Utility/ArchSpec.h
@@ -183,6 +183,8 @@
 eCore_uknownMach32,
 eCore_uknownMach64,
 
+eCore_arc, // little endian ARC
+
 kNumCores,
 
 kCore_invalid,
Index: source/Utility/ArchSpec.cpp
===
--- source/Utility/ArchSpec.cpp
+++ source/Utility/ArchSpec.cpp
@@ -214,6 +214,7 @@
  ArchSpec::eCore_uknownMach32, "unknown-mach-32"},
 {eByteOrderLittle, 8, 4, 4, llvm::Triple::UnknownArch,
  ArchSpec::eCore_uknownMach64, "unknown-mach-64"},
+{eByteOrderLittle, 4, 2, 4, llvm::Triple::arc, ArchSpec::eCore_arc, "arc"}
 };
 
 // Ensure that we have an entry in the g_core_definitions for each core. If you
@@ -436,6 +437,8 @@
  ArchSpec::eMIPSSubType_mips64r6el, 0xu, 0xu}, // 
mips64r6el
 {ArchSpec::eCore_hexagon_generic, llvm::ELF::EM_HEXAGON,
  LLDB_INVALID_CPUTYPE, 0xu, 0xu}, // HEXAGON
+{ArchSpec::eCore_arc, llvm::ELF::EM_ARC_COMPACT2, LLDB_INVALID_CPUTYPE,
+ 0xu, 0xu }, // ARC
 };
 
 static const ArchDefinition g_elf_arch_def = {
Index: source/Target/Thread.cpp
===
--- source/Target/Thread.cpp
+++ source/Target/Thread.cpp
@@ -2060,6 +2060,7 @@
 case llvm::Triple::ppc64le:
 case llvm::Triple::systemz:
 case llvm::Triple::hexagon:
+case llvm::Triple::arc:
   m_unwinder_up.reset(new UnwindLLDB(*this));
   break;
 
Index: source/Target/Platform.cpp
===
--- source/Target/Platform.cpp
+++ source/Target/Platform.cpp
@@ -1822,6 +1822,12 @@
 trap_opcode_size = sizeof(g_aarch64_opcode);
   } break;
 
+  case llvm::Triple::arc: {
+static const uint8_t g_hex_opcode[] = { 0xff, 0x7f };
+trap_opcode = g_hex_opcode;
+trap_opcode_size = sizeof(g_hex_opcode);
+  } break;
+
   // TODO: support big-endian arm and thumb trap codes.
   case llvm::Triple::arm: {
 // The ARM reference recommends the use of 0xe7fddefe and 0xdefe but the
Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
===
--- source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -339,7 +339,7 @@
   // not, we assume no limit
 
   // build the qSupported packet
-  std::vector features = {"xmlRegisters=i386,arm,mips"};
+  std::vector features = {"xmlRegisters=i386,arm,mips,arc"};
   StreamString packet;
   packet.PutCString("qSupported");
   for (uint32_t i = 0; i < features.size(); ++i) {


Index: include/lldb/Utility/ArchSpec.h
===
--- include/lldb/Utility/ArchSpec.h
+++ include/lldb/Utility/ArchSpec.h
@@ -183,6 +183,8 @@
 eCore_uknownMach32,
 eCore_uknownMach64,
 
+eCore_arc, // little endian ARC
+
 kNumCores,
 
 kCore_invalid,
Index: source/Utility/ArchSpec.cpp
===
--- source/Utility/ArchSpec.cpp
+++ source/Utility/ArchSpec.cpp
@@ -214,6 +214,7 @@
  ArchSpec::eCore_uknownMach32, "unknown-mach-32"},
 {eByteOrderLittle, 8, 4, 4, llvm::Triple::UnknownArch,
  ArchSpec::eCore_uknownMach64, "unknown-mach-64"},
+{eByteOrderLittle, 4, 2, 4, llvm::Triple::arc, ArchSpec::eCore_arc, "arc"}
 };
 
 // Ensure that we have an entry in the g_core_definitions for each core. If you
@@ -436,6 +437,8 @@
  ArchSpec::eMIPSSubType_mips64r6el, 0xu, 0xu}, // mips64r6el
 {ArchSpec::eCore_hexagon_generic, llvm::ELF::EM_HEXAGON,
  LLDB_INVALID_CPUTYPE, 0xu, 0xu}, // HEXAGON
+{ArchSpec::eCore_arc, llvm::ELF::EM_ARC_COMPACT2, LLDB_INVALID_CPUTYPE,
+ 0xu, 0xu }, // ARC
 };
 
 static const ArchDefinition g_elf_arch_def = {
Index: source/Target/Thread.cpp
===
--- source/Target/Thread.cpp
+++ source/Target/Thread.cpp
@@ -2060,6 +2060,7 @@
 case llvm::Triple::ppc64le:
 case llvm::Triple::systemz:
 case llvm::Triple::hexagon:
+case llvm::Triple::arc:
   m_unwind

[Lldb-commits] [PATCH] D68858: [lldb] Creates _liblldb symlink from cmake

2019-10-15 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha accepted this revision.
tatyana-krasnukha added a comment.
This revision is now accepted and ready to land.

Build and installation completed successfully! LGTM, though it would be good if 
anyone tests this with Xcode.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68858



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


[Lldb-commits] [PATCH] D68858: [lldb] Creates _liblldb symlink from cmake

2019-10-14 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha added a comment.

F10259577: D68858d.diff 

@hhb, please, take a look. Slightly changed your patch to make it work for 
Visual Studio.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68858



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


[Lldb-commits] [PATCH] D68858: [lldb] Creates _liblldb symlink from cmake

2019-10-12 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha added inline comments.



Comment at: lldb/CMakeLists.txt:228
+function(create_relative_symlink target dest_file output_dir output_name)
+  get_filename_component(dest_file ${dest_file} ABSOLUTE)
+  get_filename_component(output_dir ${output_dir} ABSOLUTE)

The problem is that for multi-configuration generators the current 
configuration cannot be evaluated at the configuring step i.e. you cannot just 
insert ${CMAKE_CFG_INTDIR} in the `dest_file` path and use it here. The 
variable should be expanded in the post-build command.



Comment at: lldb/CMakeLists.txt:244
+  else()
+set(LIBLLDB_SYMLINK_DEST 
"${liblldb_build_dir}/liblldb${CMAKE_SHARED_LIBRARY_SUFFIX}")
+  endif()

This command still produces a path without configuration name, Visual Studio 
failed to execute the post-build step.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68858



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


[Lldb-commits] [PATCH] D68719: Fix issue when building with Visual Studio

2019-10-11 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha added inline comments.



Comment at: finishSwigPythonLLDB.py:380
 
-strSrc = os.path.normcase(os.path.join(strPrefix, vstrSrcFile))
-strRelSrc = os.path.relpath(strSrc, os.path.dirname(strTarget))

tatyana-krasnukha wrote:
> hhb wrote:
> > hhb wrote:
> > > tatyana-krasnukha wrote:
> > > > This command produces an incorrect path for Visual Studio since it 
> > > > concatenates the root build directory with 'bin/liblldb.dll' bypassing 
> > > > configuration name.
> > > Hmm understood. The origin change is reverted in rG958091c209d0. So I 
> > > don't think this is relevant any more. I'll redo the change. Can you help 
> > > test that time? I don't have a visual studio...
> > Sorry rGc0da1282fc036908cc721ee74f574fbb99d5e506
> Yes, now it works well
> Can you help test that time? I don't have a visual studio...

Yes, of course!

BTW, I suppose that '--cmakeBuildConfiguration' option can fix the issue for 
XCode too. 




Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68719



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


[Lldb-commits] [PATCH] D68719: Fix issue when building with Visual Studio

2019-10-11 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha abandoned this revision.
tatyana-krasnukha added a comment.

Fixed by reverting the initial commit.




Comment at: finishSwigPythonLLDB.py:380
 
-strSrc = os.path.normcase(os.path.join(strPrefix, vstrSrcFile))
-strRelSrc = os.path.relpath(strSrc, os.path.dirname(strTarget))

hhb wrote:
> hhb wrote:
> > tatyana-krasnukha wrote:
> > > This command produces an incorrect path for Visual Studio since it 
> > > concatenates the root build directory with 'bin/liblldb.dll' bypassing 
> > > configuration name.
> > Hmm understood. The origin change is reverted in rG958091c209d0. So I don't 
> > think this is relevant any more. I'll redo the change. Can you help test 
> > that time? I don't have a visual studio...
> Sorry rGc0da1282fc036908cc721ee74f574fbb99d5e506
Yes, now it works well


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68719



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


[Lldb-commits] [PATCH] D68728: [lldb] Put site-packages into a sub dir of CMAKE_CFG_INTDIR

2019-10-10 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha added a comment.

Please see my comment D68719#1703785 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68728



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


  1   2   3   >