This patch fixes execution of CLI commands in MI mode. The CLI commands are executed using "-interpreter-exec" command. The bug was in the CMICmnLLDBDebugSessionInfo class which contained the following members: SBProcess, SBTarget, SBDebugger and SBListener, but CLI commands don't affect to them and they aren't updated. Therefore some members can contain incorrect (or obsolete) reference and it can cause an error. My patch removes these members and uses getters that provides the updated instance every time it is used.
For example (before fix):
$ bin/lldb-mi --interpreter (gdb) -interpreter-exec command "target create ~/p/hello" Current executable set to '~/p/hello' (x86_64). Current executable set to '~/p/hello' (x86_64). ^done -break-insert -f main ^done,bkpt={number="0",type="breakpoint",disp="keep",enabled="y",addr="0xffffffff",func="??",file="??",fullname="??/??",line="0",pending=["main"],times="0",original-location="main"} -exec-run ^error,msg="Command 'exec-run'. Invalid process during debug session"
As I said, my patch fixes this example (and many others):
$ bin/lldb-mi --interpreter (gdb) -interpreter-exec command "target create ~/p/hello" Current executable set to '~/p/hello' (x86_64). Current executable set to '~/p/hello' (x86_64). ^done -break-insert -f main =breakpoint-modified,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0xffffffff",func="main",file="hello.cpp",fullname="/Users/IliaK/p/hello.cpp",line="4",pending=["main"],times="0",original-location="main"} ^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0xffffffff",func="main",file="hello.cpp",fullname="/Users/IliaK/p/hello.cpp",line="4",pending=["main"],times="1",original-location="main"} -exec-run ^running =thread-group-started,id="i1",pid="56624" =thread-created,id="1",group-id="i1" =thread-selected,id="1" (gdb) *running,thread-id="all" (gdb) (gdb) *stopped,reason="breakpoint-hit",disp="del",bkptno="1",frame={addr="0x1036d6e74",func="main",args=[{name="argc",value="1"},{name="argv",value="0x00007fff5c529f28"}],file="hello.cpp",fullname="/Users//IliaK/p/hello.cpp",line="4"},thread-id="1",stopped-threads="all" (gdb) quit MI: Program exited OK