Index: lldb/packages/Python/lldbsuite/test/lldbtest.py =================================================================== --- lldb/packages/Python/lldbsuite/test/lldbtest.py +++ lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -2455,6 +2455,27 @@ err = platform.Run(shell_command) return (err, shell_command.GetStatus(), shell_command.GetOutput()) + def set_setting(self, name, value, value_to_restore = None): + # Set setting's value. + self.runCmd("settings set %s %s" % (name, value)) + + # Clear setting or restore old value if provided. + def cleanup(): + if value_to_restore: + command = "settings set %s %s" % (name, value_to_restore) + else: + command = "settings clear %s" % (name) + + self.runCmd(command, check=False) + + self.addTearDownHook(cleanup) + + def append_setting(self, name, key, value): + self.runCmd("settings append %s %s=%s" % (name, key, value)) + self.addTearDownHook( + lambda: self.runCmd( + "settings remove %s %s" % (name, key))) + # ================================================= # Misc. helper methods for debugging test execution # ================================================= Index: lldb/test/API/api/check_public_api_headers/TestPublicAPIHeaders.py =================================================================== --- lldb/test/API/api/check_public_api_headers/TestPublicAPIHeaders.py +++ lldb/test/API/api/check_public_api_headers/TestPublicAPIHeaders.py @@ -46,15 +46,11 @@ self.line_to_break = line_number( self.getBuildArtifact(self.source), '// Set breakpoint here.') - env_cmd = "settings set target.env-vars %s=%s" % ( - self.dylibPath, self.getLLDBLibraryEnvVal()) if self.TraceOn(): - print("Set environment to: ", env_cmd) - self.runCmd(env_cmd) - self.addTearDownHook( - lambda: self.dbg.HandleCommand( - "settings remove target.env-vars %s" % - self.dylibPath)) + print("Set environment to: %s = %s", + self.dylibPath, self.getLLDBLibraryEnvVal()) + self.append_setting("target.env-vars", + self.dylibPath, self.getLLDBLibraryEnvVal()) lldbutil.run_break_set_by_file_and_line( self, self.source, self.line_to_break, num_expected_locations=-1) Index: lldb/test/API/benchmarks/continue/TestBenchmarkContinue.py =================================================================== --- lldb/test/API/benchmarks/continue/TestBenchmarkContinue.py +++ lldb/test/API/benchmarks/continue/TestBenchmarkContinue.py @@ -49,9 +49,6 @@ self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd( - "settings set target.max-children-count 256", - check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) Index: lldb/test/API/benchmarks/libcxxlist/TestBenchmarkLibcxxList.py =================================================================== --- lldb/test/API/benchmarks/libcxxlist/TestBenchmarkLibcxxList.py +++ lldb/test/API/benchmarks/libcxxlist/TestBenchmarkLibcxxList.py @@ -49,9 +49,6 @@ self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd( - "settings set target.max-children-count 256", - check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) Index: lldb/test/API/benchmarks/libcxxmap/TestBenchmarkLibcxxMap.py =================================================================== --- lldb/test/API/benchmarks/libcxxmap/TestBenchmarkLibcxxMap.py +++ lldb/test/API/benchmarks/libcxxmap/TestBenchmarkLibcxxMap.py @@ -49,9 +49,6 @@ self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd( - "settings set target.max-children-count 256", - check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) Index: lldb/test/API/commands/expression/import-std-module/basic/TestImportStdModule.py =================================================================== --- lldb/test/API/commands/expression/import-std-module/basic/TestImportStdModule.py +++ lldb/test/API/commands/expression/import-std-module/basic/TestImportStdModule.py @@ -20,7 +20,7 @@ "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) # Activate importing of std module. - self.runCmd("settings set target.import-std-module true") + self.set_setting("target.import-std-module", "true") # Calling some normal std functions that return non-template types. self.expect_expr("std::abs(-42)", result_type="int", result_value="42") self.expect_expr("std::div(2, 1).quot", result_type="int", result_value="2") @@ -39,7 +39,7 @@ "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) # Activate importing of std module. - self.runCmd("settings set target.import-std-module true") + self.set_setting("target.import-std-module", "true") # These languages don't support C++ modules, so they shouldn't # be able to evaluate the expression. self.expect("expr -l C -- std::abs(-42)", error=True) Index: lldb/test/API/commands/expression/import-std-module/conflicts/TestStdModuleWithConflicts.py =================================================================== --- lldb/test/API/commands/expression/import-std-module/conflicts/TestStdModuleWithConflicts.py +++ lldb/test/API/commands/expression/import-std-module/conflicts/TestStdModuleWithConflicts.py @@ -24,7 +24,7 @@ lldbutil.run_to_source_breakpoint(self, "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) - self.runCmd("settings set target.import-std-module true") + self.set_setting("target.import-std-module", "true") self.expect_expr("std::abs(-42)", result_type="int", result_value="42") self.expect_expr("std::div(2, 1).quot", result_type="int", result_value="2") self.expect_expr("(std::size_t)33U", result_type="std::size_t", result_value="33") Index: lldb/test/API/commands/expression/import-std-module/deque-basic/TestDequeFromStdModule.py =================================================================== --- lldb/test/API/commands/expression/import-std-module/deque-basic/TestDequeFromStdModule.py +++ lldb/test/API/commands/expression/import-std-module/deque-basic/TestDequeFromStdModule.py @@ -18,7 +18,7 @@ lldbutil.run_to_source_breakpoint(self, "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) - self.runCmd("settings set target.import-std-module true") + self.set_setting("target.import-std-module", "true") self.expect_expr("(size_t)a.size()", result_type="size_t", result_value="3") self.expect_expr("(int)a.front()", result_type="int", result_value="3") Index: lldb/test/API/commands/expression/import-std-module/deque-dbg-info-content/TestDbgInfoContentDequeFromStdModule.py =================================================================== --- lldb/test/API/commands/expression/import-std-module/deque-dbg-info-content/TestDbgInfoContentDequeFromStdModule.py +++ lldb/test/API/commands/expression/import-std-module/deque-dbg-info-content/TestDbgInfoContentDequeFromStdModule.py @@ -18,7 +18,7 @@ lldbutil.run_to_source_breakpoint(self, "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) - self.runCmd("settings set target.import-std-module true") + self.set_setting("target.import-std-module", "true") self.expect("expr (size_t)a.size()", substrs=['(size_t) $0 = 3']) self.expect("expr (int)a.front().a", substrs=['(int) $1 = 3']) Index: lldb/test/API/commands/expression/import-std-module/empty-module/TestEmptyStdModule.py =================================================================== --- lldb/test/API/commands/expression/import-std-module/empty-module/TestEmptyStdModule.py +++ lldb/test/API/commands/expression/import-std-module/empty-module/TestEmptyStdModule.py @@ -27,7 +27,7 @@ lldbutil.run_to_source_breakpoint(self, "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) - self.runCmd("settings set target.import-std-module true") + self.set_setting("target.import-std-module", "true") # Use the typedef that is only defined in our 'empty' module. If this fails, then LLDB # somehow figured out the correct define for the header and compiled the right Index: 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-dbg-info-content/TestDbgInfoContentForwardListFromStdModule.py +++ lldb/test/API/commands/expression/import-std-module/forward_list-dbg-info-content/TestDbgInfoContentForwardListFromStdModule.py @@ -18,7 +18,7 @@ lldbutil.run_to_source_breakpoint(self, "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) - self.runCmd("settings set target.import-std-module true") + self.set_setting("target.import-std-module", "true") self.expect("expr (size_t)std::distance(a.begin(), a.end())", substrs=['(size_t) $0 = 3']) self.expect("expr (int)a.front().a", substrs=['(int) $1 = 3']) Index: lldb/test/API/commands/expression/import-std-module/forward_list/TestForwardListFromStdModule.py =================================================================== --- lldb/test/API/commands/expression/import-std-module/forward_list/TestForwardListFromStdModule.py +++ lldb/test/API/commands/expression/import-std-module/forward_list/TestForwardListFromStdModule.py @@ -18,7 +18,7 @@ lldbutil.run_to_source_breakpoint(self, "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) - self.runCmd("settings set target.import-std-module true") + self.set_setting("target.import-std-module", "true") self.expect("expr (size_t)std::distance(a.begin(), a.end())", substrs=['(size_t) $0 = 3']) self.expect("expr (int)a.front()", substrs=['(int) $1 = 3']) Index: lldb/test/API/commands/expression/import-std-module/list-dbg-info-content/TestDbgInfoContentListFromStdModule.py =================================================================== --- lldb/test/API/commands/expression/import-std-module/list-dbg-info-content/TestDbgInfoContentListFromStdModule.py +++ lldb/test/API/commands/expression/import-std-module/list-dbg-info-content/TestDbgInfoContentListFromStdModule.py @@ -19,7 +19,7 @@ lldbutil.run_to_source_breakpoint(self, "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) - self.runCmd("settings set target.import-std-module true") + self.set_setting("target.import-std-module", "true") self.expect("expr (size_t)a.size()", substrs=['(size_t) $0 = 3']) self.expect("expr (int)a.front().a", substrs=['(int) $1 = 3']) Index: lldb/test/API/commands/expression/import-std-module/list/TestListFromStdModule.py =================================================================== --- lldb/test/API/commands/expression/import-std-module/list/TestListFromStdModule.py +++ lldb/test/API/commands/expression/import-std-module/list/TestListFromStdModule.py @@ -18,7 +18,7 @@ lldbutil.run_to_source_breakpoint(self, "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) - self.runCmd("settings set target.import-std-module true") + self.set_setting("target.import-std-module", "true") self.expect("expr (size_t)a.size()", substrs=['(size_t) $0 = 3']) self.expect("expr (int)a.front()", substrs=['(int) $1 = 3']) Index: lldb/test/API/commands/expression/import-std-module/no-std-module/TestMissingStdModule.py =================================================================== --- lldb/test/API/commands/expression/import-std-module/no-std-module/TestMissingStdModule.py +++ lldb/test/API/commands/expression/import-std-module/no-std-module/TestMissingStdModule.py @@ -26,7 +26,7 @@ "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) # Activate importing of std module. - self.runCmd("settings set target.import-std-module true") + self.set_setting("target.import-std-module", "true") # Run some commands that should all fail without our std module. self.expect("expr std::abs(-42)", error=True) Index: lldb/test/API/commands/expression/import-std-module/queue/TestQueueFromStdModule.py =================================================================== --- lldb/test/API/commands/expression/import-std-module/queue/TestQueueFromStdModule.py +++ lldb/test/API/commands/expression/import-std-module/queue/TestQueueFromStdModule.py @@ -18,7 +18,7 @@ lldbutil.run_to_source_breakpoint(self, "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) - self.runCmd("settings set target.import-std-module true") + self.set_setting("target.import-std-module", "true") # Test std::queue functionality with a std::deque. self.expect("expr q_deque.pop()") Index: 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-dbg-info-content/TestSharedPtrDbgInfoContentFromStdModule.py +++ lldb/test/API/commands/expression/import-std-module/shared_ptr-dbg-info-content/TestSharedPtrDbgInfoContentFromStdModule.py @@ -18,7 +18,7 @@ lldbutil.run_to_source_breakpoint(self, "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) - self.runCmd("settings set target.import-std-module true") + self.set_setting("target.import-std-module", "true") self.expect("expr (int)s->a", substrs=['(int) $0 = 3']) self.expect("expr (int)(s->a = 5)", substrs=['(int) $1 = 5']) Index: lldb/test/API/commands/expression/import-std-module/shared_ptr/TestSharedPtrFromStdModule.py =================================================================== --- lldb/test/API/commands/expression/import-std-module/shared_ptr/TestSharedPtrFromStdModule.py +++ lldb/test/API/commands/expression/import-std-module/shared_ptr/TestSharedPtrFromStdModule.py @@ -18,7 +18,7 @@ lldbutil.run_to_source_breakpoint(self, "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) - self.runCmd("settings set target.import-std-module true") + self.set_setting("target.import-std-module", "true") self.expect("expr (int)*s", substrs=['(int) $0 = 3']) self.expect("expr (int)(*s = 5)", substrs=['(int) $1 = 5']) Index: lldb/test/API/commands/expression/import-std-module/stack/TestStackFromStdModule.py =================================================================== --- lldb/test/API/commands/expression/import-std-module/stack/TestStackFromStdModule.py +++ lldb/test/API/commands/expression/import-std-module/stack/TestStackFromStdModule.py @@ -18,7 +18,7 @@ lldbutil.run_to_source_breakpoint(self, "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) - self.runCmd("settings set target.import-std-module true") + self.set_setting("target.import-std-module", "true") # Test std::stack functionality with a std::deque. self.expect("expr s_deque.pop()") Index: lldb/test/API/commands/expression/import-std-module/sysroot/TestStdModuleSysroot.py =================================================================== --- lldb/test/API/commands/expression/import-std-module/sysroot/TestStdModuleSysroot.py +++ lldb/test/API/commands/expression/import-std-module/sysroot/TestStdModuleSysroot.py @@ -28,7 +28,7 @@ lldbutil.run_to_source_breakpoint(self, "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) - self.runCmd("settings set target.import-std-module true") + self.set_setting("target.import-std-module", "true") # Call our custom function in our sysroot std module. # If this gives us the correct result, then we used the sysroot. Index: 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-dbg-info-content/TestUniquePtrDbgInfoContent.py +++ lldb/test/API/commands/expression/import-std-module/unique_ptr-dbg-info-content/TestUniquePtrDbgInfoContent.py @@ -18,7 +18,7 @@ lldbutil.run_to_source_breakpoint(self, "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) - self.runCmd("settings set target.import-std-module true") + self.set_setting("target.import-std-module", "true") self.expect("expr (int)s->a", substrs=['(int) $0 = 3']) self.expect("expr (int)(s->a = 5)", substrs=['(int) $1 = 5']) Index: lldb/test/API/commands/expression/import-std-module/unique_ptr/TestUniquePtrFromStdModule.py =================================================================== --- lldb/test/API/commands/expression/import-std-module/unique_ptr/TestUniquePtrFromStdModule.py +++ lldb/test/API/commands/expression/import-std-module/unique_ptr/TestUniquePtrFromStdModule.py @@ -18,7 +18,7 @@ lldbutil.run_to_source_breakpoint(self, "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) - self.runCmd("settings set target.import-std-module true") + self.set_setting("target.import-std-module", "true") self.expect("expr (int)*s", substrs=['(int) $0 = 3']) self.expect("expr (int)(*s = 5)", substrs=['(int) $1 = 5']) Index: lldb/test/API/commands/expression/import-std-module/vector-bool/TestVectorBoolFromStdModule.py =================================================================== --- lldb/test/API/commands/expression/import-std-module/vector-bool/TestVectorBoolFromStdModule.py +++ lldb/test/API/commands/expression/import-std-module/vector-bool/TestVectorBoolFromStdModule.py @@ -18,7 +18,7 @@ lldbutil.run_to_source_breakpoint(self, "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) - self.runCmd("settings set target.import-std-module true") + self.set_setting("target.import-std-module", "true") self.expect("expr (size_t)a.size()", substrs=['(size_t) $0 = 4']) self.expect("expr (bool)a.front()", substrs=['(bool) $1 = false']) Index: lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py =================================================================== --- lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py +++ lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py @@ -19,7 +19,7 @@ lldbutil.run_to_source_breakpoint(self, "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) - self.runCmd("settings set target.import-std-module true") + self.set_setting("target.import-std-module", "true") self.expect("expr (size_t)a.size()", substrs=['(size_t) $0 = 3']) self.expect("expr (int)a.front().a", substrs=['(int) $1 = 3']) Index: lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py =================================================================== --- lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py +++ lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py @@ -18,7 +18,7 @@ lldbutil.run_to_source_breakpoint(self, "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) - self.runCmd("settings set target.import-std-module true") + self.set_setting("target.import-std-module", "true") self.expect("expr (size_t)a.size()", substrs=['(size_t) $0 = 2']) self.expect("expr (int)a.front().front()", substrs=['(int) $1 = 1']) Index: lldb/test/API/commands/expression/import-std-module/vector/TestVectorFromStdModule.py =================================================================== --- lldb/test/API/commands/expression/import-std-module/vector/TestVectorFromStdModule.py +++ lldb/test/API/commands/expression/import-std-module/vector/TestVectorFromStdModule.py @@ -18,7 +18,7 @@ lldbutil.run_to_source_breakpoint(self, "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) - self.runCmd("settings set target.import-std-module true") + self.set_setting("target.import-std-module", "true") self.expect("expr (size_t)a.size()", substrs=['(size_t) $0 = 3']) self.expect("expr (int)a.front()", substrs=['(int) $1 = 3']) Index: 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-dbg-info-content/TestDbgInfoContentWeakPtrFromStdModule.py +++ lldb/test/API/commands/expression/import-std-module/weak_ptr-dbg-info-content/TestDbgInfoContentWeakPtrFromStdModule.py @@ -18,7 +18,7 @@ lldbutil.run_to_source_breakpoint(self, "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) - self.runCmd("settings set target.import-std-module true") + self.set_setting("target.import-std-module", "true") self.expect("expr (int)w.lock()->a", substrs=['(int) $0 = 3']) self.expect("expr (int)(w.lock()->a = 5)", substrs=['(int) $1 = 5']) Index: lldb/test/API/commands/expression/import-std-module/weak_ptr/TestWeakPtrFromStdModule.py =================================================================== --- lldb/test/API/commands/expression/import-std-module/weak_ptr/TestWeakPtrFromStdModule.py +++ lldb/test/API/commands/expression/import-std-module/weak_ptr/TestWeakPtrFromStdModule.py @@ -18,7 +18,7 @@ lldbutil.run_to_source_breakpoint(self, "// Set break point at this line.", lldb.SBFileSpec("main.cpp")) - self.runCmd("settings set target.import-std-module true") + self.set_setting("target.import-std-module", "true") self.expect("expr (int)*w.lock()", substrs=['(int) $0 = 3']) self.expect("expr (int)(*w.lock() = 5)", substrs=['(int) $1 = 5']) Index: lldb/test/API/commands/expression/ir-interpreter/TestIRInterpreter.py =================================================================== --- lldb/test/API/commands/expression/ir-interpreter/TestIRInterpreter.py +++ lldb/test/API/commands/expression/ir-interpreter/TestIRInterpreter.py @@ -24,9 +24,7 @@ '// Set breakpoint here') # Disable confirmation prompt to avoid infinite wait - self.runCmd("settings set auto-confirm true") - self.addTearDownHook( - lambda: self.runCmd("settings clear auto-confirm")) + self.set_setting("auto-confirm", "true") def build_and_run(self): """Test the IR interpreter""" Index: lldb/test/API/commands/expression/save_jit_objects/TestSaveJITObjects.py =================================================================== --- lldb/test/API/commands/expression/save_jit_objects/TestSaveJITObjects.py +++ lldb/test/API/commands/expression/save_jit_objects/TestSaveJITObjects.py @@ -41,7 +41,7 @@ self.assertEquals(self.countJITFiles(), 0, "No files emitted with save-jit-objects=false") - self.runCmd("settings set target.save-jit-objects true") + self.set_setting("target.save-jit-objects", "true") frame.EvaluateExpression("(void*)malloc(0x1)") jit_files_count = self.countJITFiles() self.cleanJITFiles() Index: lldb/test/API/commands/expression/test/TestExprs.py =================================================================== --- lldb/test/API/commands/expression/test/TestExprs.py +++ lldb/test/API/commands/expression/test/TestExprs.py @@ -34,9 +34,7 @@ '// Please test many expressions while stopped at this line:') # Disable confirmation prompt to avoid infinite wait - self.runCmd("settings set auto-confirm true") - self.addTearDownHook( - lambda: self.runCmd("settings clear auto-confirm")) + self.set_setting("auto-confirm", "true") def build_and_run(self): """These basic expression commands should work as expected.""" Index: lldb/test/API/commands/expression/top-level/TestTopLevelExprs.py =================================================================== --- lldb/test/API/commands/expression/top-level/TestTopLevelExprs.py +++ lldb/test/API/commands/expression/top-level/TestTopLevelExprs.py @@ -26,9 +26,7 @@ '// Set breakpoint here') # Disable confirmation prompt to avoid infinite wait - self.runCmd("settings set auto-confirm true") - self.addTearDownHook( - lambda: self.runCmd("settings clear auto-confirm")) + self.set_setting("auto-confirm", "true") def build_and_run(self): """Test top-level expressions.""" Index: lldb/test/API/commands/expression/weak_symbols/TestWeakSymbols.py =================================================================== --- lldb/test/API/commands/expression/weak_symbols/TestWeakSymbols.py +++ lldb/test/API/commands/expression/weak_symbols/TestWeakSymbols.py @@ -34,7 +34,7 @@ correct_value = 10 else: correct_value = 20 - + # Note, I'm adding the "; 10" at the end of the expression to work around # the bug that expressions with no result currently return False for Success()... expr = "if (&" + weak_varname + " != NULL) { present_weak_int = 10; } else { present_weak_int = 20;}; 10" @@ -62,8 +62,8 @@ # for the weak symbol. We need to add the source dir to the module # search paths, and then run @import to introduce it into the expression # context: - self.dbg.HandleCommand("settings set target.clang-module-search-paths " + self.getSourceDir()) - + self.set_setting("target.clang-module-search-paths", "'%s'" % (self.getSourceDir())) + self.frame = thread.frames[0] self.assertTrue(self.frame.IsValid(), "Got a good frame") options = lldb.SBExpressionOptions() @@ -73,7 +73,7 @@ # Now run an expression that references an absent weak symbol: self.run_weak_var_check("absent_weak_int", False) self.run_weak_var_check("absent_weak_function", False) - + # Make sure we can do the same thing with present weak symbols self.run_weak_var_check("present_weak_int", True) self.run_weak_var_check("present_weak_function", True) Index: lldb/test/API/commands/help/TestHelp.py =================================================================== --- lldb/test/API/commands/help/TestHelp.py +++ lldb/test/API/commands/help/TestHelp.py @@ -257,8 +257,7 @@ @no_debug_info_test def test_help_format_output(self): """Test that help output reaches TerminalWidth.""" - self.runCmd( - 'settings set term-width 108') + self.set_setting("term-width", "108") self.expect( "help format", matching=True, Index: lldb/test/API/commands/process/launch/TestProcessLaunch.py =================================================================== --- lldb/test/API/commands/process/launch/TestProcessLaunch.py +++ lldb/test/API/commands/process/launch/TestProcessLaunch.py @@ -22,10 +22,9 @@ def setUp(self): # Call super's setUp(). TestBase.setUp(self) - self.runCmd("settings set auto-confirm true") + self.set_setting("auto-confirm", "true") def tearDown(self): - self.runCmd("settings clear auto-confirm") TestBase.tearDown(self) @not_remote_testsuite_ready Index: lldb/test/API/commands/watchpoints/watchpoint_size/TestWatchpointSizes.py =================================================================== --- lldb/test/API/commands/watchpoints/watchpoint_size/TestWatchpointSizes.py +++ lldb/test/API/commands/watchpoints/watchpoint_size/TestWatchpointSizes.py @@ -112,11 +112,9 @@ # Delete the watchpoint immediately, but set auto-confirm to true # first. - self.runCmd("settings set auto-confirm true") + self.set_setting("auto-confirm", "true") self.expect( "watchpoint delete", substrs=['All watchpoints removed.']) - # Restore the original setting of auto-confirm. - self.runCmd("settings clear auto-confirm") self.runCmd("process continue") Index: lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py =================================================================== --- lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py +++ lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py @@ -38,9 +38,7 @@ # Find the line number to break inside main(). self.line = line_number('main.c', '// Set break point at this line.') # disable "There is a running process, kill it and restart?" prompt - self.runCmd("settings set auto-confirm true") - self.addTearDownHook( - lambda: self.runCmd("settings clear auto-confirm")) + self.set_setting("auto-confirm", "true") def test_delete_all_breakpoints(self): """Test that deleting all breakpoints works.""" Index: lldb/test/API/functionalities/breakpoint/breakpoint_options/TestBreakpointOptions.py =================================================================== --- lldb/test/API/functionalities/breakpoint/breakpoint_options/TestBreakpointOptions.py +++ lldb/test/API/functionalities/breakpoint/breakpoint_options/TestBreakpointOptions.py @@ -94,7 +94,7 @@ sym_exact=False, extra_options="-L c", num_expected_locations=0) - self.runCmd("settings set target.language c") + self.set_setting("target.language", "c") lldbutil.run_break_set_by_symbol( self, 'ns::func', sym_exact=False, num_expected_locations=0) Index: lldb/test/API/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py =================================================================== --- lldb/test/API/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py +++ lldb/test/API/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py @@ -80,10 +80,9 @@ self.build(None, None, {'PWD': pwd_symlink}) if setting_value: - cmd = "settings set %s '%s'" % (_COMP_DIR_SYM_LINK_PROP, setting_value) + self.set_setting(_COMP_DIR_SYM_LINK_PROP, "'%s'" % (setting_value)) else: - cmd = "settings clear %s"%_COMP_DIR_SYM_LINK_PROP - self.runCmd(cmd) + self.runCmd("settings clear %s" %_COMP_DIR_SYM_LINK_PROP) exe = self.getBuildArtifact(_EXE_NAME) self.runCmd('file ' + exe, CURRENT_EXECUTABLE_SET) Index: lldb/test/API/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py =================================================================== --- lldb/test/API/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py +++ lldb/test/API/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py @@ -72,41 +72,39 @@ # Don't skip prologue, so we can check the breakpoint address more # easily - self.runCmd("settings set target.skip-prologue false") - try: - names = ['~c', 'c::~c', 'c::~c()'] - loc_names = {'a::c::~c()', 'b::c::~c()'} - # TODO: For windows targets we should put windows mangled names - # here - symbols = [ - '_ZN1a1cD1Ev', - '_ZN1a1cD2Ev', - '_ZN1b1cD1Ev', - '_ZN1b1cD2Ev'] - - for name in names: - bp = target.BreakpointCreateByName(name) - - bp_loc_names = {bp_loc.GetAddress().GetFunction().GetName() - for bp_loc in bp} - self.assertEquals( - bp_loc_names, - loc_names, - "Breakpoint set on the correct symbol") - - bp_addresses = {bp_loc.GetLoadAddress() for bp_loc in bp} - symbol_addresses = set() - for symbol in symbols: - sc_list = target.FindSymbols(symbol, lldb.eSymbolTypeCode) - self.assertEquals( - sc_list.GetSize(), 1, "Found symbol " + symbol) - symbol = sc_list.GetContextAtIndex(0).GetSymbol() - symbol_addresses.add( - symbol.GetStartAddress().GetLoadAddress(target)) + self.set_setting("target.skip-prologue", "false") + + names = ['~c', 'c::~c', 'c::~c()'] + loc_names = {'a::c::~c()', 'b::c::~c()'} + # TODO: For windows targets we should put windows mangled names + # here + symbols = [ + '_ZN1a1cD1Ev', + '_ZN1a1cD2Ev', + '_ZN1b1cD1Ev', + '_ZN1b1cD2Ev'] + for name in names: + bp = target.BreakpointCreateByName(name) + + bp_loc_names = {bp_loc.GetAddress().GetFunction().GetName() + for bp_loc in bp} + self.assertEquals( + bp_loc_names, + loc_names, + "Breakpoint set on the correct symbol") + + bp_addresses = {bp_loc.GetLoadAddress() for bp_loc in bp} + symbol_addresses = set() + for symbol in symbols: + sc_list = target.FindSymbols(symbol, lldb.eSymbolTypeCode) self.assertEquals( - symbol_addresses, - bp_addresses, - "Breakpoint set on correct address") - finally: - self.runCmd("settings clear target.skip-prologue") + sc_list.GetSize(), 1, "Found symbol " + symbol) + symbol = sc_list.GetContextAtIndex(0).GetSymbol() + symbol_addresses.add( + symbol.GetStartAddress().GetLoadAddress(target)) + + self.assertEquals( + symbol_addresses, + bp_addresses, + "Breakpoint set on correct address") Index: lldb/test/API/functionalities/breakpoint/inlined_breakpoints/TestInlinedBreakpoints.py =================================================================== --- lldb/test/API/functionalities/breakpoint/inlined_breakpoints/TestInlinedBreakpoints.py +++ lldb/test/API/functionalities/breakpoint/inlined_breakpoints/TestInlinedBreakpoints.py @@ -45,9 +45,6 @@ # Now enable breakpoints in implementation files and see the breakpoint # set succeed self.runCmd('settings set target.inline-breakpoint-strategy always') - # And add hooks to restore the settings during tearDown(). - self.addTearDownHook(lambda: self.runCmd( - "settings set target.inline-breakpoint-strategy always")) lldbutil.run_break_set_by_file_and_line( self, Index: lldb/test/API/functionalities/breakpoint/require_hw_breakpoints/TestRequireHWBreakpoints.py =================================================================== --- lldb/test/API/functionalities/breakpoint/require_hw_breakpoints/TestRequireHWBreakpoints.py +++ lldb/test/API/functionalities/breakpoint/require_hw_breakpoints/TestRequireHWBreakpoints.py @@ -30,7 +30,7 @@ exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) - self.runCmd("settings set target.require-hardware-breakpoint true") + self.set_setting("target.require-hardware-breakpoint", "true") breakpoint = target.BreakpointCreateByLocation("main.c", 1) self.assertTrue(breakpoint.IsHardware()) @@ -44,7 +44,7 @@ _, _, thread, _ = lldbutil.run_to_line_breakpoint( self, lldb.SBFileSpec("main.c"), 1) - self.runCmd("settings set target.require-hardware-breakpoint true") + self.set_setting("target.require-hardware-breakpoint", "true") # Ensure we fail in the interpreter. self.expect("thread step-in") @@ -66,7 +66,7 @@ _, _, thread, _ = lldbutil.run_to_line_breakpoint( self, lldb.SBFileSpec("main.c"), 1) - self.runCmd("settings set target.require-hardware-breakpoint true") + self.set_setting("target.require-hardware-breakpoint", "true") # Ensure this fails in the command interpreter. self.expect("thread step-out", error=True) @@ -87,7 +87,7 @@ _, _, thread, _ = lldbutil.run_to_line_breakpoint( self, lldb.SBFileSpec("main.c"), 7) - self.runCmd("settings set target.require-hardware-breakpoint true") + self.set_setting("target.require-hardware-breakpoint", "true") # Step over doesn't fail immediately but fails later on. self.expect( @@ -106,7 +106,7 @@ _, _, thread, _ = lldbutil.run_to_line_breakpoint( self, lldb.SBFileSpec("main.c"), 7) - self.runCmd("settings set target.require-hardware-breakpoint true") + self.set_setting("target.require-hardware-breakpoint", "true") self.expect("thread until 5", error=True) Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py =================================================================== --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py @@ -44,9 +44,6 @@ self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd( - "settings set target.max-children-count 256", - check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py =================================================================== --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py @@ -60,9 +60,6 @@ self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd( - "settings set target.max-children-count 256", - check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py =================================================================== --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py @@ -43,9 +43,6 @@ self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd( - "settings set target.max-children-count 256", - check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/TestDataFormatterLibccMultiMap.py =================================================================== --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/TestDataFormatterLibccMultiMap.py +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/TestDataFormatterLibccMultiMap.py @@ -43,9 +43,6 @@ self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd( - "settings set target.max-children-count 256", - check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/TestDataFormatterLibcxxMultiSet.py =================================================================== --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/TestDataFormatterLibcxxMultiSet.py +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/TestDataFormatterLibcxxMultiSet.py @@ -56,9 +56,6 @@ self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd( - "settings set target.max-children-count 256", - check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/set/TestDataFormatterLibcxxSet.py =================================================================== --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/set/TestDataFormatterLibcxxSet.py +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/set/TestDataFormatterLibcxxSet.py @@ -56,9 +56,6 @@ self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd( - "settings set target.max-children-count 256", - check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py =================================================================== --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py @@ -46,9 +46,6 @@ self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd( - "settings set target.max-children-count 256", - check=False) is_64_bit = self.process().GetAddressByteSize() == 8 Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/TestDataFormatterUnordered.py =================================================================== --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/TestDataFormatterUnordered.py +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/TestDataFormatterUnordered.py @@ -40,9 +40,6 @@ self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd( - "settings set target.max-children-count 256", - check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py =================================================================== --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py @@ -43,9 +43,6 @@ self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd( - "settings set target.max-children-count 256", - check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py =================================================================== --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py @@ -61,9 +61,6 @@ self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd( - "settings set target.max-children-count 256", - check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/TestDataFormatterStdIterator.py =================================================================== --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/TestDataFormatterStdIterator.py +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/TestDataFormatterStdIterator.py @@ -43,9 +43,6 @@ self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd( - "settings set target.max-children-count 256", - check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/list/TestDataFormatterStdList.py =================================================================== --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/list/TestDataFormatterStdList.py +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/list/TestDataFormatterStdList.py @@ -47,9 +47,6 @@ self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd( - "settings set target.max-children-count 256", - check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py =================================================================== --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py @@ -43,9 +43,6 @@ self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd( - "settings set target.max-children-count 256", - check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py =================================================================== --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py @@ -44,9 +44,6 @@ self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd( - "settings set target.max-children-count 256", - check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/TestDataFormatterStdVBool.py =================================================================== --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/TestDataFormatterStdVBool.py +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/TestDataFormatterStdVBool.py @@ -43,9 +43,6 @@ self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd( - "settings set target.max-children-count 256", - check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/TestDataFormatterStdVector.py =================================================================== --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/TestDataFormatterStdVector.py +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/TestDataFormatterStdVector.py @@ -43,9 +43,6 @@ self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd( - "settings set target.max-children-count 256", - check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) Index: lldb/test/API/functionalities/exec/TestExec.py =================================================================== --- lldb/test/API/functionalities/exec/TestExec.py +++ lldb/test/API/functionalities/exec/TestExec.py @@ -56,13 +56,7 @@ if self.TraceOn(): self.runCmd("settings show target.process.stop-on-exec", check=False) if skip_exec: - self.dbg.HandleCommand("settings set target.process.stop-on-exec false") - def cleanup(): - self.runCmd("settings set target.process.stop-on-exec false", - check=False) - - # Execute the cleanup function during test case tear down. - self.addTearDownHook(cleanup) + self.set_setting("target.process.stop-on-exec", "false") # The stop reason of the thread should be breakpoint. self.assertTrue(process.GetState() == lldb.eStateStopped, Index: lldb/test/API/functionalities/float-display/main.c =================================================================== --- lldb/test/API/functionalities/float-display/main.c +++ lldb/test/API/functionalities/float-display/main.c @@ -79,7 +79,7 @@ //% # Now change the setting to print all the zeroes. //% # Note that changing this setting should invalidate the data visualizer //% # cache so that the new setting is used in the following calls. - //% self.runCmd("settings set target.max-zero-padding-in-float-format 9999") + //% self.set_setting("target.max-zero-padding-in-float-format", "9999") //% self.expect("frame variable f_neg3", substrs=["0.00123456"]) //% self.expect("frame variable f_neg4", substrs=["0.000123456"]) //% self.expect("frame variable f_neg5", substrs=["0.0000123456"]) Index: lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py =================================================================== --- lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py +++ lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py @@ -76,10 +76,7 @@ def test_read_registers_using_g_packets(self): """Test reading registers using 'g' packets (default behavior)""" - self.dbg.HandleCommand( - "settings set plugin.process.gdb-remote.use-g-packet-for-reading true") - self.addTearDownHook(lambda: - self.runCmd("settings set plugin.process.gdb-remote.use-g-packet-for-reading false")) + self.set_setting("plugin.process.gdb-remote.use-g-packet-for-reading", "true") self.server.responder = self.gPacketResponder() target = self.createTarget("a.yaml") process = self.connect(target) @@ -93,8 +90,7 @@ def test_read_registers_using_p_packets(self): """Test reading registers using 'p' packets""" - self.dbg.HandleCommand( - "settings set plugin.process.gdb-remote.use-g-packet-for-reading false") + self.set_setting("plugin.process.gdb-remote.use-g-packet-for-reading", "false") target = self.createTarget("a.yaml") process = self.connect(target) Index: lldb/test/API/functionalities/gdb_remote_client/TestRecognizeBreakpoint.py =================================================================== --- lldb/test/API/functionalities/gdb_remote_client/TestRecognizeBreakpoint.py +++ lldb/test/API/functionalities/gdb_remote_client/TestRecognizeBreakpoint.py @@ -94,9 +94,8 @@ python_os_plugin_path = os.path.join(self.getSourceDir(), 'operating_system_2.py') - command ="settings set target.process.python-os-plugin-path '{}'".format( - python_os_plugin_path) - self.runCmd(command) + self.set_setting("target.process.python-os-plugin-path", + "'%s'" % (python_os_plugin_path)) self.server.responder = MyResponder() target = self.dbg.CreateTarget("") Index: lldb/test/API/functionalities/gdb_remote_client/TestThreadSelectionBug.py =================================================================== --- lldb/test/API/functionalities/gdb_remote_client/TestThreadSelectionBug.py +++ lldb/test/API/functionalities/gdb_remote_client/TestThreadSelectionBug.py @@ -16,9 +16,8 @@ process = self.connect(target) python_os_plugin_path = os.path.join(self.getSourceDir(), 'operating_system.py') - command = "settings set target.process.python-os-plugin-path '{}'".format( - python_os_plugin_path) - self.dbg.HandleCommand(command) + self.set_setting("target.process.python-os-plugin-path", + "'%s'" % (python_os_plugin_path)) self.assertTrue(process, PROCESS_IS_VALID) self.assertEqual(process.GetNumThreads(), 3) Index: lldb/test/API/functionalities/jitloader_gdb/TestJITLoaderGDB.py =================================================================== --- lldb/test/API/functionalities/jitloader_gdb/TestJITLoaderGDB.py +++ lldb/test/API/functionalities/jitloader_gdb/TestJITLoaderGDB.py @@ -64,12 +64,12 @@ logfile = self.gen_log_file() self.runCmd("log enable -f %s lldb jit" % (logfile)) - self.runCmd("settings set plugin.jit-loader.gdb.enable on") def cleanup(): self.runCmd("log disable lldb") - self.runCmd("settings set plugin.jit-loader.gdb.enable default") self.addTearDownHook(cleanup) + self.set_setting("plugin.jit-loader.gdb.enable", "on") + # launch the process target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) @@ -94,12 +94,12 @@ logfile = self.gen_log_file() self.runCmd("log enable -f %s lldb jit" % (logfile)) - self.runCmd("settings set plugin.jit-loader.gdb.enable off") def cleanup(): self.runCmd("log disable lldb") - self.runCmd("settings set plugin.jit-loader.gdb.enable default") self.addTearDownHook(cleanup) + self.set_setting("plugin.jit-loader.gdb.enable", "off") + # launch the process target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) Index: lldb/test/API/functionalities/load_unload/TestLoadUnload.py =================================================================== --- lldb/test/API/functionalities/load_unload/TestLoadUnload.py +++ lldb/test/API/functionalities/load_unload/TestLoadUnload.py @@ -37,23 +37,14 @@ lldbutil.mkdir_p(self.getBuildArtifact("hidden")) if not self.platformIsDarwin(): if not lldb.remote_platform and "LD_LIBRARY_PATH" in os.environ: - self.runCmd( - "settings set target.env-vars " + - self.dylibPath + - "=" + - os.environ["LD_LIBRARY_PATH"] + - ":" + - self.getBuildDir()) + dyn_lib_path = os.environ["LD_LIBRARY_PATH"] + ":" + self.getBuildDir() + self.append_setting("target.env-vars", self.dylibPath, dyn_lib_path) else: if lldb.remote_platform: wd = lldb.remote_platform.GetWorkingDirectory() else: wd = self.getBuildDir() - self.runCmd( - "settings set target.env-vars " + - self.dylibPath + - "=" + - wd) + self.append_setting("target.env-vars", self.dylibPath, wd) def copy_shlibs_to_remote(self, hidden_dir=False): """ Copies the shared libs required by this test suite to remote. @@ -93,10 +84,8 @@ (wd, err.GetCString())) def setSvr4Support(self, enabled): - self.runCmd( - "settings set plugin.process.gdb-remote.use-libraries-svr4 {enabled}".format( - enabled="true" if enabled else "false" - ) + self.set_setting("plugin.process.gdb-remote.use-libraries-svr4", + "true" if enabled else "false" ) # libloadunload_d.so does not appear in the image list because executable @@ -142,16 +131,11 @@ # Obliterate traces of libd from the old location. os.remove(old_dylib) # Inform (DY)LD_LIBRARY_PATH of the new path, too. - env_cmd_string = "settings set target.env-vars " + self.dylibPath + "=" + new_dir if self.TraceOn(): - print("Set environment to: ", env_cmd_string) - self.runCmd(env_cmd_string) + print("Set environment to: ", self.dylibPath + "=" + new_dir) + self.append_setting("target.env-vars", self.dylibPath, new_dir) self.runCmd("settings show target.env-vars") - remove_dyld_path_cmd = "settings remove target.env-vars " + self.dylibPath - self.addTearDownHook( - lambda: self.dbg.HandleCommand(remove_dyld_path_cmd)) - self.runCmd("run") self.expect( @@ -195,11 +179,6 @@ new_dir = os.path.join(wd, special_dir) old_dylib = os.path.join(old_dir, dylibName) - remove_dyld_path_cmd = "settings remove target.env-vars " \ - + self.dylibPath - self.addTearDownHook( - lambda: self.dbg.HandleCommand(remove_dyld_path_cmd)) - # For now we don't track (DY)LD_LIBRARY_PATH, so the old # library will be in the modules list. self.expect("target modules list", @@ -214,11 +193,9 @@ self.runCmd("continue") # Add the hidden directory first in the search path. - env_cmd_string = ("settings set target.env-vars %s=%s" % - (self.dylibPath, new_dir)) if not self.platformIsDarwin(): - env_cmd_string += ":" + wd - self.runCmd(env_cmd_string) + new_dir += ":" + wd + self.append_setting("target.env-vars", self.dylibPath, new_dir) # This time, the hidden library should be picked up. self.expect("run", substrs=["return", "12345"]) Index: lldb/test/API/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py =================================================================== --- lldb/test/API/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py +++ lldb/test/API/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py @@ -80,8 +80,8 @@ # Now load the python OS plug-in which should update the thread list and we should have # OS plug-in created threads with the IDs: 0x111111111, 0x222222222, # 0x333333333 - command = "settings set target.process.python-os-plugin-path '%s'" % python_os_plugin_path - self.dbg.HandleCommand(command) + self.set_setting("target.process.python-os-plugin-path", + "'%s'" % (python_os_plugin_path)) # Verify our OS plug-in threads showed up thread = process.GetThreadByID(0x111111111) @@ -156,8 +156,8 @@ # Now load the python OS plug-in which should update the thread list and we should have # OS plug-in created threads with the IDs: 0x111111111, 0x222222222, # 0x333333333 - command = "settings set target.process.python-os-plugin-path '%s'" % python_os_plugin_path - self.dbg.HandleCommand(command) + self.set_setting("target.process.python-os-plugin-path", + "'%s'" % (python_os_plugin_path)) # Verify our OS plug-in threads showed up thread = process.GetThreadByID(0x111111111) Index: lldb/test/API/functionalities/postmortem/mach-core/TestMachCore.py =================================================================== --- lldb/test/API/functionalities/postmortem/mach-core/TestMachCore.py +++ lldb/test/API/functionalities/postmortem/mach-core/TestMachCore.py @@ -41,9 +41,8 @@ # Load OS plugin. python_os_plugin_path = os.path.join(self.getSourceDir(), 'operating_system.py') - command = "settings set target.process.python-os-plugin-path '{}'".format( - python_os_plugin_path) - self.dbg.HandleCommand(command) + self.set_setting("target.process.python-os-plugin-path", + "'%s'" % (python_os_plugin_path)) # Load core. process = target.LoadCore(self.getBuildArtifact("test.core")) Index: lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py =================================================================== --- lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py +++ lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py @@ -154,8 +154,8 @@ """ so_path = self.getBuildArtifact("libuuidmatch.so") self.yaml2obj("libuuidmatch.yaml", so_path) - cmd = 'settings set target.exec-search-paths "%s"' % (os.path.dirname(so_path)) - self.dbg.HandleCommand(cmd) + self.set_setting('target.exec-search-paths', + '"%s"' % (os.path.dirname(so_path))) modules = self.get_minidump_modules("linux-arm-partial-uuids-match.yaml") self.assertEqual(1, len(modules)) self.verify_module(modules[0], so_path, @@ -175,8 +175,8 @@ """ so_path = self.getBuildArtifact("libuuidmismatch.so") self.yaml2obj("libuuidmismatch.yaml", so_path) - cmd = 'settings set target.exec-search-paths "%s"' % (os.path.dirname(so_path)) - self.dbg.HandleCommand(cmd) + self.set_setting('target.exec-search-paths', + '"%s"' % (os.path.dirname(so_path))) modules = self.get_minidump_modules("linux-arm-partial-uuids-mismatch.yaml") self.assertEqual(1, len(modules)) self.verify_module(modules[0], Index: lldb/test/API/functionalities/source-map/TestTargetSourceMap.py =================================================================== --- lldb/test/API/functionalities/source-map/TestTargetSourceMap.py +++ lldb/test/API/functionalities/source-map/TestTargetSourceMap.py @@ -25,8 +25,7 @@ bp = target.BreakpointCreateByLocation(src_path, 2) self.assertEquals(bp.GetNumLocations(), 0, "make sure no breakpoints were resolved without map") - src_map_cmd = 'settings set target.source-map . "%s"' % (src_dir) - self.dbg.HandleCommand(src_map_cmd) + self.set_setting('target.source-map', '. "%s"' % (src_dir)) # Set a breakpoint after we remap source and verify that it succeeds bp = target.BreakpointCreateByLocation(src_path, 2) Index: lldb/test/API/functionalities/step-avoids-no-debug/TestStepNoDebug.py =================================================================== --- lldb/test/API/functionalities/step-avoids-no-debug/TestStepNoDebug.py +++ lldb/test/API/functionalities/step-avoids-no-debug/TestStepNoDebug.py @@ -61,13 +61,7 @@ TestBase.setUp(self) self.main_source = "with-debug.c" self.main_source_spec = lldb.SBFileSpec("with-debug.c") - self.dbg.HandleCommand( - "settings set target.process.thread.step-out-avoid-nodebug true") - - def tearDown(self): - self.dbg.HandleCommand( - "settings set target.process.thread.step-out-avoid-nodebug false") - TestBase.tearDown(self) + self.set_setting("target.process.thread.step-out-avoid-nodebug", "true") def hit_correct_line(self, pattern): target_line = line_number(self.main_source, pattern) Index: lldb/test/API/functionalities/thread/backtrace_limit/TestBacktraceLimit.py =================================================================== --- lldb/test/API/functionalities/thread/backtrace_limit/TestBacktraceLimit.py +++ lldb/test/API/functionalities/thread/backtrace_limit/TestBacktraceLimit.py @@ -20,8 +20,5 @@ self.main_source_file = lldb.SBFileSpec("main.cpp") (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self, "Set a breakpoint here", self.main_source_file) - interp = self.dbg.GetCommandInterpreter() - result = lldb.SBCommandReturnObject() - interp.HandleCommand("settings set target.process.thread.max-backtrace-depth 30", result) - self.assertEqual(True, result.Succeeded()) + self.set_setting("target.process.thread.max-backtrace-depth", "30") self.assertEqual(30, thread.GetNumFrames()) Index: lldb/test/API/lang/c/shared_lib/TestSharedLib.py =================================================================== --- lldb/test/API/lang/c/shared_lib/TestSharedLib.py +++ lldb/test/API/lang/c/shared_lib/TestSharedLib.py @@ -75,7 +75,7 @@ target = self.dbg.CreateTarget(self.getBuildArtifact("a.out")) self.assertTrue(target, VALID_TARGET) - self.runCmd("settings set target.preload-symbols " + str(preload_symbols).lower()) + self.set_setting("target.preload-symbols", str(preload_symbols).lower()) # Break inside the foo function which takes a bar_ptr argument. lldbutil.run_break_set_by_file_and_line( Index: lldb/test/API/lang/c/tls_globals/TestTlsGlobals.py =================================================================== --- lldb/test/API/lang/c/tls_globals/TestTlsGlobals.py +++ lldb/test/API/lang/c/tls_globals/TestTlsGlobals.py @@ -21,20 +21,12 @@ # LD_LIBRARY_PATH must be set so the shared libraries are found on # startup if "LD_LIBRARY_PATH" in os.environ: - self.runCmd( - "settings set target.env-vars " + - self.dylibPath + - "=" + - os.environ["LD_LIBRARY_PATH"] + - ":" + - self.getBuildDir()) + self.append_setting("target.env-vars", + self.dylibPath, + os.environ["LD_LIBRARY_PATH"] + ":" + self.getBuildDir()) else: - self.runCmd("settings set target.env-vars " + - self.dylibPath + "=" + self.getBuildDir()) - self.addTearDownHook( - lambda: self.runCmd( - "settings remove target.env-vars " + - self.dylibPath)) + self.append_setting("target.env-vars", + self.dylibPath, self.getBuildDir()) # TLS works differently on Windows, this would need to be implemented # separately. Index: lldb/test/API/lang/cpp/type_lookup/TestCppTypeLookup.py =================================================================== --- lldb/test/API/lang/cpp/type_lookup/TestCppTypeLookup.py +++ lldb/test/API/lang/cpp/type_lookup/TestCppTypeLookup.py @@ -40,7 +40,7 @@ # We are testing LLDB's type lookup machinery, but if we inject local # variables, the types for those will be found because they have been # imported through the variable, not because the type lookup worked. - self.runCmd("settings set target.experimental.inject-local-vars false") + self.set_setting("target.experimental.inject-local-vars", "false") # Make sure we don't accidentally accept structures that exist only # in namespaces when evaluating expressions with top level types. Index: lldb/test/API/lang/mixed/TestMixedLanguages.py =================================================================== --- lldb/test/API/lang/mixed/TestMixedLanguages.py +++ lldb/test/API/lang/mixed/TestMixedLanguages.py @@ -17,13 +17,6 @@ exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - # Execute the cleanup function during test case tear down - # to restore the frame format. - def cleanup(): - self.runCmd( - "settings set frame-format %s" % - self.format_string, check=False) - self.addTearDownHook(cleanup) self.runCmd("settings show frame-format") m = re.match( '^frame-format \(format-string\) = "(.*)\"$', @@ -33,7 +26,7 @@ # Change the default format to print the language. format_string = "frame #${frame.index}: ${frame.pc}{ ${module.file.basename}\`${function.name}{${function.pc-offset}}}{, lang=${language}}\n" - self.runCmd("settings set frame-format %s" % format_string) + self.set_setting("frame-format", format_string, value_to_restore = self.format_string) self.expect("settings show frame-format", SETTING_MSG("frame-format"), substrs=[format_string]) Index: lldb/test/API/lang/objc/modules-auto-import/TestModulesAutoImport.py =================================================================== --- lldb/test/API/lang/objc/modules-auto-import/TestModulesAutoImport.py +++ lldb/test/API/lang/objc/modules-auto-import/TestModulesAutoImport.py @@ -42,7 +42,7 @@ self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE, substrs=[' resolved, hit count = 1']) - self.runCmd("settings set target.auto-import-clang-modules true") + self.set_setting("target.auto-import-clang-modules", "true") self.expect("p getpid()", VARIABLES_DISPLAYED_CORRECTLY, substrs=["pid_t"]) Index: lldb/test/API/lang/objc/modules-cache/TestClangModulesCache.py =================================================================== --- lldb/test/API/lang/objc/modules-cache/TestClangModulesCache.py +++ lldb/test/API/lang/objc/modules-cache/TestClangModulesCache.py @@ -20,15 +20,15 @@ def test_expr(self): self.build() self.main_source_file = lldb.SBFileSpec("main.m") - self.runCmd("settings set target.auto-import-clang-modules true") + self.set_setting("settings set target.auto-import-clang-modules", "true") mod_cache = self.getBuildArtifact("my-clang-modules-cache") if os.path.isdir(mod_cache): shutil.rmtree(mod_cache) self.assertFalse(os.path.isdir(mod_cache), "module cache should not exist") - self.runCmd('settings set symbols.clang-modules-cache-path "%s"' % mod_cache) - self.runCmd('settings set target.clang-module-search-paths "%s"' - % self.getSourceDir()) + self.set_setting("symbols.clang-modules-cache-path", '"%s"' % mod_cache, + value_to_restore = configuration.lldb_module_cache_dir) + self.set_setting("target.clang-module-search-paths", self.getSourceDir()) (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( self, "Set breakpoint here", self.main_source_file) self.runCmd("expr @import Foo") Index: lldb/test/API/lang/objc/modules-incomplete/TestIncompleteModules.py =================================================================== --- lldb/test/API/lang/objc/modules-incomplete/TestIncompleteModules.py +++ lldb/test/API/lang/objc/modules-incomplete/TestIncompleteModules.py @@ -39,10 +39,8 @@ self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE, substrs=[' resolved, hit count = 1']) - self.runCmd( - "settings set target.clang-module-search-paths \"" + - self.getSourceDir() + - "\"") + self.set_setting("target.clang-module-search-paths", + "'%s'" % (self.getSourceDir())) self.expect("expr @import myModule; 3", VARIABLES_DISPLAYED_CORRECTLY, substrs=["int", "3"]) Index: lldb/test/API/lang/objc/modules-inline-functions/TestModulesInlineFunctions.py =================================================================== --- lldb/test/API/lang/objc/modules-inline-functions/TestModulesInlineFunctions.py +++ lldb/test/API/lang/objc/modules-inline-functions/TestModulesInlineFunctions.py @@ -26,10 +26,8 @@ lldbutil.run_to_source_breakpoint( self, '// Set breakpoint here.', lldb.SBFileSpec('main.m')) - self.runCmd( - "settings set target.clang-module-search-paths \"" + - self.getSourceDir() + - "\"") + self.set_setting("target.clang-module-search-paths", + "'%s'" % (self.getSourceDir())) self.expect("expr @import myModule; 3", VARIABLES_DISPLAYED_CORRECTLY, substrs=["int", "3"]) Index: lldb/test/API/macosx/add-dsym/TestAddDsymMidExecutionCommand.py =================================================================== --- lldb/test/API/macosx/add-dsym/TestAddDsymMidExecutionCommand.py +++ lldb/test/API/macosx/add-dsym/TestAddDsymMidExecutionCommand.py @@ -30,7 +30,7 @@ main_bp = self.target.BreakpointCreateByName("main", "a.out") self.assertTrue(main_bp, VALID_BREAKPOINT) - self.runCmd("settings set target.disable-aslr false") + self.set_setting("target.disable-aslr", "false") self.process = self.target.LaunchSimple( None, None, self.get_process_working_directory()) self.assertTrue(self.process, PROCESS_IS_VALID) Index: lldb/test/API/macosx/find-dsym/deep-bundle/TestDeepBundle.py =================================================================== --- lldb/test/API/macosx/find-dsym/deep-bundle/TestDeepBundle.py +++ lldb/test/API/macosx/find-dsym/deep-bundle/TestDeepBundle.py @@ -45,8 +45,9 @@ # Since the library that was dlopen()'ed is now removed, lldb will need to find the # binary & dSYM via target.exec-search-paths - settings_str = "settings set target.exec-search-paths " + self.get_process_working_directory() + "/hide.app" - self.runCmd(settings_str) + self.set_setting("target.exec-search-paths", + self.get_process_working_directory() + "/hide.app") + self.runCmd("process attach -p " + str(popen.pid)) target = self.dbg.GetSelectedTarget() Index: lldb/test/API/source-manager/TestSourceManager.py =================================================================== --- lldb/test/API/source-manager/TestSourceManager.py +++ lldb/test/API/source-manager/TestSourceManager.py @@ -70,9 +70,9 @@ # Setup whether we should use ansi escape sequences, including color # and styles such as underline. self.dbg.SetUseColor(use_color) - # Disable syntax highlighting if needed. - self.runCmd("settings set highlight-source " + str(highlight_source).lower()) + # Disable syntax highlighting if needed. + self.set_setting("highlight-source", str(highlight_source).lower()) filespec = lldb.SBFileSpec(self.file, False) source_mgr = self.dbg.GetSourceManager() @@ -161,8 +161,8 @@ builddir_real = os.path.realpath(self.getBuildDir()) hidden_real = os.path.realpath(hidden) # Set target.source-map settings. - self.runCmd("settings set target.source-map %s %s" % - (builddir_real, hidden_real)) + self.set_setting("target.source-map", + "%s %s" % (builddir_real, hidden_real)) # And verify that the settings work. self.expect("settings show target.source-map", substrs=[builddir_real, hidden_real]) @@ -245,8 +245,8 @@ # 'make -C' has resolved current directory to its realpath form. builddir_real = os.path.realpath(self.getBuildDir()) hidden_real = os.path.realpath(hidden) - self.runCmd("settings set target.source-map %s %s" % - (builddir_real, hidden_real)) + self.set_setting("target.source-map", + "%s %s" % (builddir_real, hidden_real)) exe = self.getBuildArtifact("a.out") main = os.path.join(builddir_real, "hidden", "main-copy.c") Index: lldb/test/API/types/AbstractBase.py =================================================================== --- lldb/test/API/types/AbstractBase.py +++ lldb/test/API/types/AbstractBase.py @@ -143,10 +143,7 @@ # This test uses a #include of "basic_type.cpp" so we need to enable # always setting inlined breakpoints. - self.runCmd('settings set target.inline-breakpoint-strategy always') - # And add hooks to restore the settings during tearDown(). - self.addTearDownHook(lambda: self.runCmd( - "settings set target.inline-breakpoint-strategy headers")) + self.set_setting("target.inline-breakpoint-strategy", "always") # Bring the program to the point where we can issue a series of # 'frame variable --show-types' command. @@ -239,10 +236,7 @@ # This test uses a #include of "basic_type.cpp" so we need to enable # always setting inlined breakpoints. - self.runCmd('settings set target.inline-breakpoint-strategy always') - # And add hooks to restore the settings during tearDown(). - self.addTearDownHook(lambda: self.runCmd( - "settings set target.inline-breakpoint-strategy headers")) + self.set_setting("target.inline-breakpoint-strategy", "always") # Bring the program to the point where we can issue a series of # 'expr' command.