Add enable&disable breakpoints by rg-expression.#230
Conversation
kastiglione
left a comment
There was a problem hiding this comment.
Thanks for the contribution, this is a cool command.
|
|
||
| br_list = listStr.splitlines() | ||
| expression_pattern = re.compile(r'{}'.format(expression),re.I) | ||
| id_pattern = re.compile(r'^\s*([1-9]\d*)(\.\d+)?',re.I) |
There was a problem hiding this comment.
What do you think about using the Python API, instead of parsing the output of breakpoint list?
For example, it would roughly look like:
for breakpoint in target.breakpoint_iter():
for location in breakpoint:
if pattern.search(location.GetAddress().symbol.name):
location.SetEnabled(False)There was a problem hiding this comment.
target = lldb.debugger.GetSelectedTarget()
for breakpoint in target.breakpoint_iter():
for location in breakpoint:
if expression_pattern.search('{}'.format(location)):
location.SetEnabled(on)
What do you think about using location?
They have some different.
location 2.1: where = SunLigth`__66+[SUNNetService httpAsyncPostWithDictionary:completionBlock:]_block_invoke + 1984 at SUNNetService.m:37, address = 0x0000000104514dfc, unresolved, hit count = 0 Options: disabled
address SunLigth`__66+[SUNNetService httpAsyncPostWithDictionary:completionBlock:]_block_invoke + 1984 at SUNNetService.m:37
symbol id = {0x00006db1}, range = [0x00000001001e063c-0x00000001001e0ec8), mangled="__66+[SUNNetService httpAsyncPostWithDictionary:completionBlock:]_block_invoke"
name __66+[SUNNetService httpAsyncPostWithDictionary:completionBlock:]_block_invoke
So that,we can use benable disabled to switch all breakpoints to enable,and also as follow
#use `benable disabled` to switch all breakpoints to `enable`
benable disabled
* benable ***address***
benable 0x0000000104514dfc
* benable ***filename***
benable SUNNetService.m
* benable ***module***
benable UIKit
benable SunLigth
There was a problem hiding this comment.
Enabling/disabling via filename and module definitely seem useful!
| return 'benable' | ||
|
|
||
| def description(self): | ||
| return "Enable a set of breakpoints for a relative expression" |
There was a problem hiding this comment.
typo: should be "regular", not "relative"
|
|
||
| class FBMethodBreakpointEnableCommand(fb.FBCommand): | ||
| def name(self): | ||
| return 'benable' |
There was a problem hiding this comment.
lldb has an alias command named rb for regex breakpoint. I think it makes sense to call this rbenable and rbdisable, what do you think?
|
|
||
| def switchBreakpointState(expression,on): | ||
| ci = lldb.debugger.GetCommandInterpreter() | ||
| res = lldb.SBCommandReturnObject() |
There was a problem hiding this comment.
These two lines are no longer used.
| ci = lldb.debugger.GetCommandInterpreter() | ||
| res = lldb.SBCommandReturnObject() | ||
|
|
||
| expression_pattern = re.compile(r'{}'.format(expression),re.I) |
There was a problem hiding this comment.
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)): |
There was a problem hiding this comment.
This also doesn't need the format, I think it can be just .search(str(location)).
| for breakpoint in target.breakpoint_iter(): | ||
| for location in breakpoint: | ||
| if expression_pattern.search('{}'.format(location)): | ||
| print location |
|
|
||
| #use `rbenable ***module(AppName)***` to switch all breakpoints in this module to `enable` | ||
| benable UIKit | ||
| benable Foundation |
There was a problem hiding this comment.
This documentation block uses benable where it should be rbenable.
| Examples: | ||
|
|
||
| #use `rbenable disabled` to switch all breakpoints to `enable` | ||
| benable disabled |
There was a problem hiding this comment.
This doesn't appear to be implemented. I don't think it's necessary to implement, since br dis (breakpoint disable) does this already.
There was a problem hiding this comment.
since br dis (breakpoint disable)has already this.
Should we use location.GetAddress() to search?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
What does id = {0x0000024e} represent? The address of the breakpoint is in the location: address = 0x00000001832ef564.
There was a problem hiding this comment.
i am sorry.i mean that i want search 0x1832ef564 ,not 0x00000001832ef564
There was a problem hiding this comment.
Do you mean you want rbdisable 0x1832ef564 to disable the breakpoint whose address is 0x00000001832ef564?
There was a problem hiding this comment.
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.
|
@sunbohong I have just a few more small comments. Once those are resolved, I will merge this pull request. Thanks again. |
|
@sunbohong after thinking about it a little bit, I think |
| Examples: | ||
|
|
||
| #use `benable disabled` to switch all breakpoints to `enable` | ||
| benable disabled |
There was a problem hiding this comment.
I don't think this should be documented. A builtin command already does this: breakpoint enable (or br en for short).
| Examples: | ||
|
|
||
| #use `bdisable disabled` to switch all breakpoints to `disable` | ||
| bdisable disabled |
There was a problem hiding this comment.
Likewise, this is builtin.
There was a problem hiding this comment.
ok,i will remove it
| for breakpoint in target.breakpoint_iter(): | ||
| if breakpoint.IsEnabled() != on and (expression_pattern.search(str(breakpoint))): | ||
| print str(breakpoint) | ||
| breakpoint.SetEnabled(on) |
There was a problem hiding this comment.
Did you find this was necessary in your experience? I'm curious what are some example cases where these commands need to apply to the breakpoint itself instead of working only on the locations.
There was a problem hiding this comment.
If we use br disable 41 to off 41,and benable 41 only enable locations's state.
The 41 41.1 will be ignore.
|
Thanks @sunbohong! |

No description provided.