Ejemplo n.º 1
0
    def make_a_dummy_name(self):
        "This makes a breakpoint name in the dummy target to make sure it gets copied over"

        dummy_target = self.dbg.GetDummyTarget()
        self.assertTrue(dummy_target.IsValid(), "Dummy target was not valid.")

        def cleanup():
            self.dbg.GetDummyTarget().DeleteBreakpointName(self.bp_name_string)

        # Execute the cleanup function during test case tear down.
        self.addTearDownHook(cleanup)

        # Now find it in the dummy target, and make sure these settings took:
        bp_name = lldb.SBBreakpointName(dummy_target, self.bp_name_string)
        # Make sure the name is right:
        self.assertTrue(bp_name.GetName() == self.bp_name_string,
                        "Wrong bp_name: %s" % (bp_name.GetName()))
        bp_name.SetOneShot(self.is_one_shot)
        bp_name.SetIgnoreCount(self.ignore_count)
        bp_name.SetCondition(self.condition)
        bp_name.SetAutoContinue(self.auto_continue)
        bp_name.SetThreadID(self.tid)
        bp_name.SetThreadIndex(self.tidx)
        bp_name.SetThreadName(self.thread_name)
        bp_name.SetQueueName(self.queue_name)
        bp_name.SetCommandLineCommands(self.cmd_list)

        # Now look it up again, and make sure it got set correctly.
        bp_name = lldb.SBBreakpointName(dummy_target, self.bp_name_string)
        self.assertTrue(bp_name.IsValid(), "Failed to make breakpoint name.")
        self.check_option_values(bp_name)
Ejemplo n.º 2
0
    def do_check_configuring_permissions_sb(self):
        bp_name = lldb.SBBreakpointName(self.target, self.bp_name_string)

        # Make a breakpoint name with delete disallowed:
        bp_name = lldb.SBBreakpointName(self.target, self.bp_name_string)
        self.assertTrue(bp_name.IsValid(), "Failed to make breakpoint name for valid name.")

        bp_name.SetAllowDelete(False)
        bp_name.SetAllowDisable(False)
        bp_name.SetAllowList(False)
        self.check_permission_results(bp_name)
Ejemplo n.º 3
0
 def do_check_configuring_permissions_cli(self):
     # Make the name with the right options using the command line:
     self.runCmd("breakpoint name configure -L 0 -D 0 -A 0 %s"%(self.bp_name_string), check=True)
     # Now look up the breakpoint we made, and check that it works.
     bp_name = lldb.SBBreakpointName(self.target, self.bp_name_string)
     self.assertTrue(bp_name.IsValid(), "Didn't make a breakpoint name we could find.")
     self.check_permission_results(bp_name)
 def test_SBBreakpointName(self):
     obj = lldb.SBBreakpointName()
     if self.TraceOn():
         print(obj)
     self.assertFalse(obj)
     # Do fuzz testing on the invalid obj, it should not crash lldb.
     import sb_breakpointname
     sb_breakpointname.fuzz_obj(obj)
Ejemplo n.º 5
0
    def do_check_illegal_names(self):
        """Use Python APIs to check that we reject illegal names."""
        bkpt = self.target.BreakpointCreateByLocation(self.main_file_spec, 10)
        bad_names = ["-CantStartWithADash",
                     "1CantStartWithANumber",
                     "^CantStartWithNonAlpha",
                     "CantHave-ADash",
                     "Cant Have Spaces"]
        for bad_name in bad_names:
            success = bkpt.AddName(bad_name)
            self.assertTrue(not success,"We allowed an illegal name: %s"%(bad_name))
            bp_name = lldb.SBBreakpointName(self.target, bad_name)
            self.assertFalse(bp_name.IsValid(), "We made a breakpoint name with an illegal name: %s"%(bad_name));

            retval =lldb.SBCommandReturnObject()
            self.dbg.GetCommandInterpreter().HandleCommand("break set -n whatever -N '%s'"%(bad_name), retval)
            self.assertTrue(not retval.Succeeded(), "break set succeeded with: illegal name: %s"%(bad_name))
Ejemplo n.º 6
0
    def do_check_configuring_names(self):
        """Use Python APIs to check that configuring breakpoint names works correctly."""
        other_bp_name_string = "AnotherBreakpointName"
        cl_bp_name_string = "CLBreakpointName"

        # Now find the version copied in from the dummy target, and make sure these settings took:
        bp_name = lldb.SBBreakpointName(self.target, self.bp_name_string)
        self.assertTrue(bp_name.IsValid(), "Failed to make breakpoint name.")
        self.check_option_values(bp_name)

        # Now add this name to a breakpoint, and make sure it gets configured properly
        bkpt = self.target.BreakpointCreateByLocation(self.main_file_spec, 10)
        success = bkpt.AddName(self.bp_name_string)
        self.assertTrue(success, "Couldn't add this name to the breakpoint")
        self.check_option_values(bkpt)

        # Now make a name from this breakpoint, and make sure the new name is properly configured:
        new_name = lldb.SBBreakpointName(bkpt, other_bp_name_string)
        self.assertTrue(new_name.IsValid(),
                        "Couldn't make a valid bp_name from a breakpoint.")
        self.check_option_values(bkpt)

        # Now change the name's option and make sure it gets propagated to
        # the breakpoint:
        new_auto_continue = not self.auto_continue
        bp_name.SetAutoContinue(new_auto_continue)
        self.assertEqual(bp_name.GetAutoContinue(), new_auto_continue,
                         "Couldn't change auto-continue on the name")
        self.assertEqual(bkpt.GetAutoContinue(), new_auto_continue,
                         "Option didn't propagate to the breakpoint.")

        # Now make this same breakpoint name - but from the command line
        cmd_str = "breakpoint name configure %s -o %d -i %d -c '%s' -G %d -t %d -x %d -T '%s' -q '%s' -H '%s'" % (
            cl_bp_name_string, self.is_one_shot, self.ignore_count,
            self.condition, self.auto_continue, self.tid, self.tidx,
            self.thread_name, self.queue_name, self.help_string)
        for cmd in self.cmd_list:
            cmd_str += " -C '%s'" % (cmd)

        self.runCmd(cmd_str, check=True)
        # Now look up this name again and check its options:
        cl_name = lldb.SBBreakpointName(self.target, cl_bp_name_string)
        self.check_option_values(cl_name)
        # Also check the help string:
        self.assertEqual(self.help_string, cl_name.GetHelpString(),
                         "Help string didn't match")
        # Change the name and make sure that works:
        new_help = "I do something even more interesting"
        cl_name.SetHelpString(new_help)
        self.assertEqual(new_help, cl_name.GetHelpString(),
                         "SetHelpString didn't")

        # We should have three names now, make sure the target can list them:
        name_list = lldb.SBStringList()
        self.target.GetBreakpointNames(name_list)
        for name_string in [
                self.bp_name_string, other_bp_name_string, cl_bp_name_string
        ]:
            self.assertTrue(name_string in name_list,
                            "Didn't find %s in names" % (name_string))

        # Delete the name from the current target.  Make sure that works and deletes the
        # name from the breakpoint as well:
        self.target.DeleteBreakpointName(self.bp_name_string)
        name_list.Clear()
        self.target.GetBreakpointNames(name_list)
        self.assertTrue(
            self.bp_name_string not in name_list,
            "Didn't delete %s from a real target" % (self.bp_name_string))
        # Also make sure the name got removed from breakpoints holding it:
        self.assertFalse(bkpt.MatchesName(self.bp_name_string),
                         "Didn't remove the name from the breakpoint.")

        # Test that deleting the name we injected into the dummy target works (there's also a
        # cleanup that will do this, but that won't test the result...
        dummy_target = self.dbg.GetDummyTarget()
        dummy_target.DeleteBreakpointName(self.bp_name_string)
        name_list.Clear()
        dummy_target.GetBreakpointNames(name_list)
        self.assertTrue(
            self.bp_name_string not in name_list,
            "Didn't delete %s from the dummy target" % (self.bp_name_string))
        # Also make sure the name got removed from breakpoints holding it:
        self.assertFalse(bkpt.MatchesName(self.bp_name_string),
                         "Didn't remove the name from the breakpoint.")