Change the way the m_trap_handlers Platform base class ivar is initialized;

add a new pure virtual CalculateTrapHandlerSymbolNames() that Platform 
subclasses must implement which fills in the function name list with any
trap handlers that are expected on that platform.

llvm-svn: 201364
This commit is contained in:
Jason Molenda 2014-02-13 23:11:45 +00:00
parent 20b99b60b8
commit 2094dbf4e7
15 changed files with 92 additions and 13 deletions

View File

@ -856,10 +856,7 @@ namespace lldb_private {
/// A list of symbol names. The list may be empty.
//------------------------------------------------------------------
virtual const std::vector<ConstString> &
GetTrapHandlerSymbolNames ()
{
return m_trap_handlers;
}
GetTrapHandlerSymbolNames ();
protected:
bool m_is_host;
@ -894,6 +891,23 @@ namespace lldb_private {
bool m_ignores_remote_hostname;
std::string m_local_cache_directory;
std::vector<ConstString> m_trap_handlers;
bool m_calculated_trap_handlers;
//------------------------------------------------------------------
/// Ask the Platform subclass to fill in the list of trap handler names
///
/// For most Unix user process environments, this will be a single
/// function name, _sigtramp. More specialized environments may have
/// additional handler names. The unwinder code needs to know when a
/// trap handler is on the stack because the unwind rules for the frame
/// that caused the trap are different.
///
/// The base class Platform ivar m_trap_handlers should be updated by
/// the Platform subclass when this method is called. If there are no
/// predefined trap handlers, this method may be a no-op.
//------------------------------------------------------------------
virtual void
CalculateTrapHandlerSymbolNames () = 0;
const char *
GetCachedUserName (uint32_t uid)

View File

@ -145,7 +145,6 @@ PlatformFreeBSD::PlatformFreeBSD (bool is_host) :
Platform(is_host),
m_remote_platform_sp()
{
m_trap_handlers.push_back (ConstString ("_sigtramp"));
}
//------------------------------------------------------------------
@ -676,3 +675,9 @@ PlatformFreeBSD::GetStatus (Stream &strm)
Platform::GetStatus(strm);
}
void
PlatformFreeBSD::CalculateTrapHandlerSymbolNames ()
{
m_trap_handlers.push_back (ConstString ("_sigtramp"));
}

View File

@ -160,6 +160,9 @@ public:
virtual void
GetStatus (lldb_private::Stream &strm);
virtual void
CalculateTrapHandlerSymbolNames ();
protected:
lldb::PlatformSP m_remote_platform_sp; // Allow multiple ways to connect to a remote freebsd OS

View File

@ -307,7 +307,6 @@ PlatformLinux::PlatformLinux (bool is_host) :
Platform(is_host), // This is the local host platform
m_remote_platform_sp ()
{
m_trap_handlers.push_back (ConstString ("_sigtramp"));
}
//------------------------------------------------------------------
@ -481,3 +480,9 @@ PlatformLinux::Attach(ProcessAttachInfo &attach_info,
}
return process_sp;
}
void
PlatformLinux::CalculateTrapHandlerSymbolNames ()
{
m_trap_handlers.push_back (ConstString ("_sigtramp"));
}

View File

@ -100,6 +100,9 @@ namespace lldb_private {
return false;
}
virtual void
CalculateTrapHandlerSymbolNames ();
protected:
lldb::PlatformSP m_remote_platform_sp; // Allow multiple ways to connect to a remote darwin OS

View File

@ -40,7 +40,6 @@ PlatformDarwin::PlatformDarwin (bool is_host) :
PlatformPOSIX(is_host), // This is the local host platform
m_developer_directory ()
{
m_trap_handlers.push_back (ConstString ("_sigtramp"));
}
//------------------------------------------------------------------
@ -1344,3 +1343,9 @@ PlatformDarwin::GetResumeCountForLaunchInfo (ProcessLaunchInfo &launch_info)
else
return 1;
}
void
PlatformDarwin::CalculateTrapHandlerSymbolNames ()
{
m_trap_handlers.push_back (ConstString ("_sigtramp"));
}

View File

@ -127,6 +127,9 @@ public:
virtual int32_t
GetResumeCountForLaunchInfo (lldb_private::ProcessLaunchInfo &launch_info);
virtual void
CalculateTrapHandlerSymbolNames ();
protected:
void

View File

@ -257,8 +257,6 @@ PlatformDarwinKernel::PlatformDarwinKernel (lldb_private::LazyBool is_ios_debug_
{
SearchForKexts ();
}
m_trap_handlers.push_back(ConstString ("trap_from_kernel"));
m_trap_handlers.push_back(ConstString ("hndl_double_fault"));
}
//------------------------------------------------------------------
@ -658,6 +656,13 @@ PlatformDarwinKernel::GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &a
#endif
}
void
PlatformDarwinKernel::CalculateTrapHandlerSymbolNames ()
{
m_trap_handlers.push_back(ConstString ("trap_from_kernel"));
m_trap_handlers.push_back(ConstString ("hndl_double_fault"));
}
#else // __APPLE__
// Since DynamicLoaderDarwinKernel is compiled in for all systems, and relies on
@ -675,5 +680,4 @@ PlatformDarwinKernel::GetPluginNameStatic ()
return g_name;
}
#endif // __APPLE__

View File

@ -161,6 +161,9 @@ protected:
lldb_private::Error
ExamineKextForMatchingUUID (const lldb_private::FileSpec &kext_bundle_path, const lldb_private::UUID &uuid, const lldb_private::ArchSpec &arch, lldb::ModuleSP &exe_module_sp);
virtual void
CalculateTrapHandlerSymbolNames ();
private:
BundleIDToKextMap m_name_to_kext_path_map;

View File

@ -32,7 +32,6 @@ PlatformPOSIX::PlatformPOSIX (bool is_host) :
Platform(is_host), // This is the local host platform
m_remote_platform_sp ()
{
m_trap_handlers.push_back (ConstString ("_sigtramp"));
}
//------------------------------------------------------------------
@ -590,3 +589,8 @@ PlatformPOSIX::SetRemoteWorkingDirectory(const lldb_private::ConstString &path)
return Platform::SetRemoteWorkingDirectory(path);
}
void
PlatformPOSIX::CalculateTrapHandlerSymbolNames ()
{
m_trap_handlers.push_back (ConstString ("_sigtramp"));
}

View File

@ -111,6 +111,9 @@ public:
uint64_t &low,
uint64_t &high);
virtual void
CalculateTrapHandlerSymbolNames ();
protected:
std::unique_ptr<lldb_private::OptionGroupOptions> m_options;

View File

@ -148,6 +148,12 @@ public:
return false;
}
// FIXME not sure what the _sigtramp equivalent would be on this platform
virtual void
CalculateTrapHandlerSymbolNames ()
{
}
protected:
lldb::PlatformSP m_remote_platform_sp;

View File

@ -135,7 +135,6 @@ PlatformRemoteGDBServer::PlatformRemoteGDBServer () :
Platform(false), // This is a remote platform
m_gdb_client(true)
{
m_trap_handlers.push_back (ConstString ("_sigtramp"));
}
//------------------------------------------------------------------
@ -702,3 +701,9 @@ PlatformRemoteGDBServer::RunShellCommand (const char *command, // Shou
{
return m_gdb_client.RunShellCommand (command, working_dir, status_ptr, signo_ptr, command_output, timeout_sec);
}
void
PlatformRemoteGDBServer::CalculateTrapHandlerSymbolNames ()
{
m_trap_handlers.push_back (ConstString ("_sigtramp"));
}

View File

@ -209,6 +209,9 @@ public:
std::string *command_output, // Pass NULL if you don't want the command output
uint32_t timeout_sec); // Timeout in seconds to wait for shell program to finish
virtual void
CalculateTrapHandlerSymbolNames ();
protected:
GDBRemoteCommunicationClient m_gdb_client;
std::string m_platform_description; // After we connect we can get a more complete description of what we are connected to

View File

@ -256,7 +256,8 @@ Platform::Platform (bool is_host) :
m_supports_ssh (false),
m_ssh_opts (),
m_ignores_remote_hostname (false),
m_trap_handlers()
m_trap_handlers(),
m_calculated_trap_handlers (false)
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
if (log)
@ -1391,3 +1392,15 @@ Platform::GetEnvironment (StringList &environment)
environment.Clear();
return false;
}
const std::vector<ConstString> &
Platform::GetTrapHandlerSymbolNames ()
{
if (!m_calculated_trap_handlers)
{
CalculateTrapHandlerSymbolNames();
m_calculated_trap_handlers = true;
}
return m_trap_handlers;
}