[Lldb-commits] [PATCH] D111920: Test untested variants of BreakpointCreateBySourceRegex
This revision was automatically updated to reflect the committed changes. Closed by commit rG9a2e9c5db692: Add tests for the other variants of BreakpointCreateBySourceRegex. (authored by jingham). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D111920/new/ https://reviews.llvm.org/D111920 Files: lldb/packages/Python/lldbsuite/test/lldbutil.py lldb/test/API/functionalities/breakpoint/break_in_loaded_dylib/Makefile lldb/test/API/functionalities/breakpoint/break_in_loaded_dylib/TestBreakInLoadedDylib.py lldb/test/API/functionalities/breakpoint/break_in_loaded_dylib/b.cpp lldb/test/API/functionalities/breakpoint/break_in_loaded_dylib/main.cpp lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py lldb/test/API/functionalities/breakpoint/breakpoint_command/bktptcmd.py Index: lldb/test/API/functionalities/breakpoint/breakpoint_command/bktptcmd.py === --- lldb/test/API/functionalities/breakpoint/breakpoint_command/bktptcmd.py +++ lldb/test/API/functionalities/breakpoint/breakpoint_command/bktptcmd.py @@ -17,6 +17,12 @@ se_string = se_value.GetStringValue(100) side_effect.fancier = se_string +def a_list_function(frame, bp_loc, extra_args, dict): +se_value = extra_args.GetValueForKey("side_effect") +se_string = se_value.GetStringValue(100) +side_effect.from_list = se_string + + def empty_extra_args(frame, bp_loc, extra_args, dict): if extra_args.IsValid(): side_effect.not_so_fancy = "Extra args should not be valid" Index: lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py === --- lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py +++ lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py @@ -54,6 +54,17 @@ "Set break point at this line.", self.main_source_spec) self.assertTrue(fancier_bkpt, VALID_BREAKPOINT) +# Also test the list version of this: +file_list = lldb.SBFileSpecList() +file_list.Append(self.main_source_spec) +module_list = lldb.SBFileSpecList() +module_list.Append(self.target.GetExecutable()) + +list_bkpt = self.target.BreakpointCreateBySourceRegex( +"Set break point at this line.", module_list, file_list) +self.assertTrue(list_bkpt, VALID_BREAKPOINT) + + not_so_fancy_bkpt = self.target.BreakpointCreateBySourceRegex( "Set break point at this line.", self.main_source_spec) self.assertTrue(not_so_fancy_bkpt, VALID_BREAKPOINT) @@ -114,13 +125,21 @@ error = not_so_fancy_bkpt.SetScriptCallbackFunction("bktptcmd.empty_extra_args", empty_args) self.assertTrue(error.Success(), "Failed to add callback %s"%(error.GetCString())) +# Do list breakpoint like fancy: +stream.Clear() +stream.Print('{"side_effect" : "I come from list input"}') +extra_args.SetFromJSON(stream) +error = list_bkpt.SetScriptCallbackFunction("bktptcmd.a_list_function", extra_args) +self.assertTrue(error.Success(), "Failed to add callback %s"%(error.GetCString())) + # Clear out canary variables side_effect.bktptcmd = None side_effect.callback = None side_effect.fancy= None side_effect.fancier = None side_effect.not_so_fancy = None - +side_effect.a_list_function = None + # Now launch the process, and do not stop at entry point. self.process = self.target.LaunchSimple( None, None, self.get_process_working_directory()) @@ -133,11 +152,13 @@ self.assertEquals(len(threads), 1, "Stopped at inner breakpoint.") self.thread = threads[0] +print("* Num Locations: {0} ; Hit Count {1}".format(list_bkpt.GetNumLocations(), list_bkpt.GetHitCount())) self.assertEquals("callback was here", side_effect.callback) self.assertEquals("function was here", side_effect.bktptcmd) self.assertEquals("I am fancy", side_effect.fancy) self.assertEquals("I am fancier", side_effect.fancier) self.assertEquals("Not so fancy", side_effect.not_so_fancy) +self.assertEquals("I come from list input", side_effect.from_list) def do_bad_args_to_python_command(self): error = lldb.SBError() Index: lldb/test/API/functionalities/breakpoint/break_in_loaded_dylib/main.cpp === --- /dev/null +++ lldb/test/API/functionalities/breakpoint/break_in_loaded_dylib/main.cpp @@ -0,0 +1,15 @@ +#include "dylib.h" +#include +#include +#include +#include + +int main(int argc, char* argv[]) { + // Break here before we dlopen the
[Lldb-commits] [PATCH] D111920: Test untested variants of BreakpointCreateBySourceRegex
jingham created this revision. jingham added reviewers: aprantl, JDevlieghere. jingham requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits. Add tests for the other variants of BreakpointCreateBySourceRegex. I added some tests for the case where the breakpoints take immediately to the extant test case, and made a new test case for when the source regex breakpoint will be set in a dlopen-ed library. I also noticed when doing this that "lldbutil.run_to_source_breakpoint can't handle the case where the breakpoint will be in a dlopen-ed library, since it requires the breakpoint to have at least 1 location before run. I fixed that by adding a parameter to say whether a before run location is expected. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D111920 Files: lldb/packages/Python/lldbsuite/test/lldbutil.py lldb/test/API/functionalities/breakpoint/break_in_loaded_dylib/Makefile lldb/test/API/functionalities/breakpoint/break_in_loaded_dylib/TestBreakInLoadedDylib.py lldb/test/API/functionalities/breakpoint/break_in_loaded_dylib/b.cpp lldb/test/API/functionalities/breakpoint/break_in_loaded_dylib/main.cpp lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py lldb/test/API/functionalities/breakpoint/breakpoint_command/bktptcmd.py Index: lldb/test/API/functionalities/breakpoint/breakpoint_command/bktptcmd.py === --- lldb/test/API/functionalities/breakpoint/breakpoint_command/bktptcmd.py +++ lldb/test/API/functionalities/breakpoint/breakpoint_command/bktptcmd.py @@ -17,6 +17,12 @@ se_string = se_value.GetStringValue(100) side_effect.fancier = se_string +def a_list_function(frame, bp_loc, extra_args, dict): +se_value = extra_args.GetValueForKey("side_effect") +se_string = se_value.GetStringValue(100) +side_effect.from_list = se_string + + def empty_extra_args(frame, bp_loc, extra_args, dict): if extra_args.IsValid(): side_effect.not_so_fancy = "Extra args should not be valid" Index: lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py === --- lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py +++ lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py @@ -54,6 +54,17 @@ "Set break point at this line.", self.main_source_spec) self.assertTrue(fancier_bkpt, VALID_BREAKPOINT) +# Also test the list version of this: +file_list = lldb.SBFileSpecList() +file_list.Append(self.main_source_spec) +module_list = lldb.SBFileSpecList() +module_list.Append(self.target.GetExecutable()) + +list_bkpt = self.target.BreakpointCreateBySourceRegex( +"Set break point at this line.", module_list, file_list) +self.assertTrue(list_bkpt, VALID_BREAKPOINT) + + not_so_fancy_bkpt = self.target.BreakpointCreateBySourceRegex( "Set break point at this line.", self.main_source_spec) self.assertTrue(not_so_fancy_bkpt, VALID_BREAKPOINT) @@ -114,13 +125,21 @@ error = not_so_fancy_bkpt.SetScriptCallbackFunction("bktptcmd.empty_extra_args", empty_args) self.assertTrue(error.Success(), "Failed to add callback %s"%(error.GetCString())) +# Do list breakpoint like fancy: +stream.Clear() +stream.Print('{"side_effect" : "I come from list input"}') +extra_args.SetFromJSON(stream) +error = list_bkpt.SetScriptCallbackFunction("bktptcmd.a_list_function", extra_args) +self.assertTrue(error.Success(), "Failed to add callback %s"%(error.GetCString())) + # Clear out canary variables side_effect.bktptcmd = None side_effect.callback = None side_effect.fancy= None side_effect.fancier = None side_effect.not_so_fancy = None - +side_effect.a_list_function = None + # Now launch the process, and do not stop at entry point. self.process = self.target.LaunchSimple( None, None, self.get_process_working_directory()) @@ -133,11 +152,13 @@ self.assertEquals(len(threads), 1, "Stopped at inner breakpoint.") self.thread = threads[0] +print("* Num Locations: {0} ; Hit Count {1}".format(list_bkpt.GetNumLocations(), list_bkpt.GetHitCount())) self.assertEquals("callback was here", side_effect.callback) self.assertEquals("function was here", side_effect.bktptcmd) self.assertEquals("I am fancy", side_effect.fancy) self.assertEquals("I am fancier", side_effect.fancier) self.assertEquals("Not so fancy", side_effect.not_so_fancy) +self.assertEquals("I come f