[Lldb-commits] [lldb] r186475 - simple plugin now works with Linux fix assert in SetPluginInfo implement Linux ePathTypeLLDBSystemPlugins and ePathTypeLLDBUserPlugins implement Linux Host::Backtrace and Host::GetEnvironment add .gnu_debugdata comment
Michael Sartain
mikesart at valvesoftware.com
Tue Jul 16 17:26:30 PDT 2013
Author: mikesart
Date: Tue Jul 16 19:26:30 2013
New Revision: 186475
URL: http://llvm.org/viewvc/llvm-project?rev=186475&view=rev
Log:
simple plugin now works with Linux fix assert in SetPluginInfo implement Linux ePathTypeLLDBSystemPlugins and ePathTypeLLDBUserPlugins implement Linux Host::Backtrace and Host::GetEnvironment add .gnu_debugdata comment
Differential Revision: http://llvm-reviews.chandlerc.com/D1159
Modified:
lldb/trunk/source/Core/Debugger.cpp
lldb/trunk/source/Core/PluginManager.cpp
lldb/trunk/source/Host/common/Host.cpp
lldb/trunk/source/Host/linux/Host.cpp
lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
Modified: lldb/trunk/source/Core/Debugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=186475&r1=186474&r2=186475&view=diff
==============================================================================
--- lldb/trunk/source/Core/Debugger.cpp (original)
+++ lldb/trunk/source/Core/Debugger.cpp Tue Jul 16 19:26:30 2013
@@ -413,6 +413,7 @@ Debugger::LoadPlugin (const FileSpec& sp
}
lldb::DebuggerSP debugger_sp(shared_from_this());
lldb::SBDebugger debugger_sb(debugger_sp);
+ // This calls the bool lldb::PluginInitialize(lldb::SBDebugger debugger) function.
// TODO: mangle this differently for your system - on OSX, the first underscore needs to be removed and the second one stays
LLDBCommandPluginInit init_func = dynlib_sp->GetSymbol<LLDBCommandPluginInit>("_ZN4lldb16PluginInitializeENS_10SBDebuggerE");
if (!init_func)
@@ -440,6 +441,7 @@ LoadPluginCallback
Error error;
static ConstString g_dylibext("dylib");
+ static ConstString g_solibext("so");
if (!baton)
return FileSpec::eEnumerateDirectoryResultQuit;
@@ -457,8 +459,11 @@ LoadPluginCallback
FileSpec plugin_file_spec (file_spec);
plugin_file_spec.ResolvePath ();
- if (plugin_file_spec.GetFileNameExtension() != g_dylibext)
+ if (plugin_file_spec.GetFileNameExtension() != g_dylibext &&
+ plugin_file_spec.GetFileNameExtension() != g_solibext)
+ {
return FileSpec::eEnumerateDirectoryResultNext;
+ }
Error plugin_load_error;
debugger->LoadPlugin (plugin_file_spec, plugin_load_error);
Modified: lldb/trunk/source/Core/PluginManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/PluginManager.cpp?rev=186475&r1=186474&r2=186475&view=diff
==============================================================================
--- lldb/trunk/source/Core/PluginManager.cpp (original)
+++ lldb/trunk/source/Core/PluginManager.cpp Tue Jul 16 19:26:30 2013
@@ -75,7 +75,7 @@ SetPluginInfo (const FileSpec &plugin_fi
{
Mutex::Locker locker (GetPluginMapMutex ());
PluginTerminateMap &plugin_map = GetPluginMap ();
- assert (plugin_map.find (plugin_file_spec) != plugin_map.end());
+ assert (plugin_map.find (plugin_file_spec) == plugin_map.end());
plugin_map[plugin_file_spec] = plugin_info;
}
Modified: lldb/trunk/source/Host/common/Host.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=186475&r1=186474&r2=186475&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/Host.cpp (original)
+++ lldb/trunk/source/Host/common/Host.cpp Tue Jul 16 19:26:30 2013
@@ -532,13 +532,13 @@ Host::ThreadCreated (const char *thread_
void
Host::Backtrace (Stream &strm, uint32_t max_frames)
{
- // TODO: Is there a way to backtrace the current process on linux? Other systems?
+ // TODO: Is there a way to backtrace the current process on other systems?
}
size_t
Host::GetEnvironment (StringList &env)
{
- // TODO: Is there a way to the host environment for this process on linux? Other systems?
+ // TODO: Is there a way to the host environment for this process on other systems?
return 0;
}
@@ -880,7 +880,7 @@ Host::GetLLDBPath (PathType path_type, F
// To get paths related to LLDB we get the path to the executable that
// contains this function. On MacOSX this will be "LLDB.framework/.../LLDB",
// on linux this is assumed to be the "lldb" main executable. If LLDB on
- // linux is actually in a shared library (lldb.so??) then this function will
+ // linux is actually in a shared library (liblldb.so) then this function will
// need to be modified to "do the right thing".
switch (path_type)
@@ -1008,12 +1008,13 @@ Host::GetLLDBPath (PathType path_type, F
case ePathTypeLLDBSystemPlugins: // System plug-ins directory
{
-#if defined (__APPLE__)
+#if defined (__APPLE__) || defined(__linux__)
static ConstString g_lldb_system_plugin_dir;
static bool g_lldb_system_plugin_dir_located = false;
if (!g_lldb_system_plugin_dir_located)
{
g_lldb_system_plugin_dir_located = true;
+#if defined (__APPLE__)
FileSpec lldb_file_spec;
if (GetLLDBPath (ePathTypeLLDBShlibDir, lldb_file_spec))
{
@@ -1031,6 +1032,13 @@ Host::GetLLDBPath (PathType path_type, F
}
return false;
}
+#elif defined (__linux__)
+ FileSpec lldb_file_spec("/usr/lib/lldb", true);
+ if (lldb_file_spec.Exists())
+ {
+ g_lldb_system_plugin_dir.SetCString(lldb_file_spec.GetPath().c_str());
+ }
+#endif // __APPLE__ || __linux__
}
if (g_lldb_system_plugin_dir)
@@ -1038,9 +1046,10 @@ Host::GetLLDBPath (PathType path_type, F
file_spec.GetDirectory() = g_lldb_system_plugin_dir;
return true;
}
-#endif
- // TODO: where would system LLDB plug-ins be located on linux? Other systems?
+#else
+ // TODO: where would system LLDB plug-ins be located on other systems?
return false;
+#endif
}
break;
@@ -1060,8 +1069,39 @@ Host::GetLLDBPath (PathType path_type, F
}
file_spec.GetDirectory() = g_lldb_user_plugin_dir;
return file_spec.GetDirectory();
+#elif defined (__linux__)
+ static ConstString g_lldb_user_plugin_dir;
+ if (!g_lldb_user_plugin_dir)
+ {
+ // XDG Base Directory Specification
+ // http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
+ // If XDG_DATA_HOME exists, use that, otherwise use ~/.local/share/lldb.
+ FileSpec lldb_file_spec;
+ const char *xdg_data_home = getenv("XDG_DATA_HOME");
+ if (xdg_data_home && xdg_data_home[0])
+ {
+ std::string user_plugin_dir (xdg_data_home);
+ user_plugin_dir += "/lldb";
+ lldb_file_spec.SetFile (user_plugin_dir.c_str(), true);
+ }
+ else
+ {
+ const char *home_dir = getenv("HOME");
+ if (home_dir && home_dir[0])
+ {
+ std::string user_plugin_dir (home_dir);
+ user_plugin_dir += "/.local/share/lldb";
+ lldb_file_spec.SetFile (user_plugin_dir.c_str(), true);
+ }
+ }
+
+ if (lldb_file_spec.Exists())
+ g_lldb_user_plugin_dir.SetCString(lldb_file_spec.GetPath().c_str());
+ }
+ file_spec.GetDirectory() = g_lldb_user_plugin_dir;
+ return file_spec.GetDirectory();
#endif
- // TODO: where would user LLDB plug-ins be located on linux? Other systems?
+ // TODO: where would user LLDB plug-ins be located on other systems?
return false;
}
}
Modified: lldb/trunk/source/Host/linux/Host.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/linux/Host.cpp?rev=186475&r1=186474&r2=186475&view=diff
==============================================================================
--- lldb/trunk/source/Host/linux/Host.cpp (original)
+++ lldb/trunk/source/Host/linux/Host.cpp Tue Jul 16 19:26:30 2013
@@ -14,6 +14,7 @@
#include <sys/stat.h>
#include <dirent.h>
#include <fcntl.h>
+#include <execinfo.h>
// C++ Includes
// Other libraries and framework includes
@@ -509,12 +510,28 @@ Host::GetThreadName (lldb::pid_t pid, ll
void
Host::Backtrace (Stream &strm, uint32_t max_frames)
{
- // TODO: Is there a way to backtrace the current process on linux?
+ if (max_frames > 0)
+ {
+ std::vector<void *> frame_buffer (max_frames, NULL);
+ int num_frames = ::backtrace (&frame_buffer[0], frame_buffer.size());
+ char** strs = ::backtrace_symbols (&frame_buffer[0], num_frames);
+ if (strs)
+ {
+ // Start at 1 to skip the "Host::Backtrace" frame
+ for (int i = 1; i < num_frames; ++i)
+ strm.Printf("%s\n", strs[i]);
+ ::free (strs);
+ }
+ }
}
size_t
Host::GetEnvironment (StringList &env)
{
- // TODO: Is there a way to the host environment for this process on linux?
- return 0;
+ char **host_env = environ;
+ char *env_entry;
+ size_t i;
+ for (i=0; (env_entry = host_env[i]) != NULL; ++i)
+ env.AppendString(env_entry);
+ return i;
}
Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp?rev=186475&r1=186474&r2=186475&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Tue Jul 16 19:26:30 2013
@@ -911,7 +911,8 @@ ObjectFileELF::CreateSections(SectionLis
// .debug_pubtypes â Lookup table for mapping type names to compilation units
// .debug_ranges â Address ranges used in DW_AT_ranges attributes
// .debug_str â String table used in .debug_info
- // MISSING? .debug-index http://src.chromium.org/viewvc/chrome/trunk/src/build/gdb-add-index?pathrev=144644
+ // MISSING? .gnu_debugdata - "mini debuginfo / MiniDebugInfo" section, http://sourceware.org/gdb/onlinedocs/gdb/MiniDebugInfo.html
+ // MISSING? .debug-index - http://src.chromium.org/viewvc/chrome/trunk/src/build/gdb-add-index?pathrev=144644
// MISSING? .debug_types - Type descriptions from DWARF 4? See http://gcc.gnu.org/wiki/DwarfSeparateTypeInfo
else if (name == g_sect_name_dwarf_debug_abbrev) sect_type = eSectionTypeDWARFDebugAbbrev;
else if (name == g_sect_name_dwarf_debug_aranges) sect_type = eSectionTypeDWARFDebugAranges;
More information about the lldb-commits
mailing list