-
Notifications
You must be signed in to change notification settings - Fork 804
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add delay command #179
Add delay command #179
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/python | ||
from threading import Timer | ||
import fblldbbase as fb | ||
import fblldbobjcruntimehelpers as runtimeHelpers | ||
import lldb | ||
import string | ||
|
||
|
||
def lldbcommands(): | ||
return [ | ||
FBDelay() | ||
] | ||
|
||
class FBDelay(fb.FBCommand): | ||
def name(self): | ||
return 'zzz' | ||
|
||
def description(self): | ||
return 'Executes specified lldb command after delay.' | ||
|
||
def args(self): | ||
return [ | ||
fb.FBCommandArgument(arg='delay in seconds', type='float', help='time to wait before executing specified command'), | ||
fb.FBCommandArgument(arg='lldb command', type='string', help='another lldb command to execute after specified delay', default='process interrupt') | ||
] | ||
|
||
def run(self, arguments, options): | ||
lldb.debugger.SetAsync(True) | ||
lldb.debugger.HandleCommand('process continue') | ||
delay = float(arguments[0]) | ||
command = str(arguments[1]) | ||
t = Timer(delay, lambda: self.runDelayed(command)) | ||
t.start() | ||
|
||
def runDelayed(self, command): | ||
lldb.debugger.HandleCommand('process interrupt') | ||
lldb.debugger.HandleCommand(command) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does lldb silently accept an empty command? I ask because the description says There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I actually set a default value on the command option, it probably got lost because I didn't break it at certain line length (is there a style guide you'd like to follow here?) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 😎 I did overlook the default. Given the declared default, don't feel strongly either way about handling an empty command. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this code save the current value of async and set it back after?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like I didn't understand the meaning of
SetAsync()
.From documentation I thought that it detaches execution of the following command (
continue
in this case) allowing function to be evaluated even after we continue the execution.Did I misunderstand it? Or maybe I'm just missing the point of your comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's right, but I didn't think its affect was for only one command, I'm thinking it stays in async mode until something calls
SetAsync(False)
. If that is the case this command should change it back to the original value after it's done.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually don't see it being used like that in other cases we either enable reset async conditionally or don't do it at all in FBFindCommands.py
I don't mind resetting if you are certain we should do it.
Sadly, no documentation, and I don't feel like lldb spelunking right now 😳
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I spelunked last night, and the main thing is that the async setting decides whether
Resume()
orResumeSynchronous()
is called. I didn't write any code though which would really answer the question. I don't know if those other cases really confirm it either way.Since it must work as is, we can leave this for another day 👍