HandleBroadcastEvent (const lldb::SBEvent &event);
protected:
+ friend class SBAttachInfo;
friend class SBBroadcaster;
friend class SBCommandInterpreter;
friend class SBDebugger;
+ friend class SBLaunchInfo;
friend class SBTarget;
SBListener (lldb_private::Listener &listener);
+ SBListener (const lldb::ListenerSP &listener_sp);
+
+ lldb::ListenerSP
+ GetSP ()
+ {
+ return m_opaque_sp;
+ }
+
private:
lldb_private::Listener *
SBFileSpec
GetExecutableFile ();
-
+
//----------------------------------------------------------------------
/// Set the executable file that will be used to launch the process and
/// optionally set it as the first argument in the argument vector.
//----------------------------------------------------------------------
void
SetExecutableFile (SBFileSpec exe_file, bool add_as_first_arg);
-
+
+
+ //----------------------------------------------------------------------
+ /// Get the listener that will be used to receive process events.
+ ///
+ /// If no listener has been set via a call to
+ /// SBLaunchInfo::SetListener(), then an invalid SBListener will be
+ /// returned (SBListener::IsValid() will return false). If a listener
+ /// has been set, then the valid listener object will be returned.
+ //----------------------------------------------------------------------
+ SBListener
+ GetListener ();
+
+ //----------------------------------------------------------------------
+ /// Set the listener that will be used to receive process events.
+ ///
+ /// By default the SBDebugger, which has a listener, that the SBTarget
+ /// belongs to will listen for the process events. Calling this function
+ /// allows a different listener to be used to listen for process events.
+ //----------------------------------------------------------------------
+ void
+ SetListener (SBListener &listener);
+
uint32_t
GetNumArguments ();
bool
ParentProcessIDIsValid();
-
+
+ //----------------------------------------------------------------------
+ /// Get the listener that will be used to receive process events.
+ ///
+ /// If no listener has been set via a call to
+ /// SBLaunchInfo::SetListener(), then an invalid SBListener will be
+ /// returned (SBListener::IsValid() will return false). If a listener
+ /// has been set, then the valid listener object will be returned.
+ //----------------------------------------------------------------------
+ SBListener
+ GetListener ();
+
+ //----------------------------------------------------------------------
+ /// Set the listener that will be used to receive process events.
+ ///
+ /// By default the SBDebugger, which has a listener, that the SBTarget
+ /// belongs to will listen for the process events. Calling this function
+ /// allows a different listener to be used to listen for process events.
+ //----------------------------------------------------------------------
+ void
+ SetListener (SBListener &listener);
+
protected:
friend class SBTarget;
/// a suitable executable, \b false otherwise.
//------------------------------------------------------------------
virtual Error
- ResolveExecutable (const FileSpec &exe_file,
- const ArchSpec &arch,
+ ResolveExecutable (const ModuleSpec &module_spec,
lldb::ModuleSP &module_sp,
const FileSpecList *module_search_paths_ptr);
DebugProcess (ProcessLaunchInfo &launch_info,
Debugger &debugger,
Target *target, // Can be NULL, if NULL create a new target, else use existing one
- Listener &listener,
Error &error);
//------------------------------------------------------------------
Attach (ProcessAttachInfo &attach_info,
Debugger &debugger,
Target *target, // Can be NULL, if NULL create a new target, else use existing one
- Listener &listener,
Error &error) = 0;
//------------------------------------------------------------------
public:
ProcessAttachInfo() :
ProcessInstanceInfo(),
+ m_listener_sp(),
+ m_hijack_listener_sp(),
m_plugin_name (),
m_resume_count (0),
m_wait_for_launch (false),
ProcessAttachInfo (const ProcessLaunchInfo &launch_info) :
ProcessInstanceInfo(),
+ m_listener_sp(),
+ m_hijack_listener_sp(),
m_plugin_name (),
m_resume_count (0),
m_wait_for_launch (false),
ProcessInfo::operator= (launch_info);
SetProcessPluginName (launch_info.GetProcessPluginName());
SetResumeCount (launch_info.GetResumeCount());
+ SetListener(launch_info.GetListener());
SetHijackListener(launch_info.GetHijackListener());
m_detach_on_error = launch_info.GetDetachOnError();
}
{
m_detach_on_error = enable;
}
-
+
+ // Get and set the actual listener that will be used for the process events
+ lldb::ListenerSP
+ GetListener () const
+ {
+ return m_listener_sp;
+ }
+
+ void
+ SetListener (const lldb::ListenerSP &listener_sp)
+ {
+ m_listener_sp = listener_sp;
+ }
+
+
+ Listener &
+ GetListenerForProcess (Debugger &debugger);
+
protected:
+ lldb::ListenerSP m_listener_sp;
lldb::ListenerSP m_hijack_listener_sp;
std::string m_plugin_name;
uint32_t m_resume_count; // How many times do we resume after launching
return *m_pty;
}
+ // Get and set the actual listener that will be used for the process events
+ lldb::ListenerSP
+ GetListener () const
+ {
+ return m_listener_sp;
+ }
+
+ void
+ SetListener (const lldb::ListenerSP &listener_sp)
+ {
+ m_listener_sp = listener_sp;
+ }
+
+ Listener &
+ GetListenerForProcess (Debugger &debugger);
+
lldb::ListenerSP
GetHijackListener () const
{
m_hijack_listener_sp = listener_sp;
}
-
void
SetLaunchEventData (const char *data)
{
void *m_monitor_callback_baton;
bool m_monitor_signals;
std::string m_event_data; // A string passed to the plugin launch, having no meaning to the upper levels of lldb.
+ lldb::ListenerSP m_listener_sp;
lldb::ListenerSP m_hijack_listener_sp;
};
}
Destroy();
Error
- Launch (Listener &listener,
- ProcessLaunchInfo &launch_info,
+ Launch (ProcessLaunchInfo &launch_info,
Stream *stream); // Optional stream to receive first stop info
//------------------------------------------------------------------
lldb::addr_t load_addr,
bool warn_multiple = false);
+ size_t
+ UnloadModuleSections (const lldb::ModuleSP &module_sp);
+
+ size_t
+ UnloadModuleSections (const ModuleList &module_list);
+
bool
SetSectionUnloaded (const lldb::SectionSP §ion_sp);
void
SetExecutableFile (lldb::SBFileSpec exe_file, bool add_as_first_arg);
+ lldb::SBListener
+ GetListener ();
+
+ void
+ SetListener (lldb::SBListener &listener);
+
uint32_t
GetNumArguments ();
bool
ParentProcessIDIsValid();
+
+ lldb::SBListener
+ GetListener ();
+
+ void
+ SetListener (lldb::SBListener &listener);
};
{
}
+SBListener::SBListener (const lldb::ListenerSP &listener_sp) :
+ m_opaque_sp (listener_sp),
+ m_opaque_ptr (listener_sp.get())
+{
+}
+
SBListener::~SBListener ()
{
}
m_opaque_sp->SetExecutableFile(exe_file.ref(), add_as_first_arg);
}
+SBListener
+SBLaunchInfo::GetListener ()
+{
+ return SBListener(m_opaque_sp->GetListener());
+}
+
+void
+SBLaunchInfo::SetListener (SBListener &listener)
+{
+ m_opaque_sp->SetListener(listener.GetSP());
+}
+
uint32_t
SBLaunchInfo::GetNumArguments ()
{
return m_opaque_sp->ParentProcessIDIsValid();
}
+SBListener
+SBAttachInfo::GetListener ()
+{
+ return SBListener(m_opaque_sp->GetListener());
+}
+
+void
+SBAttachInfo::SetListener (SBListener &listener)
+{
+ m_opaque_sp->SetListener(listener.GetSP());
+}
//----------------------------------------------------------------------
// SBTarget constructor
launch_info.GetEnvironmentEntries ().SetArguments (envp);
if (listener.IsValid())
- error.SetError (target_sp->Launch(listener.ref(), launch_info, NULL));
- else
- error.SetError (target_sp->Launch(target_sp->GetDebugger().GetListener(), launch_info, NULL));
+ launch_info.SetListener(listener.GetSP());
+
+ error.SetError (target_sp->Launch(launch_info, NULL));
sb_process.SetSP(target_sp->GetProcessSP());
}
if (arch_spec.IsValid())
launch_info.GetArchitecture () = arch_spec;
- error.SetError (target_sp->Launch (target_sp->GetDebugger().GetListener(), launch_info, NULL));
+ error.SetError (target_sp->Launch (launch_info, NULL));
sb_process.SetSP(target_sp->GetProcessSP());
}
else
ProcessSP process_sp (platform_sp->DebugProcess (m_options.launch_info,
debugger,
target,
- debugger.GetListener(),
error));
if (process_sp && process_sp->IsAlive())
{
{
Error err;
ProcessSP remote_process_sp =
- platform_sp->Attach(m_options.attach_info, m_interpreter.GetDebugger(), NULL, m_interpreter.GetDebugger().GetListener(), err);
+ platform_sp->Attach(m_options.attach_info, m_interpreter.GetDebugger(), NULL, err);
if (err.Fail())
{
result.AppendError(err.AsCString());
}
StreamString stream;
- Error error = target->Launch(debugger.GetListener(), m_options.launch_info, &stream);
+ Error error = target->Launch(m_options.launch_info, &stream);
if (error.Success())
{
#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
+#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/StreamString.h"
#include "lldb/Host/ConnectionFileDescriptor.h"
Error error;
char exe_path[PATH_MAX];
PlatformSP host_platform_sp (Platform::GetHostPlatform ());
-
- const ArchSpec &arch_spec = launch_info.GetArchitecture();
-
- FileSpec exe_spec(launch_info.GetExecutableFile());
-
- FileSpec::FileType file_type = exe_spec.GetFileType();
+
+ ModuleSpec exe_module_spec(launch_info.GetExecutableFile(), launch_info.GetArchitecture());
+
+ FileSpec::FileType file_type = exe_module_spec.GetFileSpec().GetFileType();
if (file_type != FileSpec::eFileTypeRegular)
{
lldb::ModuleSP exe_module_sp;
- error = host_platform_sp->ResolveExecutable (exe_spec,
- arch_spec,
+ error = host_platform_sp->ResolveExecutable (exe_module_spec,
exe_module_sp,
NULL);
return error;
if (exe_module_sp)
- exe_spec = exe_module_sp->GetFileSpec();
+ exe_module_spec.GetFileSpec() = exe_module_sp->GetFileSpec();
}
- if (exe_spec.Exists())
+ if (exe_module_spec.GetFileSpec().Exists())
{
- exe_spec.GetPath (exe_path, sizeof(exe_path));
+ exe_module_spec.GetFileSpec().GetPath (exe_path, sizeof(exe_path));
}
else
{
Error
-PlatformFreeBSD::ResolveExecutable (const FileSpec &exe_file,
- const ArchSpec &exe_arch,
+PlatformFreeBSD::ResolveExecutable (const ModuleSpec &module_spec,
lldb::ModuleSP &exe_module_sp,
const FileSpecList *module_search_paths_ptr)
{
// Nothing special to do here, just use the actual file and architecture
char exe_path[PATH_MAX];
- FileSpec resolved_exe_file (exe_file);
+ ModuleSpec resolved_module_spec(module_spec);
if (IsHost())
{
- // If we have "ls" as the exe_file, resolve the executable location based on
+ // If we have "ls" as the module_spec's file, resolve the executable location based on
// the current path variables
- if (!resolved_exe_file.Exists())
+ if (!resolved_module_spec.GetFileSpec().Exists())
{
- exe_file.GetPath(exe_path, sizeof(exe_path));
- resolved_exe_file.SetFile(exe_path, true);
+ module_spec.GetFileSpec().GetPath(exe_path, sizeof(exe_path));
+ resolved_module_spec.GetFileSpec().SetFile(exe_path, true);
}
- if (!resolved_exe_file.Exists())
- resolved_exe_file.ResolveExecutableLocation ();
+ if (!resolved_module_spec.GetFileSpec().Exists())
+ resolved_module_spec.GetFileSpec().ResolveExecutableLocation ();
- if (resolved_exe_file.Exists())
+ if (resolved_module_spec.GetFileSpec().Exists())
error.Clear();
else
{
- exe_file.GetPath(exe_path, sizeof(exe_path));
- error.SetErrorStringWithFormat("unable to find executable for '%s'", exe_path);
+ error.SetErrorStringWithFormat("unable to find executable for '%s'", resolved_module_spec.GetFileSpec().GetPath().c_str());
}
}
else
{
if (m_remote_platform_sp)
{
- error = m_remote_platform_sp->ResolveExecutable (exe_file,
- exe_arch,
+ error = m_remote_platform_sp->ResolveExecutable (module_spec,
exe_module_sp,
module_search_paths_ptr);
}
// We may connect to a process and use the provided executable (Don't use local $PATH).
// Resolve any executable within a bundle on MacOSX
- Host::ResolveExecutableInBundle (resolved_exe_file);
+ Host::ResolveExecutableInBundle (resolved_module_spec.GetFileSpec());
- if (resolved_exe_file.Exists()) {
+ if (resolved_module_spec.GetFileSpec().Exists())
+ {
error.Clear();
}
else
{
- exe_file.GetPath(exe_path, sizeof(exe_path));
- error.SetErrorStringWithFormat("the platform is not currently connected, and '%s' doesn't exist in the system root.", exe_path);
+ error.SetErrorStringWithFormat("the platform is not currently connected, and '%s' doesn't exist in the system root.", resolved_module_spec.GetFileSpec().GetPath().c_str());
}
}
}
if (error.Success())
{
- ModuleSpec module_spec (resolved_exe_file, exe_arch);
- if (module_spec.GetArchitecture().IsValid())
+ if (resolved_module_spec.GetArchitecture().IsValid())
{
- error = ModuleList::GetSharedModule (module_spec,
+ error = ModuleList::GetSharedModule (resolved_module_spec,
exe_module_sp,
module_search_paths_ptr,
NULL,
{
exe_module_sp.reset();
error.SetErrorStringWithFormat ("'%s' doesn't contain the architecture %s",
- exe_file.GetPath().c_str(),
- exe_arch.GetArchitectureName());
+ resolved_module_spec.GetFileSpec().GetPath().c_str(),
+ resolved_module_spec.GetArchitecture().GetArchitectureName());
}
}
else
// the architectures that we should be using (in the correct order)
// and see if we can find a match that way
StreamString arch_names;
- ArchSpec platform_arch;
- for (uint32_t idx = 0; GetSupportedArchitectureAtIndex (idx, platform_arch); ++idx)
+ for (uint32_t idx = 0; GetSupportedArchitectureAtIndex (idx, resolved_module_spec.GetArchitecture()); ++idx)
{
- error = ModuleList::GetSharedModule (module_spec,
+ error = ModuleList::GetSharedModule (resolved_module_spec,
exe_module_sp,
module_search_paths_ptr,
NULL,
if (idx > 0)
arch_names.PutCString (", ");
- arch_names.PutCString (platform_arch.GetArchitectureName());
+ arch_names.PutCString (resolved_module_spec.GetArchitecture().GetArchitectureName());
}
if (error.Fail() || !exe_module_sp)
{
- if (exe_file.Readable())
+ if (resolved_module_spec.GetFileSpec().Readable())
{
error.SetErrorStringWithFormat ("'%s' doesn't contain any '%s' platform architectures: %s",
- exe_file.GetPath().c_str(),
+ resolved_module_spec.GetFileSpec().GetPath().c_str(),
GetPluginName().GetCString(),
arch_names.GetString().c_str());
}
else
{
- error.SetErrorStringWithFormat("'%s' is not readable", exe_file.GetPath().c_str());
+ error.SetErrorStringWithFormat("'%s' is not readable", resolved_module_spec.GetFileSpec().GetPath().c_str());
}
}
}
PlatformFreeBSD::Attach(ProcessAttachInfo &attach_info,
Debugger &debugger,
Target *target,
- Listener &listener,
Error &error)
{
lldb::ProcessSP process_sp;
// The freebsd always currently uses the GDB remote debugger plug-in
// so even when debugging locally we are debugging remotely!
// Just like the darwin plugin.
- process_sp = target->CreateProcess (listener, "gdb-remote", NULL);
+ process_sp = target->CreateProcess (attach_info.GetListenerForProcess(debugger), "gdb-remote", NULL);
if (process_sp)
error = process_sp->Attach (attach_info);
else
{
if (m_remote_platform_sp)
- process_sp = m_remote_platform_sp->Attach (attach_info, debugger, target, listener, error);
+ process_sp = m_remote_platform_sp->Attach (attach_info, debugger, target, error);
else
error.SetErrorString ("the platform is not currently connected");
}
uint32_t timeout_sec);
virtual lldb_private::Error
- ResolveExecutable (const lldb_private::FileSpec &exe_file,
- const lldb_private::ArchSpec &arch,
+ ResolveExecutable (const lldb_private::ModuleSpec &module_spec,
lldb::ModuleSP &module_sp,
const lldb_private::FileSpecList *module_search_paths_ptr);
Attach(lldb_private::ProcessAttachInfo &attach_info,
lldb_private::Debugger &debugger,
lldb_private::Target *target,
- lldb_private::Listener &listener,
lldb_private::Error &error);
// FreeBSD processes can not be launched by spawning and attaching.
}
Error
-PlatformKalimba::ResolveExecutable (const FileSpec &exe_file,
- const ArchSpec &exe_arch,
- lldb::ModuleSP &exe_module_sp,
- const FileSpecList *module_search_paths_ptr)
+PlatformKalimba::ResolveExecutable (const ModuleSpec &ms,
+ lldb::ModuleSP &exe_module_sp,
+ const FileSpecList *module_search_paths_ptr)
{
Error error;
char exe_path[PATH_MAX];
- FileSpec resolved_exe_file (exe_file);
+ ModuleSpec resolved_module_spec(ms);
- if (!resolved_exe_file.Exists())
+ if (!resolved_module_spec.GetFileSpec().Exists())
{
- exe_file.GetPath(exe_path, sizeof(exe_path));
+ resolved_module_spec.GetFileSpec().GetPath(exe_path, sizeof(exe_path));
error.SetErrorStringWithFormat("unable to find executable for '%s'", exe_path);
}
if (error.Success())
{
- ModuleSpec module_spec (resolved_exe_file, exe_arch);
- if (exe_arch.IsValid())
+ if (resolved_module_spec.GetArchitecture().IsValid())
{
- error = ModuleList::GetSharedModule (module_spec,
+ error = ModuleList::GetSharedModule (resolved_module_spec,
exe_module_sp,
NULL,
NULL,
{
// If we failed, it may be because the vendor and os aren't known. If that is the
// case, try setting them to the host architecture and give it another try.
- llvm::Triple &module_triple = module_spec.GetArchitecture().GetTriple();
+ llvm::Triple &module_triple = resolved_module_spec.GetArchitecture().GetTriple();
bool is_vendor_specified = (module_triple.getVendor() != llvm::Triple::UnknownVendor);
bool is_os_specified = (module_triple.getOS() != llvm::Triple::UnknownOS);
if (!is_vendor_specified || !is_os_specified)
if (!is_os_specified)
module_triple.setOSName (host_triple.getOSName());
- error = ModuleList::GetSharedModule (module_spec,
+ error = ModuleList::GetSharedModule (resolved_module_spec,
exe_module_sp,
NULL,
NULL,
{
exe_module_sp.reset();
error.SetErrorStringWithFormat ("'%s' doesn't contain the architecture %s",
- exe_file.GetPath().c_str(),
- exe_arch.GetArchitectureName());
+ resolved_module_spec.GetFileSpec().GetPath().c_str(),
+ resolved_module_spec.GetArchitecture().GetArchitectureName());
}
}
else
// the architectures that we should be using (in the correct order)
// and see if we can find a match that way
StreamString arch_names;
- for (uint32_t idx = 0; GetSupportedArchitectureAtIndex (idx, module_spec.GetArchitecture()); ++idx)
+ for (uint32_t idx = 0; GetSupportedArchitectureAtIndex (idx, resolved_module_spec.GetArchitecture()); ++idx)
{
- error = ModuleList::GetSharedModule (module_spec,
+ error = ModuleList::GetSharedModule (resolved_module_spec,
exe_module_sp,
NULL,
NULL,
if (idx > 0)
arch_names.PutCString (", ");
- arch_names.PutCString (module_spec.GetArchitecture().GetArchitectureName());
+ arch_names.PutCString (resolved_module_spec.GetArchitecture().GetArchitectureName());
}
if (error.Fail() || !exe_module_sp)
{
- if (exe_file.Readable())
+ if (resolved_module_spec.GetFileSpec().Readable())
{
error.SetErrorStringWithFormat ("'%s' doesn't contain any '%s' platform architectures: %s",
- exe_file.GetPath().c_str(),
+ resolved_module_spec.GetFileSpec().GetPath().c_str(),
GetPluginName().GetCString(),
arch_names.GetString().c_str());
}
else
{
- error.SetErrorStringWithFormat("'%s' is not readable", exe_file.GetPath().c_str());
+ error.SetErrorStringWithFormat("'%s' is not readable", resolved_module_spec.GetFileSpec().GetPath().c_str());
}
}
}
lldb::ProcessSP
PlatformKalimba::Attach(ProcessAttachInfo &attach_info,
- Debugger &debugger,
- Target *target,
- Listener &listener,
- Error &error)
+ Debugger &debugger,
+ Target *target,
+ Error &error)
{
lldb::ProcessSP process_sp;
if (IsHost())
else
{
if (m_remote_platform_sp)
- process_sp = m_remote_platform_sp->Attach (attach_info, debugger, target, listener, error);
+ process_sp = m_remote_platform_sp->Attach (attach_info, debugger, target, error);
else
error.SetErrorString ("the platform is not currently connected");
}
// lldb_private::Platform functions
//------------------------------------------------------------
virtual Error
- ResolveExecutable (const FileSpec &exe_file,
- const ArchSpec &arch,
+ ResolveExecutable (const lldb_private::ModuleSpec &module_spec,
lldb::ModuleSP &module_sp,
const FileSpecList *module_search_paths_ptr) override;
virtual lldb::ProcessSP
Attach(ProcessAttachInfo &attach_info, Debugger &debugger,
- Target *target, Listener &listener, Error &error) override;
+ Target *target, Error &error) override;
// Kalimba processes can not be launched by spawning and attaching.
virtual bool
}
Error
-PlatformLinux::ResolveExecutable (const FileSpec &exe_file,
- const ArchSpec &exe_arch,
+PlatformLinux::ResolveExecutable (const ModuleSpec &ms,
lldb::ModuleSP &exe_module_sp,
const FileSpecList *module_search_paths_ptr)
{
// Nothing special to do here, just use the actual file and architecture
char exe_path[PATH_MAX];
- FileSpec resolved_exe_file (exe_file);
+ ModuleSpec resolved_module_spec (ms);
if (IsHost())
{
// If we have "ls" as the exe_file, resolve the executable location based on
// the current path variables
- if (!resolved_exe_file.Exists())
+ if (!resolved_module_spec.GetFileSpec().Exists())
{
- exe_file.GetPath(exe_path, sizeof(exe_path));
- resolved_exe_file.SetFile(exe_path, true);
+ resolved_module_spec.GetFileSpec().GetPath(exe_path, sizeof(exe_path));
+ resolved_module_spec.GetFileSpec().SetFile(exe_path, true);
}
- if (!resolved_exe_file.Exists())
- resolved_exe_file.ResolveExecutableLocation ();
+ if (!resolved_module_spec.GetFileSpec().Exists())
+ resolved_module_spec.GetFileSpec().ResolveExecutableLocation ();
- if (resolved_exe_file.Exists())
+ if (resolved_module_spec.GetFileSpec().Exists())
error.Clear();
else
{
- exe_file.GetPath(exe_path, sizeof(exe_path));
- error.SetErrorStringWithFormat("unable to find executable for '%s'", exe_path);
+ error.SetErrorStringWithFormat("unable to find executable for '%s'", resolved_module_spec.GetFileSpec().GetPath().c_str());
}
}
else
{
if (m_remote_platform_sp)
{
- error = m_remote_platform_sp->ResolveExecutable (exe_file,
- exe_arch,
+ error = m_remote_platform_sp->ResolveExecutable (ms,
exe_module_sp,
NULL);
}
{
// We may connect to a process and use the provided executable (Don't use local $PATH).
- if (resolved_exe_file.Exists())
+ if (resolved_module_spec.GetFileSpec().Exists())
error.Clear();
else
error.SetErrorStringWithFormat("the platform is not currently connected, and '%s' doesn't exist in the system root.", exe_path);
if (error.Success())
{
- ModuleSpec module_spec (resolved_exe_file, exe_arch);
- if (exe_arch.IsValid())
+ if (resolved_module_spec.GetArchitecture().IsValid())
{
- error = ModuleList::GetSharedModule (module_spec,
+ error = ModuleList::GetSharedModule (resolved_module_spec,
exe_module_sp,
NULL,
NULL,
{
// If we failed, it may be because the vendor and os aren't known. If that is the
// case, try setting them to the host architecture and give it another try.
- llvm::Triple &module_triple = module_spec.GetArchitecture().GetTriple();
+ llvm::Triple &module_triple = resolved_module_spec.GetArchitecture().GetTriple();
bool is_vendor_specified = (module_triple.getVendor() != llvm::Triple::UnknownVendor);
bool is_os_specified = (module_triple.getOS() != llvm::Triple::UnknownOS);
if (!is_vendor_specified || !is_os_specified)
if (!is_os_specified)
module_triple.setOSName (host_triple.getOSName());
- error = ModuleList::GetSharedModule (module_spec,
+ error = ModuleList::GetSharedModule (resolved_module_spec,
exe_module_sp,
NULL,
NULL,
{
exe_module_sp.reset();
error.SetErrorStringWithFormat ("'%s' doesn't contain the architecture %s",
- exe_file.GetPath().c_str(),
- exe_arch.GetArchitectureName());
+ resolved_module_spec.GetFileSpec().GetPath().c_str(),
+ resolved_module_spec.GetArchitecture().GetArchitectureName());
}
}
else
// the architectures that we should be using (in the correct order)
// and see if we can find a match that way
StreamString arch_names;
- for (uint32_t idx = 0; GetSupportedArchitectureAtIndex (idx, module_spec.GetArchitecture()); ++idx)
+ for (uint32_t idx = 0; GetSupportedArchitectureAtIndex (idx, resolved_module_spec.GetArchitecture()); ++idx)
{
- error = ModuleList::GetSharedModule (module_spec,
+ error = ModuleList::GetSharedModule (resolved_module_spec,
exe_module_sp,
NULL,
NULL,
if (idx > 0)
arch_names.PutCString (", ");
- arch_names.PutCString (module_spec.GetArchitecture().GetArchitectureName());
+ arch_names.PutCString (resolved_module_spec.GetArchitecture().GetArchitectureName());
}
if (error.Fail() || !exe_module_sp)
{
- if (exe_file.Readable())
+ if (resolved_module_spec.GetFileSpec().Readable())
{
error.SetErrorStringWithFormat ("'%s' doesn't contain any '%s' platform architectures: %s",
- exe_file.GetPath().c_str(),
+ resolved_module_spec.GetFileSpec().GetPath().c_str(),
GetPluginName().GetCString(),
arch_names.GetString().c_str());
}
else
{
- error.SetErrorStringWithFormat("'%s' is not readable", exe_file.GetPath().c_str());
+ error.SetErrorStringWithFormat("'%s' is not readable", resolved_module_spec.GetFileSpec().GetPath().c_str());
}
}
}
// approach on MacOSX.
lldb::ProcessSP
PlatformLinux::DebugProcess (ProcessLaunchInfo &launch_info,
- Debugger &debugger,
- Target *target, // Can be NULL, if NULL create a new target, else use existing one
- Listener &listener,
- Error &error)
+ Debugger &debugger,
+ Target *target, // Can be NULL, if NULL create a new target, else use existing one
+ Error &error)
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PLATFORM));
if (log)
// If we're a remote host, use standard behavior from parent class.
if (!IsHost ())
- return PlatformPOSIX::DebugProcess (launch_info, debugger, target, listener, error);
+ return PlatformPOSIX::DebugProcess (launch_info, debugger, target, error);
//
// For local debugging, we'll insist on having ProcessGDBRemote create the process.
// Now create the gdb-remote process.
if (log)
log->Printf ("PlatformLinux::%s having target create process with gdb-remote plugin", __FUNCTION__);
- process_sp = target->CreateProcess (listener, "gdb-remote", nullptr);
+ process_sp = target->CreateProcess (launch_info.GetListenerForProcess(debugger), "gdb-remote", nullptr);
if (!process_sp)
{
// lldb_private::Platform functions
//------------------------------------------------------------
Error
- ResolveExecutable (const FileSpec &exe_file,
- const ArchSpec &arch,
+ ResolveExecutable (const lldb_private::ModuleSpec &module_spec,
lldb::ModuleSP &module_sp,
const FileSpecList *module_search_paths_ptr) override;
DebugProcess (ProcessLaunchInfo &launch_info,
Debugger &debugger,
Target *target,
- Listener &listener,
Error &error) override;
void
}
Error
-PlatformDarwin::ResolveExecutable (const FileSpec &exe_file,
- const ArchSpec &exe_arch,
+PlatformDarwin::ResolveExecutable (const ModuleSpec &module_spec,
lldb::ModuleSP &exe_module_sp,
const FileSpecList *module_search_paths_ptr)
{
// Nothing special to do here, just use the actual file and architecture
char exe_path[PATH_MAX];
- FileSpec resolved_exe_file (exe_file);
-
+ ModuleSpec resolved_module_spec(module_spec);
+
if (IsHost())
{
// If we have "ls" as the exe_file, resolve the executable loation based on
// the current path variables
- if (resolved_exe_file.Exists())
- {
-
- }
- else
+ if (!resolved_module_spec.GetFileSpec().Exists())
{
- exe_file.GetPath (exe_path, sizeof(exe_path));
- resolved_exe_file.SetFile(exe_path, true);
+ module_spec.GetFileSpec().GetPath (exe_path, sizeof(exe_path));
+ resolved_module_spec.GetFileSpec().SetFile(exe_path, true);
}
- if (!resolved_exe_file.Exists())
- resolved_exe_file.ResolveExecutableLocation ();
+ if (!resolved_module_spec.GetFileSpec().Exists())
+ resolved_module_spec.GetFileSpec().ResolveExecutableLocation ();
// Resolve any executable within a bundle on MacOSX
- Host::ResolveExecutableInBundle (resolved_exe_file);
+ Host::ResolveExecutableInBundle (resolved_module_spec.GetFileSpec());
- if (resolved_exe_file.Exists())
+ if (resolved_module_spec.GetFileSpec().Exists())
error.Clear();
else
{
- const uint32_t permissions = resolved_exe_file.GetPermissions();
+ const uint32_t permissions = resolved_module_spec.GetFileSpec().GetPermissions();
if (permissions && (permissions & eFilePermissionsEveryoneR) == 0)
- error.SetErrorStringWithFormat ("executable '%s' is not readable", resolved_exe_file.GetPath().c_str());
+ error.SetErrorStringWithFormat ("executable '%s' is not readable", resolved_module_spec.GetFileSpec().GetPath().c_str());
else
- error.SetErrorStringWithFormat ("unable to find executable for '%s'", resolved_exe_file.GetPath().c_str());
+ error.SetErrorStringWithFormat ("unable to find executable for '%s'", resolved_module_spec.GetFileSpec().GetPath().c_str());
}
}
else
{
if (m_remote_platform_sp)
{
- error = m_remote_platform_sp->ResolveExecutable (exe_file,
- exe_arch,
+ error = m_remote_platform_sp->ResolveExecutable (module_spec,
exe_module_sp,
module_search_paths_ptr);
}
// We may connect to a process and use the provided executable (Don't use local $PATH).
// Resolve any executable within a bundle on MacOSX
- Host::ResolveExecutableInBundle (resolved_exe_file);
+ Host::ResolveExecutableInBundle (resolved_module_spec.GetFileSpec());
- if (resolved_exe_file.Exists())
+ if (resolved_module_spec.GetFileSpec().Exists())
error.Clear();
else
- error.SetErrorStringWithFormat("the platform is not currently connected, and '%s' doesn't exist in the system root.", resolved_exe_file.GetFilename().AsCString(""));
+ error.SetErrorStringWithFormat("the platform is not currently connected, and '%s' doesn't exist in the system root.", resolved_module_spec.GetFileSpec().GetFilename().AsCString(""));
}
}
if (error.Success())
{
- ModuleSpec module_spec (resolved_exe_file, exe_arch);
- if (module_spec.GetArchitecture().IsValid())
+ if (resolved_module_spec.GetArchitecture().IsValid())
{
- error = ModuleList::GetSharedModule (module_spec,
+ error = ModuleList::GetSharedModule (resolved_module_spec,
exe_module_sp,
module_search_paths_ptr,
NULL,
{
exe_module_sp.reset();
error.SetErrorStringWithFormat ("'%s' doesn't contain the architecture %s",
- exe_file.GetPath().c_str(),
- exe_arch.GetArchitectureName());
+ resolved_module_spec.GetFileSpec().GetPath().c_str(),
+ resolved_module_spec.GetArchitecture().GetArchitectureName());
}
}
else
// the architectures that we should be using (in the correct order)
// and see if we can find a match that way
StreamString arch_names;
- for (uint32_t idx = 0; GetSupportedArchitectureAtIndex (idx, module_spec.GetArchitecture()); ++idx)
+ for (uint32_t idx = 0; GetSupportedArchitectureAtIndex (idx, resolved_module_spec.GetArchitecture()); ++idx)
{
- error = GetSharedModule (module_spec,
+ error = GetSharedModule (resolved_module_spec,
exe_module_sp,
module_search_paths_ptr,
NULL,
if (idx > 0)
arch_names.PutCString (", ");
- arch_names.PutCString (module_spec.GetArchitecture().GetArchitectureName());
+ arch_names.PutCString (resolved_module_spec.GetArchitecture().GetArchitectureName());
}
if (error.Fail() || !exe_module_sp)
{
- if (exe_file.Readable())
+ if (resolved_module_spec.GetFileSpec().Readable())
{
error.SetErrorStringWithFormat ("'%s' doesn't contain any '%s' platform architectures: %s",
- exe_file.GetPath().c_str(),
+ resolved_module_spec.GetFileSpec().GetPath().c_str(),
GetPluginName().GetCString(),
arch_names.GetString().c_str());
}
else
{
- error.SetErrorStringWithFormat("'%s' is not readable", exe_file.GetPath().c_str());
+ error.SetErrorStringWithFormat("'%s' is not readable", resolved_module_spec.GetFileSpec().GetPath().c_str());
}
}
}
// lldb_private::Platform functions
//------------------------------------------------------------
virtual lldb_private::Error
- ResolveExecutable (const lldb_private::FileSpec &exe_file,
- const lldb_private::ArchSpec &arch,
+ ResolveExecutable (const lldb_private::ModuleSpec &module_spec,
lldb::ModuleSP &module_sp,
- const lldb_private::FileSpecList *module_search_paths_ptr);
+ const lldb_private::FileSpecList *module_search_paths_ptr) override;
virtual lldb_private::Error
ResolveSymbolFile (lldb_private::Target &target,
m_device_support_directory(),
m_device_support_directory_for_os_version (),
m_build_update(),
- m_last_module_sdk_idx(UINT32_MAX)
+ m_last_module_sdk_idx (UINT32_MAX),
+ m_connected_module_sdk_idx (UINT32_MAX)
{
}
Error
-PlatformRemoteiOS::ResolveExecutable (const FileSpec &exe_file,
- const ArchSpec &exe_arch,
+PlatformRemoteiOS::ResolveExecutable (const ModuleSpec &ms,
lldb::ModuleSP &exe_module_sp,
const FileSpecList *module_search_paths_ptr)
{
Error error;
// Nothing special to do here, just use the actual file and architecture
- FileSpec resolved_exe_file (exe_file);
-
- // If we have "ls" as the exe_file, resolve the executable loation based on
- // the current path variables
- // TODO: resolve bare executables in the Platform SDK
-// if (!resolved_exe_file.Exists())
-// resolved_exe_file.ResolveExecutableLocation ();
+ ModuleSpec resolved_module_spec(ms);
// Resolve any executable within a bundle on MacOSX
// TODO: verify that this handles shallow bundles, if not then implement one ourselves
- Host::ResolveExecutableInBundle (resolved_exe_file);
+ Host::ResolveExecutableInBundle (resolved_module_spec.GetFileSpec());
- if (resolved_exe_file.Exists())
+ if (resolved_module_spec.GetFileSpec().Exists())
{
- if (exe_arch.IsValid())
+ if (resolved_module_spec.GetArchitecture().IsValid() || resolved_module_spec.GetUUID().IsValid())
{
- ModuleSpec module_spec (resolved_exe_file, exe_arch);
- error = ModuleList::GetSharedModule (module_spec,
+ error = ModuleList::GetSharedModule (resolved_module_spec,
exe_module_sp,
NULL,
NULL,
// found so ask the platform for the architectures that we should be
// using (in the correct order) and see if we can find a match that way
StreamString arch_names;
- ArchSpec platform_arch;
- for (uint32_t idx = 0; GetSupportedArchitectureAtIndex (idx, platform_arch); ++idx)
+ for (uint32_t idx = 0; GetSupportedArchitectureAtIndex (idx, resolved_module_spec.GetArchitecture()); ++idx)
{
- ModuleSpec module_spec (resolved_exe_file, platform_arch);
- error = ModuleList::GetSharedModule (module_spec,
+ error = ModuleList::GetSharedModule (resolved_module_spec,
exe_module_sp,
NULL,
NULL,
if (idx > 0)
arch_names.PutCString (", ");
- arch_names.PutCString (platform_arch.GetArchitectureName());
+ arch_names.PutCString (resolved_module_spec.GetArchitecture().GetArchitectureName());
}
if (error.Fail() || !exe_module_sp)
{
- if (exe_file.Readable())
+ if (resolved_module_spec.GetFileSpec().Readable())
{
error.SetErrorStringWithFormat ("'%s' doesn't contain any '%s' platform architectures: %s",
- exe_file.GetPath().c_str(),
+ resolved_module_spec.GetFileSpec().GetPath().c_str(),
GetPluginName().GetCString(),
arch_names.GetString().c_str());
}
else
{
- error.SetErrorStringWithFormat("'%s' is not readable", exe_file.GetPath().c_str());
+ error.SetErrorStringWithFormat("'%s' is not readable", resolved_module_spec.GetFileSpec().GetPath().c_str());
}
}
}
else
{
error.SetErrorStringWithFormat ("'%s' does not exist",
- exe_file.GetPath().c_str());
+ resolved_module_spec.GetFileSpec().GetPath().c_str());
}
return error;
const bool find_directories = true;
const bool find_files = false;
const bool find_other = false;
+
+ SDKDirectoryInfoCollection builtin_sdk_directory_infos;
FileSpec::EnumerateDirectory (m_device_support_directory.c_str(),
find_directories,
find_files,
find_other,
GetContainedFilesIntoVectorOfStringsCallback,
- &m_sdk_directory_infos);
-
+ &builtin_sdk_directory_infos);
+
+ // Only add SDK directories that have symbols in them, some SDKs only contain
+ // developer disk images and no symbols, so they aren't useful to us.
+ FileSpec sdk_symbols_symlink_fspec;
+ for (const auto &sdk_directory_info : builtin_sdk_directory_infos)
+ {
+ sdk_symbols_symlink_fspec = sdk_directory_info.directory;
+ sdk_symbols_symlink_fspec.AppendPathComponent("Symbols");
+ if (sdk_symbols_symlink_fspec.Exists())
+ {
+ m_sdk_directory_infos.push_back(sdk_directory_info);
+ }
+ }
+
const uint32_t num_installed = m_sdk_directory_infos.size();
FileSpec local_sdk_cache("~/Library/Developer/Xcode/iOS DeviceSupport", true);
if (local_sdk_cache.Exists())
// with the right UUID.
const FileSpec &platform_file = module_spec.GetFileSpec();
- FileSpec local_file;
- const UUID *module_uuid_ptr = module_spec.GetUUIDPtr();
Error error;
char platform_file_path[PATH_MAX];
if (platform_file.GetPath(platform_file_path, sizeof(platform_file_path)))
{
- FileSpec local_file;
+ ModuleSpec platform_module_spec(module_spec);
+ UpdateSDKDirectoryInfosInNeeded();
+
UpdateSDKDirectoryInfosInNeeded();
const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
+
+ // If we are connected we migth be able to correctly deduce the SDK directory
+ // using the OS build.
+ const uint32_t connected_sdk_idx = GetConnectedSDKIndex ();
+ if (connected_sdk_idx < num_sdk_infos)
+ {
+ if (GetFileInSDK (platform_file_path, connected_sdk_idx, platform_module_spec.GetFileSpec()))
+ {
+ module_sp.reset();
+ error = ResolveExecutable (platform_module_spec,
+ module_sp,
+ NULL);
+ if (module_sp)
+ {
+ m_last_module_sdk_idx = connected_sdk_idx;
+ error.Clear();
+ return error;
+ }
+ }
+ }
+
// Try the last SDK index if it is set as most files from an SDK
// will tend to be valid in that same SDK.
if (m_last_module_sdk_idx < num_sdk_infos)
{
- if (GetFileInSDK (platform_file_path, m_last_module_sdk_idx, local_file))
+ if (GetFileInSDK (platform_file_path, m_last_module_sdk_idx, platform_module_spec.GetFileSpec()))
{
- //printf ("sdk[%u] last: '%s'\n", m_last_module_sdk_idx, local_file.GetPath().c_str());
module_sp.reset();
- error = ResolveExecutable (local_file,
- module_spec.GetArchitecture(),
+ error = ResolveExecutable (platform_module_spec,
module_sp,
NULL);
- if (module_sp && ((module_uuid_ptr == NULL) || (module_sp->GetUUID() == *module_uuid_ptr)))
+ if (module_sp)
{
- //printf ("sdk[%u] last found\n", m_last_module_sdk_idx);
error.Clear();
return error;
}
// it above
continue;
}
- if (GetFileInSDK (platform_file_path, sdk_idx, local_file))
+ if (GetFileInSDK (platform_file_path, sdk_idx, platform_module_spec.GetFileSpec()))
{
//printf ("sdk[%u]: '%s'\n", sdk_idx, local_file.GetPath().c_str());
- error = ResolveExecutable (local_file,
- module_spec.GetArchitecture(),
- module_sp,
- NULL);
- if (module_sp && ((module_uuid_ptr == NULL) || (module_sp->GetUUID() == *module_uuid_ptr)))
+ error = ResolveExecutable (platform_module_spec, module_sp, NULL);
+ if (module_sp)
{
// Remember the index of the last SDK that we found a file
// in in case the wrong SDK was selected.
m_last_module_sdk_idx = sdk_idx;
- //printf ("sdk[%u]: found (setting last to %u)\n", sdk_idx, m_last_module_sdk_idx);
error.Clear();
return error;
}
return error;
const bool always_create = false;
- error = ModuleList::GetSharedModule (module_spec,
+ error = ModuleList::GetSharedModule (module_spec,
module_sp,
module_search_paths_ptr,
old_module_sp_ptr,
{
return ARMGetSupportedArchitectureAtIndex (idx, arch);
}
+
+uint32_t
+PlatformRemoteiOS::GetConnectedSDKIndex ()
+{
+ if (IsConnected())
+ {
+ if (m_connected_module_sdk_idx == UINT32_MAX)
+ {
+ std::string build;
+ if (GetRemoteOSBuildString(build))
+ {
+ const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
+ for (uint32_t i=0; i<num_sdk_infos; ++i)
+ {
+ const SDKDirectoryInfo &sdk_dir_info = m_sdk_directory_infos[i];
+ if (strstr(sdk_dir_info.directory.GetFilename().AsCString(""), build.c_str()))
+ {
+ m_connected_module_sdk_idx = i;
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ m_connected_module_sdk_idx = UINT32_MAX;
+ }
+ return m_connected_module_sdk_idx;
+}
+
// lldb_private::Platform functions
//------------------------------------------------------------
virtual lldb_private::Error
- ResolveExecutable (const lldb_private::FileSpec &exe_file,
- const lldb_private::ArchSpec &arch,
+ ResolveExecutable (const lldb_private::ModuleSpec &module_spec,
lldb::ModuleSP &module_sp,
const lldb_private::FileSpecList *module_search_paths_ptr);
std::string m_device_support_directory_for_os_version;
std::string m_build_update;
uint32_t m_last_module_sdk_idx;
+ uint32_t m_connected_module_sdk_idx;
bool
UpdateSDKDirectoryInfosInNeeded();
FindFileInAllSDKs (const lldb_private::FileSpec &platform_file,
lldb_private::FileSpecList &file_list);
+ uint32_t
+ GetConnectedSDKIndex ();
+
private:
DISALLOW_COPY_AND_ASSIGN (PlatformRemoteiOS);
Error
-PlatformiOSSimulator::ResolveExecutable (const FileSpec &exe_file,
- const ArchSpec &exe_arch,
+PlatformiOSSimulator::ResolveExecutable (const ModuleSpec &module_spec,
lldb::ModuleSP &exe_module_sp,
const FileSpecList *module_search_paths_ptr)
{
Error error;
// Nothing special to do here, just use the actual file and architecture
- FileSpec resolved_exe_file (exe_file);
-
+ ModuleSpec resolved_module_spec(module_spec);
+
// If we have "ls" as the exe_file, resolve the executable loation based on
// the current path variables
// TODO: resolve bare executables in the Platform SDK
// Resolve any executable within a bundle on MacOSX
// TODO: verify that this handles shallow bundles, if not then implement one ourselves
- Host::ResolveExecutableInBundle (resolved_exe_file);
+ Host::ResolveExecutableInBundle (resolved_module_spec.GetFileSpec());
- if (resolved_exe_file.Exists())
+ if (resolved_module_spec.GetFileSpec().Exists())
{
- ModuleSpec module_spec(resolved_exe_file, exe_arch);
- if (exe_arch.IsValid())
+ if (resolved_module_spec.GetArchitecture().IsValid())
{
- error = ModuleList::GetSharedModule (module_spec,
+ error = ModuleList::GetSharedModule (resolved_module_spec,
exe_module_sp,
NULL,
NULL,
// using (in the correct order) and see if we can find a match that way
StreamString arch_names;
ArchSpec platform_arch;
- for (uint32_t idx = 0; GetSupportedArchitectureAtIndex (idx, module_spec.GetArchitecture()); ++idx)
+ for (uint32_t idx = 0; GetSupportedArchitectureAtIndex (idx, resolved_module_spec.GetArchitecture()); ++idx)
{
// Only match x86 with x86 and x86_64 with x86_64...
- if (!exe_arch.IsValid() || exe_arch.GetCore() == module_spec.GetArchitecture().GetCore())
+ if (!module_spec.GetArchitecture().IsValid() || module_spec.GetArchitecture().GetCore() == resolved_module_spec.GetArchitecture().GetCore())
{
- error = ModuleList::GetSharedModule (module_spec,
+ error = ModuleList::GetSharedModule (resolved_module_spec,
exe_module_sp,
NULL,
NULL,
if (error.Fail() || !exe_module_sp)
{
- if (exe_file.Readable())
+ if (resolved_module_spec.GetFileSpec().Readable())
{
error.SetErrorStringWithFormat ("'%s' doesn't contain any '%s' platform architectures: %s",
- exe_file.GetPath().c_str(),
+ resolved_module_spec.GetFileSpec().GetPath().c_str(),
GetPluginName().GetCString(),
arch_names.GetString().c_str());
}
else
{
- error.SetErrorStringWithFormat("'%s' is not readable", exe_file.GetPath().c_str());
+ error.SetErrorStringWithFormat("'%s' is not readable", resolved_module_spec.GetFileSpec().GetPath().c_str());
}
}
}
else
{
error.SetErrorStringWithFormat ("'%s' does not exist",
- exe_file.GetPath().c_str());
+ module_spec.GetFileSpec().GetPath().c_str());
}
return error;
// then we attempt to get a shared module for the right architecture
// with the right UUID.
Error error;
- FileSpec local_file;
+ ModuleSpec platform_module_spec (module_spec);
const FileSpec &platform_file = module_spec.GetFileSpec();
- error = GetSymbolFile (platform_file, module_spec.GetUUIDPtr(), local_file);
+ error = GetSymbolFile (platform_file, module_spec.GetUUIDPtr(), platform_module_spec.GetFileSpec());
if (error.Success())
{
- error = ResolveExecutable (local_file, module_spec.GetArchitecture(), module_sp, module_search_paths_ptr);
+ error = ResolveExecutable (platform_module_spec, module_sp, module_search_paths_ptr);
}
else
{
// lldb_private::Platform functions
//------------------------------------------------------------
virtual lldb_private::Error
- ResolveExecutable (const lldb_private::FileSpec &exe_file,
- const lldb_private::ArchSpec &arch,
+ ResolveExecutable (const lldb_private::ModuleSpec &module_spec,
lldb::ModuleSP &module_sp,
const lldb_private::FileSpecList *module_search_paths_ptr);
PlatformPOSIX::Attach (ProcessAttachInfo &attach_info,
Debugger &debugger,
Target *target,
- Listener &listener,
Error &error)
{
lldb::ProcessSP process_sp;
}
- process_sp = target->CreateProcess (listener, attach_info.GetProcessPluginName(), NULL);
+ process_sp = target->CreateProcess (attach_info.GetListenerForProcess(debugger), attach_info.GetProcessPluginName(), NULL);
if (process_sp)
{
else
{
if (m_remote_platform_sp)
- process_sp = m_remote_platform_sp->Attach (attach_info, debugger, target, listener, error);
+ process_sp = m_remote_platform_sp->Attach (attach_info, debugger, target, error);
else
error.SetErrorString ("the platform is not currently connected");
}
PlatformPOSIX::DebugProcess (ProcessLaunchInfo &launch_info,
Debugger &debugger,
Target *target, // Can be NULL, if NULL create a new target, else use existing one
- Listener &listener,
Error &error)
{
ProcessSP process_sp;
// We still need to reap it from lldb but if we let the monitor thread also set the exit status, we set up a
// race between debugserver & us for who will find out about the debugged process's death.
launch_info.GetFlags().Set(eLaunchFlagDontSetExitStatus);
- process_sp = Platform::DebugProcess (launch_info, debugger, target, listener, error);
+ process_sp = Platform::DebugProcess (launch_info, debugger, target, error);
}
else
{
if (m_remote_platform_sp)
- process_sp = m_remote_platform_sp->DebugProcess (launch_info, debugger, target, listener, error);
+ process_sp = m_remote_platform_sp->DebugProcess (launch_info, debugger, target, error);
else
error.SetErrorString ("the platform is not currently connected");
}
Attach (lldb_private::ProcessAttachInfo &attach_info,
lldb_private::Debugger &debugger,
lldb_private::Target *target, // Can be NULL, if NULL create a new target, else use existing one
- lldb_private::Listener &listener,
lldb_private::Error &error) override;
lldb::ProcessSP
DebugProcess (lldb_private::ProcessLaunchInfo &launch_info,
lldb_private::Debugger &debugger,
lldb_private::Target *target, // Can be NULL, if NULL create a new target, else use existing one
- lldb_private::Listener &listener,
lldb_private::Error &error) override;
virtual std::string
}
Error
-PlatformWindows::ResolveExecutable (const FileSpec &exe_file,
- const ArchSpec &exe_arch,
+PlatformWindows::ResolveExecutable (const ModuleSpec &ms,
lldb::ModuleSP &exe_module_sp,
const FileSpecList *module_search_paths_ptr)
{
// Nothing special to do here, just use the actual file and architecture
char exe_path[PATH_MAX];
- FileSpec resolved_exe_file (exe_file);
+ ModuleSpec resolved_module_spec(ms);
if (IsHost())
{
// if we cant resolve the executable loation based on the current path variables
- if (!resolved_exe_file.Exists())
+ if (!resolved_module_spec.GetFileSpec().Exists())
{
- exe_file.GetPath(exe_path, sizeof(exe_path));
- resolved_exe_file.SetFile(exe_path, true);
+ resolved_module_spec.GetFileSpec().GetPath(exe_path, sizeof(exe_path));
+ resolved_module_spec.GetFileSpec().SetFile(exe_path, true);
}
- if (!resolved_exe_file.Exists())
- resolved_exe_file.ResolveExecutableLocation ();
+ if (!resolved_module_spec.GetFileSpec().Exists())
+ resolved_module_spec.GetFileSpec().ResolveExecutableLocation ();
- if (resolved_exe_file.Exists())
+ if (resolved_module_spec.GetFileSpec().Exists())
error.Clear();
else
{
- exe_file.GetPath(exe_path, sizeof(exe_path));
+ ms.GetFileSpec().GetPath(exe_path, sizeof(exe_path));
error.SetErrorStringWithFormat("unable to find executable for '%s'", exe_path);
}
}
{
if (m_remote_platform_sp)
{
- error = m_remote_platform_sp->ResolveExecutable (exe_file,
- exe_arch,
+ error = m_remote_platform_sp->ResolveExecutable (ms,
exe_module_sp,
NULL);
}
else
{
// We may connect to a process and use the provided executable (Don't use local $PATH).
- if (resolved_exe_file.Exists())
+ if (resolved_module_spec.GetFileSpec().Exists())
error.Clear();
else
error.SetErrorStringWithFormat("the platform is not currently connected, and '%s' doesn't exist in the system root.", exe_path);
if (error.Success())
{
- ModuleSpec module_spec (resolved_exe_file, exe_arch);
- if (exe_arch.IsValid())
+ if (resolved_module_spec.GetArchitecture().IsValid())
{
- error = ModuleList::GetSharedModule (module_spec,
+ error = ModuleList::GetSharedModule (resolved_module_spec,
exe_module_sp,
NULL,
NULL,
{
exe_module_sp.reset();
error.SetErrorStringWithFormat ("'%s' doesn't contain the architecture %s",
- exe_file.GetPath().c_str(),
- exe_arch.GetArchitectureName());
+ resolved_module_spec.GetFileSpec().GetPath().c_str(),
+ resolved_module_spec.GetArchitecture().GetArchitectureName());
}
}
else
// the architectures that we should be using (in the correct order)
// and see if we can find a match that way
StreamString arch_names;
- for (uint32_t idx = 0; GetSupportedArchitectureAtIndex (idx, module_spec.GetArchitecture()); ++idx)
+ for (uint32_t idx = 0; GetSupportedArchitectureAtIndex (idx, resolved_module_spec.GetArchitecture()); ++idx)
{
- error = ModuleList::GetSharedModule (module_spec,
+ error = ModuleList::GetSharedModule (resolved_module_spec,
exe_module_sp,
NULL,
NULL,
if (idx > 0)
arch_names.PutCString (", ");
- arch_names.PutCString (module_spec.GetArchitecture().GetArchitectureName());
+ arch_names.PutCString (resolved_module_spec.GetArchitecture().GetArchitectureName());
}
if (error.Fail() || !exe_module_sp)
{
- if (exe_file.Readable())
+ if (resolved_module_spec.GetFileSpec().Readable())
{
error.SetErrorStringWithFormat ("'%s' doesn't contain any '%s' platform architectures: %s",
- exe_file.GetPath().c_str(),
+ resolved_module_spec.GetFileSpec().GetPath().c_str(),
GetPluginName().GetCString(),
arch_names.GetString().c_str());
}
else
{
- error.SetErrorStringWithFormat("'%s' is not readable", exe_file.GetPath().c_str());
+ error.SetErrorStringWithFormat("'%s' is not readable", resolved_module_spec.GetFileSpec().GetPath().c_str());
}
}
}
PlatformWindows::Attach(ProcessAttachInfo &attach_info,
Debugger &debugger,
Target *target,
- Listener &listener,
Error &error)
{
lldb::ProcessSP process_sp;
// The Windows platform always currently uses the GDB remote debugger plug-in
// so even when debugging locally we are debugging remotely!
// Just like the darwin plugin.
- process_sp = target->CreateProcess (listener, "gdb-remote", NULL);
+ process_sp = target->CreateProcess (attach_info.GetListenerForProcess(debugger), "gdb-remote", NULL);
if (process_sp)
error = process_sp->Attach (attach_info);
else
{
if (m_remote_platform_sp)
- process_sp = m_remote_platform_sp->Attach (attach_info, debugger, target, listener, error);
+ process_sp = m_remote_platform_sp->Attach (attach_info, debugger, target, error);
else
error.SetErrorString ("the platform is not currently connected");
}
// lldb_private::Platform functions
//------------------------------------------------------------
virtual Error
- ResolveExecutable(const FileSpec &exe_file,
- const ArchSpec &arch,
+ ResolveExecutable(const lldb_private::ModuleSpec &module_spec,
lldb::ModuleSP &module_sp,
const FileSpecList *module_search_paths_ptr);
Attach(lldb_private::ProcessAttachInfo &attach_info,
lldb_private::Debugger &debugger,
lldb_private::Target *target,
- lldb_private::Listener &listener,
lldb_private::Error &error);
virtual lldb_private::Error
#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleList.h"
+#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/StreamString.h"
#include "lldb/Host/ConnectionFileDescriptor.h"
}
Error
-PlatformRemoteGDBServer::ResolveExecutable (const FileSpec &exe_file,
- const ArchSpec &exe_arch,
+PlatformRemoteGDBServer::ResolveExecutable (const ModuleSpec &module_spec,
lldb::ModuleSP &exe_module_sp,
const FileSpecList *module_search_paths_ptr)
{
Error error;
//error.SetErrorString ("PlatformRemoteGDBServer::ResolveExecutable() is unimplemented");
- if (m_gdb_client.GetFileExists(exe_file))
+ if (m_gdb_client.GetFileExists(module_spec.GetFileSpec()))
return error;
// TODO: get the remote end to somehow resolve this file
error.SetErrorString("file not found on remote end");
PlatformRemoteGDBServer::DebugProcess (lldb_private::ProcessLaunchInfo &launch_info,
lldb_private::Debugger &debugger,
lldb_private::Target *target, // Can be NULL, if NULL create a new target, else use existing one
- lldb_private::Listener &listener,
lldb_private::Error &error)
{
lldb::ProcessSP process_sp;
// The darwin always currently uses the GDB remote debugger plug-in
// so even when debugging locally we are debugging remotely!
- process_sp = target->CreateProcess (listener, "gdb-remote", NULL);
+ process_sp = target->CreateProcess (launch_info.GetListenerForProcess(debugger), "gdb-remote", NULL);
if (process_sp)
{
PlatformRemoteGDBServer::Attach (lldb_private::ProcessAttachInfo &attach_info,
Debugger &debugger,
Target *target, // Can be NULL, if NULL create a new target, else use existing one
- Listener &listener,
Error &error)
{
lldb::ProcessSP process_sp;
// The darwin always currently uses the GDB remote debugger plug-in
// so even when debugging locally we are debugging remotely!
- process_sp = target->CreateProcess (listener, "gdb-remote", NULL);
+ process_sp = target->CreateProcess (attach_info.GetListenerForProcess(debugger), "gdb-remote", NULL);
if (process_sp)
{
// lldb_private::Platform functions
//------------------------------------------------------------
virtual lldb_private::Error
- ResolveExecutable (const lldb_private::FileSpec &exe_file,
- const lldb_private::ArchSpec &arch,
+ ResolveExecutable (const lldb_private::ModuleSpec &module_spec,
lldb::ModuleSP &module_sp,
const lldb_private::FileSpecList *module_search_paths_ptr);
DebugProcess (lldb_private::ProcessLaunchInfo &launch_info,
lldb_private::Debugger &debugger,
lldb_private::Target *target, // Can be NULL, if NULL create a new target, else use existing one
- lldb_private::Listener &listener,
lldb_private::Error &error);
virtual lldb::ProcessSP
Attach (lldb_private::ProcessAttachInfo &attach_info,
lldb_private::Debugger &debugger,
lldb_private::Target *target, // Can be NULL, if NULL create a new target, else use existing one
- lldb_private::Listener &listener,
lldb_private::Error &error);
virtual bool
break;
case DW_ATE_float:
+ if (streq(type_name, "float") && QualTypeMatchesBitSize (bit_size, ast, ast->FloatTy))
+ return ClangASTType (ast, ast->FloatTy.getAsOpaquePtr());
+ if (streq(type_name, "double") && QualTypeMatchesBitSize (bit_size, ast, ast->DoubleTy))
+ return ClangASTType (ast, ast->DoubleTy.getAsOpaquePtr());
+ if (streq(type_name, "long double") && QualTypeMatchesBitSize (bit_size, ast, ast->LongDoubleTy))
+ return ClangASTType (ast, ast->LongDoubleTy.getAsOpaquePtr());
+ // Fall back to not requring a name match
if (QualTypeMatchesBitSize (bit_size, ast, ast->FloatTy))
return ClangASTType (ast, ast->FloatTy.getAsOpaquePtr());
if (QualTypeMatchesBitSize (bit_size, ast, ast->DoubleTy))
Error
-Platform::ResolveExecutable (const FileSpec &exe_file,
- const ArchSpec &exe_arch,
+Platform::ResolveExecutable (const ModuleSpec &module_spec,
lldb::ModuleSP &exe_module_sp,
const FileSpecList *module_search_paths_ptr)
{
Error error;
- if (exe_file.Exists())
+ if (module_spec.GetFileSpec().Exists())
{
- ModuleSpec module_spec (exe_file, exe_arch);
if (module_spec.GetArchitecture().IsValid())
{
error = ModuleList::GetSharedModule (module_spec,
// No valid architecture was specified, ask the platform for
// the architectures that we should be using (in the correct order)
// and see if we can find a match that way
- for (uint32_t idx = 0; GetSupportedArchitectureAtIndex (idx, module_spec.GetArchitecture()); ++idx)
+ ModuleSpec arch_module_spec(module_spec);
+ for (uint32_t idx = 0; GetSupportedArchitectureAtIndex (idx, arch_module_spec.GetArchitecture()); ++idx)
{
- error = ModuleList::GetSharedModule (module_spec,
+ error = ModuleList::GetSharedModule (arch_module_spec,
exe_module_sp,
module_search_paths_ptr,
NULL,
else
{
error.SetErrorStringWithFormat ("'%s' does not exist",
- exe_file.GetPath().c_str());
+ module_spec.GetFileSpec().GetPath().c_str());
}
return error;
}
Platform::DebugProcess (ProcessLaunchInfo &launch_info,
Debugger &debugger,
Target *target, // Can be NULL, if NULL create a new target, else use existing one
- Listener &listener,
Error &error)
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PLATFORM));
if (launch_info.GetProcessID() != LLDB_INVALID_PROCESS_ID)
{
ProcessAttachInfo attach_info (launch_info);
- process_sp = Attach (attach_info, debugger, target, listener, error);
+ process_sp = Attach (attach_info, debugger, target, error);
if (process_sp)
{
if (log)
return m_exit_string.c_str();
}
+Listener &
+ProcessAttachInfo::GetListenerForProcess (Debugger &debugger)
+{
+ if (m_listener_sp)
+ return *m_listener_sp;
+ else
+ return debugger.GetListener();
+}
+
Error
Process::Attach (ProcessAttachInfo &attach_info)
{
#include "lldb/Host/Config.h"
+#include "lldb/Core/Debugger.h"
#include "lldb/Core/Log.h"
#include "lldb/Target/ProcessLaunchInfo.h"
#include "lldb/Target/FileAction.h"
m_monitor_callback (NULL),
m_monitor_callback_baton (NULL),
m_monitor_signals (false),
+ m_listener_sp (),
m_hijack_listener_sp ()
{
}
m_monitor_callback(NULL),
m_monitor_callback_baton(NULL),
m_monitor_signals(false),
+ m_listener_sp (),
m_hijack_listener_sp()
{
if (stdin_path)
m_flags.Clear();
m_file_actions.clear();
m_resume_count = 0;
+ m_listener_sp.reset();
m_hijack_listener_sp.reset();
}
}
return false;
}
+
+Listener &
+ProcessLaunchInfo::GetListenerForProcess (Debugger &debugger)
+{
+ if (m_listener_sp)
+ return *m_listener_sp;
+ else
+ return debugger.GetListener();
+}
do
{
uint32_t idx = m_concrete_frames_fetched++;
- lldb::addr_t pc;
- lldb::addr_t cfa;
+ lldb::addr_t pc = LLDB_INVALID_ADDRESS;
+ lldb::addr_t cfa = LLDB_INVALID_ADDRESS;
if (idx == 0)
{
// We might have already created frame zero, only create it
if (begin != end)
{
collection::const_iterator pos = std::lower_bound (begin, end, stack_id, CompareStackID);
- if (pos != end && (*pos)->GetStackID() == stack_id)
- return *pos;
+ if (pos != end)
+ {
+ if ((*pos)->GetStackID() == stack_id)
+ return *pos;
+ }
- if (m_frames.back()->GetStackID() < stack_id)
- frame_idx = m_frames.size();
+// if (m_frames.back()->GetStackID() < stack_id)
+// frame_idx = m_frames.size();
}
do
{
{
if (m_valid && module_list.GetSize())
{
+ UnloadModuleSections (module_list);
m_breakpoint_list.UpdateBreakpoints (module_list, false, delete_locations);
// TODO: make event data that packages up the module_list
BroadcastEvent (eBroadcastBitModulesUnloaded, NULL);
}
+size_t
+Target::UnloadModuleSections (const ModuleList &module_list)
+{
+ size_t section_unload_count = 0;
+ size_t num_modules = module_list.GetSize();
+ for (size_t i=0; i<num_modules; ++i)
+ {
+ section_unload_count += UnloadModuleSections (module_list.GetModuleAtIndex(i));
+ }
+ return section_unload_count;
+}
+
+size_t
+Target::UnloadModuleSections (const lldb::ModuleSP &module_sp)
+{
+ uint32_t stop_id = 0;
+ ProcessSP process_sp(GetProcessSP());
+ if (process_sp)
+ stop_id = process_sp->GetStopID();
+ else
+ stop_id = m_section_load_history.GetLastStopID();
+ SectionList *sections = module_sp->GetSectionList();
+ size_t section_unload_count = 0;
+ if (sections)
+ {
+ const uint32_t num_sections = sections->GetNumSections(0);
+ for (uint32_t i = 0; i < num_sections; ++i)
+ {
+ section_unload_count += m_section_load_history.SetSectionUnloaded(stop_id, sections->GetSectionAtIndex(i));
+ }
+ }
+ return section_unload_count;
+}
+
bool
Target::SetSectionUnloaded (const lldb::SectionSP §ion_sp)
{
Error
-Target::Launch (Listener &listener, ProcessLaunchInfo &launch_info, Stream *stream)
+Target::Launch (ProcessLaunchInfo &launch_info, Stream *stream)
{
Error error;
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TARGET));
m_process_sp = GetPlatform()->DebugProcess (launch_info,
debugger,
this,
- listener,
error);
}
else
{
// Use a Process plugin to construct the process.
const char *plugin_name = launch_info.GetProcessPluginName();
- CreateProcess (listener, plugin_name, NULL);
+ CreateProcess (launch_info.GetListenerForProcess(debugger), plugin_name, NULL);
}
// Since we didn't have a platform launch the process, launch it here.
if (platform_sp)
{
FileSpecList executable_search_paths (Target::GetDefaultExecutableSearchPaths());
- error = platform_sp->ResolveExecutable (file,
- arch,
+ ModuleSpec module_spec(file, arch);
+ error = platform_sp->ResolveExecutable (module_spec,
exe_module_sp,
executable_search_paths.GetSize() ? &executable_search_paths : NULL);
}