Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions commands/FBDebugCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ def lldbcommands():
FBMethodBreakpointCommand(),
FBMemoryWarningCommand(),
FBFindInstancesCommand(),
FBMethodBreakpointEnableCommand(),
FBMethodBreakpointDisableCommand(),
]

class FBWatchInstanceVariableCommand(fb.FBCommand):
Expand Down Expand Up @@ -189,6 +191,86 @@ def run(self, arguments, options):
fb.evaluateEffect('[[UIApplication sharedApplication] performSelector:@selector(_performMemoryWarning)]')


def switchBreakpointState(expression,on):
ci = lldb.debugger.GetCommandInterpreter()
res = lldb.SBCommandReturnObject()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two lines are no longer used.


expression_pattern = re.compile(r'{}'.format(expression),re.I)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be re.compile(expression, re.I)


target = lldb.debugger.GetSelectedTarget()
for breakpoint in target.breakpoint_iter():
for location in breakpoint:
if expression_pattern.search('{}'.format(location)):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also doesn't need the format, I think it can be just .search(str(location)).

print location

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice addition 👍

location.SetEnabled(on)

class FBMethodBreakpointEnableCommand(fb.FBCommand):
def name(self):
return 'rbenable'

def description(self):
return """
Enable a set of breakpoints for a regular expression

Examples:

#use `rbenable disabled` to switch all breakpoints to `enable`
benable disabled

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't appear to be implemented. I don't think it's necessary to implement, since br dis (breakpoint disable) does this already.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since br dis (breakpoint disable)has already this.
Should we use location.GetAddress() to search?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

location	57.1: where = libsystem_kernel.dylib`mach_msg_trap + 4, address = 0x00000001832ef564, resolved, hit count = 0 
address		libsystem_kernel.dylib`mach_msg_trap + 4
symbol		id = {0x0000024e}, range = [0x000000018095b560-0x000000018095b56c), name="mach_msg_trap"
name		mach_msg_trap

when i set breakpoint at this address(0x0000024e),only symbol contain 0x0000024e.
So i want search address and symbol.How do you think?

@kastiglione kastiglione Mar 1, 2018

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does id = {0x0000024e} represent? The address of the breakpoint is in the location: address = 0x00000001832ef564.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i am sorry.i mean that i want search 0x1832ef564 ,not 0x00000001832ef564

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean you want rbdisable 0x1832ef564 to disable the breakpoint whose address is 0x00000001832ef564?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

@kastiglione kastiglione Mar 2, 2018

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add special cased input handling. If the user's input expression matches 0x[[:xdigit:]], then when building the regex, add a 0* after the 0x. So 0x1832ef564 would become 0x0*1832ef564.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this should be documented. A builtin command already does this: breakpoint enable (or br en for short).


* rbenable ***address***
benable 0x0000000104514dfc

#use `rbenable *filename*` to switch all breakpoints in this file to `enable`
benable SUNNetService.m

#use `rbenable ***module(AppName)***` to switch all breakpoints in this module to `enable`
benable UIKit
benable Foundation

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This documentation block uses benable where it should be rbenable.


"""

def args(self):
return [
fb.FBCommandArgument(arg='expression', type='string', help='Expression to enable breakpoint'),
]

def run(self, arguments, options):
expression = arguments[0]
switchBreakpointState(expression,True)

class FBMethodBreakpointDisableCommand(fb.FBCommand):
def name(self):
return 'rbdisable'

def description(self):
return """
Disable a set of breakpoints for a regular expression

Examples:

#use `rbdisable disabled` to switch all breakpoints to `disable`
rbdisable disabled

* rbdisable ***address***
rbdisable 0x0000000104514dfc

#use `rbdisable *filename*` to switch all breakpoints in this file to `disable`
rbdisable SUNNetService.m

#use `rbdisable ***module(AppName)***` to switch all breakpoints in this module to `disable`
rbdisable UIKit
rbdisable Foundation

"""
def args(self):
return [
fb.FBCommandArgument(arg='expression', type='string', help='Expression to disable breakpoint'),
]

def run(self, arguments, options):
expression = arguments[0]
switchBreakpointState(expression,False)

class FBFindInstancesCommand(fb.FBCommand):
def name(self):
return 'findinstances'
Expand Down