This is an archive of the discontinued LLVM Phabricator instance.

Fix CLI commands in lldb-mi
ClosedPublic

Authored by ki.stfu on Feb 2 2015, 1:34 PM.

Details

Reviewers
abidh
clayborg
Summary

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

Diff Detail

Event Timeline

ki.stfu updated this revision to Diff 19180.Feb 2 2015, 1:34 PM
ki.stfu retitled this revision from to Fix CLI commands in lldb-mi.
ki.stfu updated this object.
ki.stfu edited the test plan for this revision. (Show Details)
ki.stfu added reviewers: abidh, clayborg.
ki.stfu set the repository for this revision to rL LLVM.
ki.stfu changed the visibility from "Public (No Login Required)" to "All Users".
ki.stfu added subscribers: Unknown Object (MLST), abidh, clayborg.
clayborg accepted this revision.Feb 2 2015, 3:02 PM
clayborg edited edge metadata.

Looks good.

This revision is now accepted and ready to land.Feb 2 2015, 3:02 PM

Looks good.

Can you commit it?

abidh closed this revision.Feb 3 2015, 2:08 AM
abidh edited edge metadata.

Committed in 227958.

ki.stfu edited edge metadata.Feb 3 2015, 3:36 AM
ki.stfu changed the visibility from "All Users" to "Public (No Login Required)".