[llvm-branch-commits] [lldb] r200025 - Merge with top of tree.
Greg Clayton
gclayton at apple.com
Fri Jan 24 10:41:28 PST 2014
Author: gclayton
Date: Fri Jan 24 12:41:28 2014
New Revision: 200025
URL: http://llvm.org/viewvc/llvm-project?rev=200025&view=rev
Log:
Merge with top of tree.
Modified:
lldb/branches/iohandler/ (props changed)
lldb/branches/iohandler/examples/python/types.py
lldb/branches/iohandler/include/lldb/API/SBModule.h
lldb/branches/iohandler/include/lldb/API/SBType.h
lldb/branches/iohandler/include/lldb/Symbol/Type.h
lldb/branches/iohandler/include/lldb/Target/Process.h
lldb/branches/iohandler/include/lldb/Target/Thread.h
lldb/branches/iohandler/include/lldb/Target/ThreadPlanStepInRange.h
lldb/branches/iohandler/scripts/Python/interface/SBModule.i
lldb/branches/iohandler/scripts/Python/interface/SBType.i
lldb/branches/iohandler/source/API/SBModule.cpp
lldb/branches/iohandler/source/API/SBType.cpp
lldb/branches/iohandler/source/Core/Mangled.cpp
lldb/branches/iohandler/source/Core/ValueObject.cpp
lldb/branches/iohandler/source/Core/ValueObjectChild.cpp
lldb/branches/iohandler/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
lldb/branches/iohandler/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h
lldb/branches/iohandler/source/Symbol/Type.cpp
lldb/branches/iohandler/source/Target/Thread.cpp
lldb/branches/iohandler/source/Target/ThreadPlanStepInRange.cpp
lldb/branches/iohandler/test/lang/objc/foundation/TestObjCMethods.py
lldb/branches/iohandler/tools/lldb-gdbserver/lldb-gdbserver.cpp
Propchange: lldb/branches/iohandler/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Jan 24 12:41:28 2014
@@ -1,2 +1,2 @@
/lldb/branches/apple/python-GIL:156467-162159
-/lldb/trunk:198360-199911
+/lldb/trunk:198360-200024
Modified: lldb/branches/iohandler/examples/python/types.py
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/examples/python/types.py?rev=200025&r1=200024&r2=200025&view=diff
==============================================================================
--- lldb/branches/iohandler/examples/python/types.py (original)
+++ lldb/branches/iohandler/examples/python/types.py Fri Jan 24 12:41:28 2014
@@ -178,7 +178,20 @@ def check_padding_command (debugger, com
result.SetStatus (lldb.eReturnStatusFailed)
return "option parsing failed" # returning a string is the same as returning an error whose description is the string
verify_types(options, debugger.GetSelectedTarget(), command_args)
-
+
+ at lldb.command("parse_all_struct_class_types")
+def parse_all_struct_class_types (debugger, command, result, dict):
+ command_args = shlex.split(command)
+ for f in command_args:
+ error = lldb.SBError()
+ target = debugger.CreateTarget (f, None, None, False, error)
+ module = target.GetModuleAtIndex(0)
+ print "Parsing all types in '%s'" % (module)
+ types = module.GetTypes(lldb.eTypeClassClass | lldb.eTypeClassStruct)
+ for t in types:
+ print t
+ print ""
+
def verify_types (target, options):
Modified: lldb/branches/iohandler/include/lldb/API/SBModule.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/include/lldb/API/SBModule.h?rev=200025&r1=200024&r2=200025&view=diff
==============================================================================
--- lldb/branches/iohandler/include/lldb/API/SBModule.h (original)
+++ lldb/branches/iohandler/include/lldb/API/SBModule.h Fri Jan 24 12:41:28 2014
@@ -235,6 +235,25 @@ public:
lldb::SBTypeList
FindTypes (const char* type);
+ //------------------------------------------------------------------
+ /// Get a type using its type ID.
+ ///
+ /// Each symbol file reader will assign different user IDs to their
+ /// types, but it is sometimes useful when debugging type issues to
+ /// be able to grab a type using its type ID.
+ ///
+ /// For DWARF debug info, the type ID is the DIE offset.
+ ///
+ /// @param[in] uid
+ /// The type user ID.
+ ///
+ /// @return
+ /// An SBType for the given type ID, or an empty SBType if the
+ /// type was not found.
+ //------------------------------------------------------------------
+ lldb::SBType
+ GetTypeByID (lldb::user_id_t uid);
+
lldb::SBType
GetBasicType(lldb::BasicType type);
Modified: lldb/branches/iohandler/include/lldb/API/SBType.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/include/lldb/API/SBType.h?rev=200025&r1=200024&r2=200025&view=diff
==============================================================================
--- lldb/branches/iohandler/include/lldb/API/SBType.h (original)
+++ lldb/branches/iohandler/include/lldb/API/SBType.h Fri Jan 24 12:41:28 2014
@@ -106,6 +106,9 @@ public:
GetReferenceType();
lldb::SBType
+ GetTypedefedType();
+
+ lldb::SBType
GetDereferencedType();
lldb::SBType
Modified: lldb/branches/iohandler/include/lldb/Symbol/Type.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/include/lldb/Symbol/Type.h?rev=200025&r1=200024&r2=200025&view=diff
==============================================================================
--- lldb/branches/iohandler/include/lldb/Symbol/Type.h (original)
+++ lldb/branches/iohandler/include/lldb/Symbol/Type.h Fri Jan 24 12:41:28 2014
@@ -417,7 +417,15 @@ public:
return type_sp->GetClangLayoutType().GetLValueReferenceType();
return clang_type.GetLValueReferenceType();
}
-
+
+ ClangASTType
+ GetTypedefedType () const
+ {
+ if (type_sp)
+ return type_sp->GetClangFullType().GetTypedefedType();
+ return clang_type.GetTypedefedType();
+ }
+
ClangASTType
GetDereferencedType () const
{
@@ -513,6 +521,9 @@ public:
GetReferenceType () const;
TypeImpl
+ GetTypedefedType () const;
+
+ TypeImpl
GetDereferencedType () const;
TypeImpl
Modified: lldb/branches/iohandler/include/lldb/Target/Process.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/include/lldb/Target/Process.h?rev=200025&r1=200024&r2=200025&view=diff
==============================================================================
--- lldb/branches/iohandler/include/lldb/Target/Process.h (original)
+++ lldb/branches/iohandler/include/lldb/Target/Process.h Fri Jan 24 12:41:28 2014
@@ -803,6 +803,18 @@ public:
m_monitor_signals = monitor_signals;
}
+ Host::MonitorChildProcessCallback
+ GetMonitorProcessCallback ()
+ {
+ return m_monitor_callback;
+ }
+
+ const void*
+ GetMonitorProcessBaton () const
+ {
+ return m_monitor_callback_baton;
+ }
+
bool
MonitorProcess () const
{
Modified: lldb/branches/iohandler/include/lldb/Target/Thread.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/include/lldb/Target/Thread.h?rev=200025&r1=200024&r2=200025&view=diff
==============================================================================
--- lldb/branches/iohandler/include/lldb/Target/Thread.h (original)
+++ lldb/branches/iohandler/include/lldb/Target/Thread.h Fri Jan 24 12:41:28 2014
@@ -44,6 +44,9 @@ public:
const RegularExpression *
GetSymbolsToAvoidRegexp();
+ FileSpecList &
+ GetLibrariesToAvoid() const;
+
bool
GetTraceEnabledState() const;
};
Modified: lldb/branches/iohandler/include/lldb/Target/ThreadPlanStepInRange.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/include/lldb/Target/ThreadPlanStepInRange.h?rev=200025&r1=200024&r2=200025&view=diff
==============================================================================
--- lldb/branches/iohandler/include/lldb/Target/ThreadPlanStepInRange.h (original)
+++ lldb/branches/iohandler/include/lldb/Target/ThreadPlanStepInRange.h Fri Jan 24 12:41:28 2014
@@ -73,7 +73,7 @@ protected:
SetFlagsToDefault ();
bool
- FrameMatchesAvoidRegexp ();
+ FrameMatchesAvoidCriteria ();
private:
Modified: lldb/branches/iohandler/scripts/Python/interface/SBModule.i
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/scripts/Python/interface/SBModule.i?rev=200025&r1=200024&r2=200025&view=diff
==============================================================================
--- lldb/branches/iohandler/scripts/Python/interface/SBModule.i (original)
+++ lldb/branches/iohandler/scripts/Python/interface/SBModule.i Fri Jan 24 12:41:28 2014
@@ -231,6 +231,9 @@ public:
FindTypes (const char* type);
lldb::SBType
+ GetTypeByID (lldb::user_id_t uid);
+
+ lldb::SBType
GetBasicType(lldb::BasicType type);
%feature("docstring", "
Modified: lldb/branches/iohandler/scripts/Python/interface/SBType.i
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/scripts/Python/interface/SBType.i?rev=200025&r1=200024&r2=200025&view=diff
==============================================================================
--- lldb/branches/iohandler/scripts/Python/interface/SBType.i (original)
+++ lldb/branches/iohandler/scripts/Python/interface/SBType.i Fri Jan 24 12:41:28 2014
@@ -178,6 +178,9 @@ public:
GetReferenceType();
lldb::SBType
+ SBType::GetTypedefedType();
+
+ lldb::SBType
GetDereferencedType();
lldb::SBType
Modified: lldb/branches/iohandler/source/API/SBModule.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/source/API/SBModule.cpp?rev=200025&r1=200024&r2=200025&view=diff
==============================================================================
--- lldb/branches/iohandler/source/API/SBModule.cpp (original)
+++ lldb/branches/iohandler/source/API/SBModule.cpp Fri Jan 24 12:41:28 2014
@@ -579,6 +579,23 @@ SBModule::FindTypes (const char *type)
return retval;
}
+lldb::SBType
+SBModule::GetTypeByID (lldb::user_id_t uid)
+{
+ ModuleSP module_sp (GetSP ());
+ if (module_sp)
+ {
+ SymbolVendor* vendor = module_sp->GetSymbolVendor();
+ if (vendor)
+ {
+ Type *type_ptr = vendor->ResolveTypeUID(uid);
+ if (type_ptr)
+ return SBType(type_ptr->shared_from_this());
+ }
+ }
+ return SBType();
+}
+
lldb::SBTypeList
SBModule::GetTypes (uint32_t type_mask)
{
Modified: lldb/branches/iohandler/source/API/SBType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/source/API/SBType.cpp?rev=200025&r1=200024&r2=200025&view=diff
==============================================================================
--- lldb/branches/iohandler/source/API/SBType.cpp (original)
+++ lldb/branches/iohandler/source/API/SBType.cpp Fri Jan 24 12:41:28 2014
@@ -186,6 +186,14 @@ SBType::GetReferenceType()
}
SBType
+SBType::GetTypedefedType()
+{
+ if (!IsValid())
+ return SBType();
+ return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetTypedefedType())));
+}
+
+SBType
SBType::GetDereferencedType()
{
if (!IsValid())
Modified: lldb/branches/iohandler/source/Core/Mangled.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/source/Core/Mangled.cpp?rev=200025&r1=200024&r2=200025&view=diff
==============================================================================
--- lldb/branches/iohandler/source/Core/Mangled.cpp (original)
+++ lldb/branches/iohandler/source/Core/Mangled.cpp Fri Jan 24 12:41:28 2014
@@ -23,7 +23,7 @@
//----------------------------------------------------------------------
// Inlined copy of:
// http://llvm.org/svn/llvm-project/libcxxabi/trunk/src/cxa_demangle.cpp
-// revision 197169.
+// revision 199944.
//
// Changes include:
// - remove the "__cxxabiv1" namespace
@@ -2313,6 +2313,7 @@ parse_type(const char* first, const char
// ::= gt # >
// ::= ix # []
// ::= le # <=
+// ::= li <source-name> # operator ""
// ::= ls # <<
// ::= lS # <<=
// ::= lt # <
@@ -2474,6 +2475,18 @@ parse_operator_name(const char* first, c
db.names.push_back("operator<=");
first += 2;
break;
+ case 'i':
+ {
+ const char* t = parse_source_name(first+2, last, db);
+ if (t != first+2)
+ {
+ if (db.names.empty())
+ return first;
+ db.names.back().first.insert(0, "operator\"\" ");
+ first = t;
+ }
+ }
+ break;
case 's':
db.names.push_back("operator<<");
first += 2;
Modified: lldb/branches/iohandler/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/source/Core/ValueObject.cpp?rev=200025&r1=200024&r2=200025&view=diff
==============================================================================
--- lldb/branches/iohandler/source/Core/ValueObject.cpp (original)
+++ lldb/branches/iohandler/source/Core/ValueObject.cpp Fri Jan 24 12:41:28 2014
@@ -978,14 +978,14 @@ ValueObject::GetPointeeData (DataExtract
ValueObjectSP pointee_sp = Dereference(error);
if (error.Fail() || pointee_sp.get() == NULL)
return 0;
- return pointee_sp->GetDataExtractor().Copy(data);
+ return pointee_sp->GetData(data);
}
else
{
ValueObjectSP child_sp = GetChildAtIndex(0, true);
if (child_sp.get() == NULL)
return 0;
- return child_sp->GetDataExtractor().Copy(data);
+ return child_sp->GetData(data);
}
return true;
}
Modified: lldb/branches/iohandler/source/Core/ValueObjectChild.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/source/Core/ValueObjectChild.cpp?rev=200025&r1=200024&r2=200025&view=diff
==============================================================================
--- lldb/branches/iohandler/source/Core/ValueObjectChild.cpp (original)
+++ lldb/branches/iohandler/source/Core/ValueObjectChild.cpp Fri Jan 24 12:41:28 2014
@@ -208,7 +208,10 @@ ValueObjectChild::UpdateValue ()
{
const bool thread_and_frame_only_if_stopped = true;
ExecutionContext exe_ctx (GetExecutionContextRef().Lock(thread_and_frame_only_if_stopped));
- m_error = m_value.GetValueAsData (&exe_ctx, m_data, 0, GetModule().get());
+ if (GetClangType().GetTypeInfo() & ClangASTType::eTypeHasValue)
+ m_error = m_value.GetValueAsData (&exe_ctx, m_data, 0, GetModule().get());
+ else
+ m_error.Clear(); // No value so nothing to read...
}
}
else
Modified: lldb/branches/iohandler/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp?rev=200025&r1=200024&r2=200025&view=diff
==============================================================================
--- lldb/branches/iohandler/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp (original)
+++ lldb/branches/iohandler/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp Fri Jan 24 12:41:28 2014
@@ -143,6 +143,10 @@ GDBRemoteCommunicationServer::GetPacketA
packet_result = Handle_qKillSpawnedProcess (packet);
break;
+ case StringExtractorGDBRemote::eServerPacketType_k:
+ packet_result = Handle_k (packet);
+ break;
+
case StringExtractorGDBRemote::eServerPacketType_qLaunchSuccess:
packet_result = Handle_qLaunchSuccess (packet);
break;
@@ -271,6 +275,56 @@ GDBRemoteCommunicationServer::GetPacketA
return packet_result == PacketResult::Success;
}
+lldb_private::Error
+GDBRemoteCommunicationServer::SetLaunchArguments (const char *const args[], int argc)
+{
+ if ((argc < 1) || !args || !args[0] || !args[0][0])
+ return lldb_private::Error ("%s: no process command line specified to launch", __FUNCTION__);
+
+ m_process_launch_info.SetArguments (const_cast<const char**> (args), true);
+ return lldb_private::Error ();
+}
+
+lldb_private::Error
+GDBRemoteCommunicationServer::SetLaunchFlags (unsigned int launch_flags)
+{
+ m_process_launch_info.GetFlags ().Set (launch_flags);
+ return lldb_private::Error ();
+}
+
+lldb_private::Error
+GDBRemoteCommunicationServer::LaunchProcess ()
+{
+ if (!m_process_launch_info.GetArguments ().GetArgumentCount ())
+ return lldb_private::Error ("%s: no process command line specified to launch", __FUNCTION__);
+
+ // specify the process monitor if not already set. This should
+ // generally be what happens since we need to reap started
+ // processes.
+ if (!m_process_launch_info.GetMonitorProcessCallback ())
+ m_process_launch_info.SetMonitorProcessCallback(ReapDebuggedProcess, this, false);
+
+ lldb_private::Error error = Host::LaunchProcess (m_process_launch_info);
+ if (!error.Success ())
+ {
+ fprintf (stderr, "%s: failed to launch executable %s", __FUNCTION__, m_process_launch_info.GetArguments ().GetArgumentAtIndex (0));
+ return error;
+ }
+
+ printf ("Launched '%s' as process %" PRIu64 "...\n", m_process_launch_info.GetArguments ().GetArgumentAtIndex (0), m_process_launch_info.GetProcessID());
+
+ // add to list of spawned processes. On an lldb-gdbserver, we
+ // would expect there to be only one.
+ lldb::pid_t pid;
+ if ( (pid = m_process_launch_info.GetProcessID()) != LLDB_INVALID_PROCESS_ID )
+ {
+ Mutex::Locker locker (m_spawned_pids_mutex);
+ m_spawned_pids.insert(pid);
+ }
+
+ return error;
+}
+
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServer::SendUnimplementedResponse (const char *)
{
@@ -810,6 +864,26 @@ GDBRemoteCommunicationServer::ReapDebugs
return true;
}
+bool
+GDBRemoteCommunicationServer::DebuggedProcessReaped (lldb::pid_t pid)
+{
+ // reap a process that we were debugging (but not debugserver)
+ Mutex::Locker locker (m_spawned_pids_mutex);
+ return m_spawned_pids.erase(pid) > 0;
+}
+
+bool
+GDBRemoteCommunicationServer::ReapDebuggedProcess (void *callback_baton,
+ lldb::pid_t pid,
+ bool exited,
+ int signal, // Zero for no signal
+ int status) // Exit value of process if signal is zero
+{
+ GDBRemoteCommunicationServer *server = (GDBRemoteCommunicationServer *)callback_baton;
+ server->DebuggedProcessReaped (pid);
+ return true;
+}
+
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServer::Handle_qLaunchGDBServer (StringExtractorGDBRemote &packet)
{
@@ -897,57 +971,122 @@ GDBRemoteCommunicationServer::Handle_qLa
#endif
}
-GDBRemoteCommunication::PacketResult
-GDBRemoteCommunicationServer::Handle_qKillSpawnedProcess (StringExtractorGDBRemote &packet)
+bool
+GDBRemoteCommunicationServer::KillSpawnedProcess (lldb::pid_t pid)
{
- // Spawn a local debugserver as a platform so we can then attach or launch
- // a process...
-
- if (m_is_platform)
+ // make sure we know about this process
{
- packet.SetFilePos(::strlen ("qKillSpawnedProcess:"));
+ Mutex::Locker locker (m_spawned_pids_mutex);
+ if (m_spawned_pids.find(pid) == m_spawned_pids.end())
+ return false;
+ }
- lldb::pid_t pid = packet.GetU64(LLDB_INVALID_PROCESS_ID);
+ // first try a SIGTERM (standard kill)
+ Host::Kill (pid, SIGTERM);
- // Scope for locker
+ // check if that worked
+ for (size_t i=0; i<10; ++i)
+ {
{
Mutex::Locker locker (m_spawned_pids_mutex);
if (m_spawned_pids.find(pid) == m_spawned_pids.end())
- return SendErrorResponse (10);
+ {
+ // it is now killed
+ return true;
+ }
}
- Host::Kill (pid, SIGTERM);
+ usleep (10000);
+ }
+
+ // check one more time after the final usleep
+ {
+ Mutex::Locker locker (m_spawned_pids_mutex);
+ if (m_spawned_pids.find(pid) == m_spawned_pids.end())
+ return true;
+ }
+
+ // the launched process still lives. Now try killling it again,
+ // this time with an unblockable signal.
+ Host::Kill (pid, SIGKILL);
- for (size_t i=0; i<10; ++i)
+ for (size_t i=0; i<10; ++i)
+ {
{
- // Scope for locker
+ Mutex::Locker locker (m_spawned_pids_mutex);
+ if (m_spawned_pids.find(pid) == m_spawned_pids.end())
{
- Mutex::Locker locker (m_spawned_pids_mutex);
- if (m_spawned_pids.find(pid) == m_spawned_pids.end())
- return SendOKResponse();
+ // it is now killed
+ return true;
}
- usleep (10000);
}
+ usleep (10000);
+ }
+
+ // check one more time after the final usleep
+ // Scope for locker
+ {
+ Mutex::Locker locker (m_spawned_pids_mutex);
+ if (m_spawned_pids.find(pid) == m_spawned_pids.end())
+ return true;
+ }
+
+ // no luck - the process still lives
+ return false;
+}
+
+GDBRemoteCommunication::PacketResult
+GDBRemoteCommunicationServer::Handle_qKillSpawnedProcess (StringExtractorGDBRemote &packet)
+{
+ packet.SetFilePos(::strlen ("qKillSpawnedProcess:"));
+
+ lldb::pid_t pid = packet.GetU64(LLDB_INVALID_PROCESS_ID);
- // Scope for locker
+ // verify that we know anything about this pid.
+ // Scope for locker
+ {
+ Mutex::Locker locker (m_spawned_pids_mutex);
+ if (m_spawned_pids.find(pid) == m_spawned_pids.end())
{
- Mutex::Locker locker (m_spawned_pids_mutex);
- if (m_spawned_pids.find(pid) == m_spawned_pids.end())
- return SendOKResponse();
+ // not a pid we know about
+ return SendErrorResponse (10);
}
- Host::Kill (pid, SIGKILL);
+ }
- for (size_t i=0; i<10; ++i)
+ // go ahead and attempt to kill the spawned process
+ if (KillSpawnedProcess (pid))
+ return SendOKResponse ();
+ else
+ return SendErrorResponse (11);
+}
+
+GDBRemoteCommunication::PacketResult
+GDBRemoteCommunicationServer::Handle_k (StringExtractorGDBRemote &packet)
+{
+ // ignore for now if we're lldb_platform
+ if (m_is_platform)
+ return SendUnimplementedResponse (packet.GetStringRef().c_str());
+
+ // shutdown all spawned processes
+ std::set<lldb::pid_t> spawned_pids_copy;
+
+ // copy pids
+ {
+ Mutex::Locker locker (m_spawned_pids_mutex);
+ spawned_pids_copy.insert (m_spawned_pids.begin (), m_spawned_pids.end ());
+ }
+
+ // nuke the spawned processes
+ for (auto it = spawned_pids_copy.begin (); it != spawned_pids_copy.end (); ++it)
+ {
+ lldb::pid_t spawned_pid = *it;
+ if (!KillSpawnedProcess (spawned_pid))
{
- // Scope for locker
- {
- Mutex::Locker locker (m_spawned_pids_mutex);
- if (m_spawned_pids.find(pid) == m_spawned_pids.end())
- return SendOKResponse();
- }
- usleep (10000);
+ fprintf (stderr, "%s: failed to kill spawned pid %" PRIu64 ", ignoring.\n", __FUNCTION__, spawned_pid);
}
}
- return SendErrorResponse (11);
+
+ // TODO figure out how to shut down gracefully at this point
+ return SendOKResponse ();
}
GDBRemoteCommunication::PacketResult
Modified: lldb/branches/iohandler/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h?rev=200025&r1=200024&r2=200025&view=diff
==============================================================================
--- lldb/branches/iohandler/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h (original)
+++ lldb/branches/iohandler/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h Fri Jan 24 12:41:28 2014
@@ -138,6 +138,53 @@ public:
m_port_offset = port_offset;
}
+ //------------------------------------------------------------------
+ /// Specify the program to launch and its arguments.
+ ///
+ /// The LaunchProcess () command can be executed to do the lauching.
+ ///
+ /// @param[in] args
+ /// The command line to launch.
+ ///
+ /// @param[in] argc
+ /// The number of elements in the args array of cstring pointers.
+ ///
+ /// @return
+ /// An Error object indicating the success or failure of making
+ /// the setting.
+ //------------------------------------------------------------------
+ lldb_private::Error
+ SetLaunchArguments (const char *const args[], int argc);
+
+ //------------------------------------------------------------------
+ /// Specify the launch flags for the process.
+ ///
+ /// The LaunchProcess () command can be executed to do the lauching.
+ ///
+ /// @param[in] launch_flags
+ /// The launch flags to use when launching this process.
+ ///
+ /// @return
+ /// An Error object indicating the success or failure of making
+ /// the setting.
+ //------------------------------------------------------------------
+ lldb_private::Error
+ SetLaunchFlags (unsigned int launch_flags);
+
+ //------------------------------------------------------------------
+ /// Launch a process with the current launch settings.
+ ///
+ /// This method supports running an lldb-gdbserver or similar
+ /// server in a situation where the startup code has been provided
+ /// with all the information for a child process to be launched.
+ ///
+ /// @return
+ /// An Error object indicating the success or failure of the
+ /// launch.
+ //------------------------------------------------------------------
+ lldb_private::Error
+ LaunchProcess ();
+
protected:
lldb::thread_t m_async_thread;
lldb_private::ProcessLaunchInfo m_process_launch_info;
@@ -175,6 +222,9 @@ protected:
Handle_qKillSpawnedProcess (StringExtractorGDBRemote &packet);
PacketResult
+ Handle_k (StringExtractorGDBRemote &packet);
+
+ PacketResult
Handle_qPlatform_mkdir (StringExtractorGDBRemote &packet);
PacketResult
@@ -275,6 +325,19 @@ private:
int signal,
int status);
+ bool
+ DebuggedProcessReaped (lldb::pid_t pid);
+
+ static bool
+ ReapDebuggedProcess (void *callback_baton,
+ lldb::pid_t pid,
+ bool exited,
+ int signal,
+ int status);
+
+ bool
+ KillSpawnedProcess (lldb::pid_t pid);
+
//------------------------------------------------------------------
// For GDBRemoteCommunicationServer only
//------------------------------------------------------------------
Modified: lldb/branches/iohandler/source/Symbol/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/source/Symbol/Type.cpp?rev=200025&r1=200024&r2=200025&view=diff
==============================================================================
--- lldb/branches/iohandler/source/Symbol/Type.cpp (original)
+++ lldb/branches/iohandler/source/Symbol/Type.cpp Fri Jan 24 12:41:28 2014
@@ -1084,6 +1084,16 @@ TypeImpl::GetReferenceType () const
}
TypeImpl
+TypeImpl::GetTypedefedType () const
+{
+ if (m_dynamic_type.IsValid())
+ {
+ return TypeImpl(m_static_type, m_dynamic_type.GetTypedefedType());
+ }
+ return TypeImpl(m_static_type.GetTypedefedType());
+}
+
+TypeImpl
TypeImpl::GetDereferencedType () const
{
if (m_dynamic_type.IsValid())
Modified: lldb/branches/iohandler/source/Target/Thread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/source/Target/Thread.cpp?rev=200025&r1=200024&r2=200025&view=diff
==============================================================================
--- lldb/branches/iohandler/source/Target/Thread.cpp (original)
+++ lldb/branches/iohandler/source/Target/Thread.cpp Fri Jan 24 12:41:28 2014
@@ -18,6 +18,7 @@
#include "lldb/Core/StreamString.h"
#include "lldb/Core/RegularExpression.h"
#include "lldb/Host/Host.h"
+#include "lldb/Interpreter/OptionValueFileSpecList.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Target/DynamicLoader.h"
#include "lldb/Target/ExecutionContext.h"
@@ -61,12 +62,14 @@ static PropertyDefinition
g_properties[] =
{
{ "step-avoid-regexp", OptionValue::eTypeRegex , true , REG_EXTENDED, "^std::", NULL, "A regular expression defining functions step-in won't stop in." },
+ { "step-avoid-libraries", OptionValue::eTypeFileSpecList , true , REG_EXTENDED, NULL, NULL, "A list of libraries that source stepping won't stop in." },
{ "trace-thread", OptionValue::eTypeBoolean, false, false, NULL, NULL, "If true, this thread will single-step and log execution." },
{ NULL , OptionValue::eTypeInvalid, false, 0 , NULL, NULL, NULL }
};
enum {
ePropertyStepAvoidRegex,
+ ePropertyStepAvoidLibraries,
ePropertyEnableThreadTrace
};
@@ -132,6 +135,15 @@ ThreadProperties::GetSymbolsToAvoidRegex
return m_collection_sp->GetPropertyAtIndexAsOptionValueRegex (NULL, idx);
}
+FileSpecList &
+ThreadProperties::GetLibrariesToAvoid() const
+{
+ const uint32_t idx = ePropertyStepAvoidLibraries;
+ OptionValueFileSpecList *option_value = m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList (NULL, false, idx);
+ assert(option_value);
+ return option_value->GetCurrentValue();
+}
+
bool
ThreadProperties::GetTraceEnabledState() const
{
Modified: lldb/branches/iohandler/source/Target/ThreadPlanStepInRange.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/source/Target/ThreadPlanStepInRange.cpp?rev=200025&r1=200024&r2=200025&view=diff
==============================================================================
--- lldb/branches/iohandler/source/Target/ThreadPlanStepInRange.cpp (original)
+++ lldb/branches/iohandler/source/Target/ThreadPlanStepInRange.cpp Fri Jan 24 12:41:28 2014
@@ -16,6 +16,7 @@
#include "lldb/lldb-private-log.h"
#include "lldb/Core/Log.h"
+#include "lldb/Core/Module.h"
#include "lldb/Core/Stream.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Symbol/Function.h"
@@ -273,10 +274,36 @@ ThreadPlanStepInRange::SetDefaultFlagVal
}
bool
-ThreadPlanStepInRange::FrameMatchesAvoidRegexp ()
+ThreadPlanStepInRange::FrameMatchesAvoidCriteria ()
{
StackFrame *frame = GetThread().GetStackFrameAtIndex(0).get();
+
+ // Check the library list first, as that's cheapest:
+ bool libraries_say_avoid = false;
+ FileSpecList libraries_to_avoid (GetThread().GetLibrariesToAvoid());
+ size_t num_libraries = libraries_to_avoid.GetSize();
+ if (num_libraries > 0)
+ {
+ SymbolContext sc(frame->GetSymbolContext(eSymbolContextModule));
+ FileSpec frame_library(sc.module_sp->GetFileSpec());
+
+ if (frame_library)
+ {
+ for (size_t i = 0; i < num_libraries; i++)
+ {
+ const FileSpec &file_spec(libraries_to_avoid.GetFileSpecAtIndex(i));
+ if (FileSpec::Equal (file_spec, frame_library, false))
+ {
+ libraries_say_avoid = true;
+ break;
+ }
+ }
+ }
+ }
+ if (libraries_say_avoid)
+ return true;
+
const RegularExpression *avoid_regexp_to_use = m_avoid_regexp_ap.get();
if (avoid_regexp_to_use == NULL)
avoid_regexp_to_use = GetThread().GetSymbolsToAvoidRegexp();
@@ -368,8 +395,8 @@ ThreadPlanStepInRange::DefaultShouldStop
if (!should_step_out)
{
ThreadPlanStepInRange *step_in_range_plan = static_cast<ThreadPlanStepInRange *> (current_plan);
- // Don't log the should_step_out here, it's easier to do it in FrameMatchesAvoidRegexp.
- should_step_out = step_in_range_plan->FrameMatchesAvoidRegexp ();
+ // Don't log the should_step_out here, it's easier to do it in FrameMatchesAvoidCriteria.
+ should_step_out = step_in_range_plan->FrameMatchesAvoidCriteria ();
}
}
Modified: lldb/branches/iohandler/test/lang/objc/foundation/TestObjCMethods.py
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/test/lang/objc/foundation/TestObjCMethods.py?rev=200025&r1=200024&r2=200025&view=diff
==============================================================================
--- lldb/branches/iohandler/test/lang/objc/foundation/TestObjCMethods.py (original)
+++ lldb/branches/iohandler/test/lang/objc/foundation/TestObjCMethods.py Fri Jan 24 12:41:28 2014
@@ -143,7 +143,7 @@ class FoundationTestCase(TestBase):
self.runCmd("log disable dwarf lookups")
def cleanup():
- sys.unlink (logfile)
+ os.unlink (logfile)
self.addTearDownHook(cleanup)
Modified: lldb/branches/iohandler/tools/lldb-gdbserver/lldb-gdbserver.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/iohandler/tools/lldb-gdbserver/lldb-gdbserver.cpp?rev=200025&r1=200024&r2=200025&view=diff
==============================================================================
--- lldb/branches/iohandler/tools/lldb-gdbserver/lldb-gdbserver.cpp (original)
+++ lldb/branches/iohandler/tools/lldb-gdbserver/lldb-gdbserver.cpp Fri Jan 24 12:41:28 2014
@@ -105,7 +105,7 @@ main (int argc, char *argv[])
debugger_sp->SetOutputFileHandle(stdout, false);
debugger_sp->SetErrorFileHandle(stderr, false);
- ProcessLaunchInfo launch_info;
+ // ProcessLaunchInfo launch_info;
ProcessAttachInfo attach_info;
bool show_usage = false;
@@ -210,6 +210,9 @@ main (int argc, char *argv[])
puts (output);
}
+ const bool is_platform = false;
+ GDBRemoteCommunicationServer gdb_server (is_platform);
+
const char *host_and_port = argv[0];
argc -= 1;
argv += 1;
@@ -218,31 +221,33 @@ main (int argc, char *argv[])
// to launch a program, or a vAttach packet to attach to an existing process.
if (argc > 0)
{
- // Launch the program specified on the command line
- launch_info.SetArguments((const char **)argv, true);
+ error = gdb_server.SetLaunchArguments (argv, argc);
+ if (error.Fail ())
+ {
+ fprintf (stderr, "error: failed to set launch args for '%s': %s\n", argv[0], error.AsCString());
+ exit(1);
+ }
unsigned int launch_flags = eLaunchFlagStopAtEntry;
#if !defined(__linux__)
// linux doesn't yet handle eLaunchFlagDebug
launch_flags |= eLaunchFlagDebug;
#endif
- launch_info.GetFlags ().Set (launch_flags);
- error = Host::LaunchProcess (launch_info);
-
- if (error.Success())
+ error = gdb_server.SetLaunchFlags (launch_flags);
+ if (error.Fail ())
{
- printf ("Launched '%s' as process %" PRIu64 "...\n", argv[0], launch_info.GetProcessID());
+ fprintf (stderr, "error: failed to set launch flags for '%s': %s\n", argv[0], error.AsCString());
+ exit(1);
}
- else
+
+ error = gdb_server.LaunchProcess ();
+ if (error.Fail ())
{
fprintf (stderr, "error: failed to launch '%s': %s\n", argv[0], error.AsCString());
exit(1);
}
}
-
- const bool is_platform = false;
- GDBRemoteCommunicationServer gdb_server (is_platform);
-
+
if (host_and_port && host_and_port[0])
{
std::unique_ptr<ConnectionFileDescriptor> conn_ap(new ConnectionFileDescriptor());
@@ -271,7 +276,7 @@ main (int argc, char *argv[])
if (!gdb_server.GetPacketAndSendResponse (UINT32_MAX, error, interrupt, done))
break;
}
-
+
if (error.Fail())
{
fprintf(stderr, "error: %s\n", error.AsCString());
More information about the llvm-branch-commits
mailing list