summaryrefslogtreecommitdiffstats
path: root/lldb/source/Target
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2012-02-13 23:10:39 +0000
committerGreg Clayton <gclayton@apple.com>2012-02-13 23:10:39 +0000
commitc859e2d52488ef1852e6489716ddf6147402ea64 (patch)
tree5639f72ea58d93f18e65eb6fb71f76062fbba9e6 /lldb/source/Target
parent698452bc7e838e3a355029539d7f0be974d4d81d (diff)
downloadbcm5719-llvm-c859e2d52488ef1852e6489716ddf6147402ea64.tar.gz
bcm5719-llvm-c859e2d52488ef1852e6489716ddf6147402ea64.zip
Full core file support has been added for mach-o core files.
Tracking modules down when you have a UUID and a path has been improved. DynamicLoaderDarwinKernel no longer parses mach-o load commands and it now uses the memory based modules now that we can load modules from memory. Added a target setting named "target.exec-search-paths" which can be used to supply a list of directories to use when trying to look for executables. This allows one or more directories to be used when searching for modules that may not exist in the SDK/PDK. The target automatically adds the directory for the main executable to this list so this should help us in tracking down shared libraries and other binaries. llvm-svn: 150426
Diffstat (limited to 'lldb/source/Target')
-rw-r--r--lldb/source/Target/Platform.cpp7
-rw-r--r--lldb/source/Target/Process.cpp42
-rw-r--r--lldb/source/Target/SectionLoadList.cpp17
-rw-r--r--lldb/source/Target/Target.cpp91
-rw-r--r--lldb/source/Target/TargetList.cpp17
5 files changed, 159 insertions, 15 deletions
diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp
index 737b8d4914b..1c07db9c644 100644
--- a/lldb/source/Target/Platform.cpp
+++ b/lldb/source/Target/Platform.cpp
@@ -94,6 +94,7 @@ Platform::GetSharedModule (const FileSpec &platform_file,
const ConstString *object_name_ptr,
off_t object_offset,
ModuleSP &module_sp,
+ const FileSpecList *module_search_paths_ptr,
ModuleSP *old_module_sp_ptr,
bool *did_create_ptr)
{
@@ -111,6 +112,7 @@ Platform::GetSharedModule (const FileSpec &platform_file,
object_name_ptr,
object_offset,
module_sp,
+ module_search_paths_ptr,
old_module_sp_ptr,
did_create_ptr,
always_create);
@@ -403,7 +405,8 @@ Platform::SetOSVersion (uint32_t major,
Error
Platform::ResolveExecutable (const FileSpec &exe_file,
const ArchSpec &exe_arch,
- lldb::ModuleSP &exe_module_sp)
+ lldb::ModuleSP &exe_module_sp,
+ const FileSpecList *module_search_paths_ptr)
{
Error error;
if (exe_file.Exists())
@@ -416,6 +419,7 @@ Platform::ResolveExecutable (const FileSpec &exe_file,
NULL,
0,
exe_module_sp,
+ module_search_paths_ptr,
NULL,
NULL);
}
@@ -433,6 +437,7 @@ Platform::ResolveExecutable (const FileSpec &exe_file,
NULL,
0,
exe_module_sp,
+ module_search_paths_ptr,
NULL,
NULL);
// Did we find an executable using one of the
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 6ed2b2ac040..10922feb7db 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -2193,14 +2193,23 @@ Process::DeallocateMemory (addr_t ptr)
}
ModuleSP
-Process::ReadModuleFromMemory (const FileSpec& file_spec, lldb::addr_t header_addr)
+Process::ReadModuleFromMemory (const FileSpec& file_spec,
+ lldb::addr_t header_addr,
+ bool add_image_to_target,
+ bool load_sections_in_target)
{
ModuleSP module_sp (new Module (file_spec, shared_from_this(), header_addr));
if (module_sp)
{
- m_target.GetImages().Append(module_sp);
- bool changed = false;
- module_sp->SetLoadAddress (m_target, 0, changed);
+ if (add_image_to_target)
+ {
+ m_target.GetImages().Append(module_sp);
+ if (load_sections_in_target)
+ {
+ bool changed = false;
+ module_sp->SetLoadAddress (m_target, 0, changed);
+ }
+ }
}
return module_sp;
}
@@ -2306,9 +2315,9 @@ Process::Launch (const ProcessLaunchInfo &launch_info)
DidLaunch ();
- m_dyld_ap.reset (DynamicLoader::FindPlugin (this, NULL));
- if (m_dyld_ap.get())
- m_dyld_ap->DidLaunch();
+ DynamicLoader *dyld = GetDynamicLoader ();
+ if (dyld)
+ dyld->DidLaunch();
m_os_ap.reset (OperatingSystem::FindPlugin (this, NULL));
// This delays passing the stopped event to listeners till DidLaunch gets
@@ -2349,7 +2358,11 @@ Process::LoadCore ()
else
StartPrivateStateThread ();
- CompleteAttach ();
+ DynamicLoader *dyld = GetDynamicLoader ();
+ if (dyld)
+ dyld->DidAttach();
+
+ m_os_ap.reset (OperatingSystem::FindPlugin (this, NULL));
// We successfully loaded a core file, now pretend we stopped so we can
// show all of the threads in the core file and explore the crashed
// state.
@@ -2359,6 +2372,13 @@ Process::LoadCore ()
return error;
}
+DynamicLoader *
+Process::GetDynamicLoader ()
+{
+ if (m_dyld_ap.get() == NULL)
+ m_dyld_ap.reset (DynamicLoader::FindPlugin(this, NULL));
+ return m_dyld_ap.get();
+}
Process::NextEventAction::EventActionResult
@@ -2622,9 +2642,9 @@ Process::CompleteAttach ()
// We have completed the attach, now it is time to find the dynamic loader
// plug-in
- m_dyld_ap.reset (DynamicLoader::FindPlugin(this, NULL));
- if (m_dyld_ap.get())
- m_dyld_ap->DidAttach();
+ DynamicLoader *dyld = GetDynamicLoader ();
+ if (dyld)
+ dyld->DidAttach();
m_os_ap.reset (OperatingSystem::FindPlugin (this, NULL));
// Figure out which one is the executable, and set that in our target:
diff --git a/lldb/source/Target/SectionLoadList.cpp b/lldb/source/Target/SectionLoadList.cpp
index 09431abc00f..df2802378b1 100644
--- a/lldb/source/Target/SectionLoadList.cpp
+++ b/lldb/source/Target/SectionLoadList.cpp
@@ -74,6 +74,9 @@ SectionLoadList::SetSectionLoadAddress (const Section *section, addr_t load_addr
load_addr);
}
+ if (section->GetByteSize() == 0)
+ return false; // No change
+
Mutex::Locker locker(m_mutex);
sect_to_addr_collection::iterator sta_pos = m_sect_to_addr.find(section);
if (sta_pos != m_sect_to_addr.end())
@@ -89,7 +92,19 @@ SectionLoadList::SetSectionLoadAddress (const Section *section, addr_t load_addr
addr_to_sect_collection::iterator ats_pos = m_addr_to_sect.find(load_addr);
if (ats_pos != m_addr_to_sect.end())
{
- assert (section != ats_pos->second);
+ if (section != ats_pos->second)
+ {
+ Module *module = section->GetModule();
+ if (module)
+ {
+ module->ReportWarning ("address 0x%16.16llx maps to more than one section: %s.%s and %s.%s",
+ load_addr,
+ module->GetFileSpec().GetFilename().GetCString(),
+ section->GetName().GetCString(),
+ ats_pos->second->GetModule()->GetFileSpec().GetFilename().GetCString(),
+ ats_pos->second->GetName().GetCString());
+ }
+ }
ats_pos->second = section;
}
else
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 20b8e938fe1..6a6cb0eae7e 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -869,6 +869,7 @@ Target::SetArchitecture (const ArchSpec &arch_spec)
NULL,
0,
executable_sp,
+ &GetExecutableSearchPaths(),
NULL,
NULL);
@@ -1227,7 +1228,15 @@ Target::GetSharedModule
if (m_image_search_paths.RemapPath (file_spec.GetDirectory(), transformed_spec.GetDirectory()))
{
transformed_spec.GetFilename() = file_spec.GetFilename();
- error = ModuleList::GetSharedModule (transformed_spec, arch, uuid_ptr, object_name, object_offset, module_sp, &old_module_sp, &did_create_module);
+ error = ModuleList::GetSharedModule (transformed_spec,
+ arch,
+ uuid_ptr,
+ object_name,
+ object_offset,
+ module_sp,
+ &GetExecutableSearchPaths(),
+ &old_module_sp,
+ &did_create_module);
}
}
@@ -1242,6 +1251,7 @@ Target::GetSharedModule
object_name,
object_offset,
module_sp,
+ &GetExecutableSearchPaths(),
&old_module_sp,
&did_create_module);
}
@@ -1395,6 +1405,20 @@ Target::GetSettingsController ()
return g_settings_controller_sp;
}
+FileSpecList
+Target::GetDefaultExecutableSearchPaths ()
+{
+ lldb::UserSettingsControllerSP settings_controller_sp (GetSettingsController());
+ if (settings_controller_sp)
+ {
+ lldb::InstanceSettingsSP instance_settings_sp (settings_controller_sp->GetDefaultInstanceSettings ());
+ if (instance_settings_sp)
+ return static_cast<TargetInstanceSettings *>(instance_settings_sp.get())->GetExecutableSearchPaths ();
+ }
+ return FileSpecList();
+}
+
+
ArchSpec
Target::GetDefaultArchitecture ()
{
@@ -2016,6 +2040,7 @@ Target::SettingsController::CreateInstanceSettings (const char *instance_name)
#define TSC_PREFER_DYNAMIC "prefer-dynamic-value"
#define TSC_SKIP_PROLOGUE "skip-prologue"
#define TSC_SOURCE_MAP "source-map"
+#define TSC_EXE_SEARCH_PATHS "exec-search-paths"
#define TSC_MAX_CHILDREN "max-children-count"
#define TSC_MAX_STRLENSUMMARY "max-string-summary-length"
#define TSC_PLATFORM_AVOID "breakpoints-use-platform-avoid-list"
@@ -2058,6 +2083,13 @@ GetSettingNameForSourcePathMap ()
}
static const ConstString &
+GetSettingNameForExecutableSearchPaths ()
+{
+ static ConstString g_const_string (TSC_EXE_SEARCH_PATHS);
+ return g_const_string;
+}
+
+static const ConstString &
GetSettingNameForSkipPrologue ()
{
static ConstString g_const_string (TSC_SKIP_PROLOGUE);
@@ -2193,6 +2225,7 @@ TargetInstanceSettings::TargetInstanceSettings
m_prefer_dynamic_value (2),
m_skip_prologue (true, true),
m_source_map (NULL, NULL),
+ m_exe_search_paths (),
m_max_children_display(256),
m_max_strlen_length(1024),
m_breakpoints_use_platform_avoid (true, true),
@@ -2231,6 +2264,7 @@ TargetInstanceSettings::TargetInstanceSettings (const TargetInstanceSettings &rh
m_prefer_dynamic_value (rhs.m_prefer_dynamic_value),
m_skip_prologue (rhs.m_skip_prologue),
m_source_map (rhs.m_source_map),
+ m_exe_search_paths (rhs.m_exe_search_paths),
m_max_children_display (rhs.m_max_children_display),
m_max_strlen_length (rhs.m_max_strlen_length),
m_breakpoints_use_platform_avoid (rhs.m_breakpoints_use_platform_avoid),
@@ -2265,6 +2299,7 @@ TargetInstanceSettings::operator= (const TargetInstanceSettings &rhs)
m_prefer_dynamic_value = rhs.m_prefer_dynamic_value;
m_skip_prologue = rhs.m_skip_prologue;
m_source_map = rhs.m_source_map;
+ m_exe_search_paths = rhs.m_exe_search_paths;
m_max_children_display = rhs.m_max_children_display;
m_max_strlen_length = rhs.m_max_strlen_length;
m_breakpoints_use_platform_avoid = rhs.m_breakpoints_use_platform_avoid;
@@ -2357,6 +2392,49 @@ TargetInstanceSettings::UpdateInstanceSettingsVariable (const ConstString &var_n
if (ok)
m_max_strlen_length = new_value;
}
+ else if (var_name == GetSettingNameForExecutableSearchPaths())
+ {
+ switch (op)
+ {
+ case eVarSetOperationReplace:
+ case eVarSetOperationInsertBefore:
+ case eVarSetOperationInsertAfter:
+ case eVarSetOperationRemove:
+ default:
+ break;
+ case eVarSetOperationAssign:
+ m_exe_search_paths.Clear();
+ // Fall through to append....
+ case eVarSetOperationAppend:
+ {
+ Args args(value);
+ const uint32_t argc = args.GetArgumentCount();
+ if (argc > 0)
+ {
+ const char *exe_search_path_dir;
+ for (uint32_t idx = 0; (exe_search_path_dir = args.GetArgumentAtIndex(idx)) != NULL; ++idx)
+ {
+ FileSpec file_spec;
+ file_spec.GetDirectory().SetCString(exe_search_path_dir);
+ FileSpec::FileType file_type = file_spec.GetFileType();
+ if (file_type == FileSpec::eFileTypeDirectory || file_type == FileSpec::eFileTypeInvalid)
+ {
+ m_exe_search_paths.Append(file_spec);
+ }
+ else
+ {
+ err.SetErrorStringWithFormat("executable search path '%s' exists, but it does not resolve to a directory", exe_search_path_dir);
+ }
+ }
+ }
+ }
+ break;
+
+ case eVarSetOperationClear:
+ m_exe_search_paths.Clear();
+ break;
+ }
+ }
else if (var_name == GetSettingNameForSourcePathMap ())
{
switch (op)
@@ -2487,6 +2565,16 @@ TargetInstanceSettings::GetInstanceSettingsValue (const SettingEntry &entry,
else
value.AppendString ("false");
}
+ else if (var_name == GetSettingNameForExecutableSearchPaths())
+ {
+ if (m_exe_search_paths.GetSize())
+ {
+ for (size_t i = 0, n = m_exe_search_paths.GetSize(); i < n; ++i)
+ {
+ value.AppendString(m_exe_search_paths.GetFileSpecAtIndex (i).GetDirectory().AsCString());
+ }
+ }
+ }
else if (var_name == GetSettingNameForSourcePathMap ())
{
if (m_source_map.GetSize())
@@ -2670,6 +2758,7 @@ Target::SettingsController::instance_settings_table[] =
{ TSC_PREFER_DYNAMIC , eSetVarTypeEnum , NULL , g_dynamic_value_types, false, false, "Should printed values be shown as their dynamic value." },
{ TSC_SKIP_PROLOGUE , eSetVarTypeBoolean, "true" , NULL, false, false, "Skip function prologues when setting breakpoints by name." },
{ TSC_SOURCE_MAP , eSetVarTypeArray , NULL , NULL, false, false, "Source path remappings to use when locating source files from debug information." },
+ { TSC_EXE_SEARCH_PATHS , eSetVarTypeArray , NULL , NULL, false, false, "Executable search paths to use when locating executable files whose paths don't match the local file system." },
{ TSC_MAX_CHILDREN , eSetVarTypeInt , "256" , NULL, true, false, "Maximum number of children to expand in any level of depth." },
{ TSC_MAX_STRLENSUMMARY , eSetVarTypeInt , "1024" , NULL, true, false, "Maximum number of characters to show when using %s in summary strings." },
{ TSC_PLATFORM_AVOID , eSetVarTypeBoolean, "true" , NULL, false, false, "Consult the platform module avoid list when setting non-module specific breakpoints." },
diff --git a/lldb/source/Target/TargetList.cpp b/lldb/source/Target/TargetList.cpp
index 6ca58b86ef5..e412beb1da5 100644
--- a/lldb/source/Target/TargetList.cpp
+++ b/lldb/source/Target/TargetList.cpp
@@ -92,6 +92,16 @@ TargetList::CreateTarget (Debugger &debugger,
get_dependent_files,
platform_sp,
target_sp);
+
+ if (target_sp)
+ {
+ if (file.GetDirectory())
+ {
+ FileSpec file_dir;
+ file_dir.GetDirectory() = file.GetDirectory();
+ target_sp->GetExecutableSearchPaths ().Append (file_dir);
+ }
+ }
return error;
}
@@ -120,7 +130,12 @@ TargetList::CreateTarget
FileSpec resolved_file(file);
if (platform_sp)
- error = platform_sp->ResolveExecutable (file, arch, exe_module_sp);
+ {
+ FileSpecList executable_search_paths (Target::GetDefaultExecutableSearchPaths());
+ error = platform_sp->ResolveExecutable (file, arch,
+ exe_module_sp,
+ executable_search_paths.GetSize() ? &executable_search_paths : NULL);
+ }
if (error.Success() && exe_module_sp)
{
OpenPOWER on IntegriCloud