Jim,

an easy way to have commands run synchronous would be to change 
ScriptInterpreterPython::RunScriptBasedCommand() to run 
"debugger.SetAsync(False)" before actually invoking the target function, and 
"debugger.SetAsync(True)" immediately after.

Of course, one could add a --asynchronous flag to "command script add" and have 
all commands added *without* this flag run synchronous through the above trick.
If you want, I can try to work on this in the coming days and let you have a 
patch for this.

Otherwise, if the preferred idea is to leave it to the individual scripted 
commands to pick their synchronicity, I guess it is safer to have the code in a 
try-finally block, as in:

> def StepOver(debugger, args, result, dict):
>       arg_split = args.split(" ")
>       print type(arg_split)
>       count = int(arg_split[0])
>       try:
>           debugger.SetAsync(False)
>               for i in range(0,count):
>                   lldb.thread.StepOver(lldb.eOnlyThisThread)
>                   debugger.HandleCommand("fr var")
>                   print "step<%d>"%i
>       finally:
>           debugger.SetAsync (True)



Sincerely,
- Enrico Granata

On Nov 4, 2011, at 6:18 PM, Jim Ingham wrote:

> gdbrulez:lldb-clean/build/Debug > cat ~/Desktop/script.py
> #########################
> import lldb
> import sys
> import os
> import time
> 
> def StepOver(debugger, args, result, dict):
>       arg_split = args.split(" ")
>       print type(arg_split)
>       count = int(arg_split[0])
>        debugger.SetAsync(False)
>       for i in range(0,count):
>               lldb.thread.StepOver(lldb.eOnlyThisThread)
>               debugger.HandleCommand("fr var")
>               print "step<%d>"%i
> 
>        debugger.SetAsync (True)
> 
> def __lldb_init_module(debugger, session_dict):
>       debugger.HandleCommand("command script add -f script.StepOver mysto")
>       return None
> 
> Be sure to set the debugger back to Async mode in the script when you're 
> done.  My guess is that the most useful way to run lldb "script" commands is 
> to set them to synchronous mode by default.  Or maybe this should be a flag 
> on the "command script add"?
> 
> Hope this helps,
> 
> Jim
_______________________________________________
lldb-dev mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev

Reply via email to