File tree Expand file tree Collapse file tree 12 files changed +100
-4
lines changed
packages/Python/lldbsuite/test
functionalities/reproducers/attach Expand file tree Collapse file tree 12 files changed +100
-4
lines changed Original file line number Diff line number Diff line change 4747#include " lldb/API/SBProcessInfo.h"
4848#include " lldb/API/SBQueue.h"
4949#include " lldb/API/SBQueueItem.h"
50+ #include " lldb/API/SBReproducer.h"
5051#include " lldb/API/SBSection.h"
5152#include " lldb/API/SBSourceManager.h"
5253#include " lldb/API/SBStream.h"
Original file line number Diff line number Diff line change 1+ // ===-- SWIG Interface for SBReproducer--------------------------*- C++ -*-===//
2+ //
3+ // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+ // See https://llvm.org/LICENSE.txt for license information.
5+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+ //
7+ // ===----------------------------------------------------------------------===//
8+
9+ namespace lldb {
10+ class SBReproducer
11+ {
12+ public:
13+ static const char *Capture (const char *path);
14+ static const char *PassiveReplay (const char *path);
15+ static bool SetAutoGenerate (bool b);
16+ };
17+ }
Original file line number Diff line number Diff line change 5454%include " ./interface/SBProcessInfo.i"
5555%include " ./interface/SBQueue.i"
5656%include " ./interface/SBQueueItem.i"
57+ %include " ./interface/SBReproducer.i"
5758%include " ./interface/SBSection.i"
5859%include " ./interface/SBSourceManager.i"
5960%include " ./interface/SBStream.i"
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ class LLDB_API SBReproducer {
2222 static const char *Capture (const char *path);
2323 static const char *Replay (const char *path);
2424 static const char *Replay (const char *path, bool skip_version_check);
25+ static const char *PassiveReplay (const char *path);
2526 static const char *GetPath ();
2627 static bool SetAutoGenerate (bool b);
2728 static bool Generate ();
Original file line number Diff line number Diff line change 8787
8888# Set this flag if there is any session info dumped during the test run.
8989sdir_has_content = False
90-
9190# svn_info stores the output from 'svn info lldb.base.dir'.
9291svn_info = ''
9392
124123results_formatter_options = None
125124test_result = None
126125
126+ # Reproducers
127+ capture_path = None
128+ replay_path = None
129+
127130# Test rerun configuration vars
128131rerun_all_issues = False
129132
Original file line number Diff line number Diff line change @@ -854,3 +854,11 @@ def is_asan():
854854 return "ASAN unsupported"
855855 return None
856856 return skipTestIfFn (is_asan )(func )
857+
858+ def skipIfReproducer (func ):
859+ """Skip this test if the environment is set up to run LLDB with reproducers."""
860+ def is_reproducer ():
861+ if configuration .capture_path or configuration .replay_path :
862+ return "reproducers unsupported"
863+ return None
864+ return skipTestIfFn (is_reproducer )(func )
Original file line number Diff line number Diff line change @@ -429,6 +429,17 @@ def parseOptionsAndInitTestdirs():
429429 configuration .results_formatter_name = (
430430 "lldbsuite.test_event.formatter.results_formatter.ResultsFormatter" )
431431
432+ # Reproducer arguments
433+ if args .capture_path and args .replay_path :
434+ logging .error ('Cannot specify both a capture and a replay path.' )
435+ sys .exit (- 1 )
436+
437+ if args .capture_path :
438+ configuration .capture_path = args .capture_path
439+
440+ if args .replay_path :
441+ configuration .replay_path = args .replay_path
442+
432443 # rerun-related arguments
433444 configuration .rerun_all_issues = args .rerun_all_issues
434445
@@ -955,8 +966,19 @@ def run_suite():
955966 setupSysPath ()
956967
957968 import lldbconfig
969+ if configuration .capture_path or configuration .replay_path :
970+ lldbconfig .INITIALIZE = False
958971 import lldb
959972
973+ if configuration .capture_path :
974+ lldb .SBReproducer .Capture (configuration .capture_path )
975+ lldb .SBReproducer .SetAutoGenerate (True )
976+ elif configuration .replay_path :
977+ lldb .SBReproducer .PassiveReplay (configuration .replay_path )
978+
979+ if not lldbconfig .INITIALIZE :
980+ lldb .SBDebugger .Initialize ()
981+
960982 # Use host platform by default.
961983 lldb .selected_platform = lldb .SBPlatform .GetHostPlatform ()
962984
Original file line number Diff line number Diff line change @@ -196,6 +196,17 @@ def create_parser():
196196 metavar = 'platform-working-dir' ,
197197 help = 'The directory to use on the remote platform.' )
198198
199+ # Reproducer options
200+ group = parser .add_argument_group ('Reproducer options' )
201+ group .add_argument (
202+ '--capture-path' ,
203+ metavar = 'reproducer path' ,
204+ help = 'The reproducer capture path' )
205+ group .add_argument (
206+ '--replay-path' ,
207+ metavar = 'reproducer path' ,
208+ help = 'The reproducer replay path' )
209+
199210 # Test-suite behaviour
200211 group = parser .add_argument_group ('Runtime behaviour options' )
201212 X ('-d' , 'Suspend the process after launch to wait indefinitely for a debugger to attach' )
Original file line number Diff line number Diff line change @@ -124,6 +124,15 @@ const char *SBReproducer::Capture(const char *path) {
124124 return nullptr ;
125125}
126126
127+ const char *SBReproducer::PassiveReplay (const char *path) {
128+ static std::string error;
129+ if (auto e = Reproducer::Initialize (ReproducerMode::Replay, FileSpec (path))) {
130+ error = llvm::toString (std::move (e));
131+ return error.c_str ();
132+ }
133+ return nullptr ;
134+ }
135+
127136const char *SBReproducer::Replay (const char *path) {
128137 return SBReproducer::Replay (path, false );
129138}
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ class ReproducerAttachTestCase(TestBase):
2020 @skipIfWindows
2121 @skipIfRemote
2222 @skipIfiOSSimulator
23+ @skipIfReproducer
2324 def test_reproducer_attach (self ):
2425 """Test thread creation after process attach."""
2526 exe = '%s_%d' % (self .testMethodName , os .getpid ())
You can’t perform that action at this time.
0 commit comments