jingham added a comment.

I made a few comments all to the same effect, you can use 
CommandObject::GetSelectedOrDummyTarget to get the target that the command is 
operating on, or you can get is straight from m_exe_ctx if you want to make 
sure that you are getting a real target.  In the case of stats, I think running 
with the dummy target is fine, since for instance you can run expressions in 
the dummy target...

Other than that I think this is a good place to start from.

Comment at: lldb/source/Commands/CommandObjectExpression.cpp:626
+  Target *target = m_interpreter.GetExecutionContext().GetTargetPtr();
+  if (!target)
This is what CommandObject::GetSelectedOrDummy target is for.

Comment at: lldb/source/Commands/CommandObjectStats.cpp:30-31
+  bool DoExecute(Args &command, CommandReturnObject &result) override {
+    auto exe_ctx = m_interpreter.GetExecutionContext();
+    Target *target = exe_ctx.GetTargetPtr();
By the time the DoExecute is run, m_exe_ctx has the execution context, so you 
can get the target from there, or use GetSelectedOrDummyTarget.  You can run 
expressions in the dummy target so there's no reason not to collect stats from 


lldb-commits mailing list

Reply via email to