[Lldb-commits] [PATCH] D37651: Fix for bug 34532 - A few rough corners related to post-mortem debugging (core/minidump)

2017-09-13 Thread Leonard Mosescu via Phabricator via lldb-commits
lemo updated this revision to Diff 115068.
lemo marked an inline comment as done.
lemo added a comment.

Adding test coverage


https://reviews.llvm.org/D37651

Files:
  include/lldb/Target/Process.h
  
packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
  source/Commands/CommandObjectThread.cpp
  source/Plugins/Process/elf-core/ProcessElfCore.h
  source/Target/Process.cpp

Index: source/Target/Process.cpp
===
--- source/Target/Process.cpp
+++ source/Target/Process.cpp
@@ -1621,7 +1621,12 @@
   log->Printf("Process::Resume: -- TrySetRunning failed, not resuming.");
 return error;
   }
-  return PrivateResume();
+  Status error = PrivateResume();
+  if (!error.Success()) {
+// Undo running state change
+m_public_run_lock.SetStopped();
+  }
+  return error;
 }
 
 Status Process::ResumeSynchronous(Stream *stream) {
@@ -1650,6 +1655,9 @@
   error.SetErrorStringWithFormat(
   "process not in stopped state after synchronous resume: %s",
   StateAsCString(state));
+  } else {
+// Undo running state change
+m_public_run_lock.SetStopped();
   }
 
   // Undo the hijacking of process events...
Index: source/Plugins/Process/elf-core/ProcessElfCore.h
===
--- source/Plugins/Process/elf-core/ProcessElfCore.h
+++ source/Plugins/Process/elf-core/ProcessElfCore.h
@@ -89,6 +89,8 @@
   //--
   bool IsAlive() override;
 
+  bool WarnBeforeDetach() const override { return false; }
+
   //--
   // Process Memory
   //--
Index: source/Commands/CommandObjectThread.cpp
===
--- source/Commands/CommandObjectThread.cpp
+++ source/Commands/CommandObjectThread.cpp
@@ -94,7 +94,7 @@
 bool all_threads = false;
 if (command.GetArgumentCount() == 0) {
   Thread *thread = m_exe_ctx.GetThreadPtr();
-  if (!HandleOneThread(thread->GetID(), result))
+  if (!thread || !HandleOneThread(thread->GetID(), result))
 return false;
   return result.Succeeded();
 } else if (command.GetArgumentCount() == 1) {
@@ -775,6 +775,12 @@
   else
 error = process->Resume();
 
+  if (!error.Success()) {
+result.AppendMessage(error.AsCString());
+result.SetStatus(eReturnStatusFailed);
+return false;
+  }
+
   // There is a race condition where this thread will return up the call
   // stack to the main command handler
   // and show an (lldb) prompt before HandlePrivateEvent (from
Index: packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
===
--- packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
+++ packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
@@ -31,6 +31,34 @@
 lldb.DBG.SetSelectedPlatform(self._initial_platform)
 super(MiniDumpNewTestCase, self).tearDown()
 
+def check_state(self):
+with open(os.devnull) as devnul:
+# sanitize test output
+self.dbg.SetOutputFileHandle(devnul, False)
+self.dbg.SetErrorFileHandle(devnul, False)
+
+self.assertTrue(self.process.is_stopped)
+
+# Process.Continue
+error = self.process.Continue()
+self.assertFalse(error.Success())
+self.assertTrue(self.process.is_stopped)
+
+# Thread.StepOut
+thread = self.process.GetSelectedThread()
+thread.StepOut()
+self.assertTrue(self.process.is_stopped)
+
+# command line
+self.dbg.HandleCommand('s')
+self.assertTrue(self.process.is_stopped)
+self.dbg.HandleCommand('c')
+self.assertTrue(self.process.is_stopped)
+
+# restore file handles
+self.dbg.SetOutputFileHandle(None, False)
+self.dbg.SetErrorFileHandle(None, False)
+
 def test_process_info_in_minidump(self):
 """Test that lldb can read the process information from the Minidump."""
 # target create -c linux-x86_64.dmp
@@ -40,13 +68,15 @@
 self.assertTrue(self.process, PROCESS_IS_VALID)
 self.assertEqual(self.process.GetNumThreads(), 1)
 self.assertEqual(self.process.GetProcessID(), self._linux_x86_64_pid)
+self.check_state()
 
 def test_thread_info_in_minidump(self):
 """Test that lldb can read the thread information from the Minidump."""
 # target create -c linux-x86_64.dmp
 self.dbg.C

[Lldb-commits] [PATCH] D37651: Fix for bug 34532 - A few rough corners related to post-mortem debugging (core/minidump)

2017-09-13 Thread Jim Ingham via Phabricator via lldb-commits
jingham accepted this revision.
jingham added a comment.

This looks okay for now.  It will end up sending a Running & then a Stopped 
event.  That's a little awkward, but that happens in the ordinary course of 
debugging anyway so it shouldn't freak anybody out.

It would be better to find a place where this can be fixed before we send the 
running event, but that's going to take more thinking, and I don't see that 
desire should block this patch.  But can you file another PR to go figure out 
how to fix this closer to the source, so we don't forget to fix this next time 
we're in the bowels of the process event code?

Thanks!


https://reviews.llvm.org/D37651



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


[Lldb-commits] [PATCH] D37651: Fix for bug 34532 - A few rough corners related to post-mortem debugging (core/minidump)

2017-09-13 Thread Leonard Mosescu via Phabricator via lldb-commits
lemo added a comment.

@Jim: Good point, I created this bug to track this as you suggested:
Bug 34594 - Revisit the failure path for Process::Resume() to avoid leaking 
Stopped->Running->Stopped events


https://reviews.llvm.org/D37651



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


[Lldb-commits] [PATCH] D37651: Fix for bug 34532 - A few rough corners related to post-mortem debugging (core/minidump)

2017-09-13 Thread Adrian McCarthy via Phabricator via lldb-commits
amccarth accepted this revision.
amccarth added a comment.

LGTM.  Thanks for adding the tests.


https://reviews.llvm.org/D37651



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


[Lldb-commits] [lldb] r313181 - [unittests] Speculative fix for changes introduced in rL313156

2017-09-13 Thread Vedant Kumar via lldb-commits
Author: vedantk
Date: Wed Sep 13 13:02:24 2017
New Revision: 313181

URL: http://llvm.org/viewvc/llvm-project?rev=313181&view=rev
Log:
[unittests] Speculative fix for changes introduced in rL313156

Modified:
lldb/trunk/unittests/ObjectFile/ELF/TestObjectFileELF.cpp

Modified: lldb/trunk/unittests/ObjectFile/ELF/TestObjectFileELF.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/ObjectFile/ELF/TestObjectFileELF.cpp?rev=313181&r1=313180&r2=313181&view=diff
==
--- lldb/trunk/unittests/ObjectFile/ELF/TestObjectFileELF.cpp (original)
+++ lldb/trunk/unittests/ObjectFile/ELF/TestObjectFileELF.cpp Wed Sep 13 
13:02:24 2017
@@ -15,6 +15,7 @@
 #include "lldb/Core/Section.h"
 #include "lldb/Host/HostInfo.h"
 #include "unittests/Utility/Helpers/TestUtilities.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Program.h"
@@ -61,7 +62,8 @@ TEST_F(ObjectFileELFTest, SectionsResolv
   llvm::FileRemover remover(obj);
   const char *args[] = {YAML2OBJ, yaml.c_str(), nullptr};
   llvm::StringRef obj_ref = obj;
-  const llvm::StringRef *redirects[] = {nullptr, &obj_ref, nullptr};
+  const llvm::Optional redirects[] = {llvm::None, obj_ref,
+   llvm::None};
   ASSERT_EQ(0, llvm::sys::ExecuteAndWait(YAML2OBJ, args, nullptr, redirects));
   uint64_t size;
   ASSERT_NO_ERROR(llvm::sys::fs::file_size(obj, size));


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


[Lldb-commits] [lldb] r313183 - [unittests] Another speculative fix for changes introduced in rL313156

2017-09-13 Thread Vedant Kumar via lldb-commits
Author: vedantk
Date: Wed Sep 13 13:03:34 2017
New Revision: 313183

URL: http://llvm.org/viewvc/llvm-project?rev=313183&view=rev
Log:
[unittests] Another speculative fix for changes introduced in rL313156

Modified:
lldb/trunk/unittests/Symbol/TestDWARFCallFrameInfo.cpp

Modified: lldb/trunk/unittests/Symbol/TestDWARFCallFrameInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Symbol/TestDWARFCallFrameInfo.cpp?rev=313183&r1=313182&r2=313183&view=diff
==
--- lldb/trunk/unittests/Symbol/TestDWARFCallFrameInfo.cpp (original)
+++ lldb/trunk/unittests/Symbol/TestDWARFCallFrameInfo.cpp Wed Sep 13 13:03:34 
2017
@@ -98,7 +98,8 @@ void DWARFCallFrameInfoTest::TestBasic(D
 
   const char *args[] = {YAML2OBJ, yaml.c_str(), nullptr};
   llvm::StringRef obj_ref = obj;
-  const llvm::StringRef *redirects[] = {nullptr, &obj_ref, nullptr};
+  const llvm::Optional redirects[] = {llvm::None, obj_ref,
+   llvm::None};
   ASSERT_EQ(0, llvm::sys::ExecuteAndWait(YAML2OBJ, args, nullptr, redirects));
 
   uint64_t size;


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


[Lldb-commits] [PATCH] D37651: Fix for bug 34532 - A few rough corners related to post-mortem debugging (core/minidump)

2017-09-13 Thread Adrian McCarthy via Phabricator via lldb-commits
amccarth added a comment.

@sas:  Do the latest changes address your concerns with this patch?


https://reviews.llvm.org/D37651



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


[Lldb-commits] [PATCH] D37651: Fix for bug 34532 - A few rough corners related to post-mortem debugging (core/minidump)

2017-09-13 Thread Stephane Sezer via Phabricator via lldb-commits
sas accepted this revision.
sas added a comment.
This revision is now accepted and ready to land.

Seems fine.


https://reviews.llvm.org/D37651



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


[Lldb-commits] [PATCH] D37651: Fix for bug 34532 - A few rough corners related to post-mortem debugging (core/minidump)

2017-09-13 Thread Adrian McCarthy via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL313210: Fix for bug 34532 - A few rough corners related to 
post-mortem debugging… (authored by amccarth).

Changed prior to commit:
  https://reviews.llvm.org/D37651?vs=115068&id=115132#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37651

Files:
  lldb/trunk/include/lldb/Target/Process.h
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
  lldb/trunk/source/Commands/CommandObjectThread.cpp
  lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.h
  lldb/trunk/source/Target/Process.cpp

Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
@@ -244,13 +244,43 @@
 end_region.GetRegionBase())
 self.assertEqual(end_region.GetRegionEnd(), lldb.LLDB_INVALID_ADDRESS)
 
+def check_state(self, process):
+with open(os.devnull) as devnul:
+# sanitize test output
+self.dbg.SetOutputFileHandle(devnul, False)
+self.dbg.SetErrorFileHandle(devnul, False)
+
+self.assertTrue(process.is_stopped)
+
+# Process.Continue
+error = process.Continue()
+self.assertFalse(error.Success())
+self.assertTrue(process.is_stopped)
+
+# Thread.StepOut
+thread = process.GetSelectedThread()
+thread.StepOut()
+self.assertTrue(process.is_stopped)
+
+# command line
+self.dbg.HandleCommand('s')
+self.assertTrue(process.is_stopped)
+self.dbg.HandleCommand('c')
+self.assertTrue(process.is_stopped)
+
+# restore file handles
+self.dbg.SetOutputFileHandle(None, False)
+self.dbg.SetErrorFileHandle(None, False)
+
 def do_test(self, filename, pid, region_count):
 target = self.dbg.CreateTarget(filename + ".out")
 process = target.LoadCore(filename + ".core")
 self.assertTrue(process, PROCESS_IS_VALID)
 self.assertEqual(process.GetNumThreads(), 1)
 self.assertEqual(process.GetProcessID(), pid)
 
+self.check_state(process)
+
 thread = process.GetSelectedThread()
 self.assertTrue(thread)
 self.assertEqual(thread.GetThreadID(), pid)
Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
@@ -31,6 +31,34 @@
 lldb.DBG.SetSelectedPlatform(self._initial_platform)
 super(MiniDumpNewTestCase, self).tearDown()
 
+def check_state(self):
+with open(os.devnull) as devnul:
+# sanitize test output
+self.dbg.SetOutputFileHandle(devnul, False)
+self.dbg.SetErrorFileHandle(devnul, False)
+
+self.assertTrue(self.process.is_stopped)
+
+# Process.Continue
+error = self.process.Continue()
+self.assertFalse(error.Success())
+self.assertTrue(self.process.is_stopped)
+
+# Thread.StepOut
+thread = self.process.GetSelectedThread()
+thread.StepOut()
+self.assertTrue(self.process.is_stopped)
+
+# command line
+self.dbg.HandleCommand('s')
+self.assertTrue(self.process.is_stopped)
+self.dbg.HandleCommand('c')
+self.assertTrue(self.process.is_stopped)
+
+# restore file handles
+self.dbg.SetOutputFileHandle(None, False)
+self.dbg.SetErrorFileHandle(None, False)
+
 def test_process_info_in_minidump(self):
 """Test that lldb can read the process information from the Minidump."""
 # target create -c linux-x86_64.dmp
@@ -40,13 +68,15 @@
 self.assertTrue(self.process, PROCESS_IS_VALID)
 self.assertEqual(self.process.GetNumThreads(), 1)
 self.assertEqual(self.process.GetProcessID(), self._linux_x86_64_pid)
+self.check_state()
 
 def test_thread_info_in_minidump(self):
 """Test that lldb can read the thread information from the Minidump."""
 # target create -c linux-x86_64.dmp
 self.dbg.CreateTarget(None)
 self.target = self.dbg.GetSelectedTarget()
 self.process = self.target.LoadCore("linux-x86_64.dmp")
+s

[Lldb-commits] [lldb] r313210 - Fix for bug 34532 - A few rough corners related to post-mortem debugging (core/minidump)

2017-09-13 Thread Adrian McCarthy via lldb-commits
Author: amccarth
Date: Wed Sep 13 15:57:11 2017
New Revision: 313210

URL: http://llvm.org/viewvc/llvm-project?rev=313210&view=rev
Log:
Fix for bug 34532 - A few rough corners related to post-mortem debugging 
(core/minidump)

The main change is to avoid setting the process state as running when
debugging core/minidumps (details in the bug).

Also included a few small, related fixes around how the errors propagate in
this case.

patch by lemo

Bug: https://bugs.llvm.org/show_bug.cgi?id=34532

Differential Revision: https://reviews.llvm.org/D37651

Modified:
lldb/trunk/include/lldb/Target/Process.h

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
lldb/trunk/source/Commands/CommandObjectThread.cpp
lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.h
lldb/trunk/source/Target/Process.cpp

Modified: lldb/trunk/include/lldb/Target/Process.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=313210&r1=313209&r2=313210&view=diff
==
--- lldb/trunk/include/lldb/Target/Process.h (original)
+++ lldb/trunk/include/lldb/Target/Process.h Wed Sep 13 15:57:11 2017
@@ -1248,7 +1248,13 @@ public:
   /// @return
   /// Returns an error object.
   //--
-  virtual Status WillResume() { return Status(); }
+  virtual Status WillResume() {
+Status error;
+error.SetErrorStringWithFormat(
+"error: %s does not support resuming processes",
+GetPluginName().GetCString());
+return error;
+  }
 
   //--
   /// Resumes all of a process's threads as configured using the

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py?rev=313210&r1=313209&r2=313210&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
 Wed Sep 13 15:57:11 2017
@@ -244,6 +244,34 @@ class LinuxCoreTestCase(TestBase):
 end_region.GetRegionBase())
 self.assertEqual(end_region.GetRegionEnd(), lldb.LLDB_INVALID_ADDRESS)
 
+def check_state(self, process):
+with open(os.devnull) as devnul:
+# sanitize test output
+self.dbg.SetOutputFileHandle(devnul, False)
+self.dbg.SetErrorFileHandle(devnul, False)
+
+self.assertTrue(process.is_stopped)
+
+# Process.Continue
+error = process.Continue()
+self.assertFalse(error.Success())
+self.assertTrue(process.is_stopped)
+
+# Thread.StepOut
+thread = process.GetSelectedThread()
+thread.StepOut()
+self.assertTrue(process.is_stopped)
+
+# command line
+self.dbg.HandleCommand('s')
+self.assertTrue(process.is_stopped)
+self.dbg.HandleCommand('c')
+self.assertTrue(process.is_stopped)
+
+# restore file handles
+self.dbg.SetOutputFileHandle(None, False)
+self.dbg.SetErrorFileHandle(None, False)
+
 def do_test(self, filename, pid, region_count):
 target = self.dbg.CreateTarget(filename + ".out")
 process = target.LoadCore(filename + ".core")
@@ -251,6 +279,8 @@ class LinuxCoreTestCase(TestBase):
 self.assertEqual(process.GetNumThreads(), 1)
 self.assertEqual(process.GetProcessID(), pid)
 
+self.check_state(process)
+
 thread = process.GetSelectedThread()
 self.assertTrue(thread)
 self.assertEqual(thread.GetThreadID(), pid)

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py?rev=313210&r1=313209&r2=313210&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
 Wed Sep 13 15:57:11 2017
@@ -31,6 +31,34 @@ class MiniDumpNewTestCase(TestBase):
 lldb.DBG.SetSelectedPlatform(self._initial_platform)
 super(MiniDumpNewTestCase, self).tearDown()
 
+def check_state(self):
+  

[Lldb-commits] [lldb] r313216 - Forgot to svn add the test cases for breakpoint auto-continue flag.

2017-09-13 Thread Jim Ingham via lldb-commits
Author: jingham
Date: Wed Sep 13 16:43:26 2017
New Revision: 313216

URL: http://llvm.org/viewvc/llvm-project?rev=313216&view=rev
Log:
Forgot to svn add the test cases for breakpoint auto-continue flag.
Adding that now.

Added:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/auto_continue/

lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/auto_continue/Makefile

lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/auto_continue/TestBreakpointAutoContinue.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/auto_continue/main.c

Added: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/auto_continue/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/auto_continue/Makefile?rev=313216&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/auto_continue/Makefile
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/auto_continue/Makefile
 Wed Sep 13 16:43:26 2017
@@ -0,0 +1,6 @@
+LEVEL = ../../../make
+
+C_SOURCES := main.c
+CFLAGS_EXTRAS += -std=c99
+
+include $(LEVEL)/Makefile.rules

Added: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/auto_continue/TestBreakpointAutoContinue.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/auto_continue/TestBreakpointAutoContinue.py?rev=313216&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/auto_continue/TestBreakpointAutoContinue.py
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/auto_continue/TestBreakpointAutoContinue.py
 Wed Sep 13 16:43:26 2017
@@ -0,0 +1,104 @@
+"""
+Test that the breakpoint auto-continue flag works correctly.
+"""
+
+from __future__ import print_function
+
+
+import os
+import time
+import re
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+
+
+class BreakpointAutoContinue(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+NO_DEBUG_INFO_TESTCASE = True
+
+def test_breakpoint_auto_continue(self):
+"""Make sure the auto continue continues with no other complications"""
+self.build()
+self.simple_auto_continue()
+
+def test_auto_continue_with_command(self):
+"""Add a command, make sure the command gets run"""
+self.build()
+self.auto_continue_with_command()
+
+def test_auto_continue_on_location(self):
+"""Set auto-continue on a location and make sure only that location 
continues"""
+self.build()
+self.auto_continue_location()
+
+def make_target_and_bkpt(self, additional_options=None, 
num_expected_loc=1, 
+ pattern="Set a breakpoint here"):
+exe = os.path.join(os.getcwd(), "a.out")
+self.target = self.dbg.CreateTarget(exe)
+self.assertTrue(self.target.IsValid(), "Target is not valid")
+
+extra_options_txt = "--auto-continue 1 "
+if additional_options:
+extra_options_txt += additional_options
+bpno = lldbutil.run_break_set_by_source_regexp(self, pattern, 
+extra_options = extra_options_txt, 
+num_expected_locations = 
num_expected_loc)
+return bpno
+
+def launch_it (self, expected_state):
+error = lldb.SBError()
+launch_info = lldb.SBLaunchInfo(None)
+launch_info.SetWorkingDirectory(self.get_process_working_directory())
+
+process = self.target.Launch(launch_info, error)
+self.assertTrue(error.Success(), "Launch failed.")
+
+state = process.GetState()
+self.assertEqual(state, expected_state, "Didn't get expected state")
+
+return process
+
+def setUp(self):
+# Call super's setUp().
+TestBase.setUp(self)
+
+def simple_auto_continue(self):
+bpno = self.make_target_and_bkpt()
+process = self.launch_it(lldb.eStateExited)
+
+bkpt = self.target.FindBreakpointByID(bpno)
+self.assertEqual(bkpt.GetHitCount(), 2, "Should have run through the 
breakpoint twice")
+
+def auto_continue_with_command(self):
+bpno = self.make_target_and_bkpt("-N BKPT -C 'break modify 
--auto-continue 0 BKPT'")
+process = self.launch_it(lldb.eStateStopped)
+state = process.GetState()
+self.assertEqual(state, lldb.eStateStopped, "Process should be 
stopped")
+bkpt = self.target.FindBreakpointByID(bpno)
+threads = lldbutil.get_threads_stopped_at_breakpoint(process, bkpt)
+self.assertEqual(len(threads), 1, "There was a thread 

[Lldb-commits] [lldb] r313221 - Commands are -d to break modify, not -C.

2017-09-13 Thread Jim Ingham via lldb-commits
Author: jingham
Date: Wed Sep 13 17:27:36 2017
New Revision: 313221

URL: http://llvm.org/viewvc/llvm-project?rev=313221&view=rev
Log:
Commands are -d to break modify, not -C.

The auto-continue test was using the new (better) name
for providing commands (-C) but I haven't checked in that change
yet.  Put the test back to the old way for now.

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/auto_continue/TestBreakpointAutoContinue.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/auto_continue/TestBreakpointAutoContinue.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/auto_continue/TestBreakpointAutoContinue.py?rev=313221&r1=313220&r2=313221&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/auto_continue/TestBreakpointAutoContinue.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/auto_continue/TestBreakpointAutoContinue.py
 Wed Sep 13 17:27:36 2017
@@ -73,7 +73,7 @@ class BreakpointAutoContinue(TestBase):
 self.assertEqual(bkpt.GetHitCount(), 2, "Should have run through the 
breakpoint twice")
 
 def auto_continue_with_command(self):
-bpno = self.make_target_and_bkpt("-N BKPT -C 'break modify 
--auto-continue 0 BKPT'")
+bpno = self.make_target_and_bkpt("-N BKPT -d 'break modify 
--auto-continue 0 BKPT'")
 process = self.launch_it(lldb.eStateStopped)
 state = process.GetState()
 self.assertEqual(state, lldb.eStateStopped, "Process should be 
stopped")


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