Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes: - Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file". - modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly - Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was. - modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile() Cleaned up header includes a bit as well. llvm-svn: 162860
213 lines
6.4 KiB
C++
213 lines
6.4 KiB
C++
//===-- DynamicLoaderStatic.cpp ---------------------------------*- C++ -*-===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "lldb/Core/Module.h"
|
|
#include "lldb/Core/PluginManager.h"
|
|
#include "lldb/Core/Section.h"
|
|
#include "lldb/Symbol/ObjectFile.h"
|
|
#include "lldb/Target/Target.h"
|
|
|
|
#include "DynamicLoaderStatic.h"
|
|
|
|
using namespace lldb;
|
|
using namespace lldb_private;
|
|
|
|
//----------------------------------------------------------------------
|
|
// Create an instance of this class. This function is filled into
|
|
// the plugin info class that gets handed out by the plugin factory and
|
|
// allows the lldb to instantiate an instance of this class.
|
|
//----------------------------------------------------------------------
|
|
DynamicLoader *
|
|
DynamicLoaderStatic::CreateInstance (Process* process, bool force)
|
|
{
|
|
bool create = force;
|
|
if (!create)
|
|
{
|
|
const llvm::Triple &triple_ref = process->GetTarget().GetArchitecture().GetTriple();
|
|
const llvm::Triple::OSType os_type = triple_ref.getOS();
|
|
if ((os_type == llvm::Triple::UnknownOS))
|
|
create = true;
|
|
}
|
|
|
|
if (!create)
|
|
{
|
|
Module *exe_module = process->GetTarget().GetExecutableModulePointer();
|
|
if (exe_module)
|
|
{
|
|
ObjectFile *object_file = exe_module->GetObjectFile();
|
|
if (object_file)
|
|
{
|
|
create = (object_file->GetStrata() == ObjectFile::eStrataRawImage);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (create)
|
|
return new DynamicLoaderStatic (process);
|
|
return NULL;
|
|
}
|
|
|
|
//----------------------------------------------------------------------
|
|
// Constructor
|
|
//----------------------------------------------------------------------
|
|
DynamicLoaderStatic::DynamicLoaderStatic (Process* process) :
|
|
DynamicLoader(process)
|
|
{
|
|
}
|
|
|
|
//----------------------------------------------------------------------
|
|
// Destructor
|
|
//----------------------------------------------------------------------
|
|
DynamicLoaderStatic::~DynamicLoaderStatic()
|
|
{
|
|
}
|
|
|
|
//------------------------------------------------------------------
|
|
/// Called after attaching a process.
|
|
///
|
|
/// Allow DynamicLoader plug-ins to execute some code after
|
|
/// attaching to a process.
|
|
//------------------------------------------------------------------
|
|
void
|
|
DynamicLoaderStatic::DidAttach ()
|
|
{
|
|
LoadAllImagesAtFileAddresses();
|
|
}
|
|
|
|
//------------------------------------------------------------------
|
|
/// Called after attaching a process.
|
|
///
|
|
/// Allow DynamicLoader plug-ins to execute some code after
|
|
/// attaching to a process.
|
|
//------------------------------------------------------------------
|
|
void
|
|
DynamicLoaderStatic::DidLaunch ()
|
|
{
|
|
LoadAllImagesAtFileAddresses();
|
|
}
|
|
|
|
void
|
|
DynamicLoaderStatic::LoadAllImagesAtFileAddresses ()
|
|
{
|
|
ModuleList &module_list = m_process->GetTarget().GetImages();
|
|
|
|
ModuleList loaded_module_list;
|
|
|
|
Mutex::Locker mutex_locker(module_list.GetMutex());
|
|
|
|
const size_t num_modules = module_list.GetSize();
|
|
for (uint32_t idx = 0; idx < num_modules; ++idx)
|
|
{
|
|
ModuleSP module_sp (module_list.GetModuleAtIndexUnlocked (idx));
|
|
if (module_sp)
|
|
{
|
|
bool changed = false;
|
|
ObjectFile *image_object_file = module_sp->GetObjectFile();
|
|
if (image_object_file)
|
|
{
|
|
SectionList *section_list = image_object_file->GetSectionList ();
|
|
if (section_list)
|
|
{
|
|
// All sections listed in the dyld image info structure will all
|
|
// either be fixed up already, or they will all be off by a single
|
|
// slide amount that is determined by finding the first segment
|
|
// that is at file offset zero which also has bytes (a file size
|
|
// that is greater than zero) in the object file.
|
|
|
|
// Determine the slide amount (if any)
|
|
const size_t num_sections = section_list->GetSize();
|
|
size_t sect_idx = 0;
|
|
for (sect_idx = 0; sect_idx < num_sections; ++sect_idx)
|
|
{
|
|
// Iterate through the object file sections to find the
|
|
// first section that starts of file offset zero and that
|
|
// has bytes in the file...
|
|
SectionSP section_sp (section_list->GetSectionAtIndex (sect_idx));
|
|
if (section_sp)
|
|
{
|
|
if (m_process->GetTarget().GetSectionLoadList().SetSectionLoadAddress (section_sp, section_sp->GetFileAddress()))
|
|
changed = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (changed)
|
|
loaded_module_list.AppendIfNeeded (module_sp);
|
|
}
|
|
}
|
|
|
|
if (loaded_module_list.GetSize())
|
|
m_process->GetTarget().ModulesDidLoad (loaded_module_list);
|
|
}
|
|
|
|
ThreadPlanSP
|
|
DynamicLoaderStatic::GetStepThroughTrampolinePlan (Thread &thread, bool stop_others)
|
|
{
|
|
return ThreadPlanSP();
|
|
}
|
|
|
|
Error
|
|
DynamicLoaderStatic::CanLoadImage ()
|
|
{
|
|
Error error;
|
|
error.SetErrorString ("can't load images on with a static debug session");
|
|
return error;
|
|
}
|
|
|
|
void
|
|
DynamicLoaderStatic::Initialize()
|
|
{
|
|
PluginManager::RegisterPlugin (GetPluginNameStatic(),
|
|
GetPluginDescriptionStatic(),
|
|
CreateInstance);
|
|
}
|
|
|
|
void
|
|
DynamicLoaderStatic::Terminate()
|
|
{
|
|
PluginManager::UnregisterPlugin (CreateInstance);
|
|
}
|
|
|
|
|
|
const char *
|
|
DynamicLoaderStatic::GetPluginNameStatic()
|
|
{
|
|
return "dynamic-loader.static";
|
|
}
|
|
|
|
const char *
|
|
DynamicLoaderStatic::GetPluginDescriptionStatic()
|
|
{
|
|
return "Dynamic loader plug-in that will load any images at the static addresses contained in each image.";
|
|
}
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
// PluginInterface protocol
|
|
//------------------------------------------------------------------
|
|
const char *
|
|
DynamicLoaderStatic::GetPluginName()
|
|
{
|
|
return "DynamicLoaderStatic";
|
|
}
|
|
|
|
const char *
|
|
DynamicLoaderStatic::GetShortPluginName()
|
|
{
|
|
return GetPluginNameStatic();
|
|
}
|
|
|
|
uint32_t
|
|
DynamicLoaderStatic::GetPluginVersion()
|
|
{
|
|
return 1;
|
|
}
|
|
|