2010-06-09 00:52:24 +08:00
|
|
|
//===-- SBTarget.cpp --------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2012-12-05 08:20:57 +08:00
|
|
|
#include "lldb/lldb-python.h"
|
|
|
|
|
2010-06-09 15:44:37 +08:00
|
|
|
#include "lldb/API/SBTarget.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2011-03-25 05:19:54 +08:00
|
|
|
#include "lldb/lldb-public.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2011-06-30 06:09:02 +08:00
|
|
|
#include "lldb/API/SBDebugger.h"
|
|
|
|
#include "lldb/API/SBBreakpoint.h"
|
2013-01-05 02:10:18 +08:00
|
|
|
#include "lldb/API/SBExpressionOptions.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/API/SBFileSpec.h"
|
2011-06-30 06:09:02 +08:00
|
|
|
#include "lldb/API/SBListener.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/API/SBModule.h"
|
Added a way to extract the module specifications from a file. A module specification is information that is required to describe a module (executable, shared library, object file, ect). This information includes host path, platform path (remote path), symbol file path, UUID, object name (for objects in .a files for example you could have an object name of "foo.o"), and target triple. Module specification can be used to create a module, or used to add a module to a target. A list of module specifications can be used to enumerate objects in container objects (like universal mach files and BSD archive files).
There are two new classes:
lldb::SBModuleSpec
lldb::SBModuleSpecList
The SBModuleSpec wraps up a lldb_private::ModuleSpec, and SBModuleSpecList wraps up a lldb_private::ModuleSpecList.
llvm-svn: 185877
2013-07-09 06:22:41 +08:00
|
|
|
#include "lldb/API/SBModuleSpec.h"
|
2011-09-13 08:29:56 +08:00
|
|
|
#include "lldb/API/SBSourceManager.h"
|
2011-06-30 06:09:02 +08:00
|
|
|
#include "lldb/API/SBProcess.h"
|
2010-09-20 13:20:02 +08:00
|
|
|
#include "lldb/API/SBStream.h"
|
2011-06-21 09:34:41 +08:00
|
|
|
#include "lldb/API/SBSymbolContextList.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Breakpoint/BreakpointID.h"
|
|
|
|
#include "lldb/Breakpoint/BreakpointIDList.h"
|
|
|
|
#include "lldb/Breakpoint/BreakpointList.h"
|
|
|
|
#include "lldb/Breakpoint/BreakpointLocation.h"
|
|
|
|
#include "lldb/Core/Address.h"
|
|
|
|
#include "lldb/Core/AddressResolver.h"
|
|
|
|
#include "lldb/Core/AddressResolverName.h"
|
|
|
|
#include "lldb/Core/ArchSpec.h"
|
|
|
|
#include "lldb/Core/Debugger.h"
|
|
|
|
#include "lldb/Core/Disassembler.h"
|
2010-10-26 11:11:13 +08:00
|
|
|
#include "lldb/Core/Log.h"
|
<rdar://problem/11757916>
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
2012-08-30 05:13:06 +08:00
|
|
|
#include "lldb/Core/Module.h"
|
|
|
|
#include "lldb/Core/ModuleSpec.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Core/RegularExpression.h"
|
|
|
|
#include "lldb/Core/SearchFilter.h"
|
<rdar://problem/11757916>
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
2012-08-30 05:13:06 +08:00
|
|
|
#include "lldb/Core/Section.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Core/STLUtils.h"
|
2013-10-09 05:49:02 +08:00
|
|
|
#include "lldb/Core/ValueObjectConstResult.h"
|
2011-06-30 06:09:02 +08:00
|
|
|
#include "lldb/Core/ValueObjectList.h"
|
|
|
|
#include "lldb/Core/ValueObjectVariable.h"
|
|
|
|
#include "lldb/Host/FileSpec.h"
|
2011-02-01 09:31:41 +08:00
|
|
|
#include "lldb/Host/Host.h"
|
2011-06-30 06:09:02 +08:00
|
|
|
#include "lldb/Interpreter/Args.h"
|
<rdar://problem/11757916>
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
2012-08-30 05:13:06 +08:00
|
|
|
#include "lldb/Symbol/ObjectFile.h"
|
2011-07-30 03:53:35 +08:00
|
|
|
#include "lldb/Symbol/SymbolVendor.h"
|
2011-06-30 06:09:02 +08:00
|
|
|
#include "lldb/Symbol/VariableList.h"
|
2012-03-06 08:37:27 +08:00
|
|
|
#include "lldb/Target/LanguageRuntime.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Target/Process.h"
|
2013-12-06 09:12:00 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Target/Target.h"
|
|
|
|
#include "lldb/Target/TargetList.h"
|
|
|
|
|
|
|
|
#include "lldb/Interpreter/CommandReturnObject.h"
|
|
|
|
#include "../source/Commands/CommandObjectBreakpoint.h"
|
2014-09-20 03:38:19 +08:00
|
|
|
#include "llvm/Support/Regex.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
|
|
#define DEFAULT_DISASM_BYTE_SIZE 32
|
|
|
|
|
2012-02-25 04:59:25 +08:00
|
|
|
SBLaunchInfo::SBLaunchInfo (const char **argv) :
|
|
|
|
m_opaque_sp(new ProcessLaunchInfo())
|
2012-02-24 13:03:03 +08:00
|
|
|
{
|
2012-02-25 04:59:25 +08:00
|
|
|
m_opaque_sp->GetFlags().Reset (eLaunchFlagDebug | eLaunchFlagDisableASLR);
|
|
|
|
if (argv && argv[0])
|
|
|
|
m_opaque_sp->GetArguments().SetArguments(argv);
|
2012-02-24 13:03:03 +08:00
|
|
|
}
|
|
|
|
|
2012-03-08 07:52:51 +08:00
|
|
|
SBLaunchInfo::~SBLaunchInfo()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb_private::ProcessLaunchInfo &
|
|
|
|
SBLaunchInfo::ref ()
|
|
|
|
{
|
|
|
|
return *m_opaque_sp;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-02-24 13:03:03 +08:00
|
|
|
uint32_t
|
|
|
|
SBLaunchInfo::GetUserID()
|
|
|
|
{
|
|
|
|
return m_opaque_sp->GetUserID();
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
SBLaunchInfo::GetGroupID()
|
|
|
|
{
|
|
|
|
return m_opaque_sp->GetGroupID();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBLaunchInfo::UserIDIsValid ()
|
|
|
|
{
|
|
|
|
return m_opaque_sp->UserIDIsValid();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBLaunchInfo::GroupIDIsValid ()
|
|
|
|
{
|
|
|
|
return m_opaque_sp->GroupIDIsValid();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBLaunchInfo::SetUserID (uint32_t uid)
|
|
|
|
{
|
|
|
|
m_opaque_sp->SetUserID (uid);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBLaunchInfo::SetGroupID (uint32_t gid)
|
|
|
|
{
|
|
|
|
m_opaque_sp->SetGroupID (gid);
|
|
|
|
}
|
|
|
|
|
2014-05-08 04:16:06 +08:00
|
|
|
SBFileSpec
|
|
|
|
SBLaunchInfo::GetExecutableFile ()
|
|
|
|
{
|
|
|
|
return SBFileSpec (m_opaque_sp->GetExecutableFile());
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBLaunchInfo::SetExecutableFile (SBFileSpec exe_file, bool add_as_first_arg)
|
|
|
|
{
|
|
|
|
m_opaque_sp->SetExecutableFile(exe_file.ref(), add_as_first_arg);
|
|
|
|
}
|
|
|
|
|
2014-11-18 03:39:20 +08:00
|
|
|
SBListener
|
|
|
|
SBLaunchInfo::GetListener ()
|
|
|
|
{
|
|
|
|
return SBListener(m_opaque_sp->GetListener());
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBLaunchInfo::SetListener (SBListener &listener)
|
|
|
|
{
|
|
|
|
m_opaque_sp->SetListener(listener.GetSP());
|
|
|
|
}
|
|
|
|
|
2012-02-24 13:03:03 +08:00
|
|
|
uint32_t
|
|
|
|
SBLaunchInfo::GetNumArguments ()
|
|
|
|
{
|
|
|
|
return m_opaque_sp->GetArguments().GetArgumentCount();
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
SBLaunchInfo::GetArgumentAtIndex (uint32_t idx)
|
|
|
|
{
|
|
|
|
return m_opaque_sp->GetArguments().GetArgumentAtIndex(idx);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBLaunchInfo::SetArguments (const char **argv, bool append)
|
|
|
|
{
|
|
|
|
if (append)
|
|
|
|
{
|
|
|
|
if (argv)
|
|
|
|
m_opaque_sp->GetArguments().AppendArguments(argv);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (argv)
|
|
|
|
m_opaque_sp->GetArguments().SetArguments(argv);
|
|
|
|
else
|
|
|
|
m_opaque_sp->GetArguments().Clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
SBLaunchInfo::GetNumEnvironmentEntries ()
|
|
|
|
{
|
|
|
|
return m_opaque_sp->GetEnvironmentEntries().GetArgumentCount();
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
SBLaunchInfo::GetEnvironmentEntryAtIndex (uint32_t idx)
|
|
|
|
{
|
|
|
|
return m_opaque_sp->GetEnvironmentEntries().GetArgumentAtIndex(idx);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBLaunchInfo::SetEnvironmentEntries (const char **envp, bool append)
|
|
|
|
{
|
|
|
|
if (append)
|
|
|
|
{
|
|
|
|
if (envp)
|
|
|
|
m_opaque_sp->GetEnvironmentEntries().AppendArguments(envp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (envp)
|
|
|
|
m_opaque_sp->GetEnvironmentEntries().SetArguments(envp);
|
|
|
|
else
|
|
|
|
m_opaque_sp->GetEnvironmentEntries().Clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBLaunchInfo::Clear ()
|
|
|
|
{
|
|
|
|
m_opaque_sp->Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
SBLaunchInfo::GetWorkingDirectory () const
|
|
|
|
{
|
|
|
|
return m_opaque_sp->GetWorkingDirectory();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBLaunchInfo::SetWorkingDirectory (const char *working_dir)
|
|
|
|
{
|
|
|
|
m_opaque_sp->SetWorkingDirectory(working_dir);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
SBLaunchInfo::GetLaunchFlags ()
|
|
|
|
{
|
|
|
|
return m_opaque_sp->GetFlags().Get();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBLaunchInfo::SetLaunchFlags (uint32_t flags)
|
|
|
|
{
|
|
|
|
m_opaque_sp->GetFlags().Reset(flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
SBLaunchInfo::GetProcessPluginName ()
|
|
|
|
{
|
|
|
|
return m_opaque_sp->GetProcessPluginName();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBLaunchInfo::SetProcessPluginName (const char *plugin_name)
|
|
|
|
{
|
|
|
|
return m_opaque_sp->SetProcessPluginName (plugin_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
SBLaunchInfo::GetShell ()
|
|
|
|
{
|
2014-10-21 01:46:43 +08:00
|
|
|
// Constify this string so that it is saved in the string pool. Otherwise
|
|
|
|
// it would be freed when this function goes out of scope.
|
|
|
|
ConstString shell(m_opaque_sp->GetShell().GetPath().c_str());
|
|
|
|
return shell.AsCString();
|
2012-02-24 13:03:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBLaunchInfo::SetShell (const char * path)
|
|
|
|
{
|
2014-10-21 01:46:43 +08:00
|
|
|
m_opaque_sp->SetShell (FileSpec(path, false));
|
2012-02-24 13:03:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
SBLaunchInfo::GetResumeCount ()
|
|
|
|
{
|
|
|
|
return m_opaque_sp->GetResumeCount();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBLaunchInfo::SetResumeCount (uint32_t c)
|
|
|
|
{
|
|
|
|
m_opaque_sp->SetResumeCount (c);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBLaunchInfo::AddCloseFileAction (int fd)
|
|
|
|
{
|
|
|
|
return m_opaque_sp->AppendCloseFileAction(fd);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBLaunchInfo::AddDuplicateFileAction (int fd, int dup_fd)
|
|
|
|
{
|
|
|
|
return m_opaque_sp->AppendDuplicateFileAction(fd, dup_fd);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBLaunchInfo::AddOpenFileAction (int fd, const char *path, bool read, bool write)
|
|
|
|
{
|
|
|
|
return m_opaque_sp->AppendOpenFileAction(fd, path, read, write);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBLaunchInfo::AddSuppressFileAction (int fd, bool read, bool write)
|
|
|
|
{
|
|
|
|
return m_opaque_sp->AppendSuppressFileAction(fd, read, write);
|
|
|
|
}
|
|
|
|
|
2014-03-30 02:54:20 +08:00
|
|
|
void
|
|
|
|
SBLaunchInfo::SetLaunchEventData (const char *data)
|
|
|
|
{
|
|
|
|
m_opaque_sp->SetLaunchEventData (data);
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
SBLaunchInfo::GetLaunchEventData () const
|
|
|
|
{
|
|
|
|
return m_opaque_sp->GetLaunchEventData ();
|
|
|
|
}
|
2012-02-24 13:03:03 +08:00
|
|
|
|
2014-06-25 10:32:56 +08:00
|
|
|
void
|
|
|
|
SBLaunchInfo::SetDetachOnError (bool enable)
|
|
|
|
{
|
|
|
|
m_opaque_sp->SetDetachOnError (enable);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBLaunchInfo::GetDetachOnError () const
|
|
|
|
{
|
|
|
|
return m_opaque_sp->GetDetachOnError ();
|
|
|
|
}
|
|
|
|
|
2012-02-24 13:03:03 +08:00
|
|
|
SBAttachInfo::SBAttachInfo () :
|
2012-03-08 07:52:51 +08:00
|
|
|
m_opaque_sp (new ProcessAttachInfo())
|
2012-02-24 13:03:03 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SBAttachInfo::SBAttachInfo (lldb::pid_t pid) :
|
2012-03-08 07:52:51 +08:00
|
|
|
m_opaque_sp (new ProcessAttachInfo())
|
2012-02-24 13:03:03 +08:00
|
|
|
{
|
|
|
|
m_opaque_sp->SetProcessID (pid);
|
|
|
|
}
|
|
|
|
|
|
|
|
SBAttachInfo::SBAttachInfo (const char *path, bool wait_for) :
|
2012-03-08 07:52:51 +08:00
|
|
|
m_opaque_sp (new ProcessAttachInfo())
|
2012-02-24 13:03:03 +08:00
|
|
|
{
|
|
|
|
if (path && path[0])
|
|
|
|
m_opaque_sp->GetExecutableFile().SetFile(path, false);
|
|
|
|
m_opaque_sp->SetWaitForLaunch (wait_for);
|
|
|
|
}
|
|
|
|
|
|
|
|
SBAttachInfo::SBAttachInfo (const SBAttachInfo &rhs) :
|
2012-03-08 07:52:51 +08:00
|
|
|
m_opaque_sp (new ProcessAttachInfo())
|
2012-02-24 13:03:03 +08:00
|
|
|
{
|
|
|
|
*m_opaque_sp = *rhs.m_opaque_sp;
|
|
|
|
}
|
|
|
|
|
2012-03-08 07:52:51 +08:00
|
|
|
SBAttachInfo::~SBAttachInfo()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb_private::ProcessAttachInfo &
|
|
|
|
SBAttachInfo::ref ()
|
|
|
|
{
|
|
|
|
return *m_opaque_sp;
|
|
|
|
}
|
|
|
|
|
2012-02-24 13:03:03 +08:00
|
|
|
SBAttachInfo &
|
|
|
|
SBAttachInfo::operator = (const SBAttachInfo &rhs)
|
|
|
|
{
|
|
|
|
if (this != &rhs)
|
|
|
|
*m_opaque_sp = *rhs.m_opaque_sp;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb::pid_t
|
|
|
|
SBAttachInfo::GetProcessID ()
|
|
|
|
{
|
|
|
|
return m_opaque_sp->GetProcessID();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBAttachInfo::SetProcessID (lldb::pid_t pid)
|
|
|
|
{
|
|
|
|
m_opaque_sp->SetProcessID (pid);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
SBAttachInfo::GetResumeCount ()
|
|
|
|
{
|
|
|
|
return m_opaque_sp->GetResumeCount();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBAttachInfo::SetResumeCount (uint32_t c)
|
|
|
|
{
|
|
|
|
m_opaque_sp->SetResumeCount (c);
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
SBAttachInfo::GetProcessPluginName ()
|
|
|
|
{
|
|
|
|
return m_opaque_sp->GetProcessPluginName();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBAttachInfo::SetProcessPluginName (const char *plugin_name)
|
|
|
|
{
|
|
|
|
return m_opaque_sp->SetProcessPluginName (plugin_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBAttachInfo::SetExecutable (const char *path)
|
|
|
|
{
|
|
|
|
if (path && path[0])
|
|
|
|
m_opaque_sp->GetExecutableFile().SetFile(path, false);
|
|
|
|
else
|
|
|
|
m_opaque_sp->GetExecutableFile().Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBAttachInfo::SetExecutable (SBFileSpec exe_file)
|
|
|
|
{
|
|
|
|
if (exe_file.IsValid())
|
|
|
|
m_opaque_sp->GetExecutableFile() = exe_file.ref();
|
|
|
|
else
|
|
|
|
m_opaque_sp->GetExecutableFile().Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBAttachInfo::GetWaitForLaunch ()
|
|
|
|
{
|
|
|
|
return m_opaque_sp->GetWaitForLaunch();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBAttachInfo::SetWaitForLaunch (bool b)
|
|
|
|
{
|
|
|
|
m_opaque_sp->SetWaitForLaunch (b);
|
|
|
|
}
|
|
|
|
|
2012-07-21 05:37:13 +08:00
|
|
|
bool
|
|
|
|
SBAttachInfo::GetIgnoreExisting ()
|
|
|
|
{
|
|
|
|
return m_opaque_sp->GetIgnoreExisting();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBAttachInfo::SetIgnoreExisting (bool b)
|
|
|
|
{
|
|
|
|
m_opaque_sp->SetIgnoreExisting (b);
|
|
|
|
}
|
|
|
|
|
2012-02-25 07:56:06 +08:00
|
|
|
uint32_t
|
|
|
|
SBAttachInfo::GetUserID()
|
|
|
|
{
|
|
|
|
return m_opaque_sp->GetUserID();
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
SBAttachInfo::GetGroupID()
|
|
|
|
{
|
|
|
|
return m_opaque_sp->GetGroupID();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBAttachInfo::UserIDIsValid ()
|
|
|
|
{
|
|
|
|
return m_opaque_sp->UserIDIsValid();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBAttachInfo::GroupIDIsValid ()
|
|
|
|
{
|
|
|
|
return m_opaque_sp->GroupIDIsValid();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBAttachInfo::SetUserID (uint32_t uid)
|
|
|
|
{
|
|
|
|
m_opaque_sp->SetUserID (uid);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBAttachInfo::SetGroupID (uint32_t gid)
|
|
|
|
{
|
|
|
|
m_opaque_sp->SetGroupID (gid);
|
|
|
|
}
|
|
|
|
|
2012-02-24 13:03:03 +08:00
|
|
|
uint32_t
|
|
|
|
SBAttachInfo::GetEffectiveUserID()
|
|
|
|
{
|
|
|
|
return m_opaque_sp->GetEffectiveUserID();
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
SBAttachInfo::GetEffectiveGroupID()
|
|
|
|
{
|
|
|
|
return m_opaque_sp->GetEffectiveGroupID();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBAttachInfo::EffectiveUserIDIsValid ()
|
|
|
|
{
|
|
|
|
return m_opaque_sp->EffectiveUserIDIsValid();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBAttachInfo::EffectiveGroupIDIsValid ()
|
|
|
|
{
|
|
|
|
return m_opaque_sp->EffectiveGroupIDIsValid ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBAttachInfo::SetEffectiveUserID (uint32_t uid)
|
|
|
|
{
|
|
|
|
m_opaque_sp->SetEffectiveUserID(uid);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBAttachInfo::SetEffectiveGroupID (uint32_t gid)
|
|
|
|
{
|
|
|
|
m_opaque_sp->SetEffectiveGroupID(gid);
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb::pid_t
|
|
|
|
SBAttachInfo::GetParentProcessID ()
|
|
|
|
{
|
|
|
|
return m_opaque_sp->GetParentProcessID();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBAttachInfo::SetParentProcessID (lldb::pid_t pid)
|
|
|
|
{
|
|
|
|
m_opaque_sp->SetParentProcessID (pid);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBAttachInfo::ParentProcessIDIsValid()
|
|
|
|
{
|
|
|
|
return m_opaque_sp->ParentProcessIDIsValid();
|
|
|
|
}
|
|
|
|
|
2014-11-18 03:39:20 +08:00
|
|
|
SBListener
|
|
|
|
SBAttachInfo::GetListener ()
|
|
|
|
{
|
|
|
|
return SBListener(m_opaque_sp->GetListener());
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBAttachInfo::SetListener (SBListener &listener)
|
|
|
|
{
|
|
|
|
m_opaque_sp->SetListener(listener.GetSP());
|
|
|
|
}
|
2012-02-24 13:03:03 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// SBTarget constructor
|
|
|
|
//----------------------------------------------------------------------
|
2010-12-15 13:08:08 +08:00
|
|
|
SBTarget::SBTarget () :
|
|
|
|
m_opaque_sp ()
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SBTarget::SBTarget (const SBTarget& rhs) :
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_sp (rhs.m_opaque_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SBTarget::SBTarget(const TargetSP& target_sp) :
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_sp (target_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-11-06 07:17:00 +08:00
|
|
|
const SBTarget&
|
|
|
|
SBTarget::operator = (const SBTarget& rhs)
|
|
|
|
{
|
|
|
|
if (this != &rhs)
|
|
|
|
m_opaque_sp = rhs.m_opaque_sp;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Destructor
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
SBTarget::~SBTarget()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-02-16 14:50:00 +08:00
|
|
|
const char *
|
|
|
|
SBTarget::GetBroadcasterClassName ()
|
|
|
|
{
|
|
|
|
return Target::GetStaticBroadcasterClass().AsCString();
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
bool
|
|
|
|
SBTarget::IsValid () const
|
|
|
|
{
|
2012-05-19 17:59:08 +08:00
|
|
|
return m_opaque_sp.get() != NULL && m_opaque_sp->IsValid();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBProcess
|
|
|
|
SBTarget::GetProcess ()
|
|
|
|
{
|
|
|
|
SBProcess sb_process;
|
2012-01-30 15:41:31 +08:00
|
|
|
ProcessSP process_sp;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
process_sp = target_sp->GetProcessSP();
|
2012-01-30 15:41:31 +08:00
|
|
|
sb_process.SetSP (process_sp);
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
if (log)
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("SBTarget(%p)::GetProcess () => SBProcess(%p)",
|
|
|
|
static_cast<void*>(target_sp.get()),
|
|
|
|
static_cast<void*>(process_sp.get()));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
return sb_process;
|
|
|
|
}
|
|
|
|
|
2014-10-22 15:22:56 +08:00
|
|
|
SBPlatform
|
|
|
|
SBTarget::GetPlatform ()
|
|
|
|
{
|
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (!target_sp)
|
|
|
|
return SBPlatform();
|
|
|
|
|
|
|
|
SBPlatform platform;
|
|
|
|
platform.m_opaque_sp = target_sp->GetPlatform();
|
|
|
|
|
|
|
|
return platform;
|
|
|
|
}
|
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
SBDebugger
|
|
|
|
SBTarget::GetDebugger () const
|
|
|
|
{
|
|
|
|
SBDebugger debugger;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
|
|
|
debugger.reset (target_sp->GetDebugger().shared_from_this());
|
2010-06-23 09:19:29 +08:00
|
|
|
return debugger;
|
|
|
|
}
|
|
|
|
|
2013-03-26 06:40:51 +08:00
|
|
|
SBProcess
|
|
|
|
SBTarget::LoadCore (const char *core_file)
|
|
|
|
{
|
|
|
|
SBProcess sb_process;
|
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
|
|
|
{
|
|
|
|
FileSpec filespec(core_file, true);
|
|
|
|
ProcessSP process_sp (target_sp->CreateProcess(target_sp->GetDebugger().GetListener(),
|
|
|
|
NULL,
|
|
|
|
&filespec));
|
|
|
|
if (process_sp)
|
|
|
|
{
|
|
|
|
process_sp->LoadCore();
|
|
|
|
sb_process.SetSP (process_sp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return sb_process;
|
|
|
|
}
|
|
|
|
|
2011-03-31 08:01:24 +08:00
|
|
|
SBProcess
|
|
|
|
SBTarget::LaunchSimple
|
|
|
|
(
|
|
|
|
char const **argv,
|
|
|
|
char const **envp,
|
|
|
|
const char *working_directory
|
|
|
|
)
|
|
|
|
{
|
|
|
|
char *stdin_path = NULL;
|
|
|
|
char *stdout_path = NULL;
|
|
|
|
char *stderr_path = NULL;
|
|
|
|
uint32_t launch_flags = 0;
|
|
|
|
bool stop_at_entry = false;
|
|
|
|
SBError error;
|
|
|
|
SBListener listener = GetDebugger().GetListener();
|
|
|
|
return Launch (listener,
|
|
|
|
argv,
|
|
|
|
envp,
|
|
|
|
stdin_path,
|
|
|
|
stdout_path,
|
|
|
|
stderr_path,
|
|
|
|
working_directory,
|
|
|
|
launch_flags,
|
|
|
|
stop_at_entry,
|
|
|
|
error);
|
|
|
|
}
|
2010-10-07 12:19:01 +08:00
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
SBError
|
|
|
|
SBTarget::Install()
|
|
|
|
{
|
|
|
|
SBError sb_error;
|
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
|
|
|
sb_error.ref() = target_sp->Install(NULL);
|
|
|
|
}
|
|
|
|
return sb_error;
|
|
|
|
}
|
|
|
|
|
2010-10-07 12:19:01 +08:00
|
|
|
SBProcess
|
Added a new variant of SBTarget::Launch() that deprectates the old one that
takes separate file handles for stdin, stdout, and stder and also allows for
the working directory to be specified.
Added support to "process launch" to a new option: --working-dir=PATH. We
can now set the working directory. If this is not set, it defaults to that
of the process that has LLDB loaded. Added the working directory to the
host LaunchInNewTerminal function to allows the current working directory
to be set in processes that are spawned in their own terminal. Also hooked this
up to the lldb_private::Process and all mac plug-ins. The linux plug-in had its
API changed, but nothing is making use of it yet. Modfied "debugserver" and
"darwin-debug" to also handle the current working directory options and modified
the code in LLDB that spawns these tools to pass the info along.
Fixed ProcessGDBRemote to properly pass along all file handles for stdin, stdout
and stderr.
After clearing the default values for the stdin/out/err file handles for
process to be NULL, we had a crasher in UserSettingsController::UpdateStringVariable
which is now fixed. Also fixed the setting of boolean values to be able to
be set as "true", "yes", "on", "1" for true (case insensitive) and "false", "no",
"off", or "0" for false.
Fixed debugserver to properly handle files for STDIN, STDOUT and STDERR that are not
already opened. Previous to this fix debugserver would only correctly open and dupe
file handles for the slave side of a pseudo terminal. It now correctly handles
getting STDIN for the inferior from a file, and spitting STDOUT and STDERR out to
files. Also made sure the file handles were correctly opened with the NOCTTY flag
for terminals.
llvm-svn: 124060
2011-01-23 13:56:20 +08:00
|
|
|
SBTarget::Launch
|
2010-10-07 06:10:17 +08:00
|
|
|
(
|
2011-02-04 05:28:34 +08:00
|
|
|
SBListener &listener,
|
2010-10-07 06:10:17 +08:00
|
|
|
char const **argv,
|
|
|
|
char const **envp,
|
Added a new variant of SBTarget::Launch() that deprectates the old one that
takes separate file handles for stdin, stdout, and stder and also allows for
the working directory to be specified.
Added support to "process launch" to a new option: --working-dir=PATH. We
can now set the working directory. If this is not set, it defaults to that
of the process that has LLDB loaded. Added the working directory to the
host LaunchInNewTerminal function to allows the current working directory
to be set in processes that are spawned in their own terminal. Also hooked this
up to the lldb_private::Process and all mac plug-ins. The linux plug-in had its
API changed, but nothing is making use of it yet. Modfied "debugserver" and
"darwin-debug" to also handle the current working directory options and modified
the code in LLDB that spawns these tools to pass the info along.
Fixed ProcessGDBRemote to properly pass along all file handles for stdin, stdout
and stderr.
After clearing the default values for the stdin/out/err file handles for
process to be NULL, we had a crasher in UserSettingsController::UpdateStringVariable
which is now fixed. Also fixed the setting of boolean values to be able to
be set as "true", "yes", "on", "1" for true (case insensitive) and "false", "no",
"off", or "0" for false.
Fixed debugserver to properly handle files for STDIN, STDOUT and STDERR that are not
already opened. Previous to this fix debugserver would only correctly open and dupe
file handles for the slave side of a pseudo terminal. It now correctly handles
getting STDIN for the inferior from a file, and spitting STDOUT and STDERR out to
files. Also made sure the file handles were correctly opened with the NOCTTY flag
for terminals.
llvm-svn: 124060
2011-01-23 13:56:20 +08:00
|
|
|
const char *stdin_path,
|
|
|
|
const char *stdout_path,
|
|
|
|
const char *stderr_path,
|
|
|
|
const char *working_directory,
|
|
|
|
uint32_t launch_flags, // See LaunchFlags
|
2010-10-07 06:10:17 +08:00
|
|
|
bool stop_at_entry,
|
Added a new variant of SBTarget::Launch() that deprectates the old one that
takes separate file handles for stdin, stdout, and stder and also allows for
the working directory to be specified.
Added support to "process launch" to a new option: --working-dir=PATH. We
can now set the working directory. If this is not set, it defaults to that
of the process that has LLDB loaded. Added the working directory to the
host LaunchInNewTerminal function to allows the current working directory
to be set in processes that are spawned in their own terminal. Also hooked this
up to the lldb_private::Process and all mac plug-ins. The linux plug-in had its
API changed, but nothing is making use of it yet. Modfied "debugserver" and
"darwin-debug" to also handle the current working directory options and modified
the code in LLDB that spawns these tools to pass the info along.
Fixed ProcessGDBRemote to properly pass along all file handles for stdin, stdout
and stderr.
After clearing the default values for the stdin/out/err file handles for
process to be NULL, we had a crasher in UserSettingsController::UpdateStringVariable
which is now fixed. Also fixed the setting of boolean values to be able to
be set as "true", "yes", "on", "1" for true (case insensitive) and "false", "no",
"off", or "0" for false.
Fixed debugserver to properly handle files for STDIN, STDOUT and STDERR that are not
already opened. Previous to this fix debugserver would only correctly open and dupe
file handles for the slave side of a pseudo terminal. It now correctly handles
getting STDIN for the inferior from a file, and spitting STDOUT and STDERR out to
files. Also made sure the file handles were correctly opened with the NOCTTY flag
for terminals.
llvm-svn: 124060
2011-01-23 13:56:20 +08:00
|
|
|
lldb::SBError& error
|
2010-10-07 06:10:17 +08:00
|
|
|
)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2012-01-30 17:04:36 +08:00
|
|
|
SBProcess sb_process;
|
|
|
|
ProcessSP process_sp;
|
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
2010-10-26 11:11:13 +08:00
|
|
|
if (log)
|
Added a new variant of SBTarget::Launch() that deprectates the old one that
takes separate file handles for stdin, stdout, and stder and also allows for
the working directory to be specified.
Added support to "process launch" to a new option: --working-dir=PATH. We
can now set the working directory. If this is not set, it defaults to that
of the process that has LLDB loaded. Added the working directory to the
host LaunchInNewTerminal function to allows the current working directory
to be set in processes that are spawned in their own terminal. Also hooked this
up to the lldb_private::Process and all mac plug-ins. The linux plug-in had its
API changed, but nothing is making use of it yet. Modfied "debugserver" and
"darwin-debug" to also handle the current working directory options and modified
the code in LLDB that spawns these tools to pass the info along.
Fixed ProcessGDBRemote to properly pass along all file handles for stdin, stdout
and stderr.
After clearing the default values for the stdin/out/err file handles for
process to be NULL, we had a crasher in UserSettingsController::UpdateStringVariable
which is now fixed. Also fixed the setting of boolean values to be able to
be set as "true", "yes", "on", "1" for true (case insensitive) and "false", "no",
"off", or "0" for false.
Fixed debugserver to properly handle files for STDIN, STDOUT and STDERR that are not
already opened. Previous to this fix debugserver would only correctly open and dupe
file handles for the slave side of a pseudo terminal. It now correctly handles
getting STDIN for the inferior from a file, and spitting STDOUT and STDERR out to
files. Also made sure the file handles were correctly opened with the NOCTTY flag
for terminals.
llvm-svn: 124060
2011-01-23 13:56:20 +08:00
|
|
|
log->Printf ("SBTarget(%p)::Launch (argv=%p, envp=%p, stdin=%s, stdout=%s, stderr=%s, working-dir=%s, launch_flags=0x%x, stop_at_entry=%i, &error (%p))...",
|
2014-04-04 12:06:10 +08:00
|
|
|
static_cast<void*>(target_sp.get()),
|
|
|
|
static_cast<void*>(argv), static_cast<void*>(envp),
|
|
|
|
stdin_path ? stdin_path : "NULL",
|
|
|
|
stdout_path ? stdout_path : "NULL",
|
|
|
|
stderr_path ? stderr_path : "NULL",
|
Added a new variant of SBTarget::Launch() that deprectates the old one that
takes separate file handles for stdin, stdout, and stder and also allows for
the working directory to be specified.
Added support to "process launch" to a new option: --working-dir=PATH. We
can now set the working directory. If this is not set, it defaults to that
of the process that has LLDB loaded. Added the working directory to the
host LaunchInNewTerminal function to allows the current working directory
to be set in processes that are spawned in their own terminal. Also hooked this
up to the lldb_private::Process and all mac plug-ins. The linux plug-in had its
API changed, but nothing is making use of it yet. Modfied "debugserver" and
"darwin-debug" to also handle the current working directory options and modified
the code in LLDB that spawns these tools to pass the info along.
Fixed ProcessGDBRemote to properly pass along all file handles for stdin, stdout
and stderr.
After clearing the default values for the stdin/out/err file handles for
process to be NULL, we had a crasher in UserSettingsController::UpdateStringVariable
which is now fixed. Also fixed the setting of boolean values to be able to
be set as "true", "yes", "on", "1" for true (case insensitive) and "false", "no",
"off", or "0" for false.
Fixed debugserver to properly handle files for STDIN, STDOUT and STDERR that are not
already opened. Previous to this fix debugserver would only correctly open and dupe
file handles for the slave side of a pseudo terminal. It now correctly handles
getting STDIN for the inferior from a file, and spitting STDOUT and STDERR out to
files. Also made sure the file handles were correctly opened with the NOCTTY flag
for terminals.
llvm-svn: 124060
2011-01-23 13:56:20 +08:00
|
|
|
working_directory ? working_directory : "NULL",
|
2014-04-04 12:06:10 +08:00
|
|
|
launch_flags, stop_at_entry,
|
|
|
|
static_cast<void*>(error.get()));
|
2012-01-30 17:04:36 +08:00
|
|
|
|
|
|
|
if (target_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
2010-10-06 11:53:16 +08:00
|
|
|
|
2011-01-27 09:01:10 +08:00
|
|
|
if (getenv("LLDB_LAUNCH_FLAG_DISABLE_ASLR"))
|
|
|
|
launch_flags |= eLaunchFlagDisableASLR;
|
|
|
|
|
2011-04-30 09:09:13 +08:00
|
|
|
StateType state = eStateInvalid;
|
2012-01-30 17:04:36 +08:00
|
|
|
process_sp = target_sp->GetProcessSP();
|
2012-01-30 15:41:31 +08:00
|
|
|
if (process_sp)
|
2011-04-30 09:09:13 +08:00
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
state = process_sp->GetState();
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2012-01-30 15:41:31 +08:00
|
|
|
if (process_sp->IsAlive() && state != eStateConnected)
|
2014-04-04 12:06:10 +08:00
|
|
|
{
|
2011-04-30 09:09:13 +08:00
|
|
|
if (state == eStateAttaching)
|
|
|
|
error.SetErrorString ("process attach is in progress");
|
|
|
|
else
|
|
|
|
error.SetErrorString ("a process is already being debugged");
|
|
|
|
return sb_process;
|
2014-04-04 12:06:10 +08:00
|
|
|
}
|
2011-04-30 09:09:13 +08:00
|
|
|
}
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2011-04-30 09:09:13 +08:00
|
|
|
if (state == eStateConnected)
|
2011-01-27 14:44:37 +08:00
|
|
|
{
|
2011-04-30 09:09:13 +08:00
|
|
|
// If we are already connected, then we have already specified the
|
|
|
|
// listener, so if a valid listener is supplied, we need to error out
|
|
|
|
// to let the client know.
|
|
|
|
if (listener.IsValid())
|
2011-01-27 14:44:37 +08:00
|
|
|
{
|
2011-04-30 09:09:13 +08:00
|
|
|
error.SetErrorString ("process is connected and already has a listener, pass empty listener");
|
|
|
|
return sb_process;
|
2011-01-27 14:44:37 +08:00
|
|
|
}
|
|
|
|
}
|
2011-01-27 09:01:10 +08:00
|
|
|
|
2013-12-14 01:20:18 +08:00
|
|
|
if (getenv("LLDB_LAUNCH_FLAG_DISABLE_STDIO"))
|
|
|
|
launch_flags |= eLaunchFlagDisableSTDIO;
|
2011-01-27 09:01:10 +08:00
|
|
|
|
2013-12-14 01:20:18 +08:00
|
|
|
ProcessLaunchInfo launch_info (stdin_path, stdout_path, stderr_path, working_directory, launch_flags);
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2013-12-14 01:20:18 +08:00
|
|
|
Module *exe_module = target_sp->GetExecutableModulePointer();
|
|
|
|
if (exe_module)
|
|
|
|
launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true);
|
|
|
|
if (argv)
|
|
|
|
launch_info.GetArguments().AppendArguments (argv);
|
|
|
|
if (envp)
|
|
|
|
launch_info.GetEnvironmentEntries ().SetArguments (envp);
|
|
|
|
|
|
|
|
if (listener.IsValid())
|
2014-11-18 03:39:20 +08:00
|
|
|
launch_info.SetListener(listener.GetSP());
|
|
|
|
|
|
|
|
error.SetError (target_sp->Launch(launch_info, NULL));
|
2013-12-14 01:20:18 +08:00
|
|
|
|
|
|
|
sb_process.SetSP(target_sp->GetProcessSP());
|
2010-10-07 06:10:17 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
error.SetErrorString ("SBTarget is invalid");
|
|
|
|
}
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-10-30 05:48:37 +08:00
|
|
|
log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
|
2010-10-26 11:11:13 +08:00
|
|
|
if (log)
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("SBTarget(%p)::Launch (...) => SBProcess(%p)",
|
|
|
|
static_cast<void*>(target_sp.get()),
|
|
|
|
static_cast<void*>(sb_process.GetSP().get()));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-10-07 06:10:17 +08:00
|
|
|
return sb_process;
|
|
|
|
}
|
|
|
|
|
2012-02-24 13:03:03 +08:00
|
|
|
SBProcess
|
|
|
|
SBTarget::Launch (SBLaunchInfo &sb_launch_info, SBError& error)
|
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2012-02-24 13:03:03 +08:00
|
|
|
SBProcess sb_process;
|
|
|
|
TargetSP target_sp(GetSP());
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2012-02-24 13:03:03 +08:00
|
|
|
if (log)
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("SBTarget(%p)::Launch (launch_info, error)...",
|
|
|
|
static_cast<void*>(target_sp.get()));
|
|
|
|
|
2012-02-24 13:03:03 +08:00
|
|
|
if (target_sp)
|
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
|
|
|
StateType state = eStateInvalid;
|
2013-12-14 01:20:18 +08:00
|
|
|
{
|
2014-05-08 04:16:06 +08:00
|
|
|
ProcessSP process_sp = target_sp->GetProcessSP();
|
|
|
|
if (process_sp)
|
2014-04-04 12:06:10 +08:00
|
|
|
{
|
2014-05-08 04:16:06 +08:00
|
|
|
state = process_sp->GetState();
|
|
|
|
|
|
|
|
if (process_sp->IsAlive() && state != eStateConnected)
|
|
|
|
{
|
|
|
|
if (state == eStateAttaching)
|
|
|
|
error.SetErrorString ("process attach is in progress");
|
|
|
|
else
|
|
|
|
error.SetErrorString ("a process is already being debugged");
|
|
|
|
return sb_process;
|
|
|
|
}
|
2014-04-04 12:06:10 +08:00
|
|
|
}
|
2012-02-24 13:03:03 +08:00
|
|
|
}
|
2012-02-25 04:59:25 +08:00
|
|
|
|
2013-12-14 01:20:18 +08:00
|
|
|
lldb_private::ProcessLaunchInfo &launch_info = sb_launch_info.ref();
|
2012-02-25 04:59:25 +08:00
|
|
|
|
2014-05-08 04:16:06 +08:00
|
|
|
if (!launch_info.GetExecutableFile())
|
|
|
|
{
|
|
|
|
Module *exe_module = target_sp->GetExecutableModulePointer();
|
|
|
|
if (exe_module)
|
|
|
|
launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true);
|
|
|
|
}
|
2013-12-14 01:20:18 +08:00
|
|
|
|
|
|
|
const ArchSpec &arch_spec = target_sp->GetArchitecture();
|
|
|
|
if (arch_spec.IsValid())
|
|
|
|
launch_info.GetArchitecture () = arch_spec;
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2014-11-18 03:39:20 +08:00
|
|
|
error.SetError (target_sp->Launch (launch_info, NULL));
|
2013-12-14 01:20:18 +08:00
|
|
|
sb_process.SetSP(target_sp->GetProcessSP());
|
2012-02-24 13:03:03 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
error.SetErrorString ("SBTarget is invalid");
|
|
|
|
}
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2012-02-24 13:03:03 +08:00
|
|
|
log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
|
|
|
|
if (log)
|
2013-12-14 01:20:18 +08:00
|
|
|
log->Printf ("SBTarget(%p)::Launch (...) => SBProcess(%p)",
|
2014-04-04 12:06:10 +08:00
|
|
|
static_cast<void*>(target_sp.get()),
|
|
|
|
static_cast<void*>(sb_process.GetSP().get()));
|
|
|
|
|
2012-02-24 13:03:03 +08:00
|
|
|
return sb_process;
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb::SBProcess
|
|
|
|
SBTarget::Attach (SBAttachInfo &sb_attach_info, SBError& error)
|
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2012-02-24 13:03:03 +08:00
|
|
|
SBProcess sb_process;
|
|
|
|
ProcessSP process_sp;
|
|
|
|
TargetSP target_sp(GetSP());
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2012-10-20 08:21:31 +08:00
|
|
|
if (log)
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("SBTarget(%p)::Attach (sb_attach_info, error)...",
|
|
|
|
static_cast<void*>(target_sp.get()));
|
|
|
|
|
2012-02-24 13:03:03 +08:00
|
|
|
if (target_sp)
|
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2012-02-24 13:03:03 +08:00
|
|
|
StateType state = eStateInvalid;
|
|
|
|
process_sp = target_sp->GetProcessSP();
|
|
|
|
if (process_sp)
|
|
|
|
{
|
|
|
|
state = process_sp->GetState();
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2012-02-24 13:03:03 +08:00
|
|
|
if (process_sp->IsAlive() && state != eStateConnected)
|
2014-04-04 12:06:10 +08:00
|
|
|
{
|
2012-02-24 13:03:03 +08:00
|
|
|
if (state == eStateAttaching)
|
|
|
|
error.SetErrorString ("process attach is in progress");
|
|
|
|
else
|
|
|
|
error.SetErrorString ("a process is already being debugged");
|
2012-10-20 08:21:31 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf ("SBTarget(%p)::Attach (...) => error %s",
|
2014-04-04 12:06:10 +08:00
|
|
|
static_cast<void*>(target_sp.get()),
|
|
|
|
error.GetCString());
|
2012-02-24 13:03:03 +08:00
|
|
|
return sb_process;
|
2014-04-04 12:06:10 +08:00
|
|
|
}
|
2012-02-24 13:03:03 +08:00
|
|
|
}
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2012-02-24 13:03:03 +08:00
|
|
|
if (state != eStateConnected)
|
|
|
|
process_sp = target_sp->CreateProcess (target_sp->GetDebugger().GetListener(), NULL, NULL);
|
|
|
|
|
|
|
|
if (process_sp)
|
|
|
|
{
|
|
|
|
ProcessAttachInfo &attach_info = sb_attach_info.ref();
|
2013-03-26 04:11:18 +08:00
|
|
|
if (attach_info.ProcessIDIsValid() && !attach_info.UserIDIsValid())
|
2012-02-29 08:12:56 +08:00
|
|
|
{
|
|
|
|
PlatformSP platform_sp = target_sp->GetPlatform();
|
2012-09-27 08:03:39 +08:00
|
|
|
// See if we can pre-verify if a process exists or not
|
|
|
|
if (platform_sp && platform_sp->IsConnected())
|
2012-02-29 08:12:56 +08:00
|
|
|
{
|
2013-03-26 04:11:18 +08:00
|
|
|
lldb::pid_t attach_pid = attach_info.GetProcessID();
|
2012-09-27 08:03:39 +08:00
|
|
|
ProcessInstanceInfo instance_info;
|
|
|
|
if (platform_sp->GetProcessInfo(attach_pid, instance_info))
|
|
|
|
{
|
|
|
|
attach_info.SetUserID(instance_info.GetEffectiveUserID());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-30 05:49:15 +08:00
|
|
|
error.ref().SetErrorStringWithFormat("no process found with process ID %" PRIu64, attach_pid);
|
2012-10-20 08:21:31 +08:00
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
log->Printf ("SBTarget(%p)::Attach (...) => error %s",
|
2014-04-04 12:06:10 +08:00
|
|
|
static_cast<void*>(target_sp.get()), error.GetCString());
|
2012-10-20 08:21:31 +08:00
|
|
|
}
|
2012-09-27 08:03:39 +08:00
|
|
|
return sb_process;
|
|
|
|
}
|
2012-02-29 08:12:56 +08:00
|
|
|
}
|
|
|
|
}
|
2012-03-01 03:16:40 +08:00
|
|
|
error.SetError (process_sp->Attach (attach_info));
|
|
|
|
if (error.Success())
|
|
|
|
{
|
|
|
|
sb_process.SetSP (process_sp);
|
|
|
|
// If we are doing synchronous mode, then wait for the
|
|
|
|
// process to stop!
|
|
|
|
if (target_sp->GetDebugger().GetAsyncExecution () == false)
|
|
|
|
process_sp->WaitForProcessToStop (NULL);
|
|
|
|
}
|
2012-02-24 13:03:03 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
error.SetErrorString ("unable to create lldb_private::Process");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
error.SetErrorString ("SBTarget is invalid");
|
|
|
|
}
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2012-10-20 08:21:31 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf ("SBTarget(%p)::Attach (...) => SBProcess(%p)",
|
2014-04-04 12:06:10 +08:00
|
|
|
static_cast<void*>(target_sp.get()),
|
|
|
|
static_cast<void*>(process_sp.get()));
|
|
|
|
|
2012-02-24 13:03:03 +08:00
|
|
|
return sb_process;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-12-02 10:10:57 +08:00
|
|
|
#if defined(__APPLE__)
|
|
|
|
|
|
|
|
lldb::SBProcess
|
|
|
|
SBTarget::AttachToProcessWithID (SBListener &listener,
|
|
|
|
::pid_t pid,
|
|
|
|
lldb::SBError& error)
|
|
|
|
{
|
|
|
|
return AttachToProcessWithID (listener, (lldb::pid_t)pid, error);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // #if defined(__APPLE__)
|
2010-10-07 06:10:17 +08:00
|
|
|
|
|
|
|
lldb::SBProcess
|
2010-10-07 12:19:01 +08:00
|
|
|
SBTarget::AttachToProcessWithID
|
2010-10-07 06:10:17 +08:00
|
|
|
(
|
2011-02-04 05:28:34 +08:00
|
|
|
SBListener &listener,
|
2010-10-07 06:10:17 +08:00
|
|
|
lldb::pid_t pid,// The process ID to attach to
|
|
|
|
SBError& error // An error explaining what went wrong if attach fails
|
|
|
|
)
|
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2012-10-20 08:21:31 +08:00
|
|
|
|
2010-10-07 06:10:17 +08:00
|
|
|
SBProcess sb_process;
|
2012-01-30 15:41:31 +08:00
|
|
|
ProcessSP process_sp;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
2012-10-20 08:21:31 +08:00
|
|
|
|
|
|
|
if (log)
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("SBTarget(%p)::AttachToProcessWithID (listener, pid=%" PRId64 ", error)...",
|
|
|
|
static_cast<void*>(target_sp.get()), pid);
|
|
|
|
|
2012-01-30 17:04:36 +08:00
|
|
|
if (target_sp)
|
2010-10-07 06:10:17 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
2011-06-24 11:21:43 +08:00
|
|
|
|
|
|
|
StateType state = eStateInvalid;
|
2012-01-30 17:04:36 +08:00
|
|
|
process_sp = target_sp->GetProcessSP();
|
2012-01-30 15:41:31 +08:00
|
|
|
if (process_sp)
|
2011-06-24 11:21:43 +08:00
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
state = process_sp->GetState();
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2012-01-30 15:41:31 +08:00
|
|
|
if (process_sp->IsAlive() && state != eStateConnected)
|
2014-04-04 12:06:10 +08:00
|
|
|
{
|
2011-06-24 11:21:43 +08:00
|
|
|
if (state == eStateAttaching)
|
|
|
|
error.SetErrorString ("process attach is in progress");
|
|
|
|
else
|
|
|
|
error.SetErrorString ("a process is already being debugged");
|
|
|
|
return sb_process;
|
2014-04-04 12:06:10 +08:00
|
|
|
}
|
2011-06-24 11:21:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (state == eStateConnected)
|
|
|
|
{
|
|
|
|
// If we are already connected, then we have already specified the
|
|
|
|
// listener, so if a valid listener is supplied, we need to error out
|
|
|
|
// to let the client know.
|
|
|
|
if (listener.IsValid())
|
|
|
|
{
|
|
|
|
error.SetErrorString ("process is connected and already has a listener, pass empty listener");
|
|
|
|
return sb_process;
|
|
|
|
}
|
|
|
|
}
|
2011-02-04 05:28:34 +08:00
|
|
|
else
|
2011-06-24 11:21:43 +08:00
|
|
|
{
|
|
|
|
if (listener.IsValid())
|
2012-02-09 14:16:32 +08:00
|
|
|
process_sp = target_sp->CreateProcess (listener.ref(), NULL, NULL);
|
2011-06-24 11:21:43 +08:00
|
|
|
else
|
2012-02-09 14:16:32 +08:00
|
|
|
process_sp = target_sp->CreateProcess (target_sp->GetDebugger().GetListener(), NULL, NULL);
|
2011-06-24 11:21:43 +08:00
|
|
|
}
|
2012-01-30 15:41:31 +08:00
|
|
|
if (process_sp)
|
2010-10-07 06:10:17 +08:00
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
sb_process.SetSP (process_sp);
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2011-11-15 11:53:30 +08:00
|
|
|
ProcessAttachInfo attach_info;
|
|
|
|
attach_info.SetProcessID (pid);
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2012-02-25 09:07:38 +08:00
|
|
|
PlatformSP platform_sp = target_sp->GetPlatform();
|
|
|
|
ProcessInstanceInfo instance_info;
|
|
|
|
if (platform_sp->GetProcessInfo(pid, instance_info))
|
|
|
|
{
|
|
|
|
attach_info.SetUserID(instance_info.GetEffectiveUserID());
|
|
|
|
}
|
2012-01-30 15:41:31 +08:00
|
|
|
error.SetError (process_sp->Attach (attach_info));
|
2012-09-08 01:51:47 +08:00
|
|
|
if (error.Success())
|
|
|
|
{
|
|
|
|
// If we are doing synchronous mode, then wait for the
|
|
|
|
// process to stop!
|
|
|
|
if (target_sp->GetDebugger().GetAsyncExecution () == false)
|
2014-10-21 09:00:42 +08:00
|
|
|
process_sp->WaitForProcessToStop (NULL);
|
2012-09-08 01:51:47 +08:00
|
|
|
}
|
2010-10-07 06:10:17 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
error.SetErrorString ("unable to create lldb_private::Process");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
error.SetErrorString ("SBTarget is invalid");
|
|
|
|
}
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2012-10-20 08:21:31 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf ("SBTarget(%p)::AttachToProcessWithID (...) => SBProcess(%p)",
|
2014-04-04 12:06:10 +08:00
|
|
|
static_cast<void*>(target_sp.get()),
|
|
|
|
static_cast<void*>(process_sp.get()));
|
2010-10-07 06:10:17 +08:00
|
|
|
return sb_process;
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb::SBProcess
|
2010-10-07 12:19:01 +08:00
|
|
|
SBTarget::AttachToProcessWithName
|
2010-10-07 06:10:17 +08:00
|
|
|
(
|
2011-02-04 05:28:34 +08:00
|
|
|
SBListener &listener,
|
2010-10-07 06:10:17 +08:00
|
|
|
const char *name, // basename of process to attach to
|
|
|
|
bool wait_for, // if true wait for a new instance of "name" to be launched
|
|
|
|
SBError& error // An error explaining what went wrong if attach fails
|
|
|
|
)
|
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2010-10-07 06:10:17 +08:00
|
|
|
SBProcess sb_process;
|
2012-01-30 15:41:31 +08:00
|
|
|
ProcessSP process_sp;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2012-10-20 08:21:31 +08:00
|
|
|
if (log)
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("SBTarget(%p)::AttachToProcessWithName (listener, name=%s, wait_for=%s, error)...",
|
|
|
|
static_cast<void*>(target_sp.get()), name,
|
|
|
|
wait_for ? "true" : "false");
|
|
|
|
|
2012-01-30 17:04:36 +08:00
|
|
|
if (name && target_sp)
|
2010-10-07 06:10:17 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
2010-12-21 04:49:23 +08:00
|
|
|
|
2011-06-24 11:21:43 +08:00
|
|
|
StateType state = eStateInvalid;
|
2012-01-30 17:04:36 +08:00
|
|
|
process_sp = target_sp->GetProcessSP();
|
2012-01-30 15:41:31 +08:00
|
|
|
if (process_sp)
|
2011-06-24 11:21:43 +08:00
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
state = process_sp->GetState();
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2012-01-30 15:41:31 +08:00
|
|
|
if (process_sp->IsAlive() && state != eStateConnected)
|
2014-04-04 12:06:10 +08:00
|
|
|
{
|
2011-06-24 11:21:43 +08:00
|
|
|
if (state == eStateAttaching)
|
|
|
|
error.SetErrorString ("process attach is in progress");
|
|
|
|
else
|
|
|
|
error.SetErrorString ("a process is already being debugged");
|
|
|
|
return sb_process;
|
2014-04-04 12:06:10 +08:00
|
|
|
}
|
2011-06-24 11:21:43 +08:00
|
|
|
}
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2011-06-24 11:21:43 +08:00
|
|
|
if (state == eStateConnected)
|
|
|
|
{
|
|
|
|
// If we are already connected, then we have already specified the
|
|
|
|
// listener, so if a valid listener is supplied, we need to error out
|
|
|
|
// to let the client know.
|
|
|
|
if (listener.IsValid())
|
|
|
|
{
|
|
|
|
error.SetErrorString ("process is connected and already has a listener, pass empty listener");
|
|
|
|
return sb_process;
|
|
|
|
}
|
|
|
|
}
|
2011-02-04 05:28:34 +08:00
|
|
|
else
|
2011-06-24 11:21:43 +08:00
|
|
|
{
|
|
|
|
if (listener.IsValid())
|
2012-02-09 14:16:32 +08:00
|
|
|
process_sp = target_sp->CreateProcess (listener.ref(), NULL, NULL);
|
2011-06-24 11:21:43 +08:00
|
|
|
else
|
2012-02-09 14:16:32 +08:00
|
|
|
process_sp = target_sp->CreateProcess (target_sp->GetDebugger().GetListener(), NULL, NULL);
|
2011-06-24 11:21:43 +08:00
|
|
|
}
|
2010-10-07 06:10:17 +08:00
|
|
|
|
2012-01-30 15:41:31 +08:00
|
|
|
if (process_sp)
|
2010-10-07 06:10:17 +08:00
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
sb_process.SetSP (process_sp);
|
2011-11-15 11:53:30 +08:00
|
|
|
ProcessAttachInfo attach_info;
|
|
|
|
attach_info.GetExecutableFile().SetFile(name, false);
|
|
|
|
attach_info.SetWaitForLaunch(wait_for);
|
2012-01-30 15:41:31 +08:00
|
|
|
error.SetError (process_sp->Attach (attach_info));
|
2013-04-02 03:47:00 +08:00
|
|
|
if (error.Success())
|
|
|
|
{
|
|
|
|
// If we are doing synchronous mode, then wait for the
|
|
|
|
// process to stop!
|
|
|
|
if (target_sp->GetDebugger().GetAsyncExecution () == false)
|
|
|
|
process_sp->WaitForProcessToStop (NULL);
|
|
|
|
}
|
2010-10-07 06:10:17 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
error.SetErrorString ("unable to create lldb_private::Process");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
error.SetErrorString ("SBTarget is invalid");
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2012-10-20 08:21:31 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf ("SBTarget(%p)::AttachToPorcessWithName (...) => SBProcess(%p)",
|
2014-04-04 12:06:10 +08:00
|
|
|
static_cast<void*>(target_sp.get()),
|
|
|
|
static_cast<void*>(process_sp.get()));
|
2010-10-06 11:53:16 +08:00
|
|
|
return sb_process;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2011-03-04 08:31:13 +08:00
|
|
|
lldb::SBProcess
|
|
|
|
SBTarget::ConnectRemote
|
|
|
|
(
|
|
|
|
SBListener &listener,
|
|
|
|
const char *url,
|
|
|
|
const char *plugin_name,
|
|
|
|
SBError& error
|
|
|
|
)
|
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2012-10-20 08:21:31 +08:00
|
|
|
|
2011-03-04 08:31:13 +08:00
|
|
|
SBProcess sb_process;
|
2012-01-30 15:41:31 +08:00
|
|
|
ProcessSP process_sp;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2012-10-20 08:21:31 +08:00
|
|
|
if (log)
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("SBTarget(%p)::ConnectRemote (listener, url=%s, plugin_name=%s, error)...",
|
|
|
|
static_cast<void*>(target_sp.get()), url, plugin_name);
|
|
|
|
|
2012-01-30 17:04:36 +08:00
|
|
|
if (target_sp)
|
2011-03-04 08:31:13 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
2011-03-04 08:31:13 +08:00
|
|
|
if (listener.IsValid())
|
2012-02-09 14:16:32 +08:00
|
|
|
process_sp = target_sp->CreateProcess (listener.ref(), plugin_name, NULL);
|
2011-03-04 08:31:13 +08:00
|
|
|
else
|
2012-02-09 14:16:32 +08:00
|
|
|
process_sp = target_sp->CreateProcess (target_sp->GetDebugger().GetListener(), plugin_name, NULL);
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2012-01-30 15:41:31 +08:00
|
|
|
if (process_sp)
|
2011-03-04 08:31:13 +08:00
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
sb_process.SetSP (process_sp);
|
2012-09-29 12:02:01 +08:00
|
|
|
error.SetError (process_sp->ConnectRemote (NULL, url));
|
2011-03-04 08:31:13 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
error.SetErrorString ("unable to create lldb_private::Process");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
error.SetErrorString ("SBTarget is invalid");
|
|
|
|
}
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2012-10-20 08:21:31 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf ("SBTarget(%p)::ConnectRemote (...) => SBProcess(%p)",
|
2014-04-04 12:06:10 +08:00
|
|
|
static_cast<void*>(target_sp.get()),
|
|
|
|
static_cast<void*>(process_sp.get()));
|
2011-03-04 08:31:13 +08:00
|
|
|
return sb_process;
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SBFileSpec
|
|
|
|
SBTarget::GetExecutable ()
|
|
|
|
{
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SBFileSpec exe_file_spec;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
Module *exe_module = target_sp->GetExecutableModulePointer();
|
2011-08-11 10:48:45 +08:00
|
|
|
if (exe_module)
|
|
|
|
exe_file_spec.SetFileSpec (exe_module->GetFileSpec());
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
if (log)
|
|
|
|
{
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("SBTarget(%p)::GetExecutable () => SBFileSpec(%p)",
|
|
|
|
static_cast<void*>(target_sp.get()),
|
|
|
|
static_cast<const void*>(exe_file_spec.get()));
|
2010-10-26 11:11:13 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
return exe_file_spec;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBTarget::operator == (const SBTarget &rhs) const
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
return m_opaque_sp.get() == rhs.m_opaque_sp.get();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBTarget::operator != (const SBTarget &rhs) const
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
return m_opaque_sp.get() != rhs.m_opaque_sp.get();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2012-01-30 15:41:31 +08:00
|
|
|
lldb::TargetSP
|
|
|
|
SBTarget::GetSP () const
|
2011-10-01 10:59:24 +08:00
|
|
|
{
|
|
|
|
return m_opaque_sp;
|
|
|
|
}
|
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
void
|
2012-01-30 15:41:31 +08:00
|
|
|
SBTarget::SetSP (const lldb::TargetSP& target_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_sp = target_sp;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2011-07-23 00:46:35 +08:00
|
|
|
lldb::SBAddress
|
|
|
|
SBTarget::ResolveLoadAddress (lldb::addr_t vm_addr)
|
2010-12-13 03:25:26 +08:00
|
|
|
{
|
2011-07-23 00:46:35 +08:00
|
|
|
lldb::SBAddress sb_addr;
|
|
|
|
Address &addr = sb_addr.ref();
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
2013-12-06 09:12:00 +08:00
|
|
|
if (target_sp->ResolveLoadAddress (vm_addr, addr))
|
2011-07-23 00:46:35 +08:00
|
|
|
return sb_addr;
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-12-13 03:25:26 +08:00
|
|
|
|
2011-07-23 00:46:35 +08:00
|
|
|
// We have a load address that isn't in a section, just return an address
|
|
|
|
// with the offset filled in (the address) and the section set to NULL
|
2012-02-24 09:59:29 +08:00
|
|
|
addr.SetRawAddress(vm_addr);
|
2011-07-23 00:46:35 +08:00
|
|
|
return sb_addr;
|
2010-12-13 03:25:26 +08:00
|
|
|
}
|
|
|
|
|
2014-10-22 15:22:56 +08:00
|
|
|
lldb::SBAddress
|
|
|
|
SBTarget::ResolveFileAddress (lldb::addr_t file_addr)
|
|
|
|
{
|
|
|
|
lldb::SBAddress sb_addr;
|
|
|
|
Address &addr = sb_addr.ref();
|
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
|
|
|
if (target_sp->ResolveFileAddress (file_addr, addr))
|
|
|
|
return sb_addr;
|
|
|
|
}
|
|
|
|
|
|
|
|
addr.SetRawAddress(file_addr);
|
|
|
|
return sb_addr;
|
|
|
|
}
|
2013-12-06 09:12:00 +08:00
|
|
|
|
|
|
|
lldb::SBAddress
|
|
|
|
SBTarget::ResolvePastLoadAddress (uint32_t stop_id, lldb::addr_t vm_addr)
|
|
|
|
{
|
|
|
|
lldb::SBAddress sb_addr;
|
|
|
|
Address &addr = sb_addr.ref();
|
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
|
|
|
if (target_sp->ResolveLoadAddress (vm_addr, addr))
|
|
|
|
return sb_addr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// We have a load address that isn't in a section, just return an address
|
|
|
|
// with the offset filled in (the address) and the section set to NULL
|
|
|
|
addr.SetRawAddress(vm_addr);
|
|
|
|
return sb_addr;
|
|
|
|
}
|
|
|
|
|
2011-03-03 05:34:46 +08:00
|
|
|
SBSymbolContext
|
2013-10-12 03:48:25 +08:00
|
|
|
SBTarget::ResolveSymbolContextForAddress (const SBAddress& addr,
|
|
|
|
uint32_t resolve_scope)
|
2011-03-03 05:34:46 +08:00
|
|
|
{
|
|
|
|
SBSymbolContext sc;
|
2012-01-30 17:04:36 +08:00
|
|
|
if (addr.IsValid())
|
|
|
|
{
|
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
|
|
|
target_sp->GetImages().ResolveSymbolContextForAddress (addr.ref(), resolve_scope, sc.ref());
|
|
|
|
}
|
2011-03-03 05:34:46 +08:00
|
|
|
return sc;
|
|
|
|
}
|
|
|
|
|
2014-10-22 15:22:56 +08:00
|
|
|
size_t
|
|
|
|
SBTarget::ReadMemory (const SBAddress addr,
|
|
|
|
void *buf,
|
|
|
|
size_t size,
|
|
|
|
lldb::SBError &error)
|
|
|
|
{
|
|
|
|
SBError sb_error;
|
|
|
|
size_t bytes_read = 0;
|
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
Fixed SBTarget::ReadMemory() to work correctly and the TestTargetAPI.py test case that was reading target memory in TargetAPITestCase.test_read_memory_with_dsym and TargetAPITestCase.test_read_memory_with_dwarf.
The problem was that SBTarget::ReadMemory() was making a new section offset lldb_private::Address by doing:
size_t
SBTarget::ReadMemory (const SBAddress addr,
void *buf,
size_t size,
lldb::SBError &error)
{
...
lldb_private::Address addr_priv(addr.GetFileAddress(), NULL);
bytes_read = target_sp->ReadMemory(addr_priv, false, buf, size, err_priv);
This is wrong. If you get the file addresss from the "addr" argument and try to read memory using that, it will think the file address is a load address and it will try to resolve it accordingly. This will work fine if your executable is loaded at the same address (no slide), but it won't work if there is a slide.
The fix is to just pass along the "addr.ref()" instead of making a new addr_priv as this will pass along the lldb_private::Address that is inside the SBAddress (which is what we want), and not always change it into something that becomes a load address (if we are running), or abmigious file address (think address zero when you have 150 shared libraries that have sections that start at zero, which one would you pick). The main reason for passing a section offset address to SBTarget::ReadMemory() is so you _can_ read from the actual section + offset that is specified in the SBAddress.
llvm-svn: 221213
2014-11-04 08:56:30 +08:00
|
|
|
bytes_read = target_sp->ReadMemory(addr.ref(), false, buf, size, sb_error.ref());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sb_error.SetErrorString("invalid target");
|
2014-10-22 15:22:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return bytes_read;
|
|
|
|
}
|
2011-03-03 05:34:46 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SBBreakpoint
|
2013-10-12 03:48:25 +08:00
|
|
|
SBTarget::BreakpointCreateByLocation (const char *file,
|
|
|
|
uint32_t line)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-11-08 08:28:40 +08:00
|
|
|
return SBBreakpoint(BreakpointCreateByLocation (SBFileSpec (file, false), line));
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBBreakpoint
|
2013-10-12 03:48:25 +08:00
|
|
|
SBTarget::BreakpointCreateByLocation (const SBFileSpec &sb_file_spec,
|
|
|
|
uint32_t line)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SBBreakpoint sb_bp;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp && line != 0)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
2014-04-04 12:06:10 +08:00
|
|
|
|
<rdar://problem/11757916>
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
2012-08-30 05:13:06 +08:00
|
|
|
const LazyBool check_inlines = eLazyBoolCalculate;
|
2012-05-22 08:12:20 +08:00
|
|
|
const LazyBool skip_prologue = eLazyBoolCalculate;
|
<rdar://problem/11757916>
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
2012-08-30 05:13:06 +08:00
|
|
|
const bool internal = false;
|
2013-10-12 03:48:25 +08:00
|
|
|
const bool hardware = false;
|
|
|
|
*sb_bp = target_sp->CreateBreakpoint (NULL, *sb_file_spec, line, check_inlines, skip_prologue, internal, hardware);
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
SBStream sstr;
|
|
|
|
sb_bp.GetDescription (sstr);
|
2010-10-31 11:01:06 +08:00
|
|
|
char path[PATH_MAX];
|
|
|
|
sb_file_spec->GetPath (path, sizeof(path));
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("SBTarget(%p)::BreakpointCreateByLocation ( %s:%u ) => SBBreakpoint(%p): %s",
|
|
|
|
static_cast<void*>(target_sp.get()), path, line,
|
|
|
|
static_cast<void*>(sb_bp.get()), sstr.GetData());
|
2010-10-26 11:11:13 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
return sb_bp;
|
|
|
|
}
|
|
|
|
|
|
|
|
SBBreakpoint
|
2013-10-12 03:48:25 +08:00
|
|
|
SBTarget::BreakpointCreateByName (const char *symbol_name,
|
|
|
|
const char *module_name)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SBBreakpoint sb_bp;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp.get())
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2012-05-22 08:12:20 +08:00
|
|
|
const bool internal = false;
|
2013-10-12 03:48:25 +08:00
|
|
|
const bool hardware = false;
|
2012-05-22 08:12:20 +08:00
|
|
|
const LazyBool skip_prologue = eLazyBoolCalculate;
|
2010-06-09 00:52:24 +08:00
|
|
|
if (module_name && module_name[0])
|
|
|
|
{
|
2011-09-21 09:17:13 +08:00
|
|
|
FileSpecList module_spec_list;
|
|
|
|
module_spec_list.Append (FileSpec (module_name, false));
|
2013-10-12 03:48:25 +08:00
|
|
|
*sb_bp = target_sp->CreateBreakpoint (&module_spec_list, NULL, symbol_name, eFunctionNameTypeAuto, skip_prologue, internal, hardware);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-10-12 03:48:25 +08:00
|
|
|
*sb_bp = target_sp->CreateBreakpoint (NULL, NULL, symbol_name, eFunctionNameTypeAuto, skip_prologue, internal, hardware);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2010-10-26 11:11:13 +08:00
|
|
|
if (log)
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("SBTarget(%p)::BreakpointCreateByName (symbol=\"%s\", module=\"%s\") => SBBreakpoint(%p)",
|
|
|
|
static_cast<void*>(target_sp.get()), symbol_name,
|
|
|
|
module_name, static_cast<void*>(sb_bp.get()));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
return sb_bp;
|
|
|
|
}
|
|
|
|
|
2011-09-23 08:54:11 +08:00
|
|
|
lldb::SBBreakpoint
|
|
|
|
SBTarget::BreakpointCreateByName (const char *symbol_name,
|
2013-10-12 03:48:25 +08:00
|
|
|
const SBFileSpecList &module_list,
|
|
|
|
const SBFileSpecList &comp_unit_list)
|
2011-10-11 09:18:55 +08:00
|
|
|
{
|
|
|
|
uint32_t name_type_mask = eFunctionNameTypeAuto;
|
|
|
|
return BreakpointCreateByName (symbol_name, name_type_mask, module_list, comp_unit_list);
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb::SBBreakpoint
|
|
|
|
SBTarget::BreakpointCreateByName (const char *symbol_name,
|
2013-10-12 03:48:25 +08:00
|
|
|
uint32_t name_type_mask,
|
|
|
|
const SBFileSpecList &module_list,
|
|
|
|
const SBFileSpecList &comp_unit_list)
|
2011-09-23 08:54:11 +08:00
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2011-09-23 08:54:11 +08:00
|
|
|
|
|
|
|
SBBreakpoint sb_bp;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp && symbol_name && symbol_name[0])
|
2011-09-23 08:54:11 +08:00
|
|
|
{
|
2012-05-22 08:12:20 +08:00
|
|
|
const bool internal = false;
|
2013-10-12 03:48:25 +08:00
|
|
|
const bool hardware = false;
|
2012-05-22 08:12:20 +08:00
|
|
|
const LazyBool skip_prologue = eLazyBoolCalculate;
|
2012-01-30 17:04:36 +08:00
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
|
|
|
*sb_bp = target_sp->CreateBreakpoint (module_list.get(),
|
2013-10-12 03:48:25 +08:00
|
|
|
comp_unit_list.get(),
|
|
|
|
symbol_name,
|
|
|
|
name_type_mask,
|
|
|
|
skip_prologue,
|
|
|
|
internal,
|
|
|
|
hardware);
|
2011-09-23 08:54:11 +08:00
|
|
|
}
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2011-09-23 08:54:11 +08:00
|
|
|
if (log)
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("SBTarget(%p)::BreakpointCreateByName (symbol=\"%s\", name_type: %d) => SBBreakpoint(%p)",
|
|
|
|
static_cast<void*>(target_sp.get()), symbol_name,
|
|
|
|
name_type_mask, static_cast<void*>(sb_bp.get()));
|
2011-09-23 08:54:11 +08:00
|
|
|
|
|
|
|
return sb_bp;
|
|
|
|
}
|
|
|
|
|
2012-03-06 08:37:27 +08:00
|
|
|
lldb::SBBreakpoint
|
|
|
|
SBTarget::BreakpointCreateByNames (const char *symbol_names[],
|
|
|
|
uint32_t num_names,
|
|
|
|
uint32_t name_type_mask,
|
|
|
|
const SBFileSpecList &module_list,
|
|
|
|
const SBFileSpecList &comp_unit_list)
|
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2012-03-06 08:37:27 +08:00
|
|
|
|
|
|
|
SBBreakpoint sb_bp;
|
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp && num_names > 0)
|
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
2012-05-22 08:12:20 +08:00
|
|
|
const bool internal = false;
|
2013-10-12 03:48:25 +08:00
|
|
|
const bool hardware = false;
|
2012-05-22 08:12:20 +08:00
|
|
|
const LazyBool skip_prologue = eLazyBoolCalculate;
|
2012-03-06 08:37:27 +08:00
|
|
|
*sb_bp = target_sp->CreateBreakpoint (module_list.get(),
|
|
|
|
comp_unit_list.get(),
|
|
|
|
symbol_names,
|
|
|
|
num_names,
|
|
|
|
name_type_mask,
|
2012-05-22 08:12:20 +08:00
|
|
|
skip_prologue,
|
2013-10-12 03:48:25 +08:00
|
|
|
internal,
|
|
|
|
hardware);
|
2012-03-06 08:37:27 +08:00
|
|
|
}
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2012-03-06 08:37:27 +08:00
|
|
|
if (log)
|
|
|
|
{
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("SBTarget(%p)::BreakpointCreateByName (symbols={",
|
|
|
|
static_cast<void*>(target_sp.get()));
|
2012-03-06 08:37:27 +08:00
|
|
|
for (uint32_t i = 0 ; i < num_names; i++)
|
|
|
|
{
|
|
|
|
char sep;
|
|
|
|
if (i < num_names - 1)
|
|
|
|
sep = ',';
|
|
|
|
else
|
|
|
|
sep = '}';
|
|
|
|
if (symbol_names[i] != NULL)
|
|
|
|
log->Printf ("\"%s\"%c ", symbol_names[i], sep);
|
|
|
|
else
|
|
|
|
log->Printf ("\"<NULL>\"%c ", sep);
|
|
|
|
}
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("name_type: %d) => SBBreakpoint(%p)", name_type_mask,
|
|
|
|
static_cast<void*>(sb_bp.get()));
|
2012-03-06 08:37:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return sb_bp;
|
|
|
|
}
|
2011-09-23 08:54:11 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SBBreakpoint
|
2013-10-12 03:48:25 +08:00
|
|
|
SBTarget::BreakpointCreateByRegex (const char *symbol_name_regex,
|
|
|
|
const char *module_name)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SBBreakpoint sb_bp;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp && symbol_name_regex && symbol_name_regex[0])
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
2010-06-09 00:52:24 +08:00
|
|
|
RegularExpression regexp(symbol_name_regex);
|
2012-05-22 08:12:20 +08:00
|
|
|
const bool internal = false;
|
2013-10-12 03:48:25 +08:00
|
|
|
const bool hardware = false;
|
2012-05-22 08:12:20 +08:00
|
|
|
const LazyBool skip_prologue = eLazyBoolCalculate;
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
if (module_name && module_name[0])
|
|
|
|
{
|
2011-09-21 09:17:13 +08:00
|
|
|
FileSpecList module_spec_list;
|
|
|
|
module_spec_list.Append (FileSpec (module_name, false));
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2013-10-12 03:48:25 +08:00
|
|
|
*sb_bp = target_sp->CreateFuncRegexBreakpoint (&module_spec_list, NULL, regexp, skip_prologue, internal, hardware);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-10-12 03:48:25 +08:00
|
|
|
*sb_bp = target_sp->CreateFuncRegexBreakpoint (NULL, NULL, regexp, skip_prologue, internal, hardware);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
if (log)
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (symbol_regex=\"%s\", module_name=\"%s\") => SBBreakpoint(%p)",
|
|
|
|
static_cast<void*>(target_sp.get()), symbol_name_regex,
|
|
|
|
module_name, static_cast<void*>(sb_bp.get()));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
return sb_bp;
|
|
|
|
}
|
|
|
|
|
2011-09-23 08:54:11 +08:00
|
|
|
lldb::SBBreakpoint
|
|
|
|
SBTarget::BreakpointCreateByRegex (const char *symbol_name_regex,
|
2013-10-12 03:48:25 +08:00
|
|
|
const SBFileSpecList &module_list,
|
|
|
|
const SBFileSpecList &comp_unit_list)
|
2011-09-23 08:54:11 +08:00
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2011-09-23 08:54:11 +08:00
|
|
|
|
|
|
|
SBBreakpoint sb_bp;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp && symbol_name_regex && symbol_name_regex[0])
|
2011-09-23 08:54:11 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
2011-09-23 08:54:11 +08:00
|
|
|
RegularExpression regexp(symbol_name_regex);
|
2012-05-22 08:12:20 +08:00
|
|
|
const bool internal = false;
|
2013-10-12 03:48:25 +08:00
|
|
|
const bool hardware = false;
|
2012-05-22 08:12:20 +08:00
|
|
|
const LazyBool skip_prologue = eLazyBoolCalculate;
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2013-10-12 03:48:25 +08:00
|
|
|
*sb_bp = target_sp->CreateFuncRegexBreakpoint (module_list.get(), comp_unit_list.get(), regexp, skip_prologue, internal, hardware);
|
2011-09-23 08:54:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (log)
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (symbol_regex=\"%s\") => SBBreakpoint(%p)",
|
|
|
|
static_cast<void*>(target_sp.get()), symbol_name_regex,
|
|
|
|
static_cast<void*>(sb_bp.get()));
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2011-09-23 08:54:11 +08:00
|
|
|
return sb_bp;
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
SBBreakpoint
|
|
|
|
SBTarget::BreakpointCreateByAddress (addr_t address)
|
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SBBreakpoint sb_bp;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
2013-10-12 03:48:25 +08:00
|
|
|
const bool hardware = false;
|
|
|
|
*sb_bp = target_sp->CreateBreakpoint (address, false, hardware);
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2010-10-26 11:11:13 +08:00
|
|
|
if (log)
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("SBTarget(%p)::BreakpointCreateByAddress (address=%" PRIu64 ") => SBBreakpoint(%p)",
|
|
|
|
static_cast<void*>(target_sp.get()),
|
|
|
|
static_cast<uint64_t>(address),
|
|
|
|
static_cast<void*>(sb_bp.get()));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
return sb_bp;
|
|
|
|
}
|
|
|
|
|
2011-09-21 09:17:13 +08:00
|
|
|
lldb::SBBreakpoint
|
2013-10-12 03:48:25 +08:00
|
|
|
SBTarget::BreakpointCreateBySourceRegex (const char *source_regex,
|
|
|
|
const lldb::SBFileSpec &source_file,
|
|
|
|
const char *module_name)
|
2011-09-21 09:17:13 +08:00
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2011-09-21 09:17:13 +08:00
|
|
|
|
|
|
|
SBBreakpoint sb_bp;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp && source_regex && source_regex[0])
|
2011-09-21 09:17:13 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
2011-09-21 09:17:13 +08:00
|
|
|
RegularExpression regexp(source_regex);
|
2011-09-23 08:54:11 +08:00
|
|
|
FileSpecList source_file_spec_list;
|
2013-10-12 03:48:25 +08:00
|
|
|
const bool hardware = false;
|
2011-09-23 08:54:11 +08:00
|
|
|
source_file_spec_list.Append (source_file.ref());
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2011-09-21 09:17:13 +08:00
|
|
|
if (module_name && module_name[0])
|
|
|
|
{
|
|
|
|
FileSpecList module_spec_list;
|
|
|
|
module_spec_list.Append (FileSpec (module_name, false));
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2013-10-12 03:48:25 +08:00
|
|
|
*sb_bp = target_sp->CreateSourceRegexBreakpoint (&module_spec_list, &source_file_spec_list, regexp, false, hardware);
|
2011-09-21 09:17:13 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-10-12 03:48:25 +08:00
|
|
|
*sb_bp = target_sp->CreateSourceRegexBreakpoint (NULL, &source_file_spec_list, regexp, false, hardware);
|
2011-09-21 09:17:13 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
char path[PATH_MAX];
|
|
|
|
source_file->GetPath (path, sizeof(path));
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (source_regex=\"%s\", file=\"%s\", module_name=\"%s\") => SBBreakpoint(%p)",
|
|
|
|
static_cast<void*>(target_sp.get()), source_regex, path,
|
|
|
|
module_name, static_cast<void*>(sb_bp.get()));
|
2011-09-21 09:17:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return sb_bp;
|
|
|
|
}
|
|
|
|
|
2011-09-23 08:54:11 +08:00
|
|
|
lldb::SBBreakpoint
|
|
|
|
SBTarget::BreakpointCreateBySourceRegex (const char *source_regex,
|
2013-10-12 03:48:25 +08:00
|
|
|
const SBFileSpecList &module_list,
|
|
|
|
const lldb::SBFileSpecList &source_file_list)
|
2011-09-23 08:54:11 +08:00
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2011-09-23 08:54:11 +08:00
|
|
|
|
|
|
|
SBBreakpoint sb_bp;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp && source_regex && source_regex[0])
|
2011-09-23 08:54:11 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
2013-10-12 03:48:25 +08:00
|
|
|
const bool hardware = false;
|
2011-09-23 08:54:11 +08:00
|
|
|
RegularExpression regexp(source_regex);
|
2013-10-12 03:48:25 +08:00
|
|
|
*sb_bp = target_sp->CreateSourceRegexBreakpoint (module_list.get(), source_file_list.get(), regexp, false, hardware);
|
2011-09-23 08:54:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (log)
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (source_regex=\"%s\") => SBBreakpoint(%p)",
|
|
|
|
static_cast<void*>(target_sp.get()), source_regex,
|
|
|
|
static_cast<void*>(sb_bp.get()));
|
2011-09-23 08:54:11 +08:00
|
|
|
|
|
|
|
return sb_bp;
|
|
|
|
}
|
2011-09-21 09:17:13 +08:00
|
|
|
|
2012-03-06 08:37:27 +08:00
|
|
|
lldb::SBBreakpoint
|
|
|
|
SBTarget::BreakpointCreateForException (lldb::LanguageType language,
|
2013-10-12 03:48:25 +08:00
|
|
|
bool catch_bp,
|
|
|
|
bool throw_bp)
|
2012-03-06 08:37:27 +08:00
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2012-03-06 08:37:27 +08:00
|
|
|
|
|
|
|
SBBreakpoint sb_bp;
|
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
2013-10-12 03:48:25 +08:00
|
|
|
const bool hardware = false;
|
|
|
|
*sb_bp = target_sp->CreateExceptionBreakpoint (language, catch_bp, throw_bp, hardware);
|
2012-03-06 08:37:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (log)
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (Language: %s, catch: %s throw: %s) => SBBreakpoint(%p)",
|
|
|
|
static_cast<void*>(target_sp.get()),
|
2012-03-06 08:37:27 +08:00
|
|
|
LanguageRuntime::GetNameForLanguageType(language),
|
2014-04-04 12:06:10 +08:00
|
|
|
catch_bp ? "on" : "off", throw_bp ? "on" : "off",
|
|
|
|
static_cast<void*>(sb_bp.get()));
|
2012-03-06 08:37:27 +08:00
|
|
|
|
|
|
|
return sb_bp;
|
|
|
|
}
|
|
|
|
|
2011-09-27 06:40:50 +08:00
|
|
|
uint32_t
|
|
|
|
SBTarget::GetNumBreakpoints () const
|
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2011-09-27 06:40:50 +08:00
|
|
|
{
|
|
|
|
// The breakpoint list is thread safe, no need to lock
|
2012-01-30 17:04:36 +08:00
|
|
|
return target_sp->GetBreakpointList().GetSize();
|
2011-09-27 06:40:50 +08:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
SBBreakpoint
|
|
|
|
SBTarget::GetBreakpointAtIndex (uint32_t idx) const
|
|
|
|
{
|
|
|
|
SBBreakpoint sb_breakpoint;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2011-09-27 06:40:50 +08:00
|
|
|
{
|
|
|
|
// The breakpoint list is thread safe, no need to lock
|
2012-01-30 17:04:36 +08:00
|
|
|
*sb_breakpoint = target_sp->GetBreakpointList().GetBreakpointAtIndex(idx);
|
2011-09-27 06:40:50 +08:00
|
|
|
}
|
|
|
|
return sb_breakpoint;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBTarget::BreakpointDelete (break_id_t bp_id)
|
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2011-09-27 06:40:50 +08:00
|
|
|
|
|
|
|
bool result = false;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2011-09-27 06:40:50 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
|
|
|
result = target_sp->RemoveBreakpointByID (bp_id);
|
2011-09-27 06:40:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (log)
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("SBTarget(%p)::BreakpointDelete (bp_id=%d) => %i",
|
|
|
|
static_cast<void*>(target_sp.get()),
|
|
|
|
static_cast<uint32_t>(bp_id), result);
|
2011-09-27 06:40:50 +08:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2010-07-24 07:33:17 +08:00
|
|
|
SBBreakpoint
|
|
|
|
SBTarget::FindBreakpointByID (break_id_t bp_id)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-07-24 07:33:17 +08:00
|
|
|
SBBreakpoint sb_breakpoint;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp && bp_id != LLDB_INVALID_BREAK_ID)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
|
|
|
*sb_breakpoint = target_sp->GetBreakpointByID (bp_id);
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
if (log)
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("SBTarget(%p)::FindBreakpointByID (bp_id=%d) => SBBreakpoint(%p)",
|
|
|
|
static_cast<void*>(target_sp.get()),
|
|
|
|
static_cast<uint32_t>(bp_id),
|
|
|
|
static_cast<void*>(sb_breakpoint.get()));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-07-24 07:33:17 +08:00
|
|
|
return sb_breakpoint;
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2011-09-27 06:40:50 +08:00
|
|
|
bool
|
|
|
|
SBTarget::EnableAllBreakpoints ()
|
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2011-09-27 06:40:50 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
|
|
|
target_sp->EnableAllBreakpoints ();
|
2011-09-27 06:40:50 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBTarget::DisableAllBreakpoints ()
|
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2011-09-27 06:40:50 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
|
|
|
target_sp->DisableAllBreakpoints ();
|
2011-09-27 06:40:50 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBTarget::DeleteAllBreakpoints ()
|
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2011-09-27 06:40:50 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
|
|
|
target_sp->RemoveAllBreakpoints ();
|
2011-09-27 06:40:50 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-07-24 07:33:17 +08:00
|
|
|
uint32_t
|
2011-10-14 02:08:26 +08:00
|
|
|
SBTarget::GetNumWatchpoints () const
|
2010-07-24 07:33:17 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
2011-10-14 08:42:25 +08:00
|
|
|
// The watchpoint list is thread safe, no need to lock
|
2012-01-30 17:04:36 +08:00
|
|
|
return target_sp->GetWatchpointList().GetSize();
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-07-24 07:33:17 +08:00
|
|
|
return 0;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2011-10-14 02:08:26 +08:00
|
|
|
SBWatchpoint
|
|
|
|
SBTarget::GetWatchpointAtIndex (uint32_t idx) const
|
2011-09-28 04:29:45 +08:00
|
|
|
{
|
2011-10-14 08:42:25 +08:00
|
|
|
SBWatchpoint sb_watchpoint;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
2011-10-14 08:42:25 +08:00
|
|
|
// The watchpoint list is thread safe, no need to lock
|
2012-02-04 10:27:34 +08:00
|
|
|
sb_watchpoint.SetSP (target_sp->GetWatchpointList().GetByIndex(idx));
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2011-10-14 08:42:25 +08:00
|
|
|
return sb_watchpoint;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2011-10-14 02:08:26 +08:00
|
|
|
SBTarget::DeleteWatchpoint (watch_id_t wp_id)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
bool result = false;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
2012-06-01 06:56:36 +08:00
|
|
|
Mutex::Locker locker;
|
|
|
|
target_sp->GetWatchpointList().GetListMutex(locker);
|
2012-01-30 17:04:36 +08:00
|
|
|
result = target_sp->RemoveWatchpointByID (wp_id);
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
if (log)
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("SBTarget(%p)::WatchpointDelete (wp_id=%d) => %i",
|
|
|
|
static_cast<void*>(target_sp.get()),
|
|
|
|
static_cast<uint32_t>(wp_id), result);
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
return result;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2011-10-14 02:08:26 +08:00
|
|
|
SBWatchpoint
|
|
|
|
SBTarget::FindWatchpointByID (lldb::watch_id_t wp_id)
|
2011-09-27 06:40:50 +08:00
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2011-09-27 06:40:50 +08:00
|
|
|
|
2011-10-14 02:08:26 +08:00
|
|
|
SBWatchpoint sb_watchpoint;
|
2012-02-04 10:27:34 +08:00
|
|
|
lldb::WatchpointSP watchpoint_sp;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp && wp_id != LLDB_INVALID_WATCH_ID)
|
2011-09-27 06:40:50 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
2012-06-01 06:56:36 +08:00
|
|
|
Mutex::Locker locker;
|
|
|
|
target_sp->GetWatchpointList().GetListMutex(locker);
|
2012-02-04 10:27:34 +08:00
|
|
|
watchpoint_sp = target_sp->GetWatchpointList().FindByID(wp_id);
|
|
|
|
sb_watchpoint.SetSP (watchpoint_sp);
|
2011-09-27 06:40:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (log)
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("SBTarget(%p)::FindWatchpointByID (bp_id=%d) => SBWatchpoint(%p)",
|
|
|
|
static_cast<void*>(target_sp.get()),
|
|
|
|
static_cast<uint32_t>(wp_id),
|
|
|
|
static_cast<void*>(watchpoint_sp.get()));
|
2011-09-27 06:40:50 +08:00
|
|
|
|
2011-10-14 02:08:26 +08:00
|
|
|
return sb_watchpoint;
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb::SBWatchpoint
|
2012-06-05 07:19:54 +08:00
|
|
|
SBTarget::WatchAddress (lldb::addr_t addr, size_t size, bool read, bool write, SBError &error)
|
2011-10-14 02:08:26 +08:00
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2011-10-14 02:08:26 +08:00
|
|
|
SBWatchpoint sb_watchpoint;
|
2012-02-04 10:27:34 +08:00
|
|
|
lldb::WatchpointSP watchpoint_sp;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
2012-02-04 10:27:34 +08:00
|
|
|
if (target_sp && (read || write) && addr != LLDB_INVALID_ADDRESS && size > 0)
|
2011-10-14 02:08:26 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
2012-02-04 10:27:34 +08:00
|
|
|
uint32_t watch_type = 0;
|
|
|
|
if (read)
|
|
|
|
watch_type |= LLDB_WATCH_TYPE_READ;
|
|
|
|
if (write)
|
|
|
|
watch_type |= LLDB_WATCH_TYPE_WRITE;
|
2013-06-19 05:52:48 +08:00
|
|
|
if (watch_type == 0)
|
|
|
|
{
|
|
|
|
error.SetErrorString("Can't create a watchpoint that is neither read nor write.");
|
|
|
|
return sb_watchpoint;
|
|
|
|
}
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2012-06-01 06:56:36 +08:00
|
|
|
// Target::CreateWatchpoint() is thread safe.
|
2012-06-05 07:19:54 +08:00
|
|
|
Error cw_error;
|
2012-10-23 15:20:06 +08:00
|
|
|
// This API doesn't take in a type, so we can't figure out what it is.
|
|
|
|
ClangASTType *type = NULL;
|
|
|
|
watchpoint_sp = target_sp->CreateWatchpoint(addr, size, type, watch_type, cw_error);
|
2012-06-05 07:19:54 +08:00
|
|
|
error.SetError(cw_error);
|
2012-02-04 10:27:34 +08:00
|
|
|
sb_watchpoint.SetSP (watchpoint_sp);
|
2011-10-14 02:08:26 +08:00
|
|
|
}
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2011-10-14 02:08:26 +08:00
|
|
|
if (log)
|
2012-11-30 05:49:15 +08:00
|
|
|
log->Printf ("SBTarget(%p)::WatchAddress (addr=0x%" PRIx64 ", 0x%u) => SBWatchpoint(%p)",
|
2014-04-04 12:06:10 +08:00
|
|
|
static_cast<void*>(target_sp.get()), addr,
|
|
|
|
static_cast<uint32_t>(size),
|
|
|
|
static_cast<void*>(watchpoint_sp.get()));
|
|
|
|
|
2011-10-14 02:08:26 +08:00
|
|
|
return sb_watchpoint;
|
2011-09-27 06:40:50 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
bool
|
2011-10-14 02:08:26 +08:00
|
|
|
SBTarget::EnableAllWatchpoints ()
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
2012-06-01 06:56:36 +08:00
|
|
|
Mutex::Locker locker;
|
|
|
|
target_sp->GetWatchpointList().GetListMutex(locker);
|
2012-01-30 17:04:36 +08:00
|
|
|
target_sp->EnableAllWatchpoints ();
|
2010-06-09 00:52:24 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2011-10-14 02:08:26 +08:00
|
|
|
SBTarget::DisableAllWatchpoints ()
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
2012-06-01 06:56:36 +08:00
|
|
|
Mutex::Locker locker;
|
|
|
|
target_sp->GetWatchpointList().GetListMutex(locker);
|
2012-01-30 17:04:36 +08:00
|
|
|
target_sp->DisableAllWatchpoints ();
|
2010-06-09 00:52:24 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-10-09 05:49:02 +08:00
|
|
|
SBValue
|
|
|
|
SBTarget::CreateValueFromAddress (const char *name, SBAddress addr, SBType type)
|
|
|
|
{
|
|
|
|
SBValue sb_value;
|
|
|
|
lldb::ValueObjectSP new_value_sp;
|
|
|
|
if (IsValid() && name && *name && addr.IsValid() && type.IsValid())
|
|
|
|
{
|
|
|
|
lldb::addr_t address(addr.GetLoadAddress(*this));
|
|
|
|
lldb::TypeImplSP type_impl_sp (type.GetSP());
|
2013-10-29 08:28:35 +08:00
|
|
|
ClangASTType pointer_ast_type(type_impl_sp->GetClangASTType(true).GetPointerType ());
|
2013-10-09 05:49:02 +08:00
|
|
|
if (pointer_ast_type)
|
|
|
|
{
|
|
|
|
lldb::DataBufferSP buffer(new lldb_private::DataBufferHeap(&address,sizeof(lldb::addr_t)));
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2013-10-09 05:49:02 +08:00
|
|
|
ExecutionContext exe_ctx (ExecutionContextRef(ExecutionContext(m_opaque_sp.get(),false)));
|
|
|
|
ValueObjectSP ptr_result_valobj_sp(ValueObjectConstResult::Create (exe_ctx.GetBestExecutionContextScope(),
|
|
|
|
pointer_ast_type,
|
|
|
|
ConstString(name),
|
|
|
|
buffer,
|
|
|
|
exe_ctx.GetByteOrder(),
|
|
|
|
exe_ctx.GetAddressByteSize()));
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2013-10-09 05:49:02 +08:00
|
|
|
if (ptr_result_valobj_sp)
|
|
|
|
{
|
|
|
|
ptr_result_valobj_sp->GetValue().SetValueType(Value::eValueTypeLoadAddress);
|
|
|
|
Error err;
|
|
|
|
new_value_sp = ptr_result_valobj_sp->Dereference(err);
|
|
|
|
if (new_value_sp)
|
|
|
|
new_value_sp->SetName(ConstString(name));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sb_value.SetSP(new_value_sp);
|
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
if (new_value_sp)
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("SBTarget(%p)::CreateValueFromAddress => \"%s\"",
|
|
|
|
static_cast<void*>(m_opaque_sp.get()),
|
|
|
|
new_value_sp->GetName().AsCString());
|
2013-10-09 05:49:02 +08:00
|
|
|
else
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("SBTarget(%p)::CreateValueFromAddress => NULL",
|
|
|
|
static_cast<void*>(m_opaque_sp.get()));
|
2013-10-09 05:49:02 +08:00
|
|
|
}
|
|
|
|
return sb_value;
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
bool
|
2011-10-14 02:08:26 +08:00
|
|
|
SBTarget::DeleteAllWatchpoints ()
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
2012-06-01 06:56:36 +08:00
|
|
|
Mutex::Locker locker;
|
|
|
|
target_sp->GetWatchpointList().GetListMutex(locker);
|
2012-01-30 17:04:36 +08:00
|
|
|
target_sp->RemoveAllWatchpoints ();
|
2010-06-09 00:52:24 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-24 08:52:29 +08:00
|
|
|
lldb::SBModule
|
|
|
|
SBTarget::AddModule (const char *path,
|
|
|
|
const char *triple,
|
|
|
|
const char *uuid_cstr)
|
2012-04-24 04:23:39 +08:00
|
|
|
{
|
|
|
|
return AddModule (path, triple, uuid_cstr, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb::SBModule
|
|
|
|
SBTarget::AddModule (const char *path,
|
|
|
|
const char *triple,
|
|
|
|
const char *uuid_cstr,
|
|
|
|
const char *symfile)
|
2011-09-24 08:52:29 +08:00
|
|
|
{
|
|
|
|
lldb::SBModule sb_module;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2011-09-24 08:52:29 +08:00
|
|
|
{
|
2012-02-26 13:51:37 +08:00
|
|
|
ModuleSpec module_spec;
|
2011-09-24 08:52:29 +08:00
|
|
|
if (path)
|
2012-02-26 13:51:37 +08:00
|
|
|
module_spec.GetFileSpec().SetFile(path, false);
|
2012-04-24 04:23:39 +08:00
|
|
|
|
2011-09-24 08:52:29 +08:00
|
|
|
if (uuid_cstr)
|
2012-09-28 06:26:11 +08:00
|
|
|
module_spec.GetUUID().SetFromCString(uuid_cstr);
|
2012-04-24 04:23:39 +08:00
|
|
|
|
2011-09-24 08:52:29 +08:00
|
|
|
if (triple)
|
2012-02-26 13:51:37 +08:00
|
|
|
module_spec.GetArchitecture().SetTriple (triple, target_sp->GetPlatform ().get());
|
2013-09-12 05:25:46 +08:00
|
|
|
else
|
|
|
|
module_spec.GetArchitecture() = target_sp->GetArchitecture();
|
2012-04-24 04:23:39 +08:00
|
|
|
|
|
|
|
if (symfile)
|
|
|
|
module_spec.GetSymbolFileSpec ().SetFile(symfile, false);
|
2011-09-24 08:52:29 +08:00
|
|
|
|
2012-02-26 13:51:37 +08:00
|
|
|
sb_module.SetSP(target_sp->GetSharedModule (module_spec));
|
2011-09-24 08:52:29 +08:00
|
|
|
}
|
|
|
|
return sb_module;
|
|
|
|
}
|
|
|
|
|
Added a way to extract the module specifications from a file. A module specification is information that is required to describe a module (executable, shared library, object file, ect). This information includes host path, platform path (remote path), symbol file path, UUID, object name (for objects in .a files for example you could have an object name of "foo.o"), and target triple. Module specification can be used to create a module, or used to add a module to a target. A list of module specifications can be used to enumerate objects in container objects (like universal mach files and BSD archive files).
There are two new classes:
lldb::SBModuleSpec
lldb::SBModuleSpecList
The SBModuleSpec wraps up a lldb_private::ModuleSpec, and SBModuleSpecList wraps up a lldb_private::ModuleSpecList.
llvm-svn: 185877
2013-07-09 06:22:41 +08:00
|
|
|
lldb::SBModule
|
|
|
|
SBTarget::AddModule (const SBModuleSpec &module_spec)
|
|
|
|
{
|
|
|
|
lldb::SBModule sb_module;
|
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
|
|
|
sb_module.SetSP(target_sp->GetSharedModule (*module_spec.m_opaque_ap));
|
|
|
|
return sb_module;
|
|
|
|
}
|
|
|
|
|
2011-09-24 08:52:29 +08:00
|
|
|
bool
|
|
|
|
SBTarget::AddModule (lldb::SBModule &module)
|
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2011-09-24 08:52:29 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
target_sp->GetImages().AppendIfNeeded (module.GetSP());
|
2011-09-24 08:52:29 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
uint32_t
|
|
|
|
SBTarget::GetNumModules () const
|
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
uint32_t num = 0;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
// The module list is thread safe, no need to lock
|
2012-01-30 17:04:36 +08:00
|
|
|
num = target_sp->GetImages().GetSize();
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
if (log)
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("SBTarget(%p)::GetNumModules () => %d",
|
|
|
|
static_cast<void*>(target_sp.get()), num);
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
return num;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2010-07-31 04:12:55 +08:00
|
|
|
void
|
|
|
|
SBTarget::Clear ()
|
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
if (log)
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("SBTarget(%p)::Clear ()",
|
|
|
|
static_cast<void*>(m_opaque_sp.get()));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-07-31 04:12:55 +08:00
|
|
|
m_opaque_sp.reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SBModule
|
|
|
|
SBTarget::FindModule (const SBFileSpec &sb_file_spec)
|
|
|
|
{
|
|
|
|
SBModule sb_module;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp && sb_file_spec.IsValid())
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
2012-02-26 13:51:37 +08:00
|
|
|
ModuleSpec module_spec(*sb_file_spec);
|
2010-12-21 04:49:23 +08:00
|
|
|
// The module list is thread safe, no need to lock
|
2012-02-26 13:51:37 +08:00
|
|
|
sb_module.SetSP (target_sp->GetImages().FindFirstModule (module_spec));
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
return sb_module;
|
|
|
|
}
|
|
|
|
|
2012-01-29 14:07:39 +08:00
|
|
|
lldb::ByteOrder
|
|
|
|
SBTarget::GetByteOrder ()
|
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
|
|
|
return target_sp->GetArchitecture().GetByteOrder();
|
2012-01-29 14:07:39 +08:00
|
|
|
return eByteOrderInvalid;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
SBTarget::GetTriple ()
|
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2012-01-29 14:07:39 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
std::string triple (target_sp->GetArchitecture().GetTriple().str());
|
2012-01-29 14:07:39 +08:00
|
|
|
// Unique the string so we don't run into ownership issues since
|
|
|
|
// the const strings put the string into the string pool once and
|
|
|
|
// the strings never comes out
|
|
|
|
ConstString const_triple (triple.c_str());
|
|
|
|
return const_triple.GetCString();
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2014-10-22 15:22:56 +08:00
|
|
|
uint32_t
|
|
|
|
SBTarget::GetDataByteSize ()
|
|
|
|
{
|
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
|
|
|
{
|
|
|
|
return target_sp->GetArchitecture().GetDataByteSize() ;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
SBTarget::GetCodeByteSize ()
|
|
|
|
{
|
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
|
|
|
{
|
|
|
|
return target_sp->GetArchitecture().GetCodeByteSize() ;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-01-29 14:07:39 +08:00
|
|
|
uint32_t
|
|
|
|
SBTarget::GetAddressByteSize()
|
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
|
|
|
return target_sp->GetArchitecture().GetAddressByteSize();
|
2012-01-29 14:07:39 +08:00
|
|
|
return sizeof(void*);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SBModule
|
|
|
|
SBTarget::GetModuleAtIndex (uint32_t idx)
|
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SBModule sb_module;
|
2012-01-30 17:04:36 +08:00
|
|
|
ModuleSP module_sp;
|
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
// The module list is thread safe, no need to lock
|
2012-01-30 17:04:36 +08:00
|
|
|
module_sp = target_sp->GetImages().GetModuleAtIndex(idx);
|
|
|
|
sb_module.SetSP (module_sp);
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
if (log)
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("SBTarget(%p)::GetModuleAtIndex (idx=%d) => SBModule(%p)",
|
|
|
|
static_cast<void*>(target_sp.get()), idx,
|
|
|
|
static_cast<void*>(module_sp.get()));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
return sb_module;
|
|
|
|
}
|
|
|
|
|
2011-09-24 08:52:29 +08:00
|
|
|
bool
|
|
|
|
SBTarget::RemoveModule (lldb::SBModule module)
|
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
|
|
|
return target_sp->GetImages().Remove(module.GetSP());
|
2011-09-24 08:52:29 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
SBBroadcaster
|
|
|
|
SBTarget::GetBroadcaster () const
|
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
SBBroadcaster broadcaster(target_sp.get(), false);
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2010-10-26 11:11:13 +08:00
|
|
|
if (log)
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("SBTarget(%p)::GetBroadcaster () => SBBroadcaster(%p)",
|
|
|
|
static_cast<void*>(target_sp.get()),
|
|
|
|
static_cast<void*>(broadcaster.get()));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
return broadcaster;
|
|
|
|
}
|
|
|
|
|
2010-09-20 13:20:02 +08:00
|
|
|
bool
|
2010-10-26 11:11:13 +08:00
|
|
|
SBTarget::GetDescription (SBStream &description, lldb::DescriptionLevel description_level)
|
|
|
|
{
|
2011-11-13 14:57:31 +08:00
|
|
|
Stream &strm = description.ref();
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2010-09-21 00:21:41 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
target_sp->Dump (&strm, description_level);
|
2010-09-21 00:21:41 +08:00
|
|
|
}
|
2010-09-20 13:20:02 +08:00
|
|
|
else
|
2011-11-13 14:57:31 +08:00
|
|
|
strm.PutCString ("No value");
|
2010-09-20 13:20:02 +08:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2011-06-21 09:34:41 +08:00
|
|
|
|
Removed all of the "#ifndef SWIG" from the SB header files since we are using
interface (.i) files for each class.
Changed the FindFunction class from:
uint32_t
SBTarget::FindFunctions (const char *name,
uint32_t name_type_mask,
bool append,
lldb::SBSymbolContextList& sc_list)
uint32_t
SBModule::FindFunctions (const char *name,
uint32_t name_type_mask,
bool append,
lldb::SBSymbolContextList& sc_list)
To:
lldb::SBSymbolContextList
SBTarget::FindFunctions (const char *name,
uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
lldb::SBSymbolContextList
SBModule::FindFunctions (const char *name,
uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
This makes the API easier to use from python. Also added the ability to
append a SBSymbolContext or a SBSymbolContextList to a SBSymbolContextList.
Exposed properties for lldb.SBSymbolContextList in python:
lldb.SBSymbolContextList.modules => list() or all lldb.SBModule objects in the list
lldb.SBSymbolContextList.compile_units => list() or all lldb.SBCompileUnits objects in the list
lldb.SBSymbolContextList.functions => list() or all lldb.SBFunction objects in the list
lldb.SBSymbolContextList.blocks => list() or all lldb.SBBlock objects in the list
lldb.SBSymbolContextList.line_entries => list() or all lldb.SBLineEntry objects in the list
lldb.SBSymbolContextList.symbols => list() or all lldb.SBSymbol objects in the list
This allows a call to the SBTarget::FindFunctions(...) and SBModule::FindFunctions(...)
and then the result can be used to extract the desired information:
sc_list = lldb.target.FindFunctions("erase")
for function in sc_list.functions:
print function
for symbol in sc_list.symbols:
print symbol
Exposed properties for the lldb.SBSymbolContext objects in python:
lldb.SBSymbolContext.module => lldb.SBModule
lldb.SBSymbolContext.compile_unit => lldb.SBCompileUnit
lldb.SBSymbolContext.function => lldb.SBFunction
lldb.SBSymbolContext.block => lldb.SBBlock
lldb.SBSymbolContext.line_entry => lldb.SBLineEntry
lldb.SBSymbolContext.symbol => lldb.SBSymbol
Exposed properties for the lldb.SBBlock objects in python:
lldb.SBBlock.parent => lldb.SBBlock for the parent block that contains
lldb.SBBlock.sibling => lldb.SBBlock for the sibling block to the current block
lldb.SBBlock.first_child => lldb.SBBlock for the first child block to the current block
lldb.SBBlock.call_site => for inline functions, return a lldb.declaration object that gives the call site file, line and column
lldb.SBBlock.name => for inline functions this is the name of the inline function that this block represents
lldb.SBBlock.inlined_block => returns the inlined function block that contains this block (might return itself if the current block is an inlined block)
lldb.SBBlock.range[int] => access the address ranges for a block by index, a list() with start and end address is returned
lldb.SBBlock.ranges => an array or all address ranges for this block
lldb.SBBlock.num_ranges => the number of address ranges for this blcok
SBFunction objects can now get the SBType and the SBBlock that represents the
top scope of the function.
SBBlock objects can now get the variable list from the current block. The value
list returned allows varaibles to be viewed prior with no process if code
wants to check the variables in a function. There are two ways to get a variable
list from a SBBlock:
lldb::SBValueList
SBBlock::GetVariables (lldb::SBFrame& frame,
bool arguments,
bool locals,
bool statics,
lldb::DynamicValueType use_dynamic);
lldb::SBValueList
SBBlock::GetVariables (lldb::SBTarget& target,
bool arguments,
bool locals,
bool statics);
When a SBFrame is used, the values returned will be locked down to the frame
and the values will be evaluated in the context of that frame.
When a SBTarget is used, global an static variables can be viewed without a
running process.
llvm-svn: 149853
2012-02-06 09:44:54 +08:00
|
|
|
lldb::SBSymbolContextList
|
|
|
|
SBTarget::FindFunctions (const char *name, uint32_t name_type_mask)
|
2011-06-21 09:34:41 +08:00
|
|
|
{
|
Removed all of the "#ifndef SWIG" from the SB header files since we are using
interface (.i) files for each class.
Changed the FindFunction class from:
uint32_t
SBTarget::FindFunctions (const char *name,
uint32_t name_type_mask,
bool append,
lldb::SBSymbolContextList& sc_list)
uint32_t
SBModule::FindFunctions (const char *name,
uint32_t name_type_mask,
bool append,
lldb::SBSymbolContextList& sc_list)
To:
lldb::SBSymbolContextList
SBTarget::FindFunctions (const char *name,
uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
lldb::SBSymbolContextList
SBModule::FindFunctions (const char *name,
uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
This makes the API easier to use from python. Also added the ability to
append a SBSymbolContext or a SBSymbolContextList to a SBSymbolContextList.
Exposed properties for lldb.SBSymbolContextList in python:
lldb.SBSymbolContextList.modules => list() or all lldb.SBModule objects in the list
lldb.SBSymbolContextList.compile_units => list() or all lldb.SBCompileUnits objects in the list
lldb.SBSymbolContextList.functions => list() or all lldb.SBFunction objects in the list
lldb.SBSymbolContextList.blocks => list() or all lldb.SBBlock objects in the list
lldb.SBSymbolContextList.line_entries => list() or all lldb.SBLineEntry objects in the list
lldb.SBSymbolContextList.symbols => list() or all lldb.SBSymbol objects in the list
This allows a call to the SBTarget::FindFunctions(...) and SBModule::FindFunctions(...)
and then the result can be used to extract the desired information:
sc_list = lldb.target.FindFunctions("erase")
for function in sc_list.functions:
print function
for symbol in sc_list.symbols:
print symbol
Exposed properties for the lldb.SBSymbolContext objects in python:
lldb.SBSymbolContext.module => lldb.SBModule
lldb.SBSymbolContext.compile_unit => lldb.SBCompileUnit
lldb.SBSymbolContext.function => lldb.SBFunction
lldb.SBSymbolContext.block => lldb.SBBlock
lldb.SBSymbolContext.line_entry => lldb.SBLineEntry
lldb.SBSymbolContext.symbol => lldb.SBSymbol
Exposed properties for the lldb.SBBlock objects in python:
lldb.SBBlock.parent => lldb.SBBlock for the parent block that contains
lldb.SBBlock.sibling => lldb.SBBlock for the sibling block to the current block
lldb.SBBlock.first_child => lldb.SBBlock for the first child block to the current block
lldb.SBBlock.call_site => for inline functions, return a lldb.declaration object that gives the call site file, line and column
lldb.SBBlock.name => for inline functions this is the name of the inline function that this block represents
lldb.SBBlock.inlined_block => returns the inlined function block that contains this block (might return itself if the current block is an inlined block)
lldb.SBBlock.range[int] => access the address ranges for a block by index, a list() with start and end address is returned
lldb.SBBlock.ranges => an array or all address ranges for this block
lldb.SBBlock.num_ranges => the number of address ranges for this blcok
SBFunction objects can now get the SBType and the SBBlock that represents the
top scope of the function.
SBBlock objects can now get the variable list from the current block. The value
list returned allows varaibles to be viewed prior with no process if code
wants to check the variables in a function. There are two ways to get a variable
list from a SBBlock:
lldb::SBValueList
SBBlock::GetVariables (lldb::SBFrame& frame,
bool arguments,
bool locals,
bool statics,
lldb::DynamicValueType use_dynamic);
lldb::SBValueList
SBBlock::GetVariables (lldb::SBTarget& target,
bool arguments,
bool locals,
bool statics);
When a SBFrame is used, the values returned will be locked down to the frame
and the values will be evaluated in the context of that frame.
When a SBTarget is used, global an static variables can be viewed without a
running process.
llvm-svn: 149853
2012-02-06 09:44:54 +08:00
|
|
|
lldb::SBSymbolContextList sb_sc_list;
|
2012-01-30 17:04:36 +08:00
|
|
|
if (name && name[0])
|
2011-06-21 09:34:41 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
|
|
|
{
|
|
|
|
const bool symbols_ok = true;
|
2012-02-11 06:52:19 +08:00
|
|
|
const bool inlines_ok = true;
|
Removed all of the "#ifndef SWIG" from the SB header files since we are using
interface (.i) files for each class.
Changed the FindFunction class from:
uint32_t
SBTarget::FindFunctions (const char *name,
uint32_t name_type_mask,
bool append,
lldb::SBSymbolContextList& sc_list)
uint32_t
SBModule::FindFunctions (const char *name,
uint32_t name_type_mask,
bool append,
lldb::SBSymbolContextList& sc_list)
To:
lldb::SBSymbolContextList
SBTarget::FindFunctions (const char *name,
uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
lldb::SBSymbolContextList
SBModule::FindFunctions (const char *name,
uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
This makes the API easier to use from python. Also added the ability to
append a SBSymbolContext or a SBSymbolContextList to a SBSymbolContextList.
Exposed properties for lldb.SBSymbolContextList in python:
lldb.SBSymbolContextList.modules => list() or all lldb.SBModule objects in the list
lldb.SBSymbolContextList.compile_units => list() or all lldb.SBCompileUnits objects in the list
lldb.SBSymbolContextList.functions => list() or all lldb.SBFunction objects in the list
lldb.SBSymbolContextList.blocks => list() or all lldb.SBBlock objects in the list
lldb.SBSymbolContextList.line_entries => list() or all lldb.SBLineEntry objects in the list
lldb.SBSymbolContextList.symbols => list() or all lldb.SBSymbol objects in the list
This allows a call to the SBTarget::FindFunctions(...) and SBModule::FindFunctions(...)
and then the result can be used to extract the desired information:
sc_list = lldb.target.FindFunctions("erase")
for function in sc_list.functions:
print function
for symbol in sc_list.symbols:
print symbol
Exposed properties for the lldb.SBSymbolContext objects in python:
lldb.SBSymbolContext.module => lldb.SBModule
lldb.SBSymbolContext.compile_unit => lldb.SBCompileUnit
lldb.SBSymbolContext.function => lldb.SBFunction
lldb.SBSymbolContext.block => lldb.SBBlock
lldb.SBSymbolContext.line_entry => lldb.SBLineEntry
lldb.SBSymbolContext.symbol => lldb.SBSymbol
Exposed properties for the lldb.SBBlock objects in python:
lldb.SBBlock.parent => lldb.SBBlock for the parent block that contains
lldb.SBBlock.sibling => lldb.SBBlock for the sibling block to the current block
lldb.SBBlock.first_child => lldb.SBBlock for the first child block to the current block
lldb.SBBlock.call_site => for inline functions, return a lldb.declaration object that gives the call site file, line and column
lldb.SBBlock.name => for inline functions this is the name of the inline function that this block represents
lldb.SBBlock.inlined_block => returns the inlined function block that contains this block (might return itself if the current block is an inlined block)
lldb.SBBlock.range[int] => access the address ranges for a block by index, a list() with start and end address is returned
lldb.SBBlock.ranges => an array or all address ranges for this block
lldb.SBBlock.num_ranges => the number of address ranges for this blcok
SBFunction objects can now get the SBType and the SBBlock that represents the
top scope of the function.
SBBlock objects can now get the variable list from the current block. The value
list returned allows varaibles to be viewed prior with no process if code
wants to check the variables in a function. There are two ways to get a variable
list from a SBBlock:
lldb::SBValueList
SBBlock::GetVariables (lldb::SBFrame& frame,
bool arguments,
bool locals,
bool statics,
lldb::DynamicValueType use_dynamic);
lldb::SBValueList
SBBlock::GetVariables (lldb::SBTarget& target,
bool arguments,
bool locals,
bool statics);
When a SBFrame is used, the values returned will be locked down to the frame
and the values will be evaluated in the context of that frame.
When a SBTarget is used, global an static variables can be viewed without a
running process.
llvm-svn: 149853
2012-02-06 09:44:54 +08:00
|
|
|
const bool append = true;
|
|
|
|
target_sp->GetImages().FindFunctions (ConstString(name),
|
|
|
|
name_type_mask,
|
2012-02-11 06:52:19 +08:00
|
|
|
symbols_ok,
|
|
|
|
inlines_ok,
|
Removed all of the "#ifndef SWIG" from the SB header files since we are using
interface (.i) files for each class.
Changed the FindFunction class from:
uint32_t
SBTarget::FindFunctions (const char *name,
uint32_t name_type_mask,
bool append,
lldb::SBSymbolContextList& sc_list)
uint32_t
SBModule::FindFunctions (const char *name,
uint32_t name_type_mask,
bool append,
lldb::SBSymbolContextList& sc_list)
To:
lldb::SBSymbolContextList
SBTarget::FindFunctions (const char *name,
uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
lldb::SBSymbolContextList
SBModule::FindFunctions (const char *name,
uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
This makes the API easier to use from python. Also added the ability to
append a SBSymbolContext or a SBSymbolContextList to a SBSymbolContextList.
Exposed properties for lldb.SBSymbolContextList in python:
lldb.SBSymbolContextList.modules => list() or all lldb.SBModule objects in the list
lldb.SBSymbolContextList.compile_units => list() or all lldb.SBCompileUnits objects in the list
lldb.SBSymbolContextList.functions => list() or all lldb.SBFunction objects in the list
lldb.SBSymbolContextList.blocks => list() or all lldb.SBBlock objects in the list
lldb.SBSymbolContextList.line_entries => list() or all lldb.SBLineEntry objects in the list
lldb.SBSymbolContextList.symbols => list() or all lldb.SBSymbol objects in the list
This allows a call to the SBTarget::FindFunctions(...) and SBModule::FindFunctions(...)
and then the result can be used to extract the desired information:
sc_list = lldb.target.FindFunctions("erase")
for function in sc_list.functions:
print function
for symbol in sc_list.symbols:
print symbol
Exposed properties for the lldb.SBSymbolContext objects in python:
lldb.SBSymbolContext.module => lldb.SBModule
lldb.SBSymbolContext.compile_unit => lldb.SBCompileUnit
lldb.SBSymbolContext.function => lldb.SBFunction
lldb.SBSymbolContext.block => lldb.SBBlock
lldb.SBSymbolContext.line_entry => lldb.SBLineEntry
lldb.SBSymbolContext.symbol => lldb.SBSymbol
Exposed properties for the lldb.SBBlock objects in python:
lldb.SBBlock.parent => lldb.SBBlock for the parent block that contains
lldb.SBBlock.sibling => lldb.SBBlock for the sibling block to the current block
lldb.SBBlock.first_child => lldb.SBBlock for the first child block to the current block
lldb.SBBlock.call_site => for inline functions, return a lldb.declaration object that gives the call site file, line and column
lldb.SBBlock.name => for inline functions this is the name of the inline function that this block represents
lldb.SBBlock.inlined_block => returns the inlined function block that contains this block (might return itself if the current block is an inlined block)
lldb.SBBlock.range[int] => access the address ranges for a block by index, a list() with start and end address is returned
lldb.SBBlock.ranges => an array or all address ranges for this block
lldb.SBBlock.num_ranges => the number of address ranges for this blcok
SBFunction objects can now get the SBType and the SBBlock that represents the
top scope of the function.
SBBlock objects can now get the variable list from the current block. The value
list returned allows varaibles to be viewed prior with no process if code
wants to check the variables in a function. There are two ways to get a variable
list from a SBBlock:
lldb::SBValueList
SBBlock::GetVariables (lldb::SBFrame& frame,
bool arguments,
bool locals,
bool statics,
lldb::DynamicValueType use_dynamic);
lldb::SBValueList
SBBlock::GetVariables (lldb::SBTarget& target,
bool arguments,
bool locals,
bool statics);
When a SBFrame is used, the values returned will be locked down to the frame
and the values will be evaluated in the context of that frame.
When a SBTarget is used, global an static variables can be viewed without a
running process.
llvm-svn: 149853
2012-02-06 09:44:54 +08:00
|
|
|
append,
|
|
|
|
*sb_sc_list);
|
2012-01-30 17:04:36 +08:00
|
|
|
}
|
2011-06-21 09:34:41 +08:00
|
|
|
}
|
Removed all of the "#ifndef SWIG" from the SB header files since we are using
interface (.i) files for each class.
Changed the FindFunction class from:
uint32_t
SBTarget::FindFunctions (const char *name,
uint32_t name_type_mask,
bool append,
lldb::SBSymbolContextList& sc_list)
uint32_t
SBModule::FindFunctions (const char *name,
uint32_t name_type_mask,
bool append,
lldb::SBSymbolContextList& sc_list)
To:
lldb::SBSymbolContextList
SBTarget::FindFunctions (const char *name,
uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
lldb::SBSymbolContextList
SBModule::FindFunctions (const char *name,
uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
This makes the API easier to use from python. Also added the ability to
append a SBSymbolContext or a SBSymbolContextList to a SBSymbolContextList.
Exposed properties for lldb.SBSymbolContextList in python:
lldb.SBSymbolContextList.modules => list() or all lldb.SBModule objects in the list
lldb.SBSymbolContextList.compile_units => list() or all lldb.SBCompileUnits objects in the list
lldb.SBSymbolContextList.functions => list() or all lldb.SBFunction objects in the list
lldb.SBSymbolContextList.blocks => list() or all lldb.SBBlock objects in the list
lldb.SBSymbolContextList.line_entries => list() or all lldb.SBLineEntry objects in the list
lldb.SBSymbolContextList.symbols => list() or all lldb.SBSymbol objects in the list
This allows a call to the SBTarget::FindFunctions(...) and SBModule::FindFunctions(...)
and then the result can be used to extract the desired information:
sc_list = lldb.target.FindFunctions("erase")
for function in sc_list.functions:
print function
for symbol in sc_list.symbols:
print symbol
Exposed properties for the lldb.SBSymbolContext objects in python:
lldb.SBSymbolContext.module => lldb.SBModule
lldb.SBSymbolContext.compile_unit => lldb.SBCompileUnit
lldb.SBSymbolContext.function => lldb.SBFunction
lldb.SBSymbolContext.block => lldb.SBBlock
lldb.SBSymbolContext.line_entry => lldb.SBLineEntry
lldb.SBSymbolContext.symbol => lldb.SBSymbol
Exposed properties for the lldb.SBBlock objects in python:
lldb.SBBlock.parent => lldb.SBBlock for the parent block that contains
lldb.SBBlock.sibling => lldb.SBBlock for the sibling block to the current block
lldb.SBBlock.first_child => lldb.SBBlock for the first child block to the current block
lldb.SBBlock.call_site => for inline functions, return a lldb.declaration object that gives the call site file, line and column
lldb.SBBlock.name => for inline functions this is the name of the inline function that this block represents
lldb.SBBlock.inlined_block => returns the inlined function block that contains this block (might return itself if the current block is an inlined block)
lldb.SBBlock.range[int] => access the address ranges for a block by index, a list() with start and end address is returned
lldb.SBBlock.ranges => an array or all address ranges for this block
lldb.SBBlock.num_ranges => the number of address ranges for this blcok
SBFunction objects can now get the SBType and the SBBlock that represents the
top scope of the function.
SBBlock objects can now get the variable list from the current block. The value
list returned allows varaibles to be viewed prior with no process if code
wants to check the variables in a function. There are two ways to get a variable
list from a SBBlock:
lldb::SBValueList
SBBlock::GetVariables (lldb::SBFrame& frame,
bool arguments,
bool locals,
bool statics,
lldb::DynamicValueType use_dynamic);
lldb::SBValueList
SBBlock::GetVariables (lldb::SBTarget& target,
bool arguments,
bool locals,
bool statics);
When a SBFrame is used, the values returned will be locked down to the frame
and the values will be evaluated in the context of that frame.
When a SBTarget is used, global an static variables can be viewed without a
running process.
llvm-svn: 149853
2012-02-06 09:44:54 +08:00
|
|
|
return sb_sc_list;
|
2011-06-21 09:34:41 +08:00
|
|
|
}
|
|
|
|
|
2014-09-20 03:38:19 +08:00
|
|
|
lldb::SBSymbolContextList
|
|
|
|
SBTarget::FindGlobalFunctions(const char *name, uint32_t max_matches, MatchType matchtype)
|
|
|
|
{
|
|
|
|
lldb::SBSymbolContextList sb_sc_list;
|
|
|
|
if (name && name[0])
|
|
|
|
{
|
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
|
|
|
{
|
|
|
|
std::string regexstr;
|
|
|
|
switch (matchtype)
|
|
|
|
{
|
|
|
|
case eMatchTypeRegex:
|
|
|
|
target_sp->GetImages().FindFunctions(RegularExpression(name), true, true, true, *sb_sc_list);
|
|
|
|
break;
|
|
|
|
case eMatchTypeStartsWith:
|
|
|
|
regexstr = llvm::Regex::escape(name) + ".*";
|
|
|
|
target_sp->GetImages().FindFunctions(RegularExpression(regexstr.c_str()), true, true, true, *sb_sc_list);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
target_sp->GetImages().FindFunctions(ConstString(name), eFunctionNameTypeAny, true, true, true, *sb_sc_list);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return sb_sc_list;
|
|
|
|
}
|
|
|
|
|
2011-07-30 03:53:35 +08:00
|
|
|
lldb::SBType
|
2012-12-06 05:24:42 +08:00
|
|
|
SBTarget::FindFirstType (const char* typename_cstr)
|
2011-07-30 03:53:35 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
2012-12-06 05:24:42 +08:00
|
|
|
if (typename_cstr && typename_cstr[0] && target_sp)
|
2011-07-30 03:53:35 +08:00
|
|
|
{
|
2012-12-06 05:24:42 +08:00
|
|
|
ConstString const_typename(typename_cstr);
|
|
|
|
SymbolContext sc;
|
|
|
|
const bool exact_match = false;
|
|
|
|
|
|
|
|
const ModuleList &module_list = target_sp->GetImages();
|
|
|
|
size_t count = module_list.GetSize();
|
2011-07-30 03:53:35 +08:00
|
|
|
for (size_t idx = 0; idx < count; idx++)
|
|
|
|
{
|
2012-12-06 05:24:42 +08:00
|
|
|
ModuleSP module_sp (module_list.GetModuleAtIndex(idx));
|
|
|
|
if (module_sp)
|
|
|
|
{
|
|
|
|
TypeSP type_sp (module_sp->FindFirstType(sc, const_typename, exact_match));
|
|
|
|
if (type_sp)
|
|
|
|
return SBType(type_sp);
|
|
|
|
}
|
2011-07-30 03:53:35 +08:00
|
|
|
}
|
2012-12-20 07:05:01 +08:00
|
|
|
|
|
|
|
// Didn't find the type in the symbols; try the Objective-C runtime
|
|
|
|
// if one is installed
|
|
|
|
|
|
|
|
ProcessSP process_sp(target_sp->GetProcessSP());
|
|
|
|
|
|
|
|
if (process_sp)
|
|
|
|
{
|
|
|
|
ObjCLanguageRuntime *objc_language_runtime = process_sp->GetObjCLanguageRuntime();
|
|
|
|
|
|
|
|
if (objc_language_runtime)
|
|
|
|
{
|
|
|
|
TypeVendor *objc_type_vendor = objc_language_runtime->GetTypeVendor();
|
|
|
|
|
|
|
|
if (objc_type_vendor)
|
|
|
|
{
|
|
|
|
std::vector <ClangASTType> types;
|
|
|
|
|
|
|
|
if (objc_type_vendor->FindTypes(const_typename, true, 1, types) > 0)
|
|
|
|
return SBType(types[0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-12-06 05:24:42 +08:00
|
|
|
|
|
|
|
// No matches, search for basic typename matches
|
|
|
|
ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext();
|
|
|
|
if (clang_ast)
|
2013-07-12 06:46:58 +08:00
|
|
|
return SBType (ClangASTContext::GetBasicType (clang_ast->getASTContext(), const_typename));
|
2012-12-06 05:24:42 +08:00
|
|
|
}
|
|
|
|
return SBType();
|
|
|
|
}
|
|
|
|
|
|
|
|
SBType
|
|
|
|
SBTarget::GetBasicType(lldb::BasicType type)
|
|
|
|
{
|
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
|
|
|
{
|
|
|
|
ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext();
|
|
|
|
if (clang_ast)
|
2013-07-12 06:46:58 +08:00
|
|
|
return SBType (ClangASTContext::GetBasicType (clang_ast->getASTContext(), type));
|
2011-07-30 03:53:35 +08:00
|
|
|
}
|
|
|
|
return SBType();
|
|
|
|
}
|
|
|
|
|
2012-12-06 05:24:42 +08:00
|
|
|
|
2011-07-30 03:53:35 +08:00
|
|
|
lldb::SBTypeList
|
2012-12-06 05:24:42 +08:00
|
|
|
SBTarget::FindTypes (const char* typename_cstr)
|
2011-07-30 03:53:35 +08:00
|
|
|
{
|
2012-12-06 05:24:42 +08:00
|
|
|
SBTypeList sb_type_list;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
2012-12-06 05:24:42 +08:00
|
|
|
if (typename_cstr && typename_cstr[0] && target_sp)
|
2011-07-30 03:53:35 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
ModuleList& images = target_sp->GetImages();
|
2012-12-06 05:24:42 +08:00
|
|
|
ConstString const_typename(typename_cstr);
|
2012-03-27 07:03:23 +08:00
|
|
|
bool exact_match = false;
|
2011-07-30 03:53:35 +08:00
|
|
|
SymbolContext sc;
|
|
|
|
TypeList type_list;
|
|
|
|
|
2012-04-07 01:41:13 +08:00
|
|
|
uint32_t num_matches = images.FindTypes (sc,
|
2012-12-06 05:24:42 +08:00
|
|
|
const_typename,
|
2012-03-27 07:03:23 +08:00
|
|
|
exact_match,
|
|
|
|
UINT32_MAX,
|
|
|
|
type_list);
|
2011-07-30 03:53:35 +08:00
|
|
|
|
2012-12-06 05:24:42 +08:00
|
|
|
if (num_matches > 0)
|
|
|
|
{
|
|
|
|
for (size_t idx = 0; idx < num_matches; idx++)
|
|
|
|
{
|
|
|
|
TypeSP type_sp (type_list.GetTypeAtIndex(idx));
|
|
|
|
if (type_sp)
|
|
|
|
sb_type_list.Append(SBType(type_sp));
|
|
|
|
}
|
|
|
|
}
|
2012-12-20 07:05:01 +08:00
|
|
|
|
|
|
|
// Try the Objective-C runtime if one is installed
|
|
|
|
|
|
|
|
ProcessSP process_sp(target_sp->GetProcessSP());
|
|
|
|
|
|
|
|
if (process_sp)
|
|
|
|
{
|
|
|
|
ObjCLanguageRuntime *objc_language_runtime = process_sp->GetObjCLanguageRuntime();
|
|
|
|
|
|
|
|
if (objc_language_runtime)
|
|
|
|
{
|
|
|
|
TypeVendor *objc_type_vendor = objc_language_runtime->GetTypeVendor();
|
|
|
|
|
|
|
|
if (objc_type_vendor)
|
|
|
|
{
|
|
|
|
std::vector <ClangASTType> types;
|
|
|
|
|
|
|
|
if (objc_type_vendor->FindTypes(const_typename, true, UINT32_MAX, types))
|
|
|
|
{
|
|
|
|
for (ClangASTType &type : types)
|
|
|
|
{
|
|
|
|
sb_type_list.Append(SBType(type));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sb_type_list.GetSize() == 0)
|
2011-07-30 03:53:35 +08:00
|
|
|
{
|
2012-12-06 05:24:42 +08:00
|
|
|
// No matches, search for basic typename matches
|
|
|
|
ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext();
|
|
|
|
if (clang_ast)
|
2013-07-12 06:46:58 +08:00
|
|
|
sb_type_list.Append (SBType (ClangASTContext::GetBasicType (clang_ast->getASTContext(), const_typename)));
|
2011-07-30 03:53:35 +08:00
|
|
|
}
|
|
|
|
}
|
2012-12-06 05:24:42 +08:00
|
|
|
return sb_type_list;
|
2011-07-30 03:53:35 +08:00
|
|
|
}
|
|
|
|
|
2011-06-30 06:09:02 +08:00
|
|
|
SBValueList
|
|
|
|
SBTarget::FindGlobalVariables (const char *name, uint32_t max_matches)
|
|
|
|
{
|
|
|
|
SBValueList sb_value_list;
|
|
|
|
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (name && target_sp)
|
2011-06-30 06:09:02 +08:00
|
|
|
{
|
|
|
|
VariableList variable_list;
|
|
|
|
const bool append = true;
|
2012-01-30 17:04:36 +08:00
|
|
|
const uint32_t match_count = target_sp->GetImages().FindGlobalVariables (ConstString (name),
|
|
|
|
append,
|
|
|
|
max_matches,
|
|
|
|
variable_list);
|
2011-06-30 06:09:02 +08:00
|
|
|
|
|
|
|
if (match_count > 0)
|
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get();
|
2011-06-30 06:09:02 +08:00
|
|
|
if (exe_scope == NULL)
|
2012-01-30 17:04:36 +08:00
|
|
|
exe_scope = target_sp.get();
|
2011-06-30 06:09:02 +08:00
|
|
|
for (uint32_t i=0; i<match_count; ++i)
|
|
|
|
{
|
|
|
|
lldb::ValueObjectSP valobj_sp (ValueObjectVariable::Create (exe_scope, variable_list.GetVariableAtIndex(i)));
|
|
|
|
if (valobj_sp)
|
2013-02-08 02:23:56 +08:00
|
|
|
sb_value_list.Append(SBValue(valobj_sp));
|
2011-06-30 06:09:02 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return sb_value_list;
|
|
|
|
}
|
|
|
|
|
2014-09-20 03:38:19 +08:00
|
|
|
SBValueList
|
|
|
|
SBTarget::FindGlobalVariables(const char *name, uint32_t max_matches, MatchType matchtype)
|
|
|
|
{
|
|
|
|
SBValueList sb_value_list;
|
|
|
|
|
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (name && target_sp)
|
|
|
|
{
|
|
|
|
VariableList variable_list;
|
|
|
|
const bool append = true;
|
|
|
|
|
|
|
|
std::string regexstr;
|
|
|
|
uint32_t match_count;
|
|
|
|
switch (matchtype)
|
|
|
|
{
|
|
|
|
case eMatchTypeNormal:
|
|
|
|
match_count = target_sp->GetImages().FindGlobalVariables(ConstString(name),
|
|
|
|
append,
|
|
|
|
max_matches,
|
|
|
|
variable_list);
|
|
|
|
break;
|
|
|
|
case eMatchTypeRegex:
|
|
|
|
match_count = target_sp->GetImages().FindGlobalVariables(RegularExpression(name),
|
|
|
|
append,
|
|
|
|
max_matches,
|
|
|
|
variable_list);
|
|
|
|
break;
|
|
|
|
case eMatchTypeStartsWith:
|
|
|
|
regexstr = llvm::Regex::escape(name) + ".*";
|
|
|
|
match_count = target_sp->GetImages().FindGlobalVariables(RegularExpression(regexstr.c_str()),
|
|
|
|
append,
|
|
|
|
max_matches,
|
|
|
|
variable_list);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (match_count > 0)
|
|
|
|
{
|
|
|
|
ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get();
|
|
|
|
if (exe_scope == NULL)
|
|
|
|
exe_scope = target_sp.get();
|
|
|
|
for (uint32_t i = 0; i<match_count; ++i)
|
|
|
|
{
|
|
|
|
lldb::ValueObjectSP valobj_sp(ValueObjectVariable::Create(exe_scope, variable_list.GetVariableAtIndex(i)));
|
|
|
|
if (valobj_sp)
|
|
|
|
sb_value_list.Append(SBValue(valobj_sp));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return sb_value_list;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-01-17 02:53:52 +08:00
|
|
|
lldb::SBValue
|
|
|
|
SBTarget::FindFirstGlobalVariable (const char* name)
|
|
|
|
{
|
|
|
|
SBValueList sb_value_list(FindGlobalVariables(name, 1));
|
|
|
|
if (sb_value_list.IsValid() && sb_value_list.GetSize() > 0)
|
|
|
|
return sb_value_list.GetValueAtIndex(0);
|
|
|
|
return SBValue();
|
|
|
|
}
|
|
|
|
|
2011-09-13 08:29:56 +08:00
|
|
|
SBSourceManager
|
|
|
|
SBTarget::GetSourceManager()
|
|
|
|
{
|
|
|
|
SBSourceManager source_manager (*this);
|
|
|
|
return source_manager;
|
|
|
|
}
|
2011-09-24 08:52:29 +08:00
|
|
|
|
2012-03-07 06:24:44 +08:00
|
|
|
lldb::SBInstructionList
|
|
|
|
SBTarget::ReadInstructions (lldb::SBAddress base_addr, uint32_t count)
|
2013-03-02 08:26:47 +08:00
|
|
|
{
|
|
|
|
return ReadInstructions (base_addr, count, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb::SBInstructionList
|
|
|
|
SBTarget::ReadInstructions (lldb::SBAddress base_addr, uint32_t count, const char *flavor_string)
|
2012-03-07 06:24:44 +08:00
|
|
|
{
|
|
|
|
SBInstructionList sb_instructions;
|
|
|
|
|
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
|
|
|
{
|
|
|
|
Address *addr_ptr = base_addr.get();
|
|
|
|
|
|
|
|
if (addr_ptr)
|
|
|
|
{
|
|
|
|
DataBufferHeap data (target_sp->GetArchitecture().GetMaximumOpcodeByteSize() * count, 0);
|
|
|
|
bool prefer_file_cache = false;
|
|
|
|
lldb_private::Error error;
|
2013-03-29 07:42:53 +08:00
|
|
|
lldb::addr_t load_addr = LLDB_INVALID_ADDRESS;
|
|
|
|
const size_t bytes_read = target_sp->ReadMemory(*addr_ptr,
|
|
|
|
prefer_file_cache,
|
|
|
|
data.GetBytes(),
|
|
|
|
data.GetByteSize(),
|
|
|
|
error,
|
|
|
|
&load_addr);
|
|
|
|
const bool data_from_file = load_addr == LLDB_INVALID_ADDRESS;
|
2012-03-07 06:24:44 +08:00
|
|
|
sb_instructions.SetDisassembler (Disassembler::DisassembleBytes (target_sp->GetArchitecture(),
|
|
|
|
NULL,
|
2013-03-02 08:26:47 +08:00
|
|
|
flavor_string,
|
2012-03-07 06:24:44 +08:00
|
|
|
*addr_ptr,
|
|
|
|
data.GetBytes(),
|
|
|
|
bytes_read,
|
2013-03-29 07:42:53 +08:00
|
|
|
count,
|
|
|
|
data_from_file));
|
2012-03-07 06:24:44 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return sb_instructions;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2011-12-15 07:49:37 +08:00
|
|
|
lldb::SBInstructionList
|
|
|
|
SBTarget::GetInstructions (lldb::SBAddress base_addr, const void *buf, size_t size)
|
2013-03-02 08:26:47 +08:00
|
|
|
{
|
|
|
|
return GetInstructionsWithFlavor (base_addr, NULL, buf, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb::SBInstructionList
|
|
|
|
SBTarget::GetInstructionsWithFlavor (lldb::SBAddress base_addr, const char *flavor_string, const void *buf, size_t size)
|
2011-12-15 07:49:37 +08:00
|
|
|
{
|
|
|
|
SBInstructionList sb_instructions;
|
|
|
|
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2011-12-15 07:49:37 +08:00
|
|
|
{
|
|
|
|
Address addr;
|
|
|
|
|
|
|
|
if (base_addr.get())
|
|
|
|
addr = *base_addr.get();
|
|
|
|
|
2013-03-29 07:42:53 +08:00
|
|
|
const bool data_from_file = true;
|
|
|
|
|
2012-01-30 17:04:36 +08:00
|
|
|
sb_instructions.SetDisassembler (Disassembler::DisassembleBytes (target_sp->GetArchitecture(),
|
2011-12-15 07:49:37 +08:00
|
|
|
NULL,
|
2013-03-02 08:26:47 +08:00
|
|
|
flavor_string,
|
2011-12-15 07:49:37 +08:00
|
|
|
addr,
|
|
|
|
buf,
|
2013-03-29 07:42:53 +08:00
|
|
|
size,
|
|
|
|
UINT32_MAX,
|
|
|
|
data_from_file));
|
2011-12-15 07:49:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return sb_instructions;
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb::SBInstructionList
|
|
|
|
SBTarget::GetInstructions (lldb::addr_t base_addr, const void *buf, size_t size)
|
|
|
|
{
|
2013-03-02 08:26:47 +08:00
|
|
|
return GetInstructionsWithFlavor (ResolveLoadAddress(base_addr), NULL, buf, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb::SBInstructionList
|
|
|
|
SBTarget::GetInstructionsWithFlavor (lldb::addr_t base_addr, const char *flavor_string, const void *buf, size_t size)
|
|
|
|
{
|
|
|
|
return GetInstructionsWithFlavor (ResolveLoadAddress(base_addr), flavor_string, buf, size);
|
2011-12-15 07:49:37 +08:00
|
|
|
}
|
2011-09-24 08:52:29 +08:00
|
|
|
|
|
|
|
SBError
|
|
|
|
SBTarget::SetSectionLoadAddress (lldb::SBSection section,
|
|
|
|
lldb::addr_t section_base_addr)
|
|
|
|
{
|
|
|
|
SBError sb_error;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2011-09-24 08:52:29 +08:00
|
|
|
{
|
|
|
|
if (!section.IsValid())
|
|
|
|
{
|
|
|
|
sb_error.SetErrorStringWithFormat ("invalid section");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-03-28 05:10:07 +08:00
|
|
|
SectionSP section_sp (section.GetSP());
|
|
|
|
if (section_sp)
|
|
|
|
{
|
|
|
|
if (section_sp->IsThreadSpecific())
|
|
|
|
{
|
|
|
|
sb_error.SetErrorString ("thread specific sections are not yet supported");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-12-06 09:12:00 +08:00
|
|
|
ProcessSP process_sp (target_sp->GetProcessSP());
|
|
|
|
if (target_sp->SetSectionLoadAddress (section_sp, section_base_addr))
|
2013-01-29 09:17:09 +08:00
|
|
|
{
|
|
|
|
// Flush info in the process (stack frames, etc)
|
|
|
|
if (process_sp)
|
|
|
|
process_sp->Flush();
|
|
|
|
}
|
2012-03-28 05:10:07 +08:00
|
|
|
}
|
|
|
|
}
|
2011-09-24 08:52:29 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-03-28 05:10:07 +08:00
|
|
|
sb_error.SetErrorString ("invalid target");
|
2011-09-24 08:52:29 +08:00
|
|
|
}
|
|
|
|
return sb_error;
|
|
|
|
}
|
|
|
|
|
|
|
|
SBError
|
|
|
|
SBTarget::ClearSectionLoadAddress (lldb::SBSection section)
|
|
|
|
{
|
|
|
|
SBError sb_error;
|
|
|
|
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2011-09-24 08:52:29 +08:00
|
|
|
{
|
|
|
|
if (!section.IsValid())
|
|
|
|
{
|
|
|
|
sb_error.SetErrorStringWithFormat ("invalid section");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-12-06 09:12:00 +08:00
|
|
|
ProcessSP process_sp (target_sp->GetProcessSP());
|
|
|
|
if (target_sp->SetSectionUnloaded (section.GetSP()))
|
2013-01-29 09:17:09 +08:00
|
|
|
{
|
|
|
|
// Flush info in the process (stack frames, etc)
|
|
|
|
if (process_sp)
|
|
|
|
process_sp->Flush();
|
|
|
|
}
|
2011-09-24 08:52:29 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sb_error.SetErrorStringWithFormat ("invalid target");
|
|
|
|
}
|
|
|
|
return sb_error;
|
|
|
|
}
|
|
|
|
|
|
|
|
SBError
|
|
|
|
SBTarget::SetModuleLoadAddress (lldb::SBModule module, int64_t slide_offset)
|
|
|
|
{
|
|
|
|
SBError sb_error;
|
|
|
|
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2011-09-24 08:52:29 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
ModuleSP module_sp (module.GetSP());
|
|
|
|
if (module_sp)
|
2011-09-24 08:52:29 +08:00
|
|
|
{
|
2012-03-28 05:10:07 +08:00
|
|
|
bool changed = false;
|
2014-02-08 06:54:47 +08:00
|
|
|
if (module_sp->SetLoadAddress (*target_sp, slide_offset, true, changed))
|
2011-09-24 08:52:29 +08:00
|
|
|
{
|
2012-03-28 05:10:07 +08:00
|
|
|
// The load was successful, make sure that at least some sections
|
|
|
|
// changed before we notify that our module was loaded.
|
|
|
|
if (changed)
|
2011-09-24 08:52:29 +08:00
|
|
|
{
|
2012-03-28 05:10:07 +08:00
|
|
|
ModuleList module_list;
|
|
|
|
module_list.Append(module_sp);
|
|
|
|
target_sp->ModulesDidLoad (module_list);
|
2013-01-29 09:17:09 +08:00
|
|
|
// Flush info in the process (stack frames, etc)
|
|
|
|
ProcessSP process_sp (target_sp->GetProcessSP());
|
|
|
|
if (process_sp)
|
|
|
|
process_sp->Flush();
|
2011-09-24 08:52:29 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-01-30 17:04:36 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
sb_error.SetErrorStringWithFormat ("invalid module");
|
|
|
|
}
|
|
|
|
|
2011-09-24 08:52:29 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sb_error.SetErrorStringWithFormat ("invalid target");
|
|
|
|
}
|
|
|
|
return sb_error;
|
|
|
|
}
|
|
|
|
|
|
|
|
SBError
|
|
|
|
SBTarget::ClearModuleLoadAddress (lldb::SBModule module)
|
|
|
|
{
|
|
|
|
SBError sb_error;
|
|
|
|
|
|
|
|
char path[PATH_MAX];
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2011-09-24 08:52:29 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
ModuleSP module_sp (module.GetSP());
|
|
|
|
if (module_sp)
|
2011-09-24 08:52:29 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
ObjectFile *objfile = module_sp->GetObjectFile();
|
2011-09-24 08:52:29 +08:00
|
|
|
if (objfile)
|
|
|
|
{
|
|
|
|
SectionList *section_list = objfile->GetSectionList();
|
|
|
|
if (section_list)
|
|
|
|
{
|
2013-12-06 09:12:00 +08:00
|
|
|
ProcessSP process_sp (target_sp->GetProcessSP());
|
|
|
|
|
2013-01-29 09:17:09 +08:00
|
|
|
bool changed = false;
|
2011-09-24 08:52:29 +08:00
|
|
|
const size_t num_sections = section_list->GetSize();
|
|
|
|
for (size_t sect_idx = 0; sect_idx < num_sections; ++sect_idx)
|
|
|
|
{
|
|
|
|
SectionSP section_sp (section_list->GetSectionAtIndex(sect_idx));
|
|
|
|
if (section_sp)
|
2014-07-17 04:28:24 +08:00
|
|
|
changed |= target_sp->SetSectionUnloaded (section_sp);
|
2013-01-29 09:17:09 +08:00
|
|
|
}
|
|
|
|
if (changed)
|
|
|
|
{
|
|
|
|
// Flush info in the process (stack frames, etc)
|
|
|
|
ProcessSP process_sp (target_sp->GetProcessSP());
|
|
|
|
if (process_sp)
|
|
|
|
process_sp->Flush();
|
2011-09-24 08:52:29 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
module_sp->GetFileSpec().GetPath (path, sizeof(path));
|
2011-09-24 08:52:29 +08:00
|
|
|
sb_error.SetErrorStringWithFormat ("no sections in object file '%s'", path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
module_sp->GetFileSpec().GetPath (path, sizeof(path));
|
2011-09-24 08:52:29 +08:00
|
|
|
sb_error.SetErrorStringWithFormat ("no object file for module '%s'", path);
|
|
|
|
}
|
|
|
|
}
|
2012-01-30 17:04:36 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
sb_error.SetErrorStringWithFormat ("invalid module");
|
|
|
|
}
|
2011-09-24 08:52:29 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sb_error.SetErrorStringWithFormat ("invalid target");
|
|
|
|
}
|
|
|
|
return sb_error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-12-04 10:22:16 +08:00
|
|
|
lldb::SBSymbolContextList
|
|
|
|
SBTarget::FindSymbols (const char *name, lldb::SymbolType symbol_type)
|
|
|
|
{
|
|
|
|
SBSymbolContextList sb_sc_list;
|
|
|
|
if (name && name[0])
|
|
|
|
{
|
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
|
|
|
{
|
|
|
|
bool append = true;
|
|
|
|
target_sp->GetImages().FindSymbolsWithNameAndType (ConstString(name),
|
|
|
|
symbol_type,
|
|
|
|
*sb_sc_list,
|
|
|
|
append);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return sb_sc_list;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-01-05 02:10:18 +08:00
|
|
|
lldb::SBValue
|
|
|
|
SBTarget::EvaluateExpression (const char *expr, const SBExpressionOptions &options)
|
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
|
|
|
Log * expr_log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
|
2013-01-05 02:10:18 +08:00
|
|
|
SBValue expr_result;
|
2014-05-05 10:47:44 +08:00
|
|
|
ExpressionResults exe_results = eExpressionSetupError;
|
2013-01-05 02:10:18 +08:00
|
|
|
ValueObjectSP expr_value_sp;
|
|
|
|
TargetSP target_sp(GetSP());
|
2013-11-04 17:33:30 +08:00
|
|
|
StackFrame *frame = NULL;
|
2013-01-05 02:10:18 +08:00
|
|
|
if (target_sp)
|
|
|
|
{
|
|
|
|
if (expr == NULL || expr[0] == '\0')
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf ("SBTarget::EvaluateExpression called with an empty expression");
|
|
|
|
return expr_result;
|
|
|
|
}
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2013-01-05 02:10:18 +08:00
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
|
|
|
ExecutionContext exe_ctx (m_opaque_sp.get());
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2013-01-05 02:10:18 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf ("SBTarget()::EvaluateExpression (expr=\"%s\")...", expr);
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2013-01-05 02:10:18 +08:00
|
|
|
frame = exe_ctx.GetFramePtr();
|
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2013-01-05 02:10:18 +08:00
|
|
|
if (target)
|
|
|
|
{
|
|
|
|
#ifdef LLDB_CONFIGURATION_DEBUG
|
|
|
|
StreamString frame_description;
|
|
|
|
if (frame)
|
|
|
|
frame->DumpUsingSettingsFormat (&frame_description);
|
|
|
|
Host::SetCrashDescriptionWithFormat ("SBTarget::EvaluateExpression (expr = \"%s\", fetch_dynamic_value = %u) %s",
|
|
|
|
expr, options.GetFetchDynamicValue(), frame_description.GetString().c_str());
|
|
|
|
#endif
|
|
|
|
exe_results = target->EvaluateExpression (expr,
|
|
|
|
frame,
|
|
|
|
expr_value_sp,
|
|
|
|
options.ref());
|
|
|
|
|
|
|
|
expr_result.SetSP(expr_value_sp, options.GetFetchDynamicValue());
|
|
|
|
#ifdef LLDB_CONFIGURATION_DEBUG
|
|
|
|
Host::SetCrashDescription (NULL);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf ("SBTarget::EvaluateExpression () => error: could not reconstruct frame object for this SBTarget.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#ifndef LLDB_DISABLE_PYTHON
|
|
|
|
if (expr_log)
|
|
|
|
expr_log->Printf("** [SBTarget::EvaluateExpression] Expression result is %s, summary %s **",
|
2014-04-04 12:06:10 +08:00
|
|
|
expr_result.GetValue(), expr_result.GetSummary());
|
|
|
|
|
2013-01-05 02:10:18 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf ("SBTarget(%p)::EvaluateExpression (expr=\"%s\") => SBValue(%p) (execution result=%d)",
|
2014-04-04 12:06:10 +08:00
|
|
|
static_cast<void*>(frame), expr,
|
|
|
|
static_cast<void*>(expr_value_sp.get()), exe_results);
|
2013-01-05 02:10:18 +08:00
|
|
|
#endif
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2013-01-05 02:10:18 +08:00
|
|
|
return expr_result;
|
|
|
|
}
|
|
|
|
|
2013-02-01 08:47:49 +08:00
|
|
|
|
|
|
|
lldb::addr_t
|
|
|
|
SBTarget::GetStackRedZoneSize()
|
|
|
|
{
|
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
|
|
|
{
|
|
|
|
ABISP abi_sp;
|
|
|
|
ProcessSP process_sp (target_sp->GetProcessSP());
|
|
|
|
if (process_sp)
|
|
|
|
abi_sp = process_sp->GetABI();
|
|
|
|
else
|
|
|
|
abi_sp = ABI::FindPlugin(target_sp->GetArchitecture());
|
|
|
|
if (abi_sp)
|
|
|
|
return abi_sp->GetRedZoneSize();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|