
Watchpoints in lldb can be either 'read', 'write', or 'read/write'. This is exposing the actual behavior of hardware watchpoints. gdb has a different behavior: a "write" type watchpoint only stops when the watched memory region *changes*. A user is using a watchpoint for one of three reasons: 1. Want to find what is changing/corrupting this memory. 2. Want to find what is writing to this memory. 3. Want to find what is reading from this memory. I believe (1) is the most common use case for watchpoints, and it currently can't be done in lldb -- the user needs to continue every time the same value is written to the watched-memory manually. I think gdb's behavior is the correct one. There are some use cases where a developer wants to find every function that writes/reads to/from a memory region, regardless of value, I want to still allow that functionality. This is also a bit of groundwork for my large watchpoint support proposal https://discourse.llvm.org/t/rfc-large-watchpoint-support-in-lldb/72116 where I will be adding support for AArch64 MASK watchpoints which watch power-of-2 memory regions. A user might ask to watch 24 bytes, and a MASK watchpoint stub can do this with a 32-byte MASK watchpoint if it is properly aligned. And we need to ignore writes to the final 8 bytes of that watched region, and not show those hits to the user. This patch adds a new 'modify' watchpoint type and it is the default. Re-landing this patch after addressing testsuite failures found in CI on Linux, Intel machines, and windows. rdar://108234227
69 lines
2.3 KiB
Python
69 lines
2.3 KiB
Python
"""
|
|
Fuzz tests an object after the default construction to make sure it does not crash lldb.
|
|
"""
|
|
|
|
import lldb
|
|
|
|
|
|
def fuzz_obj(obj):
|
|
obj.GetProcess()
|
|
listener = lldb.SBListener()
|
|
error = lldb.SBError()
|
|
obj.Launch(listener, None, None, None, None, None, None, 0, True, error)
|
|
obj.LaunchSimple(None, None, None)
|
|
obj.AttachToProcessWithID(listener, 123, error)
|
|
obj.AttachToProcessWithName(listener, "lldb", False, error)
|
|
obj.ConnectRemote(listener, "connect://to/here", None, error)
|
|
obj.GetExecutable()
|
|
obj.GetNumModules()
|
|
obj.GetModuleAtIndex(0xFFFFFFFF)
|
|
obj.GetDebugger()
|
|
filespec = lldb.SBFileSpec()
|
|
obj.FindModule(filespec)
|
|
sc_list = obj.FindFunctions("the_func")
|
|
sc_list = obj.FindFunctions("the_func", lldb.eFunctionNameTypeAny)
|
|
obj.FindFirstType("dont_care")
|
|
obj.FindTypes("dont_care")
|
|
obj.FindFirstType(None)
|
|
obj.GetInstructions(lldb.SBAddress(), bytearray())
|
|
obj.GetSourceManager()
|
|
obj.FindGlobalVariables("my_global_var", 1)
|
|
address = obj.ResolveLoadAddress(0xFFFF)
|
|
obj.ResolveSymbolContextForAddress(address, 0)
|
|
obj.BreakpointCreateByLocation("filename", 20)
|
|
obj.BreakpointCreateByLocation(filespec, 20)
|
|
obj.BreakpointCreateByName("func", None)
|
|
obj.BreakpointCreateByRegex("func.", None)
|
|
obj.BreakpointCreateByAddress(0xF0F0)
|
|
obj.GetNumBreakpoints()
|
|
obj.GetBreakpointAtIndex(0)
|
|
obj.BreakpointDelete(0)
|
|
obj.FindBreakpointByID(0)
|
|
obj.EnableAllBreakpoints()
|
|
obj.DisableAllBreakpoints()
|
|
obj.DeleteAllBreakpoints()
|
|
obj.GetNumWatchpoints()
|
|
obj.GetWatchpointAtIndex(0)
|
|
obj.DeleteWatchpoint(0)
|
|
obj.FindWatchpointByID(0)
|
|
obj.EnableAllWatchpoints()
|
|
obj.DisableAllWatchpoints()
|
|
obj.DeleteAllWatchpoints()
|
|
obj.GetAddressByteSize()
|
|
obj.GetByteOrder()
|
|
obj.GetTriple()
|
|
error = lldb.SBError()
|
|
wp_opts = lldb.SBWatchpointOptions()
|
|
wp_opts.SetWatchpointTypeRead(True)
|
|
wp_opts.SetWatchpointTypeWrite(lldb.eWatchpointWriteTypeOnModify)
|
|
obj.WatchpointCreateByAddress(123, 8, wp_opts, error)
|
|
obj.GetBroadcaster()
|
|
obj.GetDescription(lldb.SBStream(), lldb.eDescriptionLevelBrief)
|
|
obj.Clear()
|
|
for module in obj.module_iter():
|
|
s = str(module)
|
|
for bp in obj.breakpoint_iter():
|
|
s = str(bp)
|
|
for wp in obj.watchpoint_iter():
|
|
s = str(wp)
|