[Lldb-commits] [lldb] r156433 - in /lldb/trunk: include/lldb/API/SBDebugger.h include/lldb/Target/TargetList.h scripts/Python/interface/SBDebugger.i source/API/SBDebugger.cpp source/Target/TargetList.cpp tools/driver/Driver.cpp
Jim Ingham
jingham at apple.com
Tue May 8 16:06:07 PDT 2012
Author: jingham
Date: Tue May 8 18:06:07 2012
New Revision: 156433
URL: http://llvm.org/viewvc/llvm-project?rev=156433&view=rev
Log:
Print out a notification when the process of a target other than the currently selected target stops.
Modified:
lldb/trunk/include/lldb/API/SBDebugger.h
lldb/trunk/include/lldb/Target/TargetList.h
lldb/trunk/scripts/Python/interface/SBDebugger.i
lldb/trunk/source/API/SBDebugger.cpp
lldb/trunk/source/Target/TargetList.cpp
lldb/trunk/tools/driver/Driver.cpp
Modified: lldb/trunk/include/lldb/API/SBDebugger.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBDebugger.h?rev=156433&r1=156432&r2=156433&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBDebugger.h (original)
+++ lldb/trunk/include/lldb/API/SBDebugger.h Tue May 8 18:06:07 2012
@@ -127,6 +127,9 @@
lldb::SBTarget
GetTargetAtIndex (uint32_t idx);
+
+ uint32_t
+ GetIndexOfTarget (lldb::SBTarget target);
lldb::SBTarget
FindTargetWithProcessID (pid_t pid);
Modified: lldb/trunk/include/lldb/Target/TargetList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/TargetList.h?rev=156433&r1=156432&r2=156433&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/TargetList.h (original)
+++ lldb/trunk/include/lldb/Target/TargetList.h Tue May 8 18:06:07 2012
@@ -142,6 +142,9 @@
lldb::TargetSP
GetTargetAtIndex (uint32_t index) const;
+
+ uint32_t
+ GetIndexOfTarget (lldb::TargetSP target_sp) const;
//------------------------------------------------------------------
/// Find the target that contains has an executable whose path
Modified: lldb/trunk/scripts/Python/interface/SBDebugger.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBDebugger.i?rev=156433&r1=156432&r2=156433&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBDebugger.i (original)
+++ lldb/trunk/scripts/Python/interface/SBDebugger.i Tue May 8 18:06:07 2012
@@ -209,6 +209,9 @@
lldb::SBTarget
GetTargetAtIndex (uint32_t idx);
+ uint32_t
+ GetIndexOfTarget (lldb::SBTarget target);
+
lldb::SBTarget
FindTargetWithProcessID (pid_t pid);
Modified: lldb/trunk/source/API/SBDebugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=156433&r1=156432&r2=156433&view=diff
==============================================================================
--- lldb/trunk/source/API/SBDebugger.cpp (original)
+++ lldb/trunk/source/API/SBDebugger.cpp Tue May 8 18:06:07 2012
@@ -678,6 +678,20 @@
return sb_target;
}
+uint32_t
+SBDebugger::GetIndexOfTarget (lldb::SBTarget target)
+{
+
+ lldb::TargetSP target_sp = target.GetSP();
+ if (!target_sp)
+ return UINT32_MAX;
+
+ if (!m_opaque_sp)
+ return UINT32_MAX;
+
+ return m_opaque_sp->GetTargetList().GetIndexOfTarget (target.GetSP());
+}
+
SBTarget
SBDebugger::FindTargetWithProcessID (pid_t pid)
{
Modified: lldb/trunk/source/Target/TargetList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/TargetList.cpp?rev=156433&r1=156432&r2=156433&view=diff
==============================================================================
--- lldb/trunk/source/Target/TargetList.cpp (original)
+++ lldb/trunk/source/Target/TargetList.cpp Tue May 8 18:06:07 2012
@@ -421,6 +421,19 @@
}
uint32_t
+TargetList::GetIndexOfTarget (lldb::TargetSP target_sp) const
+{
+ Mutex::Locker locker (m_target_list_mutex);
+ size_t num_targets = m_target_list.size();
+ for (size_t idx = 0; idx < num_targets; idx++)
+ {
+ if (target_sp == m_target_list[idx])
+ return idx;
+ }
+ return UINT32_MAX;
+}
+
+uint32_t
TargetList::SetSelectedTarget (Target* target)
{
Mutex::Locker locker (m_target_list_mutex);
Modified: lldb/trunk/tools/driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=156433&r1=156432&r2=156433&view=diff
==============================================================================
--- lldb/trunk/tools/driver/Driver.cpp (original)
+++ lldb/trunk/tools/driver/Driver.cpp Tue May 8 18:06:07 2012
@@ -945,11 +945,26 @@
}
else
{
- SBCommandReturnObject result;
- UpdateSelectedThread ();
- m_debugger.GetCommandInterpreter().HandleCommand("process status", result, false);
- m_io_channel_ap->ErrWrite (result.GetError(), result.GetErrorSize(), ASYNC);
- m_io_channel_ap->OutWrite (result.GetOutput(), result.GetOutputSize(), ASYNC);
+ if (GetDebugger().GetSelectedTarget() == process.GetTarget())
+ {
+ SBCommandReturnObject result;
+ UpdateSelectedThread ();
+ m_debugger.GetCommandInterpreter().HandleCommand("process status", result, false);
+ m_io_channel_ap->ErrWrite (result.GetError(), result.GetErrorSize(), ASYNC);
+ m_io_channel_ap->OutWrite (result.GetOutput(), result.GetOutputSize(), ASYNC);
+ }
+ else
+ {
+ SBStream out_stream;
+ uint32_t target_idx = GetDebugger().GetIndexOfTarget(process.GetTarget());
+ if (target_idx != UINT32_MAX)
+ out_stream.Printf ("Target %d: (", target_idx);
+ else
+ out_stream.Printf ("Target <unknown index>: (");
+ process.GetTarget().GetDescription (out_stream, eDescriptionLevelBrief);
+ out_stream.Printf (") stopped.\n");
+ m_io_channel_ap->OutWrite (out_stream.GetData(), out_stream.GetSize(), ASYNC);
+ }
}
break;
}
More information about the lldb-commits
mailing list