[llvm-branch-commits] [lldb] r179679 - Merge trunk rev 179594 back into the Windows branch.
Carlo Kok
ck at remobjects.com
Wed Apr 17 01:38:53 PDT 2013
Modified: lldb/branches/windows/source/API/SBTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/API/SBTarget.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/API/SBTarget.cpp (original)
+++ lldb/branches/windows/source/API/SBTarget.cpp Wed Apr 17 03:38:48 2013
@@ -536,7 +536,7 @@ SBTarget::GetProcess ()
sb_process.SetSP (process_sp);
}
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
{
log->Printf ("SBTarget(%p)::GetProcess () => SBProcess(%p)",
@@ -557,6 +557,26 @@ SBTarget::GetDebugger () const
}
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;
+}
+
+SBProcess
SBTarget::LaunchSimple
(
char const **argv,
@@ -598,7 +618,7 @@ SBTarget::Launch
lldb::SBError& error
)
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
SBProcess sb_process;
ProcessSP process_sp;
@@ -723,7 +743,7 @@ SBTarget::Launch
SBProcess
SBTarget::Launch (SBLaunchInfo &sb_launch_info, SBError& error)
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
SBProcess sb_process;
ProcessSP process_sp;
@@ -823,7 +843,7 @@ SBTarget::Launch (SBLaunchInfo &sb_launc
lldb::SBProcess
SBTarget::Attach (SBAttachInfo &sb_attach_info, SBError& error)
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
SBProcess sb_process;
ProcessSP process_sp;
@@ -865,13 +885,13 @@ SBTarget::Attach (SBAttachInfo &sb_attac
if (process_sp)
{
ProcessAttachInfo &attach_info = sb_attach_info.ref();
- lldb::pid_t attach_pid = attach_info.GetProcessID();
- if (attach_pid != LLDB_INVALID_PROCESS_ID)
+ if (attach_info.ProcessIDIsValid() && !attach_info.UserIDIsValid())
{
PlatformSP platform_sp = target_sp->GetPlatform();
// See if we can pre-verify if a process exists or not
if (platform_sp && platform_sp->IsConnected())
{
+ lldb::pid_t attach_pid = attach_info.GetProcessID();
ProcessInstanceInfo instance_info;
if (platform_sp->GetProcessInfo(attach_pid, instance_info))
{
@@ -939,7 +959,7 @@ SBTarget::AttachToProcessWithID
SBError& error // An error explaining what went wrong if attach fails
)
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
SBProcess sb_process;
ProcessSP process_sp;
@@ -1037,7 +1057,7 @@ SBTarget::AttachToProcessWithName
SBError& error // An error explaining what went wrong if attach fails
)
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
SBProcess sb_process;
ProcessSP process_sp;
@@ -1094,11 +1114,14 @@ SBTarget::AttachToProcessWithName
attach_info.GetExecutableFile().SetFile(name, false);
attach_info.SetWaitForLaunch(wait_for);
error.SetError (process_sp->Attach (attach_info));
+ 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);
}
+ }
else
{
error.SetErrorString ("unable to create lldb_private::Process");
@@ -1126,7 +1149,7 @@ SBTarget::ConnectRemote
SBError& error
)
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
SBProcess sb_process;
ProcessSP process_sp;
@@ -1182,7 +1205,7 @@ SBTarget::GetExecutable ()
exe_file_spec.SetFileSpec (exe_module->GetFileSpec());
}
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
{
log->Printf ("SBTarget(%p)::GetExecutable () => SBFileSpec(%p)",
@@ -1258,7 +1281,7 @@ SBTarget::BreakpointCreateByLocation (co
SBBreakpoint
SBTarget::BreakpointCreateByLocation (const SBFileSpec &sb_file_spec, uint32_t line)
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
SBBreakpoint sb_bp;
TargetSP target_sp(GetSP());
@@ -1292,7 +1315,7 @@ SBTarget::BreakpointCreateByLocation (co
SBBreakpoint
SBTarget::BreakpointCreateByName (const char *symbol_name, const char *module_name)
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
SBBreakpoint sb_bp;
TargetSP target_sp(GetSP());
@@ -1338,7 +1361,7 @@ SBTarget::BreakpointCreateByName (const
const SBFileSpecList &module_list,
const SBFileSpecList &comp_unit_list)
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
SBBreakpoint sb_bp;
TargetSP target_sp(GetSP());
@@ -1371,7 +1394,7 @@ SBTarget::BreakpointCreateByNames (const
const SBFileSpecList &module_list,
const SBFileSpecList &comp_unit_list)
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
SBBreakpoint sb_bp;
TargetSP target_sp(GetSP());
@@ -1414,7 +1437,7 @@ SBTarget::BreakpointCreateByNames (const
SBBreakpoint
SBTarget::BreakpointCreateByRegex (const char *symbol_name_regex, const char *module_name)
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
SBBreakpoint sb_bp;
TargetSP target_sp(GetSP());
@@ -1452,7 +1475,7 @@ SBTarget::BreakpointCreateByRegex (const
const SBFileSpecList &module_list,
const SBFileSpecList &comp_unit_list)
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
SBBreakpoint sb_bp;
TargetSP target_sp(GetSP());
@@ -1478,7 +1501,7 @@ SBTarget::BreakpointCreateByRegex (const
SBBreakpoint
SBTarget::BreakpointCreateByAddress (addr_t address)
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
SBBreakpoint sb_bp;
TargetSP target_sp(GetSP());
@@ -1499,7 +1522,7 @@ SBTarget::BreakpointCreateByAddress (add
lldb::SBBreakpoint
SBTarget::BreakpointCreateBySourceRegex (const char *source_regex, const lldb::SBFileSpec &source_file, const char *module_name)
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
SBBreakpoint sb_bp;
TargetSP target_sp(GetSP());
@@ -1539,7 +1562,7 @@ SBTarget::BreakpointCreateBySourceRegex
const SBFileSpecList &module_list,
const lldb::SBFileSpecList &source_file_list)
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
SBBreakpoint sb_bp;
TargetSP target_sp(GetSP());
@@ -1564,7 +1587,7 @@ SBTarget::BreakpointCreateForException
bool catch_bp,
bool throw_bp)
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
SBBreakpoint sb_bp;
TargetSP target_sp(GetSP());
@@ -1615,7 +1638,7 @@ SBTarget::GetBreakpointAtIndex (uint32_t
bool
SBTarget::BreakpointDelete (break_id_t bp_id)
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
bool result = false;
TargetSP target_sp(GetSP());
@@ -1636,7 +1659,7 @@ SBTarget::BreakpointDelete (break_id_t b
SBBreakpoint
SBTarget::FindBreakpointByID (break_id_t bp_id)
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
SBBreakpoint sb_breakpoint;
TargetSP target_sp(GetSP());
@@ -1722,7 +1745,7 @@ SBTarget::GetWatchpointAtIndex (uint32_t
bool
SBTarget::DeleteWatchpoint (watch_id_t wp_id)
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
bool result = false;
TargetSP target_sp(GetSP());
@@ -1745,7 +1768,7 @@ SBTarget::DeleteWatchpoint (watch_id_t w
SBWatchpoint
SBTarget::FindWatchpointByID (lldb::watch_id_t wp_id)
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
SBWatchpoint sb_watchpoint;
lldb::WatchpointSP watchpoint_sp;
@@ -1771,7 +1794,7 @@ SBTarget::FindWatchpointByID (lldb::watc
lldb::SBWatchpoint
SBTarget::WatchAddress (lldb::addr_t addr, size_t size, bool read, bool write, SBError &error)
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
SBWatchpoint sb_watchpoint;
lldb::WatchpointSP watchpoint_sp;
@@ -1899,7 +1922,7 @@ SBTarget::AddModule (lldb::SBModule &mod
uint32_t
SBTarget::GetNumModules () const
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
uint32_t num = 0;
TargetSP target_sp(GetSP());
@@ -1918,7 +1941,7 @@ SBTarget::GetNumModules () const
void
SBTarget::Clear ()
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBTarget(%p)::Clear ()", m_opaque_sp.get());
@@ -1979,7 +2002,7 @@ SBTarget::GetAddressByteSize()
SBModule
SBTarget::GetModuleAtIndex (uint32_t idx)
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
SBModule sb_module;
ModuleSP module_sp;
@@ -2013,7 +2036,7 @@ SBTarget::RemoveModule (lldb::SBModule m
SBBroadcaster
SBTarget::GetBroadcaster () const
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
TargetSP target_sp(GetSP());
SBBroadcaster broadcaster(target_sp.get(), false);
@@ -2219,12 +2242,11 @@ SBTarget::FindGlobalVariables (const cha
ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get();
if (exe_scope == NULL)
exe_scope = target_sp.get();
- ValueObjectList &value_object_list = sb_value_list.ref();
for (uint32_t i=0; i<match_count; ++i)
{
lldb::ValueObjectSP valobj_sp (ValueObjectVariable::Create (exe_scope, variable_list.GetVariableAtIndex(i)));
if (valobj_sp)
- value_object_list.Append(valobj_sp);
+ sb_value_list.Append(SBValue(valobj_sp));
}
}
}
@@ -2232,6 +2254,15 @@ SBTarget::FindGlobalVariables (const cha
return sb_value_list;
}
+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();
+}
+
SBSourceManager
SBTarget::GetSourceManager()
{
@@ -2242,6 +2273,12 @@ SBTarget::GetSourceManager()
lldb::SBInstructionList
SBTarget::ReadInstructions (lldb::SBAddress base_addr, uint32_t count)
{
+ return ReadInstructions (base_addr, count, NULL);
+}
+
+lldb::SBInstructionList
+SBTarget::ReadInstructions (lldb::SBAddress base_addr, uint32_t count, const char *flavor_string)
+{
SBInstructionList sb_instructions;
TargetSP target_sp(GetSP());
@@ -2254,13 +2291,22 @@ SBTarget::ReadInstructions (lldb::SBAddr
DataBufferHeap data (target_sp->GetArchitecture().GetMaximumOpcodeByteSize() * count, 0);
bool prefer_file_cache = false;
lldb_private::Error error;
- const size_t bytes_read = target_sp->ReadMemory(*addr_ptr, prefer_file_cache, data.GetBytes(), data.GetByteSize(), error);
+ 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;
sb_instructions.SetDisassembler (Disassembler::DisassembleBytes (target_sp->GetArchitecture(),
NULL,
+ flavor_string,
*addr_ptr,
data.GetBytes(),
bytes_read,
- count));
+ count,
+ data_from_file));
}
}
@@ -2271,6 +2317,12 @@ SBTarget::ReadInstructions (lldb::SBAddr
lldb::SBInstructionList
SBTarget::GetInstructions (lldb::SBAddress base_addr, const void *buf, size_t size)
{
+ 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)
+{
SBInstructionList sb_instructions;
TargetSP target_sp(GetSP());
@@ -2281,11 +2333,16 @@ SBTarget::GetInstructions (lldb::SBAddre
if (base_addr.get())
addr = *base_addr.get();
+ const bool data_from_file = true;
+
sb_instructions.SetDisassembler (Disassembler::DisassembleBytes (target_sp->GetArchitecture(),
NULL,
+ flavor_string,
addr,
buf,
- size));
+ size,
+ UINT32_MAX,
+ data_from_file));
}
return sb_instructions;
@@ -2294,7 +2351,13 @@ SBTarget::GetInstructions (lldb::SBAddre
lldb::SBInstructionList
SBTarget::GetInstructions (lldb::addr_t base_addr, const void *buf, size_t size)
{
- return GetInstructions (ResolveLoadAddress(base_addr), buf, size);
+ 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);
}
SBError
@@ -2320,11 +2383,17 @@ SBTarget::SetSectionLoadAddress (lldb::S
}
else
{
- target_sp->GetSectionLoadList().SetSectionLoadAddress (section_sp, section_base_addr);
+ if (target_sp->GetSectionLoadList().SetSectionLoadAddress (section_sp, section_base_addr))
+ {
+ // Flush info in the process (stack frames, etc)
+ ProcessSP process_sp (target_sp->GetProcessSP());
+ if (process_sp)
+ process_sp->Flush();
}
}
}
}
+ }
else
{
sb_error.SetErrorString ("invalid target");
@@ -2346,9 +2415,15 @@ SBTarget::ClearSectionLoadAddress (lldb:
}
else
{
- target_sp->GetSectionLoadList().SetSectionUnloaded (section.GetSP());
+ if (target_sp->GetSectionLoadList().SetSectionUnloaded (section.GetSP()))
+ {
+ // Flush info in the process (stack frames, etc)
+ ProcessSP process_sp (target_sp->GetProcessSP());
+ if (process_sp)
+ process_sp->Flush();
}
}
+ }
else
{
sb_error.SetErrorStringWithFormat ("invalid target");
@@ -2377,6 +2452,10 @@ SBTarget::SetModuleLoadAddress (lldb::SB
ModuleList module_list;
module_list.Append(module_sp);
target_sp->ModulesDidLoad (module_list);
+ // Flush info in the process (stack frames, etc)
+ ProcessSP process_sp (target_sp->GetProcessSP());
+ if (process_sp)
+ process_sp->Flush();
}
}
}
@@ -2411,13 +2490,21 @@ SBTarget::ClearModuleLoadAddress (lldb::
SectionList *section_list = objfile->GetSectionList();
if (section_list)
{
+ bool changed = false;
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)
- target_sp->GetSectionLoadList().SetSectionUnloaded (section_sp);
+ changed |= target_sp->GetSectionLoadList().SetSectionUnloaded (section_sp) > 0;
}
+ if (changed)
+ {
+ // Flush info in the process (stack frames, etc)
+ ProcessSP process_sp (target_sp->GetProcessSP());
+ if (process_sp)
+ process_sp->Flush();
+ }
}
else
{
@@ -2468,8 +2555,8 @@ SBTarget::FindSymbols (const char *name,
lldb::SBValue
SBTarget::EvaluateExpression (const char *expr, const SBExpressionOptions &options)
{
- LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- LogSP expr_log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+ Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log * expr_log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
SBValue expr_result;
ExecutionResults exe_results = eExecutionSetupError;
ValueObjectSP expr_value_sp;
@@ -2535,3 +2622,22 @@ SBTarget::EvaluateExpression (const char
return expr_result;
}
+
+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;
+}
+
Modified: lldb/branches/windows/source/API/SBThread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/API/SBThread.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/API/SBThread.cpp (original)
+++ lldb/branches/windows/source/API/SBThread.cpp Wed Apr 17 03:38:48 2013
@@ -16,6 +16,7 @@
#include "lldb/API/SBStream.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/Debugger.h"
+#include "lldb/Core/State.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Interpreter/CommandInterpreter.h"
@@ -102,7 +103,7 @@ SBThread::Clear ()
StopReason
SBThread::GetStopReason()
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
StopReason reason = eStopReasonInvalid;
Mutex::Locker api_locker;
@@ -179,7 +180,7 @@ SBThread::GetStopReasonDataCount ()
}
else
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBThread(%p)::GetStopReasonDataCount() => error: process is running", exe_ctx.GetThreadPtr());
}
@@ -253,7 +254,7 @@ SBThread::GetStopReasonDataAtIndex (uint
}
else
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBThread(%p)::GetStopReasonDataAtIndex() => error: process is running", exe_ctx.GetThreadPtr());
}
@@ -264,7 +265,7 @@ SBThread::GetStopReasonDataAtIndex (uint
size_t
SBThread::GetStopDescription (char *dst, size_t dst_len)
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
@@ -380,7 +381,7 @@ SBThread::GetStopDescription (char *dst,
}
else
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBThread(%p)::GetStopDescription() => error: process is running", exe_ctx.GetThreadPtr());
}
@@ -393,7 +394,7 @@ SBThread::GetStopDescription (char *dst,
SBValue
SBThread::GetStopReturnValue ()
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
ValueObjectSP return_valobj_sp;
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
@@ -453,7 +454,7 @@ SBThread::GetIndexID () const
const char *
SBThread::GetName () const
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
const char *name = NULL;
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
@@ -485,7 +486,7 @@ SBThread::GetQueueName () const
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (exe_ctx.HasThreadScope())
{
Process::StopLocker stop_locker;
@@ -551,7 +552,7 @@ SBThread::ResumeNewPlan (ExecutionContex
void
SBThread::StepOver (lldb::RunMode stop_other_threads)
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
@@ -600,7 +601,7 @@ SBThread::StepInto (lldb::RunMode stop_o
void
SBThread::StepInto (const char *target_name, lldb::RunMode stop_other_threads)
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
@@ -645,7 +646,7 @@ SBThread::StepInto (const char *target_n
void
SBThread::StepOut ()
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
@@ -677,7 +678,7 @@ SBThread::StepOut ()
void
SBThread::StepOutOfFrame (lldb::SBFrame &sb_frame)
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
@@ -712,7 +713,7 @@ SBThread::StepOutOfFrame (lldb::SBFrame
void
SBThread::StepInstruction (bool step_over)
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
@@ -735,7 +736,7 @@ SBThread::StepInstruction (bool step_ove
void
SBThread::RunToAddress (lldb::addr_t addr)
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
@@ -766,7 +767,7 @@ SBThread::StepOverUntil (lldb::SBFrame &
uint32_t line)
{
SBError sb_error;
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
char path[PATH_MAX];
Mutex::Locker api_locker;
@@ -913,7 +914,7 @@ SBThread::ReturnFromFrame (SBFrame &fram
{
SBError sb_error;
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
@@ -935,7 +936,7 @@ SBThread::ReturnFromFrame (SBFrame &fram
bool
SBThread::Suspend()
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
ExecutionContext exe_ctx (m_opaque_sp.get());
bool result = false;
if (exe_ctx.HasThreadScope())
@@ -960,7 +961,7 @@ SBThread::Suspend()
bool
SBThread::Resume ()
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
ExecutionContext exe_ctx (m_opaque_sp.get());
bool result = false;
if (exe_ctx.HasThreadScope())
@@ -991,12 +992,19 @@ SBThread::IsSuspended()
return false;
}
+bool
+SBThread::IsStopped()
+{
+ ExecutionContext exe_ctx (m_opaque_sp.get());
+ if (exe_ctx.HasThreadScope())
+ return StateIsStoppedState(exe_ctx.GetThreadPtr()->GetState(), true);
+ return false;
+}
+
SBProcess
SBThread::GetProcess ()
{
-
SBProcess sb_process;
- ProcessSP process_sp;
ExecutionContext exe_ctx (m_opaque_sp.get());
if (exe_ctx.HasThreadScope())
{
@@ -1004,13 +1012,13 @@ SBThread::GetProcess ()
sb_process.SetSP (exe_ctx.GetProcessSP());
}
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
{
SBStream frame_desc_strm;
sb_process.GetDescription (frame_desc_strm);
log->Printf ("SBThread(%p)::GetProcess () => SBProcess(%p): %s", exe_ctx.GetThreadPtr(),
- process_sp.get(), frame_desc_strm.GetData());
+ sb_process.GetSP().get(), frame_desc_strm.GetData());
}
return sb_process;
@@ -1019,7 +1027,7 @@ SBThread::GetProcess ()
uint32_t
SBThread::GetNumFrames ()
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
uint32_t num_frames = 0;
Mutex::Locker api_locker;
@@ -1048,7 +1056,7 @@ SBThread::GetNumFrames ()
SBFrame
SBThread::GetFrameAtIndex (uint32_t idx)
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
SBFrame sb_frame;
StackFrameSP frame_sp;
@@ -1084,7 +1092,7 @@ SBThread::GetFrameAtIndex (uint32_t idx)
lldb::SBFrame
SBThread::GetSelectedFrame ()
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
SBFrame sb_frame;
StackFrameSP frame_sp;
@@ -1120,7 +1128,7 @@ SBThread::GetSelectedFrame ()
lldb::SBFrame
SBThread::SetSelectedFrame (uint32_t idx)
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
SBFrame sb_frame;
StackFrameSP frame_sp;
Modified: lldb/branches/windows/source/API/SBType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/API/SBType.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/API/SBType.cpp (original)
+++ lldb/branches/windows/source/API/SBType.cpp Wed Apr 17 03:38:48 2013
@@ -136,7 +136,7 @@ SBType::IsValid() const
return m_opaque_sp->IsValid();
}
-size_t
+uint64_t
SBType::GetByteSize()
{
if (!IsValid())
@@ -534,7 +534,7 @@ SBTypeList::~SBTypeList()
bool
SBType::IsPointerType (void *opaque_type)
{
- LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
bool ret_value = ClangASTContext::IsPointerType (opaque_type);
Modified: lldb/branches/windows/source/API/SBTypeCategory.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/API/SBTypeCategory.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/API/SBTypeCategory.cpp (original)
+++ lldb/branches/windows/source/API/SBTypeCategory.cpp Wed Apr 17 03:38:48 2013
@@ -18,8 +18,8 @@
#include "lldb/API/SBTypeNameSpecifier.h"
#include "lldb/API/SBStream.h"
-#include "lldb/Core/DataVisualization.h"
#include "lldb/Core/Debugger.h"
+#include "lldb/DataFormatters/DataVisualization.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/ScriptInterpreter.h"
@@ -233,7 +233,7 @@ SBTypeCategory::GetSyntheticForType (SBT
if (!children_sp)
return lldb::SBTypeSynthetic();
- TypeSyntheticImplSP synth_sp = STD_STATIC_POINTER_CAST(TypeSyntheticImpl,children_sp);
+ ScriptedSyntheticChildrenSP synth_sp = STD_STATIC_POINTER_CAST(ScriptedSyntheticChildren,children_sp);
return lldb::SBTypeSynthetic(synth_sp);
}
@@ -285,7 +285,7 @@ SBTypeCategory::GetSyntheticAtIndex (uin
if (!children_sp.get())
return lldb::SBTypeSynthetic();
- TypeSyntheticImplSP synth_sp = STD_STATIC_POINTER_CAST(TypeSyntheticImpl,children_sp);
+ ScriptedSyntheticChildrenSP synth_sp = STD_STATIC_POINTER_CAST(ScriptedSyntheticChildren,children_sp);
return lldb::SBTypeSynthetic(synth_sp);
}
Modified: lldb/branches/windows/source/API/SBTypeFilter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/API/SBTypeFilter.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/API/SBTypeFilter.cpp (original)
+++ lldb/branches/windows/source/API/SBTypeFilter.cpp Wed Apr 17 03:38:48 2013
@@ -13,7 +13,7 @@
#include "lldb/API/SBStream.h"
-#include "lldb/Core/DataVisualization.h"
+#include "lldb/DataFormatters/DataVisualization.h"
using namespace lldb;
using namespace lldb_private;
Modified: lldb/branches/windows/source/API/SBTypeFormat.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/API/SBTypeFormat.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/API/SBTypeFormat.cpp (original)
+++ lldb/branches/windows/source/API/SBTypeFormat.cpp Wed Apr 17 03:38:48 2013
@@ -13,7 +13,7 @@
#include "lldb/API/SBStream.h"
-#include "lldb/Core/DataVisualization.h"
+#include "lldb/DataFormatters/DataVisualization.h"
using namespace lldb;
using namespace lldb_private;
Modified: lldb/branches/windows/source/API/SBTypeNameSpecifier.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/API/SBTypeNameSpecifier.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/API/SBTypeNameSpecifier.cpp (original)
+++ lldb/branches/windows/source/API/SBTypeNameSpecifier.cpp Wed Apr 17 03:38:48 2013
@@ -14,7 +14,7 @@
#include "lldb/API/SBStream.h"
#include "lldb/API/SBType.h"
-#include "lldb/Core/DataVisualization.h"
+#include "lldb/DataFormatters/DataVisualization.h"
using namespace lldb;
using namespace lldb_private;
Modified: lldb/branches/windows/source/API/SBTypeSummary.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/API/SBTypeSummary.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/API/SBTypeSummary.cpp (original)
+++ lldb/branches/windows/source/API/SBTypeSummary.cpp Wed Apr 17 03:38:48 2013
@@ -13,7 +13,7 @@
#include "lldb/API/SBStream.h"
-#include "lldb/Core/DataVisualization.h"
+#include "lldb/DataFormatters/DataVisualization.h"
using namespace lldb;
using namespace lldb_private;
Modified: lldb/branches/windows/source/API/SBTypeSynthetic.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/API/SBTypeSynthetic.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/API/SBTypeSynthetic.cpp (original)
+++ lldb/branches/windows/source/API/SBTypeSynthetic.cpp Wed Apr 17 03:38:48 2013
@@ -13,7 +13,7 @@
#include "lldb/API/SBStream.h"
-#include "lldb/Core/DataVisualization.h"
+#include "lldb/DataFormatters/DataVisualization.h"
using namespace lldb;
using namespace lldb_private;
@@ -30,7 +30,7 @@ SBTypeSynthetic::CreateWithClassName (co
{
if (!data || data[0] == 0)
return SBTypeSynthetic();
- return SBTypeSynthetic(TypeSyntheticImplSP(new TypeSyntheticImpl(options, data, "")));
+ return SBTypeSynthetic(ScriptedSyntheticChildrenSP(new ScriptedSyntheticChildren(options, data, "")));
}
SBTypeSynthetic
@@ -38,7 +38,7 @@ SBTypeSynthetic::CreateWithScriptCode (c
{
if (!data || data[0] == 0)
return SBTypeSynthetic();
- return SBTypeSynthetic(TypeSyntheticImplSP(new TypeSyntheticImpl(options, "", data)));
+ return SBTypeSynthetic(ScriptedSyntheticChildrenSP(new ScriptedSyntheticChildren(options, "", data)));
}
SBTypeSynthetic::SBTypeSynthetic (const lldb::SBTypeSynthetic &rhs) :
@@ -172,19 +172,19 @@ SBTypeSynthetic::operator != (lldb::SBTy
return m_opaque_sp != rhs.m_opaque_sp;
}
-lldb::TypeSyntheticImplSP
+lldb::ScriptedSyntheticChildrenSP
SBTypeSynthetic::GetSP ()
{
return m_opaque_sp;
}
void
-SBTypeSynthetic::SetSP (const lldb::TypeSyntheticImplSP &TypeSynthetic_impl_sp)
+SBTypeSynthetic::SetSP (const lldb::ScriptedSyntheticChildrenSP &TypeSynthetic_impl_sp)
{
m_opaque_sp = TypeSynthetic_impl_sp;
}
-SBTypeSynthetic::SBTypeSynthetic (const lldb::TypeSyntheticImplSP &TypeSynthetic_impl_sp) :
+SBTypeSynthetic::SBTypeSynthetic (const lldb::ScriptedSyntheticChildrenSP &TypeSynthetic_impl_sp) :
m_opaque_sp(TypeSynthetic_impl_sp)
{
}
@@ -197,7 +197,7 @@ SBTypeSynthetic::CopyOnWrite_Impl()
if (m_opaque_sp.unique())
return true;
- TypeSyntheticImplSP new_sp(new TypeSyntheticImpl(m_opaque_sp->GetOptions(),
+ ScriptedSyntheticChildrenSP new_sp(new ScriptedSyntheticChildren(m_opaque_sp->GetOptions(),
m_opaque_sp->GetPythonClassName(),
m_opaque_sp->GetPythonCode()));
Modified: lldb/branches/windows/source/API/SBValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/API/SBValue.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/API/SBValue.cpp (original)
+++ lldb/branches/windows/source/API/SBValue.cpp Wed Apr 17 03:38:48 2013
@@ -20,7 +20,6 @@
#include "lldb/Breakpoint/Watchpoint.h"
#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/DataVisualization.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/Scalar.h"
@@ -30,6 +29,7 @@
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
+#include "lldb/DataFormatters/DataVisualization.h"
#include "lldb/Symbol/Block.h"
#include "lldb/Symbol/Declaration.h"
#include "lldb/Symbol/ObjectFile.h"
@@ -106,6 +106,12 @@ namespace {
if (!m_opaque_sp)
return m_opaque_sp;
lldb::ValueObjectSP value_sp = m_opaque_sp;
+
+ Mutex::Locker api_lock;
+ Target *target = value_sp->GetTargetSP().get();
+ if (target)
+ api_lock.Lock(target->GetAPIMutex());
+
if (value_sp->GetDynamicValue(m_use_dynamic))
value_sp = value_sp->GetDynamicValue(m_use_dynamic);
if (value_sp->GetSyntheticValue(m_use_synthetic))
@@ -220,7 +226,7 @@ SBValue::GetName()
if (value_sp)
name = value_sp->GetName().GetCString();
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
{
if (name)
@@ -235,7 +241,7 @@ SBValue::GetName()
const char *
SBValue::GetTypeName ()
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
const char *name = NULL;
lldb::ValueObjectSP value_sp(GetSP());
if (value_sp)
@@ -275,7 +281,7 @@ SBValue::GetTypeName ()
size_t
SBValue::GetByteSize ()
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
size_t result = 0;
lldb::ValueObjectSP value_sp(GetSP());
@@ -324,7 +330,7 @@ SBValue::IsInScope ()
}
}
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBValue(%p)::IsInScope () => %i", value_sp.get(), result);
@@ -334,7 +340,7 @@ SBValue::IsInScope ()
const char *
SBValue::GetValue ()
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
const char *cstr = NULL;
lldb::ValueObjectSP value_sp(GetSP());
@@ -375,7 +381,7 @@ SBValue::GetValueType ()
lldb::ValueObjectSP value_sp(GetSP());
if (value_sp)
result = value_sp->GetValueType();
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
{
switch (result)
@@ -396,7 +402,7 @@ SBValue::GetValueType ()
const char *
SBValue::GetObjectDescription ()
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
const char *cstr = NULL;
lldb::ValueObjectSP value_sp(GetSP());
if (value_sp)
@@ -431,7 +437,7 @@ SBValue::GetObjectDescription ()
SBType
SBValue::GetType()
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
SBType sb_type;
lldb::ValueObjectSP value_sp(GetSP());
TypeImplSP type_sp;
@@ -468,7 +474,7 @@ SBValue::GetType()
bool
SBValue::GetValueDidChange ()
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
bool result = false;
lldb::ValueObjectSP value_sp(GetSP());
if (value_sp)
@@ -500,7 +506,7 @@ SBValue::GetValueDidChange ()
const char *
SBValue::GetSummary ()
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
const char *cstr = NULL;
lldb::ValueObjectSP value_sp(GetSP());
if (value_sp)
@@ -536,7 +542,7 @@ SBValue::GetSummary ()
const char *
SBValue::GetLocation ()
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
const char *cstr = NULL;
lldb::ValueObjectSP value_sp(GetSP());
if (value_sp)
@@ -581,7 +587,7 @@ SBValue::SetValueFromCString (const char
{
bool success = false;
lldb::ValueObjectSP value_sp(GetSP());
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (value_sp)
{
ProcessSP process_sp(value_sp->GetProcessSP());
@@ -618,7 +624,7 @@ SBValue::GetTypeFormat ()
Process::StopLocker stop_locker;
if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock()))
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBValue(%p)::GetTypeFormat() => error: process is running", value_sp.get());
}
@@ -652,7 +658,7 @@ SBValue::GetTypeSummary ()
Process::StopLocker stop_locker;
if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock()))
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBValue(%p)::GetTypeSummary() => error: process is running", value_sp.get());
}
@@ -686,7 +692,7 @@ SBValue::GetTypeFilter ()
Process::StopLocker stop_locker;
if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock()))
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBValue(%p)::GetTypeFilter() => error: process is running", value_sp.get());
}
@@ -724,7 +730,7 @@ SBValue::GetTypeSynthetic ()
Process::StopLocker stop_locker;
if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock()))
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBValue(%p)::GetTypeSynthetic() => error: process is running", value_sp.get());
}
@@ -740,7 +746,7 @@ SBValue::GetTypeSynthetic ()
if (children_sp && children_sp->IsScripted())
{
- TypeSyntheticImplSP synth_sp = STD_STATIC_POINTER_CAST(TypeSyntheticImpl,children_sp);
+ ScriptedSyntheticChildrenSP synth_sp = STD_STATIC_POINTER_CAST(ScriptedSyntheticChildren,children_sp);
synthetic.SetSP(synth_sp);
}
}
@@ -763,7 +769,7 @@ SBValue::CreateChildAtOffset (const char
Process::StopLocker stop_locker;
if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock()))
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBValue(%p)::CreateChildAtOffset() => error: process is running", value_sp.get());
}
@@ -784,7 +790,7 @@ SBValue::CreateChildAtOffset (const char
}
}
}
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
{
if (new_value_sp)
@@ -820,7 +826,7 @@ SBValue::CreateValueFromExpression (cons
lldb::SBValue
SBValue::CreateValueFromExpression (const char *name, const char *expression, SBExpressionOptions &options)
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
lldb::SBValue sb_value;
lldb::ValueObjectSP value_sp(GetSP());
lldb::ValueObjectSP new_value_sp;
@@ -905,7 +911,7 @@ SBValue::CreateValueFromAddress(const ch
sb_value.SetSP(new_value_sp);
}
}
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
{
if (new_value_sp)
@@ -935,7 +941,7 @@ SBValue::CreateValueFromData (const char
new_value_sp->SetAddressTypeOfChildren(eAddressTypeLoad);
sb_value.SetSP(new_value_sp);
}
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
{
if (new_value_sp)
@@ -965,7 +971,7 @@ SBValue
SBValue::GetChildAtIndex (uint32_t idx, lldb::DynamicValueType use_dynamic, bool can_create_synthetic)
{
lldb::ValueObjectSP child_sp;
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
lldb::ValueObjectSP value_sp(GetSP());
if (value_sp)
@@ -1024,7 +1030,7 @@ SBValue::GetIndexOfChildWithName (const
idx = value_sp->GetIndexOfChildWithName (ConstString(name));
}
}
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
{
if (idx == UINT32_MAX)
@@ -1059,7 +1065,7 @@ SBValue::GetChildMemberWithName (const c
lldb::ValueObjectSP child_sp;
const ConstString str_name (name);
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
lldb::ValueObjectSP value_sp(GetSP());
if (value_sp)
@@ -1192,7 +1198,7 @@ SBValue::IsSynthetic ()
lldb::SBValue
SBValue::GetValueForExpressionPath(const char* expr_path)
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
lldb::ValueObjectSP child_sp;
lldb::ValueObjectSP value_sp(GetSP());
if (value_sp)
@@ -1236,7 +1242,7 @@ SBValue::GetValueAsSigned(SBError& error
Process::StopLocker stop_locker;
if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock()))
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBValue(%p)::GetValueAsSigned() => error: process is running", value_sp.get());
error.SetErrorString("process is running");
@@ -1272,7 +1278,7 @@ SBValue::GetValueAsUnsigned(SBError& err
Process::StopLocker stop_locker;
if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock()))
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBValue(%p)::GetValueAsUnsigned() => error: process is running", value_sp.get());
error.SetErrorString("process is running");
@@ -1307,7 +1313,7 @@ SBValue::GetValueAsSigned(int64_t fail_v
Process::StopLocker stop_locker;
if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock()))
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBValue(%p)::GetValueAsSigned() => error: process is running", value_sp.get());
}
@@ -1336,7 +1342,7 @@ SBValue::GetValueAsUnsigned(uint64_t fai
Process::StopLocker stop_locker;
if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock()))
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBValue(%p)::GetValueAsUnsigned() => error: process is running", value_sp.get());
}
@@ -1358,14 +1364,14 @@ SBValue::GetValueAsUnsigned(uint64_t fai
bool
SBValue::MightHaveChildren ()
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
bool has_children = false;
lldb::ValueObjectSP value_sp(GetSP());
if (value_sp)
has_children = value_sp->MightHaveChildren();
if (log)
- log->Printf ("SBValue(%p)::HasChildren() => %i", value_sp.get(), has_children);
+ log->Printf ("SBValue(%p)::MightHaveChildren() => %i", value_sp.get(), has_children);
return has_children;
}
@@ -1374,7 +1380,7 @@ SBValue::GetNumChildren ()
{
uint32_t num_children = 0;
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
lldb::ValueObjectSP value_sp(GetSP());
if (value_sp)
{
@@ -1420,7 +1426,7 @@ SBValue::Dereference ()
sb_value = value_sp->Dereference (error);
}
}
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBValue(%p)::Dereference () => SBValue(%p)", value_sp.get(), value_sp.get());
@@ -1444,7 +1450,7 @@ SBValue::TypeIsPointerType ()
}
}
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBValue(%p)::TypeIsPointerType () => %i", value_sp.get(), is_ptr_type);
@@ -1480,7 +1486,7 @@ SBValue::GetTarget()
target_sp = value_sp->GetTargetSP();
sb_target.SetSP (target_sp);
}
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
{
if (target_sp.get() == NULL)
@@ -1503,7 +1509,7 @@ SBValue::GetProcess()
if (process_sp)
sb_process.SetSP (process_sp);
}
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
{
if (process_sp.get() == NULL)
@@ -1525,7 +1531,7 @@ SBValue::GetThread()
thread_sp = value_sp->GetThreadSP();
sb_thread.SetThread(thread_sp);
}
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
{
if (thread_sp.get() == NULL)
@@ -1547,7 +1553,7 @@ SBValue::GetFrame()
frame_sp = value_sp->GetFrameSP();
sb_frame.SetFrameSP (frame_sp);
}
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
{
if (frame_sp.get() == NULL)
@@ -1670,7 +1676,7 @@ SBValue::GetDescription (SBStream &descr
Process::StopLocker stop_locker;
if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock()))
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBValue(%p)::GetDescription() => error: process is running", value_sp.get());
}
@@ -1717,7 +1723,7 @@ SBValue::AddressOf()
sb_value.SetSP(value_sp->AddressOf (error),GetPreferDynamicValue(), GetPreferSyntheticValue());
}
}
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBValue(%p)::AddressOf () => SBValue(%p)", value_sp.get(), value_sp.get());
@@ -1754,7 +1760,7 @@ SBValue::GetLoadAddress()
value = LLDB_INVALID_ADDRESS;
}
}
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBValue(%p)::GetLoadAddress () => (%" PRIu64 ")", value_sp.get(), value);
@@ -1791,7 +1797,7 @@ SBValue::GetAddress()
}
}
}
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBValue(%p)::GetAddress () => (%s,%" PRIu64 ")", value_sp.get(),
(addr.GetSection() ? addr.GetSection()->GetName().GetCString() : "NULL"),
@@ -1803,7 +1809,7 @@ lldb::SBData
SBValue::GetPointeeData (uint32_t item_idx,
uint32_t item_count)
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
lldb::SBData sb_data;
lldb::ValueObjectSP value_sp(GetSP());
if (value_sp)
@@ -1841,7 +1847,7 @@ SBValue::GetPointeeData (uint32_t item_i
lldb::SBData
SBValue::GetData ()
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
lldb::SBData sb_data;
lldb::ValueObjectSP value_sp(GetSP());
if (value_sp)
@@ -1874,6 +1880,65 @@ SBValue::GetData ()
return sb_data;
}
+bool
+SBValue::SetData (lldb::SBData &data, SBError &error)
+{
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ lldb::ValueObjectSP value_sp(GetSP());
+ bool ret = true;
+
+ if (value_sp)
+ {
+ ProcessSP process_sp(value_sp->GetProcessSP());
+ Process::StopLocker stop_locker;
+ if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock()))
+ {
+ if (log)
+ log->Printf ("SBValue(%p)::SetData() => error: process is running", value_sp.get());
+
+ error.SetErrorString("Process is running");
+ ret = false;
+ }
+ else
+ {
+ DataExtractor *data_extractor = data.get();
+
+ if (!data_extractor)
+ {
+ if (log)
+ log->Printf ("SBValue(%p)::SetData() => error: no data to set", value_sp.get());
+
+ error.SetErrorString("No data to set");
+ ret = false;
+ }
+ else
+ {
+ Error set_error;
+
+ value_sp->SetData(*data_extractor, set_error);
+
+ if (!set_error.Success())
+ {
+ error.SetErrorStringWithFormat("Couldn't set data: %s", set_error.AsCString());
+ ret = false;
+ }
+ }
+ }
+ }
+ else
+ {
+ error.SetErrorString("Couldn't set data: invalid SBValue");
+ ret = false;
+ }
+
+ if (log)
+ log->Printf ("SBValue(%p)::SetData (%p) => %s",
+ value_sp.get(),
+ data.get(),
+ ret ? "true" : "false");
+ return ret;
+}
+
lldb::SBDeclaration
SBValue::GetDeclaration ()
{
@@ -1903,7 +1968,7 @@ SBValue::Watch (bool resolve_location, b
Process::StopLocker stop_locker;
if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock()))
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBValue(%p)::Watch() => error: process is running", value_sp.get());
return sb_watchpoint;
Modified: lldb/branches/windows/source/API/SBValueList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/API/SBValueList.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/API/SBValueList.cpp (original)
+++ lldb/branches/windows/source/API/SBValueList.cpp Wed Apr 17 03:38:48 2013
@@ -14,9 +14,78 @@
#include "lldb/Core/Log.h"
#include "lldb/Core/ValueObjectList.h"
+#include <vector>
+
using namespace lldb;
using namespace lldb_private;
+namespace {
+ class ValueListImpl
+ {
+ public:
+ ValueListImpl () :
+ m_values()
+ {
+ }
+
+ ValueListImpl (const ValueListImpl& rhs) :
+ m_values(rhs.m_values)
+ {
+ }
+
+ ValueListImpl&
+ operator = (const ValueListImpl& rhs)
+ {
+ if (this == &rhs)
+ return *this;
+ m_values = rhs.m_values;
+ return *this;
+ };
+
+ uint32_t
+ GetSize ()
+ {
+ return m_values.size();
+ }
+
+ void
+ Append (const lldb::SBValue& sb_value)
+ {
+ m_values.push_back(sb_value);
+ }
+
+ void
+ Append (const ValueListImpl& list)
+ {
+ for (auto val : list.m_values)
+ Append (val);
+ }
+
+ lldb::SBValue
+ GetValueAtIndex (uint32_t index)
+ {
+ if (index >= GetSize())
+ return lldb::SBValue();
+ return m_values[index];
+ }
+
+ lldb::SBValue
+ FindValueByUID (lldb::user_id_t uid)
+ {
+ for (auto val : m_values)
+ {
+ if (val.IsValid() && val.GetID() == uid)
+ return val;
+ }
+ return lldb::SBValue();
+ }
+
+ private:
+ std::vector<lldb::SBValue> m_values;
+ };
+}
+
+
SBValueList::SBValueList () :
m_opaque_ap ()
{
@@ -25,10 +94,10 @@ SBValueList::SBValueList () :
SBValueList::SBValueList (const SBValueList &rhs) :
m_opaque_ap ()
{
- LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (rhs.IsValid())
- m_opaque_ap.reset (new ValueObjectList (*rhs));
+ m_opaque_ap.reset (new ValueListImpl (*rhs));
if (log)
{
@@ -38,13 +107,13 @@ SBValueList::SBValueList (const SBValueL
}
}
-SBValueList::SBValueList (const ValueObjectList *lldb_object_ptr) :
+SBValueList::SBValueList (const ValueListImpl *lldb_object_ptr) :
m_opaque_ap ()
{
- LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (lldb_object_ptr)
- m_opaque_ap.reset (new ValueObjectList (*lldb_object_ptr));
+ m_opaque_ap.reset (new ValueListImpl (*lldb_object_ptr));
if (log)
{
@@ -76,32 +145,32 @@ SBValueList::operator = (const SBValueLi
if (this != &rhs)
{
if (rhs.IsValid())
- m_opaque_ap.reset (new ValueObjectList (*rhs));
+ m_opaque_ap.reset (new ValueListImpl (*rhs));
else
m_opaque_ap.reset ();
}
return *this;
}
-ValueObjectList *
+ValueListImpl *
SBValueList::operator->()
{
return m_opaque_ap.get();
}
-ValueObjectList &
+ValueListImpl &
SBValueList::operator*()
{
return *m_opaque_ap;
}
-const ValueObjectList *
+const ValueListImpl *
SBValueList::operator->() const
{
return m_opaque_ap.get();
}
-const ValueObjectList &
+const ValueListImpl &
SBValueList::operator*() const
{
return *m_opaque_ap;
@@ -110,12 +179,8 @@ SBValueList::operator*() const
void
SBValueList::Append (const SBValue &val_obj)
{
- ValueObjectSP value_sp (val_obj.GetSP());
- if (value_sp)
- {
- CreateIfNeeded ();
- m_opaque_ap->Append (value_sp);
- }
+ CreateIfNeeded ();
+ m_opaque_ap->Append (val_obj);
}
void
@@ -124,7 +189,7 @@ SBValueList::Append (lldb::ValueObjectSP
if (val_obj_sp)
{
CreateIfNeeded ();
- m_opaque_ap->Append (val_obj_sp);
+ m_opaque_ap->Append (SBValue(val_obj_sp));
}
}
@@ -142,25 +207,21 @@ SBValueList::Append (const lldb::SBValue
SBValue
SBValueList::GetValueAtIndex (uint32_t idx) const
{
- LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
//if (log)
// log->Printf ("SBValueList::GetValueAtIndex (uint32_t idx) idx = %d", idx);
SBValue sb_value;
- ValueObjectSP value_sp;
if (m_opaque_ap.get())
- {
- value_sp = m_opaque_ap->GetValueObjectAtIndex (idx);
- sb_value.SetSP (value_sp);
- }
+ sb_value = m_opaque_ap->GetValueAtIndex (idx);
if (log)
{
SBStream sstr;
sb_value.GetDescription (sstr);
log->Printf ("SBValueList::GetValueAtIndex (this.ap=%p, idx=%d) => SBValue (this.sp = %p, '%s')",
- m_opaque_ap.get(), idx, value_sp.get(), sstr.GetData());
+ m_opaque_ap.get(), idx, sb_value.GetSP().get(), sstr.GetData());
}
return sb_value;
@@ -169,7 +230,7 @@ SBValueList::GetValueAtIndex (uint32_t i
uint32_t
SBValueList::GetSize () const
{
- LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
//if (log)
// log->Printf ("SBValueList::GetSize ()");
@@ -188,7 +249,7 @@ void
SBValueList::CreateIfNeeded ()
{
if (m_opaque_ap.get() == NULL)
- m_opaque_ap.reset (new ValueObjectList());
+ m_opaque_ap.reset (new ValueListImpl());
}
@@ -197,17 +258,17 @@ SBValueList::FindValueObjectByUID (lldb:
{
SBValue sb_value;
if (m_opaque_ap.get())
- sb_value.SetSP (m_opaque_ap->FindValueObjectByUID (uid));
+ sb_value = m_opaque_ap->FindValueByUID(uid);
return sb_value;
}
-ValueObjectList *
-SBValueList::get ()
+void *
+SBValueList::opaque_ptr ()
{
return m_opaque_ap.get();
}
-ValueObjectList &
+ValueListImpl &
SBValueList::ref ()
{
CreateIfNeeded();
Modified: lldb/branches/windows/source/API/SBWatchpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/API/SBWatchpoint.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/API/SBWatchpoint.cpp (original)
+++ lldb/branches/windows/source/API/SBWatchpoint.cpp Wed Apr 17 03:38:48 2013
@@ -35,7 +35,7 @@ SBWatchpoint::SBWatchpoint () :
SBWatchpoint::SBWatchpoint (const lldb::WatchpointSP &wp_sp) :
m_opaque_sp (wp_sp)
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
{
@@ -67,7 +67,7 @@ SBWatchpoint::~SBWatchpoint ()
watch_id_t
SBWatchpoint::GetID ()
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
watch_id_t watch_id = LLDB_INVALID_WATCH_ID;
lldb::WatchpointSP watchpoint_sp(GetSP());
@@ -183,7 +183,7 @@ SBWatchpoint::GetHitCount ()
count = watchpoint_sp->GetHitCount();
}
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBWatchpoint(%p)::GetHitCount () => %u", watchpoint_sp.get(), count);
Modified: lldb/branches/windows/source/Breakpoint/Breakpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Breakpoint/Breakpoint.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Breakpoint/Breakpoint.cpp (original)
+++ lldb/branches/windows/source/Breakpoint/Breakpoint.cpp Wed Apr 17 03:38:48 2013
@@ -108,7 +108,7 @@ Breakpoint::FindLocationByID (break_id_t
}
BreakpointLocationSP
-Breakpoint::GetLocationAtIndex (uint32_t index)
+Breakpoint::GetLocationAtIndex (size_t index)
{
return m_locations.GetByIndex(index);
}
@@ -242,7 +242,8 @@ Breakpoint::GetThreadIndex() const
void
Breakpoint::SetThreadName (const char *thread_name)
{
- if (::strcmp (m_options.GetThreadSpec()->GetName(), thread_name) == 0)
+ if (m_options.GetThreadSpec()->GetName() != NULL
+ && ::strcmp (m_options.GetThreadSpec()->GetName(), thread_name) == 0)
return;
m_options.GetThreadSpec()->SetName (thread_name);
@@ -261,7 +262,8 @@ Breakpoint::GetThreadName () const
void
Breakpoint::SetQueueName (const char *queue_name)
{
- if (::strcmp (m_options.GetThreadSpec()->GetQueueName(), queue_name) == 0)
+ if (m_options.GetThreadSpec()->GetQueueName() != NULL
+ && ::strcmp (m_options.GetThreadSpec()->GetQueueName(), queue_name) == 0)
return;
m_options.GetThreadSpec()->SetQueueName (queue_name);
@@ -391,7 +393,7 @@ Breakpoint::ModulesChanged (ModuleList &
if (!break_loc->ResolveBreakpointSite())
{
- LogSP log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
+ Log *log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
if (log)
log->Printf ("Warning: could not set breakpoint site for breakpoint location %d of breakpoint %d.\n",
break_loc->GetID(), GetID());
@@ -523,12 +525,21 @@ Breakpoint::GetNumLocations() const
void
Breakpoint::GetDescription (Stream *s, lldb::DescriptionLevel level, bool show_locations)
{
- const size_t num_locations = GetNumLocations ();
- const size_t num_resolved_locations = GetNumResolvedLocations ();
-
assert (s != NULL);
-
+ if (!m_kind_description.empty())
+ {
+ if (eDescriptionLevelBrief)
+ {
+ s->PutCString (GetBreakpointKind());
+ return;
+ }
+ else
+ s->Printf("Kind: %s\n", GetBreakpointKind ());
+ }
+
+ const size_t num_locations = GetNumLocations ();
+ const size_t num_resolved_locations = GetNumResolvedLocations ();
// They just made the breakpoint, they don't need to be told HOW they made it...
// Also, we'll print the breakpoint number differently depending on whether there is 1 or more locations.
@@ -758,7 +769,7 @@ Breakpoint::BreakpointEventData::GetBrea
return bp_sp;
}
-uint32_t
+size_t
Breakpoint::BreakpointEventData::GetNumBreakpointLocationsFromEvent (const EventSP &event_sp)
{
const BreakpointEventData *data = GetEventDataFromEvent (event_sp.get());
Modified: lldb/branches/windows/source/Breakpoint/BreakpointIDList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Breakpoint/BreakpointIDList.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Breakpoint/BreakpointIDList.cpp (original)
+++ lldb/branches/windows/source/Breakpoint/BreakpointIDList.cpp Wed Apr 17 03:38:48 2013
@@ -38,7 +38,7 @@ BreakpointIDList::GetSize()
}
BreakpointID &
-BreakpointIDList::GetBreakpointIDAtIndex (uint32_t index)
+BreakpointIDList::GetBreakpointIDAtIndex (size_t index)
{
if (index < m_breakpoint_ids.size())
return m_breakpoint_ids[index];
@@ -47,7 +47,7 @@ BreakpointIDList::GetBreakpointIDAtIndex
}
bool
-BreakpointIDList::RemoveBreakpointIDAtIndex (uint32_t index)
+BreakpointIDList::RemoveBreakpointIDAtIndex (size_t index)
{
if (index >= m_breakpoint_ids.size())
return false;
@@ -89,10 +89,8 @@ BreakpointIDList::AddBreakpointID (const
}
bool
-BreakpointIDList::FindBreakpointID (BreakpointID &bp_id, uint32_t *position)
+BreakpointIDList::FindBreakpointID (BreakpointID &bp_id, size_t *position)
{
- BreakpointIDArray::iterator tmp_pos;
-
for (size_t i = 0; i < m_breakpoint_ids.size(); ++i)
{
BreakpointID tmp_id = m_breakpoint_ids[i];
@@ -108,7 +106,7 @@ BreakpointIDList::FindBreakpointID (Brea
}
bool
-BreakpointIDList::FindBreakpointID (const char *bp_id_str, uint32_t *position)
+BreakpointIDList::FindBreakpointID (const char *bp_id_str, size_t *position)
{
BreakpointID temp_bp_id;
break_id_t bp_id;
@@ -124,7 +122,7 @@ BreakpointIDList::FindBreakpointID (cons
}
void
-BreakpointIDList::InsertStringArray (const char **string_array, uint32_t array_size, CommandReturnObject &result)
+BreakpointIDList::InsertStringArray (const char **string_array, size_t array_size, CommandReturnObject &result)
{
if (string_array == NULL)
return;
@@ -174,8 +172,8 @@ BreakpointIDList::FindAndReplaceIDRanges
bool is_range = false;
current_arg = old_args.GetArgumentAtIndex (i);
- uint32_t range_start_len = 0;
- uint32_t range_end_pos = 0;
+ size_t range_start_len = 0;
+ size_t range_end_pos = 0;
if (BreakpointIDList::StringContainsIDRangeExpression (current_arg, &range_start_len, &range_end_pos))
{
is_range = true;
@@ -350,8 +348,8 @@ BreakpointIDList::FindAndReplaceIDRanges
bool
BreakpointIDList::StringContainsIDRangeExpression (const char *in_string,
- uint32_t *range_start_len,
- uint32_t *range_end_pos)
+ size_t *range_start_len,
+ size_t *range_end_pos)
{
bool is_range_expression = false;
std::string arg_str = in_string;
@@ -368,7 +366,7 @@ BreakpointIDList::StringContainsIDRangeE
for (int i = 0; i < specifiers_size && !is_range_expression; ++i)
{
const char *specifier_str = BreakpointID::g_range_specifiers[i];
- int len = strlen (specifier_str);
+ size_t len = strlen (specifier_str);
idx = arg_str.find (BreakpointID::g_range_specifiers[i]);
if (idx != std::string::npos)
{
Modified: lldb/branches/windows/source/Breakpoint/BreakpointList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Breakpoint/BreakpointList.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Breakpoint/BreakpointList.cpp (original)
+++ lldb/branches/windows/source/Breakpoint/BreakpointList.cpp Wed Apr 17 03:38:48 2013
@@ -172,13 +172,13 @@ BreakpointList::Dump (Stream *s) const
BreakpointSP
-BreakpointList::GetBreakpointAtIndex (uint32_t i)
+BreakpointList::GetBreakpointAtIndex (size_t i)
{
Mutex::Locker locker(m_mutex);
BreakpointSP stop_sp;
bp_collection::iterator end = m_breakpoints.end();
bp_collection::iterator pos;
- uint32_t curr_i = 0;
+ size_t curr_i = 0;
for (pos = m_breakpoints.begin(), curr_i = 0; pos != end; ++pos, ++curr_i)
{
if (curr_i == i)
@@ -188,13 +188,13 @@ BreakpointList::GetBreakpointAtIndex (ui
}
const BreakpointSP
-BreakpointList::GetBreakpointAtIndex (uint32_t i) const
+BreakpointList::GetBreakpointAtIndex (size_t i) const
{
Mutex::Locker locker(m_mutex);
BreakpointSP stop_sp;
bp_collection::const_iterator end = m_breakpoints.end();
bp_collection::const_iterator pos;
- uint32_t curr_i = 0;
+ size_t curr_i = 0;
for (pos = m_breakpoints.begin(), curr_i = 0; pos != end; ++pos, ++curr_i)
{
if (curr_i == i)
Modified: lldb/branches/windows/source/Breakpoint/BreakpointLocation.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Breakpoint/BreakpointLocation.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Breakpoint/BreakpointLocation.cpp (original)
+++ lldb/branches/windows/source/Breakpoint/BreakpointLocation.cpp Wed Apr 17 03:38:48 2013
@@ -322,7 +322,7 @@ bool
BreakpointLocation::ShouldStop (StoppointCallbackContext *context)
{
bool should_stop = true;
- LogSP log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS);
+ Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS);
IncrementHitCount();
@@ -378,7 +378,7 @@ BreakpointLocation::ResolveBreakpointSit
if (new_id == LLDB_INVALID_BREAK_ID)
{
- LogSP log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS);
+ Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS);
if (log)
log->Warning ("Tried to add breakpoint site at 0x%" PRIx64 " but it was already present.\n",
m_address.GetOpcodeLoadAddress (&m_owner.GetTarget()));
Modified: lldb/branches/windows/source/Breakpoint/BreakpointLocationCollection.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Breakpoint/BreakpointLocationCollection.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Breakpoint/BreakpointLocationCollection.cpp (original)
+++ lldb/branches/windows/source/Breakpoint/BreakpointLocationCollection.cpp Wed Apr 17 03:38:48 2013
@@ -115,7 +115,7 @@ BreakpointLocationCollection::FindByIDPa
}
BreakpointLocationSP
-BreakpointLocationCollection::GetByIndex (uint32_t i)
+BreakpointLocationCollection::GetByIndex (size_t i)
{
BreakpointLocationSP stop_sp;
if (i < m_break_loc_collection.size())
@@ -125,7 +125,7 @@ BreakpointLocationCollection::GetByIndex
}
const BreakpointLocationSP
-BreakpointLocationCollection::GetByIndex (uint32_t i) const
+BreakpointLocationCollection::GetByIndex (size_t i) const
{
BreakpointLocationSP stop_sp;
if (i < m_break_loc_collection.size())
@@ -162,6 +162,25 @@ BreakpointLocationCollection::ValidForTh
return false;
}
+bool
+BreakpointLocationCollection::IsInternal () const
+{
+ collection::const_iterator pos,
+ begin = m_break_loc_collection.begin(),
+ end = m_break_loc_collection.end();
+
+ bool is_internal = true;
+
+ for (pos = begin; pos != end; ++pos)
+ {
+ if (!(*pos)->GetBreakpoint().IsInternal ())
+ {
+ is_internal = false;
+ break;
+ }
+ }
+ return is_internal;
+}
void
BreakpointLocationCollection::GetDescription (Stream *s, lldb::DescriptionLevel level)
Modified: lldb/branches/windows/source/Breakpoint/BreakpointLocationList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Breakpoint/BreakpointLocationList.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Breakpoint/BreakpointLocationList.cpp (original)
+++ lldb/branches/windows/source/Breakpoint/BreakpointLocationList.cpp Wed Apr 17 03:38:48 2013
@@ -138,7 +138,7 @@ BreakpointLocationList::Dump (Stream *s)
BreakpointLocationSP
-BreakpointLocationList::GetByIndex (uint32_t i)
+BreakpointLocationList::GetByIndex (size_t i)
{
Mutex::Locker locker (m_mutex);
BreakpointLocationSP bp_loc_sp;
@@ -149,7 +149,7 @@ BreakpointLocationList::GetByIndex (uint
}
const BreakpointLocationSP
-BreakpointLocationList::GetByIndex (uint32_t i) const
+BreakpointLocationList::GetByIndex (size_t i) const
{
Mutex::Locker locker (m_mutex);
BreakpointLocationSP bp_loc_sp;
Modified: lldb/branches/windows/source/Breakpoint/BreakpointResolverAddress.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Breakpoint/BreakpointResolverAddress.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Breakpoint/BreakpointResolverAddress.cpp (original)
+++ lldb/branches/windows/source/Breakpoint/BreakpointResolverAddress.cpp Wed Apr 17 03:38:48 2013
@@ -83,7 +83,7 @@ BreakpointResolverAddress::SearchCallbac
{
StreamString s;
bp_loc_sp->GetDescription(&s, lldb::eDescriptionLevelVerbose);
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
if (log)
log->Printf ("Added location: %s\n", s.GetData());
}
Modified: lldb/branches/windows/source/Breakpoint/BreakpointResolverFileLine.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Breakpoint/BreakpointResolverFileLine.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Breakpoint/BreakpointResolverFileLine.cpp (original)
+++ lldb/branches/windows/source/Breakpoint/BreakpointResolverFileLine.cpp Wed Apr 17 03:38:48 2013
@@ -59,7 +59,7 @@ BreakpointResolverFileLine::SearchCallba
SymbolContextList sc_list;
assert (m_breakpoint != NULL);
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
// There is a tricky bit here. You can have two compilation units that #include the same file, and
// in one of them the function at m_line_number is used (and so code and a line entry for it is generated) but in the
@@ -73,8 +73,8 @@ BreakpointResolverFileLine::SearchCallba
// So we go through the match list and pull out the sets that have the same file spec in their line_entry
// and treat each set separately.
- uint32_t num_comp_units = context.module_sp->GetNumCompileUnits();
- for (uint32_t i = 0; i < num_comp_units; i++)
+ const size_t num_comp_units = context.module_sp->GetNumCompileUnits();
+ for (size_t i = 0; i < num_comp_units; i++)
{
CompUnitSP cu_sp (context.module_sp->GetCompileUnitAtIndex (i));
if (cu_sp)
@@ -123,85 +123,101 @@ BreakpointResolverFileLine::SearchCallba
current_idx++;
}
- // Okay, we've found the closest line number match, now throw away all the others,
+ // Okay, we've found the closest line number match, now throw away all the others:
+
+ current_idx = 0;
+ while (current_idx < tmp_sc_list.GetSize())
+ {
+ if (tmp_sc_list.GetContextAtIndex(current_idx, sc))
+ {
+ if (sc.line_entry.line != closest_line_number)
+ tmp_sc_list.RemoveContextAtIndex(current_idx);
+ else
+ current_idx++;
+ }
+ }
+
+ // Next go through and see if there are line table entries that are contiguous, and if so keep only the
+ // first of the contiguous range:
+
+ lldb::addr_t last_end_addr = LLDB_INVALID_ADDRESS;
+ current_idx = 0;
+ while (current_idx < tmp_sc_list.GetSize())
+ {
+ if (tmp_sc_list.GetContextAtIndex(current_idx, sc))
+ {
+ lldb::addr_t start_file_addr = sc.line_entry.range.GetBaseAddress().GetFileAddress();
+ lldb::addr_t end_file_addr = start_file_addr + sc.line_entry.range.GetByteSize();
+
+ if (start_file_addr == last_end_addr)
+ tmp_sc_list.RemoveContextAtIndex(current_idx);
+ else
+ current_idx++;
+
+ last_end_addr = end_file_addr;
+ }
+ }
+
// and make breakpoints out of the closest line number match.
uint32_t tmp_sc_list_size = tmp_sc_list.GetSize();
for (uint32_t i = 0; i < tmp_sc_list_size; i++)
{
- SymbolContext sc;
if (tmp_sc_list.GetContextAtIndex(i, sc))
{
- if (sc.line_entry.line == closest_line_number)
+ Address line_start = sc.line_entry.range.GetBaseAddress();
+ if (line_start.IsValid())
{
- Address line_start = sc.line_entry.range.GetBaseAddress();
- if (line_start.IsValid())
+ if (filter.AddressPasses(line_start))
{
- if (filter.AddressPasses(line_start))
+ // If the line number is before the prologue end, move it there...
+ bool skipped_prologue = false;
+ if (m_skip_prologue)
{
- // If the line number is before the prologue end, move it there...
- bool skipped_prologue = false;
- if (m_skip_prologue)
+ if (sc.function)
{
- if (sc.function)
+ Address prologue_addr(sc.function->GetAddressRange().GetBaseAddress());
+ if (prologue_addr.IsValid() && (line_start == prologue_addr))
{
- Address prologue_addr(sc.function->GetAddressRange().GetBaseAddress());
- if (prologue_addr.IsValid() && (line_start == prologue_addr))
+ const uint32_t prologue_byte_size = sc.function->GetPrologueByteSize();
+ if (prologue_byte_size)
{
- const uint32_t prologue_byte_size = sc.function->GetPrologueByteSize();
- if (prologue_byte_size)
+ prologue_addr.Slide(prologue_byte_size);
+
+ if (filter.AddressPasses(prologue_addr))
{
- prologue_addr.Slide(prologue_byte_size);
-
- if (filter.AddressPasses(prologue_addr))
- {
- skipped_prologue = true;
- line_start = prologue_addr;
- }
+ skipped_prologue = true;
+ line_start = prologue_addr;
}
}
}
}
-
- BreakpointLocationSP bp_loc_sp (m_breakpoint->AddLocation(line_start));
- if (log && bp_loc_sp && !m_breakpoint->IsInternal())
- {
- StreamString s;
- bp_loc_sp->GetDescription (&s, lldb::eDescriptionLevelVerbose);
- log->Printf ("Added location (skipped prologue: %s): %s \n", skipped_prologue ? "yes" : "no", s.GetData());
- }
}
- else if (log)
+
+ BreakpointLocationSP bp_loc_sp (m_breakpoint->AddLocation(line_start));
+ if (log && bp_loc_sp && !m_breakpoint->IsInternal())
{
- log->Printf ("Breakpoint at file address 0x%" PRIx64 " for %s:%d didn't pass the filter.\n",
- line_start.GetFileAddress(),
- m_file_spec.GetFilename().AsCString("<Unknown>"),
- m_line_number);
+ StreamString s;
+ bp_loc_sp->GetDescription (&s, lldb::eDescriptionLevelVerbose);
+ log->Printf ("Added location (skipped prologue: %s): %s \n", skipped_prologue ? "yes" : "no", s.GetData());
}
}
- else
+ else if (log)
{
- if (log)
- log->Printf ("error: Unable to set breakpoint at file address 0x%" PRIx64 " for %s:%d\n",
- line_start.GetFileAddress(),
- m_file_spec.GetFilename().AsCString("<Unknown>"),
- m_line_number);
+ log->Printf ("Breakpoint at file address 0x%" PRIx64 " for %s:%d didn't pass the filter.\n",
+ line_start.GetFileAddress(),
+ m_file_spec.GetFilename().AsCString("<Unknown>"),
+ m_line_number);
}
}
else
{
- #if 0
- s << "error: Breakpoint at '" << pos->c_str() << "' isn't resolved yet: \n";
- if (sc.line_entry.address.Dump(&s, Address::DumpStyleSectionNameOffset))
- s.EOL();
- if (sc.line_entry.address.Dump(&s, Address::DumpStyleSectionPointerOffset))
- s.EOL();
- if (sc.line_entry.address.Dump(&s, Address::DumpStyleFileAddress))
- s.EOL();
- if (sc.line_entry.address.Dump(&s, Address::DumpStyleLoadAddress))
- s.EOL();
- #endif
+ if (log)
+ log->Printf ("error: Unable to set breakpoint at file address 0x%" PRIx64 " for %s:%d\n",
+ line_start.GetFileAddress(),
+ m_file_spec.GetFilename().AsCString("<Unknown>"),
+ m_line_number);
}
}
}
Modified: lldb/branches/windows/source/Breakpoint/BreakpointResolverFileRegex.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Breakpoint/BreakpointResolverFileRegex.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Breakpoint/BreakpointResolverFileRegex.cpp (original)
+++ lldb/branches/windows/source/Breakpoint/BreakpointResolverFileRegex.cpp Wed Apr 17 03:38:48 2013
@@ -55,7 +55,7 @@ BreakpointResolverFileRegex::SearchCallb
if (!context.target_sp)
return eCallbackReturnContinue;
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
CompileUnit *cu = context.comp_unit;
FileSpec cu_file_spec = *(static_cast<FileSpec *>(cu));
Modified: lldb/branches/windows/source/Breakpoint/BreakpointResolverName.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Breakpoint/BreakpointResolverName.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Breakpoint/BreakpointResolverName.cpp (original)
+++ lldb/branches/windows/source/Breakpoint/BreakpointResolverName.cpp Wed Apr 17 03:38:48 2013
@@ -22,20 +22,17 @@
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Target/ObjCLanguageRuntime.h"
using namespace lldb;
using namespace lldb_private;
-BreakpointResolverName::BreakpointResolverName
-(
- Breakpoint *bkpt,
- const char *func_name,
- uint32_t func_name_type_mask,
- Breakpoint::MatchType type,
- bool skip_prologue
-) :
+BreakpointResolverName::BreakpointResolverName (Breakpoint *bkpt,
+ const char *name_cstr,
+ uint32_t name_type_mask,
+ Breakpoint::MatchType type,
+ bool skip_prologue) :
BreakpointResolver (bkpt, BreakpointResolver::NameResolver),
- m_func_name_type_mask (func_name_type_mask),
m_class_name (),
m_regex (),
m_match_type (type),
@@ -44,17 +41,17 @@ BreakpointResolverName::BreakpointResolv
if (m_match_type == Breakpoint::Regexp)
{
- if (!m_regex.Compile (func_name))
+ if (!m_regex.Compile (name_cstr))
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
if (log)
- log->Warning ("function name regexp: \"%s\" did not compile.", func_name);
+ log->Warning ("function name regexp: \"%s\" did not compile.", name_cstr);
}
}
else
{
- m_func_names.push_back(ConstString(func_name));
+ AddNameLookup (ConstString(name_cstr), name_type_mask);
}
}
@@ -64,13 +61,12 @@ BreakpointResolverName::BreakpointResolv
uint32_t name_type_mask,
bool skip_prologue) :
BreakpointResolver (bkpt, BreakpointResolver::NameResolver),
- m_func_name_type_mask (name_type_mask),
m_match_type (Breakpoint::Exact),
m_skip_prologue (skip_prologue)
{
for (size_t i = 0; i < num_names; i++)
{
- m_func_names.push_back (ConstString (names[i]));
+ AddNameLookup (ConstString (names[i]), name_type_mask);
}
}
@@ -79,24 +75,18 @@ BreakpointResolverName::BreakpointResolv
uint32_t name_type_mask,
bool skip_prologue) :
BreakpointResolver (bkpt, BreakpointResolver::NameResolver),
- m_func_name_type_mask (name_type_mask),
m_match_type (Breakpoint::Exact),
m_skip_prologue (skip_prologue)
{
- size_t num_names = names.size();
-
- for (size_t i = 0; i < num_names; i++)
+ for (const std::string& name : names)
{
- m_func_names.push_back (ConstString (names[i].c_str()));
+ AddNameLookup (ConstString (name.c_str(), name.size()), name_type_mask);
}
}
-BreakpointResolverName::BreakpointResolverName
-(
- Breakpoint *bkpt,
- RegularExpression &func_regex,
- bool skip_prologue
-) :
+BreakpointResolverName::BreakpointResolverName (Breakpoint *bkpt,
+ RegularExpression &func_regex,
+ bool skip_prologue) :
BreakpointResolver (bkpt, BreakpointResolver::NameResolver),
m_class_name (NULL),
m_regex (func_regex),
@@ -119,13 +109,71 @@ BreakpointResolverName::BreakpointResolv
m_match_type (type),
m_skip_prologue (skip_prologue)
{
- m_func_names.push_back(ConstString(method));
+ LookupInfo lookup;
+ lookup.name.SetCString(method);
+ lookup.lookup_name = lookup.name;
+ lookup.name_type_mask = eFunctionNameTypeMethod;
+ lookup.match_name_after_lookup = false;
+ m_lookups.push_back (lookup);
}
BreakpointResolverName::~BreakpointResolverName ()
{
}
+void
+BreakpointResolverName::AddNameLookup (const ConstString &name, uint32_t name_type_mask)
+{
+ ObjCLanguageRuntime::MethodName objc_method(name.GetCString(), false);
+ if (objc_method.IsValid(false))
+ {
+ std::vector<ConstString> objc_names;
+ objc_method.GetFullNames(objc_names, true);
+ for (ConstString objc_name : objc_names)
+ {
+ LookupInfo lookup;
+ lookup.name = name;
+ lookup.lookup_name = objc_name;
+ lookup.name_type_mask = eFunctionNameTypeFull;
+ lookup.match_name_after_lookup = false;
+ m_lookups.push_back (lookup);
+ }
+ }
+ else
+ {
+ LookupInfo lookup;
+ lookup.name = name;
+ Module::PrepareForFunctionNameLookup(lookup.name, name_type_mask, lookup.lookup_name, lookup.name_type_mask, lookup.match_name_after_lookup);
+ m_lookups.push_back (lookup);
+ }
+}
+
+
+void
+BreakpointResolverName::LookupInfo::Prune (SymbolContextList &sc_list, size_t start_idx) const
+{
+ if (match_name_after_lookup && name)
+ {
+ SymbolContext sc;
+ size_t i = start_idx;
+ while (i < sc_list.GetSize())
+ {
+ if (!sc_list.GetContextAtIndex(i, sc))
+ break;
+ ConstString full_name (sc.GetFunctionName());
+ if (full_name && ::strstr(full_name.GetCString(), name.GetCString()) == NULL)
+ {
+ sc_list.RemoveContextAtIndex(i);
+ }
+ else
+ {
+ ++i;
+ }
+ }
+ }
+}
+
+
// FIXME: Right now we look at the module level, and call the module's "FindFunctions".
// Greg says he will add function tables, maybe at the CompileUnit level to accelerate function
// lookup. At that point, we should switch the depth to CompileUnit, and look in these tables.
@@ -144,11 +192,10 @@ BreakpointResolverName::SearchCallback
uint32_t i;
bool new_location;
- SymbolContext sc;
Address break_addr;
assert (m_breakpoint != NULL);
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
if (m_class_name)
{
@@ -167,22 +214,29 @@ BreakpointResolverName::SearchCallback
case Breakpoint::Exact:
if (context.module_sp)
{
- size_t num_names = m_func_names.size();
- for (int j = 0; j < num_names; j++)
+ for (const LookupInfo &lookup : m_lookups)
{
- uint32_t num_functions = context.module_sp->FindFunctions (m_func_names[j],
- NULL,
- m_func_name_type_mask,
- include_symbols,
- include_inlines,
- append,
- func_list);
+ const size_t start_func_idx = func_list.GetSize();
+ context.module_sp->FindFunctions (lookup.lookup_name,
+ NULL,
+ lookup.name_type_mask,
+ include_symbols,
+ include_inlines,
+ append,
+ func_list);
+ const size_t end_func_idx = func_list.GetSize();
+
+ if (start_func_idx < end_func_idx)
+ lookup.Prune (func_list, start_func_idx);
// If the search filter specifies a Compilation Unit, then we don't need to bother to look in plain
// symbols, since all the ones from a set compilation unit will have been found above already.
-
- if (num_functions == 0 && !filter_by_cu)
+ else if (!filter_by_cu)
{
- context.module_sp->FindFunctionSymbols (m_func_names[j], m_func_name_type_mask, sym_list);
+ const size_t start_symbol_idx = sym_list.GetSize();
+ context.module_sp->FindFunctionSymbols (lookup.lookup_name, lookup.name_type_mask, sym_list);
+ const size_t end_symbol_idx = sym_list.GetSize();
+ if (start_symbol_idx < end_symbol_idx)
+ lookup.Prune (func_list, start_symbol_idx);
}
}
}
@@ -224,6 +278,7 @@ BreakpointResolverName::SearchCallback
}
// Remove any duplicates between the funcion list and the symbol list
+ SymbolContext sc;
if (func_list.GetSize())
{
for (i = 0; i < func_list.GetSize(); i++)
@@ -341,17 +396,17 @@ BreakpointResolverName::GetDescription (
s->Printf("regex = '%s'", m_regex.GetText());
else
{
- size_t num_names = m_func_names.size();
+ size_t num_names = m_lookups.size();
if (num_names == 1)
- s->Printf("name = '%s'", m_func_names[0].AsCString());
+ s->Printf("name = '%s'", m_lookups[0].name.GetCString());
else
{
s->Printf("names = {");
for (size_t i = 0; i < num_names - 1; i++)
{
- s->Printf ("'%s', ", m_func_names[i].AsCString());
+ s->Printf ("'%s', ", m_lookups[i].name.GetCString());
}
- s->Printf ("'%s'}", m_func_names[num_names - 1].AsCString());
+ s->Printf ("'%s'}", m_lookups[num_names - 1].name.GetCString());
}
}
}
Modified: lldb/branches/windows/source/Breakpoint/BreakpointSite.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Breakpoint/BreakpointSite.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Breakpoint/BreakpointSite.cpp (original)
+++ lldb/branches/windows/source/Breakpoint/BreakpointSite.cpp Wed Apr 17 03:38:48 2013
@@ -25,10 +25,9 @@ BreakpointSite::BreakpointSite
BreakpointSiteList *list,
const BreakpointLocationSP& owner,
lldb::addr_t addr,
- lldb::tid_t tid,
bool use_hardware
) :
- StoppointLocation(GetNextID(), addr, tid, use_hardware),
+ StoppointLocation(GetNextID(), addr, 0, use_hardware),
m_type (eSoftware), // Process subclasses need to set this correctly using SetType()
m_saved_opcode(),
m_trap_opcode(),
@@ -99,6 +98,12 @@ BreakpointSite::GetDescription (Stream *
m_owners.GetDescription (s, level);
}
+bool
+BreakpointSite::IsInternal() const
+{
+ return m_owners.IsInternal();
+}
+
uint8_t *
BreakpointSite::GetTrapOpcodeBytes()
{
@@ -118,7 +123,7 @@ BreakpointSite::GetTrapOpcodeMaxByteSize
}
bool
-BreakpointSite::SetTrapOpcode (const uint8_t *trap_opcode, size_t trap_opcode_size)
+BreakpointSite::SetTrapOpcode (const uint8_t *trap_opcode, uint32_t trap_opcode_size)
{
if (trap_opcode_size > 0 && trap_opcode_size <= sizeof(m_trap_opcode))
{
@@ -160,21 +165,21 @@ BreakpointSite::AddOwner (const Breakpoi
m_owners.Add(owner);
}
-uint32_t
+size_t
BreakpointSite::RemoveOwner (lldb::break_id_t break_id, lldb::break_id_t break_loc_id)
{
m_owners.Remove(break_id, break_loc_id);
return m_owners.GetSize();
}
-uint32_t
+size_t
BreakpointSite::GetNumberOfOwners ()
{
return m_owners.GetSize();
}
BreakpointLocationSP
-BreakpointSite::GetOwnerAtIndex (uint32_t index)
+BreakpointSite::GetOwnerAtIndex (size_t index)
{
return m_owners.GetByIndex (index);
}
Modified: lldb/branches/windows/source/Breakpoint/BreakpointSiteList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Breakpoint/BreakpointSiteList.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Breakpoint/BreakpointSiteList.cpp (original)
+++ lldb/branches/windows/source/Breakpoint/BreakpointSiteList.cpp Wed Apr 17 03:38:48 2013
@@ -169,7 +169,7 @@ BreakpointSiteList::BreakpointSiteContai
{
collection::const_iterator pos = GetIDConstIterator(bp_site_id);
if (pos != m_bp_site_list.end())
- pos->second->IsBreakpointAtThisSite (bp_id);
+ return pos->second->IsBreakpointAtThisSite (bp_id);
return false;
}
Modified: lldb/branches/windows/source/Breakpoint/Watchpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Breakpoint/Watchpoint.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Breakpoint/Watchpoint.cpp (original)
+++ lldb/branches/windows/source/Breakpoint/Watchpoint.cpp Wed Apr 17 03:38:48 2013
@@ -27,7 +27,7 @@
using namespace lldb;
using namespace lldb_private;
-Watchpoint::Watchpoint (Target& target, lldb::addr_t addr, size_t size, const ClangASTType *type, bool hardware) :
+Watchpoint::Watchpoint (Target& target, lldb::addr_t addr, uint32_t size, const ClangASTType *type, bool hardware) :
StoppointLocation (0, addr, size, hardware),
m_target(target),
m_enabled(false),
Modified: lldb/branches/windows/source/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/CMakeLists.txt?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/CMakeLists.txt (original)
+++ lldb/branches/windows/source/CMakeLists.txt Wed Apr 17 03:38:48 2013
@@ -1,7 +1,17 @@
+include_directories(.)
+
+if ( CMAKE_SYSTEM_NAME MATCHES "Linux" )
+include_directories(
+ Plugins/Process/Linux
+ Plugins/Process/POSIX
+ )
+endif ()
+
add_subdirectory(API)
add_subdirectory(Breakpoint)
add_subdirectory(Commands)
add_subdirectory(Core)
+add_subdirectory(DataFormatters)
add_subdirectory(Expression)
add_subdirectory(Host)
add_subdirectory(Interpreter)
@@ -10,7 +20,158 @@ add_subdirectory(Symbol)
add_subdirectory(Target)
add_subdirectory(Utility)
-add_lldb_library(lldbInitAndLog
+set( LLDB_USED_LIBS
+ lldbAPI
+ lldbBreakpoint
+ lldbCommands
+ lldbDataFormatters
+ lldbHostCommon
+ lldbCore
+ lldbExpression
+ lldbInterpreter
+ lldbSymbol
+ lldbTarget
+ lldbUtility
+
+ # Plugins
+ lldbPluginDisassemblerLLVM
+ lldbPluginSymbolFileDWARF
+ lldbPluginSymbolFileSymtab
+ lldbPluginDynamicLoaderStatic
+
+ lldbPluginObjectFileMachO
+ lldbPluginObjectFileELF
+ lldbPluginObjectContainerBSDArchive
+ lldbPluginObjectContainerMachOArchive
+ lldbPluginProcessGDBRemote
+ lldbPluginProcessUtility
+ lldbPluginPlatformGDB
+ lldbPluginPlatformWindows
+ lldbPluginPlatformFreeBSD
+ lldbPluginPlatformLinux
+ lldbPluginObjectFileMachO
+ lldbPluginObjectContainerMachOArchive
+ lldbPluginObjectContainerBSDArchive
+ lldbPluginPlatformMacOSX
+ lldbPluginDynamicLoaderMacOSXDYLD
+ lldbPluginDynamicLoaderPosixDYLD
+ lldbPluginUnwindAssemblyInstEmulation
+ lldbPluginUnwindAssemblyX86
+ lldbPluginDynamicLoaderDarwinKernel
+ lldbPluginAppleObjCRuntime
+ lldbPluginCXXItaniumABI
+ lldbPluginABIMacOSX_arm
+ lldbPluginABIMacOSX_i386
+ lldbPluginABISysV_x86_64
+ lldbPluginInstructionARM
+ lldbPluginObjectFilePECOFF
+ lldbPluginOSPython
+ )
+
+# Windows-only libraries
+if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
+ list(APPEND LLDB_USED_LIBS
+ lldbHostWindows
+ lldbPluginPlatformWindows
+ Ws2_32
+ )
+endif ()
+
+# Linux-only libraries
+if ( CMAKE_SYSTEM_NAME MATCHES "Linux" )
+ list(APPEND LLDB_USED_LIBS
+ lldbHostLinux
+ lldbPluginProcessLinux
+ lldbPluginProcessPOSIX
+ )
+endif ()
+
+set( CLANG_USED_LIBS
+ clangAnalysis
+ clangAST
+ clangBasic
+ clangCodeGen
+ clangDriver
+ clangEdit
+ clangFrontend
+ clangLex
+ clangParse
+ clangRewriteCore
+ clangRewriteFrontend
+ clangSema
+ clangSerialization
+ )
+
+set( LLDB_SYSTEM_LIBS
+# edit
+# python2.7
+ )
+
+set( LLVM_LINK_COMPONENTS
+ ${LLVM_TARGETS_TO_BUILD}
+ jit
+ interpreter
+ nativecodegen
+ asmparser
+ bitreader
+ bitwriter
+ codegen
+ ipo
+ selectiondag
+ bitreader
+ mc
+ mcjit
+ core
+ mcdisassembler
+ executionengine
+ instrumentation
+ )
+
+set_source_files_properties(${LLDB_BINARY_DIR}/scripts/LLDBWrapPython.cpp PROPERTIES GENERATED 1)
+set(SHARED_LIBRARY 1)
+
+if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
+add_lldb_library(liblldb
+ lldb.cpp
+ lldb-log.cpp
+ )
+else()
+add_lldb_library(liblldb
lldb.cpp
lldb-log.cpp
+ ${LLDB_BINARY_DIR}/scripts/LLDBWrapPython.cpp
)
+endif()
+
+set_target_properties(liblldb PROPERTIES OUTPUT_NAME lldb)
+if(NOT(CMAKE_SYSTEM_NAME STREQUAL "Windows"))
+add_dependencies(liblldb ${LLDB_BINARY_DIR}/scripts/LLDBWrapPython.cpp)
+endif()
+target_link_libraries(liblldb ${LLDB_SYSTEM_LIBS})
+
+# Determine LLDB revision and repository. GetSourceVersion and GetRepositoryPath are shell-scripts, and as
+# such will not work on Windows.
+if ( NOT CMAKE_SYSTEM_NAME MATCHES "Windows" )
+ execute_process(COMMAND ${CMAKE_SOURCE_DIR}/utils/GetSourceVersion ${LLDB_SOURCE_DIR}
+ OUTPUT_VARIABLE LLDB_REVISION)
+ if ( LLDB_REVISION )
+ string(REGEX REPLACE "(\r?\n)+$" "" LLDB_REVISION ${LLDB_REVISION})
+ endif()
+
+ execute_process(COMMAND ${CMAKE_SOURCE_DIR}/utils/GetRepositoryPath ${LLDB_SOURCE_DIR}
+ OUTPUT_VARIABLE LLDB_REPOSITORY)
+ if ( LLDB_REPOSITORY )
+ string(REGEX REPLACE "(\r?\n)+$" "" LLDB_REPOSITORY ${LLDB_REPOSITORY})
+ string(REPLACE " " "" LLDB_REPOSITORY ${LLDB_REPOSITORY})
+ endif()
+
+ set_property(
+ SOURCE lldb.cpp
+ PROPERTY COMPILE_DEFINITIONS "LLDB_REVISION=\"${LLDB_REVISION}\"" "LLDB_REPOSITORY=\"${LLDB_REPOSITORY}\"")
+endif ()
+# FIXME: implement svn/git revision and repository parsing solution on Windows. There is an SVN-only
+# revision parsing solution in tools/clang/lib/Basic/CMakelists.txt.
+
+install(TARGETS liblldb
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib)
Modified: lldb/branches/windows/source/Commands/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Commands/CMakeLists.txt?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Commands/CMakeLists.txt (original)
+++ lldb/branches/windows/source/Commands/CMakeLists.txt Wed Apr 17 03:38:48 2013
@@ -7,7 +7,6 @@ add_lldb_library(lldbCommands
CommandObjectBreakpoint.cpp
CommandObjectBreakpointCommand.cpp
CommandObjectCommands.cpp
- CommandObjectCrossref.cpp
CommandObjectDisassemble.cpp
CommandObjectExpression.cpp
CommandObjectFrame.cpp
Modified: lldb/branches/windows/source/Commands/CommandCompletions.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Commands/CommandCompletions.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Commands/CommandCompletions.cpp (original)
+++ lldb/branches/windows/source/Commands/CommandCompletions.cpp Wed Apr 17 03:38:48 2013
@@ -131,7 +131,7 @@ DiskFilesOrDirectories
// I'm going to use the "glob" function with GLOB_TILDE for user directory expansion.
// If it is not defined on your host system, you'll need to implement it yourself...
- int partial_name_len = strlen(partial_file_name);
+ size_t partial_name_len = strlen(partial_file_name);
if (partial_name_len >= PATH_MAX)
return matches.GetSize();
Modified: lldb/branches/windows/source/Commands/CommandObjectApropos.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Commands/CommandObjectApropos.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Commands/CommandObjectApropos.cpp (original)
+++ lldb/branches/windows/source/Commands/CommandObjectApropos.cpp Wed Apr 17 03:38:48 2013
@@ -56,7 +56,7 @@ CommandObjectApropos::~CommandObjectApro
bool
CommandObjectApropos::DoExecute (Args& args, CommandReturnObject &result)
{
- const int argc = args.GetArgumentCount ();
+ const size_t argc = args.GetArgumentCount ();
if (argc == 1)
{
Modified: lldb/branches/windows/source/Commands/CommandObjectArgs.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Commands/CommandObjectArgs.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Commands/CommandObjectArgs.cpp (original)
+++ lldb/branches/windows/source/Commands/CommandObjectArgs.cpp Wed Apr 17 03:38:48 2013
@@ -104,7 +104,7 @@ CommandObjectArgs::DoExecute (Args& args
ConstString target_triple;
- Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
+ Process *process = m_exe_ctx.GetProcessPtr();
if (!process)
{
result.AppendError ("Args found no process.");
@@ -120,7 +120,7 @@ CommandObjectArgs::DoExecute (Args& args
return false;
}
- int num_args = args.GetArgumentCount ();
+ const size_t num_args = args.GetArgumentCount ();
int arg_index;
if (!num_args)
@@ -130,7 +130,7 @@ CommandObjectArgs::DoExecute (Args& args
return false;
}
- Thread *thread = m_interpreter.GetExecutionContext ().GetThreadPtr();
+ Thread *thread = m_exe_ctx.GetThreadPtr();
if (!thread)
{
Modified: lldb/branches/windows/source/Commands/CommandObjectBreakpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Commands/CommandObjectBreakpoint.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Commands/CommandObjectBreakpoint.cpp (original)
+++ lldb/branches/windows/source/Commands/CommandObjectBreakpoint.cpp Wed Apr 17 03:38:48 2013
@@ -189,7 +189,7 @@ public:
if (!success)
error.SetErrorStringWithFormat ("Invalid boolean value for on-catch option: '%s'", option_arg);
}
-
+ break;
case 'i':
{
m_ignore_count = Args::StringToUInt32(option_arg, UINT32_MAX, 0);
@@ -396,7 +396,7 @@ protected:
case eSetTypeFileAndLine: // Breakpoint by source position
{
FileSpec file;
- uint32_t num_files = m_options.m_filenames.GetSize();
+ const size_t num_files = m_options.m_filenames.GetSize();
if (num_files == 0)
{
if (!GetDefaultFile (target, file, result))
@@ -467,7 +467,7 @@ protected:
break;
case eSetTypeSourceRegexp: // Breakpoint by regexp on source text.
{
- int num_files = m_options.m_filenames.GetSize();
+ const size_t num_files = m_options.m_filenames.GetSize();
if (num_files == 0)
{
@@ -557,7 +557,7 @@ private:
// Then use the current stack frame's file.
if (!target->GetSourceManager().GetDefaultFileAndLine(file, default_line))
{
- StackFrame *cur_frame = m_interpreter.GetExecutionContext().GetFramePtr();
+ StackFrame *cur_frame = m_exe_ctx.GetFramePtr();
if (cur_frame == NULL)
{
result.AppendError ("No selected frame to use to find the default file.");
@@ -607,13 +607,13 @@ CommandObjectBreakpointSet::CommandOptio
"Set the number of times this breakpoint is skipped before stopping." },
{ LLDB_OPT_SET_ALL, false, "one-shot", 'o', no_argument, NULL, 0, eArgTypeNone,
- "The breakpoint is deleted the first time it stop causes a stop." },
+ "The breakpoint is deleted the first time it causes a stop." },
{ LLDB_OPT_SET_ALL, false, "condition", 'c', required_argument, NULL, 0, eArgTypeExpression,
"The breakpoint stops only if this condition expression evaluates to true."},
{ LLDB_OPT_SET_ALL, false, "thread-index", 'x', required_argument, NULL, 0, eArgTypeThreadIndex,
- "The breakpoint stops only for the thread whose index matches this argument."},
+ "The breakpoint stops only for the thread whose indeX matches this argument."},
{ LLDB_OPT_SET_ALL, false, "thread-id", 't', required_argument, NULL, 0, eArgTypeThreadID,
"The breakpoint stops only for the thread whose TID matches this argument."},
@@ -625,7 +625,10 @@ CommandObjectBreakpointSet::CommandOptio
"The breakpoint stops only for threads in the queue whose name is given by this argument."},
{ LLDB_OPT_FILE, false, "file", 'f', required_argument, NULL, CommandCompletions::eSourceFileCompletion, eArgTypeFilename,
- "Specifies the source file in which to set this breakpoint."},
+ "Specifies the source file in which to set this breakpoint. "
+ "Note, by default lldb only looks for files that are #included if they use the standard include file extensions. "
+ "To set breakpoints on .c/.cpp/.m/.mm files that are #included, set target.inline-breakpoint-strategy"
+ " to \"always\"."},
{ LLDB_OPT_SET_1, true, "line", 'l', required_argument, NULL, 0, eArgTypeLineNum,
"Specifies the line number on which to set this breakpoint."},
@@ -635,11 +638,11 @@ CommandObjectBreakpointSet::CommandOptio
// { 0, false, "column", 'C', required_argument, NULL, "<column>",
// "Set the breakpoint by source location at this particular column."},
- { LLDB_OPT_SET_2, true, "address", 'a', required_argument, NULL, 0, eArgTypeAddress,
+ { LLDB_OPT_SET_2, true, "address", 'a', required_argument, NULL, 0, eArgTypeAddressOrExpression,
"Set the breakpoint by address, at the specified address."},
{ LLDB_OPT_SET_3, true, "name", 'n', required_argument, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName,
- "Set the breakpoint by function name. Can be repeated multiple times to make one breakpoint for multiple snames" },
+ "Set the breakpoint by function name. Can be repeated multiple times to make one breakpoint for multiple names" },
{ LLDB_OPT_SET_4, true, "fullname", 'F', required_argument, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFullName,
"Set the breakpoint by fully qualified function names. For C++ this means namespaces and all arguments, and "
@@ -982,7 +985,7 @@ CommandObjectBreakpointModify::CommandOp
{
{ LLDB_OPT_SET_ALL, false, "ignore-count", 'i', required_argument, NULL, 0, eArgTypeCount, "Set the number of times this breakpoint is skipped before stopping." },
{ LLDB_OPT_SET_ALL, false, "one-shot", 'o', required_argument, NULL, 0, eArgTypeBoolean, "The breakpoint is deleted the first time it stop causes a stop." },
-{ LLDB_OPT_SET_ALL, false, "thread-index", 'x', required_argument, NULL, 0, eArgTypeThreadIndex, "The breakpoint stops only for the thread whose indeX matches this argument."},
+{ LLDB_OPT_SET_ALL, false, "thread-index", 'x', required_argument, NULL, 0, eArgTypeThreadIndex, "The breakpoint stops only for the thread whose index matches this argument."},
{ LLDB_OPT_SET_ALL, false, "thread-id", 't', required_argument, NULL, 0, eArgTypeThreadID, "The breakpoint stops only for the thread whose TID matches this argument."},
{ LLDB_OPT_SET_ALL, false, "thread-name", 'T', required_argument, NULL, 0, eArgTypeThreadName, "The breakpoint stops only for the thread whose thread name matches this argument."},
{ LLDB_OPT_SET_ALL, false, "queue-name", 'q', required_argument, NULL, 0, eArgTypeQueueName, "The breakpoint stops only for threads in the queue whose name is given by this argument."},
@@ -1106,10 +1109,30 @@ public:
"Disable the specified breakpoint(s) without removing it/them. If no breakpoints are specified, disable them all.",
NULL)
{
+ SetHelpLong(
+"Disable the specified breakpoint(s) without removing it/them. \n\
+If no breakpoints are specified, disable them all.\n\
+\n\
+Note: disabling a breakpoint will cause none of its locations to be hit\n\
+regardless of whether they are enabled or disabled. So the sequence: \n\
+\n\
+ (lldb) break disable 1\n\
+ (lldb) break enable 1.1\n\
+\n\
+will NOT cause location 1.1 to get hit. To achieve that, do:\n\
+\n\
+ (lldb) break disable 1.*\n\
+ (lldb) break enable 1.1\n\
+\n\
+The first command disables all the locations of breakpoint 1, \n\
+the second re-enables the first location."
+ );
+
CommandArgumentEntry arg;
CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange);
// Add the entry for the first argument for this command to the object's arguments vector.
- m_arguments.push_back (arg);
+ m_arguments.push_back (arg);
+
}
@@ -1647,7 +1670,7 @@ protected:
else
{
target->RemoveAllBreakpoints ();
- result.AppendMessageWithFormat ("All breakpoints removed. (%lu breakpoints)\n", num_breakpoints);
+ result.AppendMessageWithFormat ("All breakpoints removed. (%lu %s)\n", num_breakpoints, num_breakpoints > 1 ? "breakpoints" : "breakpoint");
}
result.SetStatus (eReturnStatusSuccessFinishNoResult);
}
@@ -1790,7 +1813,7 @@ CommandObjectMultiwordBreakpoint::Verify
Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
if (breakpoint != NULL)
{
- int num_locations = breakpoint->GetNumLocations();
+ const size_t num_locations = breakpoint->GetNumLocations();
if (cur_bp_id.GetLocationID() > num_locations)
{
StreamString id_str;
Modified: lldb/branches/windows/source/Commands/CommandObjectBreakpointCommand.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Commands/CommandObjectBreakpointCommand.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Commands/CommandObjectBreakpointCommand.cpp (original)
+++ lldb/branches/windows/source/Commands/CommandObjectBreakpointCommand.cpp Wed Apr 17 03:38:48 2013
@@ -534,6 +534,13 @@ protected:
if (result.Succeeded())
{
const size_t count = valid_bp_ids.GetSize();
+ if (count > 1)
+ {
+ result.AppendError ("can only add commands to one breakpoint at a time.");
+ result.SetStatus (eReturnStatusFailed);
+ return false;
+ }
+
for (size_t i = 0; i < count; ++i)
{
BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
Modified: lldb/branches/windows/source/Commands/CommandObjectCommands.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Commands/CommandObjectCommands.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Commands/CommandObjectCommands.cpp (original)
+++ lldb/branches/windows/source/Commands/CommandObjectCommands.cpp Wed Apr 17 03:38:48 2013
@@ -188,7 +188,7 @@ public:
return "";
}
- int
+ virtual int
HandleArgumentCompletion (Args &input,
int &cursor_index,
int &cursor_char_position,
@@ -285,7 +285,7 @@ protected:
bool
DoExecute(Args& command, CommandReturnObject &result)
{
- const int argc = command.GetArgumentCount();
+ const size_t argc = command.GetArgumentCount();
if (argc == 1)
{
const char *filename = command.GetArgumentAtIndex(0);
@@ -1289,7 +1289,7 @@ public:
{
}
- int
+ virtual int
HandleArgumentCompletion (Args &input,
int &cursor_index,
int &cursor_char_position,
Removed: lldb/branches/windows/source/Commands/CommandObjectCrossref.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Commands/CommandObjectCrossref.cpp?rev=179678&view=auto
==============================================================================
--- lldb/branches/windows/source/Commands/CommandObjectCrossref.cpp (original)
+++ lldb/branches/windows/source/Commands/CommandObjectCrossref.cpp (removed)
@@ -1,88 +0,0 @@
-//===-- CommandObjectCrossref.cpp -------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "lldb/Interpreter/CommandObjectCrossref.h"
-
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Interpreter/CommandReturnObject.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-//-------------------------------------------------------------------------
-// CommandObjectCrossref
-//-------------------------------------------------------------------------
-
-CommandObjectCrossref::CommandObjectCrossref
-(
- CommandInterpreter &interpreter,
- const char *name,
- const char *help,
- const char *syntax
-) :
- CommandObjectParsed (interpreter, name, help, syntax),
- m_crossref_object_types()
-{
-}
-
-CommandObjectCrossref::~CommandObjectCrossref ()
-{
-}
-
-bool
-CommandObjectCrossref::DoExecute (Args& command, CommandReturnObject &result)
-{
- if (m_crossref_object_types.GetArgumentCount() == 0)
- {
- result.AppendErrorWithFormat ("There are no objects for which you can call '%s'.\n", GetCommandName());
- result.SetStatus (eReturnStatusFailed);
- }
- else
- {
- GenerateHelpText (result);
- }
- return result.Succeeded();
-}
-
-void
-CommandObjectCrossref::AddObject (const char *obj_name)
-{
- m_crossref_object_types.AppendArgument (obj_name);
-}
-
-const char **
-CommandObjectCrossref::GetObjectTypes () const
-{
- return m_crossref_object_types.GetConstArgumentVector();
-}
-
-void
-CommandObjectCrossref::GenerateHelpText (CommandReturnObject &result)
-{
- result.AppendMessage ("This command can be called on the following types of objects:");
-
- const size_t count = m_crossref_object_types.GetArgumentCount();
- for (size_t i = 0; i < count; ++i)
- {
- const char *obj_name = m_crossref_object_types.GetArgumentAtIndex(i);
- result.AppendMessageWithFormat (" %s (e.g. '%s %s')\n", obj_name,
- obj_name, GetCommandName());
- }
-
- result.SetStatus (eReturnStatusSuccessFinishNoResult);
-}
-
-bool
-CommandObjectCrossref::IsCrossRefObject ()
-{
- return true;
-}
Modified: lldb/branches/windows/source/Commands/CommandObjectDisassemble.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Commands/CommandObjectDisassemble.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Commands/CommandObjectDisassemble.cpp (original)
+++ lldb/branches/windows/source/Commands/CommandObjectDisassemble.cpp Wed Apr 17 03:38:48 2013
@@ -17,6 +17,7 @@
// Project includes
#include "lldb/Core/AddressRange.h"
#include "lldb/Core/Disassembler.h"
+#include "lldb/Core/Module.h"
#include "lldb/Core/SourceManager.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/CommandCompletions.h"
@@ -46,8 +47,10 @@ CommandObjectDisassemble::CommandOptions
at_pc (false),
frame_line (false),
plugin_name (),
+ flavor_string(),
arch(),
- some_location_specified (false)
+ some_location_specified (false),
+ symbol_containing_addr ()
{
OptionParsingStarting();
}
@@ -125,6 +128,18 @@ CommandObjectDisassemble::CommandOptions
plugin_name.assign (option_arg);
break;
+ case 'F':
+ {
+ Target *target = m_interpreter.GetExecutionContext().GetTargetPtr();
+ if (target->GetArchitecture().GetTriple().getArch() == llvm::Triple::x86
+ || target->GetArchitecture().GetTriple().getArch() == llvm::Triple::x86_64)
+ {
+ flavor_string.assign (option_arg);
+ }
+ else
+ error.SetErrorStringWithFormat("Disassembler flavors are currently only supported for x86 and x86_64 targets.");
+ break;
+ }
case 'r':
raw = true;
break;
@@ -134,11 +149,22 @@ CommandObjectDisassemble::CommandOptions
some_location_specified = true;
break;
- case 'a':
+ case 'A':
if (!arch.SetTriple (option_arg, m_interpreter.GetPlatform (true).get()))
arch.SetTriple (option_arg);
break;
+ case 'a':
+ {
+ ExecutionContext exe_ctx (m_interpreter.GetExecutionContext());
+ symbol_containing_addr = Args::StringToAddress(&exe_ctx, option_arg, LLDB_INVALID_ADDRESS, &error);
+ if (symbol_containing_addr != LLDB_INVALID_ADDRESS)
+ {
+ some_location_specified = true;
+ }
+ }
+ break;
+
default:
error.SetErrorStringWithFormat("unrecognized short option '%c'", short_option);
break;
@@ -160,8 +186,29 @@ CommandObjectDisassemble::CommandOptions
frame_line = false;
start_addr = LLDB_INVALID_ADDRESS;
end_addr = LLDB_INVALID_ADDRESS;
+ symbol_containing_addr = LLDB_INVALID_ADDRESS;
raw = false;
plugin_name.clear();
+
+ Target *target = m_interpreter.GetExecutionContext().GetTargetPtr();
+
+ // This is a hack till we get the ability to specify features based on architecture. For now GetDisassemblyFlavor
+ // is really only valid for x86 (and for the llvm assembler plugin, but I'm papering over that since that is the
+ // only disassembler plugin we have...
+ if (target)
+ {
+ if (target->GetArchitecture().GetTriple().getArch() == llvm::Triple::x86
+ || target->GetArchitecture().GetTriple().getArch() == llvm::Triple::x86_64)
+ {
+ flavor_string.assign(target->GetDisassemblyFlavor());
+ }
+ else
+ flavor_string.assign ("default");
+
+ }
+ else
+ flavor_string.assign("default");
+
arch.Clear();
some_location_specified = false;
}
@@ -189,10 +236,13 @@ CommandObjectDisassemble::CommandOptions
{ LLDB_OPT_SET_ALL, false, "mixed" , 'm', no_argument , NULL, 0, eArgTypeNone, "Enable mixed source and assembly display."},
{ LLDB_OPT_SET_ALL, false, "raw" , 'r', no_argument , NULL, 0, eArgTypeNone, "Print raw disassembly with no symbol information."},
{ LLDB_OPT_SET_ALL, false, "plugin" , 'P', required_argument , NULL, 0, eArgTypePlugin, "Name of the disassembler plugin you want to use."},
-{ LLDB_OPT_SET_ALL, false, "arch" , 'a', required_argument , NULL, 0, eArgTypeArchitecture,"Specify the architecture to use from cross disassembly."},
+{ LLDB_OPT_SET_ALL, false, "flavor" , 'F', required_argument , NULL, 0, eArgTypeDisassemblyFlavor, "Name of the disassembly flavor you want to use. "
+ "Currently the only valid options are default, and for Intel"
+ " architectures, att and intel."},
+{ LLDB_OPT_SET_ALL, false, "arch" , 'A', required_argument , NULL, 0, eArgTypeArchitecture,"Specify the architecture to use from cross disassembly."},
{ LLDB_OPT_SET_1 |
- LLDB_OPT_SET_2 , true , "start-address", 's', required_argument , NULL, 0, eArgTypeStartAddress,"Address at which to start disassembling."},
-{ LLDB_OPT_SET_1 , false, "end-address" , 'e', required_argument , NULL, 0, eArgTypeEndAddress, "Address at which to end disassembling."},
+ LLDB_OPT_SET_2 , true , "start-address", 's', required_argument , NULL, 0, eArgTypeAddressOrExpression,"Address at which to start disassembling."},
+{ LLDB_OPT_SET_1 , false, "end-address" , 'e', required_argument , NULL, 0, eArgTypeAddressOrExpression, "Address at which to end disassembling."},
{ LLDB_OPT_SET_2 |
LLDB_OPT_SET_3 |
LLDB_OPT_SET_4 |
@@ -202,6 +252,7 @@ CommandObjectDisassemble::CommandOptions
{ LLDB_OPT_SET_4 , false, "frame" , 'f', no_argument , NULL, 0, eArgTypeNone, "Disassemble from the start of the current frame's function."},
{ LLDB_OPT_SET_5 , false, "pc" , 'p', no_argument , NULL, 0, eArgTypeNone, "Disassemble around the current pc."},
{ LLDB_OPT_SET_6 , false, "line" , 'l', no_argument , NULL, 0, eArgTypeNone, "Disassemble the current frame's current source line instructions if there debug line table information, else disasemble around the pc."},
+{ LLDB_OPT_SET_7 , false, "address" , 'a', required_argument , NULL, 0, eArgTypeAddressOrExpression, "Disassemble function containing this address."},
{ 0 , false, NULL , 0, 0 , NULL, 0, eArgTypeNone, NULL }
};
@@ -245,20 +296,26 @@ CommandObjectDisassemble::DoExecute (Arg
}
const char *plugin_name = m_options.GetPluginName ();
- DisassemblerSP disassembler = Disassembler::FindPlugin(m_options.arch, plugin_name);
+ const char *flavor_string = m_options.GetFlavorString();
+
+ DisassemblerSP disassembler = Disassembler::FindPlugin(m_options.arch, flavor_string, plugin_name);
if (!disassembler)
{
if (plugin_name)
- result.AppendErrorWithFormat ("Unable to find Disassembler plug-in named '%s' that supports the '%s' architecture.\n",
+ {
+ result.AppendErrorWithFormat ("Unable to find Disassembler plug-in named '%s' that supports the '%s' architecture.\n",
plugin_name,
m_options.arch.GetArchitectureName());
+ }
else
result.AppendErrorWithFormat ("Unable to find Disassembler plug-in for the '%s' architecture.\n",
m_options.arch.GetArchitectureName());
result.SetStatus (eReturnStatusFailed);
return false;
}
+ else if (flavor_string != NULL && !disassembler->FlavorValidForArchSpec(m_options.arch, flavor_string))
+ result.AppendWarningWithFormat("invalid disassembler flavor \"%s\", using default.\n", flavor_string);
result.SetStatus (eReturnStatusSuccessFinishResult);
@@ -273,7 +330,6 @@ CommandObjectDisassemble::DoExecute (Arg
if (m_options.show_mixed && m_options.num_lines_context == 0)
m_options.num_lines_context = 1;
- ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
// Always show the PC in the disassembly
uint32_t options = Disassembler::eOptionMarkPCAddress;
@@ -294,7 +350,8 @@ CommandObjectDisassemble::DoExecute (Arg
if (Disassembler::Disassemble (m_interpreter.GetDebugger(),
m_options.arch,
plugin_name,
- exe_ctx,
+ flavor_string,
+ m_exe_ctx,
name,
NULL, // Module *
m_options.num_instructions,
@@ -313,7 +370,7 @@ CommandObjectDisassemble::DoExecute (Arg
else
{
AddressRange range;
- StackFrame *frame = exe_ctx.GetFramePtr();
+ StackFrame *frame = m_exe_ctx.GetFramePtr();
if (m_options.frame_line)
{
if (frame == NULL)
@@ -384,9 +441,43 @@ CommandObjectDisassemble::DoExecute (Arg
range.SetByteSize (m_options.end_addr - m_options.start_addr);
}
}
+ else
+ {
+ if (m_options.symbol_containing_addr != LLDB_INVALID_ADDRESS
+ && target
+ && !target->GetSectionLoadList().IsEmpty())
+ {
+ bool failed = false;
+ Address symbol_containing_address;
+ if (target->GetSectionLoadList().ResolveLoadAddress (m_options.symbol_containing_addr, symbol_containing_address))
+ {
+ ModuleSP module_sp (symbol_containing_address.GetModule());
+ SymbolContext sc;
+ module_sp->ResolveSymbolContextForAddress (symbol_containing_address, eSymbolContextEverything, sc);
+ if (sc.function || sc.symbol)
+ {
+ sc.GetAddressRange (eSymbolContextFunction | eSymbolContextSymbol, 0, false, range);
+ }
+ else
+ {
+ failed = true;
+ }
+ }
+ else
+ {
+ failed = true;
+ }
+ if (failed)
+ {
+ result.AppendErrorWithFormat ("Could not find function bounds for address 0x%" PRIx64 "\n", m_options.symbol_containing_addr);
+ result.SetStatus (eReturnStatusFailed);
+ return false;
+ }
+ }
+ }
}
}
-
+
if (m_options.num_instructions != 0)
{
if (!range.GetBaseAddress().IsValid())
@@ -414,7 +505,8 @@ CommandObjectDisassemble::DoExecute (Arg
if (Disassembler::Disassemble (m_interpreter.GetDebugger(),
m_options.arch,
plugin_name,
- exe_ctx,
+ flavor_string,
+ m_exe_ctx,
range.GetBaseAddress(),
m_options.num_instructions,
m_options.show_mixed ? m_options.num_lines_context : 0,
@@ -460,7 +552,8 @@ CommandObjectDisassemble::DoExecute (Arg
if (Disassembler::Disassemble (m_interpreter.GetDebugger(),
m_options.arch,
plugin_name,
- exe_ctx,
+ flavor_string,
+ m_exe_ctx,
range,
m_options.num_instructions,
m_options.show_mixed ? m_options.num_lines_context : 0,
Modified: lldb/branches/windows/source/Commands/CommandObjectDisassemble.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Commands/CommandObjectDisassemble.h?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Commands/CommandObjectDisassemble.h (original)
+++ lldb/branches/windows/source/Commands/CommandObjectDisassemble.h Wed Apr 17 03:38:48 2013
@@ -53,6 +53,14 @@ public:
return plugin_name.c_str();
}
+ const char *
+ GetFlavorString ()
+ {
+ if (flavor_string.empty() || flavor_string == "default")
+ return NULL;
+ return flavor_string.c_str();
+ }
+
virtual Error
OptionParsingFinished ();
@@ -68,9 +76,11 @@ public:
bool at_pc;
bool frame_line;
std::string plugin_name;
+ std::string flavor_string;
ArchSpec arch;
bool some_location_specified; // If no location was specified, we'll select "at_pc". This should be set
// in SetOptionValue if anything the selects a location is set.
+ lldb::addr_t symbol_containing_addr;
static OptionDefinition g_option_table[];
};
Modified: lldb/branches/windows/source/Commands/CommandObjectExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Commands/CommandObjectExpression.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Commands/CommandObjectExpression.cpp (original)
+++ lldb/branches/windows/source/Commands/CommandObjectExpression.cpp Wed Apr 17 03:38:48 2013
@@ -53,10 +53,9 @@ OptionDefinition
CommandObjectExpression::CommandOptions::g_option_table[] =
{
{ LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "all-threads", 'a', required_argument, NULL, 0, eArgTypeBoolean, "Should we run all threads if the execution doesn't complete on one thread."},
- { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "dynamic-value", 'd', required_argument, NULL, 0, eArgTypeBoolean, "Upcast the value resulting from the expression to its dynamic type if available."},
+ { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "ignore-breakpoints", 'i', required_argument, NULL, 0, eArgTypeBoolean, "Ignore breakpoint hits while running expressions"},
{ LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "timeout", 't', required_argument, NULL, 0, eArgTypeUnsignedInteger, "Timeout value for running the expression."},
- { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "unwind-on-error", 'u', required_argument, NULL, 0, eArgTypeBoolean, "Clean up program state if the expression causes a crash, breakpoint hit or signal."},
- { LLDB_OPT_SET_2 , false, "object-description", 'O', no_argument, NULL, 0, eArgTypeNone, "Print the object description of the value resulting from the expression."},
+ { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "unwind-on-error", 'u', required_argument, NULL, 0, eArgTypeBoolean, "Clean up program state if the expression causes a crash, or raises a signal. Note, unlike gdb hitting a breakpoint is controlled by another option (-i)."},
};
@@ -96,27 +95,16 @@ CommandObjectExpression::CommandOptions:
}
break;
- case 'd':
+ case 'i':
{
bool success;
- bool result;
- result = Args::StringToBoolean(option_arg, true, &success);
- if (!success)
- error.SetErrorStringWithFormat("invalid dynamic value setting: \"%s\"", option_arg);
+ bool tmp_value = Args::StringToBoolean(option_arg, true, &success);
+ if (success)
+ ignore_breakpoints = tmp_value;
else
- {
- if (result)
- use_dynamic = eLazyBoolYes;
- else
- use_dynamic = eLazyBoolNo;
- }
+ error.SetErrorStringWithFormat("could not convert \"%s\" to a boolean value.", option_arg);
+ break;
}
- break;
-
- case 'O':
- print_object = true;
- break;
-
case 't':
{
bool success;
@@ -132,8 +120,10 @@ CommandObjectExpression::CommandOptions:
case 'u':
{
bool success;
- unwind_on_error = Args::StringToBoolean(option_arg, true, &success);
- if (!success)
+ bool tmp_value = Args::StringToBoolean(option_arg, true, &success);
+ if (success)
+ unwind_on_error = tmp_value;
+ else
error.SetErrorStringWithFormat("could not convert \"%s\" to a boolean value.", option_arg);
break;
}
@@ -148,10 +138,18 @@ CommandObjectExpression::CommandOptions:
void
CommandObjectExpression::CommandOptions::OptionParsingStarting (CommandInterpreter &interpreter)
{
- use_dynamic = eLazyBoolCalculate;
- print_object = false;
- unwind_on_error = true;
- show_types = true;
+ Process *process = interpreter.GetExecutionContext().GetProcessPtr();
+ if (process != NULL)
+ {
+ ignore_breakpoints = process->GetIgnoreBreakpointsInExpressions();
+ unwind_on_error = process->GetUnwindOnErrorInExpressions();
+ }
+ else
+ {
+ ignore_breakpoints = false;
+ unwind_on_error = true;
+ }
+
show_summary = true;
try_all_threads = true;
timeout = 0;
@@ -168,7 +166,7 @@ CommandObjectExpression::CommandObjectEx
"expression",
"Evaluate a C/ObjC/C++ expression in the current program context, using user defined variables and variables currently in scope.",
NULL,
- eFlagProcessMustBePaused),
+ eFlagProcessMustBePaused | eFlagTryTargetAPILock),
m_option_group (interpreter),
m_format_options (eFormatDefault),
m_command_options (),
@@ -212,6 +210,7 @@ Examples: \n\
// Add the "--format" and "--gdb-format"
m_option_group.Append (&m_format_options, OptionGroupFormat::OPTION_GROUP_FORMAT | OptionGroupFormat::OPTION_GROUP_GDB_FMT, LLDB_OPT_SET_1);
m_option_group.Append (&m_command_options);
+ m_option_group.Append (&m_varobj_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1 | LLDB_OPT_SET_2);
m_option_group.Finalize();
}
@@ -315,7 +314,12 @@ CommandObjectExpression::EvaluateExpress
CommandReturnObject *result
)
{
- Target *target = m_interpreter.GetExecutionContext().GetTargetPtr();
+ // Don't use m_exe_ctx as this might be called asynchronously
+ // after the command object DoExecute has finished when doing
+ // multi-line expression that use an input reader...
+ ExecutionContext exe_ctx (m_interpreter.GetExecutionContext());
+
+ Target *target = exe_ctx.GetTargetPtr();
if (!target)
target = Host::GetDummyTarget(m_interpreter.GetDebugger()).get();
@@ -327,40 +331,28 @@ CommandObjectExpression::EvaluateExpress
ExecutionResults exe_results;
bool keep_in_memory = true;
- lldb::DynamicValueType use_dynamic;
- // If use dynamic is not set, get it from the target:
- switch (m_command_options.use_dynamic)
- {
- case eLazyBoolCalculate:
- use_dynamic = target->GetPreferDynamicValue();
- break;
- case eLazyBoolYes:
- use_dynamic = lldb::eDynamicCanRunTarget;
- break;
- case eLazyBoolNo:
- use_dynamic = lldb::eNoDynamicValues;
- break;
- }
-
+
EvaluateExpressionOptions options;
- options.SetCoerceToId(m_command_options.print_object)
+ options.SetCoerceToId(m_varobj_options.use_objc)
.SetUnwindOnError(m_command_options.unwind_on_error)
+ .SetIgnoreBreakpoints (m_command_options.ignore_breakpoints)
.SetKeepInMemory(keep_in_memory)
- .SetUseDynamic(use_dynamic)
+ .SetUseDynamic(m_varobj_options.use_dynamic)
.SetRunOthers(m_command_options.try_all_threads)
.SetTimeoutUsec(m_command_options.timeout);
exe_results = target->EvaluateExpression (expr,
- m_interpreter.GetExecutionContext().GetFramePtr(),
+ exe_ctx.GetFramePtr(),
result_valobj_sp,
options);
- if (exe_results == eExecutionInterrupted && !m_command_options.unwind_on_error)
+ if ((exe_results == eExecutionInterrupted && !m_command_options.unwind_on_error)
+ ||(exe_results == eExecutionHitBreakpoint && !m_command_options.ignore_breakpoints))
{
uint32_t start_frame = 0;
uint32_t num_frames = 1;
uint32_t num_frames_with_source = 0;
- Thread *thread = m_interpreter.GetExecutionContext().GetThreadPtr();
+ Thread *thread = exe_ctx.GetThreadPtr();
if (thread)
{
thread->GetStatus (result->GetOutputStream(),
@@ -370,7 +362,7 @@ CommandObjectExpression::EvaluateExpress
}
else
{
- Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
+ Process *process = exe_ctx.GetProcessPtr();
if (process)
{
bool only_threads_with_stop_reason = true;
@@ -394,22 +386,8 @@ CommandObjectExpression::EvaluateExpress
if (format != eFormatDefault)
result_valobj_sp->SetFormat (format);
- ValueObject::DumpValueObjectOptions options;
- options.SetMaximumPointerDepth(0)
- .SetMaximumDepth(UINT32_MAX)
- .SetShowLocation(false)
- .SetShowTypes(m_command_options.show_types)
- .SetUseObjectiveC(m_command_options.print_object)
- .SetUseDynamicType(use_dynamic)
- .SetScopeChecked(true)
- .SetFlatOutput(false)
- .SetUseSyntheticValue(true)
- .SetIgnoreCap(false)
- .SetFormat(format)
- .SetSummary()
- .SetShowSummary(!m_command_options.print_object)
- .SetHideRootType(m_command_options.print_object);
-
+ ValueObject::DumpValueObjectOptions options(m_varobj_options.GetAsDumpOptions(true,format));
+
ValueObject::DumpValueObject (*(output_stream),
result_valobj_sp.get(), // Variable object to dump
options);
@@ -434,7 +412,7 @@ CommandObjectExpression::EvaluateExpress
const char *error_cstr = result_valobj_sp->GetError().AsCString();
if (error_cstr && error_cstr[0])
{
- int error_cstr_len = strlen (error_cstr);
+ const size_t error_cstr_len = strlen (error_cstr);
const bool ends_with_newline = error_cstr[error_cstr_len - 1] == '\n';
if (strstr(error_cstr, "error:") != error_cstr)
error_stream->PutCString ("error: ");
Modified: lldb/branches/windows/source/Commands/CommandObjectExpression.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Commands/CommandObjectExpression.h?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Commands/CommandObjectExpression.h (original)
+++ lldb/branches/windows/source/Commands/CommandObjectExpression.h Wed Apr 17 03:38:48 2013
@@ -16,6 +16,7 @@
// Project includes
#include "lldb/Interpreter/CommandObject.h"
#include "lldb/Interpreter/OptionGroupFormat.h"
+#include "lldb/Interpreter/OptionGroupValueObjectDisplay.h"
#include "lldb/Target/ExecutionContext.h"
namespace lldb_private {
@@ -50,9 +51,8 @@ public:
// Options table: Required for subclasses of Options.
static OptionDefinition g_option_table[];
- bool print_object;
- LazyBool use_dynamic;
bool unwind_on_error;
+ bool ignore_breakpoints;
bool show_types;
bool show_summary;
uint32_t timeout;
@@ -88,6 +88,7 @@ protected:
OptionGroupOptions m_option_group;
OptionGroupFormat m_format_options;
+ OptionGroupValueObjectDisplay m_varobj_options;
CommandOptions m_command_options;
uint32_t m_expr_line_count;
std::string m_expr_lines; // Multi-line expression support
Modified: lldb/branches/windows/source/Commands/CommandObjectFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Commands/CommandObjectFrame.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Commands/CommandObjectFrame.cpp (original)
+++ lldb/branches/windows/source/Commands/CommandObjectFrame.cpp Wed Apr 17 03:38:48 2013
@@ -16,7 +16,6 @@
#include <string>
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/DataVisualization.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/StreamFile.h"
@@ -25,6 +24,7 @@
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectVariable.h"
+#include "lldb/DataFormatters/DataVisualization.h"
#include "lldb/Host/Host.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/CommandInterpreter.h"
@@ -63,7 +63,10 @@ public:
"frame info",
"List information about the currently selected frame in the current thread.",
"frame info",
- eFlagProcessMustBeLaunched | eFlagProcessMustBePaused)
+ eFlagRequiresFrame |
+ eFlagTryTargetAPILock |
+ eFlagProcessMustBeLaunched |
+ eFlagProcessMustBePaused )
{
}
@@ -73,21 +76,10 @@ public:
protected:
bool
- DoExecute (Args& command,
- CommandReturnObject &result)
+ DoExecute (Args& command, CommandReturnObject &result)
{
- ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
- StackFrame *frame = exe_ctx.GetFramePtr();
- if (frame)
- {
- frame->DumpUsingSettingsFormat (&result.GetOutputStream());
+ m_exe_ctx.GetFrameRef().DumpUsingSettingsFormat (&result.GetOutputStream());
result.SetStatus (eReturnStatusSuccessFinishResult);
- }
- else
- {
- result.AppendError ("no current frame");
- result.SetStatus (eReturnStatusFailed);
- }
return result.Succeeded();
}
};
@@ -162,7 +154,10 @@ public:
"frame select",
"Select a frame by index from within the current thread and make it the current frame.",
NULL,
- eFlagProcessMustBeLaunched | eFlagProcessMustBePaused),
+ eFlagRequiresThread |
+ eFlagTryTargetAPILock |
+ eFlagProcessMustBeLaunched |
+ eFlagProcessMustBePaused ),
m_options (interpreter)
{
CommandArgumentEntry arg;
@@ -193,13 +188,11 @@ public:
protected:
bool
- DoExecute (Args& command,
- CommandReturnObject &result)
+ DoExecute (Args& command, CommandReturnObject &result)
{
- ExecutionContext exe_ctx (m_interpreter.GetExecutionContext());
- Thread *thread = exe_ctx.GetThreadPtr();
- if (thread)
- {
+ // No need to check "thread" for validity as eFlagRequiresThread ensures it is valid
+ Thread *thread = m_exe_ctx.GetThreadPtr();
+
uint32_t frame_idx = UINT32_MAX;
if (m_options.relative_frame_offset != INT32_MIN)
{
@@ -268,38 +261,19 @@ protected:
}
}
- const bool broadcast = true;
- bool success = thread->SetSelectedFrameByIndex (frame_idx, broadcast);
+ bool success = thread->SetSelectedFrameByIndexNoisily (frame_idx, result.GetOutputStream());
if (success)
{
- exe_ctx.SetFrameSP(thread->GetSelectedFrame ());
- StackFrame *frame = exe_ctx.GetFramePtr();
- if (frame)
- {
- bool already_shown = false;
- SymbolContext frame_sc(frame->GetSymbolContext(eSymbolContextLineEntry));
- if (m_interpreter.GetDebugger().GetUseExternalEditor() && frame_sc.line_entry.file && frame_sc.line_entry.line != 0)
- {
- already_shown = Host::OpenFileInExternalEditor (frame_sc.line_entry.file, frame_sc.line_entry.line);
- }
-
- bool show_frame_info = true;
- bool show_source = !already_shown;
- if (frame->GetStatus (result.GetOutputStream(), show_frame_info, show_source))
- {
+ m_exe_ctx.SetFrameSP(thread->GetSelectedFrame ());
result.SetStatus (eReturnStatusSuccessFinishResult);
- return result.Succeeded();
}
- }
- }
- result.AppendErrorWithFormat ("Frame index (%u) out of range.\n", frame_idx);
- }
else
{
- result.AppendError ("no current thread");
- }
+ result.AppendErrorWithFormat ("Frame index (%u) out of range.\n", frame_idx);
result.SetStatus (eReturnStatusFailed);
- return false;
+ }
+
+ return result.Succeeded();
}
protected:
@@ -331,7 +305,11 @@ public:
"Children of aggregate variables can be specified such as "
"'var->child.x'.",
NULL,
- eFlagProcessMustBeLaunched | eFlagProcessMustBePaused),
+ eFlagRequiresFrame |
+ eFlagTryTargetAPILock |
+ eFlagProcessMustBeLaunched |
+ eFlagProcessMustBePaused |
+ eFlagRequiresProcess),
m_option_group (interpreter),
m_option_variable(true), // Include the frame specific options by passing "true"
m_option_format (eFormatDefault),
@@ -372,14 +350,8 @@ protected:
virtual bool
DoExecute (Args& command, CommandReturnObject &result)
{
- ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
- StackFrame *frame = exe_ctx.GetFramePtr();
- if (frame == NULL)
- {
- result.AppendError ("you must be stopped in a valid stack frame to view frame variables.");
- result.SetStatus (eReturnStatusFailed);
- return false;
- }
+ // No need to check "frame" for validity as eFlagRequiresFrame ensures it is valid
+ StackFrame *frame = m_exe_ctx.GetFramePtr();
Stream &s = result.GetOutputStream();
@@ -402,22 +374,7 @@ protected:
else if (!m_option_variable.summary_string.IsCurrentValueEmpty())
summary_format_sp.reset(new StringSummaryFormat(TypeSummaryImpl::Flags(),m_option_variable.summary_string.GetCurrentValue()));
- ValueObject::DumpValueObjectOptions options;
-
- options.SetMaximumPointerDepth(m_varobj_options.ptr_depth)
- .SetMaximumDepth(m_varobj_options.max_depth)
- .SetShowTypes(m_varobj_options.show_types)
- .SetShowLocation(m_varobj_options.show_location)
- .SetUseObjectiveC(m_varobj_options.use_objc)
- .SetUseDynamicType(m_varobj_options.use_dynamic)
- .SetUseSyntheticValue(m_varobj_options.use_synth)
- .SetFlatOutput(m_varobj_options.flat_output)
- .SetOmitSummaryDepth(m_varobj_options.no_summary_depth)
- .SetIgnoreCap(m_varobj_options.ignore_cap)
- .SetSummary(summary_format_sp);
-
- if (m_varobj_options.be_raw)
- options.SetRawDisplay(true);
+ ValueObject::DumpValueObjectOptions options(m_varobj_options.GetAsDumpOptions(false,eFormatDefault,summary_format_sp));
if (variable_list)
{
@@ -434,7 +391,7 @@ protected:
{
if (m_option_variable.use_regex)
{
- const uint32_t regex_start_index = regex_var_list.GetSize();
+ const size_t regex_start_index = regex_var_list.GetSize();
RegularExpression regex (name_cstr);
if (regex.Compile(name_cstr))
{
@@ -444,7 +401,7 @@ protected:
num_matches);
if (num_new_regex_vars > 0)
{
- for (uint32_t regex_idx = regex_start_index, end_index = regex_var_list.GetSize();
+ for (size_t regex_idx = regex_start_index, end_index = regex_var_list.GetSize();
regex_idx < end_index;
++regex_idx)
{
@@ -527,10 +484,10 @@ protected:
}
else // No command arg specified. Use variable_list, instead.
{
- const uint32_t num_variables = variable_list->GetSize();
+ const size_t num_variables = variable_list->GetSize();
if (num_variables > 0)
{
- for (uint32_t i=0; i<num_variables; i++)
+ for (size_t i=0; i<num_variables; i++)
{
var_sp = variable_list->GetVariableAtIndex(i);
bool dump_variable = true;
Modified: lldb/branches/windows/source/Commands/CommandObjectHelp.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Commands/CommandObjectHelp.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Commands/CommandObjectHelp.cpp (original)
+++ lldb/branches/windows/source/Commands/CommandObjectHelp.cpp Wed Apr 17 03:38:48 2013
@@ -64,7 +64,7 @@ CommandObjectHelp::DoExecute (Args& comm
{
CommandObject::CommandMap::iterator pos;
CommandObject *cmd_obj;
- const int argc = command.GetArgumentCount ();
+ const size_t argc = command.GetArgumentCount ();
// 'help' doesn't take any arguments, other than command names. If argc is 0, we show the user
// all commands (aliases and user commands if asked for). Otherwise every argument must be the name of a command or a sub-command.
@@ -224,8 +224,8 @@ CommandObjectHelp::DoExecute (Args& comm
{
Stream &output_strm = result.GetOutputStream();
output_strm.Printf("Help requested with ambiguous command name, possible completions:\n");
- const uint32_t match_count = matches.GetSize();
- for (uint32_t i = 0; i < match_count; i++)
+ const size_t match_count = matches.GetSize();
+ for (size_t i = 0; i < match_count; i++)
{
output_strm.Printf("\t%s\n", matches.GetStringAtIndex(i));
}
Modified: lldb/branches/windows/source/Commands/CommandObjectMemory.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Commands/CommandObjectMemory.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Commands/CommandObjectMemory.cpp (original)
+++ lldb/branches/windows/source/Commands/CommandObjectMemory.cpp Wed Apr 17 03:38:48 2013
@@ -221,6 +221,14 @@ public:
if (!count_option_set)
format_options.GetCountValue() = 8;
break;
+ case eFormatComplexInteger:
+ if (!byte_size_option_set)
+ byte_size_value = 8;
+ if (!num_per_line_option_set)
+ m_num_per_line = 1;
+ if (!count_option_set)
+ format_options.GetCountValue() = 8;
+ break;
case eFormatHex:
if (!byte_size_option_set)
byte_size_value = 4;
@@ -298,7 +306,7 @@ public:
"memory read",
"Read from the memory of the process being debugged.",
NULL,
- eFlagProcessMustBePaused),
+ eFlagRequiresTarget | eFlagProcessMustBePaused),
m_option_group (interpreter),
m_format_options (eFormatBytesWithASCII, 1, 8),
m_memory_options (),
@@ -317,14 +325,14 @@ public:
CommandArgumentData end_addr_arg;
// Define the first (and only) variant of this arg.
- start_addr_arg.arg_type = eArgTypeStartAddress;
+ start_addr_arg.arg_type = eArgTypeAddressOrExpression;
start_addr_arg.arg_repetition = eArgRepeatPlain;
// There is only one variant this argument could be; put it into the argument entry.
arg1.push_back (start_addr_arg);
// Define the first (and only) variant of this arg.
- end_addr_arg.arg_type = eArgTypeEndAddress;
+ end_addr_arg.arg_type = eArgTypeAddressOrExpression;
end_addr_arg.arg_repetition = eArgRepeatOptional;
// There is only one variant this argument could be; put it into the argument entry.
@@ -371,17 +379,11 @@ protected:
virtual bool
DoExecute (Args& command, CommandReturnObject &result)
{
- ExecutionContext exe_ctx (m_interpreter.GetExecutionContext());
- Target *target = exe_ctx.GetTargetPtr();
- if (target == NULL)
- {
- result.AppendError("need at least a target to read memory");
- result.SetStatus(eReturnStatusFailed);
- return false;
- }
+ // No need to check "target" for validity as eFlagRequiresTarget ensures it is valid
+ Target *target = m_exe_ctx.GetTargetPtr();
+
const size_t argc = command.GetArgumentCount();
-
if ((argc == 0 && m_next_addr == LLDB_INVALID_ADDRESS) || argc > 2)
{
result.AppendErrorWithFormat ("%s takes a start address expression with an optional end address expression.\n", m_cmd_name.c_str());
@@ -496,7 +498,7 @@ protected:
}
ConstString lookup_type_name(type_str.c_str());
- StackFrame *frame = exe_ctx.GetFramePtr();
+ StackFrame *frame = m_exe_ctx.GetFramePtr();
if (frame)
{
sc = frame->GetSymbolContext (eSymbolContextModule);
@@ -544,7 +546,7 @@ protected:
--pointer_count;
}
- m_format_options.GetByteSizeValue() = (clang_ast_type.GetClangTypeBitWidth () + 7) / 8;
+ m_format_options.GetByteSizeValue() = clang_ast_type.GetClangTypeByteSize();
if (m_format_options.GetByteSizeValue() == 0)
{
@@ -592,7 +594,7 @@ protected:
}
size_t item_count = m_format_options.GetCountValue().GetCurrentValue();
- const size_t item_byte_size = m_format_options.GetByteSizeValue().GetCurrentValue();
+ size_t item_byte_size = m_format_options.GetByteSizeValue().GetCurrentValue();
const size_t num_per_line = m_memory_options.m_num_per_line.GetCurrentValue();
if (total_byte_size == 0)
@@ -603,7 +605,7 @@ protected:
}
if (argc > 0)
- addr = Args::StringToAddress(&exe_ctx, command.GetArgumentAtIndex(0), LLDB_INVALID_ADDRESS, &error);
+ addr = Args::StringToAddress(&m_exe_ctx, command.GetArgumentAtIndex(0), LLDB_INVALID_ADDRESS, &error);
if (addr == LLDB_INVALID_ADDRESS)
{
@@ -615,7 +617,7 @@ protected:
if (argc == 2)
{
- lldb::addr_t end_addr = Args::StringToAddress(&exe_ctx, command.GetArgumentAtIndex(1), LLDB_INVALID_ADDRESS, 0);
+ lldb::addr_t end_addr = Args::StringToAddress(&m_exe_ctx, command.GetArgumentAtIndex(1), LLDB_INVALID_ADDRESS, 0);
if (end_addr == LLDB_INVALID_ADDRESS)
{
result.AppendError("invalid end address expression.");
@@ -647,6 +649,8 @@ protected:
return false;
}
+
+
DataBufferSP data_sp;
size_t bytes_read = 0;
if (clang_ast_type.GetOpaqueQualType())
@@ -657,7 +661,7 @@ protected:
bytes_read = clang_ast_type.GetTypeByteSize() * m_format_options.GetCountValue().GetCurrentValue();
}
- else
+ else if (m_format_options.GetFormatValue().GetCurrentValue() != eFormatCString)
{
data_sp.reset (new DataBufferHeap (total_byte_size, '\0'));
Address address(addr, NULL);
@@ -678,7 +682,47 @@ protected:
}
if (bytes_read < total_byte_size)
- result.AppendWarningWithFormat("Not all bytes (%lu/%lu) were able to be read from 0x%" PRIx64 ".", bytes_read, total_byte_size, addr);
+ result.AppendWarningWithFormat("Not all bytes (%lu/%lu) were able to be read from 0x%" PRIx64 ".\n", bytes_read, total_byte_size, addr);
+ }
+ else
+ {
+ // we treat c-strings as a special case because they do not have a fixed size
+ if (m_format_options.GetByteSizeValue().OptionWasSet() && !m_format_options.HasGDBFormat())
+ item_byte_size = m_format_options.GetByteSizeValue().GetCurrentValue();
+ else
+ item_byte_size = target->GetMaximumSizeOfStringSummary();
+ if (!m_format_options.GetCountValue().OptionWasSet())
+ item_count = 1;
+ data_sp.reset (new DataBufferHeap ((item_byte_size+1) * item_count, '\0')); // account for NULLs as necessary
+ uint8_t *data_ptr = data_sp->GetBytes();
+ auto data_addr = addr;
+ auto count = item_count;
+ item_count = 0;
+ while (item_count < count)
+ {
+ std::string buffer;
+ buffer.resize(item_byte_size+1,0);
+ Error error;
+ size_t read = target->ReadCStringFromMemory(data_addr, &buffer[0], item_byte_size+1, error);
+ if (error.Fail())
+ {
+ result.AppendErrorWithFormat("failed to read memory from 0x%" PRIx64 ".\n", addr);
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+ if (item_byte_size == read)
+ {
+ result.AppendWarningWithFormat("unable to find a NULL terminated string at 0x%" PRIx64 ".Consider increasing the maximum read length.\n", data_addr);
+ break;
+ }
+ read+=1; // account for final NULL byte
+ memcpy(data_ptr, &buffer[0], read);
+ data_ptr += read;
+ data_addr += read;
+ bytes_read += read;
+ item_count++; // if we break early we know we only read item_count strings
+ }
+ data_sp.reset(new DataBufferHeap(data_sp->GetBytes(),bytes_read+1));
}
m_next_addr = addr + bytes_read;
@@ -706,10 +750,10 @@ protected:
{
if (m_memory_options.m_output_as_binary)
{
- int bytes_written = outfile_stream.Write (data_sp->GetBytes(), bytes_read);
+ const size_t bytes_written = outfile_stream.Write (data_sp->GetBytes(), bytes_read);
if (bytes_written > 0)
{
- result.GetOutputStream().Printf ("%i bytes %s to '%s'\n",
+ result.GetOutputStream().Printf ("%zi bytes %s to '%s'\n",
bytes_written,
append ? "appended" : "written",
path);
@@ -742,7 +786,7 @@ protected:
}
- ExecutionContextScope *exe_scope = exe_ctx.GetBestExecutionContextScope();
+ ExecutionContextScope *exe_scope = m_exe_ctx.GetBestExecutionContextScope();
if (clang_ast_type.GetOpaqueQualType())
{
for (uint32_t i = 0; i<item_count; ++i)
@@ -761,21 +805,8 @@ protected:
if (format != eFormatDefault)
valobj_sp->SetFormat (format);
- bool scope_already_checked = true;
+ ValueObject::DumpValueObjectOptions options(m_varobj_options.GetAsDumpOptions(false,format));
- ValueObject::DumpValueObjectOptions options;
- options.SetMaximumPointerDepth(m_varobj_options.ptr_depth)
- .SetMaximumDepth(m_varobj_options.max_depth)
- .SetShowLocation(m_varobj_options.show_location)
- .SetShowTypes(m_varobj_options.show_types)
- .SetUseObjectiveC(m_varobj_options.use_objc)
- .SetScopeChecked(scope_already_checked)
- .SetFlatOutput(m_varobj_options.flat_output)
- .SetUseSyntheticValue(m_varobj_options.be_raw ? false : m_varobj_options.use_synth)
- .SetOmitSummaryDepth(m_varobj_options.be_raw ? UINT32_MAX : m_varobj_options.no_summary_depth)
- .SetIgnoreCap(m_varobj_options.be_raw ? true : m_varobj_options.ignore_cap)
- .SetFormat(format)
- .SetSummary();
ValueObject::DumpValueObject (*output_stream,
valobj_sp.get(),
options);
@@ -799,16 +830,16 @@ protected:
assert (output_stream);
- uint32_t bytes_dumped = data.Dump (output_stream,
- 0,
- m_format_options.GetFormat(),
- item_byte_size,
- item_count,
- num_per_line,
- addr,
- 0,
- 0,
- exe_scope);
+ size_t bytes_dumped = data.Dump (output_stream,
+ 0,
+ m_format_options.GetFormat(),
+ item_byte_size,
+ item_count,
+ num_per_line,
+ addr,
+ 0,
+ 0,
+ exe_scope);
m_next_addr = addr + bytes_dumped;
output_stream->EOL();
return true;
@@ -922,7 +953,7 @@ public:
"memory write",
"Write to the memory of the process being debugged.",
NULL,
- eFlagProcessMustBeLaunched),
+ eFlagRequiresProcess | eFlagProcessMustBeLaunched),
m_option_group (interpreter),
m_format_options (eFormatBytes, 1, UINT64_MAX),
m_memory_options ()
@@ -999,14 +1030,8 @@ protected:
virtual bool
DoExecute (Args& command, CommandReturnObject &result)
{
- ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
- Process *process = exe_ctx.GetProcessPtr();
- if (process == NULL)
- {
- result.AppendError("need a process to read memory");
- result.SetStatus(eReturnStatusFailed);
- return false;
- }
+ // No need to check "process" for validity as eFlagRequiresProcess ensures it is valid
+ Process *process = m_exe_ctx.GetProcessPtr();
const size_t argc = command.GetArgumentCount();
@@ -1034,7 +1059,7 @@ protected:
size_t item_byte_size = byte_size_value.GetCurrentValue();
Error error;
- lldb::addr_t addr = Args::StringToAddress (&exe_ctx,
+ lldb::addr_t addr = Args::StringToAddress (&m_exe_ctx,
command.GetArgumentAtIndex(0),
LLDB_INVALID_ADDRESS,
&error);
@@ -1099,9 +1124,8 @@ protected:
uint64_t uval64;
int64_t sval64;
bool success = false;
- const uint32_t num_value_args = command.GetArgumentCount();
- uint32_t i;
- for (i=0; i<num_value_args; ++i)
+ const size_t num_value_args = command.GetArgumentCount();
+ for (size_t i=0; i<num_value_args; ++i)
{
const char *value_str = command.GetArgumentAtIndex(i);
Modified: lldb/branches/windows/source/Commands/CommandObjectMultiword.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Commands/CommandObjectMultiword.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Commands/CommandObjectMultiword.cpp (original)
+++ lldb/branches/windows/source/Commands/CommandObjectMultiword.cpp Wed Apr 17 03:38:48 2013
@@ -34,7 +34,8 @@ CommandObjectMultiword::CommandObjectMul
const char *syntax,
uint32_t flags
) :
- CommandObject (interpreter, name, help, syntax, flags)
+ CommandObject (interpreter, name, help, syntax, flags),
+ m_can_be_removed(false)
{
}
@@ -100,7 +101,6 @@ CommandObjectMultiword::LoadSubCommand
if (pos == m_subcommand_dict.end())
{
m_subcommand_dict[name] = cmd_obj;
- m_interpreter.CrossRegisterCommand (name, GetCommandName());
}
else
success = false;
@@ -143,7 +143,7 @@ CommandObjectMultiword::Execute(const ch
else
{
std::string error_msg;
- int num_subcmd_matches = matches.GetSize();
+ const size_t num_subcmd_matches = matches.GetSize();
if (num_subcmd_matches > 0)
error_msg.assign ("ambiguous command ");
else
@@ -158,14 +158,14 @@ CommandObjectMultiword::Execute(const ch
if (num_subcmd_matches > 0)
{
error_msg.append (" Possible completions:");
- for (int i = 0; i < num_subcmd_matches; i++)
+ for (size_t i = 0; i < num_subcmd_matches; i++)
{
error_msg.append ("\n\t");
error_msg.append (matches.GetStringAtIndex (i));
}
}
error_msg.append ("\n");
- result.AppendRawError (error_msg.c_str(), error_msg.size());
+ result.AppendRawError (error_msg.c_str());
result.SetStatus (eReturnStatusFailed);
}
}
@@ -364,23 +364,6 @@ CommandObjectProxy::GetHelpLong ()
return NULL;
}
-void
-CommandObjectProxy::AddObject (const char *obj_name)
-{
- CommandObject *proxy_command = GetProxyCommandObject();
- if (proxy_command)
- return proxy_command->AddObject (obj_name);
-}
-
-bool
-CommandObjectProxy::IsCrossRefObject ()
-{
- CommandObject *proxy_command = GetProxyCommandObject();
- if (proxy_command)
- return proxy_command->IsCrossRefObject();
- return false;
-}
-
bool
CommandObjectProxy::IsRemovable() const
{
Modified: lldb/branches/windows/source/Commands/CommandObjectPlatform.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Commands/CommandObjectPlatform.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Commands/CommandObjectPlatform.cpp (original)
+++ lldb/branches/windows/source/Commands/CommandObjectPlatform.cpp Wed Apr 17 03:38:48 2013
@@ -207,7 +207,16 @@ protected:
{
Stream &ostrm = result.GetOutputStream();
- PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
+ Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+ PlatformSP platform_sp;
+ if (target)
+ {
+ platform_sp = target->GetPlatform();
+ }
+ if (!platform_sp)
+ {
+ platform_sp = m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform();
+ }
if (platform_sp)
{
platform_sp->GetStatus (ostrm);
@@ -357,11 +366,11 @@ class CommandObjectPlatformProcessLaunch
{
public:
CommandObjectPlatformProcessLaunch (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
+ CommandObjectParsed (interpreter,
"platform process launch",
"Launch a new process on a remote platform.",
"platform process launch program",
- 0),
+ eFlagRequiresTarget | eFlagTryTargetAPILock),
m_options (interpreter)
{
}
@@ -381,20 +390,22 @@ protected:
virtual bool
DoExecute (Args& args, CommandReturnObject &result)
{
- PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
-
+ Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+ PlatformSP platform_sp;
+ if (target)
+ {
+ platform_sp = target->GetPlatform();
+ }
+ if (!platform_sp)
+ {
+ platform_sp = m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform();
+ }
+
if (platform_sp)
{
Error error;
- const uint32_t argc = args.GetArgumentCount();
- Target *target = m_interpreter.GetExecutionContext().GetTargetPtr();
- if (target == NULL)
- {
- result.AppendError ("invalid target, create a debug target using the 'target create' command");
- result.SetStatus (eReturnStatusFailed);
- return false;
- }
-
+ const size_t argc = args.GetArgumentCount();
+ Target *target = m_exe_ctx.GetTargetPtr();
Module *exe_module = target->GetExecutableModulePointer();
if (exe_module)
{
@@ -497,7 +508,16 @@ protected:
virtual bool
DoExecute (Args& args, CommandReturnObject &result)
{
- PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
+ Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+ PlatformSP platform_sp;
+ if (target)
+ {
+ platform_sp = target->GetPlatform();
+ }
+ if (!platform_sp)
+ {
+ platform_sp = m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform();
+ }
if (platform_sp)
{
@@ -777,7 +797,17 @@ protected:
virtual bool
DoExecute (Args& args, CommandReturnObject &result)
{
- PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
+ Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+ PlatformSP platform_sp;
+ if (target)
+ {
+ platform_sp = target->GetPlatform();
+ }
+ if (!platform_sp)
+ {
+ platform_sp = m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform();
+ }
+
if (platform_sp)
{
const size_t argc = args.GetArgumentCount();
Modified: lldb/branches/windows/source/Commands/CommandObjectProcess.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Commands/CommandObjectProcess.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Commands/CommandObjectProcess.cpp (original)
+++ lldb/branches/windows/source/Commands/CommandObjectProcess.cpp Wed Apr 17 03:38:48 2013
@@ -34,19 +34,95 @@
using namespace lldb;
using namespace lldb_private;
+class CommandObjectProcessLaunchOrAttach : public CommandObjectParsed
+{
+public:
+ CommandObjectProcessLaunchOrAttach (CommandInterpreter &interpreter,
+ const char *name,
+ const char *help,
+ const char *syntax,
+ uint32_t flags,
+ const char *new_process_action) :
+ CommandObjectParsed (interpreter, name, help, syntax, flags),
+ m_new_process_action (new_process_action) {}
+
+ virtual ~CommandObjectProcessLaunchOrAttach () {}
+protected:
+ bool
+ StopProcessIfNecessary (Process *&process, StateType &state, CommandReturnObject &result)
+ {
+ state = eStateInvalid;
+ if (process)
+ {
+ state = process->GetState();
+
+ if (process->IsAlive() && state != eStateConnected)
+ {
+ char message[1024];
+ if (process->GetState() == eStateAttaching)
+ ::snprintf (message, sizeof(message), "There is a pending attach, abort it and %s?", m_new_process_action.c_str());
+ else if (process->GetShouldDetach())
+ ::snprintf (message, sizeof(message), "There is a running process, detach from it and %s?", m_new_process_action.c_str());
+ else
+ ::snprintf (message, sizeof(message), "There is a running process, kill it and %s?", m_new_process_action.c_str());
+
+ if (!m_interpreter.Confirm (message, true))
+ {
+ result.SetStatus (eReturnStatusFailed);
+ return false;
+ }
+ else
+ {
+ if (process->GetShouldDetach())
+ {
+ Error detach_error (process->Detach());
+ if (detach_error.Success())
+ {
+ result.SetStatus (eReturnStatusSuccessFinishResult);
+ process = NULL;
+ }
+ else
+ {
+ result.AppendErrorWithFormat ("Failed to detach from process: %s\n", detach_error.AsCString());
+ result.SetStatus (eReturnStatusFailed);
+ }
+ }
+ else
+ {
+ Error destroy_error (process->Destroy());
+ if (destroy_error.Success())
+ {
+ result.SetStatus (eReturnStatusSuccessFinishResult);
+ process = NULL;
+ }
+ else
+ {
+ result.AppendErrorWithFormat ("Failed to kill process: %s\n", destroy_error.AsCString());
+ result.SetStatus (eReturnStatusFailed);
+ }
+ }
+ }
+ }
+ }
+ return result.Succeeded();
+ }
+ std::string m_new_process_action;
+};
//-------------------------------------------------------------------------
// CommandObjectProcessLaunch
//-------------------------------------------------------------------------
#pragma mark CommandObjectProcessLaunch
-class CommandObjectProcessLaunch : public CommandObjectParsed
+class CommandObjectProcessLaunch : public CommandObjectProcessLaunchOrAttach
{
public:
CommandObjectProcessLaunch (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "process launch",
- "Launch the executable in the debugger.",
- NULL),
+ CommandObjectProcessLaunchOrAttach (interpreter,
+ "process launch",
+ "Launch the executable in the debugger.",
+ NULL,
+ eFlagRequiresTarget,
+ "restart"),
m_options (interpreter)
{
CommandArgumentEntry arg;
@@ -68,7 +144,7 @@ public:
{
}
- int
+ virtual int
HandleArgumentCompletion (Args &input,
int &cursor_index,
int &cursor_char_position,
@@ -111,13 +187,6 @@ protected:
Debugger &debugger = m_interpreter.GetDebugger();
Target *target = debugger.GetSelectedTarget().get();
Error error;
-
- if (target == NULL)
- {
- result.AppendError ("invalid target, create a debug target using the 'target create' command");
- result.SetStatus (eReturnStatusFailed);
- return false;
- }
// If our listener is NULL, users aren't allows to launch
char filename[PATH_MAX];
const Module *exe_module = target->GetExecutableModulePointer();
@@ -130,39 +199,10 @@ protected:
}
StateType state = eStateInvalid;
- Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
- if (process)
- {
- state = process->GetState();
-
- if (process->IsAlive() && state != eStateConnected)
- {
- char message[1024];
- if (process->GetState() == eStateAttaching)
- ::strncpy (message, "There is a pending attach, abort it and launch a new process?", sizeof(message));
- else
- ::strncpy (message, "There is a running process, kill it and restart?", sizeof(message));
+ Process *process = m_exe_ctx.GetProcessPtr();
- if (!m_interpreter.Confirm (message, true))
- {
- result.SetStatus (eReturnStatusFailed);
- return false;
- }
- else
- {
- Error destroy_error (process->Destroy());
- if (destroy_error.Success())
- {
- result.SetStatus (eReturnStatusSuccessFinishResult);
- }
- else
- {
- result.AppendErrorWithFormat ("Failed to kill process: %s\n", destroy_error.AsCString());
- result.SetStatus (eReturnStatusFailed);
- }
- }
- }
- }
+ if (!StopProcessIfNecessary(process, state, result))
+ return false;
const char *target_settings_argv0 = target->GetArg0();
@@ -205,6 +245,11 @@ protected:
if (environment.GetArgumentCount() > 0)
m_options.launch_info.GetEnvironmentEntries ().AppendArguments (environment);
+ // Get the value of synchronous execution here. If you wait till after you have started to
+ // run, then you could have hit a breakpoint, whose command might switch the value, and
+ // then you'll pick up that incorrect value.
+ bool synchronous_execution = m_interpreter.GetSynchronous ();
+
// Finalize the file actions, and if none were given, default to opening
// up a pseudo terminal
const bool default_to_use_pty = true;
@@ -218,35 +263,34 @@ protected:
m_options.launch_info.GetFlags().Clear (eLaunchFlagLaunchInTTY);
}
}
+
+ if (!m_options.launch_info.GetArchitecture().IsValid())
+ m_options.launch_info.GetArchitecture() = target->GetArchitecture();
+
+ PlatformSP platform_sp (target->GetPlatform());
+
+ if (platform_sp && platform_sp->CanDebugProcess ())
+ {
+ process = target->GetPlatform()->DebugProcess (m_options.launch_info,
+ debugger,
+ target,
+ debugger.GetListener(),
+ error).get();
+ }
else
{
- if (!m_options.launch_info.GetArchitecture().IsValid())
- m_options.launch_info.GetArchitecture() = target->GetArchitecture();
-
- PlatformSP platform_sp (target->GetPlatform());
-
- if (platform_sp && platform_sp->CanDebugProcess ())
- {
- process = target->GetPlatform()->DebugProcess (m_options.launch_info,
- debugger,
- target,
- debugger.GetListener(),
- error).get();
- }
- else
- {
- const char *plugin_name = m_options.launch_info.GetProcessPluginName();
- process = target->CreateProcess (debugger.GetListener(), plugin_name, NULL).get();
- if (process)
- error = process->Launch (m_options.launch_info);
- }
+ const char *plugin_name = m_options.launch_info.GetProcessPluginName();
+ process = target->CreateProcess (debugger.GetListener(), plugin_name, NULL).get();
+ if (process)
+ error = process->Launch (m_options.launch_info);
+ }
- if (process == NULL)
- {
- result.SetError (error, "failed to launch or debug process");
- return false;
- }
+ if (process == NULL)
+ {
+ result.SetError (error, "failed to launch or debug process");
+ return false;
}
+
if (error.Success())
{
@@ -264,7 +308,6 @@ protected:
error = process->Resume();
if (error.Success())
{
- bool synchronous_execution = m_interpreter.GetSynchronous ();
if (synchronous_execution)
{
state = process->WaitForProcessToStop (NULL);
@@ -334,7 +377,7 @@ protected:
// CommandObjectProcessAttach
//-------------------------------------------------------------------------
#pragma mark CommandObjectProcessAttach
-class CommandObjectProcessAttach : public CommandObjectParsed
+class CommandObjectProcessAttach : public CommandObjectProcessLaunchOrAttach
{
public:
@@ -452,10 +495,10 @@ public:
match_info.SetNameMatchType(eNameMatchStartsWith);
}
platform_sp->FindProcesses (match_info, process_infos);
- const uint32_t num_matches = process_infos.GetSize();
+ const size_t num_matches = process_infos.GetSize();
if (num_matches > 0)
{
- for (uint32_t i=0; i<num_matches; ++i)
+ for (size_t i=0; i<num_matches; ++i)
{
matches.AppendString (process_infos.GetProcessNameAtIndex(i),
process_infos.GetProcessNameLengthAtIndex(i));
@@ -477,10 +520,12 @@ public:
};
CommandObjectProcessAttach (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "process attach",
- "Attach to a process.",
- "process attach <cmd-options>"),
+ CommandObjectProcessLaunchOrAttach (interpreter,
+ "process attach",
+ "Attach to a process.",
+ "process attach <cmd-options>",
+ 0,
+ "attach"),
m_options (interpreter)
{
}
@@ -505,20 +550,12 @@ protected:
// and the target actually stopping. So even if the interpreter is set to be asynchronous, we wait for the stop
// ourselves here.
- Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
StateType state = eStateInvalid;
- if (process)
- {
- state = process->GetState();
- if (process->IsAlive() && state != eStateConnected)
- {
- result.AppendErrorWithFormat ("Process %" PRIu64 " is currently being debugged, kill the process before attaching.\n",
- process->GetID());
- result.SetStatus (eReturnStatusFailed);
- return false;
- }
- }
-
+ Process *process = m_exe_ctx.GetProcessPtr();
+
+ if (!StopProcessIfNecessary (process, state, result))
+ return false;
+
if (target == NULL)
{
// If there isn't a current target create one.
@@ -686,7 +723,10 @@ public:
"process continue",
"Continue execution of all threads in the current process.",
"process continue",
- eFlagProcessMustBeLaunched | eFlagProcessMustBePaused),
+ eFlagRequiresProcess |
+ eFlagTryTargetAPILock |
+ eFlagProcessMustBeLaunched |
+ eFlagProcessMustBePaused ),
m_options(interpreter)
{
}
@@ -754,19 +794,10 @@ protected:
};
bool
- DoExecute (Args& command,
- CommandReturnObject &result)
+ DoExecute (Args& command, CommandReturnObject &result)
{
- Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
+ Process *process = m_exe_ctx.GetProcessPtr();
bool synchronous_execution = m_interpreter.GetSynchronous ();
-
- if (process == NULL)
- {
- result.AppendError ("no process to continue");
- result.SetStatus (eReturnStatusFailed);
- return false;
- }
-
StateType state = process->GetState();
if (state == eStateStopped)
{
@@ -785,12 +816,12 @@ protected:
StopInfoSP stop_info_sp = sel_thread_sp->GetStopInfo();
if (stop_info_sp && stop_info_sp->GetStopReason() == eStopReasonBreakpoint)
{
- uint64_t bp_site_id = stop_info_sp->GetValue();
+ lldb::break_id_t bp_site_id = (lldb::break_id_t)stop_info_sp->GetValue();
BreakpointSiteSP bp_site_sp(process->GetBreakpointSiteList().FindByID(bp_site_id));
if (bp_site_sp)
{
- uint32_t num_owners = bp_site_sp->GetNumberOfOwners();
- for (uint32_t i = 0; i < num_owners; i++)
+ const size_t num_owners = bp_site_sp->GetNumberOfOwners();
+ for (size_t i = 0; i < num_owners; i++)
{
Breakpoint &bp_ref = bp_site_sp->GetOwnerAtIndex(i)->GetBreakpoint();
if (!bp_ref.IsInternal())
@@ -878,6 +909,8 @@ public:
"process detach",
"Detach from the current process being debugged.",
"process detach",
+ eFlagRequiresProcess |
+ eFlagTryTargetAPILock |
eFlagProcessMustBeLaunched)
{
}
@@ -888,17 +921,9 @@ public:
protected:
bool
- DoExecute (Args& command,
- CommandReturnObject &result)
+ DoExecute (Args& command, CommandReturnObject &result)
{
- Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
- if (process == NULL)
- {
- result.AppendError ("must have a valid process in order to detach");
- result.SetStatus (eReturnStatusFailed);
- return false;
- }
-
+ Process *process = m_exe_ctx.GetProcessPtr();
result.AppendMessageWithFormat ("Detaching from process %" PRIu64 "\n", process->GetID());
Error error (process->Detach());
if (error.Success())
@@ -1008,7 +1033,7 @@ protected:
TargetSP target_sp (m_interpreter.GetDebugger().GetSelectedTarget());
Error error;
- Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
+ Process *process = m_exe_ctx.GetProcessPtr();
if (process)
{
if (process->IsAlive())
@@ -1134,7 +1159,10 @@ public:
"process load",
"Load a shared library into the current process.",
"process load <filename> [<filename> ...]",
- eFlagProcessMustBeLaunched | eFlagProcessMustBePaused)
+ eFlagRequiresProcess |
+ eFlagTryTargetAPILock |
+ eFlagProcessMustBeLaunched |
+ eFlagProcessMustBePaused )
{
}
@@ -1147,15 +1175,9 @@ protected:
DoExecute (Args& command,
CommandReturnObject &result)
{
- Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
- if (process == NULL)
- {
- result.AppendError ("must have a valid process in order to load a shared library");
- result.SetStatus (eReturnStatusFailed);
- return false;
- }
+ Process *process = m_exe_ctx.GetProcessPtr();
- const uint32_t argc = command.GetArgumentCount();
+ const size_t argc = command.GetArgumentCount();
for (uint32_t i=0; i<argc; ++i)
{
@@ -1194,7 +1216,10 @@ public:
"process unload",
"Unload a shared library from the current process using the index returned by a previous call to \"process load\".",
"process unload <index>",
- eFlagProcessMustBeLaunched | eFlagProcessMustBePaused)
+ eFlagRequiresProcess |
+ eFlagTryTargetAPILock |
+ eFlagProcessMustBeLaunched |
+ eFlagProcessMustBePaused )
{
}
@@ -1207,15 +1232,9 @@ protected:
DoExecute (Args& command,
CommandReturnObject &result)
{
- Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
- if (process == NULL)
- {
- result.AppendError ("must have a valid process in order to load a shared library");
- result.SetStatus (eReturnStatusFailed);
- return false;
- }
+ Process *process = m_exe_ctx.GetProcessPtr();
- const uint32_t argc = command.GetArgumentCount();
+ const size_t argc = command.GetArgumentCount();
for (uint32_t i=0; i<argc; ++i)
{
@@ -1260,7 +1279,8 @@ public:
CommandObjectParsed (interpreter,
"process signal",
"Send a UNIX signal to the current process being debugged.",
- NULL)
+ NULL,
+ eFlagRequiresProcess | eFlagTryTargetAPILock)
{
CommandArgumentEntry arg;
CommandArgumentData signal_arg;
@@ -1285,13 +1305,7 @@ protected:
DoExecute (Args& command,
CommandReturnObject &result)
{
- Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
- if (process == NULL)
- {
- result.AppendError ("no process to signal");
- result.SetStatus (eReturnStatusFailed);
- return false;
- }
+ Process *process = m_exe_ctx.GetProcessPtr();
if (command.GetArgumentCount() == 1)
{
@@ -1348,6 +1362,8 @@ public:
"process interrupt",
"Interrupt the current process being debugged.",
"process interrupt",
+ eFlagRequiresProcess |
+ eFlagTryTargetAPILock |
eFlagProcessMustBeLaunched)
{
}
@@ -1361,7 +1377,7 @@ protected:
DoExecute (Args& command,
CommandReturnObject &result)
{
- Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
+ Process *process = m_exe_ctx.GetProcessPtr();
if (process == NULL)
{
result.AppendError ("no process to halt");
@@ -1411,6 +1427,8 @@ public:
"process kill",
"Terminate the current process being debugged.",
"process kill",
+ eFlagRequiresProcess |
+ eFlagTryTargetAPILock |
eFlagProcessMustBeLaunched)
{
}
@@ -1424,7 +1442,7 @@ protected:
DoExecute (Args& command,
CommandReturnObject &result)
{
- Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
+ Process *process = m_exe_ctx.GetProcessPtr();
if (process == NULL)
{
result.AppendError ("no process to kill");
@@ -1469,7 +1487,7 @@ public:
"process status",
"Show the current status and location of executing process.",
"process status",
- 0)
+ eFlagRequiresProcess | eFlagTryTargetAPILock)
{
}
@@ -1483,27 +1501,18 @@ public:
{
Stream &strm = result.GetOutputStream();
result.SetStatus (eReturnStatusSuccessFinishNoResult);
- ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
- Process *process = exe_ctx.GetProcessPtr();
- if (process)
- {
- const bool only_threads_with_stop_reason = true;
- const uint32_t start_frame = 0;
- const uint32_t num_frames = 1;
- const uint32_t num_frames_with_source = 1;
- process->GetStatus(strm);
- process->GetThreadStatus (strm,
- only_threads_with_stop_reason,
- start_frame,
- num_frames,
- num_frames_with_source);
-
- }
- else
- {
- result.AppendError ("No process.");
- result.SetStatus (eReturnStatusFailed);
- }
+ // No need to check "process" for validity as eFlagRequiresProcess ensures it is valid
+ Process *process = m_exe_ctx.GetProcessPtr();
+ const bool only_threads_with_stop_reason = true;
+ const uint32_t start_frame = 0;
+ const uint32_t num_frames = 1;
+ const uint32_t num_frames_with_source = 1;
+ process->GetStatus(strm);
+ process->GetThreadStatus (strm,
+ only_threads_with_stop_reason,
+ start_frame,
+ num_frames,
+ num_frames_with_source);
return result.Succeeded();
}
};
Modified: lldb/branches/windows/source/Commands/CommandObjectQuit.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Commands/CommandObjectQuit.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Commands/CommandObjectQuit.cpp (original)
+++ lldb/branches/windows/source/Commands/CommandObjectQuit.cpp Wed Apr 17 03:38:48 2013
@@ -34,9 +34,63 @@ CommandObjectQuit::~CommandObjectQuit ()
{
}
+// returns true if there is at least one alive process
+// is_a_detach will be true if all alive processes will be detached when you quit
+// and false if at least one process will be killed instead
+bool
+CommandObjectQuit::ShouldAskForConfirmation (bool& is_a_detach)
+{
+ if (m_interpreter.GetPromptOnQuit() == false)
+ return false;
+ bool should_prompt = false;
+ is_a_detach = true;
+ for (uint32_t debugger_idx = 0;
+ debugger_idx < Debugger::GetNumDebuggers();
+ debugger_idx++)
+ {
+ DebuggerSP debugger_sp(Debugger::GetDebuggerAtIndex(debugger_idx));
+ if (!debugger_sp)
+ continue;
+ const TargetList& target_list(debugger_sp->GetTargetList());
+ for (uint32_t target_idx = 0;
+ target_idx < target_list.GetNumTargets();
+ target_idx++)
+ {
+ TargetSP target_sp(target_list.GetTargetAtIndex(target_idx));
+ if (!target_sp)
+ continue;
+ ProcessSP process_sp(target_sp->GetProcessSP());
+ if (process_sp &&
+ process_sp->IsValid() &&
+ process_sp->IsAlive())
+ {
+ should_prompt = true;
+ if (process_sp->GetShouldDetach() == false)
+ {
+ // if we need to kill at least one process, just say so and return
+ is_a_detach = false;
+ return should_prompt;
+ }
+ }
+ }
+ }
+ return should_prompt;
+}
+
bool
CommandObjectQuit::DoExecute (Args& command, CommandReturnObject &result)
{
+ bool is_a_detach = true;
+ if (ShouldAskForConfirmation (is_a_detach))
+ {
+ StreamString message;
+ message.Printf("Quitting LLDB will %s one or more processes. Do you really want to proceed", (is_a_detach ? "detach from" : "kill"));
+ if (!m_interpreter.Confirm(message.GetData(), true))
+ {
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+ }
m_interpreter.BroadcastEvent (CommandInterpreter::eBroadcastBitQuitCommandReceived);
result.SetStatus (eReturnStatusQuit);
return true;
Modified: lldb/branches/windows/source/Commands/CommandObjectQuit.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Commands/CommandObjectQuit.h?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Commands/CommandObjectQuit.h (original)
+++ lldb/branches/windows/source/Commands/CommandObjectQuit.h Wed Apr 17 03:38:48 2013
@@ -35,6 +35,9 @@ protected:
virtual bool
DoExecute (Args& args,
CommandReturnObject &result);
+
+ bool
+ ShouldAskForConfirmation (bool& is_a_detach);
};
Modified: lldb/branches/windows/source/Commands/CommandObjectRegister.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Commands/CommandObjectRegister.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Commands/CommandObjectRegister.cpp (original)
+++ lldb/branches/windows/source/Commands/CommandObjectRegister.cpp Wed Apr 17 03:38:48 2013
@@ -45,7 +45,10 @@ public:
"register read",
"Dump the contents of one or more register values from the current frame. If no register is specified, dumps them all.",
NULL,
- eFlagProcessMustBeLaunched | eFlagProcessMustBePaused),
+ eFlagRequiresFrame |
+ eFlagRequiresRegContext |
+ eFlagProcessMustBeLaunched |
+ eFlagProcessMustBePaused ),
m_option_group (interpreter),
m_format_options (eFormatDefault),
m_command_options ()
@@ -126,24 +129,29 @@ public:
DumpRegisterSet (const ExecutionContext &exe_ctx,
Stream &strm,
RegisterContext *reg_ctx,
- uint32_t set_idx,
+ size_t set_idx,
bool primitive_only=false)
{
uint32_t unavailable_count = 0;
uint32_t available_count = 0;
+
+ if (!reg_ctx)
+ return false; // thread has no registers (i.e. core files are corrupt, incomplete crash logs...)
+
const RegisterSet * const reg_set = reg_ctx->GetRegisterSet(set_idx);
if (reg_set)
{
strm.Printf ("%s:\n", reg_set->name);
strm.IndentMore ();
- const uint32_t num_registers = reg_set->num_registers;
- for (uint32_t reg_idx = 0; reg_idx < num_registers; ++reg_idx)
+ const size_t num_registers = reg_set->num_registers;
+ for (size_t reg_idx = 0; reg_idx < num_registers; ++reg_idx)
{
const uint32_t reg = reg_set->registers[reg_idx];
const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex(reg);
// Skip the dumping of derived register if primitive_only is true.
if (primitive_only && reg_info && reg_info->value_regs)
continue;
+
if (DumpRegister (exe_ctx, strm, reg_ctx, reg_info))
++available_count;
else
@@ -165,89 +173,89 @@ protected:
DoExecute (Args& command, CommandReturnObject &result)
{
Stream &strm = result.GetOutputStream();
- ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
- RegisterContext *reg_ctx = exe_ctx.GetRegisterContext ();
+ RegisterContext *reg_ctx = m_exe_ctx.GetRegisterContext ();
- if (reg_ctx)
+ const RegisterInfo *reg_info = NULL;
+ if (command.GetArgumentCount() == 0)
{
- const RegisterInfo *reg_info = NULL;
- if (command.GetArgumentCount() == 0)
+ size_t set_idx;
+
+ size_t num_register_sets = 1;
+ const size_t set_array_size = m_command_options.set_indexes.GetSize();
+ if (set_array_size > 0)
{
- uint32_t set_idx;
-
- uint32_t num_register_sets = 1;
- const uint32_t set_array_size = m_command_options.set_indexes.GetSize();
- if (set_array_size > 0)
+ for (size_t i=0; i<set_array_size; ++i)
{
- for (uint32_t i=0; i<set_array_size; ++i)
+ set_idx = m_command_options.set_indexes[i]->GetUInt64Value (UINT32_MAX, NULL);
+ if (set_idx < reg_ctx->GetRegisterSetCount())
{
- set_idx = m_command_options.set_indexes[i]->GetUInt64Value (UINT32_MAX, NULL);
- if (set_idx != UINT32_MAX)
+ if (!DumpRegisterSet (m_exe_ctx, strm, reg_ctx, set_idx))
{
- if (!DumpRegisterSet (exe_ctx, strm, reg_ctx, set_idx))
- {
- result.AppendErrorWithFormat ("invalid register set index: %u\n", set_idx);
- result.SetStatus (eReturnStatusFailed);
- break;
- }
- }
- else
- {
- result.AppendError ("invalid register set index\n");
+ if (errno)
+ result.AppendErrorWithFormat ("register read failed with errno: %d\n", errno);
+ else
+ result.AppendError ("unknown error while reading registers.\n");
result.SetStatus (eReturnStatusFailed);
break;
}
}
- }
- else
- {
- if (m_command_options.dump_all_sets)
- num_register_sets = reg_ctx->GetRegisterSetCount();
-
- for (set_idx = 0; set_idx < num_register_sets; ++set_idx)
+ else
{
- // When dump_all_sets option is set, dump primitive as well as derived registers.
- DumpRegisterSet (exe_ctx, strm, reg_ctx, set_idx, !m_command_options.dump_all_sets.GetCurrentValue());
+ result.AppendErrorWithFormat ("invalid register set index: %zu\n", set_idx);
+ result.SetStatus (eReturnStatusFailed);
+ break;
}
}
}
else
{
if (m_command_options.dump_all_sets)
+ num_register_sets = reg_ctx->GetRegisterSetCount();
+
+ for (set_idx = 0; set_idx < num_register_sets; ++set_idx)
{
- result.AppendError ("the --all option can't be used when registers names are supplied as arguments\n");
- result.SetStatus (eReturnStatusFailed);
- }
- else if (m_command_options.set_indexes.GetSize() > 0)
- {
- result.AppendError ("the --set <set> option can't be used when registers names are supplied as arguments\n");
- result.SetStatus (eReturnStatusFailed);
+ // When dump_all_sets option is set, dump primitive as well as derived registers.
+ DumpRegisterSet (m_exe_ctx, strm, reg_ctx, set_idx, !m_command_options.dump_all_sets.GetCurrentValue());
}
- else
+ }
+ }
+ else
+ {
+ if (m_command_options.dump_all_sets)
+ {
+ result.AppendError ("the --all option can't be used when registers names are supplied as arguments\n");
+ result.SetStatus (eReturnStatusFailed);
+ }
+ else if (m_command_options.set_indexes.GetSize() > 0)
+ {
+ result.AppendError ("the --set <set> option can't be used when registers names are supplied as arguments\n");
+ result.SetStatus (eReturnStatusFailed);
+ }
+ else
+ {
+ const char *arg_cstr;
+ for (int arg_idx = 0; (arg_cstr = command.GetArgumentAtIndex(arg_idx)) != NULL; ++arg_idx)
{
- const char *arg_cstr;
- for (int arg_idx = 0; (arg_cstr = command.GetArgumentAtIndex(arg_idx)) != NULL; ++arg_idx)
- {
- reg_info = reg_ctx->GetRegisterInfoByName(arg_cstr);
+ // in most LLDB commands we accept $rbx as the name for register RBX - and here we would
+ // reject it and non-existant. we should be more consistent towards the user and allow them
+ // to say reg read $rbx - internally, however, we should be strict and not allow ourselves
+ // to call our registers $rbx in our own API
+ if (*arg_cstr == '$')
+ arg_cstr = arg_cstr+1;
+ reg_info = reg_ctx->GetRegisterInfoByName(arg_cstr);
- if (reg_info)
- {
- if (!DumpRegister (exe_ctx, strm, reg_ctx, reg_info))
- strm.Printf("%-12s = error: unavailable\n", reg_info->name);
- }
- else
- {
- result.AppendErrorWithFormat ("Invalid register name '%s'.\n", arg_cstr);
- }
+ if (reg_info)
+ {
+ if (!DumpRegister (m_exe_ctx, strm, reg_ctx, reg_info))
+ strm.Printf("%-12s = error: unavailable\n", reg_info->name);
+ }
+ else
+ {
+ result.AppendErrorWithFormat ("Invalid register name '%s'.\n", arg_cstr);
}
}
}
}
- else
- {
- result.AppendError ("no current frame");
- result.SetStatus (eReturnStatusFailed);
- }
return result.Succeeded();
}
@@ -366,7 +374,10 @@ public:
"register write",
"Modify a single register value.",
NULL,
- eFlagProcessMustBeLaunched | eFlagProcessMustBePaused)
+ eFlagRequiresFrame |
+ eFlagRequiresRegContext |
+ eFlagProcessMustBeLaunched |
+ eFlagProcessMustBePaused)
{
CommandArgumentEntry arg1;
CommandArgumentEntry arg2;
@@ -402,64 +413,64 @@ protected:
DoExecute(Args& command, CommandReturnObject &result)
{
DataExtractor reg_data;
- ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
- RegisterContext *reg_ctx = exe_ctx.GetRegisterContext ();
+ RegisterContext *reg_ctx = m_exe_ctx.GetRegisterContext ();
- if (reg_ctx)
+ if (command.GetArgumentCount() != 2)
{
- if (command.GetArgumentCount() != 2)
- {
- result.AppendError ("register write takes exactly 2 arguments: <reg-name> <value>");
- result.SetStatus (eReturnStatusFailed);
- }
- else
- {
- const char *reg_name = command.GetArgumentAtIndex(0);
- const char *value_str = command.GetArgumentAtIndex(1);
- const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName(reg_name);
+ result.AppendError ("register write takes exactly 2 arguments: <reg-name> <value>");
+ result.SetStatus (eReturnStatusFailed);
+ }
+ else
+ {
+ const char *reg_name = command.GetArgumentAtIndex(0);
+ const char *value_str = command.GetArgumentAtIndex(1);
+
+
+ // in most LLDB commands we accept $rbx as the name for register RBX - and here we would
+ // reject it and non-existant. we should be more consistent towards the user and allow them
+ // to say reg write $rbx - internally, however, we should be strict and not allow ourselves
+ // to call our registers $rbx in our own API
+ if (reg_name && *reg_name == '$')
+ reg_name = reg_name+1;
+
+ const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName(reg_name);
- if (reg_info)
+ if (reg_info)
+ {
+ RegisterValue reg_value;
+
+ Error error (reg_value.SetValueFromCString (reg_info, value_str));
+ if (error.Success())
{
- RegisterValue reg_value;
-
- Error error (reg_value.SetValueFromCString (reg_info, value_str));
- if (error.Success())
+ if (reg_ctx->WriteRegister (reg_info, reg_value))
{
- if (reg_ctx->WriteRegister (reg_info, reg_value))
- {
- // Toss all frames and anything else in the thread
- // after a register has been written.
- exe_ctx.GetThreadRef().Flush();
- result.SetStatus (eReturnStatusSuccessFinishNoResult);
- return true;
- }
+ // Toss all frames and anything else in the thread
+ // after a register has been written.
+ m_exe_ctx.GetThreadRef().Flush();
+ result.SetStatus (eReturnStatusSuccessFinishNoResult);
+ return true;
}
- if (error.AsCString())
- {
- result.AppendErrorWithFormat ("Failed to write register '%s' with value '%s': %s\n",
- reg_name,
- value_str,
- error.AsCString());
- }
- else
- {
- result.AppendErrorWithFormat ("Failed to write register '%s' with value '%s'",
- reg_name,
- value_str);
- }
- result.SetStatus (eReturnStatusFailed);
+ }
+ if (error.AsCString())
+ {
+ result.AppendErrorWithFormat ("Failed to write register '%s' with value '%s': %s\n",
+ reg_name,
+ value_str,
+ error.AsCString());
}
else
{
- result.AppendErrorWithFormat ("Register not found for '%s'.\n", reg_name);
- result.SetStatus (eReturnStatusFailed);
+ result.AppendErrorWithFormat ("Failed to write register '%s' with value '%s'",
+ reg_name,
+ value_str);
}
+ result.SetStatus (eReturnStatusFailed);
+ }
+ else
+ {
+ result.AppendErrorWithFormat ("Register not found for '%s'.\n", reg_name);
+ result.SetStatus (eReturnStatusFailed);
}
- }
- else
- {
- result.AppendError ("no current frame");
- result.SetStatus (eReturnStatusFailed);
}
return result.Succeeded();
}
Modified: lldb/branches/windows/source/Commands/CommandObjectSettings.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Commands/CommandObjectSettings.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Commands/CommandObjectSettings.cpp (original)
+++ lldb/branches/windows/source/Commands/CommandObjectSettings.cpp Wed Apr 17 03:38:48 2013
@@ -23,14 +23,6 @@ using namespace lldb;
using namespace lldb_private;
#include "llvm/ADT/StringRef.h"
-static inline void StripLeadingSpaces(llvm::StringRef &s)
-{
- const size_t non_space = s.find_first_not_of(' ');
- if (non_space > 0)
- s = s.substr(non_space);
-}
-
-
//-------------------------------------------------------------------------
// CommandObjectSettingsSet
//-------------------------------------------------------------------------
@@ -202,12 +194,10 @@ insert-before or insert-after.\n");
}
else
{
- ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
-
// Complete setting value
const char *setting_var_name = input.GetArgumentAtIndex(setting_var_idx);
Error error;
- lldb::OptionValueSP value_sp (m_interpreter.GetDebugger().GetPropertyValue(&exe_ctx, setting_var_name, false, error));
+ lldb::OptionValueSP value_sp (m_interpreter.GetDebugger().GetPropertyValue(&m_exe_ctx, setting_var_name, false, error));
if (value_sp)
{
value_sp->AutoComplete (m_interpreter,
@@ -250,28 +240,25 @@ protected:
}
// Split the raw command into var_name and value pair.
- std::string var_name_string = var_name;
llvm::StringRef raw_str(command);
- llvm::StringRef var_value_str = raw_str.split(var_name).second;
- StripLeadingSpaces(var_value_str);
- std::string var_value_string = var_value_str.str();
+ std::string var_value_string = raw_str.split(var_name).second.str();
+ const char *var_value_cstr = Args::StripSpaces(var_value_string, true, true, false);
- ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
Error error;
if (m_options.m_global)
{
error = m_interpreter.GetDebugger().SetPropertyValue (NULL,
eVarSetOperationAssign,
var_name,
- var_value_string.c_str());
+ var_value_cstr);
}
if (error.Success())
{
- error = m_interpreter.GetDebugger().SetPropertyValue (&exe_ctx,
+ error = m_interpreter.GetDebugger().SetPropertyValue (&m_exe_ctx,
eVarSetOperationAssign,
var_name,
- var_value_string.c_str());
+ var_value_cstr);
}
if (error.Fail())
@@ -357,7 +344,6 @@ protected:
virtual bool
DoExecute (Args& args, CommandReturnObject &result)
{
- ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
result.SetStatus (eReturnStatusSuccessFinishResult);
const size_t argc = args.GetArgumentCount ();
@@ -367,7 +353,7 @@ protected:
{
const char *property_path = args.GetArgumentAtIndex (i);
- Error error(m_interpreter.GetDebugger().DumpPropertyValue (&exe_ctx, result.GetOutputStream(), property_path, OptionValue::eDumpGroupValue));
+ Error error(m_interpreter.GetDebugger().DumpPropertyValue (&m_exe_ctx, result.GetOutputStream(), property_path, OptionValue::eDumpGroupValue));
if (error.Success())
{
result.GetOutputStream().EOL();
@@ -381,7 +367,7 @@ protected:
}
else
{
- m_interpreter.GetDebugger().DumpAllPropertyValues (& exe_ctx, result.GetOutputStream(), OptionValue::eDumpGroupValue);
+ m_interpreter.GetDebugger().DumpAllPropertyValues (&m_exe_ctx, result.GetOutputStream(), OptionValue::eDumpGroupValue);
}
return result.Succeeded();
@@ -450,7 +436,6 @@ protected:
virtual bool
DoExecute (Args& args, CommandReturnObject &result)
{
- ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
result.SetStatus (eReturnStatusSuccessFinishResult);
const bool will_modify = false;
@@ -463,7 +448,7 @@ protected:
{
const char *property_path = args.GetArgumentAtIndex (i);
- const Property *property = m_interpreter.GetDebugger().GetValueProperties()->GetPropertyAtPath (&exe_ctx, will_modify, property_path);
+ const Property *property = m_interpreter.GetDebugger().GetValueProperties()->GetPropertyAtPath (&m_exe_ctx, will_modify, property_path);
if (property)
{
@@ -586,17 +571,14 @@ protected:
}
// Split the raw command into var_name and value pair.
- std::string var_name_string = var_name;
llvm::StringRef raw_str(command);
- llvm::StringRef var_value_str = raw_str.split(var_name).second;
- StripLeadingSpaces(var_value_str);
- std::string var_value_string = var_value_str.str();
+ std::string var_value_string = raw_str.split(var_name).second.str();
+ const char *var_value_cstr = Args::StripSpaces(var_value_string, true, true, false);
- ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
- Error error (m_interpreter.GetDebugger().SetPropertyValue (&exe_ctx,
+ Error error (m_interpreter.GetDebugger().SetPropertyValue (&m_exe_ctx,
eVarSetOperationRemove,
var_name,
- var_value_string.c_str()));
+ var_value_cstr));
if (error.Fail())
{
result.AppendError (error.AsCString());
@@ -703,7 +685,6 @@ protected:
Args cmd_args(command);
const char *var_name = cmd_args.GetArgumentAtIndex (0);
- std::string var_name_string;
if ((var_name == NULL) || (var_name[0] == '\0'))
{
result.AppendError ("'settings replace' command requires a valid variable name; No value supplied");
@@ -711,19 +692,16 @@ protected:
return false;
}
- var_name_string = var_name;
// Split the raw command into var_name, index_value, and value triple.
llvm::StringRef raw_str(command);
- llvm::StringRef var_value_str = raw_str.split(var_name).second;
- StripLeadingSpaces(var_value_str);
- std::string var_value_string = var_value_str.str();
+ std::string var_value_string = raw_str.split(var_name).second.str();
+ const char *var_value_cstr = Args::StripSpaces(var_value_string, true, true, false);
- ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
- Error error(m_interpreter.GetDebugger().SetPropertyValue (&exe_ctx,
+ Error error(m_interpreter.GetDebugger().SetPropertyValue (&m_exe_ctx,
eVarSetOperationReplace,
var_name,
- var_value_string.c_str()));
+ var_value_cstr));
if (error.Fail())
{
result.AppendError (error.AsCString());
@@ -837,7 +815,6 @@ protected:
}
const char *var_name = cmd_args.GetArgumentAtIndex (0);
- std::string var_name_string;
if ((var_name == NULL) || (var_name[0] == '\0'))
{
result.AppendError ("'settings insert-before' command requires a valid variable name; No value supplied");
@@ -845,19 +822,15 @@ protected:
return false;
}
- var_name_string = var_name;
-
// Split the raw command into var_name, index_value, and value triple.
llvm::StringRef raw_str(command);
- llvm::StringRef var_value_str = raw_str.split(var_name).second;
- StripLeadingSpaces(var_value_str);
- std::string var_value_string = var_value_str.str();
+ std::string var_value_string = raw_str.split(var_name).second.str();
+ const char *var_value_cstr = Args::StripSpaces(var_value_string, true, true, false);
- ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
- Error error(m_interpreter.GetDebugger().SetPropertyValue (&exe_ctx,
+ Error error(m_interpreter.GetDebugger().SetPropertyValue (&m_exe_ctx,
eVarSetOperationInsertBefore,
var_name,
- var_value_string.c_str()));
+ var_value_cstr));
if (error.Fail())
{
result.AppendError (error.AsCString());
@@ -966,7 +939,6 @@ protected:
}
const char *var_name = cmd_args.GetArgumentAtIndex (0);
- std::string var_name_string;
if ((var_name == NULL) || (var_name[0] == '\0'))
{
result.AppendError ("'settings insert-after' command requires a valid variable name; No value supplied");
@@ -974,19 +946,15 @@ protected:
return false;
}
- var_name_string = var_name;
-
// Split the raw command into var_name, index_value, and value triple.
llvm::StringRef raw_str(command);
- llvm::StringRef var_value_str = raw_str.split(var_name).second;
- StripLeadingSpaces(var_value_str);
- std::string var_value_string = var_value_str.str();
+ std::string var_value_string = raw_str.split(var_name).second.str();
+ const char *var_value_cstr = Args::StripSpaces(var_value_string, true, true, false);
- ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
- Error error(m_interpreter.GetDebugger().SetPropertyValue (&exe_ctx,
+ Error error(m_interpreter.GetDebugger().SetPropertyValue (&m_exe_ctx,
eVarSetOperationInsertAfter,
var_name,
- var_value_string.c_str()));
+ var_value_cstr));
if (error.Fail())
{
result.AppendError (error.AsCString());
@@ -1084,7 +1052,6 @@ protected:
}
const char *var_name = cmd_args.GetArgumentAtIndex (0);
- std::string var_name_string;
if ((var_name == NULL) || (var_name[0] == '\0'))
{
result.AppendError ("'settings append' command requires a valid variable name; No value supplied");
@@ -1092,21 +1059,18 @@ protected:
return false;
}
- var_name_string = var_name;
// Do not perform cmd_args.Shift() since StringRef is manipulating the
// raw character string later on.
// Split the raw command into var_name and value pair.
llvm::StringRef raw_str(command);
- llvm::StringRef var_value_str = raw_str.split(var_name).second;
- StripLeadingSpaces(var_value_str);
- std::string var_value_string = var_value_str.str();
+ std::string var_value_string = raw_str.split(var_name).second.str();
+ const char *var_value_cstr = Args::StripSpaces(var_value_string, true, true, false);
- ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
- Error error(m_interpreter.GetDebugger().SetPropertyValue (&exe_ctx,
+ Error error(m_interpreter.GetDebugger().SetPropertyValue (&m_exe_ctx,
eVarSetOperationAppend,
var_name,
- var_value_string.c_str()));
+ var_value_cstr));
if (error.Fail())
{
result.AppendError (error.AsCString());
@@ -1196,8 +1160,7 @@ protected:
return false;
}
- ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
- Error error (m_interpreter.GetDebugger().SetPropertyValue (&exe_ctx,
+ Error error (m_interpreter.GetDebugger().SetPropertyValue (&m_exe_ctx,
eVarSetOperationClear,
var_name,
NULL));
Modified: lldb/branches/windows/source/Commands/CommandObjectSource.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Commands/CommandObjectSource.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Commands/CommandObjectSource.cpp (original)
+++ lldb/branches/windows/source/Commands/CommandObjectSource.cpp Wed Apr 17 03:38:48 2013
@@ -201,6 +201,9 @@ class CommandObjectSourceList : public C
case 'b':
show_bp_locs = true;
break;
+ case 'r':
+ reverse = true;
+ break;
default:
error.SetErrorStringWithFormat("unrecognized short option '%c'", short_option);
break;
@@ -217,8 +220,9 @@ class CommandObjectSourceList : public C
symbol_name.clear();
address = LLDB_INVALID_ADDRESS;
start_line = 0;
- num_lines = 10;
+ num_lines = 0;
show_bp_locs = false;
+ reverse = false;
modules.clear();
}
@@ -238,6 +242,7 @@ class CommandObjectSourceList : public C
uint32_t num_lines;
STLStringArray modules;
bool show_bp_locs;
+ bool reverse;
};
public:
@@ -245,21 +250,10 @@ public:
CommandObjectParsed (interpreter,
"source list",
"Display source code (as specified) based on the current executable's debug info.",
- NULL),
+ NULL,
+ eFlagRequiresTarget),
m_options (interpreter)
{
- CommandArgumentEntry arg;
- CommandArgumentData file_arg;
-
- // Define the first (and only) variant of this arg.
- file_arg.arg_type = eArgTypeFilename;
- file_arg.arg_repetition = eArgRepeatOptional;
-
- // There is only one variant this argument could be; put it into the argument entry.
- arg.push_back (file_arg);
-
- // Push the data for the first argument into the m_arguments vector.
- m_arguments.push_back (arg);
}
~CommandObjectSourceList ()
@@ -276,14 +270,36 @@ public:
virtual const char *
GetRepeatCommand (Args ¤t_command_args, uint32_t index)
{
- return m_cmd_name.c_str();
+ // This is kind of gross, but the command hasn't been parsed yet so we can't look at the option
+ // values for this invocation... I have to scan the arguments directly.
+ size_t num_args = current_command_args.GetArgumentCount();
+ bool is_reverse = false;
+ for (size_t i = 0 ; i < num_args; i++)
+ {
+ const char *arg = current_command_args.GetArgumentAtIndex(i);
+ if (arg && (strcmp(arg, "-r") == 0 || strcmp(arg, "--reverse") == 0))
+ {
+ is_reverse = true;
+ }
+ }
+ if (is_reverse)
+ {
+ if (m_reverse_name.empty())
+ {
+ m_reverse_name = m_cmd_name;
+ m_reverse_name.append (" -r");
+ }
+ return m_reverse_name.c_str();
+ }
+ else
+ return m_cmd_name.c_str();
}
protected:
bool
DoExecute (Args& command, CommandReturnObject &result)
{
- const int argc = command.GetArgumentCount();
+ const size_t argc = command.GetArgumentCount();
if (argc != 0)
{
@@ -292,18 +308,7 @@ protected:
return false;
}
- ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
- Target *target = exe_ctx.GetTargetPtr();
-
- if (target == NULL)
- target = m_interpreter.GetDebugger().GetSelectedTarget().get();
-
- if (target == NULL)
- {
- result.AppendError ("invalid target, create a debug target using the 'target create' command");
- result.SetStatus (eReturnStatusFailed);
- return false;
- }
+ Target *target = m_exe_ctx.GetTargetPtr();
SymbolContextList sc_list;
if (!m_options.symbol_name.empty())
@@ -315,10 +320,14 @@ protected:
bool append = true;
size_t num_matches = 0;
- if (m_options.modules.size() > 0)
+ if (m_options.num_lines == 0)
+ m_options.num_lines = 10;
+
+ const size_t num_modules = m_options.modules.size();
+ if (num_modules > 0)
{
ModuleList matching_modules;
- for (unsigned i = 0, e = m_options.modules.size(); i != e; i++)
+ for (size_t i = 0; i < num_modules; ++i)
{
FileSpec module_file_spec(m_options.modules[i].c_str(), false);
if (module_file_spec)
@@ -414,23 +423,26 @@ protected:
}
}
-
// This is a little hacky, but the first line table entry for a function points to the "{" that
// starts the function block. It would be nice to actually get the function
// declaration in there too. So back up a bit, but not further than what you're going to display.
- size_t lines_to_back_up = m_options.num_lines >= 10 ? 5 : m_options.num_lines/2;
+ uint32_t extra_lines;
+ if (m_options.num_lines >= 10)
+ extra_lines = 5;
+ else
+ extra_lines = m_options.num_lines/2;
uint32_t line_no;
- if (start_line <= lines_to_back_up)
+ if (start_line <= extra_lines)
line_no = 1;
else
- line_no = start_line - lines_to_back_up;
+ line_no = start_line - extra_lines;
// For fun, if the function is shorter than the number of lines we're supposed to display,
// only display the function...
if (end_line != 0)
{
if (m_options.num_lines > end_line - line_no)
- m_options.num_lines = end_line - line_no;
+ m_options.num_lines = end_line - line_no + extra_lines;
}
char path_buf[PATH_MAX];
@@ -440,13 +452,13 @@ protected:
{
const bool show_inlines = true;
m_breakpoint_locations.Reset (start_file, 0, show_inlines);
- SearchFilter target_search_filter (exe_ctx.GetTargetSP());
+ SearchFilter target_search_filter (m_exe_ctx.GetTargetSP());
target_search_filter.Search (m_breakpoint_locations);
}
else
m_breakpoint_locations.Clear();
- result.AppendMessageWithFormat("File: %s.\n", path_buf);
+ result.AppendMessageWithFormat("File: %s\n", path_buf);
target->GetSourceManager().DisplaySourceLinesWithLineNumbers (start_file,
line_no,
0,
@@ -470,13 +482,13 @@ protected:
// The target isn't loaded yet, we need to lookup the file address
// in all modules
const ModuleList &module_list = target->GetImages();
- const uint32_t num_modules = module_list.GetSize();
- for (uint32_t i=0; i<num_modules; ++i)
+ const size_t num_modules = module_list.GetSize();
+ for (size_t i=0; i<num_modules; ++i)
{
ModuleSP module_sp (module_list.GetModuleAtIndex(i));
if (module_sp && module_sp->ResolveFileAddress(m_options.address, so_addr))
{
- sc.Clear();
+ sc.Clear(true);
if (module_sp->ResolveSymbolContextForAddress (so_addr, eSymbolContextEverything, sc) & eSymbolContextLineEntry)
sc_list.Append(sc);
}
@@ -499,7 +511,7 @@ protected:
ModuleSP module_sp (so_addr.GetModule());
if (module_sp)
{
- sc.Clear();
+ sc.Clear(true);
if (module_sp->ResolveSymbolContextForAddress (so_addr, eSymbolContextEverything, sc) & eSymbolContextLineEntry)
{
sc_list.Append(sc);
@@ -541,12 +553,15 @@ protected:
bool show_module = true;
bool show_inlined_frames = true;
sc.DumpStopContext(&result.GetOutputStream(),
- exe_ctx.GetBestExecutionContextScope(),
+ m_exe_ctx.GetBestExecutionContextScope(),
sc.line_entry.range.GetBaseAddress(),
show_fullpaths,
show_module,
show_inlined_frames);
result.GetOutputStream().EOL();
+
+ if (m_options.num_lines == 0)
+ m_options.num_lines = 10;
size_t lines_to_back_up = m_options.num_lines >= 10 ? 5 : m_options.num_lines/2;
@@ -570,13 +585,18 @@ protected:
if (m_options.start_line == 0)
{
if (target->GetSourceManager().DisplayMoreWithLineNumbers (&result.GetOutputStream(),
- GetBreakpointLocations ()))
+ m_options.num_lines,
+ m_options.reverse,
+ GetBreakpointLocations ()))
{
result.SetStatus (eReturnStatusSuccessFinishResult);
}
}
else
{
+ if (m_options.num_lines == 0)
+ m_options.num_lines = 10;
+
if (m_options.show_bp_locs)
{
SourceManager::FileSP last_file_sp (target->GetSourceManager().GetLastFile ());
@@ -593,8 +613,8 @@ protected:
if (target->GetSourceManager().DisplaySourceLinesWithLineNumbersUsingLastFile(
m_options.start_line, // Line to display
- 0, // Lines before line to display
- m_options.num_lines, // Lines after line to display
+ m_options.num_lines, // Lines after line to
+ UINT32_MAX, // Don't mark "line"
"", // Don't mark "line"
&result.GetOutputStream(),
GetBreakpointLocations ()))
@@ -615,7 +635,7 @@ protected:
if (m_options.modules.size() > 0)
{
ModuleList matching_modules;
- for (unsigned i = 0, e = m_options.modules.size(); i != e; i++)
+ for (size_t i = 0, e = m_options.modules.size(); i < e; ++i)
{
FileSpec module_file_spec(m_options.modules[i].c_str(), false);
if (module_file_spec)
@@ -693,6 +713,9 @@ protected:
else
m_breakpoint_locations.Clear();
+ if (m_options.num_lines == 0)
+ m_options.num_lines = 10;
+
target->GetSourceManager().DisplaySourceLinesWithLineNumbers (sc.comp_unit,
m_options.start_line,
0,
@@ -724,6 +747,7 @@ protected:
}
CommandOptions m_options;
FileLineResolver m_breakpoint_locations;
+ std::string m_reverse_name;
};
@@ -737,7 +761,8 @@ CommandObjectSourceList::CommandOptions:
{ LLDB_OPT_SET_1 , false, "file", 'f', required_argument, NULL, CommandCompletions::eSourceFileCompletion, eArgTypeFilename, "The file from which to display source."},
{ LLDB_OPT_SET_1 , false, "line", 'l', required_argument, NULL, 0, eArgTypeLineNum, "The line number at which to start the display source."},
{ LLDB_OPT_SET_2 , false, "name", 'n', required_argument, NULL, CommandCompletions::eSymbolCompletion, eArgTypeSymbol, "The name of a function whose source to display."},
-{ LLDB_OPT_SET_3 , false, "address",'a', required_argument, NULL, 0, eArgTypeAddress, "Lookup the address and display the source information for the corresponding file and line."},
+{ LLDB_OPT_SET_3 , false, "address",'a', required_argument, NULL, 0, eArgTypeAddressOrExpression, "Lookup the address and display the source information for the corresponding file and line."},
+{ LLDB_OPT_SET_4, false, "reverse", 'r', no_argument, NULL, 0, eArgTypeNone, "Reverse the listing to look backwards from the last displayed block of source."},
{ 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
};
Modified: lldb/branches/windows/source/Commands/CommandObjectSyntax.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Commands/CommandObjectSyntax.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Commands/CommandObjectSyntax.cpp (original)
+++ lldb/branches/windows/source/Commands/CommandObjectSyntax.cpp Wed Apr 17 03:38:48 2013
@@ -59,7 +59,7 @@ CommandObjectSyntax::DoExecute (Args& co
{
CommandObject::CommandMap::iterator pos;
CommandObject *cmd_obj;
- const int argc = command.GetArgumentCount();
+ const size_t argc = command.GetArgumentCount();
if (argc > 0)
{
Modified: lldb/branches/windows/source/Commands/CommandObjectTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Commands/CommandObjectTarget.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Commands/CommandObjectTarget.cpp (original)
+++ lldb/branches/windows/source/Commands/CommandObjectTarget.cpp Wed Apr 17 03:38:48 2013
@@ -192,7 +192,7 @@ public:
return &m_option_group;
}
- int
+ virtual int
HandleArgumentCompletion (Args &input,
int &cursor_index,
int &cursor_char_position,
@@ -220,7 +220,7 @@ protected:
bool
DoExecute (Args& command, CommandReturnObject &result)
{
- const int argc = command.GetArgumentCount();
+ const size_t argc = command.GetArgumentCount();
FileSpec core_file (m_core_file.GetOptionValue().GetCurrentValue());
if (argc == 1 || core_file)
@@ -600,7 +600,7 @@ public:
"target variable",
"Read global variable(s) prior to, or while running your binary.",
NULL,
- 0),
+ eFlagRequiresTarget),
m_option_group (interpreter),
m_option_variable (false), // Don't include frame options
m_option_format (eFormatDefault),
@@ -637,19 +637,8 @@ public:
void
DumpValueObject (Stream &s, VariableSP &var_sp, ValueObjectSP &valobj_sp, const char *root_name)
{
- ValueObject::DumpValueObjectOptions options;
+ ValueObject::DumpValueObjectOptions options(m_varobj_options.GetAsDumpOptions());
- options.SetMaximumPointerDepth(m_varobj_options.ptr_depth)
- .SetMaximumDepth(m_varobj_options.max_depth)
- .SetShowTypes(m_varobj_options.show_types)
- .SetShowLocation(m_varobj_options.show_location)
- .SetUseObjectiveC(m_varobj_options.use_objc)
- .SetUseDynamicType(m_varobj_options.use_dynamic)
- .SetUseSyntheticValue(m_varobj_options.use_synth)
- .SetFlatOutput(m_varobj_options.flat_output)
- .SetOmitSummaryDepth(m_varobj_options.no_summary_depth)
- .SetIgnoreCap(m_varobj_options.ignore_cap);
-
switch (var_sp->GetScope())
{
case eValueTypeVariableGlobal:
@@ -697,9 +686,9 @@ public:
}
- static uint32_t GetVariableCallback (void *baton,
- const char *name,
- VariableList &variable_list)
+ static size_t GetVariableCallback (void *baton,
+ const char *name,
+ VariableList &variable_list)
{
Target *target = static_cast<Target *>(baton);
if (target)
@@ -769,200 +758,190 @@ protected:
virtual bool
DoExecute (Args& args, CommandReturnObject &result)
{
- ExecutionContext exe_ctx (m_interpreter.GetExecutionContext());
- Target *target = exe_ctx.GetTargetPtr();
- if (target)
+ Target *target = m_exe_ctx.GetTargetPtr();
+ const size_t argc = args.GetArgumentCount();
+ Stream &s = result.GetOutputStream();
+
+ if (argc > 0)
{
- const size_t argc = args.GetArgumentCount();
- Stream &s = result.GetOutputStream();
-
- if (argc > 0)
+
+ for (size_t idx = 0; idx < argc; ++idx)
{
+ VariableList variable_list;
+ ValueObjectList valobj_list;
- for (size_t idx = 0; idx < argc; ++idx)
+ const char *arg = args.GetArgumentAtIndex(idx);
+ size_t matches = 0;
+ bool use_var_name = false;
+ if (m_option_variable.use_regex)
{
- VariableList variable_list;
- ValueObjectList valobj_list;
-
- const char *arg = args.GetArgumentAtIndex(idx);
- uint32_t matches = 0;
- bool use_var_name = false;
- if (m_option_variable.use_regex)
- {
- RegularExpression regex(arg);
- if (!regex.IsValid ())
- {
- result.GetErrorStream().Printf ("error: invalid regular expression: '%s'\n", arg);
- result.SetStatus (eReturnStatusFailed);
- return false;
- }
- use_var_name = true;
- matches = target->GetImages().FindGlobalVariables (regex,
- true,
- UINT32_MAX,
- variable_list);
- }
- else
+ RegularExpression regex(arg);
+ if (!regex.IsValid ())
{
- Error error (Variable::GetValuesForVariableExpressionPath (arg,
- exe_ctx.GetBestExecutionContextScope(),
- GetVariableCallback,
- target,
- variable_list,
- valobj_list));
- matches = variable_list.GetSize();
- }
-
- if (matches == 0)
- {
- result.GetErrorStream().Printf ("error: can't find global variable '%s'\n", arg);
+ result.GetErrorStream().Printf ("error: invalid regular expression: '%s'\n", arg);
result.SetStatus (eReturnStatusFailed);
return false;
}
- else
+ use_var_name = true;
+ matches = target->GetImages().FindGlobalVariables (regex,
+ true,
+ UINT32_MAX,
+ variable_list);
+ }
+ else
+ {
+ Error error (Variable::GetValuesForVariableExpressionPath (arg,
+ m_exe_ctx.GetBestExecutionContextScope(),
+ GetVariableCallback,
+ target,
+ variable_list,
+ valobj_list));
+ matches = variable_list.GetSize();
+ }
+
+ if (matches == 0)
+ {
+ result.GetErrorStream().Printf ("error: can't find global variable '%s'\n", arg);
+ result.SetStatus (eReturnStatusFailed);
+ return false;
+ }
+ else
+ {
+ for (uint32_t global_idx=0; global_idx<matches; ++global_idx)
{
- for (uint32_t global_idx=0; global_idx<matches; ++global_idx)
+ VariableSP var_sp (variable_list.GetVariableAtIndex(global_idx));
+ if (var_sp)
{
- VariableSP var_sp (variable_list.GetVariableAtIndex(global_idx));
- if (var_sp)
- {
- ValueObjectSP valobj_sp (valobj_list.GetValueObjectAtIndex(global_idx));
- if (!valobj_sp)
- valobj_sp = ValueObjectVariable::Create (exe_ctx.GetBestExecutionContextScope(), var_sp);
-
- if (valobj_sp)
- DumpValueObject (s, var_sp, valobj_sp, use_var_name ? var_sp->GetName().GetCString() : arg);
- }
+ ValueObjectSP valobj_sp (valobj_list.GetValueObjectAtIndex(global_idx));
+ if (!valobj_sp)
+ valobj_sp = ValueObjectVariable::Create (m_exe_ctx.GetBestExecutionContextScope(), var_sp);
+
+ if (valobj_sp)
+ DumpValueObject (s, var_sp, valobj_sp, use_var_name ? var_sp->GetName().GetCString() : arg);
}
}
}
}
- else
+ }
+ else
+ {
+ const FileSpecList &compile_units = m_option_compile_units.GetOptionValue().GetCurrentValue();
+ const FileSpecList &shlibs = m_option_shared_libraries.GetOptionValue().GetCurrentValue();
+ SymbolContextList sc_list;
+ const size_t num_compile_units = compile_units.GetSize();
+ const size_t num_shlibs = shlibs.GetSize();
+ if (num_compile_units == 0 && num_shlibs == 0)
{
- const FileSpecList &compile_units = m_option_compile_units.GetOptionValue().GetCurrentValue();
- const FileSpecList &shlibs = m_option_shared_libraries.GetOptionValue().GetCurrentValue();
- SymbolContextList sc_list;
- const size_t num_compile_units = compile_units.GetSize();
- const size_t num_shlibs = shlibs.GetSize();
- if (num_compile_units == 0 && num_shlibs == 0)
- {
- bool success = false;
- StackFrame *frame = exe_ctx.GetFramePtr();
- CompileUnit *comp_unit = NULL;
- if (frame)
- {
- SymbolContext sc = frame->GetSymbolContext (eSymbolContextCompUnit);
- if (sc.comp_unit)
+ bool success = false;
+ StackFrame *frame = m_exe_ctx.GetFramePtr();
+ CompileUnit *comp_unit = NULL;
+ if (frame)
+ {
+ SymbolContext sc = frame->GetSymbolContext (eSymbolContextCompUnit);
+ if (sc.comp_unit)
+ {
+ const bool can_create = true;
+ VariableListSP comp_unit_varlist_sp (sc.comp_unit->GetVariableList(can_create));
+ if (comp_unit_varlist_sp)
{
- const bool can_create = true;
- VariableListSP comp_unit_varlist_sp (sc.comp_unit->GetVariableList(can_create));
- if (comp_unit_varlist_sp)
+ size_t count = comp_unit_varlist_sp->GetSize();
+ if (count > 0)
{
- size_t count = comp_unit_varlist_sp->GetSize();
- if (count > 0)
- {
- DumpGlobalVariableList(exe_ctx, sc, *comp_unit_varlist_sp, s);
- success = true;
- }
+ DumpGlobalVariableList(m_exe_ctx, sc, *comp_unit_varlist_sp, s);
+ success = true;
}
}
}
- if (!success)
+ }
+ if (!success)
+ {
+ if (frame)
{
- if (frame)
- {
- if (comp_unit)
- result.AppendErrorWithFormat ("no global variables in current compile unit: %s/%s\n",
- comp_unit->GetDirectory().GetCString(),
- comp_unit->GetFilename().GetCString());
- else
- result.AppendErrorWithFormat ("no debug information for frame %u\n", frame->GetFrameIndex());
- }
+ if (comp_unit)
+ result.AppendErrorWithFormat ("no global variables in current compile unit: %s/%s\n",
+ comp_unit->GetDirectory().GetCString(),
+ comp_unit->GetFilename().GetCString());
else
- result.AppendError ("'target variable' takes one or more global variable names as arguments\n");
- result.SetStatus (eReturnStatusFailed);
- }
+ result.AppendErrorWithFormat ("no debug information for frame %u\n", frame->GetFrameIndex());
+ }
+ else
+ result.AppendError ("'target variable' takes one or more global variable names as arguments\n");
+ result.SetStatus (eReturnStatusFailed);
}
- else
+ }
+ else
+ {
+ SymbolContextList sc_list;
+ const bool append = true;
+ // We have one or more compile unit or shlib
+ if (num_shlibs > 0)
{
- SymbolContextList sc_list;
- const bool append = true;
- // We have one or more compile unit or shlib
- if (num_shlibs > 0)
+ for (size_t shlib_idx=0; shlib_idx<num_shlibs; ++shlib_idx)
{
- for (size_t shlib_idx=0; shlib_idx<num_shlibs; ++shlib_idx)
+ const FileSpec module_file(shlibs.GetFileSpecAtIndex(shlib_idx));
+ ModuleSpec module_spec (module_file);
+
+ ModuleSP module_sp (target->GetImages().FindFirstModule(module_spec));
+ if (module_sp)
{
- const FileSpec module_file(shlibs.GetFileSpecAtIndex(shlib_idx));
- ModuleSpec module_spec (module_file);
-
- ModuleSP module_sp (target->GetImages().FindFirstModule(module_spec));
- if (module_sp)
+ if (num_compile_units > 0)
{
- if (num_compile_units > 0)
- {
- for (size_t cu_idx=0; cu_idx<num_compile_units; ++cu_idx)
- module_sp->FindCompileUnits(compile_units.GetFileSpecAtIndex(cu_idx), append, sc_list);
- }
- else
- {
- SymbolContext sc;
- sc.module_sp = module_sp;
- sc_list.Append(sc);
- }
+ for (size_t cu_idx=0; cu_idx<num_compile_units; ++cu_idx)
+ module_sp->FindCompileUnits(compile_units.GetFileSpecAtIndex(cu_idx), append, sc_list);
}
else
{
- // Didn't find matching shlib/module in target...
- result.AppendErrorWithFormat ("target doesn't contain the specified shared library: %s%s%s\n",
- module_file.GetDirectory().GetCString(),
- module_file.GetDirectory() ? "/" : "",
- module_file.GetFilename().GetCString());
+ SymbolContext sc;
+ sc.module_sp = module_sp;
+ sc_list.Append(sc);
}
}
+ else
+ {
+ // Didn't find matching shlib/module in target...
+ result.AppendErrorWithFormat ("target doesn't contain the specified shared library: %s%s%s\n",
+ module_file.GetDirectory().GetCString(),
+ module_file.GetDirectory() ? "/" : "",
+ module_file.GetFilename().GetCString());
+ }
}
- else
- {
- // No shared libraries, we just want to find globals for the compile units files that were specified
- for (size_t cu_idx=0; cu_idx<num_compile_units; ++cu_idx)
- target->GetImages().FindCompileUnits(compile_units.GetFileSpecAtIndex(cu_idx), append, sc_list);
- }
-
- const uint32_t num_scs = sc_list.GetSize();
- if (num_scs > 0)
+ }
+ else
+ {
+ // No shared libraries, we just want to find globals for the compile units files that were specified
+ for (size_t cu_idx=0; cu_idx<num_compile_units; ++cu_idx)
+ target->GetImages().FindCompileUnits(compile_units.GetFileSpecAtIndex(cu_idx), append, sc_list);
+ }
+
+ const uint32_t num_scs = sc_list.GetSize();
+ if (num_scs > 0)
+ {
+ SymbolContext sc;
+ for (uint32_t sc_idx=0; sc_idx<num_scs; ++sc_idx)
{
- SymbolContext sc;
- for (uint32_t sc_idx=0; sc_idx<num_scs; ++sc_idx)
+ if (sc_list.GetContextAtIndex(sc_idx, sc))
{
- if (sc_list.GetContextAtIndex(sc_idx, sc))
+ if (sc.comp_unit)
{
- if (sc.comp_unit)
- {
- const bool can_create = true;
- VariableListSP comp_unit_varlist_sp (sc.comp_unit->GetVariableList(can_create));
- if (comp_unit_varlist_sp)
- DumpGlobalVariableList(exe_ctx, sc, *comp_unit_varlist_sp, s);
- }
- else if (sc.module_sp)
- {
- // Get all global variables for this module
- lldb_private::RegularExpression all_globals_regex("."); // Any global with at least one character
- VariableList variable_list;
- sc.module_sp->FindGlobalVariables(all_globals_regex, append, UINT32_MAX, variable_list);
- DumpGlobalVariableList(exe_ctx, sc, variable_list, s);
- }
+ const bool can_create = true;
+ VariableListSP comp_unit_varlist_sp (sc.comp_unit->GetVariableList(can_create));
+ if (comp_unit_varlist_sp)
+ DumpGlobalVariableList(m_exe_ctx, sc, *comp_unit_varlist_sp, s);
+ }
+ else if (sc.module_sp)
+ {
+ // Get all global variables for this module
+ lldb_private::RegularExpression all_globals_regex("."); // Any global with at least one character
+ VariableList variable_list;
+ sc.module_sp->FindGlobalVariables(all_globals_regex, append, UINT32_MAX, variable_list);
+ DumpGlobalVariableList(m_exe_ctx, sc, variable_list, s);
}
}
}
}
}
}
- else
- {
- result.AppendError ("invalid target, create a debug target using the 'target create' command");
- result.SetStatus (eReturnStatusFailed);
- return false;
- }
-
+
if (m_interpreter.TruncationWarningNecessary())
{
result.GetOutputStream().Printf(m_interpreter.TruncationWarningText(),
@@ -1029,7 +1008,7 @@ protected:
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
if (target)
{
- uint32_t argc = command.GetArgumentCount();
+ const size_t argc = command.GetArgumentCount();
if (argc & 1)
{
result.AppendError ("add requires an even number of arguments\n");
@@ -1037,7 +1016,7 @@ protected:
}
else
{
- for (uint32_t i=0; i<argc; i+=2)
+ for (size_t i=0; i<argc; i+=2)
{
const char *from = command.GetArgumentAtIndex(i);
const char *to = command.GetArgumentAtIndex(i+1);
@@ -1166,7 +1145,7 @@ protected:
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
if (target)
{
- uint32_t argc = command.GetArgumentCount();
+ size_t argc = command.GetArgumentCount();
// check for at least 3 arguments and an odd nubmer of parameters
if (argc >= 3 && argc & 1)
{
@@ -1680,7 +1659,7 @@ DumpSymbolContextList (ExecutionContextS
strm.IndentLess ();
}
-static uint32_t
+static size_t
LookupFunctionInModule (CommandInterpreter &interpreter,
Stream &strm,
Module *module,
@@ -1694,7 +1673,7 @@ LookupFunctionInModule (CommandInterpret
{
SymbolContextList sc_list;
const bool append = true;
- uint32_t num_matches = 0;
+ size_t num_matches = 0;
if (name_is_regex)
{
RegularExpression function_name_regex (name);
@@ -1719,7 +1698,7 @@ LookupFunctionInModule (CommandInterpret
if (num_matches)
{
strm.Indent ();
- strm.Printf("%u match%s found in ", num_matches, num_matches > 1 ? "es" : "");
+ strm.Printf("%zu match%s found in ", num_matches, num_matches > 1 ? "es" : "");
DumpFullpath (strm, &module->GetFileSpec(), 0);
strm.PutCString(":\n");
DumpSymbolContextList (interpreter.GetExecutionContext().GetBestExecutionContextScope(), strm, sc_list, verbose);
@@ -1729,7 +1708,7 @@ LookupFunctionInModule (CommandInterpret
return 0;
}
-static uint32_t
+static size_t
LookupTypeInModule (CommandInterpreter &interpreter,
Stream &strm,
Module *module,
@@ -1740,7 +1719,7 @@ LookupTypeInModule (CommandInterpreter &
{
TypeList type_list;
const uint32_t max_num_matches = UINT32_MAX;
- uint32_t num_matches = 0;
+ size_t num_matches = 0;
bool name_is_fully_qualified = false;
SymbolContext sc;
@@ -1750,7 +1729,7 @@ LookupTypeInModule (CommandInterpreter &
if (num_matches)
{
strm.Indent ();
- strm.Printf("%u match%s found in ", num_matches, num_matches > 1 ? "es" : "");
+ strm.Printf("%zu match%s found in ", num_matches, num_matches > 1 ? "es" : "");
DumpFullpath (strm, &module->GetFileSpec(), 0);
strm.PutCString(":\n");
const uint32_t num_types = type_list.GetSize();
@@ -1784,7 +1763,7 @@ LookupTypeInModule (CommandInterpreter &
return 0;
}
-static uint32_t
+static size_t
LookupTypeHere (CommandInterpreter &interpreter,
Stream &strm,
const SymbolContext &sym_ctx,
@@ -1796,7 +1775,7 @@ LookupTypeHere (CommandInterpreter &inte
TypeList type_list;
const uint32_t max_num_matches = UINT32_MAX;
- uint32_t num_matches = 1;
+ size_t num_matches = 1;
bool name_is_fully_qualified = false;
ConstString name(name_cstr);
@@ -1883,9 +1862,9 @@ FindModulesByName (Target *target,
{
// Check the global list
Mutex::Locker locker(Module::GetAllocationModuleCollectionMutex());
- const uint32_t num_modules = Module::GetNumberAllocatedModules();
+ const size_t num_modules = Module::GetNumberAllocatedModules();
ModuleSP module_sp;
- for (uint32_t image_idx = 0; image_idx<num_modules; ++image_idx)
+ for (size_t image_idx = 0; image_idx<num_modules; ++image_idx)
{
Module *module = Module::GetAllocatedModuleAtIndex(image_idx);
@@ -1997,10 +1976,11 @@ class CommandObjectTargetModulesSourceFi
public:
CommandObjectTargetModulesSourceFileAutoComplete (CommandInterpreter &interpreter,
- const char *name,
- const char *help,
- const char *syntax) :
- CommandObjectParsed (interpreter, name, help, syntax)
+ const char *name,
+ const char *help,
+ const char *syntax,
+ uint32_t flags) :
+ CommandObjectParsed (interpreter, name, help, syntax, flags)
{
CommandArgumentEntry arg;
CommandArgumentData source_file_arg;
@@ -2154,11 +2134,11 @@ protected:
{
// Dump all sections for all modules images
Mutex::Locker modules_locker(target->GetImages().GetMutex());
- const uint32_t num_modules = target->GetImages().GetSize();
+ const size_t num_modules = target->GetImages().GetSize();
if (num_modules > 0)
{
- result.GetOutputStream().Printf("Dumping symbol table for %u modules.\n", num_modules);
- for (uint32_t image_idx = 0; image_idx<num_modules; ++image_idx)
+ result.GetOutputStream().Printf("Dumping symbol table for %zu modules.\n", num_modules);
+ for (size_t image_idx = 0; image_idx<num_modules; ++image_idx)
{
if (num_dumped > 0)
{
@@ -2287,11 +2267,11 @@ protected:
if (command.GetArgumentCount() == 0)
{
// Dump all sections for all modules images
- const uint32_t num_modules = target->GetImages().GetSize();
+ const size_t num_modules = target->GetImages().GetSize();
if (num_modules > 0)
{
- result.GetOutputStream().Printf("Dumping sections for %u modules.\n", num_modules);
- for (uint32_t image_idx = 0; image_idx<num_modules; ++image_idx)
+ result.GetOutputStream().Printf("Dumping sections for %zu modules.\n", num_modules);
+ for (size_t image_idx = 0; image_idx<num_modules; ++image_idx)
{
num_dumped++;
DumpModuleSections (m_interpreter, result.GetOutputStream(), target->GetImages().GetModulePointerAtIndex(image_idx));
@@ -2395,10 +2375,10 @@ protected:
// Dump all sections for all modules images
const ModuleList &target_modules = target->GetImages();
Mutex::Locker modules_locker (target_modules.GetMutex());
- const uint32_t num_modules = target_modules.GetSize();
+ const size_t num_modules = target_modules.GetSize();
if (num_modules > 0)
{
- result.GetOutputStream().Printf("Dumping debug symbols for %u modules.\n", num_modules);
+ result.GetOutputStream().Printf("Dumping debug symbols for %zu modules.\n", num_modules);
for (uint32_t image_idx = 0; image_idx<num_modules; ++image_idx)
{
if (DumpModuleSymbolVendor (result.GetOutputStream(), target_modules.GetModulePointerAtIndexUnlocked(image_idx)))
@@ -2461,9 +2441,10 @@ class CommandObjectTargetModulesDumpLine
public:
CommandObjectTargetModulesDumpLineTable (CommandInterpreter &interpreter) :
CommandObjectTargetModulesSourceFileAutoComplete (interpreter,
- "target modules dump line-table",
- "Dump the debug symbol file for one or more target modules.",
- NULL)
+ "target modules dump line-table",
+ "Dump the debug symbol file for one or more target modules.",
+ NULL,
+ eFlagRequiresTarget)
{
}
@@ -2477,65 +2458,55 @@ protected:
DoExecute (Args& command,
CommandReturnObject &result)
{
- Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
- if (target == NULL)
+ Target *target = m_exe_ctx.GetTargetPtr();
+ uint32_t total_num_dumped = 0;
+
+ uint32_t addr_byte_size = target->GetArchitecture().GetAddressByteSize();
+ result.GetOutputStream().SetAddressByteSize(addr_byte_size);
+ result.GetErrorStream().SetAddressByteSize(addr_byte_size);
+
+ if (command.GetArgumentCount() == 0)
{
- result.AppendError ("invalid target, create a debug target using the 'target create' command");
+ result.AppendErrorWithFormat ("\nSyntax: %s\n", m_cmd_syntax.c_str());
result.SetStatus (eReturnStatusFailed);
- return false;
}
else
{
- ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
- uint32_t total_num_dumped = 0;
-
- uint32_t addr_byte_size = target->GetArchitecture().GetAddressByteSize();
- result.GetOutputStream().SetAddressByteSize(addr_byte_size);
- result.GetErrorStream().SetAddressByteSize(addr_byte_size);
-
- if (command.GetArgumentCount() == 0)
- {
- result.AppendErrorWithFormat ("\nSyntax: %s\n", m_cmd_syntax.c_str());
- result.SetStatus (eReturnStatusFailed);
- }
- else
+ // Dump specified images (by basename or fullpath)
+ const char *arg_cstr;
+ for (int arg_idx = 0; (arg_cstr = command.GetArgumentAtIndex(arg_idx)) != NULL; ++arg_idx)
{
- // Dump specified images (by basename or fullpath)
- const char *arg_cstr;
- for (int arg_idx = 0; (arg_cstr = command.GetArgumentAtIndex(arg_idx)) != NULL; ++arg_idx)
+ FileSpec file_spec(arg_cstr, false);
+
+ const ModuleList &target_modules = target->GetImages();
+ Mutex::Locker modules_locker(target_modules.GetMutex());
+ const size_t num_modules = target_modules.GetSize();
+ if (num_modules > 0)
{
- FileSpec file_spec(arg_cstr, false);
-
- const ModuleList &target_modules = target->GetImages();
- Mutex::Locker modules_locker(target_modules.GetMutex());
- const uint32_t num_modules = target_modules.GetSize();
- if (num_modules > 0)
+ uint32_t num_dumped = 0;
+ for (uint32_t i = 0; i<num_modules; ++i)
{
- uint32_t num_dumped = 0;
- for (uint32_t i = 0; i<num_modules; ++i)
- {
- if (DumpCompileUnitLineTable (m_interpreter,
- result.GetOutputStream(),
- target_modules.GetModulePointerAtIndexUnlocked(i),
- file_spec,
- exe_ctx.GetProcessPtr() && exe_ctx.GetProcessRef().IsAlive()))
- num_dumped++;
- }
- if (num_dumped == 0)
- result.AppendWarningWithFormat ("No source filenames matched '%s'.\n", arg_cstr);
- else
- total_num_dumped += num_dumped;
+ if (DumpCompileUnitLineTable (m_interpreter,
+ result.GetOutputStream(),
+ target_modules.GetModulePointerAtIndexUnlocked(i),
+ file_spec,
+ m_exe_ctx.GetProcessPtr() && m_exe_ctx.GetProcessRef().IsAlive()))
+ num_dumped++;
}
+ if (num_dumped == 0)
+ result.AppendWarningWithFormat ("No source filenames matched '%s'.\n", arg_cstr);
+ else
+ total_num_dumped += num_dumped;
}
}
-
- if (total_num_dumped > 0)
- result.SetStatus (eReturnStatusSuccessFinishResult);
- else
- {
- result.AppendError ("no source filenames matched any command arguments");
- result.SetStatus (eReturnStatusFailed);
- }
+ }
+
+ if (total_num_dumped > 0)
+ result.SetStatus (eReturnStatusSuccessFinishResult);
+ else
+ {
+ result.AppendError ("no source filenames matched any command arguments");
+ result.SetStatus (eReturnStatusFailed);
}
return result.Succeeded();
}
@@ -2600,7 +2571,7 @@ public:
return &m_option_group;
}
- int
+ virtual int
HandleArgumentCompletion (Args &input,
int &cursor_index,
int &cursor_char_position,
@@ -2933,7 +2904,12 @@ protected:
}
if (changed)
+ {
target->ModulesDidLoad (matching_modules);
+ Process *process = m_exe_ctx.GetProcessPtr();
+ if (process)
+ process->Flush();
+ }
}
else
{
@@ -3051,11 +3027,12 @@ public:
}
else if (short_option == 'a')
{
- m_module_addr = Args::StringToAddress(NULL, option_arg, LLDB_INVALID_ADDRESS, &error);
+ ExecutionContext exe_ctx (m_interpreter.GetExecutionContext());
+ m_module_addr = Args::StringToAddress(&exe_ctx, option_arg, LLDB_INVALID_ADDRESS, &error);
}
else
{
- uint32_t width = 0;
+ unsigned long width = 0;
if (option_arg)
width = strtoul (option_arg, NULL, 0);
m_format_array.push_back(std::make_pair(short_option, width));
@@ -3147,7 +3124,7 @@ protected:
ModuleSP module_sp (module_address.GetModule());
if (module_sp)
{
- PrintModule (target, module_sp.get(), UINT32_MAX, 0, strm);
+ PrintModule (target, module_sp.get(), 0, strm);
result.SetStatus (eReturnStatusSuccessFinishResult);
}
else
@@ -3170,7 +3147,7 @@ protected:
return result.Succeeded();
}
- uint32_t num_modules = 0;
+ size_t num_modules = 0;
Mutex::Locker locker; // This locker will be locked on the mutex in module_list_ptr if it is non-NULL.
// Otherwise it will lock the AllocationModuleCollectionMutex when accessing
// the global module list directly.
@@ -3232,8 +3209,8 @@ protected:
module_sp = module->shared_from_this();
}
- int indent = strm.Printf("[%3u] ", image_idx);
- PrintModule (target, module, image_idx, indent, strm);
+ const size_t indent = strm.Printf("[%3u] ", image_idx);
+ PrintModule (target, module, indent, strm);
}
result.SetStatus (eReturnStatusSuccessFinishResult);
@@ -3262,7 +3239,7 @@ protected:
}
void
- PrintModule (Target *target, Module *module, uint32_t idx, int indent, Stream &strm)
+ PrintModule (Target *target, Module *module, int indent, Stream &strm)
{
if (module == NULL)
@@ -3356,7 +3333,7 @@ protected:
break;
case 'r':
{
- uint32_t ref_count = 0;
+ size_t ref_count = 0;
ModuleSP module_sp (module->shared_from_this());
if (module_sp)
{
@@ -3364,9 +3341,9 @@ protected:
ref_count = module_sp.use_count() - 1;
}
if (width)
- strm.Printf("{%*u}", width, ref_count);
+ strm.Printf("{%*zu}", width, ref_count);
else
- strm.Printf("{%u}", ref_count);
+ strm.Printf("{%zu}", ref_count);
}
break;
@@ -3432,7 +3409,7 @@ protected:
OptionDefinition
CommandObjectTargetModulesList::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_SET_1, false, "address", 'a', required_argument, NULL, 0, eArgTypeAddress, "Display the image at this address."},
+ { LLDB_OPT_SET_1, false, "address", 'a', required_argument, NULL, 0, eArgTypeAddressOrExpression, "Display the image at this address."},
{ LLDB_OPT_SET_1, false, "arch", 'A', optional_argument, NULL, 0, eArgTypeWidth, "Display the architecture when listing images."},
{ LLDB_OPT_SET_1, false, "triple", 't', optional_argument, NULL, 0, eArgTypeWidth, "Display the triple when listing images."},
{ LLDB_OPT_SET_1, false, "header", 'h', no_argument, NULL, 0, eArgTypeNone, "Display the image header address as a load address if debugging, a file address otherwise."},
@@ -3475,10 +3452,10 @@ public:
public:
CommandOptions (CommandInterpreter &interpreter) :
- Options(interpreter),
- m_type(eLookupTypeInvalid),
- m_str(),
- m_addr(LLDB_INVALID_ADDRESS)
+ Options(interpreter),
+ m_type(eLookupTypeInvalid),
+ m_str(),
+ m_addr(LLDB_INVALID_ADDRESS)
{
}
@@ -3541,7 +3518,11 @@ public:
CommandObjectParsed (interpreter,
"target modules show-unwind",
"Show synthesized unwind instructions for a function.",
- NULL),
+ NULL,
+ eFlagRequiresTarget |
+ eFlagRequiresProcess |
+ eFlagProcessMustBeLaunched |
+ eFlagProcessMustBePaused ),
m_options (interpreter)
{
}
@@ -3563,16 +3544,8 @@ protected:
DoExecute (Args& command,
CommandReturnObject &result)
{
- Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
- if (!target)
- {
- result.AppendError ("invalid target, create a debug target using the 'target create' command");
- result.SetStatus (eReturnStatusFailed);
- return false;
- }
-
- ExecutionContext exe_ctx = m_interpreter.GetDebugger().GetSelectedExecutionContext();
- Process *process = exe_ctx.GetProcessPtr();
+ Target *target = m_exe_ctx.GetTargetPtr();
+ Process *process = m_exe_ctx.GetProcessPtr();
ABI *abi = NULL;
if (process)
abi = process->GetABI().get();
@@ -3603,7 +3576,7 @@ protected:
if (m_options.m_type == eLookupTypeFunctionOrSymbol)
{
SymbolContextList sc_list;
- uint32_t num_matches;
+ size_t num_matches;
ConstString function_name (m_options.m_str.c_str());
num_matches = target->GetImages().FindFunctions (function_name, eFunctionNameTypeAuto, true, false, true, sc_list);
for (uint32_t idx = 0; idx < num_matches; idx++)
@@ -3730,10 +3703,11 @@ public:
switch (short_option)
{
case 'a':
- m_type = eLookupTypeAddress;
- m_addr = Args::StringToUInt64(option_arg, LLDB_INVALID_ADDRESS);
- if (m_addr == LLDB_INVALID_ADDRESS)
- error.SetErrorStringWithFormat ("invalid address string '%s'", option_arg);
+ {
+ m_type = eLookupTypeAddress;
+ ExecutionContext exe_ctx (m_interpreter.GetExecutionContext());
+ m_addr = Args::StringToAddress(&exe_ctx, option_arg, LLDB_INVALID_ADDRESS, &error);
+ }
break;
case 'o':
@@ -3837,7 +3811,8 @@ public:
CommandObjectParsed (interpreter,
"target modules lookup",
"Look up information within executable and dependent shared library images.",
- NULL),
+ NULL,
+ eFlagRequiresTarget),
m_options (interpreter)
{
CommandArgumentEntry arg;
@@ -3881,9 +3856,7 @@ public:
break;
}
- ExecutionContext exe_ctx = interpreter.GetDebugger().GetSelectedExecutionContext();
-
- StackFrameSP frame = exe_ctx.GetFrameSP();
+ StackFrameSP frame = m_exe_ctx.GetFrameSP();
if (!frame)
return false;
@@ -4061,7 +4034,7 @@ protected:
const ModuleList &target_modules = target->GetImages();
Mutex::Locker modules_locker(target_modules.GetMutex());
- const uint32_t num_modules = target_modules.GetSize();
+ const size_t num_modules = target_modules.GetSize();
if (num_modules > 0)
{
for (i = 0; i<num_modules && syntax_error == false; ++i)
@@ -4125,7 +4098,7 @@ protected:
OptionDefinition
CommandObjectTargetModulesLookup::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_SET_1, true, "address", 'a', required_argument, NULL, 0, eArgTypeAddress, "Lookup an address in one or more target modules."},
+ { LLDB_OPT_SET_1, true, "address", 'a', required_argument, NULL, 0, eArgTypeAddressOrExpression, "Lookup an address in one or more target modules."},
{ LLDB_OPT_SET_1, false, "offset", 'o', required_argument, NULL, 0, eArgTypeOffset, "When looking up an address subtract <offset> from any addresses before doing the lookup."},
{ LLDB_OPT_SET_2| LLDB_OPT_SET_4 | LLDB_OPT_SET_5
/* FIXME: re-enable this for types when the LookupTypeInModule actually uses the regex option: | LLDB_OPT_SET_6 */ ,
@@ -4194,7 +4167,6 @@ public:
{
LoadSubCommand ("add", CommandObjectSP (new CommandObjectTargetModulesAdd (interpreter)));
LoadSubCommand ("load", CommandObjectSP (new CommandObjectTargetModulesLoad (interpreter)));
- //LoadSubCommand ("unload", CommandObjectSP (new CommandObjectTargetModulesUnload (interpreter)));
LoadSubCommand ("dump", CommandObjectSP (new CommandObjectTargetModulesDump (interpreter)));
LoadSubCommand ("list", CommandObjectSP (new CommandObjectTargetModulesList (interpreter)));
LoadSubCommand ("lookup", CommandObjectSP (new CommandObjectTargetModulesLookup (interpreter)));
@@ -4223,7 +4195,7 @@ public:
CommandObjectParsed (interpreter,
"target symbols add",
"Add a debug symbol file to one of the target's current modules by specifying a path to a debug symbols file, or using the options to specify a module to download symbols for.",
- "target symbols add [<symfile>]"),
+ "target symbols add [<symfile>]", eFlagRequiresTarget),
m_option_group (interpreter),
m_file_option (LLDB_OPT_SET_1, false, "shlib", 's', CommandCompletions::eModuleCompletion, eArgTypeShlibName, "Fullpath or basename for module to find debug symbols for."),
m_current_frame_option (LLDB_OPT_SET_2, false, "frame", 'F', "Locate the debug symbols the currently selected frame.", false, true)
@@ -4240,7 +4212,7 @@ public:
{
}
- int
+ virtual int
HandleArgumentCompletion (Args &input,
int &cursor_index,
int &cursor_char_position,
@@ -4295,7 +4267,24 @@ protected:
// current target, so we need to find that module in the
// target
ModuleList matching_module_list;
- const size_t num_matches = target->GetImages().FindModules (module_spec, matching_module_list);
+ size_t num_matches = target->GetImages().FindModules (module_spec, matching_module_list);
+ while (num_matches == 0)
+ {
+ ConstString filename_no_extension(module_spec.GetFileSpec().GetFileNameStrippingExtension());
+ // Empty string returned, lets bail
+ if (!filename_no_extension)
+ break;
+
+ // Check if there was no extension to strip and the basename is the same
+ if (filename_no_extension == module_spec.GetFileSpec().GetFilename())
+ break;
+
+ // Replace basename with one less extension
+ module_spec.GetFileSpec().GetFilename() = filename_no_extension;
+
+ num_matches = target->GetImages().FindModules (module_spec, matching_module_list);
+ }
+
if (num_matches > 1)
{
result.AppendErrorWithFormat ("multiple modules match symbol file '%s', use the --uuid option to resolve the ambiguity.\n", symfile_path);
@@ -4331,7 +4320,13 @@ protected:
// if it is currently loaded
ModuleList module_list;
module_list.Append (module_sp);
- target->ModulesDidLoad (module_list);
+ target->SymbolsDidLoad (module_list);
+
+ // Make sure we load any scripting resources that may be embedded
+ // in the debug info files in case the platform supports that.
+ Error error;
+ module_sp->LoadScriptingResourceInTarget (target, error);
+
flush = true;
result.SetStatus (eReturnStatusSuccessFinishResult);
return true;
@@ -4340,7 +4335,6 @@ protected:
}
// Clear the symbol file spec if anything went wrong
module_sp->SetSymbolFileFileSpec (FileSpec());
-
}
if (module_spec.GetUUID().IsValid())
@@ -4375,198 +4369,190 @@ protected:
DoExecute (Args& args,
CommandReturnObject &result)
{
- ExecutionContext exe_ctx (m_interpreter.GetExecutionContext());
- Target *target = exe_ctx.GetTargetPtr();
+ Target *target = m_exe_ctx.GetTargetPtr();
result.SetStatus (eReturnStatusFailed);
- if (target == NULL)
- {
- result.AppendError ("invalid target, create a debug target using the 'target create' command");
- }
- else
- {
- bool flush = false;
- ModuleSpec module_spec;
- const bool uuid_option_set = m_uuid_option_group.GetOptionValue().OptionWasSet();
- const bool file_option_set = m_file_option.GetOptionValue().OptionWasSet();
- const bool frame_option_set = m_current_frame_option.GetOptionValue().OptionWasSet();
+ bool flush = false;
+ ModuleSpec module_spec;
+ const bool uuid_option_set = m_uuid_option_group.GetOptionValue().OptionWasSet();
+ const bool file_option_set = m_file_option.GetOptionValue().OptionWasSet();
+ const bool frame_option_set = m_current_frame_option.GetOptionValue().OptionWasSet();
- const size_t argc = args.GetArgumentCount();
- if (argc == 0)
+ const size_t argc = args.GetArgumentCount();
+ if (argc == 0)
+ {
+ if (uuid_option_set || file_option_set || frame_option_set)
{
- if (uuid_option_set || file_option_set || frame_option_set)
+ bool success = false;
+ bool error_set = false;
+ if (frame_option_set)
{
- bool success = false;
- bool error_set = false;
- if (frame_option_set)
+ Process *process = m_exe_ctx.GetProcessPtr();
+ if (process)
{
- Process *process = exe_ctx.GetProcessPtr();
- if (process)
+ const StateType process_state = process->GetState();
+ if (StateIsStoppedState (process_state, true))
{
- const StateType process_state = process->GetState();
- if (StateIsStoppedState (process_state, true))
+ StackFrame *frame = m_exe_ctx.GetFramePtr();
+ if (frame)
{
- StackFrame *frame = exe_ctx.GetFramePtr();
- if (frame)
+ ModuleSP frame_module_sp (frame->GetSymbolContext(eSymbolContextModule).module_sp);
+ if (frame_module_sp)
{
- ModuleSP frame_module_sp (frame->GetSymbolContext(eSymbolContextModule).module_sp);
- if (frame_module_sp)
+ if (frame_module_sp->GetPlatformFileSpec().Exists())
{
- if (frame_module_sp->GetPlatformFileSpec().Exists())
- {
- module_spec.GetArchitecture() = frame_module_sp->GetArchitecture();
- module_spec.GetFileSpec() = frame_module_sp->GetPlatformFileSpec();
- }
- module_spec.GetUUID() = frame_module_sp->GetUUID();
- success = module_spec.GetUUID().IsValid() || module_spec.GetFileSpec();
- }
- else
- {
- result.AppendError ("frame has no module");
- error_set = true;
+ module_spec.GetArchitecture() = frame_module_sp->GetArchitecture();
+ module_spec.GetFileSpec() = frame_module_sp->GetPlatformFileSpec();
}
+ module_spec.GetUUID() = frame_module_sp->GetUUID();
+ success = module_spec.GetUUID().IsValid() || module_spec.GetFileSpec();
}
else
{
- result.AppendError ("invalid current frame");
+ result.AppendError ("frame has no module");
error_set = true;
}
}
else
{
- result.AppendErrorWithFormat ("process is not stopped: %s", StateAsCString(process_state));
+ result.AppendError ("invalid current frame");
error_set = true;
}
}
else
{
- result.AppendError ("a process must exist in order to use the --frame option");
+ result.AppendErrorWithFormat ("process is not stopped: %s", StateAsCString(process_state));
error_set = true;
}
}
else
{
- if (uuid_option_set)
- {
- module_spec.GetUUID() = m_uuid_option_group.GetOptionValue().GetCurrentValue();
- success |= module_spec.GetUUID().IsValid();
- }
- else if (file_option_set)
- {
- module_spec.GetFileSpec() = m_file_option.GetOptionValue().GetCurrentValue();
- ModuleSP module_sp (target->GetImages().FindFirstModule(module_spec));
- if (module_sp)
- {
- module_spec.GetFileSpec() = module_sp->GetFileSpec();
- module_spec.GetPlatformFileSpec() = module_sp->GetPlatformFileSpec();
- module_spec.GetUUID() = module_sp->GetUUID();
- module_spec.GetArchitecture() = module_sp->GetArchitecture();
- }
- else
- {
- module_spec.GetArchitecture() = target->GetArchitecture();
- }
- success |= module_spec.GetFileSpec().Exists();
- }
+ result.AppendError ("a process must exist in order to use the --frame option");
+ error_set = true;
}
-
- if (success)
+ }
+ else
+ {
+ if (uuid_option_set)
{
- if (Symbols::DownloadObjectAndSymbolFile (module_spec))
- {
- if (module_spec.GetSymbolFileSpec())
- success = AddModuleSymbols (target, module_spec, flush, result);
- }
+ module_spec.GetUUID() = m_uuid_option_group.GetOptionValue().GetCurrentValue();
+ success |= module_spec.GetUUID().IsValid();
}
-
- if (!success && !error_set)
+ else if (file_option_set)
{
- StreamString error_strm;
- if (uuid_option_set)
- {
- error_strm.PutCString("unable to find debug symbols for UUID ");
- module_spec.GetUUID().Dump (&error_strm);
- }
- else if (file_option_set)
+ module_spec.GetFileSpec() = m_file_option.GetOptionValue().GetCurrentValue();
+ ModuleSP module_sp (target->GetImages().FindFirstModule(module_spec));
+ if (module_sp)
{
- error_strm.PutCString("unable to find debug symbols for the executable file ");
- error_strm << module_spec.GetFileSpec();
+ module_spec.GetFileSpec() = module_sp->GetFileSpec();
+ module_spec.GetPlatformFileSpec() = module_sp->GetPlatformFileSpec();
+ module_spec.GetUUID() = module_sp->GetUUID();
+ module_spec.GetArchitecture() = module_sp->GetArchitecture();
}
- else if (frame_option_set)
+ else
{
- error_strm.PutCString("unable to find debug symbols for the current frame");
+ module_spec.GetArchitecture() = target->GetArchitecture();
}
- result.AppendError (error_strm.GetData());
+ success |= module_spec.GetFileSpec().Exists();
}
}
- else
+
+ if (success)
{
- result.AppendError ("one or more symbol file paths must be specified, or options must be specified");
+ if (Symbols::DownloadObjectAndSymbolFile (module_spec))
+ {
+ if (module_spec.GetSymbolFileSpec())
+ success = AddModuleSymbols (target, module_spec, flush, result);
+ }
+ }
+
+ if (!success && !error_set)
+ {
+ StreamString error_strm;
+ if (uuid_option_set)
+ {
+ error_strm.PutCString("unable to find debug symbols for UUID ");
+ module_spec.GetUUID().Dump (&error_strm);
+ }
+ else if (file_option_set)
+ {
+ error_strm.PutCString("unable to find debug symbols for the executable file ");
+ error_strm << module_spec.GetFileSpec();
+ }
+ else if (frame_option_set)
+ {
+ error_strm.PutCString("unable to find debug symbols for the current frame");
+ }
+ result.AppendError (error_strm.GetData());
}
}
else
{
- if (uuid_option_set)
- {
- result.AppendError ("specify either one or more paths to symbol files or use the --uuid option without arguments");
- }
- else if (file_option_set)
- {
- result.AppendError ("specify either one or more paths to symbol files or use the --file option without arguments");
- }
- else if (frame_option_set)
- {
- result.AppendError ("specify either one or more paths to symbol files or use the --frame option without arguments");
- }
- else
- {
- PlatformSP platform_sp (target->GetPlatform());
+ result.AppendError ("one or more symbol file paths must be specified, or options must be specified");
+ }
+ }
+ else
+ {
+ if (uuid_option_set)
+ {
+ result.AppendError ("specify either one or more paths to symbol files or use the --uuid option without arguments");
+ }
+ else if (file_option_set)
+ {
+ result.AppendError ("specify either one or more paths to symbol files or use the --file option without arguments");
+ }
+ else if (frame_option_set)
+ {
+ result.AppendError ("specify either one or more paths to symbol files or use the --frame option without arguments");
+ }
+ else
+ {
+ PlatformSP platform_sp (target->GetPlatform());
- for (size_t i=0; i<argc; ++i)
+ for (size_t i=0; i<argc; ++i)
+ {
+ const char *symfile_path = args.GetArgumentAtIndex(i);
+ if (symfile_path)
{
- const char *symfile_path = args.GetArgumentAtIndex(i);
- if (symfile_path)
+ module_spec.GetSymbolFileSpec().SetFile(symfile_path, true);
+ if (platform_sp)
{
- module_spec.GetSymbolFileSpec().SetFile(symfile_path, true);
- if (platform_sp)
- {
- FileSpec symfile_spec;
- if (platform_sp->ResolveSymbolFile(*target, module_spec, symfile_spec).Success())
- module_spec.GetSymbolFileSpec() = symfile_spec;
- }
-
- ArchSpec arch;
- bool symfile_exists = module_spec.GetSymbolFileSpec().Exists();
+ FileSpec symfile_spec;
+ if (platform_sp->ResolveSymbolFile(*target, module_spec, symfile_spec).Success())
+ module_spec.GetSymbolFileSpec() = symfile_spec;
+ }
+
+ ArchSpec arch;
+ bool symfile_exists = module_spec.GetSymbolFileSpec().Exists();
- if (symfile_exists)
- {
- if (!AddModuleSymbols (target, module_spec, flush, result))
- break;
- }
- else
+ if (symfile_exists)
+ {
+ if (!AddModuleSymbols (target, module_spec, flush, result))
+ break;
+ }
+ else
+ {
+ char resolved_symfile_path[PATH_MAX];
+ if (module_spec.GetSymbolFileSpec().GetPath (resolved_symfile_path, sizeof(resolved_symfile_path)))
{
- char resolved_symfile_path[PATH_MAX];
- if (module_spec.GetSymbolFileSpec().GetPath (resolved_symfile_path, sizeof(resolved_symfile_path)))
+ if (strcmp (resolved_symfile_path, symfile_path) != 0)
{
- if (strcmp (resolved_symfile_path, symfile_path) != 0)
- {
- result.AppendErrorWithFormat ("invalid module path '%s' with resolved path '%s'\n", symfile_path, resolved_symfile_path);
- break;
- }
+ result.AppendErrorWithFormat ("invalid module path '%s' with resolved path '%s'\n", symfile_path, resolved_symfile_path);
+ break;
}
- result.AppendErrorWithFormat ("invalid module path '%s'\n", symfile_path);
- break;
}
+ result.AppendErrorWithFormat ("invalid module path '%s'\n", symfile_path);
+ break;
}
}
}
}
+ }
- if (flush)
- {
- Process *process = exe_ctx.GetProcessPtr();
- if (process)
- process->Flush();
- }
+ if (flush)
+ {
+ Process *process = m_exe_ctx.GetProcessPtr();
+ if (process)
+ process->Flush();
}
return result.Succeeded();
}
Modified: lldb/branches/windows/source/Commands/CommandObjectThread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Commands/CommandObjectThread.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Commands/CommandObjectThread.cpp (original)
+++ lldb/branches/windows/source/Commands/CommandObjectThread.cpp Wed Apr 17 03:38:48 2013
@@ -125,10 +125,14 @@ public:
CommandObjectThreadBacktrace (CommandInterpreter &interpreter) :
CommandObjectParsed (interpreter,
- "thread backtrace",
- "Show the stack for one or more threads. If no threads are specified, show the currently selected thread. Use the thread-index \"all\" to see all threads.",
- NULL,
- eFlagProcessMustBeLaunched | eFlagProcessMustBePaused),
+ "thread backtrace",
+ "Show the stack for one or more threads. If no threads are specified, show the currently selected thread. Use the thread-index \"all\" to see all threads.",
+ NULL,
+ eFlagRequiresProcess |
+ eFlagRequiresThread |
+ eFlagTryTargetAPILock |
+ eFlagProcessMustBeLaunched |
+ eFlagProcessMustBePaused ),
m_options(interpreter)
{
CommandArgumentEntry arg;
@@ -166,28 +170,19 @@ protected:
const uint32_t num_frames_with_source = 0;
if (command.GetArgumentCount() == 0)
{
- ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
- Thread *thread = exe_ctx.GetThreadPtr();
- if (thread)
- {
- // Thread::GetStatus() returns the number of frames shown.
- if (thread->GetStatus (strm,
- m_options.m_start,
- m_options.m_count,
- num_frames_with_source))
- {
- result.SetStatus (eReturnStatusSuccessFinishResult);
- }
- }
- else
+ Thread *thread = m_exe_ctx.GetThreadPtr();
+ // Thread::GetStatus() returns the number of frames shown.
+ if (thread->GetStatus (strm,
+ m_options.m_start,
+ m_options.m_count,
+ num_frames_with_source))
{
- result.AppendError ("invalid thread");
- result.SetStatus (eReturnStatusFailed);
+ result.SetStatus (eReturnStatusSuccessFinishResult);
}
}
else if (command.GetArgumentCount() == 1 && ::strcmp (command.GetArgumentAtIndex(0), "all") == 0)
{
- Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
+ Process *process = m_exe_ctx.GetProcessPtr();
Mutex::Locker locker (process->GetThreadList().GetMutex());
uint32_t num_threads = process->GetThreadList().GetSize();
for (uint32_t i = 0; i < num_threads; i++)
@@ -210,12 +205,12 @@ protected:
}
else
{
- uint32_t num_args = command.GetArgumentCount();
- Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
+ const size_t num_args = command.GetArgumentCount();
+ Process *process = m_exe_ctx.GetProcessPtr();
Mutex::Locker locker (process->GetThreadList().GetMutex());
std::vector<ThreadSP> thread_sps;
- for (uint32_t i = 0; i < num_args; i++)
+ for (size_t i = 0; i < num_args; i++)
{
bool success;
@@ -370,10 +365,14 @@ public:
const char *name,
const char *help,
const char *syntax,
- uint32_t flags,
StepType step_type,
StepScope step_scope) :
- CommandObjectParsed (interpreter, name, help, syntax, flags),
+ CommandObjectParsed (interpreter, name, help, syntax,
+ eFlagRequiresProcess |
+ eFlagRequiresThread |
+ eFlagTryTargetAPILock |
+ eFlagProcessMustBeLaunched |
+ eFlagProcessMustBePaused ),
m_step_type (step_type),
m_step_scope (step_scope),
m_options (interpreter)
@@ -408,170 +407,161 @@ protected:
virtual bool
DoExecute (Args& command, CommandReturnObject &result)
{
- Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
+ Process *process = m_exe_ctx.GetProcessPtr();
bool synchronous_execution = m_interpreter.GetSynchronous();
- if (process == NULL)
- {
- result.AppendError ("need a valid process to step");
- result.SetStatus (eReturnStatusFailed);
+ const uint32_t num_threads = process->GetThreadList().GetSize();
+ Thread *thread = NULL;
+ if (command.GetArgumentCount() == 0)
+ {
+ thread = process->GetThreadList().GetSelectedThread().get();
+ if (thread == NULL)
+ {
+ result.AppendError ("no selected thread in process");
+ result.SetStatus (eReturnStatusFailed);
+ return false;
+ }
}
else
{
- const uint32_t num_threads = process->GetThreadList().GetSize();
- Thread *thread = NULL;
-
- if (command.GetArgumentCount() == 0)
+ const char *thread_idx_cstr = command.GetArgumentAtIndex(0);
+ uint32_t step_thread_idx = Args::StringToUInt32 (thread_idx_cstr, LLDB_INVALID_INDEX32);
+ if (step_thread_idx == LLDB_INVALID_INDEX32)
{
- thread = process->GetThreadList().GetSelectedThread().get();
- if (thread == NULL)
- {
- result.AppendError ("no selected thread in process");
- result.SetStatus (eReturnStatusFailed);
- return false;
- }
+ result.AppendErrorWithFormat ("invalid thread index '%s'.\n", thread_idx_cstr);
+ result.SetStatus (eReturnStatusFailed);
+ return false;
}
- else
+ thread = process->GetThreadList().FindThreadByIndexID(step_thread_idx).get();
+ if (thread == NULL)
{
- const char *thread_idx_cstr = command.GetArgumentAtIndex(0);
- uint32_t step_thread_idx = Args::StringToUInt32 (thread_idx_cstr, LLDB_INVALID_INDEX32);
- if (step_thread_idx == LLDB_INVALID_INDEX32)
- {
- result.AppendErrorWithFormat ("invalid thread index '%s'.\n", thread_idx_cstr);
- result.SetStatus (eReturnStatusFailed);
- return false;
- }
- thread = process->GetThreadList().FindThreadByIndexID(step_thread_idx).get();
- if (thread == NULL)
- {
- result.AppendErrorWithFormat ("Thread index %u is out of range (valid values are 0 - %u).\n",
- step_thread_idx, num_threads);
- result.SetStatus (eReturnStatusFailed);
- return false;
- }
+ result.AppendErrorWithFormat ("Thread index %u is out of range (valid values are 0 - %u).\n",
+ step_thread_idx, num_threads);
+ result.SetStatus (eReturnStatusFailed);
+ return false;
}
+ }
- const bool abort_other_plans = false;
- const lldb::RunMode stop_other_threads = m_options.m_run_mode;
-
- // This is a bit unfortunate, but not all the commands in this command object support
- // only while stepping, so I use the bool for them.
- bool bool_stop_other_threads;
- if (m_options.m_run_mode == eAllThreads)
+ const bool abort_other_plans = false;
+ const lldb::RunMode stop_other_threads = m_options.m_run_mode;
+
+ // This is a bit unfortunate, but not all the commands in this command object support
+ // only while stepping, so I use the bool for them.
+ bool bool_stop_other_threads;
+ if (m_options.m_run_mode == eAllThreads)
+ bool_stop_other_threads = false;
+ else if (m_options.m_run_mode == eOnlyDuringStepping)
+ {
+ if (m_step_type == eStepTypeOut)
bool_stop_other_threads = false;
- else if (m_options.m_run_mode == eOnlyDuringStepping)
- {
- if (m_step_type == eStepTypeOut)
- bool_stop_other_threads = false;
- else
- bool_stop_other_threads = true;
- }
else
bool_stop_other_threads = true;
+ }
+ else
+ bool_stop_other_threads = true;
- ThreadPlan *new_plan = NULL;
-
- if (m_step_type == eStepTypeInto)
- {
- StackFrame *frame = thread->GetStackFrameAtIndex(0).get();
+ ThreadPlan *new_plan = NULL;
+
+ if (m_step_type == eStepTypeInto)
+ {
+ StackFrame *frame = thread->GetStackFrameAtIndex(0).get();
- if (frame->HasDebugInformation ())
+ if (frame->HasDebugInformation ())
+ {
+ new_plan = thread->QueueThreadPlanForStepInRange (abort_other_plans,
+ frame->GetSymbolContext(eSymbolContextEverything).line_entry.range,
+ frame->GetSymbolContext(eSymbolContextEverything),
+ m_options.m_step_in_target.c_str(),
+ stop_other_threads,
+ m_options.m_avoid_no_debug);
+ if (new_plan && !m_options.m_avoid_regexp.empty())
{
- new_plan = thread->QueueThreadPlanForStepInRange (abort_other_plans,
- frame->GetSymbolContext(eSymbolContextEverything).line_entry.range,
- frame->GetSymbolContext(eSymbolContextEverything),
- m_options.m_step_in_target.c_str(),
- stop_other_threads,
- m_options.m_avoid_no_debug);
- if (new_plan && !m_options.m_avoid_regexp.empty())
- {
- ThreadPlanStepInRange *step_in_range_plan = static_cast<ThreadPlanStepInRange *> (new_plan);
- step_in_range_plan->SetAvoidRegexp(m_options.m_avoid_regexp.c_str());
- }
+ ThreadPlanStepInRange *step_in_range_plan = static_cast<ThreadPlanStepInRange *> (new_plan);
+ step_in_range_plan->SetAvoidRegexp(m_options.m_avoid_regexp.c_str());
}
- else
- new_plan = thread->QueueThreadPlanForStepSingleInstruction (false, abort_other_plans, bool_stop_other_threads);
-
}
- else if (m_step_type == eStepTypeOver)
- {
- StackFrame *frame = thread->GetStackFrameAtIndex(0).get();
-
- if (frame->HasDebugInformation())
- new_plan = thread->QueueThreadPlanForStepOverRange (abort_other_plans,
- frame->GetSymbolContext(eSymbolContextEverything).line_entry.range,
- frame->GetSymbolContext(eSymbolContextEverything),
- stop_other_threads);
- else
- new_plan = thread->QueueThreadPlanForStepSingleInstruction (true,
- abort_other_plans,
- bool_stop_other_threads);
-
- }
- else if (m_step_type == eStepTypeTrace)
- {
+ else
new_plan = thread->QueueThreadPlanForStepSingleInstruction (false, abort_other_plans, bool_stop_other_threads);
- }
- else if (m_step_type == eStepTypeTraceOver)
- {
- new_plan = thread->QueueThreadPlanForStepSingleInstruction (true, abort_other_plans, bool_stop_other_threads);
- }
- else if (m_step_type == eStepTypeOut)
- {
- new_plan = thread->QueueThreadPlanForStepOut (abort_other_plans,
- NULL,
- false,
- bool_stop_other_threads,
- eVoteYes,
- eVoteNoOpinion,
- thread->GetSelectedFrameIndex());
- }
+
+ }
+ else if (m_step_type == eStepTypeOver)
+ {
+ StackFrame *frame = thread->GetStackFrameAtIndex(0).get();
+
+ if (frame->HasDebugInformation())
+ new_plan = thread->QueueThreadPlanForStepOverRange (abort_other_plans,
+ frame->GetSymbolContext(eSymbolContextEverything).line_entry.range,
+ frame->GetSymbolContext(eSymbolContextEverything),
+ stop_other_threads);
else
- {
- result.AppendError ("step type is not supported");
- result.SetStatus (eReturnStatusFailed);
- return false;
- }
-
- // If we got a new plan, then set it to be a master plan (User level Plans should be master plans
- // so that they can be interruptible). Then resume the process.
-
- if (new_plan != NULL)
- {
- new_plan->SetIsMasterPlan (true);
- new_plan->SetOkayToDiscard (false);
+ new_plan = thread->QueueThreadPlanForStepSingleInstruction (true,
+ abort_other_plans,
+ bool_stop_other_threads);
- process->GetThreadList().SetSelectedThreadByID (thread->GetID());
- process->Resume ();
-
+ }
+ else if (m_step_type == eStepTypeTrace)
+ {
+ new_plan = thread->QueueThreadPlanForStepSingleInstruction (false, abort_other_plans, bool_stop_other_threads);
+ }
+ else if (m_step_type == eStepTypeTraceOver)
+ {
+ new_plan = thread->QueueThreadPlanForStepSingleInstruction (true, abort_other_plans, bool_stop_other_threads);
+ }
+ else if (m_step_type == eStepTypeOut)
+ {
+ new_plan = thread->QueueThreadPlanForStepOut (abort_other_plans,
+ NULL,
+ false,
+ bool_stop_other_threads,
+ eVoteYes,
+ eVoteNoOpinion,
+ thread->GetSelectedFrameIndex());
+ }
+ else
+ {
+ result.AppendError ("step type is not supported");
+ result.SetStatus (eReturnStatusFailed);
+ return false;
+ }
+
+ // If we got a new plan, then set it to be a master plan (User level Plans should be master plans
+ // so that they can be interruptible). Then resume the process.
+
+ if (new_plan != NULL)
+ {
+ new_plan->SetIsMasterPlan (true);
+ new_plan->SetOkayToDiscard (false);
- if (synchronous_execution)
- {
- StateType state = process->WaitForProcessToStop (NULL);
-
- //EventSP event_sp;
- //StateType state = process->WaitForStateChangedEvents (NULL, event_sp);
- //while (! StateIsStoppedState (state))
- // {
- // state = process->WaitForStateChangedEvents (NULL, event_sp);
- // }
- process->GetThreadList().SetSelectedThreadByID (thread->GetID());
- result.SetDidChangeProcessState (true);
- result.AppendMessageWithFormat ("Process %" PRIu64 " %s\n", process->GetID(), StateAsCString (state));
- result.SetStatus (eReturnStatusSuccessFinishNoResult);
- }
- else
- {
- result.SetStatus (eReturnStatusSuccessContinuingNoResult);
- }
+ process->GetThreadList().SetSelectedThreadByID (thread->GetID());
+ process->Resume ();
+
+
+ if (synchronous_execution)
+ {
+ StateType state = process->WaitForProcessToStop (NULL);
+
+ //EventSP event_sp;
+ //StateType state = process->WaitForStateChangedEvents (NULL, event_sp);
+ //while (! StateIsStoppedState (state))
+ // {
+ // state = process->WaitForStateChangedEvents (NULL, event_sp);
+ // }
+ process->GetThreadList().SetSelectedThreadByID (thread->GetID());
+ result.SetDidChangeProcessState (true);
+ result.AppendMessageWithFormat ("Process %" PRIu64 " %s\n", process->GetID(), StateAsCString (state));
+ result.SetStatus (eReturnStatusSuccessFinishNoResult);
}
else
{
- result.AppendError ("Couldn't find thread plan to implement step type.");
- result.SetStatus (eReturnStatusFailed);
+ result.SetStatus (eReturnStatusSuccessContinuingNoResult);
}
}
+ else
+ {
+ result.AppendError ("Couldn't find thread plan to implement step type.");
+ result.SetStatus (eReturnStatusFailed);
+ }
return result.Succeeded();
}
@@ -622,7 +612,10 @@ public:
"thread continue",
"Continue execution of one or more threads in an active process.",
NULL,
- eFlagProcessMustBeLaunched | eFlagProcessMustBePaused)
+ eFlagRequiresThread |
+ eFlagTryTargetAPILock |
+ eFlagProcessMustBeLaunched |
+ eFlagProcessMustBePaused)
{
CommandArgumentEntry arg;
CommandArgumentData thread_idx_arg;
@@ -656,7 +649,7 @@ public:
return false;
}
- Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
+ Process *process = m_exe_ctx.GetProcessPtr();
if (process == NULL)
{
result.AppendError ("no process exists. Cannot continue");
@@ -902,7 +895,10 @@ public:
"thread until",
"Run the current or specified thread until it reaches a given line number or leaves the current function.",
NULL,
- eFlagProcessMustBeLaunched | eFlagProcessMustBePaused),
+ eFlagRequiresThread |
+ eFlagTryTargetAPILock |
+ eFlagProcessMustBeLaunched |
+ eFlagProcessMustBePaused ),
m_options (interpreter)
{
CommandArgumentEntry arg;
@@ -946,7 +942,7 @@ protected:
return false;
}
- Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
+ Process *process = m_exe_ctx.GetProcessPtr();
if (process == NULL)
{
result.AppendError ("need a valid process to step");
@@ -1144,7 +1140,10 @@ public:
"thread select",
"Select a thread as the currently active thread.",
NULL,
- eFlagProcessMustBeLaunched | eFlagProcessMustBePaused)
+ eFlagRequiresProcess |
+ eFlagTryTargetAPILock |
+ eFlagProcessMustBeLaunched |
+ eFlagProcessMustBePaused )
{
CommandArgumentEntry arg;
CommandArgumentData thread_idx_arg;
@@ -1170,7 +1169,7 @@ protected:
virtual bool
DoExecute (Args& command, CommandReturnObject &result)
{
- Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
+ Process *process = m_exe_ctx.GetProcessPtr();
if (process == NULL)
{
result.AppendError ("no process");
@@ -1217,7 +1216,10 @@ public:
"thread list",
"Show a summary of all current threads in a process.",
"thread list",
- eFlagProcessMustBeLaunched | eFlagProcessMustBePaused)
+ eFlagRequiresProcess |
+ eFlagTryTargetAPILock |
+ eFlagProcessMustBeLaunched |
+ eFlagProcessMustBePaused )
{
}
@@ -1231,46 +1233,119 @@ protected:
{
Stream &strm = result.GetOutputStream();
result.SetStatus (eReturnStatusSuccessFinishNoResult);
- ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
- Process *process = exe_ctx.GetProcessPtr();
- if (process)
- {
- const bool only_threads_with_stop_reason = false;
- const uint32_t start_frame = 0;
- const uint32_t num_frames = 0;
- const uint32_t num_frames_with_source = 0;
- process->GetStatus(strm);
- process->GetThreadStatus (strm,
- only_threads_with_stop_reason,
- start_frame,
- num_frames,
- num_frames_with_source);
- }
- else
- {
- result.AppendError ("no current location or status available");
- result.SetStatus (eReturnStatusFailed);
- }
+ Process *process = m_exe_ctx.GetProcessPtr();
+ const bool only_threads_with_stop_reason = false;
+ const uint32_t start_frame = 0;
+ const uint32_t num_frames = 0;
+ const uint32_t num_frames_with_source = 0;
+ process->GetStatus(strm);
+ process->GetThreadStatus (strm,
+ only_threads_with_stop_reason,
+ start_frame,
+ num_frames,
+ num_frames_with_source);
return result.Succeeded();
}
};
+//-------------------------------------------------------------------------
+// CommandObjectThreadReturn
+//-------------------------------------------------------------------------
+
class CommandObjectThreadReturn : public CommandObjectRaw
{
public:
+ class CommandOptions : public Options
+ {
+ public:
+
+ CommandOptions (CommandInterpreter &interpreter) :
+ Options (interpreter),
+ m_from_expression (false)
+ {
+ // Keep default values of all options in one place: OptionParsingStarting ()
+ OptionParsingStarting ();
+ }
+
+ virtual
+ ~CommandOptions ()
+ {
+ }
+
+ virtual Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg)
+ {
+ Error error;
+ const int short_option = m_getopt_table[option_idx].val;
+
+ switch (short_option)
+ {
+ case 'x':
+ {
+ bool success;
+ bool tmp_value = Args::StringToBoolean (option_arg, false, &success);
+ if (success)
+ m_from_expression = tmp_value;
+ else
+ {
+ error.SetErrorStringWithFormat ("invalid boolean value '%s' for 'x' option", option_arg);
+ }
+ }
+ break;
+ default:
+ error.SetErrorStringWithFormat("invalid short option character '%c'", short_option);
+ break;
+
+ }
+ return error;
+ }
+
+ void
+ OptionParsingStarting ()
+ {
+ m_from_expression = false;
+ }
+
+ const OptionDefinition*
+ GetDefinitions ()
+ {
+ return g_option_table;
+ }
+
+ bool m_from_expression;
+
+ // Options table: Required for subclasses of Options.
+
+ static OptionDefinition g_option_table[];
+
+ // Instance variables to hold the values for command options.
+ };
+
+ virtual
+ Options *
+ GetOptions ()
+ {
+ return &m_options;
+ }
+
CommandObjectThreadReturn (CommandInterpreter &interpreter) :
CommandObjectRaw (interpreter,
"thread return",
- "Return from the currently selected frame, short-circuiting execution of the frames below it, with an optional return value.",
+ "Return from the currently selected frame, short-circuiting execution of the frames below it, with an optional return value,"
+ " or with the -x option from the innermost function evaluation.",
"thread return",
- eFlagProcessMustBeLaunched | eFlagProcessMustBePaused)
+ eFlagRequiresFrame |
+ eFlagTryTargetAPILock |
+ eFlagProcessMustBeLaunched |
+ eFlagProcessMustBePaused ),
+ m_options (interpreter)
{
CommandArgumentEntry arg;
CommandArgumentData expression_arg;
// Define the first (and only) variant of this arg.
expression_arg.arg_type = eArgTypeExpression;
- expression_arg.arg_repetition = eArgRepeatPlain;
+ expression_arg.arg_repetition = eArgRepeatOptional;
// There is only one variant this argument could be; put it into the argument entry.
arg.push_back (expression_arg);
@@ -1293,18 +1368,41 @@ protected:
CommandReturnObject &result
)
{
- // If there is a command string, pass it to the expression parser:
- ExecutionContext exe_ctx = m_interpreter.GetExecutionContext();
- if (!(exe_ctx.HasProcessScope() && exe_ctx.HasThreadScope() && exe_ctx.HasFrameScope()))
+ // I am going to handle this by hand, because I don't want you to have to say:
+ // "thread return -- -5".
+ if (command[0] == '-' && command[1] == 'x')
{
- result.AppendError("Must have selected process, thread and frame for thread return.");
- result.SetStatus (eReturnStatusFailed);
- return false;
+ if (command && command[2] != '\0')
+ result.AppendWarning("Return values ignored when returning from user called expressions");
+
+ Thread *thread = m_exe_ctx.GetThreadPtr();
+ Error error;
+ error = thread->UnwindInnermostExpression();
+ if (!error.Success())
+ {
+ result.AppendErrorWithFormat ("Unwinding expression failed - %s.", error.AsCString());
+ result.SetStatus (eReturnStatusFailed);
+ }
+ else
+ {
+ bool success = thread->SetSelectedFrameByIndexNoisily (0, result.GetOutputStream());
+ if (success)
+ {
+ m_exe_ctx.SetFrameSP(thread->GetSelectedFrame ());
+ result.SetStatus (eReturnStatusSuccessFinishResult);
+ }
+ else
+ {
+ result.AppendErrorWithFormat ("Could not select 0th frame after unwinding expression.");
+ result.SetStatus (eReturnStatusFailed);
+ }
+ }
+ return result.Succeeded();
}
ValueObjectSP return_valobj_sp;
- StackFrameSP frame_sp = exe_ctx.GetFrameSP();
+ StackFrameSP frame_sp = m_exe_ctx.GetFrameSP();
uint32_t frame_idx = frame_sp->GetFrameIndex();
if (frame_sp->IsInlined())
@@ -1316,7 +1414,7 @@ protected:
if (command && command[0] != '\0')
{
- Target *target = exe_ctx.GetTargetPtr();
+ Target *target = m_exe_ctx.GetTargetPtr();
EvaluateExpressionOptions options;
options.SetUnwindOnError(true);
@@ -1340,7 +1438,7 @@ protected:
}
Error error;
- ThreadSP thread_sp = exe_ctx.GetThreadSP();
+ ThreadSP thread_sp = m_exe_ctx.GetThreadSP();
const bool broadcast = true;
error = thread_sp->ReturnFromFrame (frame_sp, return_valobj_sp, broadcast);
if (!error.Success())
@@ -1353,8 +1451,16 @@ protected:
result.SetStatus (eReturnStatusSuccessFinishResult);
return true;
}
+
+ CommandOptions m_options;
};
+OptionDefinition
+CommandObjectThreadReturn::CommandOptions::g_option_table[] =
+{
+{ LLDB_OPT_SET_ALL, false, "from-expression", 'x', no_argument, NULL, 0, eArgTypeNone, "Return from the innermost expression evaluation."},
+{ 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
+};
//-------------------------------------------------------------------------
// CommandObjectMultiwordThread
@@ -1377,7 +1483,6 @@ CommandObjectMultiwordThread::CommandObj
"thread step-in",
"Source level single step in specified thread (current thread, if none specified).",
NULL,
- eFlagProcessMustBeLaunched | eFlagProcessMustBePaused,
eStepTypeInto,
eStepScopeSource)));
@@ -1386,7 +1491,6 @@ CommandObjectMultiwordThread::CommandObj
"thread step-out",
"Finish executing the function of the currently selected frame and return to its call site in specified thread (current thread, if none specified).",
NULL,
- eFlagProcessMustBeLaunched | eFlagProcessMustBePaused,
eStepTypeOut,
eStepScopeSource)));
@@ -1395,7 +1499,6 @@ CommandObjectMultiwordThread::CommandObj
"thread step-over",
"Source level single step in specified thread (current thread, if none specified), stepping over calls.",
NULL,
- eFlagProcessMustBeLaunched | eFlagProcessMustBePaused,
eStepTypeOver,
eStepScopeSource)));
@@ -1404,7 +1507,6 @@ CommandObjectMultiwordThread::CommandObj
"thread step-inst",
"Single step one instruction in specified thread (current thread, if none specified).",
NULL,
- eFlagProcessMustBeLaunched | eFlagProcessMustBePaused,
eStepTypeTrace,
eStepScopeInstruction)));
@@ -1413,7 +1515,6 @@ CommandObjectMultiwordThread::CommandObj
"thread step-inst-over",
"Single step one instruction in specified thread (current thread, if none specified), stepping over calls.",
NULL,
- eFlagProcessMustBeLaunched | eFlagProcessMustBePaused,
eStepTypeTraceOver,
eStepScopeInstruction)));
}
Modified: lldb/branches/windows/source/Commands/CommandObjectType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Commands/CommandObjectType.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Commands/CommandObjectType.cpp (original)
+++ lldb/branches/windows/source/Commands/CommandObjectType.cpp Wed Apr 17 03:38:48 2013
@@ -17,13 +17,13 @@
// C++ Includes
-#include "lldb/Core/DataVisualization.h"
#include "lldb/Core/ConstString.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/InputReaderEZ.h"
#include "lldb/Core/RegularExpression.h"
#include "lldb/Core/State.h"
#include "lldb/Core/StringList.h"
+#include "lldb/DataFormatters/DataVisualization.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandObject.h"
#include "lldb/Interpreter/CommandReturnObject.h"
@@ -1961,7 +1961,7 @@ protected:
if (argc == 1 && strcmp(command.GetArgumentAtIndex(0),"*") == 0)
{
// we want to make sure to enable "system" last and "default" first
- DataVisualization::Categories::Enable(ConstString("default"), CategoryMap::First);
+ DataVisualization::Categories::Enable(ConstString("default"), TypeCategoryMap::First);
uint32_t num_categories = DataVisualization::Categories::GetCount();
for (uint32_t i = 0; i < num_categories; i++)
{
@@ -1972,10 +1972,10 @@ protected:
::strcmp(category_sp->GetName(), "default") == 0 )
continue;
else
- DataVisualization::Categories::Enable(category_sp, CategoryMap::Default);
+ DataVisualization::Categories::Enable(category_sp, TypeCategoryMap::Default);
}
}
- DataVisualization::Categories::Enable(ConstString("system"), CategoryMap::Last);
+ DataVisualization::Categories::Enable(ConstString("system"), TypeCategoryMap::Last);
}
else
{
@@ -3385,10 +3385,10 @@ public:
// everything should be fine now, let's add the synth provider class
SyntheticChildrenSP synth_provider;
- synth_provider.reset(new TypeSyntheticImpl(SyntheticChildren::Flags().SetCascades(options->m_cascade).
- SetSkipPointers(options->m_skip_pointers).
- SetSkipReferences(options->m_skip_references),
- class_name_str.c_str()));
+ synth_provider.reset(new ScriptedSyntheticChildren(SyntheticChildren::Flags().SetCascades(options->m_cascade).
+ SetSkipPointers(options->m_skip_pointers).
+ SetSkipReferences(options->m_skip_references),
+ class_name_str.c_str()));
lldb::TypeCategoryImplSP category;
@@ -3504,11 +3504,11 @@ CommandObjectTypeSynthAdd::Execute_Pytho
SyntheticChildrenSP entry;
- TypeSyntheticImpl* impl = new TypeSyntheticImpl(SyntheticChildren::Flags().
- SetCascades(m_options.m_cascade).
- SetSkipPointers(m_options.m_skip_pointers).
- SetSkipReferences(m_options.m_skip_references),
- m_options.m_class_name.c_str());
+ ScriptedSyntheticChildren* impl = new ScriptedSyntheticChildren(SyntheticChildren::Flags().
+ SetCascades(m_options.m_cascade).
+ SetSkipPointers(m_options.m_skip_pointers).
+ SetSkipReferences(m_options.m_skip_references),
+ m_options.m_class_name.c_str());
entry.reset(impl);
Modified: lldb/branches/windows/source/Commands/CommandObjectWatchpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Commands/CommandObjectWatchpoint.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Commands/CommandObjectWatchpoint.cpp (original)
+++ lldb/branches/windows/source/Commands/CommandObjectWatchpoint.cpp Wed Apr 17 03:38:48 2013
@@ -69,23 +69,6 @@ static inline void StripLeadingSpaces(ll
while (!Str.empty() && isspace(Str[0]))
Str = Str.substr(1);
}
-static inline llvm::StringRef StripOptionTerminator(llvm::StringRef &Str, bool with_dash_w, bool with_dash_x)
-{
- llvm::StringRef ExprStr = Str;
-
- // Get rid of the leading spaces first.
- StripLeadingSpaces(ExprStr);
-
- // If there's no '-w' and no '-x', we can just return.
- if (!with_dash_w && !with_dash_x)
- return ExprStr;
-
- // Otherwise, split on the "--" option terminator string, and return the rest of the string.
- ExprStr = ExprStr.split("--").second;
- StripLeadingSpaces(ExprStr);
- return ExprStr;
-}
-
// Equivalent class: {"-", "to", "To", "TO"} of range specifier array.
static const char* RSA[4] = { "-", "to", "To", "TO" };
@@ -934,7 +917,10 @@ public:
"If watchpoint setting fails, consider disable/delete existing ones "
"to free up resources.",
NULL,
- eFlagProcessMustBeLaunched | eFlagProcessMustBePaused),
+ eFlagRequiresFrame |
+ eFlagTryTargetAPILock |
+ eFlagProcessMustBeLaunched |
+ eFlagProcessMustBePaused ),
m_option_group (interpreter),
m_option_watchpoint ()
{
@@ -972,9 +958,9 @@ public:
}
protected:
- static uint32_t GetVariableCallback (void *baton,
- const char *name,
- VariableList &variable_list)
+ static size_t GetVariableCallback (void *baton,
+ const char *name,
+ VariableList &variable_list)
{
Target *target = static_cast<Target *>(baton);
if (target)
@@ -988,18 +974,10 @@ protected:
}
virtual bool
- DoExecute (Args& command,
- CommandReturnObject &result)
+ DoExecute (Args& command, CommandReturnObject &result)
{
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
- ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
- StackFrame *frame = exe_ctx.GetFramePtr();
- if (frame == NULL)
- {
- result.AppendError ("you must be stopped in a valid stack frame to set a watchpoint.");
- result.SetStatus (eReturnStatusFailed);
- return false;
- }
+ StackFrame *frame = m_exe_ctx.GetFramePtr();
// If no argument is present, issue an error message. There's no way to set a watchpoint.
if (command.GetArgumentCount() <= 0)
@@ -1025,7 +1003,8 @@ protected:
Stream &output_stream = result.GetOutputStream();
// A simple watch variable gesture allows only one argument.
- if (command.GetArgumentCount() != 1) {
+ if (command.GetArgumentCount() != 1)
+ {
result.GetErrorStream().Printf("error: specify exactly one variable to watch for\n");
result.SetStatus(eReturnStatusFailed);
return false;
@@ -1041,14 +1020,15 @@ protected:
var_sp,
error);
- if (!valobj_sp) {
+ if (!valobj_sp)
+ {
// Not in the frame; let's check the globals.
VariableList variable_list;
ValueObjectList valobj_list;
Error error (Variable::GetValuesForVariableExpressionPath (command.GetArgumentAtIndex(0),
- exe_ctx.GetBestExecutionContextScope(),
+ m_exe_ctx.GetBestExecutionContextScope(),
GetVariableCallback,
target,
variable_list,
@@ -1060,17 +1040,21 @@ protected:
ClangASTType type;
- if (valobj_sp) {
+ if (valobj_sp)
+ {
AddressType addr_type;
addr = valobj_sp->GetAddressOf(false, &addr_type);
- if (addr_type == eAddressTypeLoad) {
+ if (addr_type == eAddressTypeLoad)
+ {
// We're in business.
// Find out the size of this variable.
size = m_option_watchpoint.watch_size == 0 ? valobj_sp->GetByteSize()
: m_option_watchpoint.watch_size;
}
type.SetClangType(valobj_sp->GetClangAST(), valobj_sp->GetClangType());
- } else {
+ }
+ else
+ {
const char *error_cstr = error.AsCString(NULL);
if (error_cstr)
result.GetErrorStream().Printf("error: %s\n", error_cstr);
@@ -1084,10 +1068,12 @@ protected:
uint32_t watch_type = m_option_watchpoint.watch_type;
error.Clear();
Watchpoint *wp = target->CreateWatchpoint(addr, size, &type, watch_type, error).get();
- if (wp) {
+ if (wp)
+ {
wp->SetWatchSpec(command.GetArgumentAtIndex(0));
wp->SetWatchVariable(true);
- if (var_sp && var_sp->GetDeclaration().GetFile()) {
+ if (var_sp && var_sp->GetDeclaration().GetFile())
+ {
StreamString ss;
// True to show fullpath for declaration file.
var_sp->GetDeclaration().DumpStopContext(&ss, true);
@@ -1097,7 +1083,9 @@ protected:
wp->GetDescription(&output_stream, lldb::eDescriptionLevelFull);
output_stream.EOL();
result.SetStatus(eReturnStatusSuccessFinishResult);
- } else {
+ }
+ else
+ {
result.AppendErrorWithFormat("Watchpoint creation failed (addr=0x%" PRIx64 ", size=%lu, variable expression='%s').\n",
addr, size, command.GetArgumentAtIndex(0));
if (error.AsCString(NULL))
@@ -1135,7 +1123,10 @@ public:
"If watchpoint setting fails, consider disable/delete existing ones "
"to free up resources.",
NULL,
- eFlagProcessMustBeLaunched | eFlagProcessMustBePaused),
+ eFlagRequiresFrame |
+ eFlagTryTargetAPILock |
+ eFlagProcessMustBeLaunched |
+ eFlagProcessMustBePaused ),
m_option_group (interpreter),
m_option_watchpoint ()
{
@@ -1182,23 +1173,53 @@ protected:
DoExecute (const char *raw_command, CommandReturnObject &result)
{
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
- ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
- StackFrame *frame = exe_ctx.GetFramePtr();
- if (frame == NULL)
- {
- result.AppendError ("you must be stopped in a valid stack frame to set a watchpoint.");
- result.SetStatus (eReturnStatusFailed);
- return false;
- }
+ StackFrame *frame = m_exe_ctx.GetFramePtr();
Args command(raw_command);
+ const char *expr = NULL;
+ if (raw_command[0] == '-')
+ {
+ // We have some options and these options MUST end with --.
+ const char *end_options = NULL;
+ const char *s = raw_command;
+ while (s && s[0])
+ {
+ end_options = ::strstr (s, "--");
+ if (end_options)
+ {
+ end_options += 2; // Get past the "--"
+ if (::isspace (end_options[0]))
+ {
+ expr = end_options;
+ while (::isspace (*expr))
+ ++expr;
+ break;
+ }
+ }
+ s = end_options;
+ }
+
+ if (end_options)
+ {
+ Args args (raw_command, end_options - raw_command);
+ if (!ParseOptions (args, result))
+ return false;
+
+ Error error (m_option_group.NotifyOptionParsingFinished());
+ if (error.Fail())
+ {
+ result.AppendError (error.AsCString());
+ result.SetStatus (eReturnStatusFailed);
+ return false;
+ }
+ }
+ }
- // Process possible options.
- if (!ParseOptions (command, result))
- return false;
+ if (expr == NULL)
+ expr = raw_command;
// If no argument is present, issue an error message. There's no way to set a watchpoint.
- if (command.GetArgumentCount() <= 0)
+ if (command.GetArgumentCount() == 0)
{
result.GetErrorStream().Printf("error: required argument missing; specify an expression to evaulate into the addres to watch for\n");
result.SetStatus(eReturnStatusFailed);
@@ -1219,21 +1240,7 @@ protected:
lldb::addr_t addr = 0;
size_t size = 0;
- VariableSP var_sp;
ValueObjectSP valobj_sp;
- Stream &output_stream = result.GetOutputStream();
-
- // We will process the raw command string to rid of the '-w', '-x', or '--'
- llvm::StringRef raw_expr_str(raw_command);
- std::string expr_str = StripOptionTerminator(raw_expr_str, with_dash_w, with_dash_x).str();
-
- // Sanity check for when the user forgets to terminate the option strings with a '--'.
- if ((with_dash_w || with_dash_w) && expr_str.empty())
- {
- result.GetErrorStream().Printf("error: did you forget to enter the option terminator string \"--\"?\n");
- result.SetStatus(eReturnStatusFailed);
- return false;
- }
// Use expression evaluation to arrive at the address to watch.
EvaluateExpressionOptions options;
@@ -1243,13 +1250,14 @@ protected:
.SetRunOthers(true)
.SetTimeoutUsec(0);
- ExecutionResults expr_result = target->EvaluateExpression (expr_str.c_str(),
+ ExecutionResults expr_result = target->EvaluateExpression (expr,
frame,
valobj_sp,
options);
- if (expr_result != eExecutionCompleted) {
+ if (expr_result != eExecutionCompleted)
+ {
result.GetErrorStream().Printf("error: expression evaluation of address to watch failed\n");
- result.GetErrorStream().Printf("expression evaluated: %s\n", expr_str.c_str());
+ result.GetErrorStream().Printf("expression evaluated: %s\n", expr);
result.SetStatus(eReturnStatusFailed);
return false;
}
@@ -1257,7 +1265,8 @@ protected:
// Get the address to watch.
bool success = false;
addr = valobj_sp->GetValueAsUnsigned(0, &success);
- if (!success) {
+ if (!success)
+ {
result.GetErrorStream().Printf("error: expression did not evaluate to an address\n");
result.SetStatus(eReturnStatusFailed);
return false;
@@ -1276,18 +1285,16 @@ protected:
Error error;
Watchpoint *wp = target->CreateWatchpoint(addr, size, &type, watch_type, error).get();
- if (wp) {
- if (var_sp && var_sp->GetDeclaration().GetFile()) {
- StreamString ss;
- // True to show fullpath for declaration file.
- var_sp->GetDeclaration().DumpStopContext(&ss, true);
- wp->SetDeclInfo(ss.GetString());
- }
+ if (wp)
+ {
+ Stream &output_stream = result.GetOutputStream();
output_stream.Printf("Watchpoint created: ");
wp->GetDescription(&output_stream, lldb::eDescriptionLevelFull);
output_stream.EOL();
result.SetStatus(eReturnStatusSuccessFinishResult);
- } else {
+ }
+ else
+ {
result.AppendErrorWithFormat("Watchpoint creation failed (addr=0x%" PRIx64 ", size=%lu).\n",
addr, size);
if (error.AsCString(NULL))
Modified: lldb/branches/windows/source/Core/Address.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/Address.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/Address.cpp (original)
+++ lldb/branches/windows/source/Core/Address.cpp Wed Apr 17 03:38:48 2013
@@ -86,7 +86,7 @@ ReadUIntMax64 (ExecutionContextScope *ex
if (GetByteOrderAndAddressSize (exe_scope, address, byte_order, addr_size))
{
DataExtractor data (&buf, sizeof(buf), byte_order, addr_size);
- uint32_t offset = 0;
+ lldb::offset_t offset = 0;
uval64 = data.GetU64(&offset);
}
else
@@ -311,8 +311,15 @@ Address::GetLoadAddress (Target *target)
}
addr_t
-Address::GetCallableLoadAddress (Target *target) const
+Address::GetCallableLoadAddress (Target *target, bool is_indirect) const
{
+ if (is_indirect && target) {
+ ProcessSP processSP = target->GetProcessSP();
+ Error error;
+ if (processSP.get())
+ return processSP->ResolveIndirectFunction(this, error);
+ }
+
addr_t code_addr = GetLoadAddress (target);
if (target)
@@ -696,8 +703,8 @@ Address::Dump (Stream *s, ExecutionConte
stop_if_block_is_inlined_function,
&variable_list);
- uint32_t num_variables = variable_list.GetSize();
- for (uint32_t var_idx = 0; var_idx < num_variables; ++var_idx)
+ const size_t num_variables = variable_list.GetSize();
+ for (size_t var_idx = 0; var_idx < num_variables; ++var_idx)
{
Variable *var = variable_list.GetVariableAtIndex (var_idx).get();
if (var && var->LocationIsValidForAddress (*this))
@@ -762,7 +769,7 @@ Address::Dump (Stream *s, ExecutionConte
uint32_t
Address::CalculateSymbolContext (SymbolContext *sc, uint32_t resolve_scope) const
{
- sc->Clear();
+ sc->Clear(false);
// Absolute addresses don't have enough information to reconstruct even their target.
SectionSP section_sp (GetSection());
@@ -1008,29 +1015,6 @@ lldb_private::operator!= (const Address&
a.GetOffset() != rhs.GetOffset();
}
-bool
-Address::IsLinkedAddress () const
-{
- SectionSP section_sp (GetSection());
- return section_sp && section_sp->GetLinkedSection();
-}
-
-
-void
-Address::ResolveLinkedAddress ()
-{
- SectionSP section_sp (GetSection());
- if (section_sp)
- {
- SectionSP linked_section_sp (section_sp->GetLinkedSection());
- if (linked_section_sp)
- {
- m_offset += section_sp->GetLinkedOffset();
- m_section_wp = linked_section_sp;
- }
- }
-}
-
AddressClass
Address::GetAddressClass () const
{
Modified: lldb/branches/windows/source/Core/AddressResolverFileLine.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/AddressResolverFileLine.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/AddressResolverFileLine.cpp (original)
+++ lldb/branches/windows/source/Core/AddressResolverFileLine.cpp Wed Apr 17 03:38:48 2013
@@ -52,7 +52,7 @@ AddressResolverFileLine::SearchCallback
uint32_t sc_list_size;
CompileUnit *cu = context.comp_unit;
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
sc_list_size = cu->ResolveSymbolContext (m_file_spec, m_line_number, m_inlines, false, eSymbolContextEverything,
sc_list);
Modified: lldb/branches/windows/source/Core/AddressResolverName.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/AddressResolverName.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/AddressResolverName.cpp (original)
+++ lldb/branches/windows/source/Core/AddressResolverName.cpp Wed Apr 17 03:38:48 2013
@@ -38,7 +38,7 @@ AddressResolverName::AddressResolverName
m_regex = RegularExpression(m_func_name.AsCString());
if (!m_regex.IsValid())
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
if (log)
log->Warning ("function name regexp: \"%s\" did not compile: %s.",
@@ -101,7 +101,7 @@ AddressResolverName::SearchCallback
SymbolContext sc;
Address func_addr;
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
if (m_class_name)
{
Modified: lldb/branches/windows/source/Core/ArchSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/ArchSpec.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/ArchSpec.cpp (original)
+++ lldb/branches/windows/source/Core/ArchSpec.cpp Wed Apr 17 03:38:48 2013
@@ -57,8 +57,10 @@ static const CoreDefinition g_core_defin
{ eByteOrderLittle, 4, 2, 4, llvm::Triple::arm , ArchSpec::eCore_arm_armv6 , "armv6" },
{ eByteOrderLittle, 4, 2, 4, llvm::Triple::arm , ArchSpec::eCore_arm_armv7 , "armv7" },
{ eByteOrderLittle, 4, 2, 4, llvm::Triple::arm , ArchSpec::eCore_arm_armv7f , "armv7f" },
- { eByteOrderLittle, 4, 2, 4, llvm::Triple::arm , ArchSpec::eCore_arm_armv7k , "armv7k" },
{ eByteOrderLittle, 4, 2, 4, llvm::Triple::arm , ArchSpec::eCore_arm_armv7s , "armv7s" },
+ { eByteOrderLittle, 4, 2, 4, llvm::Triple::arm , ArchSpec::eCore_arm_armv7k , "armv7k" },
+ { eByteOrderLittle, 4, 2, 4, llvm::Triple::arm , ArchSpec::eCore_arm_armv7m , "armv7m" },
+ { eByteOrderLittle, 4, 2, 4, llvm::Triple::arm , ArchSpec::eCore_arm_armv7em , "armv7em" },
{ eByteOrderLittle, 4, 2, 4, llvm::Triple::arm , ArchSpec::eCore_arm_xscale , "xscale" },
{ eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb , ArchSpec::eCore_thumb , "thumb" },
{ eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb , ArchSpec::eCore_thumbv4t , "thumbv4t" },
@@ -67,8 +69,10 @@ static const CoreDefinition g_core_defin
{ eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb , ArchSpec::eCore_thumbv6 , "thumbv6" },
{ eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb , ArchSpec::eCore_thumbv7 , "thumbv7" },
{ eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb , ArchSpec::eCore_thumbv7f , "thumbv7f" },
- { eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb , ArchSpec::eCore_thumbv7k , "thumbv7k" },
{ eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb , ArchSpec::eCore_thumbv7s , "thumbv7s" },
+ { eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb , ArchSpec::eCore_thumbv7k , "thumbv7k" },
+ { eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb , ArchSpec::eCore_thumbv7m , "thumbv7m" },
+ { eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb , ArchSpec::eCore_thumbv7em , "thumbv7em" },
{ eByteOrderLittle, 4, 4, 4, llvm::Triple::ppc , ArchSpec::eCore_ppc_generic , "ppc" },
@@ -118,7 +122,7 @@ struct ArchDefinition
};
-uint32_t
+size_t
ArchSpec::AutoComplete (const char *name, StringList &matches)
{
uint32_t i;
@@ -161,8 +165,10 @@ static const ArchDefinitionEntry g_macho
{ ArchSpec::eCore_arm_xscale , llvm::MachO::CPUTypeARM , 8 , UINT32_MAX , SUBTYPE_MASK },
{ ArchSpec::eCore_arm_armv7 , llvm::MachO::CPUTypeARM , 9 , UINT32_MAX , SUBTYPE_MASK },
{ ArchSpec::eCore_arm_armv7f , llvm::MachO::CPUTypeARM , 10 , UINT32_MAX , SUBTYPE_MASK },
- { ArchSpec::eCore_arm_armv7k , llvm::MachO::CPUTypeARM , 12 , UINT32_MAX , SUBTYPE_MASK },
{ ArchSpec::eCore_arm_armv7s , llvm::MachO::CPUTypeARM , 11 , UINT32_MAX , SUBTYPE_MASK },
+ { ArchSpec::eCore_arm_armv7k , llvm::MachO::CPUTypeARM , 12 , UINT32_MAX , SUBTYPE_MASK },
+ { ArchSpec::eCore_arm_armv7m , llvm::MachO::CPUTypeARM , 15 , UINT32_MAX , SUBTYPE_MASK },
+ { ArchSpec::eCore_arm_armv7em , llvm::MachO::CPUTypeARM , 16 , UINT32_MAX , SUBTYPE_MASK },
{ ArchSpec::eCore_thumb , llvm::MachO::CPUTypeARM , 0 , UINT32_MAX , SUBTYPE_MASK },
{ ArchSpec::eCore_thumbv4t , llvm::MachO::CPUTypeARM , 5 , UINT32_MAX , SUBTYPE_MASK },
{ ArchSpec::eCore_thumbv5 , llvm::MachO::CPUTypeARM , 7 , UINT32_MAX , SUBTYPE_MASK },
@@ -170,8 +176,10 @@ static const ArchDefinitionEntry g_macho
{ ArchSpec::eCore_thumbv6 , llvm::MachO::CPUTypeARM , 6 , UINT32_MAX , SUBTYPE_MASK },
{ ArchSpec::eCore_thumbv7 , llvm::MachO::CPUTypeARM , 9 , UINT32_MAX , SUBTYPE_MASK },
{ ArchSpec::eCore_thumbv7f , llvm::MachO::CPUTypeARM , 10 , UINT32_MAX , SUBTYPE_MASK },
- { ArchSpec::eCore_thumbv7k , llvm::MachO::CPUTypeARM , 12 , UINT32_MAX , SUBTYPE_MASK },
{ ArchSpec::eCore_thumbv7s , llvm::MachO::CPUTypeARM , 11 , UINT32_MAX , SUBTYPE_MASK },
+ { ArchSpec::eCore_thumbv7k , llvm::MachO::CPUTypeARM , 12 , UINT32_MAX , SUBTYPE_MASK },
+ { ArchSpec::eCore_thumbv7m , llvm::MachO::CPUTypeARM , 15 , UINT32_MAX , SUBTYPE_MASK },
+ { ArchSpec::eCore_thumbv7em , llvm::MachO::CPUTypeARM , 16 , UINT32_MAX , SUBTYPE_MASK },
{ ArchSpec::eCore_ppc_generic , llvm::MachO::CPUTypePowerPC , CPU_ANY, UINT32_MAX , UINT32_MAX },
{ ArchSpec::eCore_ppc_generic , llvm::MachO::CPUTypePowerPC , 0 , UINT32_MAX , SUBTYPE_MASK },
{ ArchSpec::eCore_ppc_ppc601 , llvm::MachO::CPUTypePowerPC , 1 , UINT32_MAX , SUBTYPE_MASK },
@@ -495,11 +503,11 @@ ParseMachCPUDashSubtypeTriple (const cha
{
char *end = NULL;
errno = 0;
- uint32_t cpu = ::strtoul (triple_cstr, &end, 0);
+ uint32_t cpu = (uint32_t)::strtoul (triple_cstr, &end, 0);
if (errno == 0 && cpu != 0 && end && ((*end == '-') || (*end == '.')))
{
errno = 0;
- uint32_t sub = ::strtoul (end + 1, &end, 0);
+ uint32_t sub = (uint32_t)::strtoul (end + 1, &end, 0);
if (errno == 0 && end && ((*end == '-') || (*end == '.') || (*end == '\0')))
{
if (arch.SetArchitecture (eArchTypeMachO, cpu, sub))
@@ -513,7 +521,7 @@ ParseMachCPUDashSubtypeTriple (const cha
llvm::StringRef vendor_str(vendor_os.substr(0, dash_pos));
arch.GetTriple().setVendorName(vendor_str);
const size_t vendor_start_pos = dash_pos+1;
- dash_pos = vendor_os.find(vendor_start_pos, '-');
+ dash_pos = vendor_os.find('-', vendor_start_pos);
if (dash_pos == llvm::StringRef::npos)
{
if (vendor_start_pos < vendor_os.size())
@@ -604,7 +612,7 @@ ArchSpec::SetTriple (const char *triple_
// architecture. If this is not available (might not be
// connected) use the first supported architecture.
ArchSpec compatible_arch;
- if (platform->IsCompatibleArchitecture (raw_arch, &compatible_arch))
+ if (platform->IsCompatibleArchitecture (raw_arch, false, &compatible_arch))
{
if (compatible_arch.IsValid())
{
@@ -855,6 +863,8 @@ cores_match (const ArchSpec::Core core1,
return true;
break;
+ case ArchSpec::eCore_arm_armv7m:
+ case ArchSpec::eCore_arm_armv7em:
case ArchSpec::eCore_arm_armv7f:
case ArchSpec::eCore_arm_armv7k:
case ArchSpec::eCore_arm_armv7s:
Modified: lldb/branches/windows/source/Core/Broadcaster.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/Broadcaster.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/Broadcaster.cpp (original)
+++ lldb/branches/windows/source/Core/Broadcaster.cpp Wed Apr 17 03:38:48 2013
@@ -29,7 +29,7 @@ Broadcaster::Broadcaster (BroadcasterMan
m_hijacking_masks(),
m_manager (manager)
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
if (log)
log->Printf ("%p Broadcaster::Broadcaster(\"%s\")", this, m_broadcaster_name.AsCString());
@@ -37,7 +37,7 @@ Broadcaster::Broadcaster (BroadcasterMan
Broadcaster::~Broadcaster()
{
- LogSP log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
+ Log *log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
if (log)
log->Printf ("%p Broadcaster::~Broadcaster(\"%s\")", this, m_broadcaster_name.AsCString());
@@ -236,7 +236,7 @@ Broadcaster::PrivateBroadcastEvent (Even
hijacking_listener = NULL;
}
- LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_EVENTS));
+ Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_EVENTS));
if (log)
{
StreamString event_description;
@@ -294,7 +294,7 @@ Broadcaster::HijackBroadcaster (Listener
{
Mutex::Locker event_types_locker(m_listeners_mutex);
- LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_EVENTS));
+ Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_EVENTS));
if (log)
{
log->Printf ("%p Broadcaster(\"%s\")::HijackBroadcaster (listener(\"%s\")=%p)",
@@ -313,7 +313,7 @@ Broadcaster::RestoreBroadcaster ()
{
Mutex::Locker event_types_locker(m_listeners_mutex);
- LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_EVENTS));
+ Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_EVENTS));
if (log)
{
Listener *listener = m_hijacking_listeners.back();
Modified: lldb/branches/windows/source/Core/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/CMakeLists.txt?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/CMakeLists.txt (original)
+++ lldb/branches/windows/source/Core/CMakeLists.txt Wed Apr 17 03:38:48 2013
@@ -16,12 +16,10 @@ add_lldb_library(lldbCore
ConnectionSharedMemory.cpp
ConstString.cpp
cxa_demangle.cpp
- CXXFormatterFunctions.cpp
DataBufferHeap.cpp
DataBufferMemoryMap.cpp
DataEncoder.cpp
DataExtractor.cpp
- DataVisualization.cpp
Debugger.cpp
Disassembler.cpp
DynamicLoader.cpp
@@ -30,8 +28,6 @@ add_lldb_library(lldbCore
Event.cpp
FileLineResolver.cpp
FileSpecList.cpp
- FormatClasses.cpp
- FormatManager.cpp
History.cpp
InputReader.cpp
InputReaderEZ.cpp
@@ -78,3 +74,12 @@ add_lldb_library(lldbCore
VMRange.cpp
Windows.cpp
)
+
+#FIXME: Below we append -frtti to cxa_demangle.cpp (and let the compiler choose to ignore the
+# -fno-rtti that is added due to LLVM_NO_RTTI at the top of this file.) It would be
+# better to replace -fno-rtti with -frtti rather than just appending the latter option.
+set_property(
+ SOURCE cxa_demangle.cpp
+ PROPERTY COMPILE_FLAGS -frtti
+ )
+
Removed: lldb/branches/windows/source/Core/CXXFormatterFunctions.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/CXXFormatterFunctions.cpp?rev=179678&view=auto
==============================================================================
--- lldb/branches/windows/source/Core/CXXFormatterFunctions.cpp (original)
+++ lldb/branches/windows/source/Core/CXXFormatterFunctions.cpp (removed)
@@ -1,1473 +0,0 @@
-//===-- CXXFormatterFunctions.cpp---------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "lldb/lldb-python.h"
-
-#include "lldb/Core/CXXFormatterFunctions.h"
-
-// needed to get ConvertUTF16/32ToUTF8
-#define CLANG_NEEDS_THESE_ONE_DAY
-#include "clang/Basic/ConvertUTF.h"
-
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Stream.h"
-#include "lldb/Core/ValueObject.h"
-#include "lldb/Core/ValueObjectConstResult.h"
-#include "lldb/Host/Endian.h"
-#include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
-#include "lldb/Target/Target.h"
-
-using namespace lldb;
-using namespace lldb_private;
-using namespace lldb_private::formatters;
-
-bool
-lldb_private::formatters::ExtractValueFromObjCExpression (ValueObject &valobj,
- const char* target_type,
- const char* selector,
- uint64_t &value)
-{
- if (!target_type || !*target_type)
- return false;
- if (!selector || !*selector)
- return false;
- StreamString expr;
- expr.Printf("(%s)[(id)0x%" PRIx64 " %s]",target_type,valobj.GetPointerValue(),selector);
- ExecutionContext exe_ctx (valobj.GetExecutionContextRef());
- lldb::ValueObjectSP result_sp;
- Target* target = exe_ctx.GetTargetPtr();
- StackFrame* stack_frame = exe_ctx.GetFramePtr();
- if (!target || !stack_frame)
- return false;
-
- EvaluateExpressionOptions options;
- options.SetCoerceToId(false)
- .SetUnwindOnError(true)
- .SetKeepInMemory(true);
-
- target->EvaluateExpression(expr.GetData(),
- stack_frame,
- result_sp,
- options);
- if (!result_sp)
- return false;
- value = result_sp->GetValueAsUnsigned(0);
- return true;
-}
-
-lldb::ValueObjectSP
-lldb_private::formatters::CallSelectorOnObject (ValueObject &valobj,
- const char* return_type,
- const char* selector,
- uint64_t index)
-{
- lldb::ValueObjectSP valobj_sp;
- if (!return_type || !*return_type)
- return valobj_sp;
- if (!selector || !*selector)
- return valobj_sp;
- StreamString expr_path_stream;
- valobj.GetExpressionPath(expr_path_stream, false);
- StreamString expr;
- expr.Printf("(%s)[%s %s:%" PRId64 "]",return_type,expr_path_stream.GetData(),selector,index);
- ExecutionContext exe_ctx (valobj.GetExecutionContextRef());
- lldb::ValueObjectSP result_sp;
- Target* target = exe_ctx.GetTargetPtr();
- StackFrame* stack_frame = exe_ctx.GetFramePtr();
- if (!target || !stack_frame)
- return valobj_sp;
-
- EvaluateExpressionOptions options;
- options.SetCoerceToId(false)
- .SetUnwindOnError(true)
- .SetKeepInMemory(true)
- .SetUseDynamic(lldb::eDynamicCanRunTarget);
-
- target->EvaluateExpression(expr.GetData(),
- stack_frame,
- valobj_sp,
- options);
- return valobj_sp;
-}
-
-lldb::ValueObjectSP
-lldb_private::formatters::CallSelectorOnObject (ValueObject &valobj,
- const char* return_type,
- const char* selector,
- const char* key)
-{
- lldb::ValueObjectSP valobj_sp;
- if (!return_type || !*return_type)
- return valobj_sp;
- if (!selector || !*selector)
- return valobj_sp;
- if (!key || !*key)
- return valobj_sp;
- StreamString expr_path_stream;
- valobj.GetExpressionPath(expr_path_stream, false);
- StreamString expr;
- expr.Printf("(%s)[%s %s:%s]",return_type,expr_path_stream.GetData(),selector,key);
- ExecutionContext exe_ctx (valobj.GetExecutionContextRef());
- lldb::ValueObjectSP result_sp;
- Target* target = exe_ctx.GetTargetPtr();
- StackFrame* stack_frame = exe_ctx.GetFramePtr();
- if (!target || !stack_frame)
- return valobj_sp;
-
- EvaluateExpressionOptions options;
- options.SetCoerceToId(false)
- .SetUnwindOnError(true)
- .SetKeepInMemory(true)
- .SetUseDynamic(lldb::eDynamicCanRunTarget);
-
- target->EvaluateExpression(expr.GetData(),
- stack_frame,
- valobj_sp,
- options);
- return valobj_sp;
-}
-
-template<bool name_entries>
-bool
-lldb_private::formatters::NSDictionarySummaryProvider (ValueObject& valobj, Stream& stream)
-{
- ProcessSP process_sp = valobj.GetProcessSP();
- if (!process_sp)
- return false;
-
- ObjCLanguageRuntime* runtime = (ObjCLanguageRuntime*)process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC);
-
- if (!runtime)
- return false;
-
- ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(valobj));
-
- if (!descriptor.get() || !descriptor->IsValid())
- return false;
-
- uint32_t ptr_size = process_sp->GetAddressByteSize();
- bool is_64bit = (ptr_size == 8);
-
- lldb::addr_t valobj_addr = valobj.GetValueAsUnsigned(0);
-
- if (!valobj_addr)
- return false;
-
- uint64_t value = 0;
-
- const char* class_name = descriptor->GetClassName().GetCString();
-
- if (!class_name || !*class_name)
- return false;
-
- if (!strcmp(class_name,"__NSDictionaryI"))
- {
- Error error;
- value = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + ptr_size, ptr_size, 0, error);
- if (error.Fail())
- return false;
- value &= (is_64bit ? ~0xFC00000000000000UL : ~0xFC000000U);
- }
- else if (!strcmp(class_name,"__NSDictionaryM"))
- {
- Error error;
- value = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + ptr_size, ptr_size, 0, error);
- if (error.Fail())
- return false;
- value &= (is_64bit ? ~0xFC00000000000000UL : ~0xFC000000U);
- }
- else if (!strcmp(class_name,"__NSCFDictionary"))
- {
- Error error;
- value = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + (is_64bit ? 20 : 12), ptr_size, 0, error);
- if (error.Fail())
- return false;
- if (is_64bit)
- value &= ~0x0f1f000000000000UL;
- }
- else
- {
- if (!ExtractValueFromObjCExpression(valobj, "int", "count", value))
- return false;
- }
-
- stream.Printf("%s%" PRIu64 " %s%s",
- (name_entries ? "@\"" : ""),
- value,
- (name_entries ? (value == 1 ? "entry" : "entries") : (value == 1 ? "key/value pair" : "key/value pairs")),
- (name_entries ? "\"" : ""));
- return true;
-}
-
-bool
-lldb_private::formatters::NSArraySummaryProvider (ValueObject& valobj, Stream& stream)
-{
- ProcessSP process_sp = valobj.GetProcessSP();
- if (!process_sp)
- return false;
-
- ObjCLanguageRuntime* runtime = (ObjCLanguageRuntime*)process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC);
-
- if (!runtime)
- return false;
-
- ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(valobj));
-
- if (!descriptor.get() || !descriptor->IsValid())
- return false;
-
- uint32_t ptr_size = process_sp->GetAddressByteSize();
-
- lldb::addr_t valobj_addr = valobj.GetValueAsUnsigned(0);
-
- if (!valobj_addr)
- return false;
-
- uint64_t value = 0;
-
- const char* class_name = descriptor->GetClassName().GetCString();
-
- if (!class_name || !*class_name)
- return false;
-
- if (!strcmp(class_name,"__NSArrayI"))
- {
- Error error;
- value = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + ptr_size, ptr_size, 0, error);
- if (error.Fail())
- return false;
- }
- else if (!strcmp(class_name,"__NSArrayM"))
- {
- Error error;
- value = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + ptr_size, ptr_size, 0, error);
- if (error.Fail())
- return false;
- }
- else if (!strcmp(class_name,"__NSCFArray"))
- {
- Error error;
- value = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + 2 * ptr_size, ptr_size, 0, error);
- if (error.Fail())
- return false;
- }
- else
- {
- if (!ExtractValueFromObjCExpression(valobj, "int", "count", value))
- return false;
- }
-
- stream.Printf("@\"%" PRIu64 " object%s\"",
- value,
- value == 1 ? "" : "s");
- return true;
-}
-
-template<bool needs_at>
-bool
-lldb_private::formatters::NSDataSummaryProvider (ValueObject& valobj, Stream& stream)
-{
- ProcessSP process_sp = valobj.GetProcessSP();
- if (!process_sp)
- return false;
-
- ObjCLanguageRuntime* runtime = (ObjCLanguageRuntime*)process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC);
-
- if (!runtime)
- return false;
-
- ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(valobj));
-
- if (!descriptor.get() || !descriptor->IsValid())
- return false;
-
- bool is_64bit = (process_sp->GetAddressByteSize() == 8);
- lldb::addr_t valobj_addr = valobj.GetValueAsUnsigned(0);
-
- if (!valobj_addr)
- return false;
-
- uint64_t value = 0;
-
- const char* class_name = descriptor->GetClassName().GetCString();
-
- if (!class_name || !*class_name)
- return false;
-
- if (!strcmp(class_name,"NSConcreteData") ||
- !strcmp(class_name,"NSConcreteMutableData") ||
- !strcmp(class_name,"__NSCFData"))
- {
- uint32_t offset = (is_64bit ? 16 : 8);
- Error error;
- value = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + offset, is_64bit ? 8 : 4, 0, error);
- if (error.Fail())
- return false;
- }
- else
- {
- if (!ExtractValueFromObjCExpression(valobj, "int", "length", value))
- return false;
- }
-
- stream.Printf("%s%" PRIu64 " byte%s%s",
- (needs_at ? "@\"" : ""),
- value,
- (value > 1 ? "s" : ""),
- (needs_at ? "\"" : ""));
-
- return true;
-}
-
-bool
-lldb_private::formatters::NSNumberSummaryProvider (ValueObject& valobj, Stream& stream)
-{
- ProcessSP process_sp = valobj.GetProcessSP();
- if (!process_sp)
- return false;
-
- ObjCLanguageRuntime* runtime = (ObjCLanguageRuntime*)process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC);
-
- if (!runtime)
- return false;
-
- ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(valobj));
-
- if (!descriptor.get() || !descriptor->IsValid())
- return false;
-
- uint32_t ptr_size = process_sp->GetAddressByteSize();
-
- lldb::addr_t valobj_addr = valobj.GetValueAsUnsigned(0);
-
- if (!valobj_addr)
- return false;
-
- const char* class_name = descriptor->GetClassName().GetCString();
-
- if (!class_name || !*class_name)
- return false;
-
- if (!strcmp(class_name,"NSNumber") || !strcmp(class_name,"__NSCFNumber"))
- {
- if (descriptor->IsTagged())
- {
- // we have a call to get info and value bits in the tagged descriptor. but we prefer not to cast and replicate them
- int64_t value = (valobj_addr & ~0x0000000000000000FFL) >> 8;
- uint64_t i_bits = (valobj_addr & 0xF0) >> 4;
-
- switch (i_bits)
- {
- case 0:
- stream.Printf("(char)%hhd",(char)value);
- break;
- case 4:
- stream.Printf("(short)%hd",(short)value);
- break;
- case 8:
- stream.Printf("(int)%d",(int)value);
- break;
- case 12:
- stream.Printf("(long)%" PRId64,value);
- break;
- default:
- stream.Printf("unexpected value:(info=%" PRIu64 ", value=%" PRIu64,i_bits,value);
- break;
- }
- return true;
- }
- else
- {
- Error error;
- uint8_t data_type = (process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + ptr_size, 1, 0, error) & 0x1F);
- uint64_t data_location = valobj_addr + 2*ptr_size;
- uint64_t value = 0;
- if (error.Fail())
- return false;
- switch (data_type)
- {
- case 1: // 0B00001
- value = process_sp->ReadUnsignedIntegerFromMemory(data_location, 1, 0, error);
- if (error.Fail())
- return false;
- stream.Printf("(char)%hhd",(char)value);
- break;
- case 2: // 0B0010
- value = process_sp->ReadUnsignedIntegerFromMemory(data_location, 2, 0, error);
- if (error.Fail())
- return false;
- stream.Printf("(short)%hd",(short)value);
- break;
- case 3: // 0B0011
- value = process_sp->ReadUnsignedIntegerFromMemory(data_location, 4, 0, error);
- if (error.Fail())
- return false;
- stream.Printf("(int)%d",(int)value);
- break;
- case 17: // 0B10001
- data_location += 8;
- case 4: // 0B0100
- value = process_sp->ReadUnsignedIntegerFromMemory(data_location, 8, 0, error);
- if (error.Fail())
- return false;
- stream.Printf("(long)%" PRId64,value);
- break;
- case 5: // 0B0101
- {
- uint32_t flt_as_int = process_sp->ReadUnsignedIntegerFromMemory(data_location, 4, 0, error);
- if (error.Fail())
- return false;
- float flt_value = *((float*)&flt_as_int);
- stream.Printf("(float)%f",flt_value);
- break;
- }
- case 6: // 0B0110
- {
- uint64_t dbl_as_lng = process_sp->ReadUnsignedIntegerFromMemory(data_location, 8, 0, error);
- if (error.Fail())
- return false;
- double dbl_value = *((double*)&dbl_as_lng);
- stream.Printf("(double)%g",dbl_value);
- break;
- }
- default:
- stream.Printf("absurd: dt=%d",data_type);
- break;
- }
- return true;
- }
- }
- else
- {
- // similar to ExtractValueFromObjCExpression but uses summary instead of value
- StreamString expr_path_stream;
- valobj.GetExpressionPath(expr_path_stream, false);
- StreamString expr;
- expr.Printf("(NSString*)[%s stringValue]",expr_path_stream.GetData());
- ExecutionContext exe_ctx (valobj.GetExecutionContextRef());
- lldb::ValueObjectSP result_sp;
- Target* target = exe_ctx.GetTargetPtr();
- StackFrame* stack_frame = exe_ctx.GetFramePtr();
- if (!target || !stack_frame)
- return false;
-
- EvaluateExpressionOptions options;
- options.SetCoerceToId(false)
- .SetUnwindOnError(true)
- .SetKeepInMemory(true)
- .SetUseDynamic(lldb::eDynamicCanRunTarget);
-
- target->EvaluateExpression(expr.GetData(),
- stack_frame,
- result_sp,
- options);
- if (!result_sp)
- return false;
- stream.Printf("%s",result_sp->GetSummaryAsCString());
- return true;
- }
-}
-
-static bool
-ReadUTFBufferAndDumpToStream (uint64_t location,
- const ProcessSP& process_sp,
- Stream& stream)
-{
- Error error;
- lldb::DataBufferSP buffer_sp(new DataBufferHeap(1024,0));
- size_t data_read = process_sp->ReadMemoryFromInferior(location, (char*)buffer_sp->GetBytes(), 1024, error);
- if (error.Fail())
- {
- stream.Printf("unable to read data");
- return true;
- }
- else
- stream.Printf("@\"");
- if (data_read)
- {
- UTF16 *data_ptr = (UTF16*)buffer_sp->GetBytes();
- UTF16 *data_end_ptr = data_ptr + 256;
-
- while (data_ptr < data_end_ptr)
- {
- if (!*data_ptr)
- {
- data_end_ptr = data_ptr;
- break;
- }
- data_ptr++;
- }
-
- *data_ptr = 0;
- data_ptr = (UTF16*)buffer_sp->GetBytes();
-
- lldb::DataBufferSP utf8_data_buffer_sp(new DataBufferHeap(1024,0));
- UTF8* utf8_data_ptr = (UTF8*)utf8_data_buffer_sp->GetBytes();
- UTF8* utf8_data_end_ptr = utf8_data_ptr + 1024;
-
- ConvertUTF16toUTF8 ( (const UTF16**)&data_ptr,
- data_end_ptr,
- &utf8_data_ptr,
- utf8_data_end_ptr,
- lenientConversion);
- utf8_data_ptr = (UTF8*)utf8_data_buffer_sp->GetBytes();
- for (;utf8_data_ptr != utf8_data_end_ptr; utf8_data_ptr++)
- {
- if (!*utf8_data_ptr)
- break;
- stream.Printf("%c",*utf8_data_ptr);
- }
- stream.Printf("\"");
- return true;
- }
- stream.Printf("\"");
- return true;
-}
-
-bool
-lldb_private::formatters::NSStringSummaryProvider (ValueObject& valobj, Stream& stream)
-{
- ProcessSP process_sp = valobj.GetProcessSP();
- if (!process_sp)
- return false;
-
- ObjCLanguageRuntime* runtime = (ObjCLanguageRuntime*)process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC);
-
- if (!runtime)
- return false;
-
- ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(valobj));
-
- if (!descriptor.get() || !descriptor->IsValid())
- return false;
-
- uint32_t ptr_size = process_sp->GetAddressByteSize();
-
- lldb::addr_t valobj_addr = valobj.GetValueAsUnsigned(0);
-
- if (!valobj_addr)
- return false;
-
- const char* class_name = descriptor->GetClassName().GetCString();
-
- if (!class_name || !*class_name)
- return false;
-
- uint64_t info_bits_location = valobj_addr + ptr_size;
- if (process_sp->GetByteOrder() != lldb::eByteOrderLittle)
- info_bits_location += 3;
-
- Error error;
-
- uint8_t info_bits = process_sp->ReadUnsignedIntegerFromMemory(info_bits_location, 1, 0, error);
- if (error.Fail())
- return false;
-
- bool is_mutable = (info_bits & 1) == 1;
- bool is_inline = (info_bits & 0x60) == 0;
- bool has_explicit_length = (info_bits & (1 | 4)) != 4;
- bool is_unicode = (info_bits & 0x10) == 0x10;
- bool is_special = strcmp(class_name,"NSPathStore2") == 0;
-
- if (strcmp(class_name,"NSString") &&
- strcmp(class_name,"CFStringRef") &&
- strcmp(class_name,"CFMutableStringRef") &&
- strcmp(class_name,"__NSCFConstantString") &&
- strcmp(class_name,"__NSCFString") &&
- strcmp(class_name,"NSCFConstantString") &&
- strcmp(class_name,"NSCFString") &&
- strcmp(class_name,"NSPathStore2"))
- {
- // probably not one of us - bail out
- return false;
- }
-
- if (is_mutable)
- {
- uint64_t location = 2 * ptr_size + valobj_addr;
- location = process_sp->ReadPointerFromMemory(location, error);
- if (error.Fail())
- return false;
- if (has_explicit_length and is_unicode)
- return ReadUTFBufferAndDumpToStream (location, process_sp, stream);
- else
- {
- location++;
- lldb::DataBufferSP buffer_sp(new DataBufferHeap(1024,0));
- size_t data_read = process_sp->ReadCStringFromMemory(location, (char*)buffer_sp->GetBytes(), 1024, error);
- if (error.Fail())
- return false;
- if (data_read)
- stream.Printf("@\"%s\"",(char*)buffer_sp->GetBytes());
- return true;
- }
- }
- else if (is_inline && has_explicit_length && !is_unicode && !is_special && !is_mutable)
- {
- uint64_t location = 3 * ptr_size + valobj_addr;
- lldb::DataBufferSP buffer_sp(new DataBufferHeap(1024,0));
- size_t data_read = process_sp->ReadCStringFromMemory(location, (char*)buffer_sp->GetBytes(), 1024, error);
- if (error.Fail())
- return false;
- if (data_read)
- stream.Printf("@\"%s\"",(char*)buffer_sp->GetBytes());
- return true;
- }
- else if (is_unicode)
- {
- uint64_t location = valobj_addr + ptr_size + 4 + (ptr_size == 8 ? 4 : 0);
- if (is_inline)
- {
- if (!has_explicit_length)
- {
- stream.Printf("found new combo");
- return true;
- }
- else
- location += ptr_size;
- }
- else
- {
- location = process_sp->ReadPointerFromMemory(location, error);
- if (error.Fail())
- return false;
- }
- return ReadUTFBufferAndDumpToStream (location, process_sp, stream);
- }
- else if (is_special)
- {
- uint64_t location = valobj_addr + (ptr_size == 8 ? 12 : 8);
- return ReadUTFBufferAndDumpToStream (location, process_sp, stream);
- }
- else if (is_inline)
- {
- uint64_t location = valobj_addr + ptr_size + 4 + (ptr_size == 8 ? 4 : 0);
- if (!has_explicit_length)
- location++;
- lldb::DataBufferSP buffer_sp(new DataBufferHeap(1024,0));
- size_t data_read = process_sp->ReadCStringFromMemory(location, (char*)buffer_sp->GetBytes(), 1024, error);
- if (error.Fail())
- return false;
- if (data_read)
- stream.Printf("@\"%s\"",(char*)buffer_sp->GetBytes());
- return true;
- }
- else
- {
- uint64_t location = valobj_addr + ptr_size + 4 + (ptr_size == 8 ? 4 : 0);
- location = process_sp->ReadPointerFromMemory(location, error);
- if (error.Fail())
- return false;
- lldb::DataBufferSP buffer_sp(new DataBufferHeap(1024,0));
- size_t data_read = process_sp->ReadCStringFromMemory(location, (char*)buffer_sp->GetBytes(), 1024, error);
- if (error.Fail())
- return false;
- if (data_read)
- stream.Printf("@\"%s\"",(char*)buffer_sp->GetBytes());
- return true;
- }
-
- stream.Printf("class name = %s",class_name);
- return true;
-
-}
-bool
-lldb_private::formatters::RuntimeSpecificDescriptionSummaryProvider (ValueObject& valobj, Stream& stream)
-{
- stream.Printf("%s",valobj.GetObjectDescription());
- return true;
-}
-
-bool
-lldb_private::formatters::ObjCBOOLSummaryProvider (ValueObject& valobj, Stream& stream)
-{
- const uint32_t type_info = ClangASTContext::GetTypeInfo(valobj.GetClangType(),
- valobj.GetClangAST(),
- NULL);
-
- ValueObjectSP real_guy_sp = valobj.GetSP();
-
- if (type_info & ClangASTContext::eTypeIsPointer)
- {
- Error err;
- real_guy_sp = valobj.Dereference(err);
- if (err.Fail() || !real_guy_sp)
- return false;
- }
- else if (type_info & ClangASTContext::eTypeIsReference)
- {
- real_guy_sp = valobj.GetChildAtIndex(0, true);
- if (!real_guy_sp)
- return false;
- }
- uint64_t value = real_guy_sp->GetValueAsUnsigned(0);
- if (value == 0)
- {
- stream.Printf("NO");
- return true;
- }
- stream.Printf("YES");
- return true;
-}
-
-template <bool is_sel_ptr>
-bool
-lldb_private::formatters::ObjCSELSummaryProvider (ValueObject& valobj, Stream& stream)
-{
- lldb::addr_t data_address = LLDB_INVALID_ADDRESS;
-
- if (is_sel_ptr)
- data_address = valobj.GetValueAsUnsigned(LLDB_INVALID_ADDRESS);
- else
- data_address = valobj.GetAddressOf();
-
- if (data_address == LLDB_INVALID_ADDRESS)
- return false;
-
- ExecutionContext exe_ctx(valobj.GetExecutionContextRef());
-
- void* char_opaque_type = valobj.GetClangAST()->CharTy.getAsOpaquePtr();
- ClangASTType charstar(valobj.GetClangAST(),ClangASTType::GetPointerType(valobj.GetClangAST(), char_opaque_type));
-
- ValueObjectSP valobj_sp(ValueObject::CreateValueObjectFromAddress("text", data_address, exe_ctx, charstar));
-
- stream.Printf("%s",valobj_sp->GetSummaryAsCString());
- return true;
-}
-
-lldb_private::formatters::NSArrayMSyntheticFrontEnd::NSArrayMSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
-SyntheticChildrenFrontEnd(*valobj_sp.get()),
-m_exe_ctx_ref(),
-m_ptr_size(8),
-m_data_32(NULL),
-m_data_64(NULL)
-{
- if (valobj_sp)
- {
- m_id_type = ClangASTType(valobj_sp->GetClangAST(),valobj_sp->GetClangAST()->ObjCBuiltinIdTy.getAsOpaquePtr());
- Update();
- }
-}
-
-uint32_t
-lldb_private::formatters::NSArrayMSyntheticFrontEnd::CalculateNumChildren ()
-{
- if (m_data_32)
- return m_data_32->_used;
- if (m_data_64)
- return m_data_64->_used;
- return 0;
-}
-
-lldb::ValueObjectSP
-lldb_private::formatters::NSArrayMSyntheticFrontEnd::GetChildAtIndex (uint32_t idx)
-{
- if (!m_data_32 && !m_data_64)
- return lldb::ValueObjectSP();
- if (idx >= CalculateNumChildren())
- return lldb::ValueObjectSP();
- lldb::addr_t object_at_idx = (m_data_32 ? m_data_32->_data : m_data_64->_data);
- object_at_idx += (idx * m_ptr_size);
- StreamString idx_name;
- idx_name.Printf("[%d]",idx);
- lldb::ValueObjectSP retval_sp = ValueObject::CreateValueObjectFromAddress(idx_name.GetData(),
- object_at_idx,
- m_exe_ctx_ref,
- m_id_type);
- m_children.push_back(retval_sp);
- return retval_sp;
-}
-
-bool
-lldb_private::formatters::NSArrayMSyntheticFrontEnd::Update()
-{
- m_children.clear();
- ValueObjectSP valobj_sp = m_backend.GetSP();
- m_ptr_size = 0;
- delete m_data_32;
- m_data_32 = NULL;
- delete m_data_64;
- m_data_64 = NULL;
- if (valobj_sp->IsDynamic())
- valobj_sp = valobj_sp->GetStaticValue();
- if (!valobj_sp)
- return false;
- m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
- Error error;
- if (valobj_sp->IsPointerType())
- {
- valobj_sp = valobj_sp->Dereference(error);
- if (error.Fail() || !valobj_sp)
- return false;
- }
- error.Clear();
- lldb::ProcessSP process_sp(valobj_sp->GetProcessSP());
- if (!process_sp)
- return false;
- m_ptr_size = process_sp->GetAddressByteSize();
- uint64_t data_location = valobj_sp->GetAddressOf() + m_ptr_size;
- if (m_ptr_size == 4)
- {
- m_data_32 = new DataDescriptor_32();
- process_sp->ReadMemory (data_location, m_data_32, sizeof(DataDescriptor_32), error);
- }
- else
- {
- m_data_64 = new DataDescriptor_64();
- process_sp->ReadMemory (data_location, m_data_64, sizeof(DataDescriptor_64), error);
- }
- if (error.Fail())
- return false;
- return false;
-}
-
-bool
-lldb_private::formatters::NSArrayMSyntheticFrontEnd::MightHaveChildren ()
-{
- return true;
-}
-
-static uint32_t
-ExtractIndexFromString (const char* item_name)
-{
- if (!item_name || !*item_name)
- return UINT32_MAX;
- if (*item_name != '[')
- return UINT32_MAX;
- item_name++;
- uint32_t idx = 0;
- while(*item_name)
- {
- char x = *item_name;
- if (x == ']')
- break;
- if (x < '0' || x > '9')
- return UINT32_MAX;
- idx = 10*idx + (x-'0');
- item_name++;
- }
- return idx;
-}
-
-uint32_t
-lldb_private::formatters::NSArrayMSyntheticFrontEnd::GetIndexOfChildWithName (const ConstString &name)
-{
- if (!m_data_32 && !m_data_64)
- return UINT32_MAX;
- const char* item_name = name.GetCString();
- uint32_t idx = ExtractIndexFromString(item_name);
- if (idx < UINT32_MAX && idx >= CalculateNumChildren())
- return UINT32_MAX;
- return idx;
-}
-
-lldb_private::formatters::NSArrayMSyntheticFrontEnd::~NSArrayMSyntheticFrontEnd ()
-{
- delete m_data_32;
- m_data_32 = NULL;
- delete m_data_64;
- m_data_64 = NULL;
-}
-
-lldb_private::formatters::NSArrayISyntheticFrontEnd::NSArrayISyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
-SyntheticChildrenFrontEnd(*valobj_sp.get()),
-m_exe_ctx_ref(),
-m_ptr_size(8),
-m_items(0),
-m_data_ptr(0)
-{
- if (valobj_sp)
- {
- m_id_type = ClangASTType(valobj_sp->GetClangAST(),valobj_sp->GetClangAST()->ObjCBuiltinIdTy.getAsOpaquePtr());
- Update();
- }
-}
-
-lldb_private::formatters::NSArrayISyntheticFrontEnd::~NSArrayISyntheticFrontEnd ()
-{
-}
-
-uint32_t
-lldb_private::formatters::NSArrayISyntheticFrontEnd::GetIndexOfChildWithName (const ConstString &name)
-{
- const char* item_name = name.GetCString();
- uint32_t idx = ExtractIndexFromString(item_name);
- if (idx < UINT32_MAX && idx >= CalculateNumChildren())
- return UINT32_MAX;
- return idx;
-}
-
-uint32_t
-lldb_private::formatters::NSArrayISyntheticFrontEnd::CalculateNumChildren ()
-{
- return m_items;
-}
-
-bool
-lldb_private::formatters::NSArrayISyntheticFrontEnd::Update()
-{
- m_ptr_size = 0;
- m_items = 0;
- m_data_ptr = 0;
- m_children.clear();
- ValueObjectSP valobj_sp = m_backend.GetSP();
- if (valobj_sp->IsDynamic())
- valobj_sp = valobj_sp->GetStaticValue();
- if (!valobj_sp)
- return false;
- m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
- Error error;
- if (valobj_sp->IsPointerType())
- {
- valobj_sp = valobj_sp->Dereference(error);
- if (error.Fail() || !valobj_sp)
- return false;
- }
- error.Clear();
- lldb::ProcessSP process_sp(valobj_sp->GetProcessSP());
- if (!process_sp)
- return false;
- m_ptr_size = process_sp->GetAddressByteSize();
- uint64_t data_location = valobj_sp->GetAddressOf() + m_ptr_size;
- m_items = process_sp->ReadPointerFromMemory(data_location, error);
- if (error.Fail())
- return false;
- m_data_ptr = data_location+m_ptr_size;
- return false;
-}
-
-bool
-lldb_private::formatters::NSArrayISyntheticFrontEnd::MightHaveChildren ()
-{
- return true;
-}
-
-lldb::ValueObjectSP
-lldb_private::formatters::NSArrayISyntheticFrontEnd::GetChildAtIndex (uint32_t idx)
-{
- if (idx >= CalculateNumChildren())
- return lldb::ValueObjectSP();
- lldb::addr_t object_at_idx = m_data_ptr;
- object_at_idx += (idx * m_ptr_size);
- ProcessSP process_sp = m_exe_ctx_ref.GetProcessSP();
- if (!process_sp)
- return lldb::ValueObjectSP();
- Error error;
- object_at_idx = process_sp->ReadPointerFromMemory(object_at_idx, error);
- if (error.Fail())
- return lldb::ValueObjectSP();
- StreamString expr;
- expr.Printf("(id)%" PRIu64,object_at_idx);
- StreamString idx_name;
- idx_name.Printf("[%d]",idx);
- lldb::ValueObjectSP retval_sp = ValueObject::CreateValueObjectFromExpression(idx_name.GetData(), expr.GetData(), m_exe_ctx_ref);
- m_children.push_back(retval_sp);
- return retval_sp;
-}
-
-SyntheticChildrenFrontEnd* lldb_private::formatters::NSArraySyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp)
-{
- lldb::ProcessSP process_sp (valobj_sp->GetProcessSP());
- if (!process_sp)
- return NULL;
- ObjCLanguageRuntime *runtime = (ObjCLanguageRuntime*)process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC);
- if (!runtime)
- return NULL;
-
- if (!valobj_sp->IsPointerType())
- {
- Error error;
- valobj_sp = valobj_sp->AddressOf(error);
- if (error.Fail() || !valobj_sp)
- return NULL;
- }
-
- ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(*valobj_sp.get()));
-
- if (!descriptor.get() || !descriptor->IsValid())
- return NULL;
-
- const char* class_name = descriptor->GetClassName().GetCString();
-
- if (!class_name || !*class_name)
- return NULL;
-
- if (!strcmp(class_name,"__NSArrayI"))
- {
- return (new NSArrayISyntheticFrontEnd(valobj_sp));
- }
- else if (!strcmp(class_name,"__NSArrayM"))
- {
- return (new NSArrayMSyntheticFrontEnd(valobj_sp));
- }
- else
- {
- return (new NSArrayCodeRunningSyntheticFrontEnd(valobj_sp));
- }
-}
-
-lldb_private::formatters::NSArrayCodeRunningSyntheticFrontEnd::NSArrayCodeRunningSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
-SyntheticChildrenFrontEnd(*valobj_sp.get())
-{}
-
-uint32_t
-lldb_private::formatters::NSArrayCodeRunningSyntheticFrontEnd::CalculateNumChildren ()
-{
- uint64_t count = 0;
- if (ExtractValueFromObjCExpression(m_backend, "int", "count", count))
- return count;
- return 0;
-}
-
-lldb::ValueObjectSP
-lldb_private::formatters::NSArrayCodeRunningSyntheticFrontEnd::GetChildAtIndex (uint32_t idx)
-{
- StreamString idx_name;
- idx_name.Printf("[%d]",idx);
- lldb::ValueObjectSP valobj_sp = CallSelectorOnObject(m_backend,"id","objectAtIndex:",idx);
- if (valobj_sp)
- valobj_sp->SetName(ConstString(idx_name.GetData()));
- return valobj_sp;
-}
-
-bool
-lldb_private::formatters::NSArrayCodeRunningSyntheticFrontEnd::Update()
-{
- return false;
-}
-
-bool
-lldb_private::formatters::NSArrayCodeRunningSyntheticFrontEnd::MightHaveChildren ()
-{
- return true;
-}
-
-uint32_t
-lldb_private::formatters::NSArrayCodeRunningSyntheticFrontEnd::GetIndexOfChildWithName (const ConstString &name)
-{
- return 0;
-}
-
-lldb_private::formatters::NSArrayCodeRunningSyntheticFrontEnd::~NSArrayCodeRunningSyntheticFrontEnd ()
-{}
-
-SyntheticChildrenFrontEnd* lldb_private::formatters::NSDictionarySyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp)
-{
-
- lldb::ProcessSP process_sp (valobj_sp->GetProcessSP());
- if (!process_sp)
- return NULL;
- ObjCLanguageRuntime *runtime = (ObjCLanguageRuntime*)process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC);
- if (!runtime)
- return NULL;
-
- if (!valobj_sp->IsPointerType())
- {
- Error error;
- valobj_sp = valobj_sp->AddressOf(error);
- if (error.Fail() || !valobj_sp)
- return NULL;
- }
-
- ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(*valobj_sp.get()));
-
- if (!descriptor.get() || !descriptor->IsValid())
- return NULL;
-
- const char* class_name = descriptor->GetClassName().GetCString();
-
- if (!class_name || !*class_name)
- return NULL;
-
- if (!strcmp(class_name,"__NSDictionaryI"))
- {
- return (new NSDictionaryISyntheticFrontEnd(valobj_sp));
- }
- else if (!strcmp(class_name,"__NSDictionaryM"))
- {
- return (new NSDictionaryMSyntheticFrontEnd(valobj_sp));
- }
- else
- {
- return (new NSDictionaryCodeRunningSyntheticFrontEnd(valobj_sp));
- }
-}
-
-lldb_private::formatters::NSDictionaryCodeRunningSyntheticFrontEnd::NSDictionaryCodeRunningSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
-SyntheticChildrenFrontEnd(*valobj_sp.get())
-{}
-
-uint32_t
-lldb_private::formatters::NSDictionaryCodeRunningSyntheticFrontEnd::CalculateNumChildren ()
-{
- uint64_t count = 0;
- if (ExtractValueFromObjCExpression(m_backend, "int", "count", count))
- return count;
- return 0;
-}
-
-lldb::ValueObjectSP
-lldb_private::formatters::NSDictionaryCodeRunningSyntheticFrontEnd::GetChildAtIndex (uint32_t idx)
-{
- StreamString idx_name;
- idx_name.Printf("[%d]",idx);
- StreamString valobj_expr_path;
- m_backend.GetExpressionPath(valobj_expr_path, false);
- StreamString key_fetcher_expr;
- key_fetcher_expr.Printf("(id)[(NSArray*)[%s allKeys] objectAtIndex:%d]",valobj_expr_path.GetData(),idx);
- StreamString value_fetcher_expr;
- value_fetcher_expr.Printf("(id)[%s objectForKey:%s]",valobj_expr_path.GetData(),key_fetcher_expr.GetData());
- StreamString object_fetcher_expr;
- object_fetcher_expr.Printf("struct __lldb_autogen_nspair { id key; id value; } _lldb_valgen_item; _lldb_valgen_item.key = %s; _lldb_valgen_item.value = %s; _lldb_valgen_item;",key_fetcher_expr.GetData(),value_fetcher_expr.GetData());
- lldb::ValueObjectSP child_sp;
- m_backend.GetTargetSP()->EvaluateExpression(object_fetcher_expr.GetData(), m_backend.GetFrameSP().get(), child_sp,
- EvaluateExpressionOptions().SetKeepInMemory(true));
- if (child_sp)
- child_sp->SetName(ConstString(idx_name.GetData()));
- return child_sp;
-}
-
-bool
-lldb_private::formatters::NSDictionaryCodeRunningSyntheticFrontEnd::Update()
-{
- return false;
-}
-
-bool
-lldb_private::formatters::NSDictionaryCodeRunningSyntheticFrontEnd::MightHaveChildren ()
-{
- return true;
-}
-
-uint32_t
-lldb_private::formatters::NSDictionaryCodeRunningSyntheticFrontEnd::GetIndexOfChildWithName (const ConstString &name)
-{
- return 0;
-}
-
-lldb_private::formatters::NSDictionaryCodeRunningSyntheticFrontEnd::~NSDictionaryCodeRunningSyntheticFrontEnd ()
-{}
-
-lldb_private::formatters::NSDictionaryISyntheticFrontEnd::NSDictionaryISyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
- SyntheticChildrenFrontEnd(*valobj_sp.get()),
- m_exe_ctx_ref(),
- m_ptr_size(8),
- m_data_32(NULL),
- m_data_64(NULL)
-{
- if (valobj_sp)
- Update();
-}
-
-lldb_private::formatters::NSDictionaryISyntheticFrontEnd::~NSDictionaryISyntheticFrontEnd ()
-{
- delete m_data_32;
- m_data_32 = NULL;
- delete m_data_64;
- m_data_64 = NULL;
-}
-
-uint32_t
-lldb_private::formatters::NSDictionaryISyntheticFrontEnd::GetIndexOfChildWithName (const ConstString &name)
-{
- const char* item_name = name.GetCString();
- uint32_t idx = ExtractIndexFromString(item_name);
- if (idx < UINT32_MAX && idx >= CalculateNumChildren())
- return UINT32_MAX;
- return idx;
-}
-
-uint32_t
-lldb_private::formatters::NSDictionaryISyntheticFrontEnd::CalculateNumChildren ()
-{
- if (!m_data_32 && !m_data_64)
- return 0;
- return (m_data_32 ? m_data_32->_used : m_data_64->_used);
-}
-
-bool
-lldb_private::formatters::NSDictionaryISyntheticFrontEnd::Update()
-{
- m_children.clear();
- delete m_data_32;
- m_data_32 = NULL;
- delete m_data_64;
- m_data_64 = NULL;
- m_ptr_size = 0;
- ValueObjectSP valobj_sp = m_backend.GetSP();
- if (!valobj_sp)
- return false;
- if (valobj_sp->IsDynamic())
- valobj_sp = valobj_sp->GetStaticValue();
- if (!valobj_sp)
- return false;
- m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
- Error error;
- if (valobj_sp->IsPointerType())
- {
- valobj_sp = valobj_sp->Dereference(error);
- if (error.Fail() || !valobj_sp)
- return false;
- }
- error.Clear();
- lldb::ProcessSP process_sp(valobj_sp->GetProcessSP());
- if (!process_sp)
- return false;
- m_ptr_size = process_sp->GetAddressByteSize();
- uint64_t data_location = valobj_sp->GetAddressOf() + m_ptr_size;
- if (m_ptr_size == 4)
- {
- m_data_32 = new DataDescriptor_32();
- process_sp->ReadMemory (data_location, m_data_32, sizeof(DataDescriptor_32), error);
- }
- else
- {
- m_data_64 = new DataDescriptor_64();
- process_sp->ReadMemory (data_location, m_data_64, sizeof(DataDescriptor_64), error);
- }
- if (error.Fail())
- return false;
- m_data_ptr = data_location + m_ptr_size;
- return false;
-}
-
-bool
-lldb_private::formatters::NSDictionaryISyntheticFrontEnd::MightHaveChildren ()
-{
- return true;
-}
-
-lldb::ValueObjectSP
-lldb_private::formatters::NSDictionaryISyntheticFrontEnd::GetChildAtIndex (uint32_t idx)
-{
- uint32_t num_children = CalculateNumChildren();
-
- if (idx >= num_children)
- return lldb::ValueObjectSP();
-
- if (m_children.empty())
- {
- // do the scan phase
- lldb::addr_t key_at_idx = 0, val_at_idx = 0;
-
- uint32_t tries = 0;
- uint32_t test_idx = 0;
-
- while(tries < num_children)
- {
- key_at_idx = m_data_ptr + (2*test_idx * m_ptr_size);
- val_at_idx = key_at_idx + m_ptr_size;
- ProcessSP process_sp = m_exe_ctx_ref.GetProcessSP();
- if (!process_sp)
- return lldb::ValueObjectSP();
- Error error;
- key_at_idx = process_sp->ReadPointerFromMemory(key_at_idx, error);
- if (error.Fail())
- return lldb::ValueObjectSP();
- val_at_idx = process_sp->ReadPointerFromMemory(val_at_idx, error);
- if (error.Fail())
- return lldb::ValueObjectSP();
-
- test_idx++;
-
- if (!key_at_idx || !val_at_idx)
- continue;
- tries++;
-
- DictionaryItemDescriptor descriptor = {key_at_idx,val_at_idx,lldb::ValueObjectSP()};
-
- m_children.push_back(descriptor);
- }
- }
-
- if (idx >= m_children.size()) // should never happen
- return lldb::ValueObjectSP();
-
- DictionaryItemDescriptor &dict_item = m_children[idx];
- if (!dict_item.valobj_sp)
- {
- // make the new ValueObject
- StreamString expr;
- expr.Printf("struct __lldb_autogen_nspair { id key; id value; } _lldb_valgen_item; _lldb_valgen_item.key = (id)%" PRIu64 " ; _lldb_valgen_item.value = (id)%" PRIu64 "; _lldb_valgen_item;",dict_item.key_ptr,dict_item.val_ptr);
- StreamString idx_name;
- idx_name.Printf("[%d]",idx);
- dict_item.valobj_sp = ValueObject::CreateValueObjectFromExpression(idx_name.GetData(), expr.GetData(), m_exe_ctx_ref);
- }
- return dict_item.valobj_sp;
-}
-
-lldb_private::formatters::NSDictionaryMSyntheticFrontEnd::NSDictionaryMSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
- SyntheticChildrenFrontEnd(*valobj_sp.get()),
- m_exe_ctx_ref(),
- m_ptr_size(8),
- m_data_32(NULL),
- m_data_64(NULL)
-{
- if (valobj_sp)
- Update ();
-}
-
-lldb_private::formatters::NSDictionaryMSyntheticFrontEnd::~NSDictionaryMSyntheticFrontEnd ()
-{
- delete m_data_32;
- m_data_32 = NULL;
- delete m_data_64;
- m_data_64 = NULL;
-}
-
-uint32_t
-lldb_private::formatters::NSDictionaryMSyntheticFrontEnd::GetIndexOfChildWithName (const ConstString &name)
-{
- const char* item_name = name.GetCString();
- uint32_t idx = ExtractIndexFromString(item_name);
- if (idx < UINT32_MAX && idx >= CalculateNumChildren())
- return UINT32_MAX;
- return idx;
-}
-
-uint32_t
-lldb_private::formatters::NSDictionaryMSyntheticFrontEnd::CalculateNumChildren ()
-{
- if (!m_data_32 && !m_data_64)
- return 0;
- return (m_data_32 ? m_data_32->_used : m_data_64->_used);
-}
-
-bool
-lldb_private::formatters::NSDictionaryMSyntheticFrontEnd::Update()
-{
- m_children.clear();
- ValueObjectSP valobj_sp = m_backend.GetSP();
- m_ptr_size = 0;
- delete m_data_32;
- m_data_32 = NULL;
- delete m_data_64;
- m_data_64 = NULL;
- if (!valobj_sp)
- return false;
- if (valobj_sp->IsDynamic())
- valobj_sp = valobj_sp->GetStaticValue();
- if (!valobj_sp)
- return false;
- m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
- Error error;
- if (valobj_sp->IsPointerType())
- {
- valobj_sp = valobj_sp->Dereference(error);
- if (error.Fail() || !valobj_sp)
- return false;
- }
- error.Clear();
- lldb::ProcessSP process_sp(valobj_sp->GetProcessSP());
- if (!process_sp)
- return false;
- m_ptr_size = process_sp->GetAddressByteSize();
- uint64_t data_location = valobj_sp->GetAddressOf() + m_ptr_size;
- if (m_ptr_size == 4)
- {
- m_data_32 = new DataDescriptor_32();
- process_sp->ReadMemory (data_location, m_data_32, sizeof(DataDescriptor_32), error);
- }
- else
- {
- m_data_64 = new DataDescriptor_64();
- process_sp->ReadMemory (data_location, m_data_64, sizeof(DataDescriptor_64), error);
- }
- if (error.Fail())
- return false;
- return false;
-}
-
-bool
-lldb_private::formatters::NSDictionaryMSyntheticFrontEnd::MightHaveChildren ()
-{
- return true;
-}
-
-lldb::ValueObjectSP
-lldb_private::formatters::NSDictionaryMSyntheticFrontEnd::GetChildAtIndex (uint32_t idx)
-{
- lldb::addr_t m_keys_ptr = (m_data_32 ? m_data_32->_keys_addr : m_data_64->_keys_addr);
- lldb::addr_t m_values_ptr = (m_data_32 ? m_data_32->_objs_addr : m_data_64->_objs_addr);
-
- uint32_t num_children = CalculateNumChildren();
-
- if (idx >= num_children)
- return lldb::ValueObjectSP();
-
- if (m_children.empty())
- {
- // do the scan phase
- lldb::addr_t key_at_idx = 0, val_at_idx = 0;
-
- uint32_t tries = 0;
- uint32_t test_idx = 0;
-
- while(tries < num_children)
- {
- key_at_idx = m_keys_ptr + (test_idx * m_ptr_size);
- val_at_idx = m_values_ptr + (test_idx * m_ptr_size);;
- ProcessSP process_sp = m_exe_ctx_ref.GetProcessSP();
- if (!process_sp)
- return lldb::ValueObjectSP();
- Error error;
- key_at_idx = process_sp->ReadPointerFromMemory(key_at_idx, error);
- if (error.Fail())
- return lldb::ValueObjectSP();
- val_at_idx = process_sp->ReadPointerFromMemory(val_at_idx, error);
- if (error.Fail())
- return lldb::ValueObjectSP();
-
- test_idx++;
-
- if (!key_at_idx || !val_at_idx)
- continue;
- tries++;
-
- DictionaryItemDescriptor descriptor = {key_at_idx,val_at_idx,lldb::ValueObjectSP()};
-
- m_children.push_back(descriptor);
- }
- }
-
- if (idx >= m_children.size()) // should never happen
- return lldb::ValueObjectSP();
-
- DictionaryItemDescriptor &dict_item = m_children[idx];
- if (!dict_item.valobj_sp)
- {
- // make the new ValueObject
- StreamString expr;
- expr.Printf("struct __lldb_autogen_nspair { id key; id value; } _lldb_valgen_item; _lldb_valgen_item.key = (id)%" PRIu64 " ; _lldb_valgen_item.value = (id)%" PRIu64 "; _lldb_valgen_item;",dict_item.key_ptr,dict_item.val_ptr);
- StreamString idx_name;
- idx_name.Printf("[%d]",idx);
- dict_item.valobj_sp = ValueObject::CreateValueObjectFromExpression(idx_name.GetData(), expr.GetData(), m_exe_ctx_ref);
- }
- return dict_item.valobj_sp;
-}
-
-template bool
-lldb_private::formatters::NSDictionarySummaryProvider<true> (ValueObject&, Stream&) ;
-
-template bool
-lldb_private::formatters::NSDictionarySummaryProvider<false> (ValueObject&, Stream&) ;
-
-template bool
-lldb_private::formatters::NSDataSummaryProvider<true> (ValueObject&, Stream&) ;
-
-template bool
-lldb_private::formatters::NSDataSummaryProvider<false> (ValueObject&, Stream&) ;
-
-template bool
-lldb_private::formatters::ObjCSELSummaryProvider<true> (ValueObject&, Stream&) ;
-
-template bool
-lldb_private::formatters::ObjCSELSummaryProvider<false> (ValueObject&, Stream&) ;
Modified: lldb/branches/windows/source/Core/Communication.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/Communication.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/Communication.cpp (original)
+++ lldb/branches/windows/source/Core/Communication.cpp Wed Apr 17 03:38:48 2013
@@ -338,7 +338,7 @@ Communication::ReadThread (void *p)
{
Communication *comm = (Communication *)p;
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_COMMUNICATION));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_COMMUNICATION));
if (log)
log->Printf ("%p Communication::ReadThread () thread starting...", p);
@@ -377,9 +377,9 @@ Communication::ReadThread (void *p)
case eConnectionStatusError: // Check GetError() for details
case eConnectionStatusTimedOut: // Request timed out
if (log)
- error.LogIfError(log.get(),
- "%p Communication::ReadFromConnection () => status = %s",
- p,
+ error.LogIfError (log,
+ "%p Communication::ReadFromConnection () => status = %s",
+ p,
Communication::ConnectionStatusAsCString (status));
break;
}
Modified: lldb/branches/windows/source/Core/ConnectionFileDescriptor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/ConnectionFileDescriptor.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/ConnectionFileDescriptor.cpp (original)
+++ lldb/branches/windows/source/Core/ConnectionFileDescriptor.cpp Wed Apr 17 03:38:48 2013
@@ -7,6 +7,13 @@
//
//===----------------------------------------------------------------------===//
+#if defined(__APPLE__)
+// Enable this special support for Apple builds where we can have unlimited
+// select bounds. We tried switching to poll() and kqueue and we were panicing
+// the kernel, so we have to stick with select for now.
+#define _DARWIN_UNLIMITED_SELECT
+#endif
+
#include "lldb/Core/ConnectionFileDescriptor.h"
// C Includes
@@ -27,6 +34,9 @@
// C++ Includes
// Other libraries and framework includes
+#if defined(__APPLE__)
+#include "llvm/ADT/SmallVector.h"
+#endif
// Project includes
#include "lldb/lldb-private-log.h"
#include "lldb/Interpreter/Args.h"
@@ -45,11 +55,12 @@ DecodeHostAndPort (const char *host_and_
int32_t& port,
Error *error_ptr)
{
- RegularExpression regex ("([^:]+):([0-9]+)");
- if (regex.Execute (host_and_port, 2))
+ static RegularExpression g_regex ("([^:]+):([0-9]+)");
+ RegularExpression::Match regex_match(2);
+ if (g_regex.Execute (host_and_port, ®ex_match))
{
- if (regex.GetMatchAtIndex (host_and_port, 1, host_str) &&
- regex.GetMatchAtIndex (host_and_port, 2, port_str))
+ if (regex_match.GetMatchAtIndex (host_and_port, 1, host_str) &&
+ regex_match.GetMatchAtIndex (host_and_port, 2, port_str))
{
port = Args::StringToSInt32 (port_str.c_str(), INT32_MIN);
if (port != INT32_MIN)
@@ -82,7 +93,7 @@ ConnectionFileDescriptor::ConnectionFile
m_mutex (Mutex::eMutexTypeRecursive),
m_shutting_down (false)
{
- LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION | LIBLLDB_LOG_OBJECT));
+ Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION | LIBLLDB_LOG_OBJECT));
if (log)
log->Printf ("%p ConnectionFileDescriptor::ConnectionFileDescriptor ()", this);
}
@@ -101,7 +112,7 @@ ConnectionFileDescriptor::ConnectionFile
m_mutex (Mutex::eMutexTypeRecursive),
m_shutting_down (false)
{
- LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION | LIBLLDB_LOG_OBJECT));
+ Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION | LIBLLDB_LOG_OBJECT));
if (log)
log->Printf ("%p ConnectionFileDescriptor::ConnectionFileDescriptor (fd = %i, owns_fd = %i)", this, fd, owns_fd);
OpenCommandPipe ();
@@ -110,7 +121,7 @@ ConnectionFileDescriptor::ConnectionFile
ConnectionFileDescriptor::~ConnectionFileDescriptor ()
{
- LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION | LIBLLDB_LOG_OBJECT));
+ Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION | LIBLLDB_LOG_OBJECT));
if (log)
log->Printf ("%p ConnectionFileDescriptor::~ConnectionFileDescriptor ()", this);
Disconnect (NULL);
@@ -122,7 +133,7 @@ ConnectionFileDescriptor::OpenCommandPip
{
CloseCommandPipe();
- LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION | LIBLLDB_LOG_OBJECT));
+ Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
// Make the command file descriptor here:
int filedes[2];
#ifdef _POSIX_SOURCE
@@ -174,7 +185,7 @@ ConnectionStatus
ConnectionFileDescriptor::Connect (const char *s, Error *error_ptr)
{
Mutex::Locker locker (m_mutex);
- LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
+ Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
if (log)
log->Printf ("%p ConnectionFileDescriptor::Connect (url = '%s')", this, s);
@@ -306,7 +317,7 @@ ConnectionFileDescriptor::Connect (const
ConnectionStatus
ConnectionFileDescriptor::Disconnect (Error *error_ptr)
{
- LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
+ Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
if (log)
log->Printf ("%p ConnectionFileDescriptor::Disconnect ()", this);
@@ -383,7 +394,7 @@ ConnectionFileDescriptor::Read (void *ds
ConnectionStatus &status,
Error *error_ptr)
{
- LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
+ Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
if (log)
log->Printf ("%p ConnectionFileDescriptor::Read () ::read (fd = %i, dst = %p, dst_len = %" PRIu64 ")...",
this, m_fd_recv, dst, (uint64_t)dst_len);
@@ -529,7 +540,6 @@ ConnectionFileDescriptor::Read (void *ds
return 0;
}
- //Disconnect (NULL);
return 0;
}
return bytes_read;
@@ -538,7 +548,7 @@ ConnectionFileDescriptor::Read (void *ds
size_t
ConnectionFileDescriptor::Write (const void *src, size_t src_len, ConnectionStatus &status, Error *error_ptr)
{
- LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
+ Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
if (log)
log->Printf ("%p ConnectionFileDescriptor::Write (src = %p, src_len = %" PRIu64 ")", this, src, (uint64_t)src_len);
@@ -668,13 +678,28 @@ ConnectionFileDescriptor::Write (const v
return bytes_sent;
}
+
+
+#if defined(__APPLE__)
+
+// This ConnectionFileDescriptor::BytesAvailable() uses select().
+//
+// PROS:
+// - select is consistent across most unix platforms
+// - this Apple specific version allows for unlimited fds in the fd_sets by
+// setting the _DARWIN_UNLIMITED_SELECT define prior to including the
+// required header files.
+
+// CONS:
+// - Darwin only
+
ConnectionStatus
ConnectionFileDescriptor::BytesAvailable (uint32_t timeout_usec, Error *error_ptr)
{
// Don't need to take the mutex here separately since we are only called from Read. If we
// ever get used more generally we will need to lock here as well.
- LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
+ Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
if (log)
log->Printf("%p ConnectionFileDescriptor::BytesAvailable (timeout_usec = %u)", this, timeout_usec);
struct timeval *tv_ptr;
@@ -691,101 +716,436 @@ ConnectionFileDescriptor::BytesAvailable
tv = time_value.GetAsTimeVal();
tv_ptr = &tv;
}
-
- while (m_fd_recv >= 0)
+
+ // Make a copy of the file descriptors to make sure we don't
+ // have another thread change these values out from under us
+ // and cause problems in the loop below where like in FS_SET()
+ const int data_fd = m_fd_recv;
+ const int pipe_fd = m_pipe_read;
+
+ if (data_fd >= 0)
{
- fd_set read_fds;
- FD_ZERO (&read_fds);
- FD_SET (m_fd_recv, &read_fds);
- if (m_pipe_read != -1)
- FD_SET (m_pipe_read, &read_fds);
- int nfds = std::max<int>(m_fd_recv, m_pipe_read) + 1;
+ const bool have_pipe_fd = pipe_fd >= 0;
- Error error;
+ while (data_fd == m_fd_recv)
+ {
+ const int nfds = std::max<int>(data_fd, pipe_fd) + 1;
+ llvm::SmallVector<fd_set, 1> read_fds;
+ read_fds.resize((nfds/FD_SETSIZE) + 1);
+ for (size_t i=0; i<read_fds.size(); ++i)
+ FD_ZERO (&read_fds[i]);
+ // FD_SET doesn't bounds check, it just happily walks off the end
+ // but we have taken care of making the extra storage with our
+ // SmallVector of fd_set objects
+ FD_SET (data_fd, read_fds.data());
+ if (have_pipe_fd)
+ FD_SET (pipe_fd, read_fds.data());
+
+ Error error;
+
+ if (log)
+ {
+ if (have_pipe_fd)
+ log->Printf("%p ConnectionFileDescriptor::BytesAvailable() ::select (nfds=%i, fds={%i, %i}, NULL, NULL, timeout=%p)...",
+ this, nfds, data_fd, pipe_fd, tv_ptr);
+ else
+ log->Printf("%p ConnectionFileDescriptor::BytesAvailable() ::select (nfds=%i, fds={%i}, NULL, NULL, timeout=%p)...",
+ this, nfds, data_fd, tv_ptr);
+ }
+
+ const int num_set_fds = ::select (nfds, read_fds.data(), NULL, NULL, tv_ptr);
+ if (num_set_fds < 0)
+ error.SetErrorToErrno();
+ else
+ error.Clear();
+
+ if (log)
+ {
+ if (have_pipe_fd)
+ log->Printf("%p ConnectionFileDescriptor::BytesAvailable() ::select (nfds=%i, fds={%i, %i}, NULL, NULL, timeout=%p) => %d, error = %s",
+ this, nfds, data_fd, pipe_fd, tv_ptr, num_set_fds, error.AsCString());
+ else
+ log->Printf("%p ConnectionFileDescriptor::BytesAvailable() ::select (nfds=%i, fds={%i}, NULL, NULL, timeout=%p) => %d, error = %s",
+ this, nfds, data_fd, tv_ptr, num_set_fds, error.AsCString());
+ }
+
+ if (error_ptr)
+ *error_ptr = error;
+
+ if (error.Fail())
+ {
+ switch (error.GetError())
+ {
+ case EBADF: // One of the descriptor sets specified an invalid descriptor.
+ return eConnectionStatusLostConnection;
+
+ case EINVAL: // The specified time limit is invalid. One of its components is negative or too large.
+ default: // Other unknown error
+ return eConnectionStatusError;
+
+ case EAGAIN: // The kernel was (perhaps temporarily) unable to
+ // allocate the requested number of file descriptors,
+ // or we have non-blocking IO
+ case EINTR: // A signal was delivered before the time limit
+ // expired and before any of the selected events
+ // occurred.
+ break; // Lets keep reading to until we timeout
+ }
+ }
+ else if (num_set_fds == 0)
+ {
+ return eConnectionStatusTimedOut;
+ }
+ else if (num_set_fds > 0)
+ {
+ // FD_ISSET is happy to deal with a something larger than
+ // a single fd_set.
+ if (FD_ISSET(data_fd, read_fds.data()))
+ return eConnectionStatusSuccess;
+ if (have_pipe_fd && FD_ISSET(pipe_fd, read_fds.data()))
+ {
+ // We got a command to exit. Read the data from that pipe:
+ char buffer[16];
+ ssize_t bytes_read;
+
+ do
+ {
+ bytes_read = ::read (pipe_fd, buffer, sizeof(buffer));
+ } while (bytes_read < 0 && errno == EINTR);
+ assert (bytes_read == 1 && buffer[0] == 'q');
+
+ if (log)
+ log->Printf("%p ConnectionFileDescriptor::BytesAvailable() got data: %*s from the command channel.",
+ this, (int) bytes_read, buffer);
+
+ return eConnectionStatusEndOfFile;
+ }
+ }
+ }
+ }
+
+ if (error_ptr)
+ error_ptr->SetErrorString("not connected");
+ return eConnectionStatusLostConnection;
+}
+#else
- if (log)
- log->Printf("%p ConnectionFileDescriptor::BytesAvailable() ::select (nfds = %i, fd = %i, NULL, NULL, timeout = %p)...",
- this, nfds, m_fd_recv, tv_ptr);
+// This ConnectionFileDescriptor::BytesAvailable() uses select().
+//
+// PROS:
+// - select is consistent across most unix platforms
+// CONS:
+// - only supports file descriptors up to FD_SETSIZE. This implementation
+// will assert if it runs into that hard limit to let users know that
+// another ConnectionFileDescriptor::BytesAvailable() should be used
+// or a new version of ConnectionFileDescriptor::BytesAvailable() should
+// be written for the system that is running into the limitations. MacOSX
+// uses kqueues, and there is a poll() based implementation below.
- const int num_set_fds = ::select (nfds, &read_fds, NULL, NULL, tv_ptr);
- if (num_set_fds < 0)
- error.SetErrorToErrno();
- else
- error.Clear();
+ConnectionStatus
+ConnectionFileDescriptor::BytesAvailable (uint32_t timeout_usec, Error *error_ptr)
+{
+ // Don't need to take the mutex here separately since we are only called from Read. If we
+ // ever get used more generally we will need to lock here as well.
+
+ Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
+ if (log)
+ log->Printf("%p ConnectionFileDescriptor::BytesAvailable (timeout_usec = %u)", this, timeout_usec);
+ struct timeval *tv_ptr;
+ struct timeval tv;
+ if (timeout_usec == UINT32_MAX)
+ {
+ // Infinite wait...
+ tv_ptr = NULL;
+ }
+ else
+ {
+ TimeValue time_value;
+ time_value.OffsetWithMicroSeconds (timeout_usec);
+ tv = time_value.GetAsTimeVal();
+ tv_ptr = &tv;
+ }
+
+ // Make a copy of the file descriptors to make sure we don't
+ // have another thread change these values out from under us
+ // and cause problems in the loop below where like in FS_SET()
+ const int data_fd = m_fd_recv;
+ const int pipe_fd = m_pipe_read;
+
+ if (data_fd >= 0)
+ {
+ // If this assert fires off on MacOSX, we will need to switch to using
+ // libdispatch to read from file descriptors because poll() is causing
+ // kernel panics and if we exceed FD_SETSIZE we will have no choice...
+#ifndef _WIN32
+ assert (data_fd < FD_SETSIZE);
+#endif
+
+ const bool have_pipe_fd = pipe_fd >= 0;
+
+ if (have_pipe_fd)
+ {
+ assert (pipe_fd < FD_SETSIZE);
+ }
- if (log)
- log->Printf("%p ConnectionFileDescriptor::BytesAvailable() ::select (nfds = %i, fd = %i, NULL, NULL, timeout = %p) => %d, error = %s",
- this, nfds, m_fd_recv, tv_ptr, num_set_fds, error.AsCString());
+ while (data_fd == m_fd_recv)
+ {
+ fd_set read_fds;
+ FD_ZERO (&read_fds);
+ FD_SET (data_fd, &read_fds);
+ if (have_pipe_fd)
+ FD_SET (pipe_fd, &read_fds);
- if (error_ptr)
- *error_ptr = error;
+ const int nfds = std::max<int>(data_fd, pipe_fd) + 1;
- if (error.Fail())
- {
- switch (error.GetError())
+ Error error;
+
+ if (log)
{
+ if (have_pipe_fd)
+ log->Printf("%p ConnectionFileDescriptor::BytesAvailable() ::select (nfds=%i, fds={%i, %i}, NULL, NULL, timeout=%p)...",
+ this, nfds, data_fd, pipe_fd, tv_ptr);
+ else
+ log->Printf("%p ConnectionFileDescriptor::BytesAvailable() ::select (nfds=%i, fds={%i}, NULL, NULL, timeout=%p)...",
+ this, nfds, data_fd, tv_ptr);
+ }
+
+ const int num_set_fds = ::select (nfds, &read_fds, NULL, NULL, tv_ptr);
+ if (num_set_fds < 0)
+ error.SetErrorToErrno();
+ else
+ error.Clear();
+
+ if (log)
+ {
+ if (have_pipe_fd)
+ log->Printf("%p ConnectionFileDescriptor::BytesAvailable() ::select (nfds=%i, fds={%i, %i}, NULL, NULL, timeout=%p) => %d, error = %s",
+ this, nfds, data_fd, pipe_fd, tv_ptr, num_set_fds, error.AsCString());
+ else
+ log->Printf("%p ConnectionFileDescriptor::BytesAvailable() ::select (nfds=%i, fds={%i}, NULL, NULL, timeout=%p) => %d, error = %s",
+ this, nfds, data_fd, tv_ptr, num_set_fds, error.AsCString());
+ }
+
+ if (error_ptr)
+ *error_ptr = error;
+
+ if (error.Fail())
+ {
+ switch (error.GetError())
+ {
#ifdef _WIN32
case WSAEBADF:
#else
- case EBADF: // One of the descriptor sets specified an invalid descriptor.
+ case EBADF: // One of the descriptor sets specified an invalid descriptor.
#endif
- return eConnectionStatusLostConnection;
-
- case EINVAL: // The specified time limit is invalid. One of its components is negative or too large.
- default: // Other unknown error
- return eConnectionStatusError;
-
+ return eConnectionStatusLostConnection;
+
+ case EINVAL: // The specified time limit is invalid. One of its components is negative or too large.
+ default: // Other unknown error
+ return eConnectionStatusError;
+
#ifdef _WIN32
case WSAEWOULDBLOCK:
case WSAEINTR:
#else
- case EAGAIN: // The kernel was (perhaps temporarily) unable to
- // allocate the requested number of file descriptors,
- // or we have non-blocking IO
- case EINTR: // A signal was delivered before the time limit
- // expired and before any of the selected events
- // occurred.
+ case EAGAIN: // The kernel was (perhaps temporarily) unable to
+ // allocate the requested number of file descriptors,
+ // or we have non-blocking IO
+ case EINTR: // A signal was delivered before the time limit
+ // expired and before any of the selected events
+ // occurred.
#endif
- break; // Lets keep reading to until we timeout
+ break; // Lets keep reading to until we timeout
+ }
}
- }
- else if (num_set_fds == 0)
- {
- return eConnectionStatusTimedOut;
- }
- else if (num_set_fds > 0)
- {
- if (m_pipe_read != -1 && FD_ISSET(m_pipe_read, &read_fds))
+ else if (num_set_fds == 0)
{
- // We got a command to exit. Read the data from that pipe:
- char buffer[16];
- ssize_t bytes_read;
-
- do
+ return eConnectionStatusTimedOut;
+ }
+ else if (num_set_fds > 0)
+ {
+ if (FD_ISSET(data_fd, &read_fds))
+ return eConnectionStatusSuccess;
+ if (have_pipe_fd && FD_ISSET(pipe_fd, &read_fds))
{
+ // We got a command to exit. Read the data from that pipe:
+ char buffer[16];
+ ssize_t bytes_read;
+
+ do
+ {
#ifdef _POSIX_SOURCE
- bytes_read = ::read (m_pipe_read, buffer, sizeof(buffer));
+ bytes_read = ::read (pipe_fd, buffer, sizeof(buffer));
#endif
- } while (bytes_read < 0 && errno == EINTR);
- assert (bytes_read == 1 && buffer[0] == 'q');
-
- if (log)
- log->Printf("%p ConnectionFileDescriptor::BytesAvailable() got data: %*s from the command channel.",
- this, (int) bytes_read, buffer);
-
- return eConnectionStatusEndOfFile;
+ } while (bytes_read < 0 && errno == EINTR);
+ assert (bytes_read == 1 && buffer[0] == 'q');
+
+ if (log)
+ log->Printf("%p ConnectionFileDescriptor::BytesAvailable() got data: %*s from the command channel.",
+ this, (int) bytes_read, buffer);
+
+ return eConnectionStatusEndOfFile;
+ }
}
- else
- return eConnectionStatusSuccess;
}
}
+
+ if (error_ptr)
+ error_ptr->SetErrorString("not connected");
+ return eConnectionStatusLostConnection;
+}
+#endif
+
+#if 0
+#include <poll.h>
+
+// This ConnectionFileDescriptor::BytesAvailable() uses poll(). poll() should NOT
+// be used on MacOSX as it has all sorts of restrictions on the types of file descriptors
+// that it doesn't support.
+//
+// There may be some systems that properly support poll() that could use this
+// implementation. I will let each system opt into this on their own.
+//
+// PROS:
+// - no restrictions on the fd value that is used
+// CONS:
+// - varies wildly from platform to platform in its implementation restrictions
+
+ConnectionStatus
+ConnectionFileDescriptor::BytesAvailable (uint32_t timeout_usec, Error *error_ptr)
+{
+ // Don't need to take the mutex here separately since we are only called from Read. If we
+ // ever get used more generally we will need to lock here as well.
+
+ Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
+ if (log)
+ log->Printf("%p ConnectionFileDescriptor::BytesAvailable (timeout_usec = %u)", this, timeout_usec);
+ int timeout_msec = 0;
+ if (timeout_usec == UINT32_MAX)
+ {
+ // Infinite wait...
+ timeout_msec = -1;
+ }
+ else if (timeout_usec == 0)
+ {
+ // Return immediately, don't wait
+ timeout_msec = 0;
+ }
+ else
+ {
+ // Convert usec to msec
+ timeout_msec = (timeout_usec + 999) / 1000;
+ }
+
+ // Make a copy of the file descriptors to make sure we don't
+ // have another thread change these values out from under us
+ // and cause problems in the loop below where like in FS_SET()
+ const int data_fd = m_fd_recv;
+ const int pipe_fd = m_pipe_read;
+
+ // Make sure the file descriptor can be used with select as it
+ // must be in range
+ if (data_fd >= 0)
+ {
+ const bool have_pipe_fd = pipe_fd >= 0;
+ struct pollfd fds[2] =
+ {
+ { data_fd, POLLIN, 0 },
+ { pipe_fd, POLLIN, 0 }
+ };
+ const int nfds = have_pipe_fd ? 2 : 1;
+ Error error;
+ while (data_fd == m_fd_recv)
+ {
+ const int num_set_fds = ::poll (fds, nfds, timeout_msec);
+
+ if (num_set_fds < 0)
+ error.SetErrorToErrno();
+ else
+ error.Clear();
+
+ if (error_ptr)
+ *error_ptr = error;
+
+ if (log)
+ {
+ if (have_pipe_fd)
+ log->Printf("%p ConnectionFileDescriptor::BytesAvailable() ::poll (fds={{%i,POLLIN},{%i,POLLIN}}, nfds=%i, timeout_ms=%i) => %d, error = %s\n",
+ this,
+ data_fd,
+ pipe_fd,
+ nfds,
+ timeout_msec,
+ num_set_fds,
+ error.AsCString());
+ else
+ log->Printf("%p ConnectionFileDescriptor::BytesAvailable() ::poll (fds={{%i,POLLIN}}, nfds=%i, timeout_ms=%i) => %d, error = %s\n",
+ this,
+ data_fd,
+ nfds,
+ timeout_msec,
+ num_set_fds,
+ error.AsCString());
+ }
+
+ if (error.Fail())
+ {
+ switch (error.GetError())
+ {
+ case EBADF: // One of the descriptor sets specified an invalid descriptor.
+ return eConnectionStatusLostConnection;
+
+ case EINVAL: // The specified time limit is invalid. One of its components is negative or too large.
+ default: // Other unknown error
+ return eConnectionStatusError;
+
+ case EAGAIN: // The kernel was (perhaps temporarily) unable to
+ // allocate the requested number of file descriptors,
+ // or we have non-blocking IO
+ case EINTR: // A signal was delivered before the time limit
+ // expired and before any of the selected events
+ // occurred.
+ break; // Lets keep reading to until we timeout
+ }
+ }
+ else if (num_set_fds == 0)
+ {
+ return eConnectionStatusTimedOut;
+ }
+ else if (num_set_fds > 0)
+ {
+ if (fds[0].revents & POLLIN)
+ return eConnectionStatusSuccess;
+ if (fds[1].revents & POLLIN)
+ {
+ // We got a command to exit. Read the data from that pipe:
+ char buffer[16];
+ ssize_t bytes_read;
+
+ do
+ {
+ bytes_read = ::read (pipe_fd, buffer, sizeof(buffer));
+ } while (bytes_read < 0 && errno == EINTR);
+ assert (bytes_read == 1 && buffer[0] == 'q');
+
+ if (log)
+ log->Printf("%p ConnectionFileDescriptor::BytesAvailable() got data: %*s from the command channel.",
+ this, (int) bytes_read, buffer);
+
+ return eConnectionStatusEndOfFile;
+ }
+ }
+ }
+ }
if (error_ptr)
error_ptr->SetErrorString("not connected");
return eConnectionStatusLostConnection;
}
+#endif
+
ConnectionStatus
ConnectionFileDescriptor::Close (int& fd, Error *error_ptr)
{
@@ -800,7 +1160,7 @@ ConnectionFileDescriptor::Close (int& fd
// can get into the close scope below
if (fd >= 0)
{
- LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
+ Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
if (log)
log->Printf ("%p ConnectionFileDescriptor::Close (fd = %i)", this,fd);
@@ -920,7 +1280,8 @@ ConnectionStatus
ConnectionFileDescriptor::SocketListen (uint16_t listen_port_num, Error *error_ptr)
{
#if _POSIX_SOURCE
- LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
+ Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
+
if (log)
log->Printf ("%p ConnectionFileDescriptor::SocketListen (port = %i)", this, listen_port_num);
@@ -986,7 +1347,7 @@ ConnectionFileDescriptor::SocketListen (
ConnectionStatus
ConnectionFileDescriptor::ConnectTCP (const char *host_and_port, Error *error_ptr)
{
- LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
+ Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
if (log)
log->Printf ("%p ConnectionFileDescriptor::ConnectTCP (host/port = %s)", this, host_and_port);
Disconnect (NULL);
@@ -1060,7 +1421,7 @@ ConnectionFileDescriptor::ConnectTCP (co
ConnectionStatus
ConnectionFileDescriptor::ConnectUDP (const char *host_and_port, Error *error_ptr)
{
- LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
+ Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
if (log)
log->Printf ("%p ConnectionFileDescriptor::ConnectUDP (host/port = %s)", this, host_and_port);
Disconnect (NULL);
Modified: lldb/branches/windows/source/Core/ConstString.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/ConstString.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/ConstString.cpp (original)
+++ lldb/branches/windows/source/Core/ConstString.cpp Wed Apr 17 03:38:48 2013
@@ -87,7 +87,7 @@ public:
}
const char *
- GetConstCStringWithLength (const char *cstr, int cstr_len)
+ GetConstCStringWithLength (const char *cstr, size_t cstr_len)
{
if (cstr)
{
@@ -132,11 +132,11 @@ public:
}
const char *
- GetConstTrimmedCStringWithLength (const char *cstr, int cstr_len)
+ GetConstTrimmedCStringWithLength (const char *cstr, size_t cstr_len)
{
if (cstr)
{
- int trimmed_len = std::min<int> (strlen (cstr), cstr_len);
+ const size_t trimmed_len = std::min<size_t> (strlen (cstr), cstr_len);
return GetConstCStringWithLength (cstr, trimmed_len);
}
return NULL;
Modified: lldb/branches/windows/source/Core/DataBufferHeap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/DataBufferHeap.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/DataBufferHeap.cpp (original)
+++ lldb/branches/windows/source/Core/DataBufferHeap.cpp Wed Apr 17 03:38:48 2013
@@ -23,7 +23,7 @@ DataBufferHeap::DataBufferHeap () :
// Initialize this class with "n" characters and fill the buffer
// with "ch".
//----------------------------------------------------------------------
-DataBufferHeap::DataBufferHeap (size_t n, uint8_t ch) :
+DataBufferHeap::DataBufferHeap (lldb::offset_t n, uint8_t ch) :
m_data(n, ch)
{
}
@@ -32,7 +32,7 @@ DataBufferHeap::DataBufferHeap (size_t n
// Initialize this class with a copy of the "n" bytes from the "bytes"
// buffer.
//----------------------------------------------------------------------
-DataBufferHeap::DataBufferHeap (const void *src, size_t src_len) :
+DataBufferHeap::DataBufferHeap (const void *src, lldb::offset_t src_len) :
m_data()
{
CopyData (src, src_len);
@@ -73,7 +73,7 @@ DataBufferHeap::GetBytes () const
//----------------------------------------------------------------------
// Return the number of bytes this object currently contains.
//----------------------------------------------------------------------
-size_t
+uint64_t
DataBufferHeap::GetByteSize () const
{
return m_data.size();
@@ -84,15 +84,15 @@ DataBufferHeap::GetByteSize () const
// Sets the number of bytes that this object should be able to
// contain. This can be used prior to copying data into the buffer.
//----------------------------------------------------------------------
-size_t
-DataBufferHeap::SetByteSize (size_t new_size)
+uint64_t
+DataBufferHeap::SetByteSize (uint64_t new_size)
{
m_data.resize(new_size);
return m_data.size();
}
void
-DataBufferHeap::CopyData (const void *src, size_t src_len)
+DataBufferHeap::CopyData (const void *src, uint64_t src_len)
{
const uint8_t *src_u8 = (const uint8_t *)src;
if (src && src_len > 0)
Modified: lldb/branches/windows/source/Core/DataBufferMemoryMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/DataBufferMemoryMap.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/DataBufferMemoryMap.cpp (original)
+++ lldb/branches/windows/source/Core/DataBufferMemoryMap.cpp Wed Apr 17 03:38:48 2013
@@ -25,7 +25,10 @@
#include "lldb/Host/File.h"
#include "lldb/Host/FileSpec.h"
#include "lldb/Host/Host.h"
+#include "lldb/Core/Log.h"
+#include "lldb/lldb-private-log.h"
+using namespace lldb;
using namespace lldb_private;
//----------------------------------------------------------------------
@@ -71,7 +74,7 @@ DataBufferMemoryMap::GetBytes() const
//----------------------------------------------------------------------
// Return the number of bytes this object currently contains.
//----------------------------------------------------------------------
-size_t
+uint64_t
DataBufferMemoryMap::GetByteSize() const
{
return m_size;
@@ -86,9 +89,13 @@ DataBufferMemoryMap::Clear()
{
if (m_mmap_addr != NULL)
{
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_MMAP));
+ if (log)
+ log->Printf("DataBufferMemoryMap::Clear() m_mmap_addr = %p, m_mmap_size = %zu", m_mmap_addr, m_mmap_size);
#ifdef _WIN32
if (m_mmap_addr)
UnmapViewOfFile(m_mmap_addr);
+
if (m_mmap_handle)
CloseHandle(m_mmap_handle);
m_mmap_handle = NULL;
@@ -112,12 +119,22 @@ DataBufferMemoryMap::Clear()
//----------------------------------------------------------------------
size_t
DataBufferMemoryMap::MemoryMapFromFileSpec (const FileSpec* filespec,
- off_t offset,
- size_t length,
+ lldb::offset_t offset,
+ lldb::offset_t length,
bool writeable)
{
if (filespec != NULL)
{
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_MMAP));
+ if (log)
+ {
+ log->Printf("DataBufferMemoryMap::MemoryMapFromFileSpec(file=\"%s/%s\", offset=0x%" PRIx64 ", length=0x%" PRIx64 ", writeable=%i",
+ filespec->GetDirectory().GetCString(),
+ filespec->GetFilename().GetCString(),
+ offset,
+ length,
+ writeable);
+ }
char path[PATH_MAX];
if (filespec->GetPath(path, sizeof(path)))
{
@@ -130,8 +147,7 @@ DataBufferMemoryMap::MemoryMapFromFileSp
if (error.Success())
{
const bool fd_is_file = true;
- MemoryMapFromFileDescriptor (file.GetDescriptor(), offset, length, writeable, fd_is_file);
- return GetByteSize();
+ return MemoryMapFromFileDescriptor (file.GetDescriptor(), offset, length, writeable, fd_is_file);
}
}
}
@@ -140,7 +156,15 @@ DataBufferMemoryMap::MemoryMapFromFileSp
return 0;
}
-
+#ifdef _WIN32
+static size_t win32memmapalignment = 0;
+void LoadWin32MemMapAlignment ()
+{
+ SYSTEM_INFO data;
+ GetSystemInfo(&data);
+ win32memmapalignment = data.dwAllocationGranularity;
+}
+#endif
//----------------------------------------------------------------------
// The file descriptor FD is assumed to already be opened as read only
// and the STAT structure is assumed to a valid pointer and already
@@ -155,14 +179,24 @@ DataBufferMemoryMap::MemoryMapFromFileSp
//----------------------------------------------------------------------
size_t
DataBufferMemoryMap::MemoryMapFromFileDescriptor (int fd,
- off_t offset,
- size_t length,
+ lldb::offset_t offset,
+ lldb::offset_t length,
bool writeable,
bool fd_is_file)
{
Clear();
if (fd >= 0)
{
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_MMAP|LIBLLDB_LOG_VERBOSE));
+ if (log)
+ {
+ log->Printf("DataBufferMemoryMap::MemoryMapFromFileSpec(fd=%i, offset=0x%" PRIx64 ", length=0x%" PRIx64 ", writeable=%i, fd_is_file=%i)",
+ fd,
+ offset,
+ length,
+ writeable,
+ fd_is_file);
+ }
struct stat stat;
if (::fstat(fd, &stat) == 0)
{
@@ -190,16 +224,24 @@ DataBufferMemoryMap::MemoryMapFromFileDe
error.SetErrorToErrno ();
return 0;
}
- LPVOID data = MapViewOfFile(m_mmap_handle, writeable ? FILE_MAP_WRITE : FILE_MAP_READ, 0, offset, length);
+ if (win32memmapalignment == 0) LoadWin32MemMapAlignment();
+ lldb::offset_t realoffset = offset;
+ lldb::offset_t delta = 0;
+ if (realoffset % win32memmapalignment != 0) {
+ realoffset = realoffset / win32memmapalignment * win32memmapalignment;
+ delta = offset - realoffset;
+ }
+
+ LPVOID data = MapViewOfFile(m_mmap_handle, writeable ? FILE_MAP_WRITE : FILE_MAP_READ, 0, realoffset, length + delta);
m_mmap_addr = (uint8_t *)data;
- m_data = m_mmap_addr;
+ m_data = m_mmap_addr + delta;
if (!m_data) {
Error error;
error.SetErrorToErrno ();
CloseHandle(m_mmap_handle);
return 0;
}
- m_mmap_size = length;
+ m_mmap_size = length + delta;
m_size = length;
}
}
@@ -228,10 +270,10 @@ DataBufferMemoryMap::MemoryMapFromFileDe
flags |= MAP_FILE;
m_mmap_addr = (uint8_t *)::mmap(NULL, length, prot, flags, fd, offset);
+ Error error;
if (m_mmap_addr == (void*)-1)
{
- Error error;
error.SetErrorToErrno ();
if (error.GetError() == EINVAL)
{
@@ -272,6 +314,12 @@ DataBufferMemoryMap::MemoryMapFromFileDe
m_data = m_mmap_addr;
m_size = length;
}
+
+ if (log)
+ {
+ log->Printf("DataBufferMemoryMap::MemoryMapFromFileSpec() m_mmap_addr = %p, m_mmap_size = %zu, error = %s",
+ m_mmap_addr, m_mmap_size, error.AsCString());
+ }
}
}
#endif
Modified: lldb/branches/windows/source/Core/DataEncoder.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/DataEncoder.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/DataEncoder.cpp (original)
+++ lldb/branches/windows/source/Core/DataEncoder.cpp Wed Apr 17 03:38:48 2013
@@ -142,32 +142,6 @@ DataEncoder::GetSharedDataOffset () cons
return 0;
}
-//------------------------------------------------------------------
-// Returns true if there are LENGTH bytes availabe starting OFFSET
-// into the data that is in this object.
-//------------------------------------------------------------------
-bool
-DataEncoder::ValidOffsetForDataOfSize (uint32_t offset, uint32_t length) const
-{
- size_t size = GetByteSize();
- if (offset >= size)
- return false; // offset isn't valid
-
- if (length == 0)
- return true; // No bytes requested at this offset, return true
-
- // If we flip the bits in offset we can figure out how
- // many bytes we have left before "offset + length"
- // could overflow when doing unsigned arithmetic.
- if (length > ~offset)
- return false; // unsigned overflow
-
- // Make sure "offset + length" is a valid offset as well.
- // length must be greater than zero for this to be a
- // valid expression, and we have already checked for this.
- return ((offset + length) <= size);
-}
-
//----------------------------------------------------------------------
// Set the data with which this object will extract from to data
// starting at BYTES and set the length of the data to LENGTH bytes
Modified: lldb/branches/windows/source/Core/DataExtractor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/DataExtractor.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/DataExtractor.cpp (original)
+++ lldb/branches/windows/source/Core/DataExtractor.cpp Wed Apr 17 03:38:48 2013
@@ -38,39 +38,73 @@ using namespace lldb;
using namespace lldb_private;
static inline uint16_t
-ReadInt16(const unsigned char* ptr, unsigned offset)
+ReadInt16(const unsigned char* ptr, offset_t offset)
{
return *(uint16_t *)(ptr + offset);
}
static inline uint32_t
-ReadInt32 (const unsigned char* ptr, unsigned offset)
+ReadInt32 (const unsigned char* ptr, offset_t offset)
{
return *(uint32_t *)(ptr + offset);
}
static inline uint64_t
-ReadInt64(const unsigned char* ptr, unsigned offset)
+ReadInt64(const unsigned char* ptr, offset_t offset)
{
return *(uint64_t *)(ptr + offset);
}
static inline uint16_t
-ReadSwapInt16(const unsigned char* ptr, unsigned offset)
+ReadInt16(const void* ptr)
+{
+ return *(uint16_t *)(ptr);
+}
+static inline uint32_t
+ReadInt32 (const void* ptr)
+{
+ return *(uint32_t *)(ptr);
+}
+
+static inline uint64_t
+ReadInt64(const void* ptr)
+{
+ return *(uint64_t *)(ptr);
+}
+
+static inline uint16_t
+ReadSwapInt16(const unsigned char* ptr, offset_t offset)
{
return llvm::ByteSwap_16(*(uint16_t *)(ptr + offset));
}
static inline uint32_t
-ReadSwapInt32 (const unsigned char* ptr, unsigned offset)
+ReadSwapInt32 (const unsigned char* ptr, offset_t offset)
{
return llvm::ByteSwap_32(*(uint32_t *)(ptr + offset));
}
static inline uint64_t
-ReadSwapInt64(const unsigned char* ptr, unsigned offset)
+ReadSwapInt64(const unsigned char* ptr, offset_t offset)
{
return llvm::ByteSwap_64(*(uint64_t *)(ptr + offset));
}
+static inline uint16_t
+ReadSwapInt16(const void* ptr)
+{
+ return llvm::ByteSwap_16(*(uint16_t *)(ptr));
+}
+
+static inline uint32_t
+ReadSwapInt32 (const void* ptr)
+{
+ return llvm::ByteSwap_32(*(uint32_t *)(ptr));
+}
+static inline uint64_t
+ReadSwapInt64(const void* ptr)
+{
+ return llvm::ByteSwap_64(*(uint64_t *)(ptr));
+}
+
#define NON_PRINTABLE_CHAR '.'
//----------------------------------------------------------------------
// Default constructor.
@@ -88,7 +122,7 @@ DataExtractor::DataExtractor () :
// This constructor allows us to use data that is owned by someone else.
// The data must stay around as long as this object is valid.
//----------------------------------------------------------------------
-DataExtractor::DataExtractor (const void* data, uint32_t length, ByteOrder endian, uint8_t addr_size) :
+DataExtractor::DataExtractor (const void* data, offset_t length, ByteOrder endian, uint32_t addr_size) :
m_start ((uint8_t*)data),
m_end ((uint8_t*)data + length),
m_byte_order(endian),
@@ -104,7 +138,7 @@ DataExtractor::DataExtractor (const void
// as long as any DataExtractor objects exist that have a reference to
// this data.
//----------------------------------------------------------------------
-DataExtractor::DataExtractor (const DataBufferSP& data_sp, ByteOrder endian, uint8_t addr_size) :
+DataExtractor::DataExtractor (const DataBufferSP& data_sp, ByteOrder endian, uint32_t addr_size) :
m_start (NULL),
m_end (NULL),
m_byte_order(endian),
@@ -121,7 +155,7 @@ DataExtractor::DataExtractor (const Data
// as any object contains a reference to that data. The endian
// swap and address size settings are copied from "data".
//----------------------------------------------------------------------
-DataExtractor::DataExtractor (const DataExtractor& data, uint32_t offset, uint32_t length) :
+DataExtractor::DataExtractor (const DataExtractor& data, offset_t offset, offset_t length) :
m_start(NULL),
m_end(NULL),
m_byte_order(data.m_byte_order),
@@ -130,7 +164,7 @@ DataExtractor::DataExtractor (const Data
{
if (data.ValidOffset(offset))
{
- uint32_t bytes_available = data.GetByteSize() - offset;
+ offset_t bytes_available = data.GetByteSize() - offset;
if (length > bytes_available)
length = bytes_available;
SetData(data, offset, length);
@@ -208,32 +242,6 @@ DataExtractor::GetSharedDataOffset () co
return 0;
}
-//------------------------------------------------------------------
-// Returns true if there are LENGTH bytes availabe starting OFFSET
-// into the data that is in this object.
-//------------------------------------------------------------------
-bool
-DataExtractor::ValidOffsetForDataOfSize (uint32_t offset, uint32_t length) const
-{
- size_t size = GetByteSize();
- if (offset >= size)
- return false; // offset isn't valid
-
- if (length == 0)
- return true; // No bytes requested at this offset, return true
-
- // If we flip the bits in offset we can figure out how
- // many bytes we have left before "offset + length"
- // could overflow when doing unsigned arithmetic.
- if (length > ~offset)
- return false; // unsigned overflow
-
- // Make sure "offset + length" is a valid offset as well.
- // length must be greater than zero for this to be a
- // valid expression, and we have already checked for this.
- return ((offset + length) <= size);
-}
-
//----------------------------------------------------------------------
// Set the data with which this object will extract from to data
// starting at BYTES and set the length of the data to LENGTH bytes
@@ -244,8 +252,8 @@ DataExtractor::ValidOffsetForDataOfSize
// reference to that data will be released. Is SWAP is set to true,
// any data extracted will be endian swapped.
//----------------------------------------------------------------------
-uint32_t
-DataExtractor::SetData (const void *bytes, uint32_t length, ByteOrder endian)
+lldb::offset_t
+DataExtractor::SetData (const void *bytes, offset_t length, ByteOrder endian)
{
m_byte_order = endian;
m_data_sp.reset();
@@ -276,8 +284,8 @@ DataExtractor::SetData (const void *byte
// refers to those bytes. The address size and endian swap settings
// are copied from the current values in "data".
//----------------------------------------------------------------------
-uint32_t
-DataExtractor::SetData (const DataExtractor& data, uint32_t data_offset, uint32_t data_length)
+lldb::offset_t
+DataExtractor::SetData (const DataExtractor& data, offset_t data_offset, offset_t data_length)
{
m_addr_size = data.m_addr_size;
// If "data" contains shared pointer to data, then we can use that
@@ -311,8 +319,8 @@ DataExtractor::SetData (const DataExtrac
// around as long as it is needed. The address size and endian swap
// settings will remain unchanged from their current settings.
//----------------------------------------------------------------------
-uint32_t
-DataExtractor::SetData (const DataBufferSP& data_sp, uint32_t data_offset, uint32_t data_length)
+lldb::offset_t
+DataExtractor::SetData (const DataBufferSP& data_sp, offset_t data_offset, offset_t data_length)
{
m_start = m_end = NULL;
@@ -335,7 +343,7 @@ DataExtractor::SetData (const DataBuffer
}
}
- uint32_t new_size = GetByteSize();
+ size_t new_size = GetByteSize();
// Don't hold a shared pointer to the data buffer if we don't share
// any valid bytes in the shared buffer.
@@ -352,15 +360,12 @@ DataExtractor::SetData (const DataBuffer
// RETURNS the byte that was extracted, or zero on failure.
//----------------------------------------------------------------------
uint8_t
-DataExtractor::GetU8 (uint32_t *offset_ptr) const
+DataExtractor::GetU8 (offset_t *offset_ptr) const
{
- uint8_t val = 0;
- if ( m_start < m_end )
- {
- val = m_start[*offset_ptr];
- *offset_ptr += sizeof(val);
- }
- return val;
+ const uint8_t *data = (const uint8_t *)GetData (offset_ptr, 1);
+ if (data)
+ return *data;
+ return 0;
}
//----------------------------------------------------------------------
@@ -373,16 +378,13 @@ DataExtractor::GetU8 (uint32_t *offset_p
// the buffer due to being out of bounds, or unsufficient data.
//----------------------------------------------------------------------
void *
-DataExtractor::GetU8 (uint32_t *offset_ptr, void *dst, uint32_t count) const
+DataExtractor::GetU8 (offset_t *offset_ptr, void *dst, uint32_t count) const
{
- register uint32_t offset = *offset_ptr;
-
- if ((count > 0) && ValidOffsetForDataOfSize(offset, count) )
+ const uint8_t *data = (const uint8_t *)GetData (offset_ptr, count);
+ if (data)
{
// Copy the data into the buffer
- memcpy (dst, m_start + offset, count);
- // Advance the offset
- *offset_ptr += count;
+ memcpy (dst, data, count);
// Return a non-NULL pointer to the converted data as an indicator of success
return dst;
}
@@ -396,49 +398,52 @@ DataExtractor::GetU8 (uint32_t *offset_p
// RETURNS the uint16_t that was extracted, or zero on failure.
//----------------------------------------------------------------------
uint16_t
-DataExtractor::GetU16 (uint32_t *offset_ptr) const
+DataExtractor::GetU16 (offset_t *offset_ptr) const
{
uint16_t val = 0;
- register uint32_t offset = *offset_ptr;
- if ( ValidOffsetForDataOfSize(offset, sizeof(val)) )
+ const uint8_t *data = (const uint8_t *)GetData (offset_ptr, sizeof(val));
+ if (data)
{
if (m_byte_order != lldb::endian::InlHostByteOrder())
- val = ReadSwapInt16(m_start, offset);
+ val = ReadSwapInt16(data);
else
- val = ReadInt16 (m_start, offset);
-
- // Advance the offset
- *offset_ptr += sizeof(val);
+ val = ReadInt16 (data);
}
return val;
}
uint16_t
-DataExtractor::GetU16_unchecked (uint32_t *offset_ptr) const
+DataExtractor::GetU16_unchecked (offset_t *offset_ptr) const
{
- uint16_t val = (m_byte_order == lldb::endian::InlHostByteOrder()) ?
- ReadInt16 (m_start, *offset_ptr) :
- ReadSwapInt16(m_start, *offset_ptr);
+ uint16_t val;
+ if (m_byte_order == lldb::endian::InlHostByteOrder())
+ val = ReadInt16 (m_start, *offset_ptr);
+ else
+ val = ReadSwapInt16(m_start, *offset_ptr);
*offset_ptr += sizeof(val);
return val;
}
uint32_t
-DataExtractor::GetU32_unchecked (uint32_t *offset_ptr) const
+DataExtractor::GetU32_unchecked (offset_t *offset_ptr) const
{
- uint32_t val = (m_byte_order == lldb::endian::InlHostByteOrder()) ?
- ReadInt32 (m_start, *offset_ptr) :
- ReadSwapInt32 (m_start, *offset_ptr);
+ uint32_t val;
+ if (m_byte_order == lldb::endian::InlHostByteOrder())
+ val = ReadInt32 (m_start, *offset_ptr);
+ else
+ val = ReadSwapInt32 (m_start, *offset_ptr);
*offset_ptr += sizeof(val);
return val;
}
uint64_t
-DataExtractor::GetU64_unchecked (uint32_t *offset_ptr) const
+DataExtractor::GetU64_unchecked (offset_t *offset_ptr) const
{
- uint64_t val = (m_byte_order == lldb::endian::InlHostByteOrder()) ?
- ReadInt64 (m_start, *offset_ptr) :
- ReadSwapInt64 (m_start, *offset_ptr);
+ uint64_t val;
+ if (m_byte_order == lldb::endian::InlHostByteOrder())
+ val = ReadInt64 (m_start, *offset_ptr);
+ else
+ val = ReadSwapInt64 (m_start, *offset_ptr);
*offset_ptr += sizeof(val);
return val;
}
@@ -454,31 +459,30 @@ DataExtractor::GetU64_unchecked (uint32_
// in the buffer due to being out of bounds, or unsufficient data.
//----------------------------------------------------------------------
void *
-DataExtractor::GetU16 (uint32_t *offset_ptr, void *void_dst, uint32_t count) const
+DataExtractor::GetU16 (offset_t *offset_ptr, void *void_dst, uint32_t count) const
{
- uint16_t *dst = (uint16_t *)void_dst;
- const size_t value_size = sizeof(*dst);
- register uint32_t offset = *offset_ptr;
-
- if ((count > 0) && ValidOffsetForDataOfSize(offset, value_size * count) )
+ const size_t src_size = sizeof(uint16_t) * count;
+ const uint16_t *src = (const uint16_t *)GetData (offset_ptr, src_size);
+ if (src)
{
- uint16_t *value_ptr;
- uint16_t *end = dst + count;
if (m_byte_order != lldb::endian::InlHostByteOrder())
{
- for (value_ptr = dst; value_ptr < end; ++value_ptr, offset += value_size)
- *value_ptr = ReadSwapInt16 (m_start, offset);
+ uint16_t *dst_pos = (uint16_t *)void_dst;
+ uint16_t *dst_end = dst_pos + count;
+ const uint16_t *src_pos = src;
+ while (dst_pos < dst_end)
+ {
+ *dst_pos = ReadSwapInt16 (src_pos);
+ ++dst_pos;
+ ++src_pos;
+ }
}
else
{
- for (value_ptr = dst; value_ptr < end; ++value_ptr, offset += value_size)
- *value_ptr = ReadInt16 (m_start, offset);
+ memcpy (void_dst, src, src_size);
}
-
- // Advance the offset
- *offset_ptr = offset;
// Return a non-NULL pointer to the converted data as an indicator of success
- return dst;
+ return void_dst;
}
return NULL;
}
@@ -490,20 +494,16 @@ DataExtractor::GetU16 (uint32_t *offset_
// RETURNS the uint32_t that was extracted, or zero on failure.
//----------------------------------------------------------------------
uint32_t
-DataExtractor::GetU32 (uint32_t *offset_ptr) const
+DataExtractor::GetU32 (offset_t *offset_ptr) const
{
uint32_t val = 0;
- register uint32_t offset = *offset_ptr;
-
- if ( ValidOffsetForDataOfSize(offset, sizeof(val)) )
+ const uint32_t *data = (const uint32_t *)GetData (offset_ptr, sizeof(val));
+ if (data)
{
if (m_byte_order != lldb::endian::InlHostByteOrder())
- val = ReadSwapInt32 (m_start, offset);
+ val = ReadSwapInt32 (data);
else
- val = ReadInt32 (m_start, offset);
-
- // Advance the offset
- *offset_ptr += sizeof(val);
+ val = *data;
}
return val;
}
@@ -518,32 +518,30 @@ DataExtractor::GetU32 (uint32_t *offset_
// in the buffer due to being out of bounds, or unsufficient data.
//----------------------------------------------------------------------
void *
-DataExtractor::GetU32 (uint32_t *offset_ptr, void *void_dst, uint32_t count) const
+DataExtractor::GetU32 (offset_t *offset_ptr, void *void_dst, uint32_t count) const
{
- uint32_t *dst = (uint32_t *)void_dst;
- const size_t value_size = sizeof(*dst);
- register uint32_t offset = *offset_ptr;
-
- if ((count > 0) && ValidOffsetForDataOfSize(offset, value_size * count))
+ const size_t src_size = sizeof(uint32_t) * count;
+ const uint32_t *src = (const uint32_t *)GetData (offset_ptr, src_size);
+ if (src)
{
- uint32_t *value_ptr;
- uint32_t *end = dst + count;
if (m_byte_order != lldb::endian::InlHostByteOrder())
{
- for (value_ptr = dst; value_ptr < end; ++value_ptr, offset += value_size)
- *value_ptr = ReadSwapInt32 (m_start, offset);
-
+ uint32_t *dst_pos = (uint32_t *)void_dst;
+ uint32_t *dst_end = dst_pos + count;
+ const uint32_t *src_pos = src;
+ while (dst_pos < dst_end)
+ {
+ *dst_pos = ReadSwapInt32 (src_pos);
+ ++dst_pos;
+ ++src_pos;
+ }
}
else
{
- for (value_ptr = dst; value_ptr < end; ++value_ptr, offset += value_size)
- *value_ptr = ReadInt32 (m_start, offset);
+ memcpy (void_dst, src, src_size);
}
-
- // Advance the offset
- *offset_ptr = offset;
// Return a non-NULL pointer to the converted data as an indicator of success
- return dst;
+ return void_dst;
}
return NULL;
}
@@ -555,19 +553,16 @@ DataExtractor::GetU32 (uint32_t *offset_
// RETURNS the uint64_t that was extracted, or zero on failure.
//----------------------------------------------------------------------
uint64_t
-DataExtractor::GetU64 (uint32_t *offset_ptr) const
+DataExtractor::GetU64 (offset_t *offset_ptr) const
{
uint64_t val = 0;
- register uint32_t offset = *offset_ptr;
- if ( ValidOffsetForDataOfSize(offset, sizeof(val)) )
+ const uint64_t *data = (const uint64_t *)GetData (offset_ptr, sizeof(val));
+ if (data)
{
if (m_byte_order != lldb::endian::InlHostByteOrder())
- val = ReadSwapInt64 (m_start, offset);
+ val = ReadSwapInt64 (data);
else
- val = ReadInt64 (m_start, offset);
-
- // Advance the offset
- *offset_ptr += sizeof(val);
+ val = *data;
}
return val;
}
@@ -580,32 +575,30 @@ DataExtractor::GetU64 (uint32_t *offset_
// return false and leave the offset pointed to by offset_ptr unchanged.
//----------------------------------------------------------------------
void *
-DataExtractor::GetU64 (uint32_t *offset_ptr, void *void_dst, uint32_t count) const
+DataExtractor::GetU64 (offset_t *offset_ptr, void *void_dst, uint32_t count) const
{
- uint64_t *dst = (uint64_t *)void_dst;
- const size_t value_size = sizeof(uint64_t);
- register uint32_t offset = *offset_ptr;
-
- if ((count > 0) && ValidOffsetForDataOfSize(offset, value_size * count))
+ const size_t src_size = sizeof(uint64_t) * count;
+ const uint64_t *src = (const uint64_t *)GetData (offset_ptr, src_size);
+ if (src)
{
- uint64_t *value_ptr;
- uint64_t *end = dst + count;
if (m_byte_order != lldb::endian::InlHostByteOrder())
{
- for (value_ptr = dst; value_ptr < end; ++value_ptr, offset += value_size)
- *value_ptr = ReadSwapInt64 (m_start, offset);
-
+ uint64_t *dst_pos = (uint64_t *)void_dst;
+ uint64_t *dst_end = dst_pos + count;
+ const uint64_t *src_pos = src;
+ while (dst_pos < dst_end)
+ {
+ *dst_pos = ReadSwapInt64 (src_pos);
+ ++dst_pos;
+ ++src_pos;
+ }
}
else
{
- for (value_ptr = dst; value_ptr < end; ++value_ptr, offset += value_size)
- *value_ptr = ReadInt64 (m_start, offset);
+ memcpy (void_dst, src, src_size);
}
-
- // Advance the offset
- *offset_ptr = offset;
// Return a non-NULL pointer to the converted data as an indicator of success
- return dst;
+ return void_dst;
}
return NULL;
}
@@ -621,7 +614,7 @@ DataExtractor::GetU64 (uint32_t *offset_
// RETURNS the integer value that was extracted, or zero on failure.
//----------------------------------------------------------------------
uint32_t
-DataExtractor::GetMaxU32 (uint32_t *offset_ptr, uint32_t byte_size) const
+DataExtractor::GetMaxU32 (offset_t *offset_ptr, size_t byte_size) const
{
switch (byte_size)
{
@@ -629,7 +622,7 @@ DataExtractor::GetMaxU32 (uint32_t *offs
case 2: return GetU16(offset_ptr); break;
case 4: return GetU32(offset_ptr); break;
default:
- assert(!"GetMaxU32 unhandled case!");
+ assert("GetMaxU32 unhandled case!" == NULL);
break;
}
return 0;
@@ -646,7 +639,7 @@ DataExtractor::GetMaxU32 (uint32_t *offs
// RETURNS the integer value that was extracted, or zero on failure.
//----------------------------------------------------------------------
uint64_t
-DataExtractor::GetMaxU64 (uint32_t *offset_ptr, uint32_t size) const
+DataExtractor::GetMaxU64 (offset_t *offset_ptr, size_t size) const
{
switch (size)
{
@@ -655,14 +648,14 @@ DataExtractor::GetMaxU64 (uint32_t *offs
case 4: return GetU32(offset_ptr); break;
case 8: return GetU64(offset_ptr); break;
default:
- assert(!"GetMax64 unhandled case!");
+ assert("GetMax64 unhandled case!" == NULL);
break;
}
return 0;
}
uint64_t
-DataExtractor::GetMaxU64_unchecked (uint32_t *offset_ptr, uint32_t size) const
+DataExtractor::GetMaxU64_unchecked (offset_t *offset_ptr, size_t size) const
{
switch (size)
{
@@ -671,14 +664,14 @@ DataExtractor::GetMaxU64_unchecked (uint
case 4: return GetU32_unchecked (offset_ptr); break;
case 8: return GetU64_unchecked (offset_ptr); break;
default:
- assert(!"GetMax64 unhandled case!");
+ assert("GetMax64 unhandled case!" == NULL);
break;
}
return 0;
}
int64_t
-DataExtractor::GetMaxS64 (uint32_t *offset_ptr, uint32_t size) const
+DataExtractor::GetMaxS64 (offset_t *offset_ptr, size_t size) const
{
switch (size)
{
@@ -687,14 +680,14 @@ DataExtractor::GetMaxS64 (uint32_t *offs
case 4: return (int32_t)GetU32(offset_ptr); break;
case 8: return (int64_t)GetU64(offset_ptr); break;
default:
- assert(!"GetMax64 unhandled case!");
+ assert("GetMax64 unhandled case!" == NULL);
break;
}
return 0;
}
uint64_t
-DataExtractor::GetMaxU64Bitfield (uint32_t *offset_ptr, uint32_t size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset) const
+DataExtractor::GetMaxU64Bitfield (offset_t *offset_ptr, size_t size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset) const
{
uint64_t uval64 = GetMaxU64 (offset_ptr, size);
if (bitfield_bit_size > 0)
@@ -710,7 +703,7 @@ DataExtractor::GetMaxU64Bitfield (uint32
}
int64_t
-DataExtractor::GetMaxS64Bitfield (uint32_t *offset_ptr, uint32_t size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset) const
+DataExtractor::GetMaxS64Bitfield (offset_t *offset_ptr, size_t size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset) const
{
int64_t sval64 = GetMaxS64 (offset_ptr, size);
if (bitfield_bit_size > 0)
@@ -728,80 +721,74 @@ DataExtractor::GetMaxS64Bitfield (uint32
float
-DataExtractor::GetFloat (uint32_t *offset_ptr) const
+DataExtractor::GetFloat (offset_t *offset_ptr) const
{
typedef float float_type;
float_type val = 0.0;
- const uint8_t *src_data = PeekData (*offset_ptr, sizeof(float_type));
-
- if (src_data)
+ const size_t src_size = sizeof(float_type);
+ const float_type *src = (const float_type *)GetData (offset_ptr, src_size);
+ if (src)
{
if (m_byte_order != lldb::endian::InlHostByteOrder())
{
+ const uint8_t *src_data = (const uint8_t *)src;
uint8_t *dst_data = (uint8_t *)&val;
for (int i=0; i<sizeof(float_type); ++i)
dst_data[sizeof(float_type) - 1 - i] = src_data[i];
}
else
{
- ::memcpy (&val, src_data, sizeof (float_type));
+ val = *src;
}
-
- // Advance the offset
- *offset_ptr += sizeof(val);
}
return val;
}
double
-DataExtractor::GetDouble (uint32_t *offset_ptr) const
+DataExtractor::GetDouble (offset_t *offset_ptr) const
{
typedef double float_type;
float_type val = 0.0;
- const uint8_t *src_data = PeekData (*offset_ptr, sizeof(float_type));
-
- if (src_data)
+ const size_t src_size = sizeof(float_type);
+ const float_type *src = (const float_type *)GetData (offset_ptr, src_size);
+ if (src)
{
if (m_byte_order != lldb::endian::InlHostByteOrder())
{
+ const uint8_t *src_data = (const uint8_t *)src;
uint8_t *dst_data = (uint8_t *)&val;
for (int i=0; i<sizeof(float_type); ++i)
dst_data[sizeof(float_type) - 1 - i] = src_data[i];
}
else
{
- ::memcpy (&val, src_data, sizeof (float_type));
+ val = *src;
}
-
- // Advance the offset
- *offset_ptr += sizeof(val);
}
return val;
}
long double
-DataExtractor::GetLongDouble (uint32_t *offset_ptr) const
+DataExtractor::GetLongDouble (offset_t *offset_ptr) const
{
typedef long double float_type;
float_type val = 0.0;
- const uint8_t *src_data = PeekData (*offset_ptr, sizeof(float_type));
-
- if (src_data)
+ const size_t src_size = sizeof(float_type);
+ const float_type *src = (const float_type *)GetData (offset_ptr, src_size);
+ if (src)
{
if (m_byte_order != lldb::endian::InlHostByteOrder())
{
+ const uint8_t *src_data = (const uint8_t *)src;
uint8_t *dst_data = (uint8_t *)&val;
for (int i=0; i<sizeof(float_type); ++i)
dst_data[sizeof(float_type) - 1 - i] = src_data[i];
}
else
{
- ::memcpy (&val, src_data, sizeof (float_type));
+ val = *src;
}
-
- // Advance the offset
- *offset_ptr += sizeof(val);
}
return val;
}
@@ -816,13 +803,13 @@ DataExtractor::GetLongDouble (uint32_t *
// RETURNS the address that was extracted, or zero on failure.
//------------------------------------------------------------------
uint64_t
-DataExtractor::GetAddress (uint32_t *offset_ptr) const
+DataExtractor::GetAddress (offset_t *offset_ptr) const
{
return GetMaxU64 (offset_ptr, m_addr_size);
}
uint64_t
-DataExtractor::GetAddress_unchecked (uint32_t *offset_ptr) const
+DataExtractor::GetAddress_unchecked (offset_t *offset_ptr) const
{
return GetMaxU64_unchecked (offset_ptr, m_addr_size);
}
@@ -836,7 +823,7 @@ DataExtractor::GetAddress_unchecked (uin
// RETURNS the pointer that was extracted, or zero on failure.
//------------------------------------------------------------------
uint64_t
-DataExtractor::GetPointer (uint32_t *offset_ptr) const
+DataExtractor::GetPointer (offset_t *offset_ptr) const
{
return GetMaxU64 (offset_ptr, m_addr_size);
}
@@ -849,7 +836,7 @@ DataExtractor::GetPointer (uint32_t *off
//----------------------------------------------------------------------
uint64_t
-DataExtractor::GetGNUEHPointer (uint32_t *offset_ptr, uint32_t eh_ptr_enc, lldb::addr_t pc_rel_addr, lldb::addr_t text_addr, lldb::addr_t data_addr)//, BSDRelocs *data_relocs) const
+DataExtractor::GetGNUEHPointer (offset_t *offset_ptr, uint32_t eh_ptr_enc, lldb::addr_t pc_rel_addr, lldb::addr_t text_addr, lldb::addr_t data_addr)//, BSDRelocs *data_relocs) const
{
if (eh_ptr_enc == DW_EH_PE_omit)
return ULLONG_MAX; // Value isn't in the buffer...
@@ -948,7 +935,7 @@ DataExtractor::GetGNUEHPointer (uint32_t
}
size_t
-DataExtractor::ExtractBytes (uint32_t offset, uint32_t length, ByteOrder dst_byte_order, void *dst) const
+DataExtractor::ExtractBytes (offset_t offset, offset_t length, ByteOrder dst_byte_order, void *dst) const
{
const uint8_t *src = PeekData (offset, length);
if (src)
@@ -964,52 +951,18 @@ DataExtractor::ExtractBytes (uint32_t of
}
return 0;
}
-//----------------------------------------------------------------------
-// Peeks at bytes in the contained data.
-//
-// Returns a valid pointer to bytes if "offset" is a valid offset in
-// and there are "length" bytes available, else NULL is returned.
-//----------------------------------------------------------------------
-const uint8_t*
-DataExtractor::PeekData (uint32_t offset, uint32_t length) const
-{
- if ( length > 0 && ValidOffsetForDataOfSize(offset, length) )
- return m_start + offset;
- return NULL;
-}
-
-//----------------------------------------------------------------------
-// Returns a pointer to a bytes in this object's data at the offset
-// pointed to by "offset_ptr". If "length" is zero or too large,
-// then the offset pointed to by "offset_ptr" will not be updated
-// and NULL will be returned.
-//
-// Returns a pointer to the data if the offset and length are valid,
-// or NULL otherwise.
-//----------------------------------------------------------------------
-const void*
-DataExtractor::GetData (uint32_t *offset_ptr, uint32_t length) const
-{
- const uint8_t* bytes = NULL;
- register uint32_t offset = *offset_ptr;
- if ( length > 0 && ValidOffsetForDataOfSize(offset, length) )
- {
- bytes = m_start + offset;
- *offset_ptr = offset + length;
- }
- return bytes;
-}
// Extract data and swap if needed when doing the copy
-uint32_t
-DataExtractor::CopyByteOrderedData (uint32_t src_offset,
- uint32_t src_len,
+lldb::offset_t
+DataExtractor::CopyByteOrderedData (offset_t src_offset,
+ offset_t src_len,
void *dst_void_ptr,
- uint32_t dst_len,
+ offset_t dst_len,
ByteOrder dst_byte_order) const
{
// Validate the source info
- assert (ValidOffsetForDataOfSize(src_offset, src_len));
+ if (!ValidOffsetForDataOfSize(src_offset, src_len))
+ assert (ValidOffsetForDataOfSize(src_offset, src_len));
assert (src_len > 0);
assert (m_byte_order == eByteOrderBig || m_byte_order == eByteOrderLittle);
@@ -1033,7 +986,7 @@ DataExtractor::CopyByteOrderedData (uint
// We are copying the entire value from src into dst.
// Calculate how many, if any, zeroes we need for the most
// significant bytes if "dst_len" is greater than "src_len"...
- const uint32_t num_zeroes = dst_len - src_len;
+ const size_t num_zeroes = dst_len - src_len;
if (dst_byte_order == eByteOrderBig)
{
// Big endian, so we lead with zeroes...
@@ -1126,22 +1079,31 @@ DataExtractor::CopyByteOrderedData (uint
// updated.
//----------------------------------------------------------------------
const char*
-DataExtractor::GetCStr (uint32_t *offset_ptr) const
+DataExtractor::GetCStr (offset_t *offset_ptr) const
{
- const char *s = NULL;
- if ( m_start < m_end )
+ const char *cstr = (const char *)PeekData (*offset_ptr, 1);
+ if (cstr)
{
- s = (char*)m_start + *offset_ptr;
-
- size_t length = strlen(s) + 1;
-
- if (!ValidOffsetForDataOfSize(*offset_ptr, length))
- return NULL;
-
- // Advance the offset
- *offset_ptr += length;
+ const char *cstr_end = cstr;
+ const char *end = (const char *)m_end;
+ while (cstr_end < end && *cstr_end)
+ ++cstr_end;
+
+ // Now we are either at the end of the data or we point to the
+ // NULL C string terminator with cstr_end...
+ if (*cstr_end == '\0')
+ {
+ // Advance the offset with one extra byte for the NULL terminator
+ *offset_ptr += (cstr_end - cstr + 1);
+ return cstr;
+ }
+
+ // We reached the end of the data without finding a NULL C string
+ // terminator. Fall through and return NULL otherwise anyone that
+ // would have used the result as a C string can wonder into
+ // unknown memory...
}
- return s;
+ return NULL;
}
//------------------------------------------------------------------
@@ -1153,11 +1115,9 @@ DataExtractor::GetCStr (uint32_t *offset
// this object's data, else NULL is returned.
//------------------------------------------------------------------
const char *
-DataExtractor::PeekCStr (uint32_t offset) const
+DataExtractor::PeekCStr (offset_t offset) const
{
- if (ValidOffset (offset))
- return (const char*)m_start + offset;
- return NULL;
+ return (const char *)PeekData (offset, 1);
}
//----------------------------------------------------------------------
@@ -1169,9 +1129,9 @@ DataExtractor::PeekCStr (uint32_t offset
// Returned the extracted integer value.
//----------------------------------------------------------------------
uint64_t
-DataExtractor::GetULEB128 (uint32_t *offset_ptr) const
+DataExtractor::GetULEB128 (offset_t *offset_ptr) const
{
- const uint8_t *src = m_start + *offset_ptr;
+ const uint8_t *src = (const uint8_t *)PeekData (*offset_ptr, 1);
const uint8_t *end = m_end;
if (src < end)
@@ -1190,7 +1150,7 @@ DataExtractor::GetULEB128 (uint32_t *off
shift += 7;
}
}
- *offset_ptr = (uint32_t)(src - m_start);
+ *offset_ptr = src - m_start;
return result;
}
@@ -1206,20 +1166,21 @@ DataExtractor::GetULEB128 (uint32_t *off
// Returned the extracted integer value.
//----------------------------------------------------------------------
int64_t
-DataExtractor::GetSLEB128 (uint32_t *offset_ptr) const
+DataExtractor::GetSLEB128 (offset_t *offset_ptr) const
{
- int64_t result = 0;
-
- if ( m_start < m_end )
+ const uint8_t *src = (const uint8_t *)PeekData (*offset_ptr, 1);
+ const uint8_t *end = m_end;
+
+ if (src < end)
{
+ int64_t result = 0;
int shift = 0;
- int size = sizeof (uint32_t) * 8;
- const uint8_t *src = m_start + *offset_ptr;
+ int size = sizeof (int64_t) * 8;
uint8_t byte = 0;
int bytecount = 0;
- while (src < m_end)
+ while (src < end)
{
bytecount++;
byte = *src++;
@@ -1234,8 +1195,9 @@ DataExtractor::GetSLEB128 (uint32_t *off
result |= - (1 << shift);
*offset_ptr += bytecount;
+ return result;
}
- return result;
+ return 0;
}
//----------------------------------------------------------------------
@@ -1247,27 +1209,27 @@ DataExtractor::GetSLEB128 (uint32_t *off
// Returns the number of bytes consumed during the extraction.
//----------------------------------------------------------------------
uint32_t
-DataExtractor::Skip_LEB128 (uint32_t *offset_ptr) const
+DataExtractor::Skip_LEB128 (offset_t *offset_ptr) const
{
uint32_t bytes_consumed = 0;
- if ( m_start < m_end )
+ const uint8_t *src = (const uint8_t *)PeekData (*offset_ptr, 1);
+ const uint8_t *end = m_end;
+
+ if (src < end)
{
- const uint8_t *start = m_start + *offset_ptr;
- const uint8_t *src = start;
-
- while ((src < m_end) && (*src++ & 0x80))
+ const uint8_t *src_pos = src;
+ while ((src_pos < end) && (*src_pos++ & 0x80))
++bytes_consumed;
-
- *offset_ptr += src - start;
+ *offset_ptr += src_pos - src;
}
return bytes_consumed;
}
-static uint32_t
-DumpAPInt (Stream *s, const DataExtractor &data, uint32_t offset, uint32_t byte_size, bool is_signed, unsigned radix)
+static lldb::offset_t
+DumpAPInt (Stream *s, const DataExtractor &data, lldb::offset_t offset, lldb::offset_t byte_size, bool is_signed, unsigned radix)
{
llvm::SmallVector<uint64_t, 2> uint64_array;
- uint32_t bytes_left = byte_size;
+ lldb::offset_t bytes_left = byte_size;
uint64_t u64;
const lldb::ByteOrder byte_order = data.GetByteOrder();
if (byte_order == lldb::eByteOrderLittle)
@@ -1281,7 +1243,7 @@ DumpAPInt (Stream *s, const DataExtracto
}
else
{
- u64 = data.GetMaxU64(&offset, bytes_left);
+ u64 = data.GetMaxU64(&offset, (uint32_t)bytes_left);
bytes_left = 0;
}
uint64_array.push_back(u64);
@@ -1289,8 +1251,8 @@ DumpAPInt (Stream *s, const DataExtracto
}
else if (byte_order == lldb::eByteOrderBig)
{
- uint32_t be_offset = offset + byte_size;
- uint32_t temp_offset;
+ lldb::offset_t be_offset = offset + byte_size;
+ lldb::offset_t temp_offset;
while (bytes_left > 0)
{
if (bytes_left >= 8)
@@ -1304,7 +1266,7 @@ DumpAPInt (Stream *s, const DataExtracto
{
be_offset -= bytes_left;
temp_offset = be_offset;
- u64 = data.GetMaxU64(&temp_offset, bytes_left);
+ u64 = data.GetMaxU64(&temp_offset, (uint32_t)bytes_left);
bytes_left = 0;
}
uint64_array.push_back(u64);
@@ -1331,13 +1293,13 @@ DumpAPInt (Stream *s, const DataExtracto
return offset;
}
-uint32_t
+lldb::offset_t
DataExtractor::Dump (Stream *s,
- uint32_t start_offset,
+ offset_t start_offset,
lldb::Format item_format,
- uint32_t item_byte_size,
- uint32_t item_count,
- uint32_t num_per_line,
+ size_t item_byte_size,
+ size_t item_count,
+ size_t num_per_line,
uint64_t base_addr,
uint32_t item_bit_size, // If zero, this is not a bitfield value, if non-zero, the value is a bitfield
uint32_t item_bit_offset, // If "item_bit_size" is non-zero, this is the shift amount to apply to a bitfield
@@ -1352,7 +1314,7 @@ DataExtractor::Dump (Stream *s,
item_byte_size = s->GetAddressByteSize();
}
- uint32_t offset = start_offset;
+ offset_t offset = start_offset;
if (item_format == eFormatInstruction)
{
@@ -1361,17 +1323,23 @@ DataExtractor::Dump (Stream *s,
target_sp = exe_scope->CalculateTarget();
if (target_sp)
{
- DisassemblerSP disassembler_sp (Disassembler::FindPlugin(target_sp->GetArchitecture(), NULL));
+ DisassemblerSP disassembler_sp (Disassembler::FindPlugin(target_sp->GetArchitecture(), NULL, NULL));
if (disassembler_sp)
{
lldb::addr_t addr = base_addr + start_offset;
lldb_private::Address so_addr;
- if (!target_sp->GetSectionLoadList().ResolveLoadAddress(addr, so_addr))
+ bool data_from_file = true;
+ if (target_sp->GetSectionLoadList().ResolveLoadAddress(addr, so_addr))
+ {
+ data_from_file = false;
+ }
+ else
{
- so_addr.SetRawAddress(addr);
+ if (target_sp->GetSectionLoadList().IsEmpty() || !target_sp->GetImages().ResolveFileAddress(addr, so_addr))
+ so_addr.SetRawAddress(addr);
}
- size_t bytes_consumed = disassembler_sp->DecodeInstructions (so_addr, *this, start_offset, item_count, false);
+ size_t bytes_consumed = disassembler_sp->DecodeInstructions (so_addr, *this, start_offset, item_count, false, data_from_file);
if (bytes_consumed)
{
@@ -1393,7 +1361,7 @@ DataExtractor::Dump (Stream *s,
if ((item_format == eFormatOSType || item_format == eFormatAddressInfo) && item_byte_size > 8)
item_format = eFormatHex;
- uint32_t line_start_offset = start_offset;
+ lldb::offset_t line_start_offset = start_offset;
for (uint32_t count = 0; ValidOffset(offset) && count < item_count; ++count)
{
if ((count % num_per_line) == 0)
@@ -1402,8 +1370,8 @@ DataExtractor::Dump (Stream *s,
{
if (item_format == eFormatBytesWithASCII && offset > line_start_offset)
{
- s->Printf("%*s", (num_per_line - (offset - line_start_offset)) * 3 + 2, "");
- Dump(s, line_start_offset, eFormatCharPrintable, 1, offset - line_start_offset, UINT32_MAX, LLDB_INVALID_ADDRESS, 0, 0);
+ s->Printf("%*s", static_cast<int>((num_per_line - (offset - line_start_offset)) * 3 + 2), "");
+ Dump(s, line_start_offset, eFormatCharPrintable, 1, offset - line_start_offset, LLDB_INVALID_OFFSET, LLDB_INVALID_ADDRESS, 0, 0);
}
s->EOL();
}
@@ -1428,7 +1396,7 @@ DataExtractor::Dump (Stream *s,
s->Printf ("%s", GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size, item_bit_offset) ? "true" : "false");
else
{
- s->Printf("error: unsupported byte size (%u) for boolean format", item_byte_size);
+ s->Printf("error: unsupported byte size (%zu) for boolean format", item_byte_size);
return offset;
}
break;
@@ -1584,7 +1552,7 @@ DataExtractor::Dump (Stream *s,
if (!cstr)
{
s->Printf("NULL");
- offset = UINT32_MAX;
+ offset = LLDB_INVALID_OFFSET;
}
else
{
@@ -1628,7 +1596,7 @@ DataExtractor::Dump (Stream *s,
case eFormatComplexInteger:
{
- uint32_t complex_int_byte_size = item_byte_size / 2;
+ size_t complex_int_byte_size = item_byte_size / 2;
if (complex_int_byte_size <= 8)
{
@@ -1637,7 +1605,7 @@ DataExtractor::Dump (Stream *s,
}
else
{
- s->Printf("error: unsupported byte size (%u) for complex integer format", item_byte_size);
+ s->Printf("error: unsupported byte size (%zu) for complex integer format", item_byte_size);
return offset;
}
}
@@ -1669,7 +1637,7 @@ DataExtractor::Dump (Stream *s,
}
else
{
- s->Printf("error: unsupported byte size (%u) for complex float format", item_byte_size);
+ s->Printf("error: unsupported byte size (%zu) for complex float format", item_byte_size);
return offset;
}
break;
@@ -1682,7 +1650,7 @@ DataExtractor::Dump (Stream *s,
bool wantsuppercase = (item_format == eFormatHexUppercase);
if (item_byte_size <= 8)
{
- s->Printf(wantsuppercase ? "0x%*.*" PRIX64 : "0x%*.*" PRIx64, 2 * item_byte_size, 2 * item_byte_size, GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size, item_bit_offset));
+ s->Printf(wantsuppercase ? "0x%*.*" PRIX64 : "0x%*.*" PRIx64, (int)(2 * item_byte_size), (int)(2 * item_byte_size), GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size, item_bit_offset));
}
else
{
@@ -1727,7 +1695,7 @@ DataExtractor::Dump (Stream *s,
}
else
{
- s->Printf("error: unsupported byte size (%u) for float format", item_byte_size);
+ s->Printf("error: unsupported byte size (%zu) for float format", item_byte_size);
return offset;
}
ss.flush();
@@ -1746,7 +1714,7 @@ DataExtractor::Dump (Stream *s,
case eFormatAddressInfo:
{
addr_t addr = GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size, item_bit_offset);
- s->Printf("0x%*.*" PRIx64, 2 * item_byte_size, 2 * item_byte_size, addr);
+ s->Printf("0x%*.*" PRIx64, (int)(2 * item_byte_size), (int)(2 * item_byte_size), addr);
if (exe_scope)
{
TargetSP target_sp (exe_scope->CalculateTarget());
@@ -1790,7 +1758,7 @@ DataExtractor::Dump (Stream *s,
}
else
{
- s->Printf("error: unsupported byte size (%u) for hex float format", item_byte_size);
+ s->Printf("error: unsupported byte size (%zu) for hex float format", item_byte_size);
return offset;
}
break;
@@ -1848,7 +1816,7 @@ DataExtractor::Dump (Stream *s,
case eFormatVectorOfUInt64:
s->PutChar('{');
- offset = Dump (s, offset, eFormatHex, sizeof(uint32_t), item_byte_size / sizeof(uint32_t), item_byte_size / sizeof(uint32_t), LLDB_INVALID_ADDRESS, 0, 0);
+ offset = Dump (s, offset, eFormatHex, sizeof(uint64_t), item_byte_size / sizeof(uint64_t), item_byte_size / sizeof(uint64_t), LLDB_INVALID_ADDRESS, 0, 0);
s->PutChar('}');
break;
@@ -1874,8 +1842,8 @@ DataExtractor::Dump (Stream *s,
if (item_format == eFormatBytesWithASCII && offset > line_start_offset)
{
- s->Printf("%*s", (num_per_line - (offset - line_start_offset)) * 3 + 2, "");
- Dump(s, line_start_offset, eFormatCharPrintable, 1, offset - line_start_offset, UINT32_MAX, LLDB_INVALID_ADDRESS, 0, 0);
+ s->Printf("%*s", static_cast<int>((num_per_line - (offset - line_start_offset)) * 3 + 2), "");
+ Dump(s, line_start_offset, eFormatCharPrintable, 1, offset - line_start_offset, LLDB_INVALID_OFFSET, LLDB_INVALID_ADDRESS, 0, 0);
}
return offset; // Return the offset at which we ended up
}
@@ -1892,12 +1860,12 @@ DataExtractor::Dump (Stream *s,
// string will be used for the supplied "type". If the stream "s"
// is NULL, then the output will be send to Log().
//----------------------------------------------------------------------
-uint32_t
+lldb::offset_t
DataExtractor::PutToLog
(
Log *log,
- uint32_t start_offset,
- uint32_t length,
+ offset_t start_offset,
+ offset_t length,
uint64_t base_addr,
uint32_t num_per_line,
DataExtractor::Type type,
@@ -1907,8 +1875,8 @@ DataExtractor::PutToLog
if (log == NULL)
return start_offset;
- uint32_t offset;
- uint32_t end_offset;
+ offset_t offset;
+ offset_t end_offset;
uint32_t count;
StreamString sstr;
for (offset = start_offset, end_offset = offset + length, count = 0; ValidOffset(offset) && offset < end_offset; ++count)
@@ -1956,7 +1924,7 @@ DataExtractor::PutToLog
// Dump out a UUID starting at 'offset' bytes into the buffer
//----------------------------------------------------------------------
void
-DataExtractor::DumpUUID (Stream *s, uint32_t offset) const
+DataExtractor::DumpUUID (Stream *s, offset_t offset) const
{
if (s)
{
@@ -1968,7 +1936,7 @@ DataExtractor::DumpUUID (Stream *s, uint
}
else
{
- s->Printf("<not enough data for UUID at offset 0x%8.8x>", offset);
+ s->Printf("<not enough data for UUID at offset 0x%8.8" PRIx64 ">", offset);
}
}
}
@@ -2039,7 +2007,7 @@ DataExtractor::Append(DataExtractor& rhs
}
bool
-DataExtractor::Append(void* buf, uint32_t length)
+DataExtractor::Append(void* buf, offset_t length)
{
if (buf == NULL)
return false;
Removed: lldb/branches/windows/source/Core/DataVisualization.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/DataVisualization.cpp?rev=179678&view=auto
==============================================================================
--- lldb/branches/windows/source/Core/DataVisualization.cpp (original)
+++ lldb/branches/windows/source/Core/DataVisualization.cpp (removed)
@@ -1,279 +0,0 @@
-//===-- DataVisualization.cpp ---------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "lldb/lldb-python.h"
-
-#include "lldb/Core/DataVisualization.h"
-
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
-
-#include "lldb/Core/Debugger.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-static FormatManager&
-GetFormatManager()
-{
- static FormatManager g_format_manager;
- return g_format_manager;
-}
-
-void
-DataVisualization::ForceUpdate ()
-{
- GetFormatManager().Changed();
-}
-
-uint32_t
-DataVisualization::GetCurrentRevision ()
-{
- return GetFormatManager().GetCurrentRevision();
-}
-
-lldb::TypeFormatImplSP
-DataVisualization::ValueFormats::GetFormat (ValueObject& valobj, lldb::DynamicValueType use_dynamic)
-{
- lldb::TypeFormatImplSP entry;
- GetFormatManager().GetValueNavigator().Get(valobj, entry, use_dynamic);
- return entry;
-}
-
-lldb::TypeFormatImplSP
-DataVisualization::ValueFormats::GetFormat (const ConstString &type)
-{
- lldb::TypeFormatImplSP entry;
- GetFormatManager().GetValueNavigator().Get(type, entry);
- return entry;
-}
-
-void
-DataVisualization::ValueFormats::Add (const ConstString &type, const lldb::TypeFormatImplSP &entry)
-{
- GetFormatManager().GetValueNavigator().Add(FormatManager::GetValidTypeName(type),entry);
-}
-
-bool
-DataVisualization::ValueFormats::Delete (const ConstString &type)
-{
- return GetFormatManager().GetValueNavigator().Delete(type);
-}
-
-void
-DataVisualization::ValueFormats::Clear ()
-{
- GetFormatManager().GetValueNavigator().Clear();
-}
-
-void
-DataVisualization::ValueFormats::LoopThrough (TypeFormatImpl::ValueCallback callback, void* callback_baton)
-{
- GetFormatManager().GetValueNavigator().LoopThrough(callback, callback_baton);
-}
-
-uint32_t
-DataVisualization::ValueFormats::GetCount ()
-{
- return GetFormatManager().GetValueNavigator().GetCount();
-}
-
-lldb::TypeNameSpecifierImplSP
-DataVisualization::ValueFormats::GetTypeNameSpecifierForFormatAtIndex (uint32_t index)
-{
- return GetFormatManager().GetValueNavigator().GetTypeNameSpecifierAtIndex(index);
-}
-
-lldb::TypeFormatImplSP
-DataVisualization::ValueFormats::GetFormatAtIndex (uint32_t index)
-{
- return GetFormatManager().GetValueNavigator().GetAtIndex(index);
-}
-
-lldb::TypeSummaryImplSP
-DataVisualization::GetSummaryFormat (ValueObject& valobj,
- lldb::DynamicValueType use_dynamic)
-{
- return GetFormatManager().GetSummaryFormat(valobj, use_dynamic);
-}
-
-lldb::TypeSummaryImplSP
-DataVisualization::GetSummaryForType (lldb::TypeNameSpecifierImplSP type_sp)
-{
- return GetFormatManager().GetSummaryForType(type_sp);
-}
-
-#ifndef LLDB_DISABLE_PYTHON
-lldb::SyntheticChildrenSP
-DataVisualization::GetSyntheticChildren (ValueObject& valobj,
- lldb::DynamicValueType use_dynamic)
-{
- return GetFormatManager().GetSyntheticChildren(valobj, use_dynamic);
-}
-#endif
-
-#ifndef LLDB_DISABLE_PYTHON
-lldb::SyntheticChildrenSP
-DataVisualization::GetSyntheticChildrenForType (lldb::TypeNameSpecifierImplSP type_sp)
-{
- return GetFormatManager().GetSyntheticChildrenForType(type_sp);
-}
-#endif
-
-lldb::TypeFilterImplSP
-DataVisualization::GetFilterForType (lldb::TypeNameSpecifierImplSP type_sp)
-{
- return GetFormatManager().GetFilterForType(type_sp);
-}
-
-#ifndef LLDB_DISABLE_PYTHON
-lldb::TypeSyntheticImplSP
-DataVisualization::GetSyntheticForType (lldb::TypeNameSpecifierImplSP type_sp)
-{
- return GetFormatManager().GetSyntheticForType(type_sp);
-}
-#endif
-
-bool
-DataVisualization::AnyMatches (ConstString type_name,
- TypeCategoryImpl::FormatCategoryItems items,
- bool only_enabled,
- const char** matching_category,
- TypeCategoryImpl::FormatCategoryItems* matching_type)
-{
- return GetFormatManager().AnyMatches(type_name,
- items,
- only_enabled,
- matching_category,
- matching_type);
-}
-
-bool
-DataVisualization::Categories::GetCategory (const ConstString &category, lldb::TypeCategoryImplSP &entry,
- bool allow_create)
-{
- entry = GetFormatManager().GetCategory(category, allow_create);
- return (entry.get() != NULL);
-}
-
-void
-DataVisualization::Categories::Add (const ConstString &category)
-{
- GetFormatManager().GetCategory(category);
-}
-
-bool
-DataVisualization::Categories::Delete (const ConstString &category)
-{
- GetFormatManager().DisableCategory(category);
- return GetFormatManager().DeleteCategory(category);
-}
-
-void
-DataVisualization::Categories::Clear ()
-{
- GetFormatManager().ClearCategories();
-}
-
-void
-DataVisualization::Categories::Clear (const ConstString &category)
-{
- GetFormatManager().GetCategory(category)->Clear(eFormatCategoryItemSummary | eFormatCategoryItemRegexSummary);
-}
-
-void
-DataVisualization::Categories::Enable (const ConstString& category,
- CategoryMap::Position pos)
-{
- if (GetFormatManager().GetCategory(category)->IsEnabled())
- GetFormatManager().DisableCategory(category);
- GetFormatManager().EnableCategory(category, pos);
-}
-
-void
-DataVisualization::Categories::Disable (const ConstString& category)
-{
- if (GetFormatManager().GetCategory(category)->IsEnabled() == true)
- GetFormatManager().DisableCategory(category);
-}
-
-void
-DataVisualization::Categories::Enable (const lldb::TypeCategoryImplSP& category,
- CategoryMap::Position pos)
-{
- if (category.get())
- {
- if (category->IsEnabled())
- GetFormatManager().DisableCategory(category);
- GetFormatManager().EnableCategory(category, pos);
- }
-}
-
-void
-DataVisualization::Categories::Disable (const lldb::TypeCategoryImplSP& category)
-{
- if (category.get() && category->IsEnabled() == true)
- GetFormatManager().DisableCategory(category);
-}
-
-void
-DataVisualization::Categories::LoopThrough (FormatManager::CategoryCallback callback, void* callback_baton)
-{
- GetFormatManager().LoopThroughCategories(callback, callback_baton);
-}
-
-uint32_t
-DataVisualization::Categories::GetCount ()
-{
- return GetFormatManager().GetCategoriesCount();
-}
-
-lldb::TypeCategoryImplSP
-DataVisualization::Categories::GetCategoryAtIndex (uint32_t index)
-{
- return GetFormatManager().GetCategoryAtIndex(index);
-}
-
-bool
-DataVisualization::NamedSummaryFormats::GetSummaryFormat (const ConstString &type, lldb::TypeSummaryImplSP &entry)
-{
- return GetFormatManager().GetNamedSummaryNavigator().Get(type,entry);
-}
-
-void
-DataVisualization::NamedSummaryFormats::Add (const ConstString &type, const lldb::TypeSummaryImplSP &entry)
-{
- GetFormatManager().GetNamedSummaryNavigator().Add(FormatManager::GetValidTypeName(type),entry);
-}
-
-bool
-DataVisualization::NamedSummaryFormats::Delete (const ConstString &type)
-{
- return GetFormatManager().GetNamedSummaryNavigator().Delete(type);
-}
-
-void
-DataVisualization::NamedSummaryFormats::Clear ()
-{
- GetFormatManager().GetNamedSummaryNavigator().Clear();
-}
-
-void
-DataVisualization::NamedSummaryFormats::LoopThrough (TypeSummaryImpl::SummaryCallback callback, void* callback_baton)
-{
- GetFormatManager().GetNamedSummaryNavigator().LoopThrough(callback, callback_baton);
-}
-
-uint32_t
-DataVisualization::NamedSummaryFormats::GetCount ()
-{
- return GetFormatManager().GetNamedSummaryNavigator().GetCount();
-}
Modified: lldb/branches/windows/source/Core/Debugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/Debugger.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/Debugger.cpp (original)
+++ lldb/branches/windows/source/Core/Debugger.cpp Wed Apr 17 03:38:48 2013
@@ -20,8 +20,6 @@
#include "lldb/lldb-private.h"
#include "lldb/Core/ConnectionFileDescriptor.h"
-#include "lldb/Core/DataVisualization.h"
-#include "lldb/Core/FormatManager.h"
#include "lldb/Core/InputReader.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
@@ -33,6 +31,8 @@
#include "lldb/Core/Timer.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectVariable.h"
+#include "lldb/DataFormatters/DataVisualization.h"
+#include "lldb/DataFormatters/FormatManager.h"
#include "lldb/Host/DynamicLibrary.h"
#include "lldb/Host/Terminal.h"
#include "lldb/Interpreter/CommandInterpreter.h"
@@ -102,6 +102,8 @@ g_language_enumerators[] =
"{, ${frame.pc}}"\
MODULE_WITH_FUNC\
FILE_AND_LINE\
+ "{, name = '${thread.name}}"\
+ "{, queue = '${thread.queue}}"\
"{, stop reason = ${thread.stop-reason}}"\
"{\\nReturn value: ${thread.return-value}}"\
"\\n"
@@ -554,7 +556,7 @@ Debugger::Debugger (lldb::LogOutputCallb
m_target_list (*this),
m_platform_list (),
m_listener ("lldb.Debugger"),
- m_source_manager(*this),
+ m_source_manager_ap(),
m_source_file_cache(),
m_command_interpreter_ap (new CommandInterpreter (*this, eScriptLanguageDefault, false)),
m_input_reader_stack (),
@@ -607,10 +609,7 @@ Debugger::Clear()
{
ProcessSP process_sp (target_sp->GetProcessSP());
if (process_sp)
- {
- if (process_sp->GetShouldDetach())
- process_sp->Detach();
- }
+ process_sp->Finalize();
target_sp->Destroy();
}
}
@@ -999,7 +998,7 @@ Debugger::GetAsyncErrorStream ()
CommandInterpreter::eBroadcastBitAsynchronousErrorData));
}
-uint32_t
+size_t
Debugger::GetNumDebuggers()
{
if (g_shared_debugger_refcount > 0)
@@ -1011,7 +1010,7 @@ Debugger::GetNumDebuggers()
}
lldb::DebuggerSP
-Debugger::GetDebuggerAtIndex (uint32_t index)
+Debugger::GetDebuggerAtIndex (size_t index)
{
DebuggerSP debugger_sp;
@@ -1120,7 +1119,7 @@ ScanFormatDescriptor (const char* var_na
Format* custom_format,
ValueObject::ValueObjectRepresentationStyle* val_obj_display)
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
*percent_position = ::strchr(var_name_begin,'%');
if (!*percent_position || *percent_position > var_name_end)
{
@@ -1187,7 +1186,7 @@ ScanBracketedRange (const char* var_name
int64_t* index_lower,
int64_t* index_higher)
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
*open_bracket_position = ::strchr(var_name_begin,'[');
if (*open_bracket_position && *open_bracket_position < var_name_final)
{
@@ -1228,7 +1227,7 @@ ScanBracketedRange (const char* var_name
{
if (log)
log->Printf("[ScanBracketedRange] swapping indices");
- int temp = *index_lower;
+ int64_t temp = *index_lower;
*index_lower = *index_higher;
*index_higher = temp;
}
@@ -1240,22 +1239,22 @@ ScanBracketedRange (const char* var_name
static ValueObjectSP
ExpandIndexedExpression (ValueObject* valobj,
- uint32_t index,
+ size_t index,
StackFrame* frame,
bool deref_pointer)
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
const char* ptr_deref_format = "[%d]";
- std::auto_ptr<char> ptr_deref_buffer(new char[10]);
- ::sprintf(ptr_deref_buffer.get(), ptr_deref_format, index);
+ std::string ptr_deref_buffer(10,0);
+ ::sprintf(&ptr_deref_buffer[0], ptr_deref_format, index);
if (log)
- log->Printf("[ExpandIndexedExpression] name to deref: %s",ptr_deref_buffer.get());
+ log->Printf("[ExpandIndexedExpression] name to deref: %s",ptr_deref_buffer.c_str());
const char* first_unparsed;
ValueObject::GetValueForExpressionPathOptions options;
ValueObject::ExpressionPathEndResultType final_value_type;
ValueObject::ExpressionPathScanEndReason reason_to_stop;
ValueObject::ExpressionPathAftermath what_next = (deref_pointer ? ValueObject::eExpressionPathAftermathDereference : ValueObject::eExpressionPathAftermathNothing);
- ValueObjectSP item = valobj->GetValueForExpressionPath (ptr_deref_buffer.get(),
+ ValueObjectSP item = valobj->GetValueForExpressionPath (ptr_deref_buffer.c_str(),
&first_unparsed,
&reason_to_stop,
&final_value_type,
@@ -1293,7 +1292,7 @@ Debugger::FormatPrompt
ValueObject* realvalobj = NULL; // makes it super-easy to parse pointers
bool success = true;
const char *p;
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
for (p = format; *p != '\0'; ++p)
{
if (realvalobj)
@@ -1481,15 +1480,14 @@ Debugger::FormatPrompt
&index_higher);
Error error;
-
- std::auto_ptr<char> expr_path(new char[var_name_final-var_name_begin-1]);
- ::memset(expr_path.get(), 0, var_name_final-var_name_begin-1);
- memcpy(expr_path.get(), var_name_begin+3,var_name_final-var_name_begin-3);
-
+
+ std::string expr_path(var_name_final-var_name_begin-1,0);
+ memcpy(&expr_path[0], var_name_begin+3,var_name_final-var_name_begin-3);
+
if (log)
- log->Printf("[Debugger::FormatPrompt] symbol to expand: %s",expr_path.get());
+ log->Printf("[Debugger::FormatPrompt] symbol to expand: %s",expr_path.c_str());
- target = valobj->GetValueForExpressionPath(expr_path.get(),
+ target = valobj->GetValueForExpressionPath(expr_path.c_str(),
&first_unparsed,
&reason_to_stop,
&final_value_type,
@@ -1561,8 +1559,7 @@ Debugger::FormatPrompt
if (log)
log->Printf("[Debugger::FormatPrompt] I am into array || pointer && !range");
- if (target->HasSpecialPrintableRepresentation(val_obj_display,
- custom_format))
+ if (target->HasSpecialPrintableRepresentation(val_obj_display, custom_format))
{
// try to use the special cases
var_success = target->DumpPrintableRepresentation(str_temp,
@@ -1572,9 +1569,7 @@ Debugger::FormatPrompt
log->Printf("[Debugger::FormatPrompt] special cases did%s match", var_success ? "" : "n't");
// should not happen
- if (!var_success)
- s << "<invalid usage of pointer value as object>";
- else
+ if (var_success)
s << str_temp.GetData();
var_success = true;
break;
@@ -1592,10 +1587,6 @@ Debugger::FormatPrompt
custom_format,
ValueObject::ePrintableRepresentationSpecialCasesDisable);
}
- else
- {
- s << "<invalid usage of pointer value as object>";
- }
var_success = true;
break;
}
@@ -2000,8 +1991,7 @@ Debugger::FormatPrompt
ValueObjectSP return_valobj_sp = StopInfo::GetReturnValueObject (stop_info_sp);
if (return_valobj_sp)
{
- ValueObject::DumpValueObjectOptions dump_options;
- ValueObject::DumpValueObject (s, return_valobj_sp.get(), dump_options);
+ ValueObject::DumpValueObject (s, return_valobj_sp.get());
var_success = true;
}
}
@@ -2253,7 +2243,16 @@ Debugger::FormatPrompt
const char *open_paren = strchr (cstr, '(');
const char *close_paren = NULL;
if (open_paren)
- close_paren = strchr (open_paren, ')');
+ {
+ if (strncmp(open_paren, "(anonymous namespace)", strlen("(anonymous namespace)")) == 0)
+ {
+ open_paren = strchr (open_paren + strlen("(anonymous namespace)"), '(');
+ if (open_paren)
+ close_paren = strchr (open_paren, ')');
+ }
+ else
+ close_paren = strchr (open_paren, ')');
+ }
if (open_paren)
s.Write(cstr, open_paren - cstr + 1);
@@ -2539,8 +2538,7 @@ Debugger::FormatPrompt
unsigned long octal_value = ::strtoul (oct_str, NULL, 8);
if (octal_value <= UINT8_MAX)
{
- char octal_char = octal_value;
- s.Write (&octal_char, 1);
+ s.PutChar((char)octal_value);
}
}
break;
@@ -2563,7 +2561,7 @@ Debugger::FormatPrompt
unsigned long hex_value = strtoul (hex_str, NULL, 16);
if (hex_value <= UINT8_MAX)
- s.PutChar (hex_value);
+ s.PutChar ((char)hex_value);
}
else
{
@@ -2656,3 +2654,12 @@ Debugger::EnableLog (const char *channel
return false;
}
+SourceManager &
+Debugger::GetSourceManager ()
+{
+ if (m_source_manager_ap.get() == NULL)
+ m_source_manager_ap.reset (new SourceManager (shared_from_this()));
+ return *m_source_manager_ap;
+}
+
+
Modified: lldb/branches/windows/source/Core/Disassembler.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/Disassembler.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/Disassembler.cpp (original)
+++ lldb/branches/windows/source/Core/Disassembler.cpp Wed Apr 17 03:38:48 2013
@@ -45,7 +45,7 @@ using namespace lldb_private;
DisassemblerSP
-Disassembler::FindPlugin (const ArchSpec &arch, const char *plugin_name)
+Disassembler::FindPlugin (const ArchSpec &arch, const char *flavor, const char *plugin_name)
{
Timer scoped_timer (__PRETTY_FUNCTION__,
"Disassembler::FindPlugin (arch = %s, plugin_name = %s)",
@@ -59,7 +59,7 @@ Disassembler::FindPlugin (const ArchSpec
create_callback = PluginManager::GetDisassemblerCreateCallbackForPluginName (plugin_name);
if (create_callback)
{
- DisassemblerSP disassembler_sp(create_callback(arch));
+ DisassemblerSP disassembler_sp(create_callback(arch, flavor));
if (disassembler_sp.get())
return disassembler_sp;
@@ -69,7 +69,7 @@ Disassembler::FindPlugin (const ArchSpec
{
for (uint32_t idx = 0; (create_callback = PluginManager::GetDisassemblerCreateCallbackAtIndex(idx)) != NULL; ++idx)
{
- DisassemblerSP disassembler_sp(create_callback(arch));
+ DisassemblerSP disassembler_sp(create_callback(arch, flavor));
if (disassembler_sp.get())
return disassembler_sp;
@@ -78,6 +78,20 @@ Disassembler::FindPlugin (const ArchSpec
return DisassemblerSP();
}
+DisassemblerSP
+Disassembler::FindPluginForTarget(const TargetSP target_sp, const ArchSpec &arch, const char *flavor, const char *plugin_name)
+{
+ if (target_sp && flavor == NULL)
+ {
+ // FIXME - we don't have the mechanism in place to do per-architecture settings. But since we know that for now
+ // we only support flavors on x86 & x86_64,
+ if (arch.GetTriple().getArch() == llvm::Triple::x86
+ || arch.GetTriple().getArch() == llvm::Triple::x86_64)
+ flavor = target_sp->GetDisassemblyFlavor();
+ }
+ return FindPlugin(arch, flavor, plugin_name);
+}
+
static void
ResolveAddress (const ExecutionContext &exe_ctx,
@@ -114,6 +128,7 @@ Disassembler::Disassemble
Debugger &debugger,
const ArchSpec &arch,
const char *plugin_name,
+ const char *flavor,
const ExecutionContext &exe_ctx,
SymbolContextList &sc_list,
uint32_t num_instructions,
@@ -137,6 +152,7 @@ Disassembler::Disassemble
if (Disassemble (debugger,
arch,
plugin_name,
+ flavor,
exe_ctx,
range,
num_instructions,
@@ -158,6 +174,7 @@ Disassembler::Disassemble
Debugger &debugger,
const ArchSpec &arch,
const char *plugin_name,
+ const char *flavor,
const ExecutionContext &exe_ctx,
const ConstString &name,
Module *module,
@@ -204,6 +221,7 @@ Disassembler::Disassemble
return Disassemble (debugger,
arch,
plugin_name,
+ flavor,
exe_ctx,
sc_list,
num_instructions,
@@ -220,6 +238,7 @@ Disassembler::DisassembleRange
(
const ArchSpec &arch,
const char *plugin_name,
+ const char *flavor,
const ExecutionContext &exe_ctx,
const AddressRange &range
)
@@ -227,11 +246,12 @@ Disassembler::DisassembleRange
lldb::DisassemblerSP disasm_sp;
if (range.GetByteSize() > 0 && range.GetBaseAddress().IsValid())
{
- disasm_sp = Disassembler::FindPlugin(arch, plugin_name);
+ disasm_sp = Disassembler::FindPluginForTarget(exe_ctx.GetTargetSP(), arch, flavor, plugin_name);
if (disasm_sp)
{
- size_t bytes_disassembled = disasm_sp->ParseInstructions (&exe_ctx, range, NULL);
+ const bool prefer_file_cache = false;
+ size_t bytes_disassembled = disasm_sp->ParseInstructions (&exe_ctx, range, NULL, prefer_file_cache);
if (bytes_disassembled == 0)
disasm_sp.reset();
}
@@ -240,31 +260,31 @@ Disassembler::DisassembleRange
}
lldb::DisassemblerSP
-Disassembler::DisassembleBytes
-(
- const ArchSpec &arch,
- const char *plugin_name,
- const Address &start,
- const void *bytes,
- size_t length,
- uint32_t num_instructions
-)
+Disassembler::DisassembleBytes (const ArchSpec &arch,
+ const char *plugin_name,
+ const char *flavor,
+ const Address &start,
+ const void *src,
+ size_t src_len,
+ uint32_t num_instructions,
+ bool data_from_file)
{
lldb::DisassemblerSP disasm_sp;
- if (bytes)
+ if (src)
{
- disasm_sp = Disassembler::FindPlugin(arch, plugin_name);
+ disasm_sp = Disassembler::FindPlugin(arch, flavor, plugin_name);
if (disasm_sp)
{
- DataExtractor data(bytes, length, arch.GetByteOrder(), arch.GetAddressByteSize());
+ DataExtractor data(src, src_len, arch.GetByteOrder(), arch.GetAddressByteSize());
(void)disasm_sp->DecodeInstructions (start,
data,
0,
num_instructions,
- false);
+ false,
+ data_from_file);
}
}
@@ -278,6 +298,7 @@ Disassembler::Disassemble
Debugger &debugger,
const ArchSpec &arch,
const char *plugin_name,
+ const char *flavor,
const ExecutionContext &exe_ctx,
const AddressRange &disasm_range,
uint32_t num_instructions,
@@ -288,15 +309,15 @@ Disassembler::Disassemble
{
if (disasm_range.GetByteSize())
{
- lldb::DisassemblerSP disasm_sp (Disassembler::FindPlugin(arch, plugin_name));
+ lldb::DisassemblerSP disasm_sp (Disassembler::FindPluginForTarget(exe_ctx.GetTargetSP(), arch, flavor, plugin_name));
if (disasm_sp.get())
{
AddressRange range;
ResolveAddress (exe_ctx, disasm_range.GetBaseAddress(), range.GetBaseAddress());
range.SetByteSize (disasm_range.GetByteSize());
-
- size_t bytes_disassembled = disasm_sp->ParseInstructions (&exe_ctx, range, &strm);
+ const bool prefer_file_cache = false;
+ size_t bytes_disassembled = disasm_sp->ParseInstructions (&exe_ctx, range, &strm, prefer_file_cache);
if (bytes_disassembled == 0)
return false;
@@ -319,6 +340,7 @@ Disassembler::Disassemble
Debugger &debugger,
const ArchSpec &arch,
const char *plugin_name,
+ const char *flavor,
const ExecutionContext &exe_ctx,
const Address &start_address,
uint32_t num_instructions,
@@ -329,13 +351,19 @@ Disassembler::Disassemble
{
if (num_instructions > 0)
{
- lldb::DisassemblerSP disasm_sp (Disassembler::FindPlugin(arch, plugin_name));
+ lldb::DisassemblerSP disasm_sp (Disassembler::FindPluginForTarget(exe_ctx.GetTargetSP(),
+ arch,
+ flavor,
+ plugin_name));
if (disasm_sp.get())
{
Address addr;
ResolveAddress (exe_ctx, start_address, addr);
-
- size_t bytes_disassembled = disasm_sp->ParseInstructions (&exe_ctx, addr, num_instructions);
+ const bool prefer_file_cache = false;
+ size_t bytes_disassembled = disasm_sp->ParseInstructions (&exe_ctx,
+ addr,
+ num_instructions,
+ prefer_file_cache);
if (bytes_disassembled == 0)
return false;
return PrintInstructions (disasm_sp.get(),
@@ -445,7 +473,7 @@ Disassembler::PrintInstructions
}
else
{
- sc.Clear();
+ sc.Clear(true);
}
}
@@ -473,6 +501,7 @@ Disassembler::Disassemble
Debugger &debugger,
const ArchSpec &arch,
const char *plugin_name,
+ const char *flavor,
const ExecutionContext &exe_ctx,
uint32_t num_instructions,
uint32_t num_mixed_context_lines,
@@ -506,6 +535,7 @@ Disassembler::Disassemble
return Disassemble (debugger,
arch,
plugin_name,
+ flavor,
exe_ctx,
range,
num_instructions,
@@ -594,7 +624,7 @@ Instruction::Dump (lldb_private::Stream
ss.PutCString (m_opcode_name.c_str());
ss.FillLastLineToColumn (opcode_pos + opcode_column_width, ' ');
- ss.PutCString (m_mnemocics.c_str());
+ ss.PutCString (m_mnemonics.c_str());
if (!m_comment.empty())
{
@@ -638,7 +668,7 @@ Instruction::ReadArray (FILE *in_file, S
std::string line (buffer);
- int len = line.size();
+ size_t len = line.size();
if (line[len-1] == '\n')
{
line[len-1] = '\0';
@@ -654,10 +684,11 @@ Instruction::ReadArray (FILE *in_file, S
if (line.size() > 0)
{
std::string value;
- RegularExpression reg_exp ("^[ \t]*([^ \t]+)[ \t]*$");
- bool reg_exp_success = reg_exp.Execute (line.c_str(), 1);
+ static RegularExpression g_reg_exp ("^[ \t]*([^ \t]+)[ \t]*$");
+ RegularExpression::Match regex_match(1);
+ bool reg_exp_success = g_reg_exp.Execute (line.c_str(), ®ex_match);
if (reg_exp_success)
- reg_exp.GetMatchAtIndex (line.c_str(), 1, value);
+ regex_match.GetMatchAtIndex (line.c_str(), 1, value);
else
value = line;
@@ -706,7 +737,7 @@ Instruction::ReadDictionary (FILE *in_fi
// Check to see if the line contains the end-of-dictionary marker ("}")
std::string line (buffer);
- int len = line.size();
+ size_t len = line.size();
if (line[len-1] == '\n')
{
line[len-1] = '\0';
@@ -722,14 +753,16 @@ Instruction::ReadDictionary (FILE *in_fi
// Try to find a key-value pair in the current line and add it to the dictionary.
if (line.size() > 0)
{
- RegularExpression reg_exp ("^[ \t]*([a-zA-Z_][a-zA-Z0-9_]*)[ \t]*=[ \t]*(.*)[ \t]*$");
- bool reg_exp_success = reg_exp.Execute (line.c_str(), 2);
+ static RegularExpression g_reg_exp ("^[ \t]*([a-zA-Z_][a-zA-Z0-9_]*)[ \t]*=[ \t]*(.*)[ \t]*$");
+ RegularExpression::Match regex_match(2);
+
+ bool reg_exp_success = g_reg_exp.Execute (line.c_str(), ®ex_match);
std::string key;
std::string value;
if (reg_exp_success)
{
- reg_exp.GetMatchAtIndex (line.c_str(), 1, key);
- reg_exp.GetMatchAtIndex (line.c_str(), 2, value);
+ regex_match.GetMatchAtIndex (line.c_str(), 1, key);
+ regex_match.GetMatchAtIndex (line.c_str(), 2, value);
}
else
{
@@ -776,7 +809,7 @@ Instruction::ReadDictionary (FILE *in_fi
}
else
{
- int len = value.size();
+ size_t len = value.size();
if ((value[0] == '"') && (value[len-1] == '"'))
value = value.substr (1, len-2);
value_sp.reset (new OptionValueString (value.c_str(), ""));
@@ -945,7 +978,7 @@ InstructionList::GetMaxOpcocdeByteSize (
InstructionSP
-InstructionList::GetInstructionAtIndex (uint32_t idx) const
+InstructionList::GetInstructionAtIndex (size_t idx) const
{
InstructionSP inst_sp;
if (idx < m_instructions.size())
@@ -1007,9 +1040,9 @@ InstructionList::GetIndexOfInstructionAt
{
Address address;
address.SetLoadAddress(load_addr, &target);
- uint32_t num_instructions = m_instructions.size();
+ size_t num_instructions = m_instructions.size();
uint32_t index = UINT32_MAX;
- for (int i = 0; i < num_instructions; i++)
+ for (size_t i = 0; i < num_instructions; i++)
{
if (m_instructions[i]->GetAddress() == address)
{
@@ -1021,12 +1054,10 @@ InstructionList::GetIndexOfInstructionAt
}
size_t
-Disassembler::ParseInstructions
-(
- const ExecutionContext *exe_ctx,
- const AddressRange &range,
- Stream *error_strm_ptr
-)
+Disassembler::ParseInstructions (const ExecutionContext *exe_ctx,
+ const AddressRange &range,
+ Stream *error_strm_ptr,
+ bool prefer_file_cache)
{
if (exe_ctx)
{
@@ -1039,12 +1070,13 @@ Disassembler::ParseInstructions
DataBufferSP data_sp(heap_buffer);
Error error;
- const bool prefer_file_cache = true;
- const size_t bytes_read = target->ReadMemory (range.GetBaseAddress(),
+ lldb::addr_t load_addr = LLDB_INVALID_ADDRESS;
+ const size_t bytes_read = target->ReadMemory (range.GetBaseAddress(),
prefer_file_cache,
heap_buffer->GetBytes(),
heap_buffer->GetByteSize(),
- error);
+ error,
+ &load_addr);
if (bytes_read > 0)
{
@@ -1053,7 +1085,8 @@ Disassembler::ParseInstructions
DataExtractor data (data_sp,
m_arch.GetByteOrder(),
m_arch.GetAddressByteSize());
- return DecodeInstructions (range.GetBaseAddress(), data, 0, UINT32_MAX, false);
+ const bool data_from_file = load_addr == LLDB_INVALID_ADDRESS;
+ return DecodeInstructions (range.GetBaseAddress(), data, 0, UINT32_MAX, false, data_from_file);
}
else if (error_strm_ptr)
{
@@ -1072,12 +1105,10 @@ Disassembler::ParseInstructions
}
size_t
-Disassembler::ParseInstructions
-(
- const ExecutionContext *exe_ctx,
- const Address &start,
- uint32_t num_instructions
-)
+Disassembler::ParseInstructions (const ExecutionContext *exe_ctx,
+ const Address &start,
+ uint32_t num_instructions,
+ bool prefer_file_cache)
{
m_instruction_list.Clear();
@@ -1095,12 +1126,15 @@ Disassembler::ParseInstructions
DataBufferSP data_sp (heap_buffer);
Error error;
- bool prefer_file_cache = true;
- const size_t bytes_read = target->ReadMemory (start,
+ lldb::addr_t load_addr = LLDB_INVALID_ADDRESS;
+ const size_t bytes_read = target->ReadMemory (start,
prefer_file_cache,
heap_buffer->GetBytes(),
byte_size,
- error);
+ error,
+ &load_addr);
+
+ const bool data_from_file = load_addr == LLDB_INVALID_ADDRESS;
if (bytes_read == 0)
return 0;
@@ -1113,7 +1147,8 @@ Disassembler::ParseInstructions
data,
0,
num_instructions,
- append_instructions);
+ append_instructions,
+ data_from_file);
return m_instruction_list.GetSize();
}
@@ -1121,12 +1156,16 @@ Disassembler::ParseInstructions
//----------------------------------------------------------------------
// Disassembler copy constructor
//----------------------------------------------------------------------
-Disassembler::Disassembler(const ArchSpec& arch) :
+Disassembler::Disassembler(const ArchSpec& arch, const char *flavor) :
m_arch (arch),
m_instruction_list(),
- m_base_addr(LLDB_INVALID_ADDRESS)
+ m_base_addr(LLDB_INVALID_ADDRESS),
+ m_flavor ()
{
-
+ if (flavor == NULL)
+ m_flavor.assign("default");
+ else
+ m_flavor.assign(flavor);
}
//----------------------------------------------------------------------
@@ -1162,7 +1201,7 @@ PseudoInstruction::~PseudoInstruction ()
}
bool
-PseudoInstruction::DoesBranch () const
+PseudoInstruction::DoesBranch ()
{
// This is NOT a valid question for a pseudo instruction.
return false;
@@ -1171,7 +1210,7 @@ PseudoInstruction::DoesBranch () const
size_t
PseudoInstruction::Decode (const lldb_private::Disassembler &disassembler,
const lldb_private::DataExtractor &data,
- uint32_t data_offset)
+ lldb::offset_t data_offset)
{
return m_opcode.GetByteSize();
}
Modified: lldb/branches/windows/source/Core/DynamicLoader.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/DynamicLoader.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/DynamicLoader.cpp (original)
+++ lldb/branches/windows/source/Core/DynamicLoader.cpp Wed Apr 17 03:38:48 2013
@@ -9,6 +9,7 @@
#include "lldb/lldb-private.h"
#include "lldb/Target/DynamicLoader.h"
+#include "lldb/Target/Process.h"
#include "lldb/Core/PluginManager.h"
using namespace lldb;
@@ -45,8 +46,7 @@ DynamicLoader::FindPlugin (Process *proc
// DynamicLoader constructor
//----------------------------------------------------------------------
DynamicLoader::DynamicLoader(Process *process) :
- m_process (process),
- m_stop_when_images_change(false) // Stop the process by default when a process' images change
+ m_process (process)
{
}
@@ -64,12 +64,12 @@ DynamicLoader::~DynamicLoader()
bool
DynamicLoader::GetStopWhenImagesChange () const
{
- return m_stop_when_images_change;
+ return m_process->GetStopOnSharedLibraryEvents();
}
void
DynamicLoader::SetStopWhenImagesChange (bool stop)
{
- m_stop_when_images_change = stop;
+ m_process->SetStopOnSharedLibraryEvents (stop);
}
Modified: lldb/branches/windows/source/Core/EmulateInstruction.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/EmulateInstruction.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/EmulateInstruction.cpp (original)
+++ lldb/branches/windows/source/Core/EmulateInstruction.cpp Wed Apr 17 03:38:48 2013
@@ -186,7 +186,7 @@ EmulateInstruction::ReadMemoryUnsigned (
size_t bytes_read = m_read_mem_callback (this, m_baton, context, addr, buf, byte_size);
if (bytes_read == byte_size)
{
- uint32_t offset = 0;
+ lldb::offset_t offset = 0;
DataExtractor data (buf, byte_size, GetByteOrder(), GetAddressByteSize());
uval64 = data.GetMaxU64 (&offset, byte_size);
success = true;
Modified: lldb/branches/windows/source/Core/Error.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/Error.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/Error.cpp (original)
+++ lldb/branches/windows/source/Core/Error.cpp Wed Apr 17 03:38:48 2013
@@ -360,7 +360,7 @@ Error::SetErrorStringWithVarArg (const c
// allocated buffer above
va_list copy_args;
va_copy (copy_args, args);
- size_t length = ::vsnprintf (buf.data(), buf.size(), format, args);
+ unsigned length = ::vsnprintf (buf.data(), buf.size(), format, args);
if (length >= buf.size())
{
// The error formatted string didn't fit into our buffer, resize it
Modified: lldb/branches/windows/source/Core/FileSpecList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/FileSpecList.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/FileSpecList.cpp (original)
+++ lldb/branches/windows/source/Core/FileSpecList.cpp Wed Apr 17 03:38:48 2013
@@ -106,17 +106,16 @@ FileSpecList::Dump(Stream *s, const char
// Returns the valid index of the file that matches "file_spec" if
// it is found, else UINT32_MAX is returned.
//------------------------------------------------------------------
-uint32_t
-FileSpecList::FindFileIndex (uint32_t start_idx, const FileSpec &file_spec, bool full) const
+size_t
+FileSpecList::FindFileIndex (size_t start_idx, const FileSpec &file_spec, bool full) const
{
- const uint32_t num_files = m_files.size();
- uint32_t idx;
+ const size_t num_files = m_files.size();
// When looking for files, we will compare only the filename if the
// FILE_SPEC argument is empty
bool compare_filename_only = file_spec.GetDirectory().IsEmpty();
- for (idx = start_idx; idx < num_files; ++idx)
+ for (size_t idx = start_idx; idx < num_files; ++idx)
{
if (compare_filename_only)
{
@@ -139,7 +138,7 @@ FileSpecList::FindFileIndex (uint32_t st
// range, then an empty FileSpec object will be returned.
//------------------------------------------------------------------
const FileSpec &
-FileSpecList::GetFileSpecAtIndex(uint32_t idx) const
+FileSpecList::GetFileSpecAtIndex(size_t idx) const
{
if (idx < m_files.size())
@@ -149,7 +148,7 @@ FileSpecList::GetFileSpecAtIndex(uint32_
}
const FileSpec *
-FileSpecList::GetFileSpecPointerAtIndex(uint32_t idx) const
+FileSpecList::GetFileSpecPointerAtIndex(size_t idx) const
{
if (idx < m_files.size())
return &m_files[idx];
@@ -179,7 +178,7 @@ FileSpecList::MemorySize () const
//------------------------------------------------------------------
// Return the number of files in the file spec list.
//------------------------------------------------------------------
-uint32_t
+size_t
FileSpecList::GetSize() const
{
return m_files.size();
Removed: lldb/branches/windows/source/Core/FormatClasses.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/FormatClasses.cpp?rev=179678&view=auto
==============================================================================
--- lldb/branches/windows/source/Core/FormatClasses.cpp (original)
+++ lldb/branches/windows/source/Core/FormatClasses.cpp (removed)
@@ -1,409 +0,0 @@
-//===-- FormatClasses.cpp ----------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "lldb/lldb-python.h"
-
-// C Includes
-
-// C++ Includes
-
-// Other libraries and framework includes
-
-// Project includes
-#include "lldb/lldb-public.h"
-#include "lldb/lldb-enumerations.h"
-
-#include "lldb/Core/Debugger.h"
-#include "lldb/Core/FormatClasses.h"
-#include "lldb/Core/StreamString.h"
-#include "lldb/Core/Timer.h"
-#include "lldb/Interpreter/CommandInterpreter.h"
-#include "lldb/Symbol/ClangASTType.h"
-#include "lldb/Target/StackFrame.h"
-#include "lldb/Target/Target.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-TypeFormatImpl::TypeFormatImpl (lldb::Format f,
- const Flags& flags) :
- m_flags(flags),
- m_format (f)
-{
-}
-
-std::string
-TypeFormatImpl::GetDescription()
-{
- StreamString sstr;
- sstr.Printf ("%s%s%s%s\n",
- FormatManager::GetFormatAsCString (GetFormat()),
- Cascades() ? "" : " (not cascading)",
- SkipsPointers() ? " (skip pointers)" : "",
- SkipsReferences() ? " (skip references)" : "");
- return sstr.GetString();
-}
-
-TypeSummaryImpl::TypeSummaryImpl(const TypeSummaryImpl::Flags& flags) :
- m_flags(flags)
-{
-}
-
-
-StringSummaryFormat::StringSummaryFormat(const TypeSummaryImpl::Flags& flags,
- const char *format_cstr) :
- TypeSummaryImpl(flags),
- m_format()
-{
- if (format_cstr)
- m_format.assign(format_cstr);
-}
-
-bool
-StringSummaryFormat::FormatObject(ValueObject *valobj,
- std::string& retval)
-{
- if (!valobj)
- {
- retval.assign("NULL ValueObject");
- return false;
- }
-
- StreamString s;
- ExecutionContext exe_ctx (valobj->GetExecutionContextRef());
- SymbolContext sc;
- StackFrame *frame = exe_ctx.GetFramePtr();
- if (frame)
- sc = frame->GetSymbolContext(lldb::eSymbolContextEverything);
-
- if (IsOneliner())
- {
- ValueObject* object;
-
- ValueObjectSP synth_valobj = valobj->GetSyntheticValue();
- if (synth_valobj)
- object = synth_valobj.get();
- else
- object = valobj;
-
- const uint32_t num_children = object->GetNumChildren();
- if (num_children)
- {
- s.PutChar('(');
-
- for (uint32_t idx=0; idx<num_children; ++idx)
- {
- lldb::ValueObjectSP child_sp(object->GetChildAtIndex(idx, true));
- if (child_sp.get())
- {
- if (idx)
- s.PutCString(", ");
- if (!HideNames())
- {
- s.PutCString(child_sp.get()->GetName().AsCString());
- s.PutCString(" = ");
- }
- child_sp.get()->DumpPrintableRepresentation(s,
- ValueObject::eValueObjectRepresentationStyleSummary,
- lldb::eFormatInvalid,
- ValueObject::ePrintableRepresentationSpecialCasesDisable);
- }
- }
-
- s.PutChar(')');
-
- retval.assign(s.GetString());
- return true;
- }
- else
- {
- retval.assign("error: oneliner for no children");
- return false;
- }
-
- }
- else
- {
- if (Debugger::FormatPrompt(m_format.c_str(), &sc, &exe_ctx, &sc.line_entry.range.GetBaseAddress(), s, NULL, valobj))
- {
- retval.assign(s.GetString());
- return true;
- }
- else
- {
- retval.assign("error: summary string parsing error");
- return false;
- }
- }
-}
-
-std::string
-StringSummaryFormat::GetDescription()
-{
- StreamString sstr;
-
- sstr.Printf ("`%s`%s%s%s%s%s%s%s", m_format.c_str(),
- Cascades() ? "" : " (not cascading)",
- !DoesPrintChildren() ? "" : " (show children)",
- !DoesPrintValue() ? " (hide value)" : "",
- IsOneliner() ? " (one-line printout)" : "",
- SkipsPointers() ? " (skip pointers)" : "",
- SkipsReferences() ? " (skip references)" : "",
- HideNames() ? " (hide member names)" : "");
- return sstr.GetString();
-}
-
-CXXFunctionSummaryFormat::CXXFunctionSummaryFormat (const TypeSummaryImpl::Flags& flags,
- Callback impl,
- const char* description) :
- TypeSummaryImpl(flags),
- m_impl(impl),
- m_description(description ? description : "")
-{
-}
-
-bool
-CXXFunctionSummaryFormat::FormatObject(ValueObject *valobj,
- std::string& dest)
-{
- dest.clear();
- StreamString stream;
- if (!m_impl || m_impl(*valobj,stream) == false)
- return false;
- dest.assign(stream.GetData());
- return true;
-}
-
-std::string
-CXXFunctionSummaryFormat::GetDescription()
-{
- StreamString sstr;
- sstr.Printf ("`%s (%p) `%s%s%s%s%s%s%s", m_description.c_str(),m_impl,
- Cascades() ? "" : " (not cascading)",
- !DoesPrintChildren() ? "" : " (show children)",
- !DoesPrintValue() ? " (hide value)" : "",
- IsOneliner() ? " (one-line printout)" : "",
- SkipsPointers() ? " (skip pointers)" : "",
- SkipsReferences() ? " (skip references)" : "",
- HideNames() ? " (hide member names)" : "");
- return sstr.GetString();
-}
-
-#ifndef LLDB_DISABLE_PYTHON
-
-
-ScriptSummaryFormat::ScriptSummaryFormat(const TypeSummaryImpl::Flags& flags,
- const char * function_name,
- const char * python_script) :
- TypeSummaryImpl(flags),
- m_function_name(),
- m_python_script(),
- m_script_function_sp()
-{
- if (function_name)
- m_function_name.assign(function_name);
- if (python_script)
- m_python_script.assign(python_script);
-}
-
-bool
-ScriptSummaryFormat::FormatObject(ValueObject *valobj,
- std::string& retval)
-{
- Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
-
- TargetSP target_sp(valobj->GetTargetSP());
-
- if (!target_sp)
- {
- retval.assign("error: no target");
- return false;
- }
-
- ScriptInterpreter *script_interpreter = target_sp->GetDebugger().GetCommandInterpreter().GetScriptInterpreter();
-
- if (!script_interpreter)
- {
- retval.assign("error: no ScriptInterpreter");
- return false;
- }
-
- return script_interpreter->GetScriptedSummary(m_function_name.c_str(),
- valobj->GetSP(),
- m_script_function_sp,
- retval);
-
-}
-
-std::string
-ScriptSummaryFormat::GetDescription()
-{
- StreamString sstr;
- sstr.Printf ("%s%s%s%s%s%s%s\n%s", Cascades() ? "" : " (not cascading)",
- !DoesPrintChildren() ? "" : " (show children)",
- !DoesPrintValue() ? " (hide value)" : "",
- IsOneliner() ? " (one-line printout)" : "",
- SkipsPointers() ? " (skip pointers)" : "",
- SkipsReferences() ? " (skip references)" : "",
- HideNames() ? " (hide member names)" : "",
- m_python_script.c_str());
- return sstr.GetString();
-
-}
-
-#endif // #ifndef LLDB_DISABLE_PYTHON
-
-std::string
-TypeFilterImpl::GetDescription()
-{
- StreamString sstr;
- sstr.Printf("%s%s%s {\n",
- Cascades() ? "" : " (not cascading)",
- SkipsPointers() ? " (skip pointers)" : "",
- SkipsReferences() ? " (skip references)" : "");
-
- for (int i = 0; i < GetCount(); i++)
- {
- sstr.Printf(" %s\n",
- GetExpressionPathAtIndex(i));
- }
-
- sstr.Printf("}");
- return sstr.GetString();
-}
-
-std::string
-CXXSyntheticChildren::GetDescription()
-{
- StreamString sstr;
- sstr.Printf("%s%s%s Generator at %p - %s\n",
- Cascades() ? "" : " (not cascading)",
- SkipsPointers() ? " (skip pointers)" : "",
- SkipsReferences() ? " (skip references)" : "",
- m_create_callback,
- m_description.c_str());
-
- return sstr.GetString();
-}
-
-std::string
-SyntheticArrayView::GetDescription()
-{
- StreamString sstr;
- sstr.Printf("%s%s%s {\n",
- Cascades() ? "" : " (not cascading)",
- SkipsPointers() ? " (skip pointers)" : "",
- SkipsReferences() ? " (skip references)" : "");
-
- SyntheticArrayRange* ptr = &m_head;
- while (ptr && ptr != m_tail)
- {
- if (ptr->GetLow() == ptr->GetHigh())
- sstr.Printf(" [%d]\n",
- ptr->GetLow());
- else
- sstr.Printf(" [%d-%d]\n",
- ptr->GetLow(),
- ptr->GetHigh());
- ptr = ptr->GetNext();
- }
-
- sstr.Printf("}");
- return sstr.GetString();
-}
-
-#ifndef LLDB_DISABLE_PYTHON
-
-TypeSyntheticImpl::FrontEnd::FrontEnd(std::string pclass, ValueObject &backend) :
- SyntheticChildrenFrontEnd(backend),
- m_python_class(pclass),
- m_wrapper_sp(),
- m_interpreter(NULL)
-{
- if (backend == LLDB_INVALID_UID)
- return;
-
- TargetSP target_sp = backend.GetTargetSP();
-
- if (!target_sp)
- return;
-
- m_interpreter = target_sp->GetDebugger().GetCommandInterpreter().GetScriptInterpreter();
-
- if (m_interpreter != NULL)
- m_wrapper_sp = m_interpreter->CreateSyntheticScriptedProvider(m_python_class, backend.GetSP());
-}
-
-TypeSyntheticImpl::FrontEnd::~FrontEnd()
-{
-}
-
-lldb::ValueObjectSP
-TypeSyntheticImpl::FrontEnd::GetChildAtIndex (uint32_t idx)
-{
- if (!m_wrapper_sp || !m_interpreter)
- return lldb::ValueObjectSP();
-
- return m_interpreter->GetChildAtIndex(m_wrapper_sp, idx);
-}
-
-std::string
-TypeSyntheticImpl::GetDescription()
-{
- StreamString sstr;
- sstr.Printf("%s%s%s Python class %s",
- Cascades() ? "" : " (not cascading)",
- SkipsPointers() ? " (skip pointers)" : "",
- SkipsReferences() ? " (skip references)" : "",
- m_python_class.c_str());
-
- return sstr.GetString();
-}
-
-#endif // #ifndef LLDB_DISABLE_PYTHON
-
-int
-SyntheticArrayView::GetRealIndexForIndex(int i)
-{
- if (i >= GetCount())
- return -1;
-
- SyntheticArrayRange* ptr = &m_head;
-
- int residual = i;
-
- while(ptr && ptr != m_tail)
- {
- if (residual >= ptr->GetSelfCount())
- {
- residual -= ptr->GetSelfCount();
- ptr = ptr->GetNext();
- }
-
- return ptr->GetLow() + residual;
- }
-
- return -1;
-}
-
-uint32_t
-SyntheticArrayView::FrontEnd::GetIndexOfChildWithName (const ConstString &name_cs)
-{
- const char* name_cstr = name_cs.GetCString();
- if (*name_cstr != '[')
- return UINT32_MAX;
- std::string name(name_cstr+1);
- if (name[name.size()-1] != ']')
- return UINT32_MAX;
- name = name.erase(name.size()-1,1);
- int index = Args::StringToSInt32 (name.c_str(), -1);
- if (index < 0)
- return UINT32_MAX;
- return index;
-}
Removed: lldb/branches/windows/source/Core/FormatManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/FormatManager.cpp?rev=179678&view=auto
==============================================================================
--- lldb/branches/windows/source/Core/FormatManager.cpp (original)
+++ lldb/branches/windows/source/Core/FormatManager.cpp (removed)
@@ -1,1254 +0,0 @@
-//===-- FormatManager.cpp -------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "lldb/lldb-python.h"
-
-#include "lldb/Core/FormatManager.h"
-
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
-
-#include "lldb/Core/CXXFormatterFunctions.h"
-#include "lldb/Core/Debugger.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-
-struct FormatInfo
-{
- Format format;
- const char format_char; // One or more format characters that can be used for this format.
- const char *format_name; // Long format name that can be used to specify the current format
-};
-
-static FormatInfo
-g_format_infos[] =
-{
- { eFormatDefault , '\0' , "default" },
- { eFormatBoolean , 'B' , "boolean" },
- { eFormatBinary , 'b' , "binary" },
- { eFormatBytes , 'y' , "bytes" },
- { eFormatBytesWithASCII , 'Y' , "bytes with ASCII" },
- { eFormatChar , 'c' , "character" },
- { eFormatCharPrintable , 'C' , "printable character" },
- { eFormatComplexFloat , 'F' , "complex float" },
- { eFormatCString , 's' , "c-string" },
- { eFormatDecimal , 'd' , "decimal" },
- { eFormatEnum , 'E' , "enumeration" },
- { eFormatHex , 'x' , "hex" },
- { eFormatHexUppercase , 'X' , "uppercase hex" },
- { eFormatFloat , 'f' , "float" },
- { eFormatOctal , 'o' , "octal" },
- { eFormatOSType , 'O' , "OSType" },
- { eFormatUnicode16 , 'U' , "unicode16" },
- { eFormatUnicode32 , '\0' , "unicode32" },
- { eFormatUnsigned , 'u' , "unsigned decimal" },
- { eFormatPointer , 'p' , "pointer" },
- { eFormatVectorOfChar , '\0' , "char[]" },
- { eFormatVectorOfSInt8 , '\0' , "int8_t[]" },
- { eFormatVectorOfUInt8 , '\0' , "uint8_t[]" },
- { eFormatVectorOfSInt16 , '\0' , "int16_t[]" },
- { eFormatVectorOfUInt16 , '\0' , "uint16_t[]" },
- { eFormatVectorOfSInt32 , '\0' , "int32_t[]" },
- { eFormatVectorOfUInt32 , '\0' , "uint32_t[]" },
- { eFormatVectorOfSInt64 , '\0' , "int64_t[]" },
- { eFormatVectorOfUInt64 , '\0' , "uint64_t[]" },
- { eFormatVectorOfFloat32, '\0' , "float32[]" },
- { eFormatVectorOfFloat64, '\0' , "float64[]" },
- { eFormatVectorOfUInt128, '\0' , "uint128_t[]" },
- { eFormatComplexInteger , 'I' , "complex integer" },
- { eFormatCharArray , 'a' , "character array" },
- { eFormatAddressInfo , 'A' , "address" },
- { eFormatHexFloat , '\0' , "hex float" },
- { eFormatInstruction , 'i' , "instruction" },
- { eFormatVoid , 'v' , "void" }
-};
-
-static uint32_t
-g_num_format_infos = sizeof(g_format_infos)/sizeof(FormatInfo);
-
-static bool
-GetFormatFromFormatChar (char format_char, Format &format)
-{
- for (uint32_t i=0; i<g_num_format_infos; ++i)
- {
- if (g_format_infos[i].format_char == format_char)
- {
- format = g_format_infos[i].format;
- return true;
- }
- }
- format = eFormatInvalid;
- return false;
-}
-
-static bool
-GetFormatFromFormatName (const char *format_name, bool partial_match_ok, Format &format)
-{
- uint32_t i;
- for (i=0; i<g_num_format_infos; ++i)
- {
- if (strcasecmp (g_format_infos[i].format_name, format_name) == 0)
- {
- format = g_format_infos[i].format;
- return true;
- }
- }
-
- if (partial_match_ok)
- {
- for (i=0; i<g_num_format_infos; ++i)
- {
- if (strcasestr (g_format_infos[i].format_name, format_name) == g_format_infos[i].format_name)
- {
- format = g_format_infos[i].format;
- return true;
- }
- }
- }
- format = eFormatInvalid;
- return false;
-}
-
-bool
-FormatManager::GetFormatFromCString (const char *format_cstr,
- bool partial_match_ok,
- lldb::Format &format)
-{
- bool success = false;
- if (format_cstr && format_cstr[0])
- {
- if (format_cstr[1] == '\0')
- {
- success = GetFormatFromFormatChar (format_cstr[0], format);
- if (success)
- return true;
- }
-
- success = GetFormatFromFormatName (format_cstr, partial_match_ok, format);
- }
- if (!success)
- format = eFormatInvalid;
- return success;
-}
-
-char
-FormatManager::GetFormatAsFormatChar (lldb::Format format)
-{
- for (uint32_t i=0; i<g_num_format_infos; ++i)
- {
- if (g_format_infos[i].format == format)
- return g_format_infos[i].format_char;
- }
- return '\0';
-}
-
-
-
-const char *
-FormatManager::GetFormatAsCString (Format format)
-{
- if (format >= eFormatDefault && format < kNumFormats)
- return g_format_infos[format].format_name;
- return NULL;
-}
-
-TypeCategoryImpl::TypeCategoryImpl(IFormatChangeListener* clist,
- ConstString name) :
- m_summary_nav(new SummaryNavigator("summary",clist)),
- m_regex_summary_nav(new RegexSummaryNavigator("regex-summary",clist)),
- m_filter_nav(new FilterNavigator("filter",clist)),
- m_regex_filter_nav(new RegexFilterNavigator("regex-filter",clist)),
-#ifndef LLDB_DISABLE_PYTHON
- m_synth_nav(new SynthNavigator("synth",clist)),
- m_regex_synth_nav(new RegexSynthNavigator("regex-synth",clist)),
-#endif
- m_enabled(false),
- m_change_listener(clist),
- m_mutex(Mutex::eMutexTypeRecursive),
- m_name(name)
-{}
-
-bool
-TypeCategoryImpl::Get (ValueObject& valobj,
- lldb::TypeSummaryImplSP& entry,
- lldb::DynamicValueType use_dynamic,
- uint32_t* reason)
-{
- if (!IsEnabled())
- return false;
- if (GetSummaryNavigator()->Get(valobj, entry, use_dynamic, reason))
- return true;
- bool regex = GetRegexSummaryNavigator()->Get(valobj, entry, use_dynamic, reason);
- if (regex && reason)
- *reason |= lldb_private::eFormatterChoiceCriterionRegularExpressionSummary;
- return regex;
-}
-
-bool
-TypeCategoryImpl::Get(ValueObject& valobj,
- lldb::SyntheticChildrenSP& entry_sp,
- lldb::DynamicValueType use_dynamic,
- uint32_t* reason)
-{
- if (!IsEnabled())
- return false;
- TypeFilterImpl::SharedPointer filter_sp;
- uint32_t reason_filter = 0;
- bool regex_filter = false;
- // first find both Filter and Synth, and then check which is most recent
-
- if (!GetFilterNavigator()->Get(valobj, filter_sp, use_dynamic, &reason_filter))
- regex_filter = GetRegexFilterNavigator()->Get (valobj, filter_sp, use_dynamic, &reason_filter);
-
-#ifndef LLDB_DISABLE_PYTHON
- bool regex_synth = false;
- uint32_t reason_synth = 0;
- bool pick_synth = false;
- TypeSyntheticImpl::SharedPointer synth;
- if (!GetSyntheticNavigator()->Get(valobj, synth, use_dynamic, &reason_synth))
- regex_synth = GetRegexSyntheticNavigator()->Get (valobj, synth, use_dynamic, &reason_synth);
- if (!filter_sp.get() && !synth.get())
- return false;
- else if (!filter_sp.get() && synth.get())
- pick_synth = true;
-
- else if (filter_sp.get() && !synth.get())
- pick_synth = false;
-
- else /*if (filter_sp.get() && synth.get())*/
- {
- if (filter_sp->GetRevision() > synth->GetRevision())
- pick_synth = false;
- else
- pick_synth = true;
- }
- if (pick_synth)
- {
- if (regex_synth && reason)
- *reason |= lldb_private::eFormatterChoiceCriterionRegularExpressionFilter;
- entry_sp = synth;
- return true;
- }
- else
- {
- if (regex_filter && reason)
- *reason |= lldb_private::eFormatterChoiceCriterionRegularExpressionFilter;
- entry_sp = filter_sp;
- return true;
- }
-
-#else
- if (filter_sp)
- {
- entry_sp = filter_sp;
- return true;
- }
-#endif
-
- return false;
-
-}
-
-void
-TypeCategoryImpl::Clear (FormatCategoryItems items)
-{
- if ( (items & eFormatCategoryItemSummary) == eFormatCategoryItemSummary )
- m_summary_nav->Clear();
- if ( (items & eFormatCategoryItemRegexSummary) == eFormatCategoryItemRegexSummary )
- m_regex_summary_nav->Clear();
- if ( (items & eFormatCategoryItemFilter) == eFormatCategoryItemFilter )
- m_filter_nav->Clear();
- if ( (items & eFormatCategoryItemRegexFilter) == eFormatCategoryItemRegexFilter )
- m_regex_filter_nav->Clear();
-#ifndef LLDB_DISABLE_PYTHON
- if ( (items & eFormatCategoryItemSynth) == eFormatCategoryItemSynth )
- m_synth_nav->Clear();
- if ( (items & eFormatCategoryItemRegexSynth) == eFormatCategoryItemRegexSynth )
- m_regex_synth_nav->Clear();
-#endif
-}
-
-bool
-TypeCategoryImpl::Delete (ConstString name,
- FormatCategoryItems items)
-{
- bool success = false;
- if ( (items & eFormatCategoryItemSummary) == eFormatCategoryItemSummary )
- success = m_summary_nav->Delete(name) || success;
- if ( (items & eFormatCategoryItemRegexSummary) == eFormatCategoryItemRegexSummary )
- success = m_regex_summary_nav->Delete(name) || success;
- if ( (items & eFormatCategoryItemFilter) == eFormatCategoryItemFilter )
- success = m_filter_nav->Delete(name) || success;
- if ( (items & eFormatCategoryItemRegexFilter) == eFormatCategoryItemRegexFilter )
- success = m_regex_filter_nav->Delete(name) || success;
-#ifndef LLDB_DISABLE_PYTHON
- if ( (items & eFormatCategoryItemSynth) == eFormatCategoryItemSynth )
- success = m_synth_nav->Delete(name) || success;
- if ( (items & eFormatCategoryItemRegexSynth) == eFormatCategoryItemRegexSynth )
- success = m_regex_synth_nav->Delete(name) || success;
-#endif
- return success;
-}
-
-uint32_t
-TypeCategoryImpl::GetCount (FormatCategoryItems items)
-{
- uint32_t count = 0;
- if ( (items & eFormatCategoryItemSummary) == eFormatCategoryItemSummary )
- count += m_summary_nav->GetCount();
- if ( (items & eFormatCategoryItemRegexSummary) == eFormatCategoryItemRegexSummary )
- count += m_regex_summary_nav->GetCount();
- if ( (items & eFormatCategoryItemFilter) == eFormatCategoryItemFilter )
- count += m_filter_nav->GetCount();
- if ( (items & eFormatCategoryItemRegexFilter) == eFormatCategoryItemRegexFilter )
- count += m_regex_filter_nav->GetCount();
-#ifndef LLDB_DISABLE_PYTHON
- if ( (items & eFormatCategoryItemSynth) == eFormatCategoryItemSynth )
- count += m_synth_nav->GetCount();
- if ( (items & eFormatCategoryItemRegexSynth) == eFormatCategoryItemRegexSynth )
- count += m_regex_synth_nav->GetCount();
-#endif
- return count;
-}
-
-bool
-TypeCategoryImpl::AnyMatches(ConstString type_name,
- FormatCategoryItems items,
- bool only_enabled,
- const char** matching_category,
- FormatCategoryItems* matching_type)
-{
- if (!IsEnabled() && only_enabled)
- return false;
-
- lldb::TypeSummaryImplSP summary;
- TypeFilterImpl::SharedPointer filter;
-#ifndef LLDB_DISABLE_PYTHON
- TypeSyntheticImpl::SharedPointer synth;
-#endif
-
- if ( (items & eFormatCategoryItemSummary) == eFormatCategoryItemSummary )
- {
- if (m_summary_nav->Get(type_name, summary))
- {
- if (matching_category)
- *matching_category = m_name.GetCString();
- if (matching_type)
- *matching_type = eFormatCategoryItemSummary;
- return true;
- }
- }
- if ( (items & eFormatCategoryItemRegexSummary) == eFormatCategoryItemRegexSummary )
- {
- if (m_regex_summary_nav->Get(type_name, summary))
- {
- if (matching_category)
- *matching_category = m_name.GetCString();
- if (matching_type)
- *matching_type = eFormatCategoryItemRegexSummary;
- return true;
- }
- }
- if ( (items & eFormatCategoryItemFilter) == eFormatCategoryItemFilter )
- {
- if (m_filter_nav->Get(type_name, filter))
- {
- if (matching_category)
- *matching_category = m_name.GetCString();
- if (matching_type)
- *matching_type = eFormatCategoryItemFilter;
- return true;
- }
- }
- if ( (items & eFormatCategoryItemRegexFilter) == eFormatCategoryItemRegexFilter )
- {
- if (m_regex_filter_nav->Get(type_name, filter))
- {
- if (matching_category)
- *matching_category = m_name.GetCString();
- if (matching_type)
- *matching_type = eFormatCategoryItemRegexFilter;
- return true;
- }
- }
-#ifndef LLDB_DISABLE_PYTHON
- if ( (items & eFormatCategoryItemSynth) == eFormatCategoryItemSynth )
- {
- if (m_synth_nav->Get(type_name, synth))
- {
- if (matching_category)
- *matching_category = m_name.GetCString();
- if (matching_type)
- *matching_type = eFormatCategoryItemSynth;
- return true;
- }
- }
- if ( (items & eFormatCategoryItemRegexSynth) == eFormatCategoryItemRegexSynth )
- {
- if (m_regex_synth_nav->Get(type_name, synth))
- {
- if (matching_category)
- *matching_category = m_name.GetCString();
- if (matching_type)
- *matching_type = eFormatCategoryItemRegexSynth;
- return true;
- }
- }
-#endif
- return false;
-}
-
-bool
-CategoryMap::AnyMatches (ConstString type_name,
- TypeCategoryImpl::FormatCategoryItems items,
- bool only_enabled,
- const char** matching_category,
- TypeCategoryImpl::FormatCategoryItems* matching_type)
-{
- Mutex::Locker locker(m_map_mutex);
-
- MapIterator pos, end = m_map.end();
- for (pos = m_map.begin(); pos != end; pos++)
- {
- if (pos->second->AnyMatches(type_name,
- items,
- only_enabled,
- matching_category,
- matching_type))
- return true;
- }
- return false;
-}
-
-lldb::TypeSummaryImplSP
-CategoryMap::GetSummaryFormat (ValueObject& valobj,
- lldb::DynamicValueType use_dynamic)
-{
- Mutex::Locker locker(m_map_mutex);
-
- uint32_t reason_why;
- ActiveCategoriesIterator begin, end = m_active_categories.end();
-
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
-
- for (begin = m_active_categories.begin(); begin != end; begin++)
- {
- lldb::TypeCategoryImplSP category_sp = *begin;
- lldb::TypeSummaryImplSP current_format;
- if (log)
- log->Printf("[CategoryMap::GetSummaryFormat] Trying to use category %s\n", category_sp->GetName());
- if (!category_sp->Get(valobj, current_format, use_dynamic, &reason_why))
- continue;
- return current_format;
- }
- if (log)
- log->Printf("[CategoryMap::GetSummaryFormat] nothing found - returning empty SP\n");
- return lldb::TypeSummaryImplSP();
-}
-
-lldb::TypeSummaryImplSP
-FormatManager::GetSummaryForType (lldb::TypeNameSpecifierImplSP type_sp)
-{
- if (!type_sp)
- return lldb::TypeSummaryImplSP();
- lldb::TypeSummaryImplSP summary_chosen_sp;
- uint32_t num_categories = m_categories_map.GetCount();
- lldb::TypeCategoryImplSP category_sp;
- uint32_t prio_category = UINT32_MAX;
- for (uint32_t category_id = 0;
- category_id < num_categories;
- category_id++)
- {
- category_sp = GetCategoryAtIndex(category_id);
- if (category_sp->IsEnabled() == false)
- continue;
- lldb::TypeSummaryImplSP summary_current_sp = category_sp->GetSummaryForType(type_sp);
- if (summary_current_sp && (summary_chosen_sp.get() == NULL || (prio_category > category_sp->GetEnabledPosition())))
- {
- prio_category = category_sp->GetEnabledPosition();
- summary_chosen_sp = summary_current_sp;
- }
- }
- return summary_chosen_sp;
-}
-
-lldb::TypeFilterImplSP
-FormatManager::GetFilterForType (lldb::TypeNameSpecifierImplSP type_sp)
-{
- if (!type_sp)
- return lldb::TypeFilterImplSP();
- lldb::TypeFilterImplSP filter_chosen_sp;
- uint32_t num_categories = m_categories_map.GetCount();
- lldb::TypeCategoryImplSP category_sp;
- uint32_t prio_category = UINT32_MAX;
- for (uint32_t category_id = 0;
- category_id < num_categories;
- category_id++)
- {
- category_sp = GetCategoryAtIndex(category_id);
- if (category_sp->IsEnabled() == false)
- continue;
- lldb::TypeFilterImplSP filter_current_sp((TypeFilterImpl*)category_sp->GetFilterForType(type_sp).get());
- if (filter_current_sp && (filter_chosen_sp.get() == NULL || (prio_category > category_sp->GetEnabledPosition())))
- {
- prio_category = category_sp->GetEnabledPosition();
- filter_chosen_sp = filter_current_sp;
- }
- }
- return filter_chosen_sp;
-}
-
-#ifndef LLDB_DISABLE_PYTHON
-lldb::TypeSyntheticImplSP
-FormatManager::GetSyntheticForType (lldb::TypeNameSpecifierImplSP type_sp)
-{
- if (!type_sp)
- return lldb::TypeSyntheticImplSP();
- lldb::TypeSyntheticImplSP synth_chosen_sp;
- uint32_t num_categories = m_categories_map.GetCount();
- lldb::TypeCategoryImplSP category_sp;
- uint32_t prio_category = UINT32_MAX;
- for (uint32_t category_id = 0;
- category_id < num_categories;
- category_id++)
- {
- category_sp = GetCategoryAtIndex(category_id);
- if (category_sp->IsEnabled() == false)
- continue;
- lldb::TypeSyntheticImplSP synth_current_sp((TypeSyntheticImpl*)category_sp->GetSyntheticForType(type_sp).get());
- if (synth_current_sp && (synth_chosen_sp.get() == NULL || (prio_category > category_sp->GetEnabledPosition())))
- {
- prio_category = category_sp->GetEnabledPosition();
- synth_chosen_sp = synth_current_sp;
- }
- }
- return synth_chosen_sp;
-}
-#endif
-
-#ifndef LLDB_DISABLE_PYTHON
-lldb::SyntheticChildrenSP
-FormatManager::GetSyntheticChildrenForType (lldb::TypeNameSpecifierImplSP type_sp)
-{
- if (!type_sp)
- return lldb::SyntheticChildrenSP();
- lldb::TypeFilterImplSP filter_sp = GetFilterForType(type_sp);
- lldb::TypeSyntheticImplSP synth_sp = GetSyntheticForType(type_sp);
- if (filter_sp->GetRevision() > synth_sp->GetRevision())
- return lldb::SyntheticChildrenSP(filter_sp.get());
- else
- return lldb::SyntheticChildrenSP(synth_sp.get());
-}
-#endif
-
-#ifndef LLDB_DISABLE_PYTHON
-lldb::SyntheticChildrenSP
-CategoryMap::GetSyntheticChildren (ValueObject& valobj,
- lldb::DynamicValueType use_dynamic)
-{
- Mutex::Locker locker(m_map_mutex);
-
- uint32_t reason_why;
-
- ActiveCategoriesIterator begin, end = m_active_categories.end();
-
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
-
- for (begin = m_active_categories.begin(); begin != end; begin++)
- {
- lldb::TypeCategoryImplSP category_sp = *begin;
- lldb::SyntheticChildrenSP current_format;
- if (log)
- log->Printf("[CategoryMap::GetSyntheticChildren] Trying to use category %s\n", category_sp->GetName());
- if (!category_sp->Get(valobj, current_format, use_dynamic, &reason_why))
- continue;
- return current_format;
- }
- if (log)
- log->Printf("[CategoryMap::GetSyntheticChildren] nothing found - returning empty SP\n");
- return lldb::SyntheticChildrenSP();
-}
-#endif
-
-void
-CategoryMap::LoopThrough(CallbackType callback, void* param)
-{
- if (callback)
- {
- Mutex::Locker locker(m_map_mutex);
-
- // loop through enabled categories in respective order
- {
- ActiveCategoriesIterator begin, end = m_active_categories.end();
- for (begin = m_active_categories.begin(); begin != end; begin++)
- {
- lldb::TypeCategoryImplSP category = *begin;
- ConstString type = ConstString(category->GetName());
- if (!callback(param, category))
- break;
- }
- }
-
- // loop through disabled categories in just any order
- {
- MapIterator pos, end = m_map.end();
- for (pos = m_map.begin(); pos != end; pos++)
- {
- if (pos->second->IsEnabled())
- continue;
- KeyType type = pos->first;
- if (!callback(param, pos->second))
- break;
- }
- }
- }
-}
-
-TypeCategoryImplSP
-CategoryMap::GetAtIndex (uint32_t index)
-{
- Mutex::Locker locker(m_map_mutex);
-
- if (index < m_map.size())
- {
- MapIterator pos, end = m_map.end();
- for (pos = m_map.begin(); pos != end; pos++)
- {
- if (index == 0)
- return pos->second;
- index--;
- }
- }
-
- return TypeCategoryImplSP();
-}
-
-lldb::TypeCategoryImplSP
-FormatManager::GetCategory (const ConstString& category_name,
- bool can_create)
-{
- if (!category_name)
- return GetCategory(m_default_category_name);
- lldb::TypeCategoryImplSP category;
- if (m_categories_map.Get(category_name, category))
- return category;
-
- if (!can_create)
- return lldb::TypeCategoryImplSP();
-
- m_categories_map.Add(category_name,lldb::TypeCategoryImplSP(new TypeCategoryImpl(this, category_name)));
- return GetCategory(category_name);
-}
-
-lldb::Format
-FormatManager::GetSingleItemFormat(lldb::Format vector_format)
-{
- switch(vector_format)
- {
- case eFormatVectorOfChar:
- return eFormatCharArray;
-
- case eFormatVectorOfSInt8:
- case eFormatVectorOfSInt16:
- case eFormatVectorOfSInt32:
- case eFormatVectorOfSInt64:
- return eFormatDecimal;
-
- case eFormatVectorOfUInt8:
- case eFormatVectorOfUInt16:
- case eFormatVectorOfUInt32:
- case eFormatVectorOfUInt64:
- case eFormatVectorOfUInt128:
- return eFormatHex;
-
- case eFormatVectorOfFloat32:
- case eFormatVectorOfFloat64:
- return eFormatFloat;
-
- default:
- return lldb::eFormatInvalid;
- }
-}
-
-ConstString
-FormatManager::GetValidTypeName (const ConstString& type)
-{
- return ::GetValidTypeName_Impl(type);
-}
-
-FormatManager::FormatManager() :
- m_value_nav("format",this),
- m_named_summaries_map(this),
- m_last_revision(0),
- m_categories_map(this),
- m_default_category_name(ConstString("default")),
- m_system_category_name(ConstString("system")),
- m_gnu_cpp_category_name(ConstString("gnu-libstdc++")),
- m_libcxx_category_name(ConstString("libcxx")),
- m_objc_category_name(ConstString("objc")),
- m_corefoundation_category_name(ConstString("CoreFoundation")),
- m_coregraphics_category_name(ConstString("CoreGraphics")),
- m_coreservices_category_name(ConstString("CoreServices")),
- m_vectortypes_category_name(ConstString("VectorTypes")),
- m_appkit_category_name(ConstString("AppKit"))
-{
-
- LoadSystemFormatters();
- LoadSTLFormatters();
- LoadLibcxxFormatters();
- LoadObjCFormatters();
-
- EnableCategory(m_objc_category_name,CategoryMap::Last);
- EnableCategory(m_corefoundation_category_name,CategoryMap::Last);
- EnableCategory(m_appkit_category_name,CategoryMap::Last);
- EnableCategory(m_coreservices_category_name,CategoryMap::Last);
- EnableCategory(m_coregraphics_category_name,CategoryMap::Last);
- EnableCategory(m_gnu_cpp_category_name,CategoryMap::Last);
- EnableCategory(m_libcxx_category_name,CategoryMap::Last);
- EnableCategory(m_vectortypes_category_name,CategoryMap::Last);
- EnableCategory(m_system_category_name,CategoryMap::Last);
-}
-
-void
-FormatManager::LoadSTLFormatters()
-{
- TypeSummaryImpl::Flags stl_summary_flags;
- stl_summary_flags.SetCascades(true)
- .SetSkipPointers(false)
- .SetSkipReferences(false)
- .SetDontShowChildren(true)
- .SetDontShowValue(true)
- .SetShowMembersOneLiner(false)
- .SetHideItemNames(false);
-
- lldb::TypeSummaryImplSP std_string_summary_sp(new StringSummaryFormat(stl_summary_flags,
- "${var._M_dataplus._M_p}"));
-
- TypeCategoryImpl::SharedPointer gnu_category_sp = GetCategory(m_gnu_cpp_category_name);
-
- gnu_category_sp->GetSummaryNavigator()->Add(ConstString("std::string"),
- std_string_summary_sp);
- gnu_category_sp->GetSummaryNavigator()->Add(ConstString("std::basic_string<char>"),
- std_string_summary_sp);
- gnu_category_sp->GetSummaryNavigator()->Add(ConstString("std::basic_string<char,std::char_traits<char>,std::allocator<char> >"),
- std_string_summary_sp);
- gnu_category_sp->GetSummaryNavigator()->Add(ConstString("std::basic_string<char, std::char_traits<char>, std::allocator<char> >"),
- std_string_summary_sp);
-
-
-#ifndef LLDB_DISABLE_PYTHON
-
- SyntheticChildren::Flags stl_synth_flags;
- stl_synth_flags.SetCascades(true).SetSkipPointers(false).SetSkipReferences(false);
-
- gnu_category_sp->GetRegexSyntheticNavigator()->Add(RegularExpressionSP(new RegularExpression("^std::vector<.+>(( )?&)?$")),
- SyntheticChildrenSP(new TypeSyntheticImpl(stl_synth_flags,
- "lldb.formatters.cpp.gnu_libstdcpp.StdVectorSynthProvider")));
- gnu_category_sp->GetRegexSyntheticNavigator()->Add(RegularExpressionSP(new RegularExpression("^std::map<.+> >(( )?&)?$")),
- SyntheticChildrenSP(new TypeSyntheticImpl(stl_synth_flags,
- "lldb.formatters.cpp.gnu_libstdcpp.StdMapSynthProvider")));
- gnu_category_sp->GetRegexSyntheticNavigator()->Add(RegularExpressionSP(new RegularExpression("^std::list<.+>(( )?&)?$")),
- SyntheticChildrenSP(new TypeSyntheticImpl(stl_synth_flags,
- "lldb.formatters.cpp.gnu_libstdcpp.StdListSynthProvider")));
-
- stl_summary_flags.SetDontShowChildren(false);
- gnu_category_sp->GetRegexSummaryNavigator()->Add(RegularExpressionSP(new RegularExpression("^std::vector<.+>(( )?&)?$")),
- TypeSummaryImplSP(new StringSummaryFormat(stl_summary_flags,
- "size=${svar%#}")));
- gnu_category_sp->GetRegexSummaryNavigator()->Add(RegularExpressionSP(new RegularExpression("^std::map<.+> >(( )?&)?$")),
- TypeSummaryImplSP(new StringSummaryFormat(stl_summary_flags,
- "size=${svar%#}")));
- gnu_category_sp->GetRegexSummaryNavigator()->Add(RegularExpressionSP(new RegularExpression("^std::list<.+>(( )?&)?$")),
- TypeSummaryImplSP(new StringSummaryFormat(stl_summary_flags,
- "size=${svar%#}")));
-#endif
-}
-
-void
-FormatManager::LoadLibcxxFormatters()
-{
- TypeSummaryImpl::Flags stl_summary_flags;
- stl_summary_flags.SetCascades(true)
- .SetSkipPointers(false)
- .SetSkipReferences(false)
- .SetDontShowChildren(true)
- .SetDontShowValue(true)
- .SetShowMembersOneLiner(false)
- .SetHideItemNames(false);
-
-#ifndef LLDB_DISABLE_PYTHON
- std::string code(" lldb.formatters.cpp.libcxx.stdstring_SummaryProvider(valobj,internal_dict)");
- lldb::TypeSummaryImplSP std_string_summary_sp(new ScriptSummaryFormat(stl_summary_flags, "lldb.formatters.cpp.libcxx.stdstring_SummaryProvider",code.c_str()));
-
- TypeCategoryImpl::SharedPointer libcxx_category_sp = GetCategory(m_libcxx_category_name);
-
- libcxx_category_sp->GetSummaryNavigator()->Add(ConstString("std::__1::string"),
- std_string_summary_sp);
- libcxx_category_sp->GetSummaryNavigator()->Add(ConstString("std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >"),
- std_string_summary_sp);
-
- SyntheticChildren::Flags stl_synth_flags;
- stl_synth_flags.SetCascades(true).SetSkipPointers(false).SetSkipReferences(false);
-
- libcxx_category_sp->GetRegexSyntheticNavigator()->Add(RegularExpressionSP(new RegularExpression("^std::__1::vector<.+>(( )?&)?$")),
- SyntheticChildrenSP(new TypeSyntheticImpl(stl_synth_flags,
- "lldb.formatters.cpp.libcxx.stdvector_SynthProvider")));
- libcxx_category_sp->GetRegexSyntheticNavigator()->Add(RegularExpressionSP(new RegularExpression("^std::__1::list<.+>(( )?&)?$")),
- SyntheticChildrenSP(new TypeSyntheticImpl(stl_synth_flags,
- "lldb.formatters.cpp.libcxx.stdlist_SynthProvider")));
- libcxx_category_sp->GetRegexSyntheticNavigator()->Add(RegularExpressionSP(new RegularExpression("^std::__1::map<.+> >(( )?&)?$")),
- SyntheticChildrenSP(new TypeSyntheticImpl(stl_synth_flags,
- "lldb.formatters.cpp.libcxx.stdmap_SynthProvider")));
- libcxx_category_sp->GetRegexSyntheticNavigator()->Add(RegularExpressionSP(new RegularExpression("^(std::__1::)deque<.+>(( )?&)?$")),
- SyntheticChildrenSP(new TypeSyntheticImpl(stl_synth_flags,
- "lldb.formatters.cpp.libcxx.stddeque_SynthProvider")));
- libcxx_category_sp->GetRegexSyntheticNavigator()->Add(RegularExpressionSP(new RegularExpression("^(std::__1::)shared_ptr<.+>(( )?&)?$")),
- SyntheticChildrenSP(new TypeSyntheticImpl(stl_synth_flags,
- "lldb.formatters.cpp.libcxx.stdsharedptr_SynthProvider")));
- libcxx_category_sp->GetRegexSyntheticNavigator()->Add(RegularExpressionSP(new RegularExpression("^(std::__1::)weak_ptr<.+>(( )?&)?$")),
- SyntheticChildrenSP(new TypeSyntheticImpl(stl_synth_flags,
- "lldb.formatters.cpp.libcxx.stdsharedptr_SynthProvider")));
-
- stl_summary_flags.SetDontShowChildren(false);stl_summary_flags.SetSkipPointers(true);
- libcxx_category_sp->GetRegexSummaryNavigator()->Add(RegularExpressionSP(new RegularExpression("^std::__1::vector<.+>(( )?&)?$")),
- TypeSummaryImplSP(new StringSummaryFormat(stl_summary_flags, "size=${svar%#}")));
- libcxx_category_sp->GetRegexSummaryNavigator()->Add(RegularExpressionSP(new RegularExpression("^std::__1::list<.+>(( )?&)?$")),
- TypeSummaryImplSP(new StringSummaryFormat(stl_summary_flags, "size=${svar%#}")));
- libcxx_category_sp->GetRegexSummaryNavigator()->Add(RegularExpressionSP(new RegularExpression("^std::__1::map<.+> >(( )?&)?$")),
- TypeSummaryImplSP(new StringSummaryFormat(stl_summary_flags, "size=${svar%#}")));
- libcxx_category_sp->GetRegexSummaryNavigator()->Add(RegularExpressionSP(new RegularExpression("^std::__1::deque<.+>(( )?&)?$")),
- TypeSummaryImplSP(new StringSummaryFormat(stl_summary_flags, "size=${svar%#}")));
- libcxx_category_sp->GetRegexSummaryNavigator()->Add(RegularExpressionSP(new RegularExpression("^std::__1::shared_ptr<.+>(( )?&)?$")),
- TypeSummaryImplSP(new StringSummaryFormat(stl_summary_flags, "{${var.__ptr_%S}} (strong=${var.count} weak=${var.weak_count})")));
- libcxx_category_sp->GetRegexSummaryNavigator()->Add(RegularExpressionSP(new RegularExpression("^std::__1::weak_ptr<.+>(( )?&)?$")),
- TypeSummaryImplSP(new StringSummaryFormat(stl_summary_flags, "{${var.__ptr_%S}} (strong=${var.count} weak=${var.weak_count})")));
-
-#endif
-}
-
-void
-FormatManager::LoadSystemFormatters()
-{
- lldb::TypeSummaryImplSP string_format(new StringSummaryFormat(TypeSummaryImpl::Flags().SetCascades(false)
- .SetSkipPointers(true)
- .SetSkipReferences(false)
- .SetDontShowChildren(true)
- .SetDontShowValue(false)
- .SetShowMembersOneLiner(false)
- .SetHideItemNames(false),
- "${var%s}"));
-
-
- lldb::TypeSummaryImplSP string_array_format(new StringSummaryFormat(TypeSummaryImpl::Flags().SetCascades(false)
- .SetSkipPointers(true)
- .SetSkipReferences(false)
- .SetDontShowChildren(false)
- .SetDontShowValue(true)
- .SetShowMembersOneLiner(false)
- .SetHideItemNames(false),
- "${var%s}"));
-
- lldb::RegularExpressionSP any_size_char_arr(new RegularExpression("char \\[[0-9]+\\]"));
-
- TypeCategoryImpl::SharedPointer sys_category_sp = GetCategory(m_system_category_name);
-
- sys_category_sp->GetSummaryNavigator()->Add(ConstString("char *"), string_format);
- sys_category_sp->GetSummaryNavigator()->Add(ConstString("const char *"), string_format);
- sys_category_sp->GetRegexSummaryNavigator()->Add(any_size_char_arr, string_array_format);
-
- lldb::TypeSummaryImplSP ostype_summary(new StringSummaryFormat(TypeSummaryImpl::Flags().SetCascades(false)
- .SetSkipPointers(true)
- .SetSkipReferences(true)
- .SetDontShowChildren(true)
- .SetDontShowValue(false)
- .SetShowMembersOneLiner(false)
- .SetHideItemNames(false),
- "${var%O}"));
-
- sys_category_sp->GetSummaryNavigator()->Add(ConstString("OSType"), ostype_summary);
-}
-
-static void
-AddStringSummary(TypeCategoryImpl::SharedPointer category_sp,
- const char* string,
- ConstString type_name,
- TypeSummaryImpl::Flags flags)
-{
- lldb::TypeSummaryImplSP summary_sp(new StringSummaryFormat(flags,
- string));
- category_sp->GetSummaryNavigator()->Add(type_name,
- summary_sp);
-}
-
-#ifndef LLDB_DISABLE_PYTHON
-static void
-AddScriptSummary(TypeCategoryImpl::SharedPointer category_sp,
- const char* funct_name,
- ConstString type_name,
- TypeSummaryImpl::Flags flags)
-{
-
- std::string code(" ");
- code.append(funct_name).append("(valobj,internal_dict)");
-
- lldb::TypeSummaryImplSP summary_sp(new ScriptSummaryFormat(flags,
- funct_name,
- code.c_str()));
- category_sp->GetSummaryNavigator()->Add(type_name,
- summary_sp);
-}
-#endif
-
-#ifndef LLDB_DISABLE_PYTHON
-static void
-AddCXXSummary (TypeCategoryImpl::SharedPointer category_sp,
- CXXFunctionSummaryFormat::Callback funct,
- const char* description,
- ConstString type_name,
- TypeSummaryImpl::Flags flags)
-{
- lldb::TypeSummaryImplSP summary_sp(new CXXFunctionSummaryFormat(flags,funct,description));
- category_sp->GetSummaryNavigator()->Add(type_name,
- summary_sp);
-}
-#endif
-
-#ifndef LLDB_DISABLE_PYTHON
-static void AddCXXSynthetic (TypeCategoryImpl::SharedPointer category_sp,
- CXXSyntheticChildren::CreateFrontEndCallback generator,
- const char* description,
- ConstString type_name,
- TypeSyntheticImpl::Flags flags)
-{
- lldb::SyntheticChildrenSP synth_sp(new CXXSyntheticChildren(flags,description,generator));
- category_sp->GetSyntheticNavigator()->Add(type_name,synth_sp);
-}
-#endif
-
-void
-FormatManager::LoadObjCFormatters()
-{
- TypeSummaryImpl::Flags objc_flags;
- objc_flags.SetCascades(false)
- .SetSkipPointers(true)
- .SetSkipReferences(true)
- .SetDontShowChildren(true)
- .SetDontShowValue(true)
- .SetShowMembersOneLiner(false)
- .SetHideItemNames(false);
-
- TypeCategoryImpl::SharedPointer objc_category_sp = GetCategory(m_objc_category_name);
-
- lldb::TypeSummaryImplSP ObjC_BOOL_summary(new CXXFunctionSummaryFormat(objc_flags, lldb_private::formatters::ObjCBOOLSummaryProvider,""));
- objc_category_sp->GetSummaryNavigator()->Add(ConstString("BOOL"),
- ObjC_BOOL_summary);
- objc_category_sp->GetSummaryNavigator()->Add(ConstString("BOOL &"),
- ObjC_BOOL_summary);
- objc_category_sp->GetSummaryNavigator()->Add(ConstString("BOOL *"),
- ObjC_BOOL_summary);
-
- // we need to skip pointers here since we are special casing a SEL* when retrieving its value
- objc_flags.SetSkipPointers(true);
-#ifndef LLDB_DISABLE_PYTHON
- AddCXXSummary(objc_category_sp, lldb_private::formatters::ObjCSELSummaryProvider<false>, "SEL summary", ConstString("SEL"), objc_flags);
- AddCXXSummary(objc_category_sp, lldb_private::formatters::ObjCSELSummaryProvider<false>, "SEL summary", ConstString("struct objc_selector"), objc_flags);
- AddCXXSummary(objc_category_sp, lldb_private::formatters::ObjCSELSummaryProvider<false>, "SEL summary", ConstString("objc_selector"), objc_flags);
- AddCXXSummary(objc_category_sp, lldb_private::formatters::ObjCSELSummaryProvider<true>, "SEL summary", ConstString("objc_selector *"), objc_flags);
-
- AddScriptSummary(objc_category_sp, "lldb.formatters.objc.Class.Class_Summary", ConstString("Class"), objc_flags);
-#endif // LLDB_DISABLE_PYTHON
-
- objc_flags.SetSkipPointers(false);
-
- TypeCategoryImpl::SharedPointer corefoundation_category_sp = GetCategory(m_corefoundation_category_name);
-
- AddStringSummary(corefoundation_category_sp,
- "${var.years} years, ${var.months} months, ${var.days} days, ${var.hours} hours, ${var.minutes} minutes ${var.seconds} seconds",
- ConstString("CFGregorianUnits"),
- objc_flags);
- AddStringSummary(corefoundation_category_sp,
- "location=${var.location} length=${var.length}",
- ConstString("CFRange"),
- objc_flags);
- AddStringSummary(corefoundation_category_sp,
- "(x=${var.x}, y=${var.y})",
- ConstString("NSPoint"),
- objc_flags);
- AddStringSummary(corefoundation_category_sp,
- "location=${var.location}, length=${var.length}",
- ConstString("NSRange"),
- objc_flags);
- AddStringSummary(corefoundation_category_sp,
- "${var.origin}, ${var.size}",
- ConstString("NSRect"),
- objc_flags);
- AddStringSummary(corefoundation_category_sp,
- "(${var.origin}, ${var.size}), ...",
- ConstString("NSRectArray"),
- objc_flags);
- AddStringSummary(objc_category_sp,
- "(width=${var.width}, height=${var.height})",
- ConstString("NSSize"),
- objc_flags);
-
- TypeCategoryImpl::SharedPointer coregraphics_category_sp = GetCategory(m_coregraphics_category_name);
-
- AddStringSummary(coregraphics_category_sp,
- "(width=${var.width}, height=${var.height})",
- ConstString("CGSize"),
- objc_flags);
- AddStringSummary(coregraphics_category_sp,
- "(x=${var.x}, y=${var.y})",
- ConstString("CGPoint"),
- objc_flags);
- AddStringSummary(coregraphics_category_sp,
- "origin=${var.origin} size=${var.size}",
- ConstString("CGRect"),
- objc_flags);
-
- TypeCategoryImpl::SharedPointer coreservices_category_sp = GetCategory(m_coreservices_category_name);
-
- AddStringSummary(coreservices_category_sp,
- "red=${var.red} green=${var.green} blue=${var.blue}",
- ConstString("RGBColor"),
- objc_flags);
- AddStringSummary(coreservices_category_sp,
- "(t=${var.top}, l=${var.left}, b=${var.bottom}, r=${var.right})",
- ConstString("Rect"),
- objc_flags);
- AddStringSummary(coreservices_category_sp,
- "(v=${var.v}, h=${var.h})",
- ConstString("Point"),
- objc_flags);
- AddStringSummary(coreservices_category_sp,
- "${var.month}/${var.day}/${var.year} ${var.hour} :${var.minute} :${var.second} dayOfWeek:${var.dayOfWeek}",
- ConstString("DateTimeRect *"),
- objc_flags);
- AddStringSummary(coreservices_category_sp,
- "${var.ld.month}/${var.ld.day}/${var.ld.year} ${var.ld.hour} :${var.ld.minute} :${var.ld.second} dayOfWeek:${var.ld.dayOfWeek}",
- ConstString("LongDateRect"),
- objc_flags);
- AddStringSummary(coreservices_category_sp,
- "(x=${var.x}, y=${var.y})",
- ConstString("HIPoint"),
- objc_flags);
- AddStringSummary(coreservices_category_sp,
- "origin=${var.origin} size=${var.size}",
- ConstString("HIRect"),
- objc_flags);
-
- TypeCategoryImpl::SharedPointer appkit_category_sp = GetCategory(m_appkit_category_name);
-
- TypeSummaryImpl::Flags appkit_flags;
- appkit_flags.SetCascades(true)
- .SetSkipPointers(false)
- .SetSkipReferences(false)
- .SetDontShowChildren(true)
- .SetDontShowValue(false)
- .SetShowMembersOneLiner(false)
- .SetHideItemNames(false);
-
- appkit_flags.SetDontShowChildren(false);
-
-#ifndef LLDB_DISABLE_PYTHON
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSArraySummaryProvider, "NSArray summary provider", ConstString("NSArray"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSArraySummaryProvider, "NSArray summary provider", ConstString("NSMutableArray"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSArraySummaryProvider, "NSArray summary provider", ConstString("__NSArrayI"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSArraySummaryProvider, "NSArray summary provider", ConstString("__NSArrayM"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSArraySummaryProvider, "NSArray summary provider", ConstString("__NSCFArray"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSArraySummaryProvider, "NSArray summary provider", ConstString("CFArrayRef"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSArraySummaryProvider, "NSArray summary provider", ConstString("CFMutableArrayRef"), appkit_flags);
-
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSDictionarySummaryProvider<false>, "NSDictionary summary provider", ConstString("NSDictionary"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSDictionarySummaryProvider<false>, "NSDictionary summary provider", ConstString("NSMutableDictionary"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSDictionarySummaryProvider<false>, "NSDictionary summary provider", ConstString("__NSCFDictionary"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSDictionarySummaryProvider<false>, "NSDictionary summary provider", ConstString("__NSDictionaryI"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSDictionarySummaryProvider<false>, "NSDictionary summary provider", ConstString("__NSDictionaryM"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSDictionarySummaryProvider<true>, "NSDictionary summary provider", ConstString("CFDictionaryRef"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSDictionarySummaryProvider<true>, "NSDictionary summary provider", ConstString("CFMutableDictionaryRef"), appkit_flags);
-#endif
- // AddSummary(appkit_category_sp, "${var.key%@} -> ${var.value%@}", ConstString("$_lldb_typegen_nspair"), appkit_flags);
-
- appkit_flags.SetDontShowChildren(true);
-
-#ifndef LLDB_DISABLE_PYTHON
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSArraySyntheticFrontEndCreator, "NSArray synthetic children", ConstString("__NSArrayM"), TypeSyntheticImpl::Flags());
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSArraySyntheticFrontEndCreator, "NSArray synthetic children", ConstString("__NSArrayI"), TypeSyntheticImpl::Flags());
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSArraySyntheticFrontEndCreator, "NSArray synthetic children", ConstString("NSArray"), TypeSyntheticImpl::Flags());
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSArraySyntheticFrontEndCreator, "NSArray synthetic children", ConstString("NSMutableArray"), TypeSyntheticImpl::Flags());
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSArraySyntheticFrontEndCreator, "NSArray synthetic children", ConstString("__NSCFArray"), TypeSyntheticImpl::Flags());
-
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSDictionarySyntheticFrontEndCreator, "NSDictionary synthetic children", ConstString("__NSDictionaryM"), TypeSyntheticImpl::Flags());
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSDictionarySyntheticFrontEndCreator, "NSDictionary synthetic children", ConstString("__NSDictionaryI"), TypeSyntheticImpl::Flags());
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSDictionarySyntheticFrontEndCreator, "NSDictionary synthetic children", ConstString("NSDictionary"), TypeSyntheticImpl::Flags());
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSDictionarySyntheticFrontEndCreator, "NSDictionary synthetic children", ConstString("NSMutableDictionary"), TypeSyntheticImpl::Flags());
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSDictionarySyntheticFrontEndCreator, "NSDictionary synthetic children", ConstString("CFDictionaryRef"), TypeSyntheticImpl::Flags());
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSDictionarySyntheticFrontEndCreator, "NSDictionary synthetic children", ConstString("CFMutableDictionaryRef"), TypeSyntheticImpl::Flags());
-
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFBag.CFBag_SummaryProvider", ConstString("CFBagRef"), appkit_flags);
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFBag.CFBag_SummaryProvider", ConstString("__CFBag"), appkit_flags);
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFBag.CFBag_SummaryProvider", ConstString("const struct __CFBag"), appkit_flags);
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFBag.CFBag_SummaryProvider", ConstString("CFMutableBagRef"), appkit_flags);
-
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFBinaryHeap.CFBinaryHeap_SummaryProvider", ConstString("CFBinaryHeapRef"), appkit_flags);
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFBinaryHeap.CFBinaryHeap_SummaryProvider", ConstString("__CFBinaryHeap"), appkit_flags);
-
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSStringSummaryProvider, "NSString summary provider", ConstString("NSString"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSStringSummaryProvider, "NSString summary provider", ConstString("CFStringRef"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSStringSummaryProvider, "NSString summary provider", ConstString("CFMutableStringRef"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSStringSummaryProvider, "NSString summary provider", ConstString("__NSCFConstantString"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSStringSummaryProvider, "NSString summary provider", ConstString("__NSCFString"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSStringSummaryProvider, "NSString summary provider", ConstString("NSCFConstantString"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSStringSummaryProvider, "NSString summary provider", ConstString("NSCFString"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSStringSummaryProvider, "NSString summary provider", ConstString("NSPathStore2"), appkit_flags);
-
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFString.CFAttributedString_SummaryProvider", ConstString("NSAttributedString"), appkit_flags);
-
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSBundle.NSBundle_SummaryProvider", ConstString("NSBundle"), appkit_flags);
-
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSDataSummaryProvider<false>, "NSData summary provider", ConstString("NSData"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSDataSummaryProvider<false>, "NSData summary provider", ConstString("NSConcreteData"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSDataSummaryProvider<false>, "NSData summary provider", ConstString("NSConcreteMutableData"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSDataSummaryProvider<false>, "NSData summary provider", ConstString("__NSCFData"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSDataSummaryProvider<true>, "NSData summary provider", ConstString("CFDataRef"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSDataSummaryProvider<true>, "NSData summary provider", ConstString("CFMutableDataRef"), appkit_flags);
-
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSException.NSException_SummaryProvider", ConstString("NSException"), appkit_flags);
-
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSMachPort.NSMachPort_SummaryProvider", ConstString("NSMachPort"), appkit_flags);
-
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSNotification.NSNotification_SummaryProvider", ConstString("NSNotification"), appkit_flags);
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSNotification.NSNotification_SummaryProvider", ConstString("NSConcreteNotification"), appkit_flags);
-
- AddStringSummary(appkit_category_sp, "domain: ${var._domain} - code: ${var._code}", ConstString("NSError"), appkit_flags);
-
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSNumberSummaryProvider, "NSNumber summary provider", ConstString("NSNumber"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSNumberSummaryProvider, "NSNumber summary provider", ConstString("__NSCFBoolean"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSNumberSummaryProvider, "NSNumber summary provider", ConstString("__NSCFNumber"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSNumberSummaryProvider, "NSNumber summary provider", ConstString("NSCFBoolean"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSNumberSummaryProvider, "NSNumber summary provider", ConstString("NSCFNumber"), appkit_flags);
-
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::RuntimeSpecificDescriptionSummaryProvider, "NSDecimalNumber summary provider", ConstString("NSDecimalNumber"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::RuntimeSpecificDescriptionSummaryProvider, "NSHost summary provider", ConstString("NSHost"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::RuntimeSpecificDescriptionSummaryProvider, "NSTask summary provider", ConstString("NSTask"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::RuntimeSpecificDescriptionSummaryProvider, "NSValue summary provider", ConstString("NSValue"), appkit_flags);
-
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSSet.NSSet_SummaryProvider", ConstString("NSSet"), appkit_flags);
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSSet.NSSet_SummaryProvider2", ConstString("CFSetRef"), appkit_flags);
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSSet.NSSet_SummaryProvider2", ConstString("CFMutableSetRef"), appkit_flags);
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSSet.NSSet_SummaryProvider", ConstString("__NSCFSet"), appkit_flags);
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSSet.NSSet_SummaryProvider", ConstString("__NSSetI"), appkit_flags);
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSSet.NSSet_SummaryProvider", ConstString("__NSSetM"), appkit_flags);
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSSet.NSSet_SummaryProvider", ConstString("NSCountedSet"), appkit_flags);
-
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSURL.NSURL_SummaryProvider", ConstString("NSURL"), appkit_flags);
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSURL.NSURL_SummaryProvider", ConstString("CFURLRef"), appkit_flags);
-
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSDate.NSDate_SummaryProvider", ConstString("NSDate"), appkit_flags);
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSDate.NSDate_SummaryProvider", ConstString("__NSDate"), appkit_flags);
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSDate.NSDate_SummaryProvider", ConstString("__NSTaggedDate"), appkit_flags);
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSDate.NSDate_SummaryProvider", ConstString("NSCalendarDate"), appkit_flags);
-
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSDate.NSTimeZone_SummaryProvider", ConstString("NSTimeZone"), appkit_flags);
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSDate.NSTimeZone_SummaryProvider", ConstString("CFTimeZoneRef"), appkit_flags);
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSDate.NSTimeZone_SummaryProvider", ConstString("__NSTimeZone"), appkit_flags);
-
- // CFAbsoluteTime is actually a double rather than a pointer to an object
- // we do not care about the numeric value, since it is probably meaningless to users
- appkit_flags.SetDontShowValue(true);
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSDate.CFAbsoluteTime_SummaryProvider", ConstString("CFAbsoluteTime"), appkit_flags);
- appkit_flags.SetDontShowValue(false);
-
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSIndexSet.NSIndexSet_SummaryProvider", ConstString("NSIndexSet"), appkit_flags);
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSIndexSet.NSIndexSet_SummaryProvider", ConstString("NSMutableIndexSet"), appkit_flags);
-
- AddStringSummary(appkit_category_sp,
- "@\"${var.month%d}/${var.day%d}/${var.year%d} ${var.hour%d}:${var.minute%d}:${var.second}\"",
- ConstString("CFGregorianDate"),
- appkit_flags);
-
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFBitVector.CFBitVector_SummaryProvider", ConstString("CFBitVectorRef"), appkit_flags);
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFBitVector.CFBitVector_SummaryProvider", ConstString("CFMutableBitVectorRef"), appkit_flags);
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFBitVector.CFBitVector_SummaryProvider", ConstString("__CFBitVector"), appkit_flags);
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFBitVector.CFBitVector_SummaryProvider", ConstString("__CFMutableBitVector"), appkit_flags);
-#endif // LLDB_DISABLE_PYTHON
-
- TypeCategoryImpl::SharedPointer vectors_category_sp = GetCategory(m_vectortypes_category_name);
-
- TypeSummaryImpl::Flags vector_flags;
- vector_flags.SetCascades(true)
- .SetSkipPointers(true)
- .SetSkipReferences(false)
- .SetDontShowChildren(true)
- .SetDontShowValue(false)
- .SetShowMembersOneLiner(true)
- .SetHideItemNames(true);
-
- AddStringSummary(vectors_category_sp,
- "${var.uint128}",
- ConstString("builtin_type_vec128"),
- objc_flags);
-
- AddStringSummary(vectors_category_sp,
- "",
- ConstString("float [4]"),
- vector_flags);
- AddStringSummary(vectors_category_sp,
- "",
- ConstString("int32_t [4]"),
- vector_flags);
- AddStringSummary(vectors_category_sp,
- "",
- ConstString("int16_t [8]"),
- vector_flags);
- AddStringSummary(vectors_category_sp,
- "",
- ConstString("vDouble"),
- vector_flags);
- AddStringSummary(vectors_category_sp,
- "",
- ConstString("vFloat"),
- vector_flags);
- AddStringSummary(vectors_category_sp,
- "",
- ConstString("vSInt8"),
- vector_flags);
- AddStringSummary(vectors_category_sp,
- "",
- ConstString("vSInt16"),
- vector_flags);
- AddStringSummary(vectors_category_sp,
- "",
- ConstString("vSInt32"),
- vector_flags);
- AddStringSummary(vectors_category_sp,
- "",
- ConstString("vUInt16"),
- vector_flags);
- AddStringSummary(vectors_category_sp,
- "",
- ConstString("vUInt8"),
- vector_flags);
- AddStringSummary(vectors_category_sp,
- "",
- ConstString("vUInt16"),
- vector_flags);
- AddStringSummary(vectors_category_sp,
- "",
- ConstString("vUInt32"),
- vector_flags);
- AddStringSummary(vectors_category_sp,
- "",
- ConstString("vBool32"),
- vector_flags);
-}
Modified: lldb/branches/windows/source/Core/History.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/History.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/History.cpp (original)
+++ lldb/branches/windows/source/Core/History.cpp Wed Apr 17 03:38:48 2013
@@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
#include "lldb/Core/History.h"
+#include "lldb/lldb-private.h"
// C Includes
#ifndef _WIN32
@@ -24,9 +25,5 @@ using namespace lldb_private;
void
HistorySourceUInt::DumpHistoryEvent (Stream &strm, HistoryEvent event)
{
-#if _WIN32
- strm.Printf ("%s %llu", m_name.c_str(), (uint64_t)((uintptr_t)event));
-#else
strm.Printf ("%s %" PRIu64, m_name.c_str(), (uint64_t)((uintptr_t)event));
-#endif
}
Modified: lldb/branches/windows/source/Core/Listener.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/Listener.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/Listener.cpp (original)
+++ lldb/branches/windows/source/Core/Listener.cpp Wed Apr 17 03:38:48 2013
@@ -32,14 +32,14 @@ Listener::Listener(const char *name) :
m_events_mutex (Mutex::eMutexTypeRecursive),
m_cond_wait()
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
if (log)
log->Printf ("%p Listener::Listener('%s')", this, m_name.c_str());
}
Listener::~Listener()
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
Mutex::Locker locker (m_broadcasters_mutex);
size_t num_managers = m_broadcaster_managers.size();
@@ -84,7 +84,7 @@ Listener::StartListeningForEvents (Broad
{
}
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EVENTS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EVENTS));
if (log)
log->Printf ("%p Listener::StartListeningForEvents (broadcaster = %p, mask = 0x%8.8x) acquired_mask = 0x%8.8x for %s",
this,
@@ -113,7 +113,7 @@ Listener::StartListeningForEvents (Broad
uint32_t acquired_mask = broadcaster->AddListener (this, event_mask);
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EVENTS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EVENTS));
if (log)
log->Printf ("%p Listener::StartListeningForEvents (broadcaster = %p, mask = 0x%8.8x, callback = %p, user_data = %p) acquired_mask = 0x%8.8x for %s",
this, broadcaster, event_mask, callback, callback_user_data, acquired_mask, m_name.c_str());
@@ -183,7 +183,7 @@ Listener::BroadcasterManagerWillDestruct
void
Listener::AddEvent (EventSP &event_sp)
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EVENTS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EVENTS));
if (log)
log->Printf ("%p Listener('%s')::AddEvent (event_sp = {%p})", this, m_name.c_str(), event_sp.get());
@@ -270,7 +270,7 @@ Listener::FindNextEventInternal
EventSP &event_sp,
bool remove)
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EVENTS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EVENTS));
Mutex::Locker lock(m_events_mutex);
@@ -400,7 +400,7 @@ Listener::WaitForEventsInternal
EventSP &event_sp
)
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EVENTS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EVENTS));
bool timed_out = false;
if (log)
Modified: lldb/branches/windows/source/Core/Log.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/Log.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/Log.cpp (original)
+++ lldb/branches/windows/source/Core/Log.cpp Wed Apr 17 03:38:48 2013
@@ -49,7 +49,7 @@ Log::Log () :
{
}
-Log::Log (StreamSP &stream_sp) :
+Log::Log (const StreamSP &stream_sp) :
m_stream_sp(stream_sp),
m_options(0),
m_mask_bits(0)
@@ -120,10 +120,9 @@ Log::PrintfWithFlagsVarArg (uint32_t fla
// Add the process and thread if requested
if (m_options.Test (LLDB_LOG_OPTION_PREPEND_THREAD_NAME))
{
- const char *thread_name_str = Host::GetThreadName (getpid(), Host::GetCurrentThreadID());
- if (thread_name_str)
- header.Printf ("%s ", thread_name_str);
-
+ std::string thread_name (Host::GetThreadName (getpid(), Host::GetCurrentThreadID()));
+ if (!thread_name.empty())
+ header.Printf ("%s ", thread_name.c_str());
}
header.PrintfVarArg (format, args);
@@ -526,7 +525,7 @@ LogChannel::FindPlugin (const char *plug
}
LogChannel::LogChannel () :
- m_log_sp ()
+ m_log_ap ()
{
}
Modified: lldb/branches/windows/source/Core/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/Makefile?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/Makefile (original)
+++ lldb/branches/windows/source/Core/Makefile Wed Apr 17 03:38:48 2013
@@ -11,15 +11,16 @@ LLDB_LEVEL := ../..
LIBRARYNAME := lldbCore
BUILD_ARCHIVE = 1
+include $(LLDB_LEVEL)/Makefile
+
# Enable RTTI on GCC builds because one source file in this directory
# (cxa_demangle.cpp) uses dynamic_cast<> and GCC (at least 4.6 and 4.7)
-# complain if we try to compile it with -fno-rtti. This is somewhat of a
-# kludge because it forces us to enable RTTI in liblldbUtility.a and also
-# link in additional clang static libraries to resolve vtable references,
-# but actually has negligible impact on (shard object) file size.
+# complain if we try to compile it with -fno-rtti.
$(info shell basename CXX is $(shell basename $(CXX)))
ifeq (g++,$(shell basename $(CXX)))
- REQUIRES_RTTI = 1
+$(ObjDir)/cxa_demangle.o: Compile.CXX := $(filter-out -fno-rtti,$(Compile.CXX)) -frtti
endif
-include $(LLDB_LEVEL)/Makefile
+ifeq (Darwin,$(shell uname -s))
+$(ObjDir)/cxa_demangle.o: Compile.CXX := $(filter-out -fno-rtti,$(Compile.CXX)) -frtti
+endif
Modified: lldb/branches/windows/source/Core/Module.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/Module.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/Module.cpp (original)
+++ lldb/branches/windows/source/Core/Module.cpp Wed Apr 17 03:38:48 2013
@@ -29,6 +29,8 @@
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Symbol/SymbolVendor.h"
+#include "lldb/Target/CPPLanguageRuntime.h"
+#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
@@ -152,7 +154,7 @@ Module::Module (const ModuleSpec &module
GetModuleCollection().push_back(this);
}
- LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_OBJECT|LIBLLDB_LOG_MODULES));
+ Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_OBJECT|LIBLLDB_LOG_MODULES));
if (log)
log->Printf ("%p Module::Module((%s) '%s/%s%s%s%s')",
this,
@@ -197,7 +199,7 @@ Module::Module(const FileSpec& file_spec
if (object_name)
m_object_name = *object_name;
- LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_OBJECT|LIBLLDB_LOG_MODULES));
+ Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_OBJECT|LIBLLDB_LOG_MODULES));
if (log)
log->Printf ("%p Module::Module((%s) '%s/%s%s%s%s')",
this,
@@ -220,7 +222,7 @@ Module::~Module()
assert (pos != end);
modules.erase(pos);
}
- LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_OBJECT|LIBLLDB_LOG_MODULES));
+ Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_OBJECT|LIBLLDB_LOG_MODULES));
if (log)
log->Printf ("%p Module::~Module((%s) '%s/%s%s%s%s')",
this,
@@ -346,16 +348,15 @@ void
Module::ParseAllDebugSymbols()
{
Mutex::Locker locker (m_mutex);
- uint32_t num_comp_units = GetNumCompileUnits();
+ size_t num_comp_units = GetNumCompileUnits();
if (num_comp_units == 0)
return;
SymbolContext sc;
sc.module_sp = shared_from_this();
- uint32_t cu_idx;
SymbolVendor *symbols = GetSymbolVendor ();
- for (cu_idx = 0; cu_idx < num_comp_units; cu_idx++)
+ for (size_t cu_idx = 0; cu_idx < num_comp_units; cu_idx++)
{
sc.comp_unit = symbols->GetCompileUnitAtIndex(cu_idx).get();
if (sc.comp_unit)
@@ -365,8 +366,7 @@ Module::ParseAllDebugSymbols()
symbols->ParseCompileUnitFunctions(sc);
- uint32_t func_idx;
- for (func_idx = 0; (sc.function = sc.comp_unit->GetFunctionAtIndex(func_idx).get()) != NULL; ++func_idx)
+ for (size_t func_idx = 0; (sc.function = sc.comp_unit->GetFunctionAtIndex(func_idx).get()) != NULL; ++func_idx)
{
symbols->ParseFunctionBlocks(sc);
@@ -400,7 +400,7 @@ Module::DumpSymbolContext(Stream *s)
s->Printf(", Module{%p}", this);
}
-uint32_t
+size_t
Module::GetNumCompileUnits()
{
Mutex::Locker locker (m_mutex);
@@ -412,10 +412,10 @@ Module::GetNumCompileUnits()
}
CompUnitSP
-Module::GetCompileUnitAtIndex (uint32_t index)
+Module::GetCompileUnitAtIndex (size_t index)
{
Mutex::Locker locker (m_mutex);
- uint32_t num_comp_units = GetNumCompileUnits ();
+ size_t num_comp_units = GetNumCompileUnits ();
CompUnitSP cu_sp;
if (index < num_comp_units)
@@ -444,8 +444,8 @@ Module::ResolveSymbolContextForAddress (
Mutex::Locker locker (m_mutex);
uint32_t resolved_flags = 0;
- // Clear the result symbol context in case we don't find anything
- sc.Clear();
+ // Clear the result symbol context in case we don't find anything, but don't clear the target
+ sc.Clear(false);
// Get the section from the section/offset address.
SectionSP section_sp (so_addr.GetSection());
@@ -529,16 +529,24 @@ Module::ResolveSymbolContextsForFileSpec
}
-uint32_t
-Module::FindGlobalVariables(const ConstString &name, const ClangNamespaceDecl *namespace_decl, bool append, uint32_t max_matches, VariableList& variables)
+size_t
+Module::FindGlobalVariables (const ConstString &name,
+ const ClangNamespaceDecl *namespace_decl,
+ bool append,
+ size_t max_matches,
+ VariableList& variables)
{
SymbolVendor *symbols = GetSymbolVendor ();
if (symbols)
return symbols->FindGlobalVariables(name, namespace_decl, append, max_matches, variables);
return 0;
}
-uint32_t
-Module::FindGlobalVariables(const RegularExpression& regex, bool append, uint32_t max_matches, VariableList& variables)
+
+size_t
+Module::FindGlobalVariables (const RegularExpression& regex,
+ bool append,
+ size_t max_matches,
+ VariableList& variables)
{
SymbolVendor *symbols = GetSymbolVendor ();
if (symbols)
@@ -546,7 +554,7 @@ Module::FindGlobalVariables(const Regula
return 0;
}
-uint32_t
+size_t
Module::FindCompileUnits (const FileSpec &path,
bool append,
SymbolContextList &sc_list)
@@ -554,12 +562,12 @@ Module::FindCompileUnits (const FileSpec
if (!append)
sc_list.Clear();
- const uint32_t start_size = sc_list.GetSize();
- const uint32_t num_compile_units = GetNumCompileUnits();
+ const size_t start_size = sc_list.GetSize();
+ const size_t num_compile_units = GetNumCompileUnits();
SymbolContext sc;
sc.module_sp = shared_from_this();
const bool compare_directory = path.GetDirectory();
- for (uint32_t i=0; i<num_compile_units; ++i)
+ for (size_t i=0; i<num_compile_units; ++i)
{
sc.comp_unit = GetCompileUnitAtIndex(i).get();
if (sc.comp_unit)
@@ -571,10 +579,10 @@ Module::FindCompileUnits (const FileSpec
return sc_list.GetSize() - start_size;
}
-uint32_t
+size_t
Module::FindFunctions (const ConstString &name,
const ClangNamespaceDecl *namespace_decl,
- uint32_t name_type_mask,
+ uint32_t name_type_mask,
bool include_symbols,
bool include_inlines,
bool append,
@@ -583,42 +591,86 @@ Module::FindFunctions (const ConstString
if (!append)
sc_list.Clear();
- const uint32_t start_size = sc_list.GetSize();
+ const size_t old_size = sc_list.GetSize();
// Find all the functions (not symbols, but debug information functions...
SymbolVendor *symbols = GetSymbolVendor ();
- if (symbols)
- symbols->FindFunctions(name, namespace_decl, name_type_mask, include_inlines, append, sc_list);
-
- // Now check our symbol table for symbols that are code symbols if requested
- if (include_symbols)
+
+ if (name_type_mask & eFunctionNameTypeAuto)
{
- ObjectFile *objfile = GetObjectFile();
- if (objfile)
+ ConstString lookup_name;
+ uint32_t lookup_name_type_mask = 0;
+ bool match_name_after_lookup = false;
+ Module::PrepareForFunctionNameLookup (name,
+ name_type_mask,
+ lookup_name,
+ lookup_name_type_mask,
+ match_name_after_lookup);
+
+ if (symbols)
+ symbols->FindFunctions(lookup_name,
+ namespace_decl,
+ lookup_name_type_mask,
+ include_inlines,
+ append,
+ sc_list);
+
+ // Now check our symbol table for symbols that are code symbols if requested
+ if (include_symbols)
{
- Symtab *symtab = objfile->GetSymtab();
- if (symtab)
+ ObjectFile *objfile = GetObjectFile();
+ if (objfile)
{
- std::vector<uint32_t> symbol_indexes;
- symtab->FindAllSymbolsWithNameAndType (name, eSymbolTypeCode, Symtab::eDebugAny, Symtab::eVisibilityAny, symbol_indexes);
- const uint32_t num_matches = symbol_indexes.size();
- if (num_matches)
+ Symtab *symtab = objfile->GetSymtab();
+ if (symtab)
+ symtab->FindFunctionSymbols(lookup_name, lookup_name_type_mask, sc_list);
+ }
+ }
+
+ if (match_name_after_lookup)
+ {
+ SymbolContext sc;
+ size_t i = old_size;
+ while (i<sc_list.GetSize())
+ {
+ if (sc_list.GetContextAtIndex(i, sc))
{
- const bool merge_symbol_into_function = true;
- SymbolContext sc(this);
- for (uint32_t i=0; i<num_matches; i++)
+ const char *func_name = sc.GetFunctionName().GetCString();
+ if (func_name && strstr (func_name, name.GetCString()) == NULL)
{
- sc.symbol = symtab->SymbolAtIndex(symbol_indexes[i]);
- sc_list.AppendIfUnique (sc, merge_symbol_into_function);
+ // Remove the current context
+ sc_list.RemoveContextAtIndex(i);
+ // Don't increment i and continue in the loop
+ continue;
}
}
+ ++i;
}
}
+
}
- return sc_list.GetSize() - start_size;
+ else
+ {
+ if (symbols)
+ symbols->FindFunctions(name, namespace_decl, name_type_mask, include_inlines, append, sc_list);
+
+ // Now check our symbol table for symbols that are code symbols if requested
+ if (include_symbols)
+ {
+ ObjectFile *objfile = GetObjectFile();
+ if (objfile)
+ {
+ Symtab *symtab = objfile->GetSymtab();
+ if (symtab)
+ symtab->FindFunctionSymbols(name, name_type_mask, sc_list);
+ }
+ }
+ }
+
+ return sc_list.GetSize() - old_size;
}
-uint32_t
+size_t
Module::FindFunctions (const RegularExpression& regex,
bool include_symbols,
bool include_inlines,
@@ -628,7 +680,7 @@ Module::FindFunctions (const RegularExpr
if (!append)
sc_list.Clear();
- const uint32_t start_size = sc_list.GetSize();
+ const size_t start_size = sc_list.GetSize();
SymbolVendor *symbols = GetSymbolVendor ();
if (symbols)
@@ -643,16 +695,19 @@ Module::FindFunctions (const RegularExpr
if (symtab)
{
std::vector<uint32_t> symbol_indexes;
- symtab->AppendSymbolIndexesMatchingRegExAndType (regex, eSymbolTypeCode, Symtab::eDebugAny, Symtab::eVisibilityAny, symbol_indexes);
- const uint32_t num_matches = symbol_indexes.size();
+ symtab->AppendSymbolIndexesMatchingRegExAndType (regex, eSymbolTypeAny, Symtab::eDebugAny, Symtab::eVisibilityAny, symbol_indexes);
+ const size_t num_matches = symbol_indexes.size();
if (num_matches)
{
const bool merge_symbol_into_function = true;
SymbolContext sc(this);
- for (uint32_t i=0; i<num_matches; i++)
+ for (size_t i=0; i<num_matches; i++)
{
sc.symbol = symtab->SymbolAtIndex(symbol_indexes[i]);
- sc_list.AppendIfUnique (sc, merge_symbol_into_function);
+ SymbolType sym_type = sc.symbol->GetType();
+ if (sc.symbol && (sym_type == eSymbolTypeCode ||
+ sym_type == eSymbolTypeResolver))
+ sc_list.AppendIfUnique (sc, merge_symbol_into_function);
}
}
}
@@ -661,12 +716,12 @@ Module::FindFunctions (const RegularExpr
return sc_list.GetSize() - start_size;
}
-uint32_t
+size_t
Module::FindTypes_Impl (const SymbolContext& sc,
const ConstString &name,
const ClangNamespaceDecl *namespace_decl,
bool append,
- uint32_t max_matches,
+ size_t max_matches,
TypeList& types)
{
Timer scoped_timer(__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
@@ -679,11 +734,11 @@ Module::FindTypes_Impl (const SymbolCont
return 0;
}
-uint32_t
+size_t
Module::FindTypesInNamespace (const SymbolContext& sc,
const ConstString &type_name,
const ClangNamespaceDecl *namespace_decl,
- uint32_t max_matches,
+ size_t max_matches,
TypeList& type_list)
{
const bool append = true;
@@ -696,21 +751,21 @@ Module::FindFirstType (const SymbolConte
bool exact_match)
{
TypeList type_list;
- const uint32_t num_matches = FindTypes (sc, name, exact_match, 1, type_list);
+ const size_t num_matches = FindTypes (sc, name, exact_match, 1, type_list);
if (num_matches)
return type_list.GetTypeAtIndex(0);
return TypeSP();
}
-uint32_t
+size_t
Module::FindTypes (const SymbolContext& sc,
const ConstString &name,
bool exact_match,
- uint32_t max_matches,
+ size_t max_matches,
TypeList& types)
{
- uint32_t num_matches = 0;
+ size_t num_matches = 0;
const char *type_name_cstr = name.GetCString();
std::string type_scope;
std::string type_basename;
@@ -756,17 +811,6 @@ Module::FindTypes (const SymbolContext&
}
-//uint32_t
-//Module::FindTypes(const SymbolContext& sc, const RegularExpression& regex, bool append, uint32_t max_matches, Type::Encoding encoding, const char *udt_name, TypeList& types)
-//{
-// Timer scoped_timer(__PRETTY_FUNCTION__);
-// SymbolVendor *symbols = GetSymbolVendor ();
-// if (symbols)
-// return symbols->FindTypes(sc, regex, append, max_matches, encoding, udt_name, types);
-// return 0;
-//
-//}
-
SymbolVendor*
Module::GetSymbolVendor (bool can_create, lldb_private::Stream *feedback_strm)
{
@@ -1009,12 +1053,14 @@ Module::GetObjectFile()
m_did_load_objfile = true;
Timer scoped_timer(__PRETTY_FUNCTION__,
"Module::GetObjectFile () module = %s", GetFileSpec().GetFilename().AsCString(""));
- DataBufferSP file_data_sp;
- m_objfile_sp = ObjectFile::FindPlugin (shared_from_this(),
+ DataBufferSP data_sp;
+ lldb::offset_t data_offset = 0;
+ m_objfile_sp = ObjectFile::FindPlugin (shared_from_this(),
&m_file,
m_object_offset,
m_file.GetByteSize(),
- file_data_sp);
+ data_sp,
+ data_offset);
if (m_objfile_sp)
{
// Once we get the object file, update our module with the object file's
@@ -1180,35 +1226,51 @@ Module::LoadScriptingResourceInTarget (T
return false;
}
- PlatformSP platform_sp(target->GetPlatform());
-
- if (!platform_sp)
+ Debugger &debugger = target->GetDebugger();
+ const ScriptLanguage script_language = debugger.GetScriptLanguage();
+ if (script_language != eScriptLanguageNone)
{
- error.SetErrorString("invalid Platform");
- return false;
- }
-
- ModuleSpec module_spec(GetFileSpec());
- FileSpec scripting_fspec = platform_sp->LocateExecutableScriptingResource(module_spec);
- Debugger &debugger(target->GetDebugger());
- if (scripting_fspec && scripting_fspec.Exists())
- {
- ScriptInterpreter *script_interpreter = debugger.GetCommandInterpreter().GetScriptInterpreter();
- if (script_interpreter)
- {
- StreamString scripting_stream;
- scripting_fspec.Dump(&scripting_stream);
- const bool can_reload = false;
- const bool init_lldb_globals = false;
- bool did_load = script_interpreter->LoadScriptingModule(scripting_stream.GetData(), can_reload, init_lldb_globals, error);
- if (!did_load)
- return false;
- }
- else
+
+ PlatformSP platform_sp(target->GetPlatform());
+
+ if (!platform_sp)
{
- error.SetErrorString("invalid ScriptInterpreter");
+ error.SetErrorString("invalid Platform");
return false;
}
+
+ FileSpecList file_specs = platform_sp->LocateExecutableScriptingResources (target,
+ *this);
+
+
+ const uint32_t num_specs = file_specs.GetSize();
+ if (num_specs)
+ {
+ ScriptInterpreter *script_interpreter = debugger.GetCommandInterpreter().GetScriptInterpreter();
+ if (script_interpreter)
+ {
+ for (uint32_t i=0; i<num_specs; ++i)
+ {
+ FileSpec scripting_fspec (file_specs.GetFileSpecAtIndex(i));
+ if (scripting_fspec && scripting_fspec.Exists())
+ {
+
+ StreamString scripting_stream;
+ scripting_fspec.Dump(&scripting_stream);
+ const bool can_reload = false;
+ const bool init_lldb_globals = false;
+ bool did_load = script_interpreter->LoadScriptingModule(scripting_stream.GetData(), can_reload, init_lldb_globals, error);
+ if (!did_load)
+ return false;
+ }
+ }
+ }
+ else
+ {
+ error.SetErrorString("invalid ScriptInterpreter");
+ return false;
+ }
+ }
}
return true;
}
@@ -1328,3 +1390,78 @@ Module::GetVersion (uint32_t *versions,
}
return 0;
}
+
+void
+Module::PrepareForFunctionNameLookup (const ConstString &name,
+ uint32_t name_type_mask,
+ ConstString &lookup_name,
+ uint32_t &lookup_name_type_mask,
+ bool &match_name_after_lookup)
+{
+ const char *name_cstr = name.GetCString();
+ lookup_name_type_mask = eFunctionNameTypeNone;
+ match_name_after_lookup = false;
+ const char *base_name_start = NULL;
+ const char *base_name_end = NULL;
+
+ if (name_type_mask & eFunctionNameTypeAuto)
+ {
+ if (CPPLanguageRuntime::IsCPPMangledName (name_cstr))
+ lookup_name_type_mask = eFunctionNameTypeFull;
+ else if (ObjCLanguageRuntime::IsPossibleObjCMethodName (name_cstr))
+ lookup_name_type_mask = eFunctionNameTypeFull;
+ else
+ {
+ if (ObjCLanguageRuntime::IsPossibleObjCSelector(name_cstr))
+ lookup_name_type_mask |= eFunctionNameTypeSelector;
+
+ if (CPPLanguageRuntime::IsPossibleCPPCall(name_cstr, base_name_start, base_name_end))
+ lookup_name_type_mask |= (eFunctionNameTypeMethod | eFunctionNameTypeBase);
+ }
+ }
+ else
+ {
+ lookup_name_type_mask = name_type_mask;
+ if (lookup_name_type_mask & eFunctionNameTypeMethod || name_type_mask & eFunctionNameTypeBase)
+ {
+ // If they've asked for a CPP method or function name and it can't be that, we don't
+ // even need to search for CPP methods or names.
+ if (!CPPLanguageRuntime::IsPossibleCPPCall(name_cstr, base_name_start, base_name_end))
+ {
+ lookup_name_type_mask &= ~(eFunctionNameTypeMethod | eFunctionNameTypeBase);
+ if (lookup_name_type_mask == eFunctionNameTypeNone)
+ return;
+ }
+ }
+
+ if (lookup_name_type_mask & eFunctionNameTypeSelector)
+ {
+ if (!ObjCLanguageRuntime::IsPossibleObjCSelector(name_cstr))
+ {
+ lookup_name_type_mask &= ~(eFunctionNameTypeSelector);
+ if (lookup_name_type_mask == eFunctionNameTypeNone)
+ return;
+ }
+ }
+ }
+
+ if (base_name_start &&
+ base_name_end &&
+ base_name_start != name_cstr &&
+ base_name_start < base_name_end)
+ {
+ // The name supplied was a partial C++ path like "a::count". In this case we want to do a
+ // lookup on the basename "count" and then make sure any matching results contain "a::count"
+ // so that it would match "b::a::count" and "a::count". This is why we set "match_name_after_lookup"
+ // to true
+ lookup_name.SetCStringWithLength(base_name_start, base_name_end - base_name_start);
+ match_name_after_lookup = true;
+ }
+ else
+ {
+ // The name is already correct, just use the exact name as supplied, and we won't need
+ // to check if any matches contain "name"
+ lookup_name = name;
+ match_name_after_lookup = false;
+ }
+}
\ No newline at end of file
Modified: lldb/branches/windows/source/Core/ModuleList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/ModuleList.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/ModuleList.cpp (original)
+++ lldb/branches/windows/source/Core/ModuleList.cpp Wed Apr 17 03:38:48 2013
@@ -296,14 +296,14 @@ ModuleList::ClearImpl (bool use_notifier
}
Module*
-ModuleList::GetModulePointerAtIndex (uint32_t idx) const
+ModuleList::GetModulePointerAtIndex (size_t idx) const
{
Mutex::Locker locker(m_modules_mutex);
return GetModulePointerAtIndexUnlocked(idx);
}
Module*
-ModuleList::GetModulePointerAtIndexUnlocked (uint32_t idx) const
+ModuleList::GetModulePointerAtIndexUnlocked (size_t idx) const
{
if (idx < m_modules.size())
return m_modules[idx].get();
@@ -311,14 +311,14 @@ ModuleList::GetModulePointerAtIndexUnloc
}
ModuleSP
-ModuleList::GetModuleAtIndex(uint32_t idx) const
+ModuleList::GetModuleAtIndex(size_t idx) const
{
Mutex::Locker locker(m_modules_mutex);
return GetModuleAtIndexUnlocked(idx);
}
ModuleSP
-ModuleList::GetModuleAtIndexUnlocked(uint32_t idx) const
+ModuleList::GetModuleAtIndexUnlocked(size_t idx) const
{
ModuleSP module_sp;
if (idx < m_modules.size())
@@ -326,7 +326,7 @@ ModuleList::GetModuleAtIndexUnlocked(uin
return module_sp;
}
-uint32_t
+size_t
ModuleList::FindFunctions (const ConstString &name,
uint32_t name_type_mask,
bool include_symbols,
@@ -337,17 +337,67 @@ ModuleList::FindFunctions (const ConstSt
if (!append)
sc_list.Clear();
+ const size_t old_size = sc_list.GetSize();
+
+ if (name_type_mask & eFunctionNameTypeAuto)
+ {
+ ConstString lookup_name;
+ uint32_t lookup_name_type_mask = 0;
+ bool match_name_after_lookup = false;
+ Module::PrepareForFunctionNameLookup (name, name_type_mask,
+ lookup_name,
+ lookup_name_type_mask,
+ match_name_after_lookup);
+
Mutex::Locker locker(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos)
{
- (*pos)->FindFunctions (name, NULL, name_type_mask, include_symbols, include_inlines, true, sc_list);
+ (*pos)->FindFunctions (lookup_name,
+ NULL,
+ lookup_name_type_mask,
+ include_symbols,
+ include_inlines,
+ true,
+ sc_list);
+ }
+
+ if (match_name_after_lookup)
+ {
+ SymbolContext sc;
+ size_t i = old_size;
+ while (i<sc_list.GetSize())
+ {
+ if (sc_list.GetContextAtIndex(i, sc))
+ {
+ const char *func_name = sc.GetFunctionName().GetCString();
+ if (func_name && strstr (func_name, name.GetCString()) == NULL)
+ {
+ // Remove the current context
+ sc_list.RemoveContextAtIndex(i);
+ // Don't increment i and continue in the loop
+ continue;
+ }
+ }
+ ++i;
+ }
+ }
+
}
+ else
+ {
- return sc_list.GetSize();
+ Mutex::Locker locker(m_modules_mutex);
+ collection::const_iterator pos, end = m_modules.end();
+ for (pos = m_modules.begin(); pos != end; ++pos)
+ {
+ (*pos)->FindFunctions (name, NULL, name_type_mask, include_symbols, include_inlines, true, sc_list);
+ }
+ }
+ return sc_list.GetSize() - old_size;
}
-uint32_t
+size_t
ModuleList::FindCompileUnits (const FileSpec &path,
bool append,
SymbolContextList &sc_list) const
@@ -365,10 +415,10 @@ ModuleList::FindCompileUnits (const File
return sc_list.GetSize();
}
-uint32_t
+size_t
ModuleList::FindGlobalVariables (const ConstString &name,
bool append,
- uint32_t max_matches,
+ size_t max_matches,
VariableList& variable_list) const
{
size_t initial_size = variable_list.GetSize();
@@ -382,10 +432,10 @@ ModuleList::FindGlobalVariables (const C
}
-uint32_t
+size_t
ModuleList::FindGlobalVariables (const RegularExpression& regex,
bool append,
- uint32_t max_matches,
+ size_t max_matches,
VariableList& variable_list) const
{
size_t initial_size = variable_list.GetSize();
@@ -495,12 +545,12 @@ ModuleList::FindModule (const UUID &uuid
}
-uint32_t
-ModuleList::FindTypes (const SymbolContext& sc, const ConstString &name, bool name_is_fully_qualified, uint32_t max_matches, TypeList& types) const
+size_t
+ModuleList::FindTypes (const SymbolContext& sc, const ConstString &name, bool name_is_fully_qualified, size_t max_matches, TypeList& types) const
{
Mutex::Locker locker(m_modules_mutex);
- uint32_t total_matches = 0;
+ size_t total_matches = 0;
collection::const_iterator pos, end = m_modules.end();
if (sc.module_sp)
{
@@ -596,9 +646,9 @@ ModuleList::Dump(Stream *s) const
}
void
-ModuleList::LogUUIDAndPaths (LogSP &log_sp, const char *prefix_cstr)
+ModuleList::LogUUIDAndPaths (Log *log, const char *prefix_cstr)
{
- if (log_sp)
+ if (log)
{
Mutex::Locker locker(m_modules_mutex);
char uuid_cstr[256];
@@ -608,7 +658,7 @@ ModuleList::LogUUIDAndPaths (LogSP &log_
Module *module = pos->get();
module->GetUUID().GetAsCString (uuid_cstr, sizeof(uuid_cstr));
const FileSpec &module_file_spec = module->GetFileSpec();
- log_sp->Printf ("%s[%u] %s (%s) \"%s/%s\"",
+ log->Printf ("%s[%u] %s (%s) \"%s/%s\"",
prefix_cstr ? prefix_cstr : "",
(uint32_t)std::distance (begin, pos),
uuid_cstr,
@@ -689,7 +739,7 @@ ModuleList::ResolveSymbolContextsForFile
return sc_list.GetSize();
}
-uint32_t
+size_t
ModuleList::GetIndexForModule (const Module *module) const
{
if (module)
@@ -737,7 +787,7 @@ ModuleList::FindSharedModules (const Mod
return GetSharedModuleList ().FindModules (module_spec, matching_module_list);
}
-uint32_t
+size_t
ModuleList::RemoveOrphanSharedModules (bool mandatory)
{
return GetSharedModuleList ().RemoveOrphans(mandatory);
@@ -781,7 +831,7 @@ ModuleList::GetSharedModule
const size_t num_matching_modules = shared_module_list.FindModules (module_spec, matching_module_list);
if (num_matching_modules > 0)
{
- for (uint32_t module_idx = 0; module_idx < num_matching_modules; ++module_idx)
+ for (size_t module_idx = 0; module_idx < num_matching_modules; ++module_idx)
{
module_sp = matching_module_list.GetModuleAtIndex(module_idx);
@@ -791,7 +841,7 @@ ModuleList::GetSharedModule
if (old_module_sp_ptr && !old_module_sp_ptr->get())
*old_module_sp_ptr = module_sp;
- LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_MODULES));
+ Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_MODULES));
if (log)
log->Printf("module changed: %p, removing from global module list", module_sp.get());
Modified: lldb/branches/windows/source/Core/PluginManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/PluginManager.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/PluginManager.cpp (original)
+++ lldb/branches/windows/source/Core/PluginManager.cpp Wed Apr 17 03:38:48 2013
@@ -1229,13 +1229,15 @@ struct PlatformInstance
PlatformInstance() :
name(),
description(),
- create_callback(NULL)
+ create_callback(NULL),
+ debugger_init_callback (NULL)
{
}
std::string name;
std::string description;
PlatformCreateInstance create_callback;
+ DebuggerInitializeCallback debugger_init_callback;
};
typedef std::vector<PlatformInstance> PlatformInstances;
@@ -1258,7 +1260,8 @@ GetPlatformInstances ()
bool
PluginManager::RegisterPlugin (const char *name,
const char *description,
- PlatformCreateInstance create_callback)
+ PlatformCreateInstance create_callback,
+ DebuggerInitializeCallback debugger_init_callback)
{
if (create_callback)
{
@@ -1270,12 +1273,14 @@ PluginManager::RegisterPlugin (const cha
if (description && description[0])
instance.description = description;
instance.create_callback = create_callback;
+ instance.debugger_init_callback = debugger_init_callback;
GetPlatformInstances ().push_back (instance);
return true;
}
return false;
}
+
const char *
PluginManager::GetPlatformPluginNameAtIndex (uint32_t idx)
{
@@ -1346,7 +1351,7 @@ PluginManager::GetPlatformCreateCallback
return NULL;
}
-uint32_t
+size_t
PluginManager::AutoCompletePlatformName (const char *name, StringList &matches)
{
if (name && name[0])
@@ -1365,7 +1370,6 @@ PluginManager::AutoCompletePlatformName
}
return matches.GetSize();
}
-
#pragma mark Process
struct ProcessInstance
@@ -1813,22 +1817,41 @@ PluginManager::GetUnwindAssemblyCreateCa
void
PluginManager::DebuggerInitialize (Debugger &debugger)
{
- Mutex::Locker locker (GetDynamicLoaderMutex ());
- DynamicLoaderInstances &instances = GetDynamicLoaderInstances ();
+ // Initialize the DynamicLoader plugins
+ {
+ Mutex::Locker locker (GetDynamicLoaderMutex ());
+ DynamicLoaderInstances &instances = GetDynamicLoaderInstances ();
- DynamicLoaderInstances::iterator pos, end = instances.end();
- for (pos = instances.begin(); pos != end; ++ pos)
+ DynamicLoaderInstances::iterator pos, end = instances.end();
+ for (pos = instances.begin(); pos != end; ++ pos)
+ {
+ if (pos->debugger_init_callback)
+ pos->debugger_init_callback (debugger);
+ }
+ }
+
+ // Initialize the Platform plugins
{
- if (pos->debugger_init_callback)
- pos->debugger_init_callback (debugger);
+ Mutex::Locker locker (GetPlatformInstancesMutex ());
+ PlatformInstances &instances = GetPlatformInstances ();
+
+ PlatformInstances::iterator pos, end = instances.end();
+ for (pos = instances.begin(); pos != end; ++ pos)
+ {
+ if (pos->debugger_init_callback)
+ pos->debugger_init_callback (debugger);
+ }
}
}
+// This will put a plugin's settings under e.g. "plugin.dynamic-loader.darwin-kernel.SETTINGNAME".
+// The new preferred ordering is to put plugins under "dynamic-loader.plugin.darwin-kernel.SETTINGNAME"
+// and if there were a generic dynamic-loader setting, it would be "dynamic-loader.SETTINGNAME".
static lldb::OptionValuePropertiesSP
-GetDebuggerPropertyForPlugins (Debugger &debugger,
- const ConstString &plugin_type_name,
- const ConstString &plugin_type_desc,
- bool can_create)
+GetDebuggerPropertyForPluginsOldStyle (Debugger &debugger,
+ const ConstString &plugin_type_name,
+ const ConstString &plugin_type_desc,
+ bool can_create)
{
lldb::OptionValuePropertiesSP parent_properties_sp (debugger.GetValueProperties());
if (parent_properties_sp)
@@ -1862,11 +1885,52 @@ GetDebuggerPropertyForPlugins (Debugger
return lldb::OptionValuePropertiesSP();
}
+// This is the preferred new way to register plugin specific settings. e.g.
+// "platform.plugin.darwin-kernel.SETTINGNAME"
+// and Platform generic settings would be under "platform.SETTINGNAME".
+static lldb::OptionValuePropertiesSP
+GetDebuggerPropertyForPlugins (Debugger &debugger,
+ const ConstString &plugin_type_name,
+ const ConstString &plugin_type_desc,
+ bool can_create)
+{
+ static ConstString g_property_name("plugin");
+ lldb::OptionValuePropertiesSP parent_properties_sp (debugger.GetValueProperties());
+ if (parent_properties_sp)
+ {
+ OptionValuePropertiesSP plugin_properties_sp = parent_properties_sp->GetSubProperty (NULL, plugin_type_name);
+ if (!plugin_properties_sp && can_create)
+ {
+ plugin_properties_sp.reset (new OptionValueProperties (plugin_type_name));
+ parent_properties_sp->AppendProperty (plugin_type_name,
+ plugin_type_desc,
+ true,
+ plugin_properties_sp);
+ }
+
+ if (plugin_properties_sp)
+ {
+ lldb::OptionValuePropertiesSP plugin_type_properties_sp = plugin_properties_sp->GetSubProperty (NULL, g_property_name);
+ if (!plugin_type_properties_sp && can_create)
+ {
+ plugin_type_properties_sp.reset (new OptionValueProperties (g_property_name));
+ plugin_properties_sp->AppendProperty (g_property_name,
+ ConstString("Settings specific to plugins"),
+ true,
+ plugin_type_properties_sp);
+ }
+ return plugin_type_properties_sp;
+ }
+ }
+ return lldb::OptionValuePropertiesSP();
+}
+
+
lldb::OptionValuePropertiesSP
PluginManager::GetSettingForDynamicLoaderPlugin (Debugger &debugger, const ConstString &setting_name)
{
lldb::OptionValuePropertiesSP properties_sp;
- lldb::OptionValuePropertiesSP plugin_type_properties_sp (GetDebuggerPropertyForPlugins (debugger,
+ lldb::OptionValuePropertiesSP plugin_type_properties_sp (GetDebuggerPropertyForPluginsOldStyle (debugger,
ConstString("dynamic-loader"),
ConstString(), // not creating to so we don't need the description
false));
@@ -1883,12 +1947,50 @@ PluginManager::CreateSettingForDynamicLo
{
if (properties_sp)
{
- lldb::OptionValuePropertiesSP plugin_type_properties_sp (GetDebuggerPropertyForPlugins (debugger,
+ lldb::OptionValuePropertiesSP plugin_type_properties_sp (GetDebuggerPropertyForPluginsOldStyle (debugger,
ConstString("dynamic-loader"),
ConstString("Settings for dynamic loader plug-ins"),
true));
if (plugin_type_properties_sp)
{
+ plugin_type_properties_sp->AppendProperty (properties_sp->GetName(),
+ description,
+ is_global_property,
+ properties_sp);
+ return true;
+ }
+ }
+ return false;
+}
+
+
+lldb::OptionValuePropertiesSP
+PluginManager::GetSettingForPlatformPlugin (Debugger &debugger, const ConstString &setting_name)
+{
+ lldb::OptionValuePropertiesSP properties_sp;
+ lldb::OptionValuePropertiesSP plugin_type_properties_sp (GetDebuggerPropertyForPlugins (debugger,
+ ConstString("platform"),
+ ConstString(), // not creating to so we don't need the description
+ false));
+ if (plugin_type_properties_sp)
+ properties_sp = plugin_type_properties_sp->GetSubProperty (NULL, setting_name);
+ return properties_sp;
+}
+
+bool
+PluginManager::CreateSettingForPlatformPlugin (Debugger &debugger,
+ const lldb::OptionValuePropertiesSP &properties_sp,
+ const ConstString &description,
+ bool is_global_property)
+{
+ if (properties_sp)
+ {
+ lldb::OptionValuePropertiesSP plugin_type_properties_sp (GetDebuggerPropertyForPlugins (debugger,
+ ConstString("platform"),
+ ConstString("Settings for platform plug-ins"),
+ true));
+ if (plugin_type_properties_sp)
+ {
plugin_type_properties_sp->AppendProperty (properties_sp->GetName(),
description,
is_global_property,
Modified: lldb/branches/windows/source/Core/RegisterValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/RegisterValue.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/RegisterValue.cpp (original)
+++ lldb/branches/windows/source/Core/RegisterValue.cpp Wed Apr 17 03:38:48 2013
@@ -301,7 +301,7 @@ RegisterValue::SetType (const RegisterIn
}
Error
-RegisterValue::SetValueFromData (const RegisterInfo *reg_info, DataExtractor &src, uint32_t src_offset, bool partial_data_ok)
+RegisterValue::SetValueFromData (const RegisterInfo *reg_info, DataExtractor &src, lldb::offset_t src_offset, bool partial_data_ok)
{
Error error;
@@ -981,12 +981,11 @@ RegisterValue::SetBytes (const void *byt
// m_data.buffer.bytes, or make it something that is allocated on
// the heap. Since the data buffer is in a union, we can't make it
// a collection class like SmallVector...
- assert (length <= sizeof (m_data.buffer.bytes));
if (bytes && length > 0)
{
+ assert (length <= sizeof (m_data.buffer.bytes) && "Storing too many bytes in a RegisterValue.");
m_type = eTypeBytes;
m_data.buffer.length = length;
- assert (length < sizeof (m_data.buffer.bytes));
memcpy (m_data.buffer.bytes, bytes, length);
m_data.buffer.byte_order = byte_order;
}
Modified: lldb/branches/windows/source/Core/RegularExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/RegularExpression.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/RegularExpression.cpp (original)
+++ lldb/branches/windows/source/Core/RegularExpression.cpp Wed Apr 17 03:38:48 2013
@@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
#include "lldb/Core/RegularExpression.h"
+#include "llvm/ADT/StringRef.h"
#include <string.h>
using namespace lldb_private;
@@ -16,9 +17,12 @@ using namespace lldb_private;
// Default constructor
//----------------------------------------------------------------------
RegularExpression::RegularExpression() :
- m_re()
+ m_re(),
+ m_comp_err (1),
+ m_preg(),
+ m_compile_flags(REG_EXTENDED)
{
- m_regex = NULL;
+ memset(&m_preg,0,sizeof(m_preg));
}
//----------------------------------------------------------------------
@@ -26,9 +30,12 @@ RegularExpression::RegularExpression() :
// resulting compiled regular expression into this object.
//----------------------------------------------------------------------
RegularExpression::RegularExpression(const char* re, int flags) :
- m_re()
+ m_re(),
+ m_comp_err (1),
+ m_preg(),
+ m_compile_flags(flags)
{
- m_regex = NULL;
+ memset(&m_preg,0,sizeof(m_preg));
Compile(re);
}
@@ -37,21 +44,20 @@ RegularExpression::RegularExpression(con
// resulting compiled regular expression into this object.
//----------------------------------------------------------------------
RegularExpression::RegularExpression(const char* re) :
- m_re()
+ m_re(),
+ m_comp_err (1),
+ m_preg(),
+ m_compile_flags(REG_EXTENDED)
{
- m_regex = NULL;
+ memset(&m_preg,0,sizeof(m_preg));
Compile(re);
}
-RegularExpression::RegularExpression(const RegularExpression &rhs) :
- m_re()
- {
- m_regex = NULL;
- const char* data = rhs.GetText();
- if (data)
- Compile(data, rhs.GetCompileFlags());
- }
-
+RegularExpression::RegularExpression(const RegularExpression &rhs)
+{
+ memset(&m_preg,0,sizeof(m_preg));
+ Compile(rhs.GetText(), rhs.GetCompileFlags());
+}
const RegularExpression &
RegularExpression::operator= (const RegularExpression &rhs)
@@ -70,11 +76,7 @@ RegularExpression::operator= (const Regu
//----------------------------------------------------------------------
RegularExpression::~RegularExpression()
{
- if (m_regex)
- {
- delete m_regex;
- m_regex = NULL;
- }
+ Free();
}
//----------------------------------------------------------------------
@@ -100,12 +102,19 @@ RegularExpression::Compile(const char* r
{
Free();
m_compile_flags = flags;
- m_re = re;
- if (m_regex)
- delete m_regex;
- m_regex = new llvm::Regex(llvm::StringRef(re));
-
- return IsValid();
+
+ if (re && re[0])
+ {
+ m_re = re;
+ m_comp_err = ::regcomp (&m_preg, re, flags);
+ }
+ else
+ {
+ // No valid regular expression
+ m_comp_err = 1;
+ }
+
+ return m_comp_err == 0;
}
//----------------------------------------------------------------------
@@ -115,22 +124,98 @@ RegularExpression::Compile(const char* r
// matches "match_count" should indicate the number of regmatch_t
// values that are present in "match_ptr". The regular expression
// will be executed using the "execute_flags".
-//----------------------------------------------------------------------
+//---------------------------------------------------------------------
bool
-RegularExpression::Execute(const char* s, size_t num_matches, int execute_flags) const
+RegularExpression::Execute(const char* s, Match *match, int execute_flags) const
{
- if (!m_regex)
+ int err = 1;
+ if (m_comp_err == 0)
+ {
+ if (match)
+ {
+ err = ::regexec (&m_preg,
+ s,
+ match->GetSize(),
+ match->GetData(),
+ execute_flags);
+ }
+ else
+ {
+ err = ::regexec (&m_preg,
+ s,
+ 0,
+ NULL,
+ execute_flags);
+ }
+ }
+
+ if (err != 0)
+ {
+ // The regular expression didn't compile, so clear the matches
+ if (match)
+ match->Clear();
return false;
- return m_regex->match(llvm::StringRef(s), &m_matches);
+ }
+ return true;
+}
+
+bool
+RegularExpression::Match::GetMatchAtIndex (const char* s, uint32_t idx, std::string& match_str) const
+{
+ if (idx < m_matches.size())
+ {
+ if (m_matches[idx].rm_eo == m_matches[idx].rm_so)
+ {
+ // Matched the empty string...
+ match_str.clear();
+ return true;
+ }
+ else if (m_matches[idx].rm_eo > m_matches[idx].rm_so)
+ {
+ match_str.assign (s + m_matches[idx].rm_so,
+ m_matches[idx].rm_eo - m_matches[idx].rm_so);
+ return true;
+ }
+ }
+ return false;
}
bool
-RegularExpression::GetMatchAtIndex (const char* s, uint32_t idx, std::string& match_str) const
+RegularExpression::Match::GetMatchAtIndex (const char* s, uint32_t idx, llvm::StringRef& match_str) const
{
if (idx < m_matches.size())
{
- match_str = m_matches[idx];
- return true;
+ if (m_matches[idx].rm_eo == m_matches[idx].rm_so)
+ {
+ // Matched the empty string...
+ match_str = llvm::StringRef();
+ return true;
+ }
+ else if (m_matches[idx].rm_eo > m_matches[idx].rm_so)
+ {
+ match_str = llvm::StringRef (s + m_matches[idx].rm_so, m_matches[idx].rm_eo - m_matches[idx].rm_so);
+ return true;
+ }
+ }
+ return false;
+}
+
+bool
+RegularExpression::Match::GetMatchSpanningIndices (const char* s, uint32_t idx1, uint32_t idx2, llvm::StringRef& match_str) const
+{
+ if (idx1 < m_matches.size() && idx2 < m_matches.size())
+ {
+ if (m_matches[idx1].rm_so == m_matches[idx2].rm_eo)
+ {
+ // Matched the empty string...
+ match_str = llvm::StringRef();
+ return true;
+ }
+ else if (m_matches[idx1].rm_so < m_matches[idx2].rm_eo)
+ {
+ match_str = llvm::StringRef (s + m_matches[idx1].rm_so, m_matches[idx2].rm_eo - m_matches[idx1].rm_so);
+ return true;
+ }
}
return false;
}
@@ -143,9 +228,7 @@ RegularExpression::GetMatchAtIndex (cons
bool
RegularExpression::IsValid () const
{
- std::string err;
- if (!m_regex) return false;
- return m_regex->isValid(err);
+ return m_comp_err == 0;
}
//----------------------------------------------------------------------
@@ -166,20 +249,36 @@ RegularExpression::GetText () const
void
RegularExpression::Free()
{
- m_re.clear();
- if (m_regex)
- delete m_regex;
- m_regex = NULL;
- m_matches.clear();
+ if (m_comp_err == 0)
+ {
+ m_re.clear();
+ regfree(&m_preg);
+ // Set a compile error since we no longer have a valid regex
+ m_comp_err = 1;
+ }
}
-std::string
+std::string
RegularExpression::GetErrorAsCString () const
{
- std::string err;
- if (m_regex)
- m_regex->isValid(err);
- return err;
+ if (m_comp_err == 0) return std::string();
+ char* error = (char*)malloc(::regerror (m_comp_err, &m_preg, NULL, 0));
+ std::string res = error;
+ free(error);
+ return res;
+}
+
+size_t
+RegularExpression::GetErrorAsCString (char *err_str, size_t err_str_max_len) const
+{
+ if (m_comp_err == 0)
+ {
+ if (err_str && err_str_max_len)
+ *err_str = '\0';
+ return 0;
+ }
+
+ return ::regerror (m_comp_err, &m_preg, err_str, err_str_max_len);
}
bool
Modified: lldb/branches/windows/source/Core/Scalar.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/Scalar.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/Scalar.cpp (original)
+++ lldb/branches/windows/source/Core/Scalar.cpp Wed Apr 17 03:38:48 2013
@@ -525,11 +525,11 @@ Scalar::GetValueTypeAsCString (Scalar::T
Scalar::Type
Scalar::GetValueTypeForSignedIntegerWithByteSize (size_t byte_size)
{
- if (byte_size <= sizeof(int))
+ if (byte_size <= sizeof(sint_t))
return e_sint;
- if (byte_size <= sizeof(long))
+ if (byte_size <= sizeof(slong_t))
return e_slong;
- if (byte_size <= sizeof(long long))
+ if (byte_size <= sizeof(slonglong_t))
return e_slonglong;
return e_void;
}
@@ -537,11 +537,11 @@ Scalar::GetValueTypeForSignedIntegerWith
Scalar::Type
Scalar::GetValueTypeForUnsignedIntegerWithByteSize (size_t byte_size)
{
- if (byte_size <= sizeof(unsigned int))
+ if (byte_size <= sizeof(uint_t))
return e_uint;
- if (byte_size <= sizeof(unsigned long))
+ if (byte_size <= sizeof(ulong_t))
return e_ulong;
- if (byte_size <= sizeof(unsigned long long))
+ if (byte_size <= sizeof(ulonglong_t))
return e_ulonglong;
return e_void;
}
@@ -549,11 +549,11 @@ Scalar::GetValueTypeForUnsignedIntegerWi
Scalar::Type
Scalar::GetValueTypeForFloatWithByteSize (size_t byte_size)
{
- if (byte_size == sizeof(float))
+ if (byte_size == sizeof(float_t))
return e_float;
- if (byte_size == sizeof(double))
+ if (byte_size == sizeof(double_t))
return e_double;
- if (byte_size == sizeof(long double))
+ if (byte_size == sizeof(long_double_t))
return e_long_double;
return e_void;
}
@@ -603,8 +603,8 @@ Scalar::Cast(Scalar::Type type)
switch (type)
{
case e_void:
- case e_sint: m_data.sint = m_data.slong; success = true; break;
- case e_uint: m_data.uint = m_data.slong; success = true; break;
+ case e_sint: m_data.sint = (sint_t)m_data.slong; success = true; break;
+ case e_uint: m_data.uint = (uint_t)m_data.slong; success = true; break;
case e_slong: success = true; break;
case e_ulong: m_data.ulong = m_data.slong; success = true; break;
case e_slonglong: m_data.slonglong = m_data.slong; success = true; break;
@@ -619,8 +619,8 @@ Scalar::Cast(Scalar::Type type)
switch (type)
{
case e_void:
- case e_sint: m_data.sint = m_data.ulong; success = true; break;
- case e_uint: m_data.uint = m_data.ulong; success = true; break;
+ case e_sint: m_data.sint = (sint_t)m_data.ulong; success = true; break;
+ case e_uint: m_data.uint = (uint_t)m_data.ulong; success = true; break;
case e_slong: m_data.slong = m_data.ulong; success = true; break;
case e_ulong: success = true; break;
case e_slonglong: m_data.slonglong = m_data.ulong; success = true; break;
@@ -635,8 +635,8 @@ Scalar::Cast(Scalar::Type type)
switch (type)
{
case e_void:
- case e_sint: m_data.sint = m_data.slonglong; success = true; break;
- case e_uint: m_data.uint = m_data.slonglong; success = true; break;
+ case e_sint: m_data.sint = (sint_t)m_data.slonglong; success = true; break;
+ case e_uint: m_data.uint = (uint_t)m_data.slonglong; success = true; break;
case e_slong: m_data.slong = m_data.slonglong; success = true; break;
case e_ulong: m_data.ulong = m_data.slonglong; success = true; break;
case e_slonglong: success = true; break;
@@ -651,8 +651,8 @@ Scalar::Cast(Scalar::Type type)
switch (type)
{
case e_void:
- case e_sint: m_data.sint = m_data.ulonglong; success = true; break;
- case e_uint: m_data.uint = m_data.ulonglong; success = true; break;
+ case e_sint: m_data.sint = (sint_t)m_data.ulonglong; success = true; break;
+ case e_uint: m_data.uint = (uint_t)m_data.ulonglong; success = true; break;
case e_slong: m_data.slong = m_data.ulonglong; success = true; break;
case e_ulong: m_data.ulong = m_data.ulonglong; success = true; break;
case e_slonglong: m_data.slonglong = m_data.ulonglong; success = true; break;
@@ -667,15 +667,15 @@ Scalar::Cast(Scalar::Type type)
switch (type)
{
case e_void:
- case e_sint: m_data.sint = m_data.flt; success = true; break;
- case e_uint: m_data.uint = m_data.flt; success = true; break;
- case e_slong: m_data.slong = m_data.flt; success = true; break;
- case e_ulong: m_data.ulong = m_data.flt; success = true; break;
- case e_slonglong: m_data.slonglong = m_data.flt; success = true; break;
- case e_ulonglong: m_data.ulonglong = m_data.flt; success = true; break;
+ case e_sint: m_data.sint = (sint_t)m_data.flt; success = true; break;
+ case e_uint: m_data.uint = (uint_t)m_data.flt; success = true; break;
+ case e_slong: m_data.slong = (slong_t)m_data.flt; success = true; break;
+ case e_ulong: m_data.ulong = (ulong_t)m_data.flt; success = true; break;
+ case e_slonglong: m_data.slonglong = (slonglong_t)m_data.flt; success = true; break;
+ case e_ulonglong: m_data.ulonglong = (ulonglong_t)m_data.flt; success = true; break;
case e_float: success = true; break;
- case e_double: m_data.dbl = m_data.flt; success = true; break;
- case e_long_double: m_data.ldbl = m_data.flt; success = true; break;
+ case e_double: m_data.dbl = m_data.flt; success = true; break;
+ case e_long_double: m_data.ldbl = m_data.flt; success = true; break;
}
break;
@@ -683,15 +683,15 @@ Scalar::Cast(Scalar::Type type)
switch (type)
{
case e_void:
- case e_sint: m_data.sint = m_data.dbl; success = true; break;
- case e_uint: m_data.uint = m_data.dbl; success = true; break;
- case e_slong: m_data.slong = m_data.dbl; success = true; break;
- case e_ulong: m_data.ulong = m_data.dbl; success = true; break;
- case e_slonglong: m_data.slonglong = m_data.dbl; success = true; break;
- case e_ulonglong: m_data.ulonglong = m_data.dbl; success = true; break;
- case e_float: m_data.flt = m_data.dbl; success = true; break;
+ case e_sint: m_data.sint = (sint_t)m_data.dbl; success = true; break;
+ case e_uint: m_data.uint = (uint_t)m_data.dbl; success = true; break;
+ case e_slong: m_data.slong = (slong_t)m_data.dbl; success = true; break;
+ case e_ulong: m_data.ulong = (ulong_t)m_data.dbl; success = true; break;
+ case e_slonglong: m_data.slonglong = (slonglong_t)m_data.dbl; success = true; break;
+ case e_ulonglong: m_data.ulonglong = (ulonglong_t)m_data.dbl; success = true; break;
+ case e_float: m_data.flt = (float_t)m_data.dbl; success = true; break;
case e_double: success = true; break;
- case e_long_double: m_data.ldbl = m_data.dbl; success = true; break;
+ case e_long_double: m_data.ldbl = m_data.dbl; success = true; break;
}
break;
@@ -699,14 +699,14 @@ Scalar::Cast(Scalar::Type type)
switch (type)
{
case e_void:
- case e_sint: m_data.sint = m_data.ldbl; success = true; break;
- case e_uint: m_data.uint = m_data.ldbl; success = true; break;
- case e_slong: m_data.slong = m_data.ldbl; success = true; break;
- case e_ulong: m_data.ulong = m_data.ldbl; success = true; break;
- case e_slonglong: m_data.slonglong = m_data.ldbl; success = true; break;
- case e_ulonglong: m_data.ulonglong = m_data.ldbl; success = true; break;
- case e_float: m_data.flt = m_data.ldbl; success = true; break;
- case e_double: m_data.dbl = m_data.ldbl; success = true; break;
+ case e_sint: m_data.sint = (sint_t)m_data.ldbl; success = true; break;
+ case e_uint: m_data.uint = (uint_t)m_data.ldbl; success = true; break;
+ case e_slong: m_data.slong = (slong_t)m_data.ldbl; success = true; break;
+ case e_ulong: m_data.ulong = (ulong_t)m_data.ldbl; success = true; break;
+ case e_slonglong: m_data.slonglong = (slonglong_t)m_data.ldbl; success = true; break;
+ case e_ulonglong: m_data.ulonglong = (ulonglong_t)m_data.ldbl; success = true; break;
+ case e_float: m_data.flt = (float_t)m_data.ldbl; success = true; break;
+ case e_double: m_data.dbl = (double_t)m_data.ldbl; success = true; break;
case e_long_double: success = true; break;
}
break;
@@ -817,29 +817,29 @@ Scalar::GetRawBits64(uint64_t fail_value
return m_data.ulonglong;
case e_float:
- if (sizeof(m_data.flt) == sizeof(int))
+ if (sizeof(m_data.flt) == sizeof(m_data.uint))
return m_data.uint;
- else if (sizeof(m_data.flt) == sizeof(unsigned long))
+ else if (sizeof(m_data.flt) == sizeof(m_data.ulong))
return m_data.ulong;
- else if (sizeof(m_data.flt) == sizeof(unsigned long long))
+ else if (sizeof(m_data.flt) == sizeof(m_data.ulonglong))
return m_data.ulonglong;
break;
case e_double:
- if (sizeof(m_data.dbl) == sizeof(int))
+ if (sizeof(m_data.dbl) == sizeof(m_data.uint))
return m_data.uint;
- else if (sizeof(m_data.dbl) == sizeof(unsigned long))
+ else if (sizeof(m_data.dbl) == sizeof(m_data.ulong))
return m_data.ulong;
- else if (sizeof(m_data.dbl) == sizeof(unsigned long long))
+ else if (sizeof(m_data.dbl) == sizeof(m_data.ulonglong))
return m_data.ulonglong;
break;
case e_long_double:
- if (sizeof(m_data.ldbl) == sizeof(int))
+ if (sizeof(m_data.ldbl) == sizeof(m_data.uint))
return m_data.uint;
- else if (sizeof(m_data.ldbl) == sizeof(unsigned long))
+ else if (sizeof(m_data.ldbl) == sizeof(m_data.ulong))
return m_data.ulong;
- else if (sizeof(m_data.ldbl) == sizeof(unsigned long long))
+ else if (sizeof(m_data.ldbl) == sizeof(m_data.ulonglong))
return m_data.ulonglong;
break;
}
@@ -1719,6 +1719,22 @@ lldb_private::operator^ (const Scalar& l
return result;
}
+const Scalar
+lldb_private::operator<< (const Scalar& lhs, const Scalar &rhs)
+{
+ Scalar result = lhs;
+ result <<= rhs;
+ return result;
+}
+
+const Scalar
+lldb_private::operator>> (const Scalar& lhs, const Scalar &rhs)
+{
+ Scalar result = lhs;
+ result >>= rhs;
+ return result;
+}
+
// Return the raw unsigned integer without any casting or conversion
unsigned int
Scalar::RawUInt () const
@@ -1742,7 +1758,7 @@ Scalar::RawULongLong () const
Error
-Scalar::SetValueFromCString (const char *value_str, Encoding encoding, uint32_t byte_size)
+Scalar::SetValueFromCString (const char *value_str, Encoding encoding, size_t byte_size)
{
Error error;
if (value_str == NULL || value_str[0] == '\0')
@@ -1764,28 +1780,24 @@ Scalar::SetValueFromCString (const char
if (!success)
error.SetErrorStringWithFormat ("'%s' is not a valid unsigned integer string value", value_str);
else if (!UIntValueIsValidForSize (uval64, byte_size))
-#ifdef _WIN32
- error.SetErrorStringWithFormat ("value 0x%llu is too large to fit in a %u byte unsigned integer value", uval64, byte_size);
-#else
- error.SetErrorStringWithFormat ("value 0x%" PRIx64 " is too large to fit in a %u byte unsigned integer value", uval64, byte_size);
-#endif
+ error.SetErrorStringWithFormat ("value 0x%" PRIx64 " is too large to fit in a %zu byte unsigned integer value", uval64, byte_size);
else
{
m_type = Scalar::GetValueTypeForUnsignedIntegerWithByteSize (byte_size);
switch (m_type)
{
- case e_uint: m_data.uint = uval64; break;
- case e_ulong: m_data.ulong = uval64; break;
- case e_ulonglong: m_data.ulonglong = uval64; break;
+ case e_uint: m_data.uint = (uint_t)uval64; break;
+ case e_ulong: m_data.ulong = (ulong_t)uval64; break;
+ case e_ulonglong: m_data.ulonglong = (ulonglong_t)uval64; break;
default:
- error.SetErrorStringWithFormat ("unsupported unsigned integer byte size: %u", byte_size);
+ error.SetErrorStringWithFormat ("unsupported unsigned integer byte size: %zu", byte_size);
break;
}
}
}
else
{
- error.SetErrorStringWithFormat ("unsupported unsigned integer byte size: %u", byte_size);
+ error.SetErrorStringWithFormat ("unsupported unsigned integer byte size: %zu", byte_size);
return error;
}
break;
@@ -1797,28 +1809,24 @@ Scalar::SetValueFromCString (const char
if (!success)
error.SetErrorStringWithFormat ("'%s' is not a valid signed integer string value", value_str);
else if (!SIntValueIsValidForSize (sval64, byte_size))
-#ifdef _WIN32
- error.SetErrorStringWithFormat ("value 0x%llu is too large to fit in a %u byte signed integer value", sval64, byte_size);
-#else
- error.SetErrorStringWithFormat ("value 0x%" PRIx64 " is too large to fit in a %u byte signed integer value", sval64, byte_size);
-#endif
+ error.SetErrorStringWithFormat ("value 0x%" PRIx64 " is too large to fit in a %zu byte signed integer value", sval64, byte_size);
else
{
m_type = Scalar::GetValueTypeForSignedIntegerWithByteSize (byte_size);
switch (m_type)
{
- case e_sint: m_data.sint = sval64; break;
- case e_slong: m_data.slong = sval64; break;
- case e_slonglong: m_data.slonglong = sval64; break;
+ case e_sint: m_data.sint = (sint_t)sval64; break;
+ case e_slong: m_data.slong = (slong_t)sval64; break;
+ case e_slonglong: m_data.slonglong = (slonglong_t)sval64; break;
default:
- error.SetErrorStringWithFormat ("unsupported signed integer byte size: %u", byte_size);
+ error.SetErrorStringWithFormat ("unsupported signed integer byte size: %zu", byte_size);
break;
}
}
}
else
{
- error.SetErrorStringWithFormat ("unsupported signed integer byte size: %u", byte_size);
+ error.SetErrorStringWithFormat ("unsupported signed integer byte size: %zu", byte_size);
return error;
}
break;
@@ -1847,7 +1855,7 @@ Scalar::SetValueFromCString (const char
}
else
{
- error.SetErrorStringWithFormat ("unsupported float byte size: %u", byte_size);
+ error.SetErrorStringWithFormat ("unsupported float byte size: %zu", byte_size);
return error;
}
break;
@@ -1862,6 +1870,70 @@ Scalar::SetValueFromCString (const char
return error;
}
+Error
+Scalar::SetValueFromData (DataExtractor &data, lldb::Encoding encoding, size_t byte_size)
+{
+ Error error;
+
+ switch (encoding)
+ {
+ case lldb::eEncodingInvalid:
+ error.SetErrorString ("invalid encoding");
+ break;
+ case lldb::eEncodingVector:
+ error.SetErrorString ("vector encoding unsupported");
+ break;
+ case lldb::eEncodingUint:
+ {
+ lldb::offset_t offset;
+
+ switch (byte_size)
+ {
+ case 1: operator=((uint8_t)data.GetU8(&offset)); break;
+ case 2: operator=((uint16_t)data.GetU16(&offset)); break;
+ case 4: operator=((uint32_t)data.GetU32(&offset)); break;
+ case 8: operator=((uint64_t)data.GetU64(&offset)); break;
+ default:
+ error.SetErrorStringWithFormat ("unsupported unsigned integer byte size: %zu", byte_size);
+ break;
+ }
+ }
+ break;
+ case lldb::eEncodingSint:
+ {
+ lldb::offset_t offset;
+
+ switch (byte_size)
+ {
+ case 1: operator=((int8_t)data.GetU8(&offset)); break;
+ case 2: operator=((int16_t)data.GetU16(&offset)); break;
+ case 4: operator=((int32_t)data.GetU32(&offset)); break;
+ case 8: operator=((int64_t)data.GetU64(&offset)); break;
+ default:
+ error.SetErrorStringWithFormat ("unsupported signed integer byte size: %zu", byte_size);
+ break;
+ }
+ }
+ break;
+ case lldb::eEncodingIEEE754:
+ {
+ lldb::offset_t offset;
+
+ if (byte_size == sizeof (float))
+ operator=((float)data.GetFloat(&offset));
+ else if (byte_size == sizeof (double))
+ operator=((double)data.GetDouble(&offset));
+ else if (byte_size == sizeof (long double))
+ operator=((long double)data.GetLongDouble(&offset));
+ else
+ error.SetErrorStringWithFormat ("unsupported float byte size: %zu", byte_size);
+ }
+ break;
+ }
+
+ return error;
+}
+
bool
Scalar::SignExtend (uint32_t sign_bit_pos)
{
@@ -1929,9 +2001,9 @@ Scalar::SignExtend (uint32_t sign_bit_po
return false;
}
-uint32_t
+size_t
Scalar::GetAsMemoryData (void *dst,
- uint32_t dst_len,
+ size_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const
{
@@ -1946,7 +2018,7 @@ Scalar::GetAsMemoryData (void *dst,
const size_t src_len = data.GetByteSize();
// Prepare a memory buffer that contains some or all of the register value
- const uint32_t bytes_copied = data.CopyByteOrderedData (0, // src offset
+ const size_t bytes_copied = data.CopyByteOrderedData (0, // src offset
src_len, // src length
dst, // dst buffer
dst_len, // dst length
@@ -1984,60 +2056,60 @@ Scalar::ExtractBitfield (uint32_t bit_si
break;
case e_float:
- if (sizeof(m_data.flt) == sizeof(int))
- m_data.sint = SignedBits (m_data.sint, msbit, lsbit);
- else if (sizeof(m_data.flt) == sizeof(unsigned long))
- m_data.slong = SignedBits (m_data.slong, msbit, lsbit);
- else if (sizeof(m_data.flt) == sizeof(unsigned long long))
- m_data.slonglong = SignedBits (m_data.slonglong, msbit, lsbit);
+ if (sizeof(m_data.flt) == sizeof(sint_t))
+ m_data.sint = (sint_t)SignedBits (m_data.sint, msbit, lsbit);
+ else if (sizeof(m_data.flt) == sizeof(ulong_t))
+ m_data.slong = (slong_t)SignedBits (m_data.slong, msbit, lsbit);
+ else if (sizeof(m_data.flt) == sizeof(ulonglong_t))
+ m_data.slonglong = (slonglong_t)SignedBits (m_data.slonglong, msbit, lsbit);
else
return false;
return true;
case e_double:
- if (sizeof(m_data.dbl) == sizeof(int))
+ if (sizeof(m_data.dbl) == sizeof(sint_t))
m_data.sint = SignedBits (m_data.sint, msbit, lsbit);
- else if (sizeof(m_data.dbl) == sizeof(unsigned long))
+ else if (sizeof(m_data.dbl) == sizeof(ulong_t))
m_data.slong = SignedBits (m_data.slong, msbit, lsbit);
- else if (sizeof(m_data.dbl) == sizeof(unsigned long long))
+ else if (sizeof(m_data.dbl) == sizeof(ulonglong_t))
m_data.slonglong = SignedBits (m_data.slonglong, msbit, lsbit);
else
return false;
return true;
case e_long_double:
- if (sizeof(m_data.ldbl) == sizeof(int))
+ if (sizeof(m_data.ldbl) == sizeof(sint_t))
m_data.sint = SignedBits (m_data.sint, msbit, lsbit);
- else if (sizeof(m_data.ldbl) == sizeof(unsigned long))
+ else if (sizeof(m_data.ldbl) == sizeof(ulong_t))
m_data.slong = SignedBits (m_data.slong, msbit, lsbit);
- else if (sizeof(m_data.ldbl) == sizeof(unsigned long long))
+ else if (sizeof(m_data.ldbl) == sizeof(ulonglong_t))
m_data.slonglong = SignedBits (m_data.slonglong, msbit, lsbit);
else
return false;
return true;
case Scalar::e_sint:
- m_data.sint = SignedBits (m_data.sint, msbit, lsbit);
+ m_data.sint = (sint_t)SignedBits (m_data.sint, msbit, lsbit);
return true;
case Scalar::e_uint:
- m_data.uint = UnsignedBits (m_data.uint, msbit, lsbit);
+ m_data.uint = (uint_t)UnsignedBits (m_data.uint, msbit, lsbit);
return true;
case Scalar::e_slong:
- m_data.slong = SignedBits (m_data.slong, msbit, lsbit);
+ m_data.slong = (slong_t)SignedBits (m_data.slong, msbit, lsbit);
return true;
case Scalar::e_ulong:
- m_data.ulong = SignedBits (m_data.ulong, msbit, lsbit);
+ m_data.ulong = (ulong_t)UnsignedBits (m_data.ulong, msbit, lsbit);
return true;
case Scalar::e_slonglong:
- m_data.slonglong = SignedBits (m_data.slonglong, msbit, lsbit);
+ m_data.slonglong = (slonglong_t)SignedBits (m_data.slonglong, msbit, lsbit);
return true;
case Scalar::e_ulonglong:
- m_data.ulonglong = SignedBits (m_data.ulonglong, msbit, lsbit);
+ m_data.ulonglong = (ulonglong_t)UnsignedBits (m_data.ulonglong, msbit, lsbit);
return true;
}
return false;
Modified: lldb/branches/windows/source/Core/SearchFilter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/SearchFilter.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/SearchFilter.cpp (original)
+++ lldb/branches/windows/source/Core/SearchFilter.cpp Wed Apr 17 03:38:48 2013
@@ -85,16 +85,6 @@ SearchFilter::ModulePasses (const Module
}
bool
-SearchFilter::SymbolContextPasses
-(
- const SymbolContext &context,
- lldb::SymbolContextItem scope
-)
-{
- return true;
-}
-
-bool
SearchFilter::AddressPasses (Address &address)
{
return true;
@@ -245,8 +235,8 @@ SearchFilter::DoCUIteration (const Modul
Searcher::CallbackReturn shouldContinue;
if (context.comp_unit == NULL)
{
- uint32_t num_comp_units = module_sp->GetNumCompileUnits();
- for (uint32_t i = 0; i < num_comp_units; i++)
+ const size_t num_comp_units = module_sp->GetNumCompileUnits();
+ for (size_t i = 0; i < num_comp_units; i++)
{
CompUnitSP cu_sp (module_sp->GetCompileUnitAtIndex (i));
if (cu_sp)
@@ -376,22 +366,6 @@ SearchFilterByModule::ModulePasses (cons
}
bool
-SearchFilterByModule::SymbolContextPasses (const SymbolContext &sc,
- lldb::SymbolContextItem scope)
-{
- if (scope & eSymbolContextModule)
- {
- if (sc.module_sp)
- {
- // Match the full path only if "m_module_spec" has a directory
- const bool full_match = m_module_spec.GetDirectory();
- return FileSpec::Equal (sc.module_sp->GetFileSpec(), m_module_spec, full_match);
- }
- }
- return false;
-}
-
-bool
SearchFilterByModule::AddressPasses (Address &address)
{
// FIXME: Not yet implemented
@@ -543,22 +517,6 @@ SearchFilterByModuleList::ModulePasses (
}
bool
-SearchFilterByModuleList::SymbolContextPasses
-(
- const SymbolContext &context,
- lldb::SymbolContextItem scope
- )
-{
- if (!(scope & eSymbolContextModule))
- return false;
-
- if (context.module_sp && m_module_spec_list.FindFileIndex(0, context.module_sp->GetFileSpec(), true) != UINT32_MAX)
- return true;
- else
- return false;
-}
-
-bool
SearchFilterByModuleList::AddressPasses (Address &address)
{
// FIXME: Not yet implemented
@@ -617,7 +575,7 @@ SearchFilterByModuleList::Search (Search
void
SearchFilterByModuleList::GetDescription (Stream *s)
{
- uint32_t num_modules = m_module_spec_list.GetSize();
+ size_t num_modules = m_module_spec_list.GetSize();
if (num_modules == 1)
{
s->Printf (", module = ");
@@ -634,8 +592,8 @@ SearchFilterByModuleList::GetDescription
}
else
{
- s->Printf (", modules(%u) = ", num_modules);
- for (uint32_t i = 0; i < num_modules; i++)
+ s->Printf (", modules(%zu) = ", num_modules);
+ for (size_t i = 0; i < num_modules; i++)
{
if (s->GetVerbose())
{
@@ -715,25 +673,8 @@ SearchFilterByModuleListAndCU::~SearchFi
}
bool
-SearchFilterByModuleListAndCU::SymbolContextPasses
-(
- const SymbolContext &context,
- lldb::SymbolContextItem scope
- )
-{
- if (!SearchFilterByModuleList::SymbolContextPasses(context, scope))
- return false;
- if (!(scope & eSymbolContextCompUnit))
- return false;
- if (context.comp_unit && m_cu_spec_list.FindFileIndex(0, context.comp_unit, false) == UINT32_MAX)
- return false;
- return true;
-}
-
-bool
SearchFilterByModuleListAndCU::AddressPasses (Address &address)
{
- // FIXME: Not yet implemented
return true;
}
@@ -812,7 +753,7 @@ SearchFilterByModuleListAndCU::Search (S
void
SearchFilterByModuleListAndCU::GetDescription (Stream *s)
{
- uint32_t num_modules = m_module_spec_list.GetSize();
+ size_t num_modules = m_module_spec_list.GetSize();
if (num_modules == 1)
{
s->Printf (", module = ");
@@ -829,8 +770,8 @@ SearchFilterByModuleListAndCU::GetDescri
}
else if (num_modules > 0)
{
- s->Printf (", modules(%d) = ", num_modules);
- for (uint32_t i = 0; i < num_modules; i++)
+ s->Printf (", modules(%zd) = ", num_modules);
+ for (size_t i = 0; i < num_modules; i++)
{
if (s->GetVerbose())
{
Modified: lldb/branches/windows/source/Core/Section.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/Section.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/Section.cpp (original)
+++ lldb/branches/windows/source/Core/Section.cpp Wed Apr 17 03:38:48 2013
@@ -21,8 +21,8 @@ Section::Section (const ModuleSP &module
SectionType sect_type,
addr_t file_addr,
addr_t byte_size,
- uint64_t file_offset,
- uint64_t file_size,
+ lldb::offset_t file_offset,
+ lldb::offset_t file_size,
uint32_t flags) :
ModuleChild (module_sp),
UserID (sect_id),
@@ -37,9 +37,7 @@ Section::Section (const ModuleSP &module
m_children (),
m_fake (false),
m_encrypted (false),
- m_thread_specific (false),
- m_linked_section_wp(),
- m_linked_offset (0)
+ m_thread_specific (false)
{
// printf ("Section::Section(%p): module=%p, sect_id = 0x%16.16" PRIx64 ", addr=[0x%16.16" PRIx64 " - 0x%16.16" PRIx64 "), file [0x%16.16" PRIx64 " - 0x%16.16" PRIx64 "), flags = 0x%8.8x, name = %s\n",
// this, module_sp.get(), sect_id, file_addr, file_addr + byte_size, file_offset, file_offset + file_size, flags, name.GetCString());
@@ -52,8 +50,8 @@ Section::Section (const lldb::SectionSP
SectionType sect_type,
addr_t file_addr,
addr_t byte_size,
- uint64_t file_offset,
- uint64_t file_size,
+ lldb::offset_t file_offset,
+ lldb::offset_t file_size,
uint32_t flags) :
ModuleChild (module_sp),
UserID (sect_id),
@@ -68,9 +66,7 @@ Section::Section (const lldb::SectionSP
m_children (),
m_fake (false),
m_encrypted (false),
- m_thread_specific (false),
- m_linked_section_wp(),
- m_linked_offset (0)
+ m_thread_specific (false)
{
// printf ("Section::Section(%p): module=%p, sect_id = 0x%16.16" PRIx64 ", addr=[0x%16.16" PRIx64 " - 0x%16.16" PRIx64 "), file [0x%16.16" PRIx64 " - 0x%16.16" PRIx64 "), flags = 0x%8.8x, name = %s.%s\n",
// this, module_sp.get(), sect_id, file_addr, file_addr + byte_size, file_offset, file_offset + file_size, flags, parent_section_sp->GetName().GetCString(), name.GetCString());
@@ -83,15 +79,6 @@ Section::~Section()
// printf ("Section::~Section(%p)\n", this);
}
-const ConstString&
-Section::GetName() const
-{
- SectionSP linked_section_sp (m_linked_section_wp.lock());
- if (linked_section_sp)
- return linked_section_sp->GetName();
- return m_name;
-}
-
addr_t
Section::GetFileAddress () const
{
@@ -119,53 +106,31 @@ Section::GetOffset () const
return 0;
}
-
-addr_t
-Section::GetLinkedFileAddress () const
-{
- SectionSP linked_section_sp (m_linked_section_wp.lock());
- if (linked_section_sp)
- return linked_section_sp->GetFileAddress() + m_linked_offset;
- return LLDB_INVALID_ADDRESS;
-}
-
-
addr_t
Section::GetLoadBaseAddress (Target *target) const
{
addr_t load_base_addr = LLDB_INVALID_ADDRESS;
- SectionSP linked_section_sp (m_linked_section_wp.lock());
- if (linked_section_sp)
+ SectionSP parent_sp (GetParent ());
+ if (parent_sp)
{
- load_base_addr = linked_section_sp->GetLoadBaseAddress(target);
+ load_base_addr = parent_sp->GetLoadBaseAddress (target);
if (load_base_addr != LLDB_INVALID_ADDRESS)
- load_base_addr += m_linked_offset;
+ load_base_addr += GetOffset();
}
else
{
- SectionSP parent_sp (GetParent ());
- if (parent_sp)
- {
- load_base_addr = parent_sp->GetLoadBaseAddress (target);
- if (load_base_addr != LLDB_INVALID_ADDRESS)
- load_base_addr += GetOffset();
- }
- else
- {
- load_base_addr = target->GetSectionLoadList().GetSectionLoadAddress (const_cast<Section *>(this)->shared_from_this());
- }
+ load_base_addr = target->GetSectionLoadList().GetSectionLoadAddress (const_cast<Section *>(this)->shared_from_this());
}
-
return load_base_addr;
}
bool
Section::ResolveContainedAddress (addr_t offset, Address &so_addr) const
{
- const uint32_t num_children = m_children.GetSize();
+ const size_t num_children = m_children.GetSize();
if (num_children > 0)
{
- for (uint32_t i=0; i<num_children; i++)
+ for (size_t i=0; i<num_children; i++)
{
Section* child_section = m_children.GetSectionAtIndex (i).get();
@@ -174,22 +139,13 @@ Section::ResolveContainedAddress (addr_t
return child_section->ResolveContainedAddress (offset - child_offset, so_addr);
}
}
- SectionSP linked_section_sp (m_linked_section_wp.lock());
- if (linked_section_sp)
- {
- so_addr.SetOffset(m_linked_offset + offset);
- so_addr.SetSection(linked_section_sp);
- }
- else
- {
- so_addr.SetOffset(offset);
- so_addr.SetSection(const_cast<Section *>(this)->shared_from_this());
-
+ so_addr.SetOffset(offset);
+ so_addr.SetSection(const_cast<Section *>(this)->shared_from_this());
+
#ifdef LLDB_CONFIGURATION_DEBUG
- // For debug builds, ensure that there are no orphaned (i.e., moduleless) sections.
- assert(GetModule().get());
+ // For debug builds, ensure that there are no orphaned (i.e., moduleless) sections.
+ assert(GetModule().get());
#endif
- }
return true;
}
@@ -208,21 +164,6 @@ Section::ContainsFileAddress (addr_t vm_
return false;
}
-bool
-Section::ContainsLinkedFileAddress (addr_t vm_addr) const
-{
- const addr_t linked_file_addr = GetLinkedFileAddress();
- if (linked_file_addr != LLDB_INVALID_ADDRESS)
- {
- if (linked_file_addr <= vm_addr)
- {
- const addr_t offset = vm_addr - linked_file_addr;
- return offset < GetByteSize();
- }
- }
- return false;
-}
-
int
Section::Compare (const Section& a, const Section& b)
{
@@ -261,12 +202,11 @@ Section::Dump (Stream *s, Target *target
bool resolved = true;
addr_t addr = LLDB_INVALID_ADDRESS;
- SectionSP linked_section_sp (m_linked_section_wp.lock());
if (GetByteSize() == 0)
s->Printf("%39s", "");
else
{
- if (target && linked_section_sp.get() == NULL)
+ if (target)
addr = GetLoadBaseAddress (target);
if (addr == LLDB_INVALID_ADDRESS)
@@ -286,35 +226,6 @@ Section::Dump (Stream *s, Target *target
s->EOL();
- if (linked_section_sp)
- {
- addr = LLDB_INVALID_ADDRESS;
- resolved = true;
- if (target)
- {
- addr = linked_section_sp->GetLoadBaseAddress(target);
- if (addr != LLDB_INVALID_ADDRESS)
- addr += m_linked_offset;
- }
-
- if (addr == LLDB_INVALID_ADDRESS)
- {
- if (target)
- resolved = false;
- addr = linked_section_sp->GetFileAddress() + m_linked_offset;
- }
-
- int indent = 28 + s->GetIndentLevel();
- s->Printf("%*.*s", indent, indent, "");
- VMRange linked_range(addr, addr + m_byte_size);
- linked_range.Dump (s, 0);
- indent = 3 * (sizeof(uint32_t) * 2 + 2 + 1) + 1;
- s->Printf("%c%*.*s", resolved ? ' ' : '*', indent, indent, "");
-
- linked_section_sp->DumpName(s);
- s->Printf(" + 0x%" PRIx64 "\n", m_linked_offset);
- }
-
if (depth > 0)
m_children.Dump(s, target, false, depth - 1);
}
@@ -371,22 +282,10 @@ Section::Slide (addr_t slide_amount, boo
return false;
}
-void
-Section::SetLinkedLocation (const lldb::SectionSP &linked_section_sp, uint64_t linked_offset)
-{
- if (linked_section_sp)
- m_module_wp = linked_section_sp->GetModule();
- m_linked_section_wp = linked_section_sp;
- m_linked_offset = linked_offset;
-}
-
#pragma mark SectionList
SectionList::SectionList () :
m_sections()
-#ifdef LLDB_CONFIGURATION_DEBUG
- , m_finalized(false)
-#endif
{
}
@@ -395,17 +294,16 @@ SectionList::~SectionList ()
{
}
-uint32_t
+size_t
SectionList::AddSection (const lldb::SectionSP& section_sp)
{
assert (section_sp.get());
- uint32_t section_index = m_sections.size();
+ size_t section_index = m_sections.size();
m_sections.push_back(section_sp);
- InvalidateRangeCache();
return section_index;
}
-uint32_t
+size_t
SectionList::FindSectionIndex (const Section* sect)
{
iterator sect_iter;
@@ -422,10 +320,10 @@ SectionList::FindSectionIndex (const Sec
return UINT32_MAX;
}
-uint32_t
+size_t
SectionList::AddUniqueSection (const lldb::SectionSP& sect_sp)
{
- uint32_t sect_idx = FindSectionIndex (sect_sp.get());
+ size_t sect_idx = FindSectionIndex (sect_sp.get());
if (sect_idx == UINT32_MAX)
sect_idx = AddSection (sect_sp);
return sect_idx;
@@ -441,7 +339,6 @@ SectionList::ReplaceSection (user_id_t s
if ((*sect_iter)->GetID() == sect_id)
{
*sect_iter = sect_sp;
- InvalidateRangeCache();
return true;
}
else if (depth > 0)
@@ -470,7 +367,7 @@ SectionList::GetNumSections (uint32_t de
}
SectionSP
-SectionList::GetSectionAtIndex (uint32_t idx) const
+SectionList::GetSectionAtIndex (size_t idx) const
{
SectionSP sect_sp;
if (idx < m_sections.size())
@@ -530,11 +427,11 @@ SectionList::FindSectionByID (user_id_t
SectionSP
-SectionList::FindSectionByType (SectionType sect_type, bool check_children, uint32_t start_idx) const
+SectionList::FindSectionByType (SectionType sect_type, bool check_children, size_t start_idx) const
{
SectionSP sect_sp;
- uint32_t num_sections = m_sections.size();
- for (uint32_t idx = start_idx; idx < num_sections; ++idx)
+ size_t num_sections = m_sections.size();
+ for (size_t idx = start_idx; idx < num_sections; ++idx)
{
if (m_sections[idx]->GetType() == sect_type)
{
@@ -575,71 +472,6 @@ SectionList::FindSectionContainingFileAd
return sect_sp;
}
-void
-SectionList::BuildRangeCache() const
-{
- m_range_cache.Clear();
-
- for (collection::size_type idx = 0, last_idx = m_sections.size();
- idx < last_idx;
- ++idx)
- {
- Section *sect = m_sections[idx].get();
-
- addr_t linked_file_address = sect->GetLinkedFileAddress();
-
- if (linked_file_address != LLDB_INVALID_ADDRESS)
- m_range_cache.Append(SectionRangeCache::Entry(linked_file_address, sect->GetByteSize(), idx));
- }
-
- m_range_cache.Sort();
-
-#ifdef LLDB_CONFIGURATION_DEBUG
- m_finalized = true;
-#endif
-}
-
-void
-SectionList::InvalidateRangeCache() const
-{
-#ifdef LLDB_CONFIGURATION_DEBUG
- assert(!m_finalized);
-#endif
- m_range_cache.Clear();
-}
-
-SectionSP
-SectionList::FindSectionContainingLinkedFileAddress (addr_t vm_addr, uint32_t depth) const
-{
- //if (m_range_cache.IsEmpty())
- // BuildRangeCache();
-#ifdef LLDB_CONFIGURATION_DEBUG
- assert(m_finalized);
-#endif
-
- SectionRangeCache::Entry *entry = m_range_cache.FindEntryThatContains(vm_addr);
-
- if (entry)
- return m_sections[entry->data];
-
- if (depth == 0)
- return SectionSP();
-
- for (const_iterator si = m_sections.begin(), se = m_sections.end();
- si != se;
- ++si)
- {
- Section *sect = si->get();
-
- SectionSP sect_sp = sect->GetChildren().FindSectionContainingLinkedFileAddress(vm_addr, depth - 1);
-
- if (sect_sp)
- return sect_sp;
- }
-
- return SectionSP();
-}
-
bool
SectionList::ContainsSection(user_id_t sect_id) const
{
@@ -681,15 +513,12 @@ SectionList::Slide (addr_t slide_amount,
if ((*pos)->Slide(slide_amount, slide_children))
++count;
}
- InvalidateRangeCache();
return count;
}
void
SectionList::Finalize ()
{
- BuildRangeCache();
-
for (const_iterator si = m_sections.begin(), se = m_sections.end();
si != se;
++si)
Modified: lldb/branches/windows/source/Core/SourceManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/SourceManager.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/SourceManager.cpp (original)
+++ lldb/branches/windows/source/Core/SourceManager.cpp Wed Apr 17 03:38:48 2013
@@ -25,8 +25,10 @@
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Target/Target.h"
+using namespace lldb;
using namespace lldb_private;
+
static inline bool is_newline_char(char ch)
{
return ch == '\n' || ch == '\r';
@@ -36,26 +38,23 @@ static inline bool is_newline_char(char
//----------------------------------------------------------------------
// SourceManager constructor
//----------------------------------------------------------------------
-SourceManager::SourceManager(Target &target) :
+SourceManager::SourceManager(const TargetSP &target_sp) :
m_last_file_sp (),
- m_last_file_line (0),
- m_last_file_context_before (0),
- m_last_file_context_after (10),
+ m_last_line (0),
+ m_last_count (0),
m_default_set(false),
- m_target (&target),
- m_debugger(NULL)
+ m_target_wp (target_sp),
+ m_debugger_wp(target_sp->GetDebugger().shared_from_this())
{
- m_debugger = &(m_target->GetDebugger());
}
-SourceManager::SourceManager(Debugger &debugger) :
+SourceManager::SourceManager(const DebuggerSP &debugger_sp) :
m_last_file_sp (),
- m_last_file_line (0),
- m_last_file_context_before (0),
- m_last_file_context_after (10),
+ m_last_line (0),
+ m_last_count (0),
m_default_set(false),
- m_target (NULL),
- m_debugger (&debugger)
+ m_target_wp (),
+ m_debugger_wp (debugger_sp)
{
}
@@ -66,88 +65,80 @@ SourceManager::~SourceManager()
{
}
-size_t
-SourceManager::DisplaySourceLines
-(
- const FileSpec &file_spec,
- uint32_t line,
- uint32_t context_before,
- uint32_t context_after,
- Stream *s
-)
-{
- m_last_file_sp = GetFile (file_spec);
- m_last_file_line = line + context_after + 1;
- m_last_file_context_before = context_before;
- m_last_file_context_after = context_after;
- if (m_last_file_sp.get())
- return m_last_file_sp->DisplaySourceLines (line, context_before, context_after, s);
-
- return 0;
-}
-
SourceManager::FileSP
SourceManager::GetFile (const FileSpec &file_spec)
{
+ bool same_as_previous = m_last_file_sp && m_last_file_sp->FileSpecMatches (file_spec);
+
+ DebuggerSP debugger_sp (m_debugger_wp.lock());
FileSP file_sp;
- file_sp = m_debugger->GetSourceFileCache().FindSourceFile (file_spec);
+ if (same_as_previous)
+ file_sp = m_last_file_sp;
+ else if (debugger_sp)
+ file_sp = debugger_sp->GetSourceFileCache().FindSourceFile (file_spec);
+
+ TargetSP target_sp (m_target_wp.lock());
+
+ // It the target source path map has been updated, get this file again so we
+ // can successfully remap the source file
+ if (target_sp && file_sp && file_sp->GetSourceMapModificationID() != target_sp->GetSourcePathMap().GetModificationID())
+ file_sp.reset();
+
// If file_sp is no good or it points to a non-existent file, reset it.
if (!file_sp || !file_sp->GetFileSpec().Exists())
{
- file_sp.reset (new File (file_spec, m_target));
+ file_sp.reset (new File (file_spec, target_sp.get()));
- m_debugger->GetSourceFileCache().AddSourceFile(file_sp);
+ if (debugger_sp)
+ debugger_sp->GetSourceFileCache().AddSourceFile(file_sp);
}
return file_sp;
}
size_t
-SourceManager::DisplaySourceLinesWithLineNumbersUsingLastFile
-(
- uint32_t line,
- uint32_t context_before,
- uint32_t context_after,
- const char* current_line_cstr,
- Stream *s,
- const SymbolContextList *bp_locs
-)
+SourceManager::DisplaySourceLinesWithLineNumbersUsingLastFile (uint32_t start_line,
+ uint32_t count,
+ uint32_t curr_line,
+ const char* current_line_cstr,
+ Stream *s,
+ const SymbolContextList *bp_locs)
{
+ if (count == 0)
+ return 0;
size_t return_value = 0;
- if (line == 0)
+ if (start_line == 0)
{
- if (m_last_file_line != 0
- && m_last_file_line != UINT32_MAX)
- line = m_last_file_line + context_before;
+ if (m_last_line != 0 && m_last_line != UINT32_MAX)
+ start_line = m_last_line + m_last_count;
else
- line = 1;
+ start_line = 1;
}
- m_last_file_line = line + context_after + 1;
- m_last_file_context_before = context_before;
- m_last_file_context_after = context_after;
+ if (!m_default_set)
+ {
+ FileSpec tmp_spec;
+ uint32_t tmp_line;
+ GetDefaultFileAndLine(tmp_spec, tmp_line);
+ }
- if (context_before == UINT32_MAX)
- context_before = 0;
- if (context_after == UINT32_MAX)
- context_after = 10;
+ m_last_line = start_line;
+ m_last_count = count;
if (m_last_file_sp.get())
{
- const uint32_t start_line = line <= context_before ? 1 : line - context_before;
- const uint32_t end_line = line + context_after;
- uint32_t curr_line;
- for (curr_line = start_line; curr_line <= end_line; ++curr_line)
+ const uint32_t end_line = start_line + count - 1;
+ for (uint32_t line = start_line; line <= end_line; ++line)
{
- if (!m_last_file_sp->LineIsValid (curr_line))
+ if (!m_last_file_sp->LineIsValid (line))
{
- m_last_file_line = UINT32_MAX;
+ m_last_line = UINT32_MAX;
break;
}
char prefix[32] = "";
if (bp_locs)
{
- uint32_t bp_count = bp_locs->NumLineEntriesWithLine (curr_line);
+ uint32_t bp_count = bp_locs->NumLineEntriesWithLine (line);
if (bp_count > 0)
::snprintf (prefix, sizeof (prefix), "[%u] ", bp_count);
@@ -156,13 +147,13 @@ SourceManager::DisplaySourceLinesWithLin
}
return_value += s->Printf("%s%2.2s %-4u\t",
- prefix,
- curr_line == line ? current_line_cstr : "",
- curr_line);
- size_t this_line_size = m_last_file_sp->DisplaySourceLines (curr_line, 0, 0, s);
+ prefix,
+ line == curr_line ? current_line_cstr : "",
+ line);
+ size_t this_line_size = m_last_file_sp->DisplaySourceLines (line, 0, 0, s);
if (this_line_size == 0)
{
- m_last_file_line = UINT32_MAX;
+ m_last_line = UINT32_MAX;
break;
}
else
@@ -184,28 +175,70 @@ SourceManager::DisplaySourceLinesWithLin
const SymbolContextList *bp_locs
)
{
- bool same_as_previous = m_last_file_sp && m_last_file_sp->FileSpecMatches (file_spec);
+ FileSP file_sp (GetFile (file_spec));
- if (!same_as_previous)
- m_last_file_sp = GetFile (file_spec);
-
- if (line == 0)
+ uint32_t start_line;
+ uint32_t count = context_before + context_after + 1;
+ if (line > context_before)
+ start_line = line - context_before;
+ else
+ start_line = 1;
+
+ if (m_last_file_sp.get() != file_sp.get())
{
- if (!same_as_previous)
- m_last_file_line = 0;
+ if (line == 0)
+ m_last_line = 0;
+ m_last_file_sp = file_sp;
}
-
- return DisplaySourceLinesWithLineNumbersUsingLastFile (line, context_before, context_after, current_line_cstr, s, bp_locs);
+ return DisplaySourceLinesWithLineNumbersUsingLastFile (start_line, count, line, current_line_cstr, s, bp_locs);
}
size_t
-SourceManager::DisplayMoreWithLineNumbers (Stream *s, const SymbolContextList *bp_locs)
-{
+SourceManager::DisplayMoreWithLineNumbers (Stream *s,
+ uint32_t count,
+ bool reverse,
+ const SymbolContextList *bp_locs)
+{
+ // If we get called before anybody has set a default file and line, then try to figure it out here.
+ const bool have_default_file_line = m_last_file_sp && m_last_line > 0;
+ if (!m_default_set)
+ {
+ FileSpec tmp_spec;
+ uint32_t tmp_line;
+ GetDefaultFileAndLine(tmp_spec, tmp_line);
+ }
+
if (m_last_file_sp)
{
- if (m_last_file_line == UINT32_MAX)
+ if (m_last_line == UINT32_MAX)
return 0;
- return DisplaySourceLinesWithLineNumbersUsingLastFile (0, m_last_file_context_before, m_last_file_context_after, "", s, bp_locs);
+
+ if (reverse && m_last_line == 1)
+ return 0;
+
+ if (count > 0)
+ m_last_count = count;
+ else if (m_last_count == 0)
+ m_last_count = 10;
+
+ if (m_last_line > 0)
+ {
+ if (reverse)
+ {
+ // If this is the first time we've done a reverse, then back up one more time so we end
+ // up showing the chunk before the last one we've shown:
+ if (m_last_line > m_last_count)
+ m_last_line -= m_last_count;
+ else
+ m_last_line = 1;
+ }
+ else if (have_default_file_line)
+ m_last_line += m_last_count;
+ }
+ else
+ m_last_line = 1;
+
+ return DisplaySourceLinesWithLineNumbersUsingLastFile (m_last_line, m_last_count, UINT32_MAX, "", s, bp_locs);
}
return 0;
}
@@ -219,7 +252,7 @@ SourceManager::SetDefaultFileAndLine (co
m_default_set = true;
if (m_last_file_sp)
{
- m_last_file_line = line;
+ m_last_line = line;
return true;
}
else
@@ -235,38 +268,48 @@ SourceManager::GetDefaultFileAndLine (Fi
if (m_last_file_sp)
{
file_spec = m_last_file_sp->GetFileSpec();
- line = m_last_file_line;
+ line = m_last_line;
return true;
}
else if (!m_default_set)
{
- // If nobody has set the default file and line then try here. If there's no executable, then we
- // will try again later when there is one. Otherwise, if we can't find it we won't look again,
- // somebody will have to set it (for instance when we stop somewhere...)
- Module *executable_ptr = m_target->GetExecutableModulePointer();
- if (executable_ptr)
+ TargetSP target_sp (m_target_wp.lock());
+
+ if (target_sp)
{
- SymbolContextList sc_list;
- uint32_t num_matches;
- ConstString main_name("main");
- bool symbols_okay = false; // Force it to be a debug symbol.
- bool inlines_okay = true;
- bool append = false;
- num_matches = executable_ptr->FindFunctions (main_name, NULL, lldb::eFunctionNameTypeBase, inlines_okay, symbols_okay, append, sc_list);
- for (uint32_t idx = 0; idx < num_matches; idx++)
+ // If nobody has set the default file and line then try here. If there's no executable, then we
+ // will try again later when there is one. Otherwise, if we can't find it we won't look again,
+ // somebody will have to set it (for instance when we stop somewhere...)
+ Module *executable_ptr = target_sp->GetExecutableModulePointer();
+ if (executable_ptr)
{
- SymbolContext sc;
- sc_list.GetContextAtIndex(idx, sc);
- if (sc.function)
+ SymbolContextList sc_list;
+ ConstString main_name("main");
+ bool symbols_okay = false; // Force it to be a debug symbol.
+ bool inlines_okay = true;
+ bool append = false;
+ size_t num_matches = executable_ptr->FindFunctions (main_name,
+ NULL,
+ lldb::eFunctionNameTypeBase,
+ inlines_okay,
+ symbols_okay,
+ append,
+ sc_list);
+ for (size_t idx = 0; idx < num_matches; idx++)
{
- lldb_private::LineEntry line_entry;
- if (sc.function->GetAddressRange().GetBaseAddress().CalculateSymbolContextLineEntry (line_entry))
+ SymbolContext sc;
+ sc_list.GetContextAtIndex(idx, sc);
+ if (sc.function)
{
- SetDefaultFileAndLine (line_entry.file,
- line_entry.line);
- file_spec = m_last_file_sp->GetFileSpec();
- line = m_last_file_line;
- return true;
+ lldb_private::LineEntry line_entry;
+ if (sc.function->GetAddressRange().GetBaseAddress().CalculateSymbolContextLineEntry (line_entry))
+ {
+ SetDefaultFileAndLine (line_entry.file,
+ line_entry.line);
+ file_spec = m_last_file_sp->GetFileSpec();
+ line = m_last_line;
+ return true;
+ }
}
}
}
@@ -293,6 +336,7 @@ SourceManager::File::File(const FileSpec
m_file_spec_orig (file_spec),
m_file_spec(file_spec),
m_mod_time (file_spec.GetModificationTime()),
+ m_source_map_mod_id (0),
m_data_sp(),
m_offsets()
{
@@ -300,6 +344,8 @@ SourceManager::File::File(const FileSpec
{
if (target)
{
+ m_source_map_mod_id = target->GetSourcePathMap().GetModificationID();
+
if (!file_spec.GetDirectory() && file_spec.GetFilename())
{
// If this is just a file name, lets see if we can find it in the target:
@@ -527,11 +573,14 @@ SourceManager::File::CalculateLineOffset
register char curr_ch = *s;
if (is_newline_char (curr_ch))
{
- register char next_ch = s[1];
- if (is_newline_char (next_ch))
+ if (s + 1 < end)
{
- if (curr_ch != next_ch)
- ++s;
+ register char next_ch = s[1];
+ if (is_newline_char (next_ch))
+ {
+ if (curr_ch != next_ch)
+ ++s;
+ }
}
m_offsets.push_back(s + 1 - start);
}
@@ -547,14 +596,14 @@ SourceManager::File::CalculateLineOffset
else
{
// Some lines have been populated, start where we last left off
- assert(!"Not implemented yet");
+ assert("Not implemented yet" == NULL);
}
}
else
{
// Calculate all line offsets up to "line"
- assert(!"Not implemented yet");
+ assert("Not implemented yet" == NULL);
}
return false;
}
@@ -565,8 +614,8 @@ SourceManager::File::GetLine (uint32_t l
if (!LineIsValid(line_no))
return false;
- uint32_t start_offset = GetLineOffset (line_no);
- uint32_t end_offset = GetLineOffset (line_no + 1);
+ size_t start_offset = GetLineOffset (line_no);
+ size_t end_offset = GetLineOffset (line_no + 1);
if (end_offset == UINT32_MAX)
{
end_offset = m_data_sp->GetByteSize();
Modified: lldb/branches/windows/source/Core/Stream.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/Stream.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/Stream.cpp (original)
+++ lldb/branches/windows/source/Core/Stream.cpp Wed Apr 17 03:38:48 2013
@@ -66,10 +66,10 @@ Stream::Offset (uint32_t uval, const cha
// Put an SLEB128 "uval" out to the stream using the printf format
// in "format".
//------------------------------------------------------------------
-int
+size_t
Stream::PutSLEB128 (int64_t sval)
{
- int bytes_written = 0;
+ size_t bytes_written = 0;
if (m_flags.Test(eBinary))
{
bool more = true;
@@ -89,11 +89,7 @@ Stream::PutSLEB128 (int64_t sval)
}
else
{
-#ifdef _WIN32
- bytes_written = Printf ("0x%llu", sval);
-#else
bytes_written = Printf ("0x%" PRIi64, sval);
-#endif
}
return bytes_written;
@@ -104,10 +100,10 @@ Stream::PutSLEB128 (int64_t sval)
// Put an ULEB128 "uval" out to the stream using the printf format
// in "format".
//------------------------------------------------------------------
-int
+size_t
Stream::PutULEB128 (uint64_t uval)
{
- int bytes_written = 0;
+ size_t bytes_written = 0;
if (m_flags.Test(eBinary))
{
do
@@ -125,11 +121,7 @@ Stream::PutULEB128 (uint64_t uval)
}
else
{
-#ifdef _WIN32
- bytes_written = Printf ("0x%llu", uval);
-#else
bytes_written = Printf ("0x%" PRIi64, uval);
-#endif
}
return bytes_written;
}
@@ -137,10 +129,10 @@ Stream::PutULEB128 (uint64_t uval)
//------------------------------------------------------------------
// Print a raw NULL terminated C string to the stream.
//------------------------------------------------------------------
-int
+size_t
Stream::PutCString (const char *cstr)
{
- int cstr_len = strlen(cstr);
+ size_t cstr_len = strlen(cstr);
// when in binary mode, emit the NULL terminator
if (m_flags.Test(eBinary))
++cstr_len;
@@ -162,7 +154,7 @@ Stream::QuotedCString (const char *cstr,
// and suffix strings.
//------------------------------------------------------------------
void
-Stream::Address (uint64_t addr, int addr_size, const char *prefix, const char *suffix)
+Stream::Address (uint64_t addr, uint32_t addr_size, const char *prefix, const char *suffix)
{
if (prefix == NULL)
prefix = "";
@@ -170,11 +162,7 @@ Stream::Address (uint64_t addr, int addr
suffix = "";
// int addr_width = m_addr_size << 1;
// Printf ("%s0x%0*" PRIx64 "%s", prefix, addr_width, addr, suffix);
-#if _WIN32
- Printf ("%s0x%d*%llu%s", prefix, addr_size * 2, (uint64_t)addr, suffix);
-#else
Printf ("%s0x%0*" PRIx64 "%s", prefix, addr_size * 2, (uint64_t)addr, suffix);
-#endif
}
//------------------------------------------------------------------
@@ -182,7 +170,7 @@ Stream::Address (uint64_t addr, int addr
// and suffix strings.
//------------------------------------------------------------------
void
-Stream::AddressRange(uint64_t lo_addr, uint64_t hi_addr, int addr_size, const char *prefix, const char *suffix)
+Stream::AddressRange(uint64_t lo_addr, uint64_t hi_addr, uint32_t addr_size, const char *prefix, const char *suffix)
{
if (prefix && prefix[0])
PutCString (prefix);
@@ -193,7 +181,7 @@ Stream::AddressRange(uint64_t lo_addr, u
}
-int
+size_t
Stream::PutChar (char ch)
{
return Write (&ch, 1);
@@ -203,7 +191,7 @@ Stream::PutChar (char ch)
//------------------------------------------------------------------
// Print some formatted output to the stream.
//------------------------------------------------------------------
-int
+size_t
Stream::Printf (const char *format, ...)
{
va_list args;
@@ -216,7 +204,7 @@ Stream::Printf (const char *format, ...)
//------------------------------------------------------------------
// Print some formatted output to the stream.
//------------------------------------------------------------------
-int
+size_t
Stream::PrintfVarArg (const char *format, va_list args)
{
char str[1024];
@@ -224,7 +212,7 @@ Stream::PrintfVarArg (const char *format
va_copy (args_copy, args);
- int bytes_written = 0;
+ size_t bytes_written = 0;
// Try and format our string into a fixed buffer first and see if it fits
size_t length = ::vsnprintf (str, sizeof(str), format, args);
if (length < sizeof(str))
@@ -258,7 +246,7 @@ Stream::PrintfVarArg (const char *format
//------------------------------------------------------------------
// Print and End of Line character to the stream
//------------------------------------------------------------------
-int
+size_t
Stream::EOL()
{
return PutChar ('\n');
@@ -268,7 +256,7 @@ Stream::EOL()
// Indent the current line using the current indentation level and
// print an optional string following the idenatation spaces.
//------------------------------------------------------------------
-int
+size_t
Stream::Indent(const char *s)
{
return Printf ("%*.*s%s", m_indent_level, m_indent_level, "", s ? s : "");
@@ -380,11 +368,7 @@ Stream::operator<< (int32_t sval)
Stream&
Stream::operator<< (int64_t sval)
{
-#if _WIN32
- Printf ("%llu", sval);
-#else
Printf ("%" PRIi64, sval);
-#endif
return *this;
}
@@ -430,7 +414,7 @@ Stream::IndentLess (int amount)
//------------------------------------------------------------------
// Get the address size in bytes
//------------------------------------------------------------------
-uint8_t
+uint32_t
Stream::GetAddressByteSize() const
{
return m_addr_size;
@@ -440,7 +424,7 @@ Stream::GetAddressByteSize() const
// Set the address size in bytes
//------------------------------------------------------------------
void
-Stream::SetAddressByteSize(uint8_t addr_size)
+Stream::SetAddressByteSize(uint32_t addr_size)
{
m_addr_size = addr_size;
}
@@ -491,7 +475,7 @@ Stream::GetByteOrder() const
return m_byte_order;
}
-int
+size_t
Stream::PrintfAsRawHex8 (const char *format, ...)
{
va_list args;
@@ -500,7 +484,7 @@ Stream::PrintfAsRawHex8 (const char *for
va_copy (args, args_copy); // Copy this so we
char str[1024];
- int bytes_written = 0;
+ size_t bytes_written = 0;
// Try and format our string into a fixed buffer first and see if it fits
size_t length = ::vsnprintf (str, sizeof(str), format, args);
if (length < sizeof(str))
@@ -529,19 +513,19 @@ Stream::PrintfAsRawHex8 (const char *for
return bytes_written;
}
-int
+size_t
Stream::PutNHex8 (size_t n, uint8_t uvalue)
{
- int bytes_written = 0;
+ size_t bytes_written = 0;
for (size_t i=0; i<n; ++i)
bytes_written += _PutHex8 (uvalue, m_flags.Test(eAddPrefix));
return bytes_written;
}
-int
+size_t
Stream::_PutHex8 (uint8_t uvalue, bool add_prefix)
{
- int bytes_written = 0;
+ size_t bytes_written = 0;
if (m_flags.Test(eBinary))
{
bytes_written = Write (&uvalue, 1);
@@ -560,76 +544,76 @@ Stream::_PutHex8 (uint8_t uvalue, bool a
return bytes_written;
}
-int
+size_t
Stream::PutHex8 (uint8_t uvalue)
{
return _PutHex8 (uvalue, m_flags.Test(eAddPrefix));
}
-int
+size_t
Stream::PutHex16 (uint16_t uvalue, ByteOrder byte_order)
{
if (byte_order == eByteOrderInvalid)
byte_order = m_byte_order;
bool add_prefix = m_flags.Test(eAddPrefix);
- int bytes_written = 0;
+ size_t bytes_written = 0;
if (byte_order == eByteOrderLittle)
{
for (size_t byte = 0; byte < sizeof(uvalue); ++byte, add_prefix = false)
- bytes_written += _PutHex8 (uvalue >> (byte * 8), add_prefix);
+ bytes_written += _PutHex8 ((uint8_t)(uvalue >> (byte * 8)), add_prefix);
}
else
{
for (size_t byte = sizeof(uvalue)-1; byte < sizeof(uvalue); --byte, add_prefix = false)
- bytes_written += _PutHex8 (uvalue >> (byte * 8), add_prefix);
+ bytes_written += _PutHex8 ((uint8_t)(uvalue >> (byte * 8)), add_prefix);
}
return bytes_written;
}
-int
+size_t
Stream::PutHex32(uint32_t uvalue, ByteOrder byte_order)
{
if (byte_order == eByteOrderInvalid)
byte_order = m_byte_order;
bool add_prefix = m_flags.Test(eAddPrefix);
- int bytes_written = 0;
+ size_t bytes_written = 0;
if (byte_order == eByteOrderLittle)
{
for (size_t byte = 0; byte < sizeof(uvalue); ++byte, add_prefix = false)
- bytes_written += _PutHex8 (uvalue >> (byte * 8), add_prefix);
+ bytes_written += _PutHex8 ((uint8_t)(uvalue >> (byte * 8)), add_prefix);
}
else
{
for (size_t byte = sizeof(uvalue)-1; byte < sizeof(uvalue); --byte, add_prefix = false)
- bytes_written += _PutHex8 (uvalue >> (byte * 8), add_prefix);
+ bytes_written += _PutHex8 ((uint8_t)(uvalue >> (byte * 8)), add_prefix);
}
return bytes_written;
}
-int
+size_t
Stream::PutHex64(uint64_t uvalue, ByteOrder byte_order)
{
if (byte_order == eByteOrderInvalid)
byte_order = m_byte_order;
bool add_prefix = m_flags.Test(eAddPrefix);
- int bytes_written = 0;
+ size_t bytes_written = 0;
if (byte_order == eByteOrderLittle)
{
for (size_t byte = 0; byte < sizeof(uvalue); ++byte, add_prefix = false)
- bytes_written += _PutHex8 (uvalue >> (byte * 8), add_prefix);
+ bytes_written += _PutHex8 ((uint8_t)(uvalue >> (byte * 8)), add_prefix);
}
else
{
for (size_t byte = sizeof(uvalue)-1; byte < sizeof(uvalue); --byte, add_prefix = false)
- bytes_written += _PutHex8 (uvalue >> (byte * 8), add_prefix);
+ bytes_written += _PutHex8 ((uint8_t)(uvalue >> (byte * 8)), add_prefix);
}
return bytes_written;
}
-int
+size_t
Stream::PutMaxHex64
(
uint64_t uvalue,
@@ -639,21 +623,21 @@ Stream::PutMaxHex64
{
switch (byte_size)
{
- case 1: return PutHex8 (uvalue);
- case 2: return PutHex16 (uvalue);
- case 4: return PutHex32 (uvalue);
+ case 1: return PutHex8 ((uint8_t)uvalue);
+ case 2: return PutHex16 ((uint16_t)uvalue);
+ case 4: return PutHex32 ((uint32_t)uvalue);
case 8: return PutHex64 (uvalue);
}
return 0;
}
-int
+size_t
Stream::PutPointer (void *ptr)
{
return PutRawBytes (&ptr, sizeof(ptr), lldb::endian::InlHostByteOrder(), lldb::endian::InlHostByteOrder());
}
-int
+size_t
Stream::PutFloat(float f, ByteOrder byte_order)
{
if (byte_order == eByteOrderInvalid)
@@ -662,7 +646,7 @@ Stream::PutFloat(float f, ByteOrder byte
return PutRawBytes (&f, sizeof(f), lldb::endian::InlHostByteOrder(), byte_order);
}
-int
+size_t
Stream::PutDouble(double d, ByteOrder byte_order)
{
if (byte_order == eByteOrderInvalid)
@@ -671,7 +655,7 @@ Stream::PutDouble(double d, ByteOrder by
return PutRawBytes (&d, sizeof(d), lldb::endian::InlHostByteOrder(), byte_order);
}
-int
+size_t
Stream::PutLongDouble(long double ld, ByteOrder byte_order)
{
if (byte_order == eByteOrderInvalid)
@@ -680,7 +664,7 @@ Stream::PutLongDouble(long double ld, By
return PutRawBytes (&ld, sizeof(ld), lldb::endian::InlHostByteOrder(), byte_order);
}
-int
+size_t
Stream::PutRawBytes (const void *s, size_t src_len, ByteOrder src_byte_order, ByteOrder dst_byte_order)
{
if (src_byte_order == eByteOrderInvalid)
@@ -689,7 +673,7 @@ Stream::PutRawBytes (const void *s, size
if (dst_byte_order == eByteOrderInvalid)
dst_byte_order = m_byte_order;
- int bytes_written = 0;
+ size_t bytes_written = 0;
const uint8_t *src = (const uint8_t *)s;
bool binary_was_set = m_flags.Test (eBinary);
if (!binary_was_set)
@@ -710,7 +694,7 @@ Stream::PutRawBytes (const void *s, size
return bytes_written;
}
-int
+size_t
Stream::PutBytesAsRawHex8 (const void *s, size_t src_len, ByteOrder src_byte_order, ByteOrder dst_byte_order)
{
if (src_byte_order == eByteOrderInvalid)
@@ -719,7 +703,7 @@ Stream::PutBytesAsRawHex8 (const void *s
if (dst_byte_order == eByteOrderInvalid)
dst_byte_order = m_byte_order;
- int bytes_written = 0;
+ size_t bytes_written = 0;
const uint8_t *src = (const uint8_t *)s;
bool binary_is_set = m_flags.Test(eBinary);
m_flags.Clear(eBinary);
@@ -739,10 +723,10 @@ Stream::PutBytesAsRawHex8 (const void *s
return bytes_written;
}
-int
+size_t
Stream::PutCStringAsRawHex8 (const char *s)
{
- int bytes_written = 0;
+ size_t bytes_written = 0;
bool binary_is_set = m_flags.Test(eBinary);
m_flags.Clear(eBinary);
do
Modified: lldb/branches/windows/source/Core/StreamAsynchronousIO.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/StreamAsynchronousIO.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/StreamAsynchronousIO.cpp (original)
+++ lldb/branches/windows/source/Core/StreamAsynchronousIO.cpp Wed Apr 17 03:38:48 2013
@@ -44,7 +44,7 @@ StreamAsynchronousIO::Flush ()
}
}
-int
+size_t
StreamAsynchronousIO::Write (const void *s, size_t length)
{
m_accumulated_data.Write (s, length);
Modified: lldb/branches/windows/source/Core/StreamCallback.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/StreamCallback.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/StreamCallback.cpp (original)
+++ lldb/branches/windows/source/Core/StreamCallback.cpp Wed Apr 17 03:38:48 2013
@@ -55,7 +55,7 @@ StreamCallback::Flush ()
out_stream.Clear();
}
-int
+size_t
StreamCallback::Write (const void *s, size_t length)
{
lldb::tid_t cur_tid = Host::GetCurrentThreadID();
Modified: lldb/branches/windows/source/Core/StreamFile.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/StreamFile.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/StreamFile.cpp (original)
+++ lldb/branches/windows/source/Core/StreamFile.cpp Wed Apr 17 03:38:48 2013
@@ -64,7 +64,7 @@ StreamFile::Flush ()
m_file.Flush();
}
-int
+size_t
StreamFile::Write (const void *s, size_t length)
{
m_file.Write (s, length);
Modified: lldb/branches/windows/source/Core/StreamString.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/StreamString.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/StreamString.cpp (original)
+++ lldb/branches/windows/source/Core/StreamString.cpp Wed Apr 17 03:38:48 2013
@@ -34,7 +34,7 @@ StreamString::Flush ()
// Nothing to do when flushing a buffer based stream...
}
-int
+size_t
StreamString::Write (const void *s, size_t length)
{
m_packet.append ((char *)s, length);
Modified: lldb/branches/windows/source/Core/StringList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/StringList.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/StringList.cpp (original)
+++ lldb/branches/windows/source/Core/StringList.cpp Wed Apr 17 03:38:48 2013
@@ -75,9 +75,9 @@ StringList::AppendList (const char **str
void
StringList::AppendList (StringList strings)
{
- uint32_t len = strings.GetSize();
+ size_t len = strings.GetSize();
- for (uint32_t i = 0; i < len; ++i)
+ for (size_t i = 0; i < len; ++i)
m_strings.push_back (strings.GetStringAtIndex(i));
}
@@ -87,7 +87,7 @@ StringList::ReadFileLines (FileSpec &inp
return input_file.ReadFileLines (m_strings);
}
-uint32_t
+size_t
StringList::GetSize () const
{
return m_strings.size();
@@ -104,7 +104,7 @@ StringList::GetStringAtIndex (size_t idx
void
StringList::Join (const char *separator, Stream &strm)
{
- uint32_t size = GetSize();
+ size_t size = GetSize();
if (size == 0)
return;
@@ -127,8 +127,8 @@ void
StringList::LongestCommonPrefix (std::string &common_prefix)
{
//arg_sstr_collection::iterator pos, end = m_args.end();
- int pos = 0;
- int end = m_strings.size();
+ size_t pos = 0;
+ size_t end = m_strings.size();
if (pos == end)
common_prefix.clear();
Modified: lldb/branches/windows/source/Core/Timer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/Timer.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/Timer.cpp (original)
+++ lldb/branches/windows/source/Core/Timer.cpp Wed Apr 17 03:38:48 2013
@@ -25,7 +25,7 @@ uint32_t Timer::g_depth = 0;
uint32_t Timer::g_display_depth = 0;
FILE * Timer::g_file = NULL;
typedef std::vector<Timer *> TimerStack;
-typedef std::map<const char *, uint64_t> CategoryMap;
+typedef std::map<const char *, uint64_t> TimerCategoryMap;
#ifdef _POSIX_SOURCE
static pthread_key_t g_key;
@@ -40,10 +40,10 @@ GetCategoryMutex()
return g_category_mutex;
}
-static CategoryMap &
+static TimerCategoryMap &
GetCategoryMap()
{
- static CategoryMap g_category_map;
+ static TimerCategoryMap g_category_map;
return g_category_map;
}
@@ -171,7 +171,7 @@ Timer::~Timer()
// Keep total results for each category so we can dump results.
Mutex::Locker locker (GetCategoryMutex());
- CategoryMap &category_map = GetCategoryMap();
+ TimerCategoryMap &category_map = GetCategoryMap();
category_map[m_category] += timer_nsec_uint;
}
if (g_depth > 0)
@@ -232,7 +232,7 @@ Timer::SetDisplayDepth (uint32_t depth)
* - returns whether a person is less than another person
*/
static bool
-CategoryMapIteratorSortCriterion (const CategoryMap::const_iterator& lhs, const CategoryMap::const_iterator& rhs)
+CategoryMapIteratorSortCriterion (const TimerCategoryMap::const_iterator& lhs, const TimerCategoryMap::const_iterator& rhs)
{
return lhs->second > rhs->second;
}
@@ -242,7 +242,7 @@ void
Timer::ResetCategoryTimes ()
{
Mutex::Locker locker (GetCategoryMutex());
- CategoryMap &category_map = GetCategoryMap();
+ TimerCategoryMap &category_map = GetCategoryMap();
category_map.clear();
}
@@ -250,9 +250,9 @@ void
Timer::DumpCategoryTimes (Stream *s)
{
Mutex::Locker locker (GetCategoryMutex());
- CategoryMap &category_map = GetCategoryMap();
- std::vector<CategoryMap::const_iterator> sorted_iterators;
- CategoryMap::const_iterator pos, end = category_map.end();
+ TimerCategoryMap &category_map = GetCategoryMap();
+ std::vector<TimerCategoryMap::const_iterator> sorted_iterators;
+ TimerCategoryMap::const_iterator pos, end = category_map.end();
for (pos = category_map.begin(); pos != end; ++pos)
{
sorted_iterators.push_back (pos);
Modified: lldb/branches/windows/source/Core/UUID.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/UUID.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/UUID.cpp (original)
+++ lldb/branches/windows/source/Core/UUID.cpp Wed Apr 17 03:38:48 2013
@@ -178,7 +178,7 @@ UUID::SetFromCString (const char *cstr)
while (isspace(*p))
++p;
- const uint32_t uuid_byte_idx = UUID::DecodeUUIDBytesFromCString (p, m_uuid, &p);
+ const size_t uuid_byte_idx = UUID::DecodeUUIDBytesFromCString (p, m_uuid, &p);
// If we successfully decoded a UUID, return the amount of characters that
// were consumed
Modified: lldb/branches/windows/source/Core/UserID.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/UserID.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/UserID.cpp (original)
+++ lldb/branches/windows/source/Core/UserID.cpp Wed Apr 17 03:38:48 2013
@@ -24,10 +24,6 @@ UserID::~UserID ()
Stream&
lldb_private::operator << (Stream& strm, const UserID& uid)
{
-#ifdef _WIN32
- strm.Printf("{0xllu}", uid.GetID());
-#else
strm.Printf("{0x%8.8" PRIx64 "}", uid.GetID());
-#endif
return strm;
}
Modified: lldb/branches/windows/source/Core/VMRange.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/VMRange.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/VMRange.cpp (original)
+++ lldb/branches/windows/source/Core/VMRange.cpp Wed Apr 17 03:38:48 2013
@@ -40,7 +40,7 @@ VMRange::ContainsRange(const VMRange::co
return false;
}
-uint32_t
+size_t
VMRange::FindRangeIndexThatContainsValue (const VMRange::collection& coll, lldb::addr_t value)
{
ValueInRangeUnaryPredicate in_range_predicate(value);
Modified: lldb/branches/windows/source/Core/Value.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/Value.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/Value.cpp (original)
+++ lldb/branches/windows/source/Core/Value.cpp Wed Apr 17 03:38:48 2013
@@ -144,7 +144,7 @@ Value::GetType()
}
void
-Value::ResizeData(int len)
+Value::ResizeData(size_t len)
{
m_value_type = eValueTypeHostAddress;
m_data_buffer.SetByteSize(len);
@@ -169,10 +169,10 @@ Value::ValueOf(ExecutionContext *exe_ctx
return false;
}
-size_t
+uint64_t
Value::GetValueByteSize (clang::ASTContext *ast_context, Error *error_ptr)
{
- size_t byte_size = 0;
+ uint64_t byte_size = 0;
switch (m_context_type)
{
@@ -190,8 +190,7 @@ Value::GetValueByteSize (clang::ASTConte
}
else
{
- uint64_t bit_width = ClangASTType::GetClangTypeBitWidth (ast_context, m_context);
- byte_size = (bit_width + 7 ) / 8;
+ byte_size = ClangASTType(ast_context, m_context).GetClangTypeByteSize();
}
break;
@@ -326,7 +325,7 @@ Value::GetData (DataExtractor &data)
}
Error
-Value::GetValueAsData (ExecutionContext *exe_ctx,
+Value::GetValueAsData (ExecutionContext *exe_ctx,
clang::ASTContext *ast_context,
DataExtractor &data,
uint32_t data_offset,
@@ -348,9 +347,8 @@ Value::GetValueAsData (ExecutionContext
data.SetByteOrder (lldb::endian::InlHostByteOrder());
if (m_context_type == eContextTypeClangType && ast_context)
{
- uint32_t ptr_bit_width = ClangASTType::GetClangTypeBitWidth (ast_context,
- ClangASTContext::GetVoidPtrType(ast_context, false));
- uint32_t ptr_byte_size = (ptr_bit_width + 7) / 8;
+ ClangASTType ptr_type (ast_context, ClangASTContext::GetVoidPtrType(ast_context, false));
+ uint64_t ptr_byte_size = ptr_type.GetClangTypeByteSize();
data.SetAddressByteSize (ptr_byte_size);
}
else
@@ -368,9 +366,54 @@ Value::GetValueAsData (ExecutionContext
else
{
Process *process = exe_ctx->GetProcessPtr();
- if (process == NULL)
+ if (process == NULL || !process->IsAlive())
{
- error.SetErrorString ("can't read load address (invalid process)");
+ Target *target = exe_ctx->GetTargetPtr();
+ if (target)
+ {
+ // Allow expressions to run and evaluate things when the target
+ // has memory sections loaded. This allows you to use "target modules load"
+ // to load your executable and any shared libraries, then execute
+ // commands where you can look at types in data sections.
+ const SectionLoadList &target_sections = target->GetSectionLoadList();
+ if (!target_sections.IsEmpty())
+ {
+ address = m_value.ULongLong(LLDB_INVALID_ADDRESS);
+ if (target_sections.ResolveLoadAddress(address, file_so_addr))
+ {
+ address_type = eAddressTypeLoad;
+ data.SetByteOrder(target->GetArchitecture().GetByteOrder());
+ data.SetAddressByteSize(target->GetArchitecture().GetAddressByteSize());
+ }
+ else
+ address = LLDB_INVALID_ADDRESS;
+ }
+// else
+// {
+// ModuleSP exe_module_sp (target->GetExecutableModule());
+// if (exe_module_sp)
+// {
+// address = m_value.ULongLong(LLDB_INVALID_ADDRESS);
+// if (address != LLDB_INVALID_ADDRESS)
+// {
+// if (exe_module_sp->ResolveFileAddress(address, file_so_addr))
+// {
+// data.SetByteOrder(target->GetArchitecture().GetByteOrder());
+// data.SetAddressByteSize(target->GetArchitecture().GetAddressByteSize());
+// address_type = eAddressTypeFile;
+// }
+// else
+// {
+// address = LLDB_INVALID_ADDRESS;
+// }
+// }
+// }
+// }
+ }
+ else
+ {
+ error.SetErrorString ("can't read load address (invalid process)");
+ }
}
else
{
@@ -515,7 +558,7 @@ Value::GetValueAsData (ExecutionContext
}
// If we got here, we need to read the value from memory
- uint32_t byte_size = GetValueByteSize (ast_context, &error);
+ size_t byte_size = GetValueByteSize (ast_context, &error);
// Bail if we encountered any errors getting the byte size
if (error.Fail())
@@ -602,16 +645,13 @@ Value::ResolveValue(ExecutionContext *ex
default:
case eValueTypeFileAddress:
- m_value.Clear();
- break;
-
case eValueTypeLoadAddress: // load address value
case eValueTypeHostAddress: // host address value (for memory in the process that is using liblldb)
{
- AddressType address_type = m_value_type == eValueTypeLoadAddress ? eAddressTypeLoad : eAddressTypeHost;
- lldb::addr_t addr = m_value.ULongLong(LLDB_INVALID_ADDRESS);
DataExtractor data;
- if (ClangASTType::ReadFromMemory (ast_context, opaque_clang_qual_type, exe_ctx, addr, address_type, data))
+ lldb::addr_t addr = m_value.ULongLong(LLDB_INVALID_ADDRESS);
+ Error error (GetValueAsData (exe_ctx, ast_context, data, 0, NULL));
+ if (error.Success())
{
Scalar scalar;
if (ClangASTType::GetValueAsScalar (ast_context, opaque_clang_qual_type, data, 0, data.GetByteSize(), scalar))
Modified: lldb/branches/windows/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/ValueObject.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/ValueObject.cpp (original)
+++ lldb/branches/windows/source/Core/ValueObject.cpp Wed Apr 17 03:38:48 2013
@@ -21,7 +21,6 @@
// Project includes
#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/DataVisualization.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
@@ -34,6 +33,8 @@
#include "lldb/Core/ValueObjectMemory.h"
#include "lldb/Core/ValueObjectSyntheticFilter.h"
+#include "lldb/DataFormatters/DataVisualization.h"
+
#include "lldb/Host/Endian.h"
#include "lldb/Interpreter/CommandInterpreter.h"
@@ -51,8 +52,6 @@
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
-#include "lldb/Utility/RefCounter.h"
-
using namespace lldb;
using namespace lldb_private;
using namespace lldb_utility;
@@ -65,6 +64,7 @@ static user_id_t g_value_obj_uid = 0;
ValueObject::ValueObject (ValueObject &parent) :
UserID (++g_value_obj_uid), // Unique identifier for every value object
m_parent (&parent),
+ m_root (NULL),
m_update_point (parent.GetUpdatePoint ()),
m_name (),
m_data (),
@@ -83,7 +83,6 @@ ValueObject::ValueObject (ValueObject &p
m_deref_valobj(NULL),
m_format (eFormatDefault),
m_last_format_mgr_revision(0),
- m_last_format_mgr_dynamic(parent.m_last_format_mgr_dynamic),
m_type_summary_sp(),
m_type_format_sp(),
m_synthetic_children_sp(),
@@ -96,7 +95,6 @@ ValueObject::ValueObject (ValueObject &p
m_is_deref_of_parent (false),
m_is_array_item_for_pointer(false),
m_is_bitfield_for_scalar(false),
- m_is_expression_path_child(false),
m_is_child_at_offset(false),
m_is_getting_summary(false),
m_did_calculate_complete_objc_class_type(false)
@@ -111,6 +109,7 @@ ValueObject::ValueObject (ExecutionConte
AddressType child_ptr_or_ref_addr_type) :
UserID (++g_value_obj_uid), // Unique identifier for every value object
m_parent (NULL),
+ m_root (NULL),
m_update_point (exe_scope),
m_name (),
m_data (),
@@ -129,7 +128,6 @@ ValueObject::ValueObject (ExecutionConte
m_deref_valobj(NULL),
m_format (eFormatDefault),
m_last_format_mgr_revision(0),
- m_last_format_mgr_dynamic(eNoDynamicValues),
m_type_summary_sp(),
m_type_format_sp(),
m_synthetic_children_sp(),
@@ -142,7 +140,6 @@ ValueObject::ValueObject (ExecutionConte
m_is_deref_of_parent (false),
m_is_array_item_for_pointer(false),
m_is_bitfield_for_scalar(false),
- m_is_expression_path_child(false),
m_is_child_at_offset(false),
m_is_getting_summary(false),
m_did_calculate_complete_objc_class_type(false)
@@ -161,17 +158,11 @@ ValueObject::~ValueObject ()
bool
ValueObject::UpdateValueIfNeeded (bool update_format)
{
- return UpdateValueIfNeeded(m_last_format_mgr_dynamic, update_format);
-}
-
-bool
-ValueObject::UpdateValueIfNeeded (DynamicValueType use_dynamic, bool update_format)
-{
bool did_change_formats = false;
if (update_format)
- did_change_formats = UpdateFormatsIfNeeded(use_dynamic);
+ did_change_formats = UpdateFormatsIfNeeded();
// If this is a constant value, then our success is predicated on whether
// we have an error or not
@@ -238,9 +229,9 @@ ValueObject::UpdateValueIfNeeded (Dynami
}
bool
-ValueObject::UpdateFormatsIfNeeded(DynamicValueType use_dynamic)
+ValueObject::UpdateFormatsIfNeeded()
{
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
if (log)
log->Printf("[%s %p] checking for FormatManager revisions. ValueObject rev: %d - Global rev: %d",
GetName().GetCString(),
@@ -250,17 +241,15 @@ ValueObject::UpdateFormatsIfNeeded(Dynam
bool any_change = false;
- if ( (m_last_format_mgr_revision != DataVisualization::GetCurrentRevision()) ||
- m_last_format_mgr_dynamic != use_dynamic)
+ if ( (m_last_format_mgr_revision != DataVisualization::GetCurrentRevision()))
{
SetValueFormat(DataVisualization::ValueFormats::GetFormat (*this, eNoDynamicValues));
- SetSummaryFormat(DataVisualization::GetSummaryFormat (*this, use_dynamic));
+ SetSummaryFormat(DataVisualization::GetSummaryFormat (*this, GetDynamicValueType()));
#ifndef LLDB_DISABLE_PYTHON
- SetSyntheticChildren(DataVisualization::GetSyntheticChildren (*this, use_dynamic));
+ SetSyntheticChildren(DataVisualization::GetSyntheticChildren (*this, GetDynamicValueType()));
#endif
m_last_format_mgr_revision = DataVisualization::GetCurrentRevision();
- m_last_format_mgr_dynamic = use_dynamic;
any_change = true;
}
@@ -510,7 +499,7 @@ ValueObject::SetValueDidChange (bool val
}
ValueObjectSP
-ValueObject::GetChildAtIndex (uint32_t idx, bool can_create)
+ValueObject::GetChildAtIndex (size_t idx, bool can_create)
{
ValueObjectSP child_sp;
// We may need to update our value if we are dynamic
@@ -533,7 +522,89 @@ ValueObject::GetChildAtIndex (uint32_t i
return child_sp;
}
-uint32_t
+#ifdef _POSIX_SOURCE
+ValueObjectSP
+ValueObject::GetChildAtIndexPath (const std::initializer_list<size_t>& idxs,
+ size_t* index_of_error)
+{
+ if (idxs.size() == 0)
+ return GetSP();
+ ValueObjectSP root(GetSP());
+ for (size_t idx : idxs)
+ {
+ root = root->GetChildAtIndex(idx, true);
+ if (!root)
+ {
+ if (index_of_error)
+ *index_of_error = idx;
+ return root;
+ }
+ }
+ return root;
+}
+
+ValueObjectSP
+ValueObject::GetChildAtIndexPath (const std::initializer_list< std::pair<size_t, bool> >& idxs,
+ size_t* index_of_error)
+{
+ if (idxs.size() == 0)
+ return GetSP();
+ ValueObjectSP root(GetSP());
+ for (std::pair<size_t, bool> idx : idxs)
+ {
+ root = root->GetChildAtIndex(idx.first, idx.second);
+ if (!root)
+ {
+ if (index_of_error)
+ *index_of_error = idx.first;
+ return root;
+ }
+ }
+ return root;
+}
+#endif
+
+lldb::ValueObjectSP
+ValueObject::GetChildAtIndexPath (const std::vector<size_t> &idxs,
+ size_t* index_of_error)
+{
+ if (idxs.size() == 0)
+ return GetSP();
+ ValueObjectSP root(GetSP());
+ for (size_t idx : idxs)
+ {
+ root = root->GetChildAtIndex(idx, true);
+ if (!root)
+ {
+ if (index_of_error)
+ *index_of_error = idx;
+ return root;
+ }
+ }
+ return root;
+}
+
+lldb::ValueObjectSP
+ValueObject::GetChildAtIndexPath (const std::vector< std::pair<size_t, bool> > &idxs,
+ size_t* index_of_error)
+{
+ if (idxs.size() == 0)
+ return GetSP();
+ ValueObjectSP root(GetSP());
+ for (std::pair<size_t, bool> idx : idxs)
+ {
+ root = root->GetChildAtIndex(idx.first, idx.second);
+ if (!root)
+ {
+ if (index_of_error)
+ *index_of_error = idx.first;
+ return root;
+ }
+ }
+ return root;
+}
+
+size_t
ValueObject::GetIndexOfChildWithName (const ConstString &name)
{
bool omit_empty_base_classes = true;
@@ -588,7 +659,7 @@ ValueObject::GetChildMemberWithName (con
}
-uint32_t
+size_t
ValueObject::GetNumChildren ()
{
UpdateValueIfNeeded();
@@ -603,12 +674,9 @@ bool
ValueObject::MightHaveChildren()
{
bool has_children = false;
- clang_type_t clang_type = GetClangType();
- if (clang_type)
+ const uint32_t type_info = GetTypeInfo();
+ if (type_info)
{
- const uint32_t type_info = ClangASTContext::GetTypeInfo (clang_type,
- GetClangAST(),
- NULL);
if (type_info & (ClangASTContext::eTypeHasChildren |
ClangASTContext::eTypeIsPointer |
ClangASTContext::eTypeIsReference))
@@ -623,7 +691,7 @@ ValueObject::MightHaveChildren()
// Should only be called by ValueObject::GetNumChildren()
void
-ValueObject::SetNumChildren (uint32_t num_children)
+ValueObject::SetNumChildren (size_t num_children)
{
m_children_count_valid = true;
m_children.SetChildrenCount(num_children);
@@ -636,7 +704,7 @@ ValueObject::SetName (const ConstString
}
ValueObject *
-ValueObject::CreateChildAtIndex (uint32_t idx, bool synthetic_array_member, int32_t synthetic_index)
+ValueObject::CreateChildAtIndex (size_t idx, bool synthetic_array_member, int32_t synthetic_index)
{
ValueObject *valobj = NULL;
@@ -806,11 +874,9 @@ bool
ValueObject::IsCStringContainer(bool check_pointer)
{
clang_type_t elem_or_pointee_clang_type;
- const Flags type_flags (ClangASTContext::GetTypeInfo (GetClangType(),
- GetClangAST(),
- &elem_or_pointee_clang_type));
+ const Flags type_flags (GetTypeInfo (&elem_or_pointee_clang_type));
bool is_char_arr_ptr (type_flags.AnySet (ClangASTContext::eTypeIsArray | ClangASTContext::eTypeIsPointer) &&
- ClangASTContext::IsCharType (elem_or_pointee_clang_type));
+ ClangASTContext::IsCharType (elem_or_pointee_clang_type));
if (!is_char_arr_ptr)
return false;
if (!check_pointer)
@@ -828,19 +894,20 @@ ValueObject::GetPointeeData (DataExtract
uint32_t item_idx,
uint32_t item_count)
{
- if (!IsPointerType() && !IsArrayType())
+ clang_type_t pointee_or_element_clang_type;
+ const uint32_t type_info = GetTypeInfo (&pointee_or_element_clang_type);
+ const bool is_pointer_type = type_info & ClangASTContext::eTypeIsPointer;
+ const bool is_array_type = type_info & ClangASTContext::eTypeIsArray;
+ if (!(is_pointer_type || is_array_type))
return 0;
if (item_count == 0)
return 0;
- uint32_t stride = 0;
+ clang::ASTContext *ast = GetClangAST();
+ ClangASTType pointee_or_element_type(ast, pointee_or_element_clang_type);
- ClangASTType type(GetClangAST(),
- GetClangType());
-
- const uint64_t item_type_size = (IsPointerType() ? ClangASTType::GetTypeByteSize(GetClangAST(), type.GetPointeeType()) :
- ClangASTType::GetTypeByteSize(GetClangAST(), type.GetArrayElementType(stride)));
+ const uint64_t item_type_size = pointee_or_element_type.GetClangTypeByteSize();
const uint64_t bytes = item_count * item_type_size;
@@ -848,7 +915,7 @@ ValueObject::GetPointeeData (DataExtract
if (item_idx == 0 && item_count == 1) // simply a deref
{
- if (IsPointerType())
+ if (is_pointer_type)
{
Error error;
ValueObjectSP pointee_sp = Dereference(error);
@@ -872,7 +939,7 @@ ValueObject::GetPointeeData (DataExtract
lldb::DataBufferSP data_sp(heap_buf_ptr = new lldb_private::DataBufferHeap());
AddressType addr_type;
- lldb::addr_t addr = IsPointerType() ? GetPointerValue(&addr_type) : GetAddressOf(true, &addr_type);
+ lldb::addr_t addr = is_pointer_type ? GetPointerValue(&addr_type) : GetAddressOf(true, &addr_type);
switch (addr_type)
{
@@ -917,9 +984,15 @@ ValueObject::GetPointeeData (DataExtract
break;
case eAddressTypeHost:
{
- heap_buf_ptr->CopyData((uint8_t*)(addr + offset), bytes);
- data.SetData(data_sp);
- return bytes;
+ ClangASTType valobj_type(ast, GetClangType());
+ uint64_t max_bytes = valobj_type.GetClangTypeByteSize();
+ if (max_bytes > offset)
+ {
+ size_t bytes_read = std::min<uint64_t>(max_bytes - offset, bytes);
+ heap_buf_ptr->CopyData((uint8_t*)(addr + offset), bytes_read);
+ data.SetData(data_sp);
+ return bytes_read;
+ }
}
break;
case eAddressTypeInvalid:
@@ -929,7 +1002,7 @@ ValueObject::GetPointeeData (DataExtract
return 0;
}
-size_t
+uint64_t
ValueObject::GetData (DataExtractor& data)
{
UpdateValueIfNeeded(false);
@@ -942,6 +1015,84 @@ ValueObject::GetData (DataExtractor& dat
return data.GetByteSize();
}
+bool
+ValueObject::SetData (DataExtractor &data, Error &error)
+{
+ error.Clear();
+ // Make sure our value is up to date first so that our location and location
+ // type is valid.
+ if (!UpdateValueIfNeeded(false))
+ {
+ error.SetErrorString("unable to read value");
+ return false;
+ }
+
+ uint64_t count = 0;
+ Encoding encoding = ClangASTType::GetEncoding (GetClangType(), count);
+
+ const size_t byte_size = GetByteSize();
+
+ Value::ValueType value_type = m_value.GetValueType();
+
+ switch (value_type)
+ {
+ case Value::eValueTypeScalar:
+ {
+ Error set_error = m_value.GetScalar().SetValueFromData(data, encoding, byte_size);
+
+ if (!set_error.Success())
+ {
+ error.SetErrorStringWithFormat("unable to set scalar value: %s", set_error.AsCString());
+ return false;
+ }
+ }
+ break;
+ case Value::eValueTypeLoadAddress:
+ {
+ // If it is a load address, then the scalar value is the storage location
+ // of the data, and we have to shove this value down to that load location.
+ ExecutionContext exe_ctx (GetExecutionContextRef());
+ Process *process = exe_ctx.GetProcessPtr();
+ if (process)
+ {
+ addr_t target_addr = m_value.GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
+ size_t bytes_written = process->WriteMemory(target_addr,
+ data.GetDataStart(),
+ byte_size,
+ error);
+ if (!error.Success())
+ return false;
+ if (bytes_written != byte_size)
+ {
+ error.SetErrorString("unable to write value to memory");
+ return false;
+ }
+ }
+ }
+ break;
+ case Value::eValueTypeHostAddress:
+ {
+ // If it is a host address, then we stuff the scalar as a DataBuffer into the Value's data.
+ DataBufferSP buffer_sp (new DataBufferHeap(byte_size, 0));
+ m_data.SetData(buffer_sp, 0);
+ data.CopyByteOrderedData (0,
+ byte_size,
+ const_cast<uint8_t *>(m_data.GetDataStart()),
+ byte_size,
+ m_data.GetByteOrder());
+ m_value.GetScalar() = (uintptr_t)m_data.GetDataStart();
+ }
+ break;
+ case Value::eValueTypeFileAddress:
+ case Value::eValueTypeVector:
+ break;
+ }
+
+ // If we have reached this point, then we have successfully changed the value.
+ SetNeedsUpdate();
+ return true;
+}
+
// will compute strlen(str), but without consuming more than
// maxlen bytes out of str (this serves the purpose of reading
// chunks of a string without having to worry about
@@ -960,14 +1111,14 @@ strlen_or_inf (const char* str,
while(*str)
{
len++;str++;
- if (len > maxlen)
+ if (len >= maxlen)
return maxlen_value;
}
}
return len;
}
-void
+size_t
ValueObject::ReadPointedString (Stream& s,
Error& error,
uint32_t max_length,
@@ -977,141 +1128,149 @@ ValueObject::ReadPointedString (Stream&
ExecutionContext exe_ctx (GetExecutionContextRef());
Target* target = exe_ctx.GetTargetPtr();
- if (target && max_length == 0)
+ if (!target)
+ {
+ s << "<no target to read from>";
+ error.SetErrorString("no target to read from");
+ return 0;
+ }
+
+ if (max_length == 0)
max_length = target->GetMaximumSizeOfStringSummary();
+ size_t bytes_read = 0;
+ size_t total_bytes_read = 0;
+
clang_type_t clang_type = GetClangType();
clang_type_t elem_or_pointee_clang_type;
- const Flags type_flags (ClangASTContext::GetTypeInfo (clang_type,
- GetClangAST(),
- &elem_or_pointee_clang_type));
+ const Flags type_flags (GetTypeInfo (&elem_or_pointee_clang_type));
if (type_flags.AnySet (ClangASTContext::eTypeIsArray | ClangASTContext::eTypeIsPointer) &&
ClangASTContext::IsCharType (elem_or_pointee_clang_type))
{
- if (target == NULL)
+ addr_t cstr_address = LLDB_INVALID_ADDRESS;
+ AddressType cstr_address_type = eAddressTypeInvalid;
+
+ size_t cstr_len = 0;
+ bool capped_data = false;
+ if (type_flags.Test (ClangASTContext::eTypeIsArray))
{
- s << "<no target to read from>";
+ // We have an array
+ cstr_len = ClangASTContext::GetArraySize (clang_type);
+ if (cstr_len > max_length)
+ {
+ capped_data = true;
+ cstr_len = max_length;
+ }
+ cstr_address = GetAddressOf (true, &cstr_address_type);
}
else
{
- addr_t cstr_address = LLDB_INVALID_ADDRESS;
- AddressType cstr_address_type = eAddressTypeInvalid;
+ // We have a pointer
+ cstr_address = GetPointerValue (&cstr_address_type);
+ }
+
+ if (cstr_address == 0 || cstr_address == LLDB_INVALID_ADDRESS)
+ {
+ s << "<invalid address>";
+ error.SetErrorString("invalid address");
+ return 0;
+ }
+
+ Address cstr_so_addr (cstr_address);
+ DataExtractor data;
+ if (cstr_len > 0 && honor_array)
+ {
+ // I am using GetPointeeData() here to abstract the fact that some ValueObjects are actually frozen pointers in the host
+ // but the pointed-to data lives in the debuggee, and GetPointeeData() automatically takes care of this
+ GetPointeeData(data, 0, cstr_len);
+
+ if ((bytes_read = data.GetByteSize()) > 0)
+ {
+ total_bytes_read = bytes_read;
+ s << '"';
+ data.Dump (&s,
+ 0, // Start offset in "data"
+ item_format,
+ 1, // Size of item (1 byte for a char!)
+ bytes_read, // How many bytes to print?
+ UINT32_MAX, // num per line
+ LLDB_INVALID_ADDRESS,// base address
+ 0, // bitfield bit size
+ 0); // bitfield bit offset
+ if (capped_data)
+ s << "...";
+ s << '"';
+ }
+ }
+ else
+ {
+ cstr_len = max_length;
+ const size_t k_max_buf_size = 64;
+
+ size_t offset = 0;
- size_t cstr_len = 0;
- bool capped_data = false;
- if (type_flags.Test (ClangASTContext::eTypeIsArray))
- {
- // We have an array
- cstr_len = ClangASTContext::GetArraySize (clang_type);
- if (cstr_len > max_length)
+ int cstr_len_displayed = -1;
+ bool capped_cstr = false;
+ // I am using GetPointeeData() here to abstract the fact that some ValueObjects are actually frozen pointers in the host
+ // but the pointed-to data lives in the debuggee, and GetPointeeData() automatically takes care of this
+ while ((bytes_read = GetPointeeData(data, offset, k_max_buf_size)) > 0)
+ {
+ total_bytes_read += bytes_read;
+ const char *cstr = data.PeekCStr(0);
+ size_t len = strlen_or_inf (cstr, k_max_buf_size, k_max_buf_size+1);
+ if (len > k_max_buf_size)
+ len = k_max_buf_size;
+ if (cstr && cstr_len_displayed < 0)
+ s << '"';
+
+ if (cstr_len_displayed < 0)
+ cstr_len_displayed = len;
+
+ if (len == 0)
+ break;
+ cstr_len_displayed += len;
+ if (len > bytes_read)
+ len = bytes_read;
+ if (len > cstr_len)
+ len = cstr_len;
+
+ data.Dump (&s,
+ 0, // Start offset in "data"
+ item_format,
+ 1, // Size of item (1 byte for a char!)
+ len, // How many bytes to print?
+ UINT32_MAX, // num per line
+ LLDB_INVALID_ADDRESS,// base address
+ 0, // bitfield bit size
+ 0); // bitfield bit offset
+
+ if (len < k_max_buf_size)
+ break;
+
+ if (len >= cstr_len)
{
- capped_data = true;
- cstr_len = max_length;
+ capped_cstr = true;
+ break;
}
- cstr_address = GetAddressOf (true, &cstr_address_type);
+
+ cstr_len -= len;
+ offset += len;
}
- else
+
+ if (cstr_len_displayed >= 0)
{
- // We have a pointer
- cstr_address = GetPointerValue (&cstr_address_type);
- }
- if (cstr_address != 0 && cstr_address != LLDB_INVALID_ADDRESS)
- {
- Address cstr_so_addr (cstr_address);
- DataExtractor data;
- size_t bytes_read = 0;
- if (cstr_len > 0 && honor_array)
- {
- // I am using GetPointeeData() here to abstract the fact that some ValueObjects are actually frozen pointers in the host
- // but the pointed-to data lives in the debuggee, and GetPointeeData() automatically takes care of this
- GetPointeeData(data, 0, cstr_len);
-
- if ((bytes_read = data.GetByteSize()) > 0)
- {
- s << '"';
- data.Dump (&s,
- 0, // Start offset in "data"
- item_format,
- 1, // Size of item (1 byte for a char!)
- bytes_read, // How many bytes to print?
- UINT32_MAX, // num per line
- LLDB_INVALID_ADDRESS,// base address
- 0, // bitfield bit size
- 0); // bitfield bit offset
- if (capped_data)
- s << "...";
- s << '"';
- }
- }
- else
- {
- cstr_len = max_length;
- const size_t k_max_buf_size = 64;
-
- size_t offset = 0;
-
- int cstr_len_displayed = -1;
- bool capped_cstr = false;
- // I am using GetPointeeData() here to abstract the fact that some ValueObjects are actually frozen pointers in the host
- // but the pointed-to data lives in the debuggee, and GetPointeeData() automatically takes care of this
- while ((bytes_read = GetPointeeData(data, offset, k_max_buf_size)) > 0)
- {
- const char *cstr = data.PeekCStr(0);
- size_t len = strlen_or_inf (cstr, k_max_buf_size, k_max_buf_size+1);
- if (len > k_max_buf_size)
- len = k_max_buf_size;
- if (cstr && cstr_len_displayed < 0)
- s << '"';
-
- if (cstr_len_displayed < 0)
- cstr_len_displayed = len;
-
- if (len == 0)
- break;
- cstr_len_displayed += len;
- if (len > bytes_read)
- len = bytes_read;
- if (len > cstr_len)
- len = cstr_len;
-
- data.Dump (&s,
- 0, // Start offset in "data"
- item_format,
- 1, // Size of item (1 byte for a char!)
- len, // How many bytes to print?
- UINT32_MAX, // num per line
- LLDB_INVALID_ADDRESS,// base address
- 0, // bitfield bit size
- 0); // bitfield bit offset
-
- if (len < k_max_buf_size)
- break;
-
- if (len >= cstr_len)
- {
- capped_cstr = true;
- break;
- }
-
- cstr_len -= len;
- offset += len;
- }
-
- if (cstr_len_displayed >= 0)
- {
- s << '"';
- if (capped_cstr)
- s << "...";
- }
- }
+ s << '"';
+ if (capped_cstr)
+ s << "...";
}
}
}
else
{
- error.SetErrorString("impossible to read a string from this object");
+ error.SetErrorString("not a string object");
s << "<not a string object>";
}
+ return total_bytes_read;
}
const char *
@@ -1178,17 +1337,40 @@ ValueObject::GetValueAsCString (lldb::Fo
clang_type_t clang_type = GetClangType ();
if (clang_type)
{
+ // put custom bytes to display in this DataExtractor to override the default value logic
+ lldb_private::DataExtractor special_format_data;
+ clang::ASTContext* ast = GetClangAST();
+ if (format == eFormatCString)
+ {
+ Flags type_flags(ClangASTContext::GetTypeInfo(clang_type, ast, NULL));
+ if (type_flags.Test(ClangASTContext::eTypeIsPointer) && !type_flags.Test(ClangASTContext::eTypeIsObjC))
+ {
+ // if we are dumping a pointer as a c-string, get the pointee data as a string
+ TargetSP target_sp(GetTargetSP());
+ if (target_sp)
+ {
+ size_t max_len = target_sp->GetMaximumSizeOfStringSummary();
+ Error error;
+ DataBufferSP buffer_sp(new DataBufferHeap(max_len+1,0));
+ Address address(GetPointerValue());
+ if (target_sp->ReadCStringFromMemory(address, (char*)buffer_sp->GetBytes(), max_len, error) && error.Success())
+ special_format_data.SetData(buffer_sp);
+ }
+ }
+ }
+
StreamString sstr;
ExecutionContext exe_ctx (GetExecutionContextRef());
- ClangASTType::DumpTypeValue (GetClangAST(), // The clang AST
- clang_type, // The clang type to display
- &sstr,
- format, // Format to display this type with
- m_data, // Data to extract from
- 0, // Byte offset into "m_data"
- GetByteSize(), // Byte size of item in "m_data"
- GetBitfieldBitSize(), // Bitfield bit size
- GetBitfieldBitOffset(), // Bitfield bit offset
+ ClangASTType::DumpTypeValue (ast, // The clang AST
+ clang_type, // The clang type to display
+ &sstr, // The stream to use for display
+ format, // Format to display this type with
+ special_format_data.GetByteSize() ?
+ special_format_data: m_data, // Data to extract from
+ 0, // Byte offset into "m_data"
+ GetByteSize(), // Byte size of item in "m_data"
+ GetBitfieldBitSize(), // Bitfield bit size
+ GetBitfieldBitOffset(), // Bitfield bit offset
exe_ctx.GetBestExecutionContextScope());
// Don't set the m_error to anything here otherwise
// we won't be able to re-format as anything else. The
@@ -1312,7 +1494,7 @@ ValueObject::HasSpecialPrintableRepresen
Format custom_format)
{
clang_type_t elem_or_pointee_type;
- Flags flags(ClangASTContext::GetTypeInfo(GetClangType(), GetClangAST(), &elem_or_pointee_type));
+ Flags flags(GetTypeInfo(&elem_or_pointee_type));
if (flags.AnySet(ClangASTContext::eTypeIsArray | ClangASTContext::eTypeIsPointer)
&& val_obj_display == ValueObject::eValueObjectRepresentationStyleValue)
@@ -1356,7 +1538,7 @@ ValueObject::DumpPrintableRepresentation
{
clang_type_t elem_or_pointee_type;
- Flags flags(ClangASTContext::GetTypeInfo(GetClangType(), GetClangAST(), &elem_or_pointee_type));
+ Flags flags(GetTypeInfo(&elem_or_pointee_type));
bool allow_special = ((special & ePrintableRepresentationSpecialCasesAllow) == ePrintableRepresentationSpecialCasesAllow);
bool only_special = ((special & ePrintableRepresentationSpecialCasesOnly) == ePrintableRepresentationSpecialCasesOnly);
@@ -1394,10 +1576,10 @@ ValueObject::DumpPrintableRepresentation
if ((custom_format == eFormatBytes) ||
(custom_format == eFormatBytesWithASCII))
{
- uint32_t count = GetNumChildren();
+ const size_t count = GetNumChildren();
s << '[';
- for (uint32_t low = 0; low < count; low++)
+ for (size_t low = 0; low < count; low++)
{
if (low)
@@ -1430,12 +1612,12 @@ ValueObject::DumpPrintableRepresentation
(custom_format == eFormatVectorOfUInt64) ||
(custom_format == eFormatVectorOfUInt8)) // arrays of bytes, bytes with ASCII or any vector format should be printed directly
{
- uint32_t count = GetNumChildren();
+ const size_t count = GetNumChildren();
Format format = FormatManager::GetSingleItemFormat(custom_format);
s << '[';
- for (uint32_t low = 0; low < count; low++)
+ for (size_t low = 0; low < count; low++)
{
if (low)
@@ -1484,8 +1666,8 @@ ValueObject::DumpPrintableRepresentation
bool var_success = false;
{
- const char * return_value;
- std::string alloc_mem;
+ const char *cstr = NULL;
+ StreamString strm;
if (custom_format != eFormatInvalid)
SetFormat(custom_format);
@@ -1493,59 +1675,49 @@ ValueObject::DumpPrintableRepresentation
switch(val_obj_display)
{
case eValueObjectRepresentationStyleValue:
- return_value = GetValueAsCString();
+ cstr = GetValueAsCString();
break;
case eValueObjectRepresentationStyleSummary:
- return_value = GetSummaryAsCString();
+ cstr = GetSummaryAsCString();
break;
case eValueObjectRepresentationStyleLanguageSpecific:
- return_value = GetObjectDescription();
+ cstr = GetObjectDescription();
break;
case eValueObjectRepresentationStyleLocation:
- return_value = GetLocationAsCString();
+ cstr = GetLocationAsCString();
break;
case eValueObjectRepresentationStyleChildrenCount:
- {
- alloc_mem.resize(512);
- return_value = &alloc_mem[0];
- int count = GetNumChildren();
- snprintf((char*)return_value, 512, "%d", count);
- }
+ strm.Printf("%zu", GetNumChildren());
+ cstr = strm.GetString().c_str();
break;
case eValueObjectRepresentationStyleType:
- return_value = GetTypeName().AsCString();
+ cstr = GetTypeName().AsCString();
break;
}
- if (!return_value)
+ if (!cstr)
{
if (val_obj_display == eValueObjectRepresentationStyleValue)
- return_value = GetSummaryAsCString();
+ cstr = GetSummaryAsCString();
else if (val_obj_display == eValueObjectRepresentationStyleSummary)
{
if (ClangASTContext::IsAggregateType (GetClangType()) == true)
{
- // this thing has no value, and it seems to have no summary
- // some combination of unitialized data and other factors can also
- // raise this condition, so let's print a nice generic description
- {
- alloc_mem.resize(684);
- return_value = &alloc_mem[0];
- snprintf((char*)return_value, 684, "%s @ %s", GetTypeName().AsCString(), GetLocationAsCString());
- }
+ strm.Printf("%s @ %s", GetTypeName().AsCString(), GetLocationAsCString());
+ cstr = strm.GetString().c_str();
}
else
- return_value = GetValueAsCString();
+ cstr = GetValueAsCString();
}
}
- if (return_value)
- s.PutCString(return_value);
+ if (cstr)
+ s.PutCString(cstr);
else
{
if (m_error.Fail())
@@ -1626,7 +1798,7 @@ ValueObject::GetPointerValue (AddressTyp
case Value::eValueTypeLoadAddress:
case Value::eValueTypeFileAddress:
{
- uint32_t data_offset = 0;
+ lldb::offset_t data_offset = 0;
address = m_data.GetPointer(&data_offset);
}
break;
@@ -1650,7 +1822,7 @@ ValueObject::SetValueFromCString (const
return false;
}
- uint32_t count = 0;
+ uint64_t count = 0;
Encoding encoding = ClangASTType::GetEncoding (GetClangType(), count);
const size_t byte_size = GetByteSize();
@@ -1782,6 +1954,12 @@ ValueObject::GetSyntheticChild (const Co
return synthetic_child_sp;
}
+uint32_t
+ValueObject::GetTypeInfo (clang_type_t *pointee_or_element_clang_type)
+{
+ return ClangASTContext::GetTypeInfo (GetClangType(), GetClangAST(), pointee_or_element_clang_type);
+}
+
bool
ValueObject::IsPointerType ()
{
@@ -1826,19 +2004,23 @@ ValueObject::IsPossibleDynamicType ()
bool
ValueObject::IsObjCNil ()
{
- bool isObjCpointer = ClangASTContext::IsObjCObjectPointerType(GetClangType(), NULL);
+ const uint32_t mask = ClangASTContext::eTypeIsObjC | ClangASTContext::eTypeIsPointer;
+ bool isObjCpointer = ( ((ClangASTContext::GetTypeInfo(GetClangType(), GetClangAST(), NULL)) & mask) == mask);
+ if (!isObjCpointer)
+ return false;
bool canReadValue = true;
bool isZero = GetValueAsUnsigned(0,&canReadValue) == 0;
- return canReadValue && isZero && isObjCpointer;
+ return canReadValue && isZero;
}
ValueObjectSP
-ValueObject::GetSyntheticArrayMember (int32_t index, bool can_create)
+ValueObject::GetSyntheticArrayMember (size_t index, bool can_create)
{
- if (IsArrayType())
+ const uint32_t type_info = GetTypeInfo ();
+ if (type_info & ClangASTContext::eTypeIsArray)
return GetSyntheticArrayMemberFromArray(index, can_create);
- if (IsPointerType())
+ if (type_info & ClangASTContext::eTypeIsPointer)
return GetSyntheticArrayMemberFromPointer(index, can_create);
return ValueObjectSP();
@@ -1846,13 +2028,13 @@ ValueObject::GetSyntheticArrayMember (in
}
ValueObjectSP
-ValueObject::GetSyntheticArrayMemberFromPointer (int32_t index, bool can_create)
+ValueObject::GetSyntheticArrayMemberFromPointer (size_t index, bool can_create)
{
ValueObjectSP synthetic_child_sp;
if (IsPointerType ())
{
char index_str[64];
- snprintf(index_str, sizeof(index_str), "[%i]", index);
+ snprintf(index_str, sizeof(index_str), "[%zu]", index);
ConstString index_const_str(index_str);
// Check if we have already created a synthetic array member in this
// valid object. If we have we will re-use it.
@@ -1889,13 +2071,13 @@ ValueObject::GetSyntheticArrayMemberFrom
// there are more items in "item_array".
ValueObjectSP
-ValueObject::GetSyntheticArrayMemberFromArray (int32_t index, bool can_create)
+ValueObject::GetSyntheticArrayMemberFromArray (size_t index, bool can_create)
{
ValueObjectSP synthetic_child_sp;
if (IsArrayType ())
{
char index_str[64];
- snprintf(index_str, sizeof(index_str), "[%i]", index);
+ snprintf(index_str, sizeof(index_str), "[%zu]", index);
ConstString index_const_str(index_str);
// Check if we have already created a synthetic array member in this
// valid object. If we have we will re-use it.
@@ -1963,42 +2145,6 @@ ValueObject::GetSyntheticBitFieldChild (
}
ValueObjectSP
-ValueObject::GetSyntheticArrayRangeChild (uint32_t from, uint32_t to, bool can_create)
-{
- ValueObjectSP synthetic_child_sp;
- if (IsArrayType () || IsPointerType ())
- {
- char index_str[64];
- snprintf(index_str, sizeof(index_str), "[%i-%i]", from, to);
- ConstString index_const_str(index_str);
- // Check if we have already created a synthetic array member in this
- // valid object. If we have we will re-use it.
- synthetic_child_sp = GetSyntheticChild (index_const_str);
- if (!synthetic_child_sp)
- {
- ValueObjectSynthetic *synthetic_child;
-
- // We haven't made a synthetic array member for INDEX yet, so
- // lets make one and cache it for any future reference.
- SyntheticArrayView *view = new SyntheticArrayView(SyntheticChildren::Flags());
- view->AddRange(from,to);
- SyntheticChildrenSP view_sp(view);
- synthetic_child = new ValueObjectSynthetic(*this, view_sp);
-
- // Cache the value if we got one back...
- if (synthetic_child)
- {
- AddSyntheticChild(index_const_str, synthetic_child);
- synthetic_child_sp = synthetic_child->GetSP();
- synthetic_child_sp->SetName(ConstString(index_str));
- synthetic_child_sp->m_is_bitfield_for_scalar = true;
- }
- }
- }
- return synthetic_child_sp;
-}
-
-ValueObjectSP
ValueObject::GetSyntheticChildAtOffset(uint32_t offset, const ClangASTType& type, bool can_create)
{
@@ -2075,9 +2221,9 @@ ValueObject::GetSyntheticExpressionPathC
// Cache the value if we got one back...
if (synthetic_child_sp.get())
{
+ // FIXME: this causes a "real" child to end up with its name changed to the contents of expression
AddSyntheticChild(name_const_string, synthetic_child_sp.get());
synthetic_child_sp->SetName(ConstString(SkipLeadingExpressionPathSeparators(expression)));
- synthetic_child_sp->m_is_expression_path_child = true;
}
}
return synthetic_child_sp;
@@ -2098,7 +2244,7 @@ ValueObject::CalculateSyntheticValue (bo
lldb::SyntheticChildrenSP current_synth_sp(m_synthetic_children_sp);
- if (!UpdateFormatsIfNeeded(m_last_format_mgr_dynamic) && m_synthetic_value)
+ if (!UpdateFormatsIfNeeded() && m_synthetic_value)
return;
if (m_synthetic_children_sp.get() == NULL)
@@ -2173,7 +2319,7 @@ ValueObject::GetSyntheticValue (bool use
bool
ValueObject::HasSyntheticValue()
{
- UpdateFormatsIfNeeded(m_last_format_mgr_dynamic);
+ UpdateFormatsIfNeeded();
if (m_synthetic_children_sp.get() == NULL)
return false;
@@ -2304,8 +2450,8 @@ ValueObject::GetValueForExpressionPath(c
{
const char* dummy_first_unparsed;
- ExpressionPathScanEndReason dummy_reason_to_stop;
- ExpressionPathEndResultType dummy_final_value_type;
+ ExpressionPathScanEndReason dummy_reason_to_stop = ValueObject::eExpressionPathScanEndReasonUnknown;
+ ExpressionPathEndResultType dummy_final_value_type = ValueObject::eExpressionPathEndResultTypeInvalid;
ExpressionPathAftermath dummy_final_task_on_target = ValueObject::eExpressionPathAftermathNothing;
ValueObjectSP ret_val = GetValueForExpressionPath_Impl(expression,
@@ -2977,8 +3123,8 @@ ValueObject::ExpandArraySliceExpression(
}
else // expand this into list
{
- int max_index = root->GetNumChildren() - 1;
- for (int index = 0; index < max_index; index++)
+ const size_t max_index = root->GetNumChildren() - 1;
+ for (size_t index = 0; index < max_index; index++)
{
ValueObjectSP child =
root->GetChildAtIndex(index, true);
@@ -3014,8 +3160,8 @@ ValueObject::ExpandArraySliceExpression(
{
if (root_clang_type_info.Test(ClangASTContext::eTypeIsArray))
{
- int max_index = root->GetNumChildren() - 1;
- for (int index = 0; index < max_index; index++)
+ const size_t max_index = root->GetNumChildren() - 1;
+ for (size_t index = 0; index < max_index; index++)
{
ValueObjectSP child =
root->GetChildAtIndex(index, true);
@@ -3215,7 +3361,7 @@ DumpValueObject_Impl (Stream &s,
{
if (valobj)
{
- bool update_success = valobj->UpdateValueIfNeeded (options.m_use_dynamic, true);
+ bool update_success = valobj->UpdateValueIfNeeded (true);
const char *root_valobj_name =
options.m_root_valobj_name.empty() ?
@@ -3256,47 +3402,19 @@ DumpValueObject_Impl (Stream &s,
show_type = options.m_show_types || (curr_depth == 0 && !options.m_flat_output);
if (show_type)
- {
- const char* typeName = valobj->GetQualifiedTypeName().AsCString("<invalid type>");
- //const char* typeName = valobj->GetTypeName().AsCString("<invalid type>");
- s.Printf("(%s", typeName);
- // only show dynamic types if the user really wants to see types
- if (options.m_show_types && options.m_use_dynamic != eNoDynamicValues &&
- (/*strstr(typeName, "id") == typeName ||*/
- ClangASTType::GetMinimumLanguage(valobj->GetClangAST(), valobj->GetClangType()) == eLanguageTypeObjC))
- {
- ExecutionContext exe_ctx (valobj->GetExecutionContextRef());
- Process *process = exe_ctx.GetProcessPtr();
- if (process == NULL)
- s.Printf(", dynamic type: unknown) ");
- else
- {
- ObjCLanguageRuntime *runtime = process->GetObjCLanguageRuntime();
- if (runtime == NULL)
- s.Printf(", dynamic type: unknown) ");
- else
- {
- ObjCLanguageRuntime::ClassDescriptorSP objc_class_sp (runtime->GetNonKVOClassDescriptor(*valobj));
- if (objc_class_sp)
- s.Printf(", dynamic type: %s) ", objc_class_sp->GetClassName().GetCString());
- else
- s.Printf(", dynamic type: unknown) ");
- }
- }
- }
- else
- s.Printf(") ");
- }
-
+ s.Printf("(%s) ", valobj->GetQualifiedTypeName().AsCString("<invalid type>"));
if (options.m_flat_output)
{
// If we are showing types, also qualify the C++ base classes
const bool qualify_cxx_base_classes = options.m_show_types;
- valobj->GetExpressionPath(s, qualify_cxx_base_classes);
- s.PutCString(" =");
+ if (!options.m_hide_name)
+ {
+ valobj->GetExpressionPath(s, qualify_cxx_base_classes);
+ s.PutCString(" =");
+ }
}
- else
+ else if (!options.m_hide_name)
{
const char *name_cstr = root_valobj_name ? root_valobj_name : valobj->GetName().AsCString("");
s.Printf ("%s =", name_cstr);
@@ -3360,7 +3478,8 @@ DumpValueObject_Impl (Stream &s,
// Make sure we have a value and make sure the summary didn't
// specify that the value should not be printed - and do not print
// the value if this thing is nil
- if (!is_nil && !value_str.empty() && (entry == NULL || entry->DoesPrintValue() || sum_cstr == NULL))
+ // (but show the value if the user passes a format explicitly)
+ if (!is_nil && !value_str.empty() && (entry == NULL || (entry->DoesPrintValue() || options.m_format != eFormatDefault) || sum_cstr == NULL) && !options.m_hide_value)
s.Printf(" %s", value_str.c_str());
if (sum_cstr)
@@ -3369,11 +3488,13 @@ DumpValueObject_Impl (Stream &s,
// let's avoid the overly verbose no description error for a nil thing
if (options.m_use_objc && !is_nil)
{
+ if (!options.m_hide_value || !options.m_hide_name)
+ s.Printf(" ");
const char *object_desc = valobj->GetObjectDescription();
if (object_desc)
- s.Printf(" %s\n", object_desc);
+ s.Printf("%s\n", object_desc);
else
- s.Printf (" [no Objective-C description available]\n");
+ s.Printf ("[no Objective-C description available]\n");
return;
}
}
@@ -3418,7 +3539,7 @@ DumpValueObject_Impl (Stream &s,
ValueObjectSP synth_valobj_sp = valobj->GetSyntheticValue (options.m_use_synthetic);
synth_valobj = (synth_valobj_sp ? synth_valobj_sp.get() : valobj);
- uint32_t num_children = synth_valobj->GetNumChildren();
+ size_t num_children = synth_valobj->GetNumChildren();
bool print_dotdotdot = false;
if (num_children)
{
@@ -3434,7 +3555,7 @@ DumpValueObject_Impl (Stream &s,
s.IndentMore();
}
- uint32_t max_num_children = valobj->GetTargetSP()->GetMaximumNumberOfChildrenToDisplay();
+ const size_t max_num_children = valobj->GetTargetSP()->GetMaximumNumberOfChildrenToDisplay();
if (num_children > max_num_children && !options.m_ignore_cap)
{
@@ -3444,9 +3565,9 @@ DumpValueObject_Impl (Stream &s,
ValueObject::DumpValueObjectOptions child_options(options);
child_options.SetFormat(options.m_format).SetSummary().SetRootValueObjectName();
- child_options.SetScopeChecked(true)
+ child_options.SetScopeChecked(true).SetHideName(options.m_hide_name).SetHideValue(options.m_hide_value)
.SetOmitSummaryDepth(child_options.m_omit_summary_depth > 1 ? child_options.m_omit_summary_depth - 1 : 0);
- for (uint32_t idx=0; idx<num_children; ++idx)
+ for (size_t idx=0; idx<num_children; ++idx)
{
ValueObjectSP child_sp(synth_valobj->GetChildAtIndex(idx, true));
if (child_sp.get())
@@ -4111,3 +4232,66 @@ ValueObject::CreateValueObjectFromData (
new_value_sp->SetName(ConstString(name));
return new_value_sp;
}
+
+ModuleSP
+ValueObject::GetModule ()
+{
+ ValueObject* root(GetRoot());
+ if (root != this)
+ return root->GetModule();
+ return lldb::ModuleSP();
+}
+
+ValueObject*
+ValueObject::GetRoot ()
+{
+ if (m_root)
+ return m_root;
+ ValueObject* parent = m_parent;
+ if (!parent)
+ return (m_root = this);
+ while (parent->m_parent)
+ {
+ if (parent->m_root)
+ return (m_root = parent->m_root);
+ parent = parent->m_parent;
+ }
+ return (m_root = parent);
+}
+
+AddressType
+ValueObject::GetAddressTypeOfChildren()
+{
+ if (m_address_type_of_ptr_or_ref_children == eAddressTypeInvalid)
+ {
+ ValueObject* root(GetRoot());
+ if (root != this)
+ return root->GetAddressTypeOfChildren();
+ }
+ return m_address_type_of_ptr_or_ref_children;
+}
+
+lldb::DynamicValueType
+ValueObject::GetDynamicValueType ()
+{
+ ValueObject* with_dv_info = this;
+ while (with_dv_info)
+ {
+ if (with_dv_info->HasDynamicValueTypeInfo())
+ return with_dv_info->GetDynamicValueTypeImpl();
+ with_dv_info = with_dv_info->m_parent;
+ }
+ return lldb::eNoDynamicValues;
+}
+lldb::Format
+ValueObject::GetFormat () const
+{
+ const ValueObject* with_fmt_info = this;
+ while (with_fmt_info)
+ {
+ if (with_fmt_info->m_format != lldb::eFormatDefault)
+ return with_fmt_info->m_format;
+ with_fmt_info = with_fmt_info->m_parent;
+ }
+ return m_format;
+}
Modified: lldb/branches/windows/source/Core/ValueObjectCast.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/ValueObjectCast.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/ValueObjectCast.cpp (original)
+++ lldb/branches/windows/source/Core/ValueObjectCast.cpp Wed Apr 17 03:38:48 2013
@@ -67,7 +67,7 @@ ValueObjectCast::GetClangTypeImpl ()
return m_cast_type.GetOpaqueQualType();
}
-uint32_t
+size_t
ValueObjectCast::CalculateNumChildren()
{
return ClangASTContext::GetNumChildren (GetClangAST (), GetClangType(), true);
@@ -79,7 +79,7 @@ ValueObjectCast::GetClangASTImpl ()
return m_cast_type.GetASTContext();
}
-size_t
+uint64_t
ValueObjectCast::GetByteSize()
{
return m_value.GetValueByteSize(GetClangAST(), NULL);
Modified: lldb/branches/windows/source/Core/ValueObjectChild.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/ValueObjectChild.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/ValueObjectChild.cpp (original)
+++ lldb/branches/windows/source/Core/ValueObjectChild.cpp Wed Apr 17 03:38:48 2013
@@ -30,7 +30,7 @@ ValueObjectChild::ValueObjectChild
clang::ASTContext *clang_ast,
void *clang_type,
const ConstString &name,
- uint32_t byte_size,
+ uint64_t byte_size,
int32_t byte_offset,
uint32_t bitfield_bit_size,
uint32_t bitfield_bit_offset,
@@ -62,7 +62,7 @@ ValueObjectChild::GetValueType() const
return m_parent->GetValueType();
}
-uint32_t
+size_t
ValueObjectChild::CalculateNumChildren()
{
return ClangASTContext::GetNumChildren (GetClangAST (), GetClangType(), true);
@@ -229,5 +229,8 @@ ValueObjectChild::UpdateValue ()
bool
ValueObjectChild::IsInScope ()
{
- return m_parent->IsInScope ();
+ ValueObject* root(GetRoot());
+ if (root)
+ return root->IsInScope ();
+ return false;
}
Modified: lldb/branches/windows/source/Core/ValueObjectConstResult.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/ValueObjectConstResult.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/ValueObjectConstResult.cpp (original)
+++ lldb/branches/windows/source/Core/ValueObjectConstResult.cpp Wed Apr 17 03:38:48 2013
@@ -124,7 +124,7 @@ ValueObjectConstResult::Create
const ConstString &name,
const lldb::DataBufferSP &data_sp,
lldb::ByteOrder data_byte_order,
- uint8_t data_addr_size,
+ uint32_t data_addr_size,
lldb::addr_t address
)
{
@@ -155,7 +155,7 @@ ValueObjectConstResult::ValueObjectConst
const ConstString &name,
const lldb::DataBufferSP &data_sp,
lldb::ByteOrder data_byte_order,
- uint8_t data_addr_size,
+ uint32_t data_addr_size,
lldb::addr_t address
) :
ValueObject (exe_scope),
@@ -185,7 +185,7 @@ ValueObjectConstResult::Create
const ConstString &name,
lldb::addr_t address,
AddressType address_type,
- uint8_t addr_byte_size
+ uint32_t addr_byte_size
)
{
return (new ValueObjectConstResult (exe_scope,
@@ -205,7 +205,7 @@ ValueObjectConstResult::ValueObjectConst
const ConstString &name,
lldb::addr_t address,
AddressType address_type,
- uint8_t addr_byte_size
+ uint32_t addr_byte_size
) :
ValueObject (exe_scope),
m_clang_ast (clang_ast),
@@ -286,7 +286,7 @@ ValueObjectConstResult::GetValueType() c
return eValueTypeConstResult;
}
-size_t
+uint64_t
ValueObjectConstResult::GetByteSize()
{
if (m_byte_size == 0)
@@ -300,7 +300,7 @@ ValueObjectConstResult::SetByteSize (siz
m_byte_size = size;
}
-uint32_t
+size_t
ValueObjectConstResult::CalculateNumChildren()
{
return ClangASTContext::GetNumChildren (GetClangAST (), GetClangType(), true);
@@ -363,7 +363,7 @@ ValueObjectConstResult::GetAddressOf (bo
}
ValueObject *
-ValueObjectConstResult::CreateChildAtIndex (uint32_t idx, bool synthetic_array_member, int32_t synthetic_index)
+ValueObjectConstResult::CreateChildAtIndex (size_t idx, bool synthetic_array_member, int32_t synthetic_index)
{
return m_impl.CreateChildAtIndex(idx, synthetic_array_member, synthetic_index);
}
Modified: lldb/branches/windows/source/Core/ValueObjectConstResultChild.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/ValueObjectConstResultChild.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/ValueObjectConstResultChild.cpp (original)
+++ lldb/branches/windows/source/Core/ValueObjectConstResultChild.cpp Wed Apr 17 03:38:48 2013
@@ -68,7 +68,7 @@ ValueObjectConstResultChild::AddressOf (
}
ValueObject *
-ValueObjectConstResultChild::CreateChildAtIndex (uint32_t idx, bool synthetic_array_member, int32_t synthetic_index)
+ValueObjectConstResultChild::CreateChildAtIndex (size_t idx, bool synthetic_array_member, int32_t synthetic_index)
{
return m_impl.CreateChildAtIndex(idx, synthetic_array_member, synthetic_index);
}
Modified: lldb/branches/windows/source/Core/ValueObjectConstResultImpl.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/ValueObjectConstResultImpl.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/ValueObjectConstResultImpl.cpp (original)
+++ lldb/branches/windows/source/Core/ValueObjectConstResultImpl.cpp Wed Apr 17 03:38:48 2013
@@ -84,7 +84,7 @@ ValueObjectConstResultImpl::Dereference
}
ValueObject *
-ValueObjectConstResultImpl::CreateChildAtIndex (uint32_t idx, bool synthetic_array_member, int32_t synthetic_index)
+ValueObjectConstResultImpl::CreateChildAtIndex (size_t idx, bool synthetic_array_member, int32_t synthetic_index)
{
if (m_impl_backend == NULL)
return NULL;
Modified: lldb/branches/windows/source/Core/ValueObjectDynamicValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/ValueObjectDynamicValue.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/ValueObjectDynamicValue.cpp (original)
+++ lldb/branches/windows/source/Core/ValueObjectDynamicValue.cpp Wed Apr 17 03:38:48 2013
@@ -38,10 +38,9 @@ using namespace lldb_private;
ValueObjectDynamicValue::ValueObjectDynamicValue (ValueObject &parent, lldb::DynamicValueType use_dynamic) :
ValueObject(parent),
m_address (),
- m_type_sp(),
+ m_dynamic_type_info(),
m_use_dynamic (use_dynamic)
{
- m_last_format_mgr_dynamic = use_dynamic;
SetName (parent.GetName());
}
@@ -53,7 +52,7 @@ ValueObjectDynamicValue::~ValueObjectDyn
lldb::clang_type_t
ValueObjectDynamicValue::GetClangTypeImpl ()
{
- if (m_type_sp)
+ if (m_dynamic_type_info.HasTypeSP())
return m_value.GetClangType();
else
return m_parent->GetClangType();
@@ -63,17 +62,35 @@ ConstString
ValueObjectDynamicValue::GetTypeName()
{
const bool success = UpdateValueIfNeeded(false);
- if (success && m_type_sp)
- return ClangASTType::GetConstTypeName (GetClangAST(), GetClangType());
- else
- return m_parent->GetTypeName();
+ if (success)
+ {
+ if (m_dynamic_type_info.HasTypeSP())
+ return ClangASTType::GetConstTypeName (GetClangAST(), GetClangType());
+ if (m_dynamic_type_info.HasName())
+ return m_dynamic_type_info.GetName();
+ }
+ return m_parent->GetTypeName();
}
-uint32_t
+ConstString
+ValueObjectDynamicValue::GetQualifiedTypeName()
+{
+ const bool success = UpdateValueIfNeeded(false);
+ if (success)
+ {
+ if (m_dynamic_type_info.HasTypeSP())
+ return ClangASTType::GetConstQualifiedTypeName (GetClangAST(), GetClangType());
+ if (m_dynamic_type_info.HasName())
+ return m_dynamic_type_info.GetName();
+ }
+ return m_parent->GetTypeName();
+}
+
+size_t
ValueObjectDynamicValue::CalculateNumChildren()
{
const bool success = UpdateValueIfNeeded(false);
- if (success && m_type_sp)
+ if (success && m_dynamic_type_info.HasTypeSP())
return ClangASTContext::GetNumChildren (GetClangAST (), GetClangType(), true);
else
return m_parent->GetNumChildren();
@@ -83,17 +100,17 @@ clang::ASTContext *
ValueObjectDynamicValue::GetClangASTImpl ()
{
const bool success = UpdateValueIfNeeded(false);
- if (success && m_type_sp)
- return m_type_sp->GetClangAST();
+ if (success && m_dynamic_type_info.HasTypeSP())
+ return m_dynamic_type_info.GetTypeSP()->GetClangAST();
else
return m_parent->GetClangAST ();
}
-size_t
+uint64_t
ValueObjectDynamicValue::GetByteSize()
{
const bool success = UpdateValueIfNeeded(false);
- if (success && m_type_sp)
+ if (success && m_dynamic_type_info.HasTypeSP())
return m_value.GetValueByteSize(GetClangAST(), NULL);
else
return m_parent->GetByteSize();
@@ -123,7 +140,7 @@ ValueObjectDynamicValue::UpdateValue ()
// parent which is equivalent to not using dynamic values.
if (m_use_dynamic == lldb::eNoDynamicValues)
{
- m_type_sp.reset();
+ m_dynamic_type_info.Clear();
return true;
}
@@ -165,8 +182,6 @@ ValueObjectDynamicValue::UpdateValue ()
}
}
- lldb::TypeSP dynamic_type_sp = class_type_or_name.GetTypeSP();
-
// Getting the dynamic value may have run the program a bit, and so marked us as needing updating, but we really
// don't...
@@ -176,10 +191,10 @@ ValueObjectDynamicValue::UpdateValue ()
// Or we could return false, and make ourselves an echo of our parent?
if (!found_dynamic_type)
{
- if (m_type_sp)
+ if (m_dynamic_type_info)
SetValueDidChange(true);
ClearDynamicTypeInformation();
- m_type_sp.reset();
+ m_dynamic_type_info.Clear();
m_value = m_parent->GetValue();
m_error = m_value.GetValueAsData (&exe_ctx, GetClangAST(), m_data, 0, GetModule().get());
return m_error.Success();
@@ -187,19 +202,19 @@ ValueObjectDynamicValue::UpdateValue ()
Value old_value(m_value);
- lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
bool has_changed_type = false;
- if (!m_type_sp)
+ if (!m_dynamic_type_info)
{
- m_type_sp = dynamic_type_sp;
+ m_dynamic_type_info = class_type_or_name;
has_changed_type = true;
}
- else if (dynamic_type_sp != m_type_sp)
+ else if (class_type_or_name != m_dynamic_type_info)
{
// We are another type, we need to tear down our children...
- m_type_sp = dynamic_type_sp;
+ m_dynamic_type_info = class_type_or_name;
SetValueDidChange (true);
has_changed_type = true;
}
@@ -219,16 +234,34 @@ ValueObjectDynamicValue::UpdateValue ()
m_value.GetScalar() = load_address;
}
- // The type will always be the type of the dynamic object. If our parent's type was a pointer,
- // then our type should be a pointer to the type of the dynamic object. If a reference, then the original type
- // should be okay...
- lldb::clang_type_t orig_type = m_type_sp->GetClangForwardType();
- lldb::clang_type_t corrected_type = orig_type;
- if (m_parent->IsPointerType())
- corrected_type = ClangASTContext::CreatePointerType (m_type_sp->GetClangAST(), orig_type);
- else if (m_parent->IsPointerOrReferenceType())
- corrected_type = ClangASTContext::CreateLValueReferenceType (m_type_sp->GetClangAST(), orig_type);
-
+ lldb::clang_type_t corrected_type;
+ if (m_dynamic_type_info.HasTypeSP())
+ {
+ // The type will always be the type of the dynamic object. If our parent's type was a pointer,
+ // then our type should be a pointer to the type of the dynamic object. If a reference, then the original type
+ // should be okay...
+ lldb::clang_type_t orig_type;
+ clang::ASTContext* ast;
+ orig_type = m_dynamic_type_info.GetTypeSP()->GetClangForwardType();
+ ast = m_dynamic_type_info.GetTypeSP()->GetClangAST();
+ corrected_type = orig_type;
+ if (m_parent->IsPointerType())
+ corrected_type = ClangASTContext::CreatePointerType (ast, orig_type);
+ else if (m_parent->IsPointerOrReferenceType())
+ corrected_type = ClangASTContext::CreateLValueReferenceType (ast, orig_type);
+ }
+ else /*if (m_dynamic_type_info.HasName())*/
+ {
+ // If we are here we need to adjust our dynamic type name to include the correct & or * symbol
+ std::string type_name_buf (m_dynamic_type_info.GetName().GetCString());
+ if (m_parent->IsPointerType())
+ type_name_buf.append(" *");
+ else if (m_parent->IsPointerOrReferenceType())
+ type_name_buf.append(" &");
+ corrected_type = m_parent->GetClangType();
+ m_dynamic_type_info.SetName(type_name_buf.c_str());
+ }
+
m_value.SetContext (Value::eContextTypeClangType, corrected_type);
// Our address is the location of the dynamic type stored in memory. It isn't a load address,
@@ -241,7 +274,7 @@ ValueObjectDynamicValue::UpdateValue ()
this,
GetTypeName().GetCString());
- if (m_address.IsValid() && m_type_sp)
+ if (m_address.IsValid() && m_dynamic_type_info)
{
// The variable value is in the Scalar value inside the m_value.
// We can point our m_data right to it.
@@ -310,3 +343,42 @@ ValueObjectDynamicValue::SetValueFromCSt
SetNeedsUpdate();
return ret_val;
}
+
+bool
+ValueObjectDynamicValue::SetData (DataExtractor &data, Error &error)
+{
+ if (!UpdateValueIfNeeded(false))
+ {
+ error.SetErrorString("unable to read value");
+ return false;
+ }
+
+ uint64_t my_value = GetValueAsUnsigned(UINT64_MAX);
+ uint64_t parent_value = m_parent->GetValueAsUnsigned(UINT64_MAX);
+
+ if (my_value == UINT64_MAX || parent_value == UINT64_MAX)
+ {
+ error.SetErrorString("unable to read value");
+ return false;
+ }
+
+ // if we are at an offset from our parent, in order to set ourselves correctly we would need
+ // to change the new value so that it refers to the correct dynamic type. we choose not to deal
+ // with that - if anything more than a value overwrite is required, you should be using the
+ // expression parser instead of the value editing facility
+ if (my_value != parent_value)
+ {
+ // but NULL'ing out a value should always be allowed
+ lldb::offset_t offset = 0;
+
+ if (data.GetPointer(&offset) != 0)
+ {
+ error.SetErrorString("unable to modify dynamic value, use 'expression' command");
+ return false;
+ }
+ }
+
+ bool ret_val = m_parent->SetData(data, error);
+ SetNeedsUpdate();
+ return ret_val;
+}
Modified: lldb/branches/windows/source/Core/ValueObjectList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/ValueObjectList.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/ValueObjectList.cpp (original)
+++ lldb/branches/windows/source/Core/ValueObjectList.cpp Wed Apr 17 03:38:48 2013
@@ -61,20 +61,20 @@ ValueObjectList::Append (const ValueObje
}
-uint32_t
+size_t
ValueObjectList::GetSize() const
{
return m_value_objects.size();
}
void
-ValueObjectList::Resize (uint32_t size)
+ValueObjectList::Resize (size_t size)
{
m_value_objects.resize (size);
}
lldb::ValueObjectSP
-ValueObjectList::GetValueObjectAtIndex (uint32_t idx)
+ValueObjectList::GetValueObjectAtIndex (size_t idx)
{
lldb::ValueObjectSP valobj_sp;
if (idx < m_value_objects.size())
@@ -83,7 +83,7 @@ ValueObjectList::GetValueObjectAtIndex (
}
lldb::ValueObjectSP
-ValueObjectList::RemoveValueObjectAtIndex (uint32_t idx)
+ValueObjectList::RemoveValueObjectAtIndex (size_t idx)
{
lldb::ValueObjectSP valobj_sp;
if (idx < m_value_objects.size())
@@ -95,7 +95,7 @@ ValueObjectList::RemoveValueObjectAtInde
}
void
-ValueObjectList::SetValueObjectAtIndex (uint32_t idx, const ValueObjectSP &valobj_sp)
+ValueObjectList::SetValueObjectAtIndex (size_t idx, const ValueObjectSP &valobj_sp)
{
if (idx >= m_value_objects.size())
m_value_objects.resize (idx + 1);
Modified: lldb/branches/windows/source/Core/ValueObjectMemory.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/ValueObjectMemory.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/ValueObjectMemory.cpp (original)
+++ lldb/branches/windows/source/Core/ValueObjectMemory.cpp Wed Apr 17 03:38:48 2013
@@ -146,7 +146,7 @@ ValueObjectMemory::GetTypeName()
return ClangASTType::GetConstTypeName (GetClangAST(), m_clang_type.GetOpaqueQualType());
}
-uint32_t
+size_t
ValueObjectMemory::CalculateNumChildren()
{
if (m_type_sp)
@@ -165,12 +165,12 @@ ValueObjectMemory::GetClangASTImpl ()
return m_clang_type.GetASTContext();
}
-size_t
+uint64_t
ValueObjectMemory::GetByteSize()
{
if (m_type_sp)
return m_type_sp->GetByteSize();
- return (m_clang_type.GetClangTypeBitWidth () + 7) / 8;
+ return m_clang_type.GetClangTypeByteSize ();
}
lldb::ValueType
Modified: lldb/branches/windows/source/Core/ValueObjectRegister.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/ValueObjectRegister.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/ValueObjectRegister.cpp (original)
+++ lldb/branches/windows/source/Core/ValueObjectRegister.cpp Wed Apr 17 03:38:48 2013
@@ -60,7 +60,7 @@ ValueObjectRegisterContext::GetQualified
return ConstString();
}
-uint32_t
+size_t
ValueObjectRegisterContext::CalculateNumChildren()
{
return m_reg_ctx_sp->GetRegisterSetCount();
@@ -72,7 +72,7 @@ ValueObjectRegisterContext::GetClangASTI
return NULL;
}
-size_t
+uint64_t
ValueObjectRegisterContext::GetByteSize()
{
return 0;
@@ -101,11 +101,11 @@ ValueObjectRegisterContext::UpdateValue
}
ValueObject *
-ValueObjectRegisterContext::CreateChildAtIndex (uint32_t idx, bool synthetic_array_member, int32_t synthetic_index)
+ValueObjectRegisterContext::CreateChildAtIndex (size_t idx, bool synthetic_array_member, int32_t synthetic_index)
{
ValueObject *new_valobj = NULL;
- const uint32_t num_children = GetNumChildren();
+ const size_t num_children = GetNumChildren();
if (idx < num_children)
{
ExecutionContext exe_ctx(GetExecutionContextRef());
@@ -162,7 +162,7 @@ ValueObjectRegisterSet::GetQualifiedType
return ConstString();
}
-uint32_t
+size_t
ValueObjectRegisterSet::CalculateNumChildren()
{
const RegisterSet *reg_set = m_reg_ctx_sp->GetRegisterSet(m_reg_set_idx);
@@ -177,7 +177,7 @@ ValueObjectRegisterSet::GetClangASTImpl
return NULL;
}
-size_t
+uint64_t
ValueObjectRegisterSet::GetByteSize()
{
return 0;
@@ -222,12 +222,12 @@ ValueObjectRegisterSet::UpdateValue ()
ValueObject *
-ValueObjectRegisterSet::CreateChildAtIndex (uint32_t idx, bool synthetic_array_member, int32_t synthetic_index)
+ValueObjectRegisterSet::CreateChildAtIndex (size_t idx, bool synthetic_array_member, int32_t synthetic_index)
{
ValueObject *valobj = NULL;
if (m_reg_ctx_sp && m_reg_set)
{
- const uint32_t num_children = GetNumChildren();
+ const size_t num_children = GetNumChildren();
if (idx < num_children)
valobj = new ValueObjectRegister(*this, m_reg_ctx_sp, m_reg_set->registers[idx]);
}
@@ -250,7 +250,7 @@ ValueObjectRegisterSet::GetChildMemberWi
return ValueObjectSP();
}
-uint32_t
+size_t
ValueObjectRegisterSet::GetIndexOfChildWithName (const ConstString &name)
{
if (m_reg_ctx_sp && m_reg_set)
@@ -341,7 +341,7 @@ ValueObjectRegister::GetTypeName()
return m_type_name;
}
-uint32_t
+size_t
ValueObjectRegister::CalculateNumChildren()
{
return 0;
@@ -361,7 +361,7 @@ ValueObjectRegister::GetClangASTImpl ()
return NULL;
}
-size_t
+uint64_t
ValueObjectRegister::GetByteSize()
{
return m_reg_info.byte_size;
@@ -411,6 +411,24 @@ ValueObjectRegister::SetValueFromCString
if (error.Success())
{
if (m_reg_ctx_sp->WriteRegister (&m_reg_info, m_reg_value))
+ {
+ SetNeedsUpdate();
+ return true;
+ }
+ else
+ return false;
+ }
+ else
+ return false;
+}
+
+bool
+ValueObjectRegister::SetData (DataExtractor &data, Error &error)
+{
+ error = m_reg_value.SetValueFromData(&m_reg_info, data, 0, false);
+ if (error.Success())
+ {
+ if (m_reg_ctx_sp->WriteRegister (&m_reg_info, m_reg_value))
{
SetNeedsUpdate();
return true;
Modified: lldb/branches/windows/source/Core/ValueObjectSyntheticFilter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/ValueObjectSyntheticFilter.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/ValueObjectSyntheticFilter.cpp (original)
+++ lldb/branches/windows/source/Core/ValueObjectSyntheticFilter.cpp Wed Apr 17 03:38:48 2013
@@ -15,8 +15,8 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/FormatClasses.h"
#include "lldb/Core/ValueObject.h"
+#include "lldb/DataFormatters/FormatClasses.h"
using namespace lldb_private;
@@ -27,19 +27,19 @@ public:
SyntheticChildrenFrontEnd(backend)
{}
- uint32_t
+ size_t
CalculateNumChildren()
{
return 0;
}
lldb::ValueObjectSP
- GetChildAtIndex (uint32_t idx)
+ GetChildAtIndex (size_t idx)
{
return lldb::ValueObjectSP();
}
- uint32_t
+ size_t
GetIndexOfChildWithName (const ConstString &name)
{
return UINT32_MAX;
@@ -95,7 +95,13 @@ ValueObjectSynthetic::GetTypeName()
return m_parent->GetTypeName();
}
-uint32_t
+ConstString
+ValueObjectSynthetic::GetQualifiedTypeName()
+{
+ return m_parent->GetQualifiedTypeName();
+}
+
+size_t
ValueObjectSynthetic::CalculateNumChildren()
{
UpdateValueIfNeeded();
@@ -104,6 +110,16 @@ ValueObjectSynthetic::CalculateNumChildr
return (m_synthetic_children_count = m_synth_filter_ap->CalculateNumChildren());
}
+lldb::ValueObjectSP
+ValueObjectSynthetic::GetDynamicValue (lldb::DynamicValueType valueType)
+{
+ if (!m_parent)
+ return lldb::ValueObjectSP();
+ if (IsDynamic() && GetDynamicValueType() == valueType)
+ return GetSP();
+ return m_parent->GetDynamicValue(valueType);
+}
+
bool
ValueObjectSynthetic::MightHaveChildren()
{
@@ -119,7 +135,7 @@ ValueObjectSynthetic::GetClangASTImpl ()
return m_parent->GetClangAST ();
}
-size_t
+uint64_t
ValueObjectSynthetic::GetByteSize()
{
return m_parent->GetByteSize();
@@ -183,7 +199,7 @@ ValueObjectSynthetic::UpdateValue ()
}
lldb::ValueObjectSP
-ValueObjectSynthetic::GetChildAtIndex (uint32_t idx, bool can_create)
+ValueObjectSynthetic::GetChildAtIndex (size_t idx, bool can_create)
{
UpdateValueIfNeeded();
@@ -219,7 +235,7 @@ ValueObjectSynthetic::GetChildMemberWith
return GetChildAtIndex(index, can_create);
}
-uint32_t
+size_t
ValueObjectSynthetic::GetIndexOfChildWithName (const ConstString &name)
{
UpdateValueIfNeeded();
Modified: lldb/branches/windows/source/Core/ValueObjectVariable.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/ValueObjectVariable.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/ValueObjectVariable.cpp (original)
+++ lldb/branches/windows/source/Core/ValueObjectVariable.cpp Wed Apr 17 03:38:48 2013
@@ -80,7 +80,7 @@ ValueObjectVariable::GetQualifiedTypeNam
return ConstString();
}
-uint32_t
+size_t
ValueObjectVariable::CalculateNumChildren()
{
ClangASTType type(GetClangAST(),
@@ -102,16 +102,15 @@ ValueObjectVariable::GetClangASTImpl ()
return 0;
}
-size_t
+uint64_t
ValueObjectVariable::GetByteSize()
{
- ClangASTType type(GetClangAST(),
- GetClangType());
+ ClangASTType type(GetClangAST(), GetClangType());
if (!type.IsValid())
return 0;
- return (ClangASTType::GetClangTypeBitWidth(type.GetASTContext(), type.GetOpaqueQualType()) + 7) / 8;
+ return type.GetClangTypeByteSize();
}
lldb::ValueType
Modified: lldb/branches/windows/source/DataFormatters/CXXFormatterFunctions.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/DataFormatters/CXXFormatterFunctions.cpp?rev=179679&r1=179594&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/DataFormatters/CXXFormatterFunctions.cpp (original)
+++ lldb/branches/windows/source/DataFormatters/CXXFormatterFunctions.cpp Wed Apr 17 03:38:48 2013
@@ -488,11 +488,20 @@ ExtractLibcxxStringInfo (ValueObject& va
ValueObjectSP &location_sp,
uint64_t& size)
{
- ValueObjectSP D(valobj.GetChildAtIndexPath({0,0,0,0}));
+ std::vector<size_t> idxes;
+ idxes.push_back(0);
+ idxes.push_back(0);
+ idxes.push_back(0);
+ idxes.push_back(0);
+ ValueObjectSP D(valobj.GetChildAtIndexPath(idxes));
if (!D)
return false;
- ValueObjectSP size_mode(D->GetChildAtIndexPath({1,0,0}));
+ idxes.clear();
+ idxes.push_back(1);
+ idxes.push_back(0);
+ idxes.push_back(0);
+ ValueObjectSP size_mode(D->GetChildAtIndexPath(idxes));
if (!size_mode)
return false;
@@ -1046,6 +1055,9 @@ lldb_private::formatters::GetOSXEpoch ()
static time_t epoch = 0;
if (!epoch)
{
+#if _WIN32
+ // TODO: Win32
+#else
tzset();
tm tm_epoch;
tm_epoch.tm_sec = 0;
@@ -1058,6 +1070,7 @@ lldb_private::formatters::GetOSXEpoch ()
tm_epoch.tm_gmtoff = 0;
tm_epoch.tm_zone = NULL;
epoch = timegm(&tm_epoch);
+#endif
}
return epoch;
}
Modified: lldb/branches/windows/source/Expression/ASTDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Expression/ASTDumper.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Expression/ASTDumper.cpp (original)
+++ lldb/branches/windows/source/Expression/ASTDumper.cpp Wed Apr 17 03:38:48 2013
@@ -89,7 +89,7 @@ void ASTDumper::ToSTDERR()
fprintf(stderr, "%s\n", m_dump.c_str());
}
-void ASTDumper::ToLog(lldb::LogSP &log, const char *prefix)
+void ASTDumper::ToLog(Log *log, const char *prefix)
{
size_t len = m_dump.length() + 1;
Modified: lldb/branches/windows/source/Expression/ASTResultSynthesizer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Expression/ASTResultSynthesizer.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Expression/ASTResultSynthesizer.cpp (original)
+++ lldb/branches/windows/source/Expression/ASTResultSynthesizer.cpp Wed Apr 17 03:38:48 2013
@@ -60,7 +60,7 @@ ASTResultSynthesizer::Initialize(ASTCont
void
ASTResultSynthesizer::TransformTopLevelDecl(Decl* D)
{
- lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
if (NamedDecl *named_decl = dyn_cast<NamedDecl>(D))
{
@@ -129,7 +129,7 @@ ASTResultSynthesizer::HandleTopLevelDecl
bool
ASTResultSynthesizer::SynthesizeFunctionResult (FunctionDecl *FunDecl)
{
- lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
if (!m_sema)
return false;
@@ -175,7 +175,7 @@ ASTResultSynthesizer::SynthesizeFunction
bool
ASTResultSynthesizer::SynthesizeObjCMethodResult (ObjCMethodDecl *MethodDecl)
{
- lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
if (!m_sema)
return false;
@@ -224,7 +224,7 @@ bool
ASTResultSynthesizer::SynthesizeBodyResult (CompoundStmt *Body,
DeclContext *DC)
{
- lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
ASTContext &Ctx(*m_ast_context);
@@ -357,7 +357,6 @@ ASTResultSynthesizer::SynthesizeBodyResu
result_ptr_id,
ptr_qual_type,
NULL,
- SC_Static,
SC_Static);
if (!result_decl)
@@ -378,7 +377,6 @@ ASTResultSynthesizer::SynthesizeBodyResu
&result_id,
expr_qual_type,
NULL,
- SC_Static,
SC_Static);
if (!result_decl)
@@ -452,7 +450,7 @@ ASTResultSynthesizer::MaybeRecordPersist
if (name.size() == 0 || name[0] != '$')
return;
- lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
ConstString name_cs(name.str().c_str());
Modified: lldb/branches/windows/source/Expression/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Expression/CMakeLists.txt?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Expression/CMakeLists.txt (original)
+++ lldb/branches/windows/source/Expression/CMakeLists.txt Wed Apr 17 03:38:48 2013
@@ -15,8 +15,9 @@ add_lldb_library(lldbExpression
DWARFExpression.cpp
ExpressionSourceCode.cpp
IRDynamicChecks.cpp
+ IRExecutionUnit.cpp
IRForTarget.cpp
IRInterpreter.cpp
- ProcessDataAllocator.cpp
- RecordingMemoryManager.cpp
+ IRMemoryMap.cpp
+ Materializer.cpp
)
Modified: lldb/branches/windows/source/Expression/ClangASTSource.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Expression/ClangASTSource.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Expression/ClangASTSource.cpp (original)
+++ lldb/branches/windows/source/Expression/ClangASTSource.cpp Wed Apr 17 03:38:48 2013
@@ -56,7 +56,7 @@ ClangASTSource::StartTranslationUnit(AST
}
// The core lookup interface.
-DeclContext::lookup_result
+bool
ClangASTSource::FindExternalVisibleDeclsByName
(
const DeclContext *decl_ctx,
@@ -64,10 +64,16 @@ ClangASTSource::FindExternalVisibleDecls
)
{
if (!m_ast_context)
- return SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
+ {
+ SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
+ return false;
+ }
if (GetImportInProgress())
- return SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
+ {
+ SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
+ return false;
+ }
std::string decl_name (clang_decl_name.getAsString());
@@ -83,7 +89,8 @@ ClangASTSource::FindExternalVisibleDecls
if (!identifier_info ||
identifier_info->getBuiltinID() != 0)
{
- return SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
+ SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
+ return false;
}
}
break;
@@ -91,12 +98,14 @@ ClangASTSource::FindExternalVisibleDecls
// Operator names. Not important for now.
case DeclarationName::CXXOperatorName:
case DeclarationName::CXXLiteralOperatorName:
- return DeclContext::lookup_result();
+ SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
+ return false;
// Using directives found in this context.
// Tell Sema we didn't find any or we'll end up getting asked a *lot*.
case DeclarationName::CXXUsingDirective:
- return SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
+ SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
+ return false;
case DeclarationName::ObjCZeroArgSelector:
case DeclarationName::ObjCOneArgSelector:
@@ -108,13 +117,15 @@ ClangASTSource::FindExternalVisibleDecls
FindObjCMethodDecls(method_search_context);
- return SetExternalVisibleDeclsForName (decl_ctx, clang_decl_name, method_decls);
+ SetExternalVisibleDeclsForName (decl_ctx, clang_decl_name, method_decls);
+ return (method_decls.size() > 0);
}
// These aren't possible in the global context.
case DeclarationName::CXXConstructorName:
case DeclarationName::CXXDestructorName:
case DeclarationName::CXXConversionFunctionName:
- return DeclContext::lookup_result();
+ SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
+ return false;
}
@@ -128,7 +139,8 @@ ClangASTSource::FindExternalVisibleDecls
}
else
{
- return SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
+ SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
+ return false;
}
}
@@ -138,7 +150,8 @@ ClangASTSource::FindExternalVisibleDecls
if (m_active_lookups.find (uniqued_const_decl_name) != m_active_lookups.end())
{
// We are currently looking up this name...
- return DeclContext::lookup_result();
+ SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
+ return false;
}
m_active_lookups.insert(uniqued_const_decl_name);
// static uint32_t g_depth = 0;
@@ -147,16 +160,16 @@ ClangASTSource::FindExternalVisibleDecls
llvm::SmallVector<NamedDecl*, 4> name_decls;
NameSearchContext name_search_context(*this, name_decls, clang_decl_name, decl_ctx);
FindExternalVisibleDecls(name_search_context);
- DeclContext::lookup_result result (SetExternalVisibleDeclsForName (decl_ctx, clang_decl_name, name_decls));
+ SetExternalVisibleDeclsForName (decl_ctx, clang_decl_name, name_decls);
// --g_depth;
m_active_lookups.erase (uniqued_const_decl_name);
- return result;
+ return (name_decls.size() != 0);
}
void
ClangASTSource::CompleteType (TagDecl *tag_decl)
{
- lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
static unsigned int invocation_id = 0;
unsigned int current_id = invocation_id++;
@@ -293,7 +306,7 @@ ClangASTSource::CompleteType (TagDecl *t
void
ClangASTSource::CompleteType (clang::ObjCInterfaceDecl *interface_decl)
{
- lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
if (log)
{
@@ -354,8 +367,10 @@ clang::ExternalLoadResult
ClangASTSource::FindExternalLexicalDecls (const DeclContext *decl_context,
bool (*predicate)(Decl::Kind),
llvm::SmallVectorImpl<Decl*> &decls)
-{
- lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+{
+ ClangASTMetrics::RegisterLexicalQuery();
+
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
const Decl *context_decl = dyn_cast<Decl>(decl_context);
@@ -397,7 +412,7 @@ ClangASTSource::FindExternalLexicalDecls
if (log)
{
- log->Printf(" FELD[%u] Original decl (Decl*)%p:", current_id, original_decl);
+ log->Printf(" FELD[%u] Original decl (ASTContext*)%p (Decl*)%p:", current_id, original_ctx, original_decl);
ASTDumper(original_decl).ToLog(log, " ");
}
@@ -453,11 +468,7 @@ ClangASTSource::FindExternalLexicalDecls
{
QualType copied_field_type = copied_field->getType();
- if (const TagType *copied_field_tag_type = copied_field_type->getAs<TagType>())
- m_ast_importer->CompleteTagDecl(copied_field_tag_type->getDecl());
- if (const ObjCObjectType *copied_field_object_type = copied_field_type->getAs<ObjCObjectType>())
- if (ObjCInterfaceDecl *copied_field_objc_interface_decl = copied_field_object_type->getInterface())
- m_ast_importer->CompleteObjCInterfaceDecl(copied_field_objc_interface_decl);
+ m_ast_importer->RequireCompleteType(copied_field_type);
}
decls.push_back(copied_decl);
@@ -472,9 +483,11 @@ ClangASTSource::FindExternalVisibleDecls
{
assert (m_ast_context);
+ ClangASTMetrics::RegisterVisibleQuery();
+
const ConstString name(context.m_decl_name.getAsString().c_str());
- lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
static unsigned int invocation_id = 0;
unsigned int current_id = invocation_id++;
@@ -565,7 +578,7 @@ ClangASTSource::FindExternalVisibleDecls
{
assert (m_ast_context);
- lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
SymbolContextList sc_list;
@@ -615,9 +628,7 @@ ClangASTSource::FindExternalVisibleDecls
const ModuleList &target_images = m_target->GetImages();
Mutex::Locker modules_locker (target_images.GetMutex());
- for (uint32_t i = 0, e = target_images.GetSize();
- i != e;
- ++i)
+ for (size_t i = 0, e = target_images.GetSize(); i < e; ++i)
{
lldb::ModuleSP image = target_images.GetModuleAtIndexUnlocked(i);
@@ -875,7 +886,7 @@ FindObjCMethodDeclsWithOrigin (unsigned
if (!copied_method_decl)
return false;
- lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
if (log)
{
@@ -891,7 +902,7 @@ FindObjCMethodDeclsWithOrigin (unsigned
void
ClangASTSource::FindObjCMethodDecls (NameSearchContext &context)
{
- lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
static unsigned int invocation_id = 0;
unsigned int current_id = invocation_id++;
@@ -1178,7 +1189,7 @@ FindObjCPropertyAndIvarDeclsWithOrigin (
ClangASTImporter *ast_importer,
DeclFromUser<const ObjCInterfaceDecl> &origin_iface_decl)
{
- lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
if (origin_iface_decl.IsInvalid())
return false;
@@ -1231,7 +1242,7 @@ FindObjCPropertyAndIvarDeclsWithOrigin (
void
ClangASTSource::FindObjCPropertyAndIvarDecls (NameSearchContext &context)
{
- lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
static unsigned int invocation_id = 0;
unsigned int current_id = invocation_id++;
@@ -1424,16 +1435,19 @@ ClangASTSource::layoutRecordType(const R
BaseOffsetMap &base_offsets,
BaseOffsetMap &virtual_base_offsets)
{
+ ClangASTMetrics::RegisterRecordLayout();
+
static unsigned int invocation_id = 0;
unsigned int current_id = invocation_id++;
- lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
if (log)
{
- log->Printf("LayoutRecordType[%u] on (RecordDecl*)%p [name = '%s']",
+ log->Printf("LayoutRecordType[%u] on (ASTContext*)%p for (RecordDecl*)%p [name = '%s']",
current_id,
m_ast_context,
+ record,
record->getNameAsString().c_str());
}
@@ -1455,12 +1469,15 @@ ClangASTSource::layoutRecordType(const R
const ASTRecordLayout &record_layout(origin_record->getASTContext().getASTRecordLayout(origin_record.decl));
- int field_idx = 0;
+ int field_idx = 0, field_count = record_layout.getFieldCount();
for (RecordDecl::field_iterator fi = origin_record->field_begin(), fe = origin_record->field_end();
fi != fe;
++fi)
{
+ if (field_idx >= field_count)
+ return false; // Layout didn't go well. Bail out.
+
uint64_t field_offset = record_layout.getFieldOffset(field_idx);
origin_field_offsets.insert(std::pair<const FieldDecl *, uint64_t>(*fi, field_offset));
@@ -1545,7 +1562,7 @@ ClangASTSource::CompleteNamespaceMap (Cl
static unsigned int invocation_id = 0;
unsigned int current_id = invocation_id++;
- lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
if (log)
{
@@ -1602,9 +1619,7 @@ ClangASTSource::CompleteNamespaceMap (Cl
ClangNamespaceDecl null_namespace_decl;
- for (uint32_t i = 0, e = target_images.GetSize();
- i != e;
- ++i)
+ for (size_t i = 0, e = target_images.GetSize(); i < e; ++i)
{
lldb::ModuleSP image = target_images.GetModuleAtIndexUnlocked(i);
@@ -1642,8 +1657,6 @@ ClangASTSource::AddNamespace (NameSearch
if (!namespace_decls)
return NULL;
- lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-
const ClangNamespaceDecl &namespace_decl = namespace_decls->begin()->second;
Decl *copied_decl = m_ast_importer->CopyDecl(m_ast_context, namespace_decl.GetASTContext(), namespace_decl.GetNamespaceDecl());
@@ -1653,6 +1666,11 @@ ClangASTSource::AddNamespace (NameSearch
NamespaceDecl *copied_namespace_decl = dyn_cast<NamespaceDecl>(copied_decl);
+ if (!copied_namespace_decl)
+ return NULL;
+
+ context.m_decls.push_back(copied_namespace_decl);
+
m_ast_importer->RegisterNamespaceMap(copied_namespace_decl, namespace_decls);
return dyn_cast<NamespaceDecl>(copied_decl);
@@ -1662,7 +1680,9 @@ void *
ClangASTSource::GuardedCopyType (ASTContext *dest_context,
ASTContext *source_context,
void *clang_type)
-{
+{
+ ClangASTMetrics::RegisterLLDBImport();
+
SetImportInProgress(true);
QualType ret_qual_type = m_ast_importer->CopyType (m_ast_context, source_context, QualType::getFromOpaquePtr(clang_type));
@@ -1693,7 +1713,6 @@ NameSearchContext::AddVarDecl(void *type
ii,
QualType::getFromOpaquePtr(type),
0,
- SC_Static,
SC_Static);
m_decls.push_back(Decl);
@@ -1743,7 +1762,6 @@ NameSearchContext::AddFunDecl (void *typ
arg_qual_type,
NULL,
SC_Static,
- SC_Static,
NULL));
}
@@ -1751,7 +1769,7 @@ NameSearchContext::AddFunDecl (void *typ
}
else
{
- lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
log->Printf("Function type wasn't a FunctionProtoType");
}
@@ -1769,8 +1787,7 @@ NameSearchContext::AddGenericFunDecl()
proto_info.Variadic = true;
QualType generic_function_type(m_ast_source.m_ast_context->getFunctionType (m_ast_source.m_ast_context->UnknownAnyTy, // result
- NULL, // argument types
- 0, // number of arguments
+ ArrayRef<QualType>(), // argument types
proto_info));
return AddFunDecl(generic_function_type.getAsOpaquePtr());
@@ -1799,6 +1816,14 @@ NameSearchContext::AddTypeDecl(void *typ
return (NamedDecl*)interface_decl;
}
+ else if (const TypedefType *typedef_type = qual_type->getAs<TypedefType>())
+ {
+ TypedefNameDecl *typedef_name_decl = typedef_type->getDecl();
+
+ m_decls.push_back(typedef_name_decl);
+
+ return (NamedDecl*)typedef_name_decl;
+ }
}
return NULL;
}
Modified: lldb/branches/windows/source/Expression/ClangExpressionDeclMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Expression/ClangExpressionDeclMap.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Expression/ClangExpressionDeclMap.cpp (original)
+++ lldb/branches/windows/source/Expression/ClangExpressionDeclMap.cpp Wed Apr 17 03:38:48 2013
@@ -27,6 +27,7 @@
#include "lldb/Expression/ASTDumper.h"
#include "lldb/Expression/ClangASTSource.h"
#include "lldb/Expression/ClangPersistentVariables.h"
+#include "lldb/Expression/Materializer.h"
#include "lldb/Host/Endian.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/ClangNamespaceDecl.h"
@@ -74,24 +75,27 @@ ClangExpressionDeclMap::~ClangExpression
}
bool
-ClangExpressionDeclMap::WillParse(ExecutionContext &exe_ctx)
-{
+ClangExpressionDeclMap::WillParse(ExecutionContext &exe_ctx,
+ Materializer *materializer)
+{
+ ClangASTMetrics::ClearLocalCounters();
+
EnableParserVars();
m_parser_vars->m_exe_ctx = exe_ctx;
Target *target = exe_ctx.GetTargetPtr();
if (exe_ctx.GetFramePtr())
m_parser_vars->m_sym_ctx = exe_ctx.GetFramePtr()->GetSymbolContext(lldb::eSymbolContextEverything);
- else if (exe_ctx.GetThreadPtr())
+ else if (exe_ctx.GetThreadPtr() && exe_ctx.GetThreadPtr()->GetStackFrameAtIndex(0))
m_parser_vars->m_sym_ctx = exe_ctx.GetThreadPtr()->GetStackFrameAtIndex(0)->GetSymbolContext(lldb::eSymbolContextEverything);
else if (exe_ctx.GetProcessPtr())
{
- m_parser_vars->m_sym_ctx.Clear();
+ m_parser_vars->m_sym_ctx.Clear(true);
m_parser_vars->m_sym_ctx.target_sp = exe_ctx.GetTargetSP();
}
else if (target)
{
- m_parser_vars->m_sym_ctx.Clear();
+ m_parser_vars->m_sym_ctx.Clear(true);
m_parser_vars->m_sym_ctx.target_sp = exe_ctx.GetTargetSP();
}
@@ -104,13 +108,19 @@ ClangExpressionDeclMap::WillParse(Execut
}
m_parser_vars->m_target_info = GetTargetInfo();
+ m_parser_vars->m_materializer = materializer;
return true;
}
-void
+void
ClangExpressionDeclMap::DidParse()
{
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+
+ if (log)
+ ClangASTMetrics::DumpCounters(log);
+
if (m_parser_vars.get())
{
for (size_t entity_index = 0, num_entities = m_found_entities.GetSize();
@@ -120,11 +130,12 @@ ClangExpressionDeclMap::DidParse()
ClangExpressionVariableSP var_sp(m_found_entities.GetVariableAtIndex(entity_index));
if (var_sp)
{
- if (var_sp->m_parser_vars.get() &&
- var_sp->m_parser_vars->m_lldb_value)
- delete var_sp->m_parser_vars->m_lldb_value;
+ ClangExpressionVariable::ParserVars *parser_vars = var_sp->GetParserVars(GetParserID());
- var_sp->DisableParserVars();
+ if (parser_vars && parser_vars->m_lldb_value)
+ delete parser_vars->m_lldb_value;
+
+ var_sp->DisableParserVars(GetParserID());
}
}
@@ -134,7 +145,7 @@ ClangExpressionDeclMap::DidParse()
{
ClangExpressionVariableSP pvar_sp(m_parser_vars->m_persistent_vars->GetVariableAtIndex(pvar_index));
if (pvar_sp)
- pvar_sp->DisableParserVars();
+ pvar_sp->DisableParserVars(GetParserID());
}
DisableParserVars();
@@ -208,7 +219,7 @@ ClangExpressionDeclMap::BuildIntegerVari
if (!user_type.GetOpaqueQualType())
{
- lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
if (log)
log->Printf("ClangExpressionDeclMap::BuildIntegerVariable - Couldn't export the type for a constant integer result");
@@ -281,7 +292,7 @@ ClangExpressionDeclMap::BuildCastVariabl
{
assert (m_parser_vars.get());
- lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
ExecutionContext &exe_ctx = m_parser_vars->m_exe_ctx;
Target *target = exe_ctx.GetTargetPtr();
@@ -290,10 +301,10 @@ ClangExpressionDeclMap::BuildCastVariabl
ASTContext *context(target->GetScratchClangASTContext()->getASTContext());
- ClangExpressionVariableSP var_sp (m_found_entities.GetVariable(decl));
+ ClangExpressionVariableSP var_sp (m_found_entities.GetVariable(decl, GetParserID()));
if (!var_sp)
- var_sp = m_parser_vars->m_persistent_vars->GetVariable(decl);
+ var_sp = m_parser_vars->m_persistent_vars->GetVariable(decl, GetParserID());
if (!var_sp)
return ClangExpressionVariableSP();
@@ -447,7 +458,7 @@ ClangExpressionDeclMap::AddPersistentVar
{
assert (m_parser_vars.get());
- lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
ExecutionContext &exe_ctx = m_parser_vars->m_exe_ctx;
Target *target = exe_ctx.GetTargetPtr();
if (target == NULL)
@@ -499,13 +510,26 @@ ClangExpressionDeclMap::AddPersistentVar
var_sp->m_flags |= ClangExpressionVariable::EVNeedsAllocation;
}
+ if (m_keep_result_in_memory)
+ {
+ var_sp->m_flags |= ClangExpressionVariable::EVKeepInTarget;
+ }
+
if (log)
log->Printf("Created persistent variable with flags 0x%hx", var_sp->m_flags);
- var_sp->EnableParserVars();
+ var_sp->EnableParserVars(GetParserID());
+
+ ClangExpressionVariable::ParserVars *parser_vars = var_sp->GetParserVars(GetParserID());
- var_sp->m_parser_vars->m_named_decl = decl;
- var_sp->m_parser_vars->m_parser_type = parser_type;
+ parser_vars->m_named_decl = decl;
+ parser_vars->m_parser_type = parser_type;
+
+ if (m_parser_vars->m_materializer)
+ {
+ Error err;
+ m_parser_vars->m_materializer->AddResultVariable(user_type, m_keep_result_in_memory, err);
+ }
return true;
}
@@ -523,17 +547,22 @@ ClangExpressionDeclMap::AddValueToStruct
assert (m_struct_vars.get());
assert (m_parser_vars.get());
- lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+ bool is_persistent_variable = false;
+
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
m_struct_vars->m_struct_laid_out = false;
- if (m_struct_members.GetVariable(decl))
+ if (m_struct_members.GetVariable(decl, GetParserID()))
return true;
- ClangExpressionVariableSP var_sp (m_found_entities.GetVariable(decl));
+ ClangExpressionVariableSP var_sp (m_found_entities.GetVariable(decl, GetParserID()));
if (!var_sp)
- var_sp = m_parser_vars->m_persistent_vars->GetVariable(decl);
+ {
+ var_sp = m_parser_vars->m_persistent_vars->GetVariable(decl, GetParserID());
+ is_persistent_variable = true;
+ }
if (!var_sp)
return false;
@@ -546,14 +575,49 @@ ClangExpressionDeclMap::AddValueToStruct
// We know entity->m_parser_vars is valid because we used a parser variable
// to find it
- var_sp->m_parser_vars->m_llvm_value = value;
- var_sp->EnableJITVars();
- var_sp->m_jit_vars->m_alignment = alignment;
- var_sp->m_jit_vars->m_size = size;
+ ClangExpressionVariable::ParserVars *parser_vars = var_sp->GetParserVars(GetParserID());
+
+ parser_vars->m_llvm_value = value;
+
+ var_sp->EnableJITVars(GetParserID());
+
+ ClangExpressionVariable::JITVars *jit_vars = var_sp->GetJITVars(GetParserID());
+
+ jit_vars->m_alignment = alignment;
+ jit_vars->m_size = size;
m_struct_members.AddVariable(var_sp);
+ if (m_parser_vars->m_materializer)
+ {
+ uint32_t offset = 0;
+
+ Error err;
+
+ if (is_persistent_variable)
+ {
+ offset = m_parser_vars->m_materializer->AddPersistentVariable(var_sp, err);
+ }
+ else
+ {
+ if (const lldb_private::Symbol *sym = parser_vars->m_lldb_sym)
+ offset = m_parser_vars->m_materializer->AddSymbol(*sym, err);
+ else if (const RegisterInfo *reg_info = var_sp->GetRegisterInfo())
+ offset = m_parser_vars->m_materializer->AddRegister(*reg_info, err);
+ else if (parser_vars->m_lldb_var)
+ offset = m_parser_vars->m_materializer->AddVariable(parser_vars->m_lldb_var, err);
+ }
+
+ if (!err.Success())
+ return false;
+
+ if (log)
+ log->Printf("Placed at 0x%llx", (unsigned long long)offset);
+
+ jit_vars->m_offset = offset; // TODO DoStructLayout() should not change this.
+ }
+
return true;
}
@@ -565,6 +629,14 @@ ClangExpressionDeclMap::DoStructLayout (
if (m_struct_vars->m_struct_laid_out)
return true;
+ if (m_parser_vars->m_materializer)
+ {
+ m_struct_vars->m_struct_alignment = m_parser_vars->m_materializer->GetStructAlignment();
+ m_struct_vars->m_struct_size = m_parser_vars->m_materializer->GetStructByteSize();
+ m_struct_vars->m_struct_laid_out = true;
+ return true;
+ }
+
off_t cursor = 0;
m_struct_vars->m_struct_alignment = 0;
@@ -577,18 +649,20 @@ ClangExpressionDeclMap::DoStructLayout (
ClangExpressionVariableSP member_sp(m_struct_members.GetVariableAtIndex(member_index));
if (!member_sp)
return false;
+
+ ClangExpressionVariable::JITVars *jit_vars = member_sp->GetJITVars(GetParserID());
- if (!member_sp->m_jit_vars.get())
+ if (!jit_vars)
return false;
if (member_index == 0)
- m_struct_vars->m_struct_alignment = member_sp->m_jit_vars->m_alignment;
+ m_struct_vars->m_struct_alignment = jit_vars->m_alignment;
- if (cursor % member_sp->m_jit_vars->m_alignment)
- cursor += (member_sp->m_jit_vars->m_alignment - (cursor % member_sp->m_jit_vars->m_alignment));
+ if (cursor % jit_vars->m_alignment)
+ cursor += (jit_vars->m_alignment - (cursor % jit_vars->m_alignment));
- member_sp->m_jit_vars->m_offset = cursor;
- cursor += member_sp->m_jit_vars->m_size;
+ jit_vars->m_offset = cursor;
+ cursor += jit_vars->m_size;
}
m_struct_vars->m_struct_size = cursor;
@@ -636,15 +710,20 @@ ClangExpressionDeclMap::GetStructElement
ClangExpressionVariableSP member_sp(m_struct_members.GetVariableAtIndex(index));
- if (!member_sp ||
- !member_sp->m_parser_vars.get() ||
- !member_sp->m_jit_vars.get() ||
+ if (!member_sp)
+ return false;
+
+ ClangExpressionVariable::ParserVars *parser_vars = member_sp->GetParserVars(GetParserID());
+ ClangExpressionVariable::JITVars *jit_vars = member_sp->GetJITVars(GetParserID());
+
+ if (!parser_vars ||
+ !jit_vars ||
!member_sp->GetValueObject())
return false;
- decl = member_sp->m_parser_vars->m_named_decl;
- value = member_sp->m_parser_vars->m_llvm_value;
- offset = member_sp->m_jit_vars->m_offset;
+ decl = parser_vars->m_named_decl;
+ value = parser_vars->m_llvm_value;
+ offset = jit_vars->m_offset;
name = member_sp->GetName();
return true;
@@ -657,7 +736,7 @@ ClangExpressionDeclMap::GetFunctionInfo
uint64_t &ptr
)
{
- ClangExpressionVariableSP entity_sp(m_found_entities.GetVariable(decl));
+ ClangExpressionVariableSP entity_sp(m_found_entities.GetVariable(decl, GetParserID()));
if (!entity_sp)
return false;
@@ -665,7 +744,9 @@ ClangExpressionDeclMap::GetFunctionInfo
// We know m_parser_vars is valid since we searched for the variable by
// its NamedDecl
- ptr = entity_sp->m_parser_vars->m_lldb_value->GetScalar().ULongLong();
+ ClangExpressionVariable::ParserVars *parser_vars = entity_sp->GetParserVars(GetParserID());
+
+ ptr = parser_vars->m_lldb_value->GetScalar().ULongLong();
return true;
}
@@ -678,11 +759,32 @@ FindCodeSymbolInContext
SymbolContextList &sc_list
)
{
+ SymbolContextList temp_sc_list;
if (sym_ctx.module_sp)
- sym_ctx.module_sp->FindSymbolsWithNameAndType(name, eSymbolTypeCode, sc_list);
+ sym_ctx.module_sp->FindSymbolsWithNameAndType(name, eSymbolTypeAny, temp_sc_list);
- if (!sc_list.GetSize())
- sym_ctx.target_sp->GetImages().FindSymbolsWithNameAndType(name, eSymbolTypeCode, sc_list);
+ if (!sc_list.GetSize() && sym_ctx.target_sp)
+ sym_ctx.target_sp->GetImages().FindSymbolsWithNameAndType(name, eSymbolTypeAny, temp_sc_list);
+
+ unsigned temp_sc_list_size = temp_sc_list.GetSize();
+ for (unsigned i = 0; i < temp_sc_list_size; i++)
+ {
+ SymbolContext sym_ctx;
+ temp_sc_list.GetContextAtIndex(i, sym_ctx);
+ if (sym_ctx.symbol)
+ {
+ switch (sym_ctx.symbol->GetType())
+ {
+ case eSymbolTypeCode:
+ case eSymbolTypeResolver:
+ sc_list.Append(sym_ctx);
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
}
bool
@@ -694,7 +796,7 @@ ClangExpressionDeclMap::GetFunctionAddre
{
assert (m_parser_vars.get());
- lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
ExecutionContext &exe_ctx = m_parser_vars->m_exe_ctx;
Target *target = exe_ctx.GetTargetPtr();
// Back out in all cases where we're not fully initialized
@@ -706,7 +808,7 @@ ClangExpressionDeclMap::GetFunctionAddre
SymbolContextList sc_list;
FindCodeSymbolInContext(name, m_parser_vars->m_sym_ctx, sc_list);
-
+
if (!sc_list.GetSize())
{
// We occasionally get debug information in which a const function is reported
@@ -728,23 +830,25 @@ ClangExpressionDeclMap::GetFunctionAddre
if (!sc_list.GetSize())
return false;
-
+
SymbolContext sym_ctx;
sc_list.GetContextAtIndex(0, sym_ctx);
-
+
const Address *func_so_addr = NULL;
-
+ bool is_indirect_function = false;
+
if (sym_ctx.function)
func_so_addr = &sym_ctx.function->GetAddressRange().GetBaseAddress();
- else if (sym_ctx.symbol)
+ else if (sym_ctx.symbol) {
func_so_addr = &sym_ctx.symbol->GetAddress();
- else
+ is_indirect_function = sym_ctx.symbol->IsIndirect();
+ } else
return false;
-
+
if (!func_so_addr || !func_so_addr->IsValid())
return false;
-
- func_addr = func_so_addr->GetCallableLoadAddress (target);
+
+ func_addr = func_so_addr->GetCallableLoadAddress (target, is_indirect_function);
return true;
}
@@ -777,7 +881,11 @@ ClangExpressionDeclMap::GetSymbolAddress
case eSymbolTypeTrampoline:
symbol_load_addr = sym_address->GetCallableLoadAddress (&target);
break;
-
+
+ case eSymbolTypeResolver:
+ symbol_load_addr = sym_address->GetCallableLoadAddress (&target, true);
+ break;
+
case eSymbolTypeData:
case eSymbolTypeRuntime:
case eSymbolTypeVariable:
@@ -1011,21 +1119,38 @@ ClangExpressionDeclMap::LookupDecl (clan
{
assert (m_parser_vars.get());
- ClangExpressionVariableSP expr_var_sp (m_found_entities.GetVariable(decl));
- ClangExpressionVariableSP persistent_var_sp (m_parser_vars->m_persistent_vars->GetVariable(decl));
+ ClangExpressionVariableSP expr_var_sp (m_found_entities.GetVariable(decl, GetParserID()));
+ ClangExpressionVariableSP persistent_var_sp (m_parser_vars->m_persistent_vars->GetVariable(decl, GetParserID()));
+
+ if (isa<FunctionDecl>(decl))
+ {
+ ClangExpressionVariableSP entity_sp(m_found_entities.GetVariable(decl, GetParserID()));
+
+ if (!entity_sp)
+ return Value();
+
+ // We know m_parser_vars is valid since we searched for the variable by
+ // its NamedDecl
+
+ ClangExpressionVariable::ParserVars *parser_vars = entity_sp->GetParserVars(GetParserID());
+
+ return *parser_vars->m_lldb_value;
+ }
if (expr_var_sp)
{
flags = expr_var_sp->m_flags;
- if (!expr_var_sp->m_parser_vars.get())
+ ClangExpressionVariable::ParserVars *parser_vars = expr_var_sp->GetParserVars(GetParserID());
+
+ if (!parser_vars)
return Value();
bool is_reference = expr_var_sp->m_flags & ClangExpressionVariable::EVTypeIsReference;
- if (expr_var_sp->m_parser_vars->m_lldb_var)
+ if (parser_vars->m_lldb_var)
{
- std::auto_ptr<Value> value(GetVariableValue(expr_var_sp->m_parser_vars->m_lldb_var, NULL));
+ std::auto_ptr<Value> value(GetVariableValue(parser_vars->m_lldb_var, NULL));
if (is_reference && value.get() && value->GetValueType() == Value::eValueTypeLoadAddress)
{
@@ -1049,9 +1174,9 @@ ClangExpressionDeclMap::LookupDecl (clan
else
return Value();
}
- else if (expr_var_sp->m_parser_vars->m_lldb_sym)
+ else if (parser_vars->m_lldb_sym)
{
- const Address sym_address = expr_var_sp->m_parser_vars->m_lldb_sym->GetAddress();
+ const Address sym_address = parser_vars->m_lldb_sym->GetAddress();
if (!sym_address.IsValid())
return Value();
@@ -1417,16 +1542,18 @@ ClangExpressionDeclMap::DumpMaterialized
s.Printf("[%s]\n", member_sp->GetName().GetCString());
- if (!member_sp->m_jit_vars.get())
+ ClangExpressionVariable::JITVars *jit_vars = member_sp->GetJITVars(GetParserID());
+
+ if (!jit_vars)
return false;
extractor.Dump (&s, // stream
- member_sp->m_jit_vars->m_offset, // offset
+ jit_vars->m_offset, // offset
lldb::eFormatBytesWithASCII, // format
1, // byte size of individual entries
- member_sp->m_jit_vars->m_size, // number of entries
+ jit_vars->m_size, // number of entries
16, // entries per line
- m_material_vars->m_materialized_location + member_sp->m_jit_vars->m_offset, // address to print
+ m_material_vars->m_materialized_location + jit_vars->m_offset, // address to print
0, // bit size (bitfields only; 0 means ignore)
0); // bit alignment (bitfields only; 0 means ignore)
@@ -1451,7 +1578,7 @@ ClangExpressionDeclMap::DoMaterialize
assert (m_struct_vars.get());
- lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
if (!m_struct_vars->m_struct_laid_out)
{
@@ -1518,6 +1645,14 @@ ClangExpressionDeclMap::DoMaterialize
{
ClangExpressionVariableSP member_sp(m_struct_members.GetVariableAtIndex(member_index));
+ ClangExpressionVariable::JITVars *jit_vars = member_sp->GetJITVars(GetParserID());
+
+ if (!jit_vars)
+ {
+ err.SetErrorString("Variable being materialized doesn't have JIT state");
+ return false;
+ }
+
if (m_found_entities.ContainsVariable (member_sp))
{
if (!member_sp->GetValueObject())
@@ -1542,22 +1677,16 @@ ClangExpressionDeclMap::DoMaterialize
if (!DoMaterializeOneRegister (dematerialize,
*reg_ctx,
*reg_info,
- m_material_vars->m_materialized_location + member_sp->m_jit_vars->m_offset,
+ m_material_vars->m_materialized_location + jit_vars->m_offset,
err))
return false;
}
else
- {
- if (!member_sp->m_jit_vars.get())
- {
- err.SetErrorString("Variable being materialized doesn't have necessary state");
- return false;
- }
-
+ {
if (!DoMaterializeOneVariable (dematerialize,
sym_ctx,
member_sp,
- m_material_vars->m_materialized_location + member_sp->m_jit_vars->m_offset,
+ m_material_vars->m_materialized_location + jit_vars->m_offset,
err))
return false;
}
@@ -1581,7 +1710,7 @@ ClangExpressionDeclMap::DoMaterialize
if (!DoMaterializeOnePersistentVariable (dematerialize,
member_sp,
- m_material_vars->m_materialized_location + member_sp->m_jit_vars->m_offset,
+ m_material_vars->m_materialized_location + jit_vars->m_offset,
stack_frame_top,
stack_frame_bottom,
err))
@@ -1609,7 +1738,7 @@ ClangExpressionDeclMap::DoMaterializeOne
Error &err
)
{
- lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
if (!var_sp)
{
@@ -1811,22 +1940,91 @@ ClangExpressionDeclMap::DoMaterializeOne
return true;
}
-bool
+bool
+ClangExpressionDeclMap::CreateLiveMemoryForExpressionVariable
+(
+ Process &process,
+ ClangExpressionVariableSP &expr_var,
+ Error &err
+)
+{
+ Error allocate_error;
+ TypeFromUser type(expr_var->GetTypeFromUser());
+ const ConstString &name(expr_var->GetName());
+
+ size_t value_bit_size = ClangASTType::GetClangTypeBitWidth(type.GetASTContext(), type.GetOpaqueQualType());
+ size_t value_byte_size = value_bit_size % 8 ? ((value_bit_size + 8) / 8) : (value_bit_size / 8);
+
+ Scalar val_addr (process.AllocateMemory (value_byte_size,
+ lldb::ePermissionsReadable | lldb::ePermissionsWritable,
+ allocate_error));
+
+ if (val_addr.ULongLong() == LLDB_INVALID_ADDRESS)
+ {
+ err.SetErrorStringWithFormat ("Couldn't allocate a memory area to store %s: %s",
+ name.GetCString(),
+ allocate_error.AsCString());
+ return false;
+ }
+
+ // Put the location of the spare memory into the live data of the ValueObject.
+
+ expr_var->m_live_sp = ValueObjectConstResult::Create (m_parser_vars->m_exe_ctx.GetBestExecutionContextScope(),
+ type.GetASTContext(),
+ type.GetOpaqueQualType(),
+ name,
+ val_addr.ULongLong(),
+ eAddressTypeLoad,
+ value_byte_size);
+
+ return true;
+}
+
+bool
+ClangExpressionDeclMap::DeleteLiveMemoryForExpressionVariable
+(
+ Process &process,
+ ClangExpressionVariableSP &expr_var,
+ Error &err
+)
+{
+ const ConstString &name(expr_var->GetName());
+
+ Scalar &val_addr = expr_var->m_live_sp->GetValue().GetScalar();
+
+ Error deallocate_error = process.DeallocateMemory(val_addr.ULongLong());
+
+ if (!deallocate_error.Success())
+ {
+ err.SetErrorStringWithFormat ("Couldn't deallocate spare memory area for %s: %s",
+ name.GetCString(),
+ deallocate_error.AsCString());
+ return false;
+ }
+
+ expr_var->m_live_sp.reset();
+
+ return true;
+}
+
+bool
ClangExpressionDeclMap::DoMaterializeOneVariable
(
bool dematerialize,
const SymbolContext &sym_ctx,
ClangExpressionVariableSP &expr_var,
- lldb::addr_t addr,
+ lldb::addr_t addr,
Error &err
)
{
- lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
Process *process = m_parser_vars->m_exe_ctx.GetProcessPtr();
StackFrame *frame = m_parser_vars->m_exe_ctx.GetFramePtr();
+
+ ClangExpressionVariable::ParserVars *var_parser_vars = expr_var->GetParserVars(GetParserID());
- if (!frame || !process || !target || !m_parser_vars.get() || !expr_var->m_parser_vars.get())
+ if (!frame || !process || !target || !m_parser_vars.get() || !var_parser_vars)
{
err.SetErrorString("Necessary state for variable materialization isn't present");
return false;
@@ -1837,8 +2035,8 @@ ClangExpressionDeclMap::DoMaterializeOne
const ConstString &name(expr_var->GetName());
TypeFromUser type(expr_var->GetTypeFromUser());
- VariableSP &var(expr_var->m_parser_vars->m_lldb_var);
- const lldb_private::Symbol *symbol = expr_var->m_parser_vars->m_lldb_sym;
+ VariableSP &var(var_parser_vars->m_lldb_var);
+ const lldb_private::Symbol *symbol = var_parser_vars->m_lldb_sym;
bool is_reference(expr_var->m_flags & ClangExpressionVariable::EVTypeIsReference);
@@ -1913,6 +2111,66 @@ ClangExpressionDeclMap::DoMaterializeOne
return false;
}
break;
+ case Value::eValueTypeHostAddress:
+ {
+ if (dematerialize)
+ {
+ if (!DeleteLiveMemoryForExpressionVariable(*process, expr_var, err))
+ return false;
+ }
+ else
+ {
+ DataExtractor value_data_extractor;
+
+ if (location_value->GetData(value_data_extractor))
+ {
+ if (value_byte_size != value_data_extractor.GetByteSize())
+ {
+ err.SetErrorStringWithFormat ("Size mismatch for %s: %" PRIu64 " versus %" PRIu64,
+ name.GetCString(),
+ (uint64_t)value_data_extractor.GetByteSize(),
+ (uint64_t)value_byte_size);
+ return false;
+ }
+
+ if (!CreateLiveMemoryForExpressionVariable(*process, expr_var, err))
+ return false;
+
+ Scalar &buf_addr = expr_var->m_live_sp->GetValue().GetScalar();
+
+ Error write_error;
+
+ if (!process->WriteMemory(buf_addr.ULongLong(),
+ value_data_extractor.GetDataStart(),
+ value_data_extractor.GetByteSize(),
+ write_error))
+ {
+ err.SetErrorStringWithFormat ("Couldn't write %s to the target: %s",
+ name.GetCString(),
+ write_error.AsCString());
+ return false;
+ }
+
+ if (!process->WriteScalarToMemory(addr,
+ buf_addr,
+ process->GetAddressByteSize(),
+ write_error))
+ {
+ err.SetErrorStringWithFormat ("Couldn't write the address of %s to the target: %s",
+ name.GetCString(),
+ write_error.AsCString());
+ return false;
+ }
+ }
+ else
+ {
+ err.SetErrorStringWithFormat ("%s is marked as a host address but doesn't contain any data",
+ name.GetCString());
+ return false;
+ }
+ }
+ }
+ break;
case Value::eValueTypeLoadAddress:
{
if (!dematerialize)
@@ -1961,17 +2219,8 @@ ClangExpressionDeclMap::DoMaterializeOne
break;
case Value::eValueTypeScalar:
{
- if (location_value->GetContextType() != Value::eContextTypeRegisterInfo)
+ if (location_value->GetContextType() == Value::eContextTypeRegisterInfo)
{
- StreamString ss;
- location_value->Dump(&ss);
-
- err.SetErrorStringWithFormat ("%s is a scalar of unhandled type: %s",
- name.GetCString(),
- ss.GetString().c_str());
- return false;
- }
-
RegisterInfo *reg_info = location_value->GetRegisterInfo();
if (!reg_info)
@@ -2031,20 +2280,9 @@ ClangExpressionDeclMap::DoMaterializeOne
return false;
}
- // Deallocate the spare area and clear the variable's live data.
-
- Error deallocate_error = process->DeallocateMemory(reg_addr.ULongLong());
-
- if (!deallocate_error.Success())
- {
- err.SetErrorStringWithFormat ("Couldn't deallocate spare memory area for %s: %s",
- name.GetCString(),
- deallocate_error.AsCString());
+ if (!DeleteLiveMemoryForExpressionVariable(*process, expr_var, err))
return false;
}
-
- expr_var->m_live_sp.reset();
- }
else
{
Error write_error;
@@ -2077,36 +2315,17 @@ ClangExpressionDeclMap::DoMaterializeOne
return true;
}
-
+
// Allocate a spare memory area to place the register's contents into. This memory area will be pointed to by the slot in the
// struct.
- Error allocate_error;
-
- Scalar reg_addr (process->AllocateMemory (value_byte_size,
- lldb::ePermissionsReadable | lldb::ePermissionsWritable,
- allocate_error));
-
- if (reg_addr.ULongLong() == LLDB_INVALID_ADDRESS)
- {
- err.SetErrorStringWithFormat ("Couldn't allocate a memory area to store %s: %s",
- name.GetCString(),
- allocate_error.AsCString());
+ if (!CreateLiveMemoryForExpressionVariable (*process, expr_var, err))
return false;
- }
- // Put the location of the spare memory into the live data of the ValueObject.
+ // Now write the location of the area into the struct.
- expr_var->m_live_sp = ValueObjectConstResult::Create (m_parser_vars->m_exe_ctx.GetBestExecutionContextScope(),
- type.GetASTContext(),
- type.GetOpaqueQualType(),
- name,
- reg_addr.ULongLong(),
- eAddressTypeLoad,
- value_byte_size);
+ Scalar ®_addr = expr_var->m_live_sp->GetValue().GetScalar();
- // Now write the location of the area into the struct.
-
if (!process->WriteScalarToMemory (addr,
reg_addr,
process->GetAddressByteSize(),
@@ -2142,6 +2361,68 @@ ClangExpressionDeclMap::DoMaterializeOne
return false;
}
}
+ else
+ {
+ // The location_value is a scalar. We need to make space for it
+ // or delete the space we made previously.
+ if (dematerialize)
+ {
+ if (!DeleteLiveMemoryForExpressionVariable(*process, expr_var, err))
+ return false;
+ }
+ else
+ {
+ DataExtractor value_data_extractor;
+
+ if (location_value->GetData(value_data_extractor))
+ {
+ if (value_byte_size != value_data_extractor.GetByteSize())
+ {
+ err.SetErrorStringWithFormat ("Size mismatch for %s: %" PRIu64 " versus %" PRIu64,
+ name.GetCString(),
+ (uint64_t)value_data_extractor.GetByteSize(),
+ (uint64_t)value_byte_size);
+ return false;
+ }
+
+ if (!CreateLiveMemoryForExpressionVariable(*process, expr_var, err))
+ return false;
+
+ Scalar &buf_addr = expr_var->m_live_sp->GetValue().GetScalar();
+
+ Error write_error;
+
+ if (!process->WriteMemory(buf_addr.ULongLong(),
+ value_data_extractor.GetDataStart(),
+ value_data_extractor.GetByteSize(),
+ write_error))
+ {
+ err.SetErrorStringWithFormat ("Couldn't write %s to the target: %s",
+ name.GetCString(),
+ write_error.AsCString());
+ return false;
+ }
+
+ if (!process->WriteScalarToMemory(addr,
+ buf_addr,
+ process->GetAddressByteSize(),
+ write_error))
+ {
+ err.SetErrorStringWithFormat ("Couldn't write the address of %s to the target: %s",
+ name.GetCString(),
+ write_error.AsCString());
+ return false;
+ }
+ }
+ else
+ {
+ err.SetErrorStringWithFormat ("%s is marked as a scalar value but doesn't contain any data",
+ name.GetCString());
+ return false;
+ }
+ }
+ }
+ }
}
return true;
@@ -2203,15 +2484,19 @@ ClangExpressionDeclMap::FindVariableInSc
bool object_pointer
)
{
- lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
ValueObjectSP valobj;
VariableSP var_sp;
Error err;
- valobj = frame.GetValueForVariableExpressionPath(name.GetCString(),
+ valobj = frame.GetValueForVariableExpressionPath(name.GetCString(),
eNoDynamicValues,
- StackFrame::eExpressionPathOptionCheckPtrVsMember,
+ StackFrame::eExpressionPathOptionCheckPtrVsMember ||
+ StackFrame::eExpressionPathOptionsAllowDirectIVarAccess ||
+ StackFrame::eExpressionPathOptionsNoFragileObjcIvar ||
+ StackFrame::eExpressionPathOptionsNoSyntheticChildren ||
+ StackFrame::eExpressionPathOptionsNoSyntheticArrayRange,
var_sp,
err);
@@ -2340,6 +2625,7 @@ ClangExpressionDeclMap::FindGlobalDataSy
case eSymbolTypeCompiler:
case eSymbolTypeInstrumentation:
case eSymbolTypeUndefined:
+ case eSymbolTypeResolver:
break;
}
}
@@ -2397,9 +2683,11 @@ ClangExpressionDeclMap::FindExternalVisi
{
assert (m_ast_context);
+ ClangASTMetrics::RegisterVisibleQuery();
+
const ConstString name(context.m_decl_name.getAsString().c_str());
- lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
if (GetImportInProgress())
{
@@ -2475,7 +2763,7 @@ ClangExpressionDeclMap::FindExternalVisi
{
assert (m_ast_context);
- lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
SymbolContextList sc_list;
@@ -2527,7 +2815,6 @@ ClangExpressionDeclMap::FindExternalVisi
if (method_decl)
{
-
clang::CXXRecordDecl *class_decl = method_decl->getParent();
QualType class_qual_type(class_decl->getTypeForDecl(), 0);
@@ -2541,7 +2828,28 @@ ClangExpressionDeclMap::FindExternalVisi
log->Printf(" CEDM::FEVD[%u] Adding type for $__lldb_class: %s", current_id, ast_dumper.GetCString());
}
- AddOneType(context, class_user_type, current_id, true);
+ TypeFromParser class_type = CopyClassType(class_user_type, current_id);
+
+ if (!class_type.IsValid())
+ return;
+
+ TypeSourceInfo *type_source_info = m_ast_context->getTrivialTypeSourceInfo(QualType::getFromOpaquePtr(class_type.GetOpaqueQualType()));
+
+ if (!type_source_info)
+ return;
+
+ TypedefDecl *typedef_decl = TypedefDecl::Create(*m_ast_context,
+ m_ast_context->getTranslationUnitDecl(),
+ SourceLocation(),
+ SourceLocation(),
+ context.m_decl_name.getAsIdentifierInfo(),
+ type_source_info);
+
+
+ if (!typedef_decl)
+ return;
+
+ context.AddNamedDecl(typedef_decl);
if (method_decl->isInstance())
{
@@ -2592,7 +2900,7 @@ ClangExpressionDeclMap::FindExternalVisi
TypeFromUser class_user_type (class_type.getAsOpaquePtr(),
this_type->GetClangAST());
- AddOneType(context, class_user_type, current_id, false);
+ AddOneType(context, class_user_type, current_id);
TypeFromUser this_user_type(this_type->GetClangFullType(),
@@ -2635,7 +2943,6 @@ ClangExpressionDeclMap::FindExternalVisi
if (method_decl)
{
-
ObjCInterfaceDecl* self_interface = method_decl->getClassInterface();
if (!self_interface)
@@ -2643,6 +2950,9 @@ ClangExpressionDeclMap::FindExternalVisi
const clang::Type *interface_type = self_interface->getTypeForDecl();
+ if (!interface_type)
+ return; // This is unlikely, but we have seen crashes where this occurred
+
TypeFromUser class_user_type(QualType(interface_type, 0).getAsOpaquePtr(),
&method_decl->getASTContext());
@@ -2652,7 +2962,7 @@ ClangExpressionDeclMap::FindExternalVisi
log->Printf(" FEVD[%u] Adding type for $__lldb_objc_class: %s", current_id, ast_dumper.GetCString());
}
- AddOneType(context, class_user_type, current_id, false);
+ AddOneType(context, class_user_type, current_id);
if (method_decl->isInstanceMethod())
{
@@ -2699,10 +3009,15 @@ ClangExpressionDeclMap::FindExternalVisi
return;
QualType self_qual_type = QualType::getFromOpaquePtr(self_type->GetClangFullType());
- const ObjCObjectPointerType *class_pointer_type = self_qual_type->getAs<ObjCObjectPointerType>();
- if (class_pointer_type)
+ if (self_qual_type->isObjCClassType())
+ {
+ return;
+ }
+ else if (self_qual_type->isObjCObjectPointerType())
{
+ const ObjCObjectPointerType *class_pointer_type = self_qual_type->getAs<ObjCObjectPointerType>();
+
QualType class_type = class_pointer_type->getPointeeType();
if (log)
@@ -2713,8 +3028,8 @@ ClangExpressionDeclMap::FindExternalVisi
TypeFromUser class_user_type (class_type.getAsOpaquePtr(),
self_type->GetClangAST());
- AddOneType(context, class_user_type, current_id, false);
+ AddOneType(context, class_user_type, current_id);
TypeFromUser self_user_type(self_type->GetClangFullType(),
self_type->GetClangAST());
@@ -2801,8 +3116,11 @@ ClangExpressionDeclMap::FindExternalVisi
{
valobj = frame->GetValueForVariableExpressionPath(name_unique_cstr,
eNoDynamicValues,
- StackFrame::eExpressionPathOptionCheckPtrVsMember
- | StackFrame::eExpressionPathOptionsAllowDirectIVarAccess,
+ StackFrame::eExpressionPathOptionCheckPtrVsMember ||
+ StackFrame::eExpressionPathOptionsAllowDirectIVarAccess ||
+ StackFrame::eExpressionPathOptionsNoFragileObjcIvar ||
+ StackFrame::eExpressionPathOptionsNoSyntheticChildren ||
+ StackFrame::eExpressionPathOptionsNoSyntheticArrayRange,
var,
err);
@@ -2857,7 +3175,7 @@ ClangExpressionDeclMap::FindExternalVisi
// instance methods for eFunctionNameTypeBase.
target->GetImages().FindFunctions(name,
- eFunctionNameTypeBase,
+ eFunctionNameTypeFull,
include_symbols,
include_inlines,
append,
@@ -2981,7 +3299,7 @@ ClangExpressionDeclMap::GetVariableValue
TypeFromParser *parser_type
)
{
- lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
Type *var_type = var->GetType();
@@ -3029,7 +3347,23 @@ ClangExpressionDeclMap::GetVariableValue
}
Error err;
- if (!var_location_expr.Evaluate(&m_parser_vars->m_exe_ctx, ast, NULL, NULL, NULL, loclist_base_load_addr, NULL, *var_location.get(), &err))
+ if (var->GetLocationIsConstantValueData())
+ {
+ DataExtractor const_value_extractor;
+
+ if (var_location_expr.GetExpressionData(const_value_extractor))
+ {
+ var_location->operator=(Value(const_value_extractor.GetDataStart(), const_value_extractor.GetByteSize()));
+ var_location->SetValueType(Value::eValueTypeHostAddress);
+ }
+ else
+ {
+ if (log)
+ log->Printf("Error evaluating constant variable: %s", err.AsCString());
+ return NULL;
+ }
+ }
+ else if (!var_location_expr.Evaluate(&m_parser_vars->m_exe_ctx, ast, NULL, NULL, NULL, loclist_base_load_addr, NULL, *var_location.get(), &err))
{
if (log)
log->Printf("Error evaluating location: %s", err.AsCString());
@@ -3094,7 +3428,7 @@ ClangExpressionDeclMap::AddOneVariable (
{
assert (m_parser_vars.get());
- lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
TypeFromUser ut;
TypeFromParser pt;
@@ -3132,12 +3466,13 @@ ClangExpressionDeclMap::AddOneVariable (
ClangExpressionVariableSP entity(m_found_entities.CreateVariable (valobj));
assert (entity.get());
- entity->EnableParserVars();
- entity->m_parser_vars->m_parser_type = pt;
- entity->m_parser_vars->m_named_decl = var_decl;
- entity->m_parser_vars->m_llvm_value = NULL;
- entity->m_parser_vars->m_lldb_value = var_location;
- entity->m_parser_vars->m_lldb_var = var;
+ entity->EnableParserVars(GetParserID());
+ ClangExpressionVariable::ParserVars *parser_vars = entity->GetParserVars(GetParserID());
+ parser_vars->m_parser_type = pt;
+ parser_vars->m_named_decl = var_decl;
+ parser_vars->m_llvm_value = NULL;
+ parser_vars->m_lldb_value = var_location;
+ parser_vars->m_lldb_var = var;
if (is_reference)
entity->m_flags |= ClangExpressionVariable::EVTypeIsReference;
@@ -3155,7 +3490,7 @@ ClangExpressionDeclMap::AddOneVariable(N
ClangExpressionVariableSP &pvar_sp,
unsigned int current_id)
{
- lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
TypeFromUser user_type (pvar_sp->GetTypeFromUser());
@@ -3173,11 +3508,12 @@ ClangExpressionDeclMap::AddOneVariable(N
NamedDecl *var_decl = context.AddVarDecl(ClangASTContext::CreateLValueReferenceType(parser_type.GetASTContext(), parser_type.GetOpaqueQualType()));
- pvar_sp->EnableParserVars();
- pvar_sp->m_parser_vars->m_parser_type = parser_type;
- pvar_sp->m_parser_vars->m_named_decl = var_decl;
- pvar_sp->m_parser_vars->m_llvm_value = NULL;
- pvar_sp->m_parser_vars->m_lldb_value = NULL;
+ pvar_sp->EnableParserVars(GetParserID());
+ ClangExpressionVariable::ParserVars *parser_vars = pvar_sp->GetParserVars(GetParserID());
+ parser_vars->m_parser_type = parser_type;
+ parser_vars->m_named_decl = var_decl;
+ parser_vars->m_llvm_value = NULL;
+ parser_vars->m_lldb_value = NULL;
if (log)
{
@@ -3193,7 +3529,7 @@ ClangExpressionDeclMap::AddOneGenericVar
{
assert(m_parser_vars.get());
- lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
@@ -3228,12 +3564,13 @@ ClangExpressionDeclMap::AddOneGenericVar
symbol_location->GetScalar() = symbol_load_addr;
symbol_location->SetValueType(Value::eValueTypeLoadAddress);
- entity->EnableParserVars();
- entity->m_parser_vars->m_parser_type = parser_type;
- entity->m_parser_vars->m_named_decl = var_decl;
- entity->m_parser_vars->m_llvm_value = NULL;
- entity->m_parser_vars->m_lldb_value = symbol_location.release();
- entity->m_parser_vars->m_lldb_sym = &symbol;
+ entity->EnableParserVars(GetParserID());
+ ClangExpressionVariable::ParserVars *parser_vars = entity->GetParserVars(GetParserID());
+ parser_vars->m_parser_type = parser_type;
+ parser_vars->m_named_decl = var_decl;
+ parser_vars->m_llvm_value = NULL;
+ parser_vars->m_lldb_value = symbol_location.release();
+ parser_vars->m_lldb_sym = &symbol;
if (log)
{
@@ -3246,7 +3583,7 @@ ClangExpressionDeclMap::AddOneGenericVar
bool
ClangExpressionDeclMap::ResolveUnknownTypes()
{
- lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
ASTContext *scratch_ast_context = target->GetScratchClangASTContext()->getASTContext();
@@ -3257,9 +3594,11 @@ ClangExpressionDeclMap::ResolveUnknownTy
{
ClangExpressionVariableSP entity = m_found_entities.GetVariableAtIndex(index);
+ ClangExpressionVariable::ParserVars *parser_vars = entity->GetParserVars(GetParserID());
+
if (entity->m_flags & ClangExpressionVariable::EVUnknownType)
{
- const NamedDecl *named_decl = entity->m_parser_vars->m_named_decl;
+ const NamedDecl *named_decl = parser_vars->m_named_decl;
const VarDecl *var_decl = dyn_cast<VarDecl>(named_decl);
if (!var_decl)
@@ -3290,8 +3629,8 @@ ClangExpressionDeclMap::ResolveUnknownTy
TypeFromUser user_type(copied_type, scratch_ast_context);
- entity->m_parser_vars->m_lldb_value->SetContext(Value::eContextTypeClangType, user_type.GetOpaqueQualType());
- entity->m_parser_vars->m_parser_type = parser_type;
+ parser_vars->m_lldb_value->SetContext(Value::eContextTypeClangType, user_type.GetOpaqueQualType());
+ parser_vars->m_parser_type = parser_type;
entity->SetClangAST(user_type.GetASTContext());
entity->SetClangType(user_type.GetOpaqueQualType());
@@ -3308,7 +3647,7 @@ ClangExpressionDeclMap::AddOneRegister (
const RegisterInfo *reg_info,
unsigned int current_id)
{
- lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
void *ast_type = ClangASTContext::GetBuiltinTypeForEncodingAndBitSize(m_ast_context,
reg_info->encoding,
@@ -3330,14 +3669,16 @@ ClangExpressionDeclMap::AddOneRegister (
m_parser_vars->m_target_info.byte_order,
m_parser_vars->m_target_info.address_byte_size));
assert (entity.get());
+
std::string decl_name(context.m_decl_name.getAsString());
entity->SetName (ConstString (decl_name.c_str()));
entity->SetRegisterInfo (reg_info);
- entity->EnableParserVars();
- entity->m_parser_vars->m_parser_type = parser_type;
- entity->m_parser_vars->m_named_decl = var_decl;
- entity->m_parser_vars->m_llvm_value = NULL;
- entity->m_parser_vars->m_lldb_value = NULL;
+ entity->EnableParserVars(GetParserID());
+ ClangExpressionVariable::ParserVars *parser_vars = entity->GetParserVars(GetParserID());
+ parser_vars->m_parser_type = parser_type;
+ parser_vars->m_named_decl = var_decl;
+ parser_vars->m_llvm_value = NULL;
+ parser_vars->m_lldb_value = NULL;
entity->m_flags |= ClangExpressionVariable::EVBareRegister;
if (log)
@@ -3355,7 +3696,7 @@ ClangExpressionDeclMap::AddOneFunction (
{
assert (m_parser_vars.get());
- lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
NamedDecl *fun_decl = NULL;
std::auto_ptr<Value> fun_location(new Value);
@@ -3364,7 +3705,9 @@ ClangExpressionDeclMap::AddOneFunction (
// only valid for Functions, not for Symbols
void *fun_opaque_type = NULL;
ASTContext *fun_ast_context = NULL;
-
+
+ bool is_indirect_function = false;
+
if (fun)
{
Type *fun_type = fun->GetType();
@@ -3410,6 +3753,7 @@ ClangExpressionDeclMap::AddOneFunction (
{
fun_address = &symbol->GetAddress();
fun_decl = context.AddGenericFunDecl();
+ is_indirect_function = symbol->IsIndirect();
}
else
{
@@ -3420,9 +3764,22 @@ ClangExpressionDeclMap::AddOneFunction (
Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
- lldb::addr_t load_addr = fun_address->GetCallableLoadAddress(target);
+ lldb::addr_t load_addr = fun_address->GetCallableLoadAddress(target, is_indirect_function);
+
+ if (load_addr != LLDB_INVALID_ADDRESS)
+ {
fun_location->SetValueType(Value::eValueTypeLoadAddress);
fun_location->GetScalar() = load_addr;
+ }
+ else
+ {
+ // We have to try finding a file address.
+
+ lldb::addr_t file_addr = fun_address->GetFileAddress();
+
+ fun_location->SetValueType(Value::eValueTypeFileAddress);
+ fun_location->GetScalar() = file_addr;
+ }
ClangExpressionVariableSP entity(m_found_entities.CreateVariable (m_parser_vars->m_exe_ctx.GetBestExecutionContextScope (),
m_parser_vars->m_target_info.byte_order,
@@ -3433,10 +3790,11 @@ ClangExpressionDeclMap::AddOneFunction (
entity->SetClangType (fun_opaque_type);
entity->SetClangAST (fun_ast_context);
- entity->EnableParserVars();
- entity->m_parser_vars->m_named_decl = fun_decl;
- entity->m_parser_vars->m_llvm_value = NULL;
- entity->m_parser_vars->m_lldb_value = fun_location.release();
+ entity->EnableParserVars(GetParserID());
+ ClangExpressionVariable::ParserVars *parser_vars = entity->GetParserVars(GetParserID());
+ parser_vars->m_named_decl = fun_decl;
+ parser_vars->m_llvm_value = NULL;
+ parser_vars->m_lldb_value = fun_location.release();
if (log)
{
@@ -3455,28 +3813,26 @@ ClangExpressionDeclMap::AddOneFunction (
}
}
-void
-ClangExpressionDeclMap::AddOneType(NameSearchContext &context,
- TypeFromUser &ut,
- unsigned int current_id,
- bool add_method)
+TypeFromParser
+ClangExpressionDeclMap::CopyClassType(TypeFromUser &ut,
+ unsigned int current_id)
{
ASTContext *parser_ast_context = m_ast_context;
ASTContext *user_ast_context = ut.GetASTContext();
-
+
void *copied_type = GuardedCopyType(parser_ast_context, user_ast_context, ut.GetOpaqueQualType());
if (!copied_type)
{
- lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+
if (log)
- log->Printf("ClangExpressionDeclMap::AddOneType - Couldn't import the type");
+ log->Printf("ClangExpressionDeclMap::CopyClassType - Couldn't import the type");
- return;
+ return TypeFromParser();
}
-
- if (add_method && ClangASTContext::IsAggregateType(copied_type) && ClangASTContext::GetCompleteType (parser_ast_context, copied_type))
+
+ if (ClangASTContext::IsAggregateType(copied_type) && ClangASTContext::GetCompleteType (parser_ast_context, copied_type))
{
void *args[1];
@@ -3509,5 +3865,28 @@ ClangExpressionDeclMap::AddOneType(NameS
is_artificial);
}
+ return TypeFromParser(copied_type, parser_ast_context);
+}
+
+void
+ClangExpressionDeclMap::AddOneType(NameSearchContext &context,
+ TypeFromUser &ut,
+ unsigned int current_id)
+{
+ ASTContext *parser_ast_context = m_ast_context;
+ ASTContext *user_ast_context = ut.GetASTContext();
+
+ void *copied_type = GuardedCopyType(parser_ast_context, user_ast_context, ut.GetOpaqueQualType());
+
+ if (!copied_type)
+ {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+
+ if (log)
+ log->Printf("ClangExpressionDeclMap::AddOneType - Couldn't import the type");
+
+ return;
+ }
+
context.AddTypeDecl(copied_type);
}
Modified: lldb/branches/windows/source/Expression/ClangExpressionParser.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Expression/ClangExpressionParser.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Expression/ClangExpressionParser.cpp (original)
+++ lldb/branches/windows/source/Expression/ClangExpressionParser.cpp Wed Apr 17 03:38:48 2013
@@ -20,8 +20,8 @@
#include "lldb/Expression/ClangASTSource.h"
#include "lldb/Expression/ClangExpression.h"
#include "lldb/Expression/ClangExpressionDeclMap.h"
+#include "lldb/Expression/IRExecutionUnit.h"
#include "lldb/Expression/IRDynamicChecks.h"
-#include "lldb/Expression/RecordingMemoryManager.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Process.h"
@@ -189,8 +189,7 @@ ClangExpressionParser::ClangExpressionPa
ClangExpression &expr) :
m_expr (expr),
m_compiler (),
- m_code_generator (NULL),
- m_jitted_functions ()
+ m_code_generator (NULL)
{
// Initialize targets first, so that --version shows registered targets.
static struct InitializeLLVM {
@@ -241,10 +240,17 @@ ClangExpressionParser::ClangExpressionPa
m_compiler->getTargetOpts().Triple = llvm::sys::getDefaultTargetTriple();
}
+ if (target_sp->GetArchitecture().GetMachine() == llvm::Triple::x86 ||
+ target_sp->GetArchitecture().GetMachine() == llvm::Triple::x86_64)
+ {
+ m_compiler->getTargetOpts().Features.push_back("+sse");
+ m_compiler->getTargetOpts().Features.push_back("+sse2");
+ }
+
if (m_compiler->getTargetOpts().Triple.find("ios") != std::string::npos)
m_compiler->getTargetOpts().ABI = "apcs-gnu";
- m_compiler->createDiagnostics(0, 0);
+ m_compiler->createDiagnostics();
// Create the target instance.
m_compiler->setTarget(TargetInfo::CreateTargetInfo(m_compiler->getDiagnostics(),
@@ -279,6 +285,7 @@ ClangExpressionParser::ClangExpressionPa
m_compiler->getLangOpts().Bool = true;
m_compiler->getLangOpts().WChar = true;
+ m_compiler->getLangOpts().Blocks = true;
m_compiler->getLangOpts().DebuggerSupport = true; // Features specifically for debugger clients
if (expr.DesiredResultType() == ClangExpression::eResultTypeId)
m_compiler->getLangOpts().DebuggerCastResultToId = true;
@@ -317,7 +324,8 @@ ClangExpressionParser::ClangExpressionPa
m_compiler->getCodeGenOpts().InstrumentFunctions = false;
// Disable some warnings.
- m_compiler->getDiagnosticOpts().Warnings.push_back("no-unused-value");
+ m_compiler->getDiagnostics().setDiagnosticGroupMapping("unused-value", clang::diag::MAP_IGNORE, SourceLocation());
+ m_compiler->getDiagnostics().setDiagnosticGroupMapping("odr", clang::diag::MAP_IGNORE, SourceLocation());
// Inform the target of the language options
//
@@ -370,6 +378,7 @@ ClangExpressionParser::ClangExpressionPa
m_code_generator.reset(CreateLLVMCodeGen(m_compiler->getDiagnostics(),
module_name,
m_compiler->getCodeGenOpts(),
+ m_compiler->getTargetOpts(),
*m_llvm_context));
}
@@ -434,7 +443,7 @@ ClangExpressionParser::Parse (Stream &st
return num_errors;
}
-static bool FindFunctionInModule (std::string &mangled_name,
+static bool FindFunctionInModule (ConstString &mangled_name,
llvm::Module *module,
const char *orig_name)
{
@@ -444,7 +453,7 @@ static bool FindFunctionInModule (std::s
{
if (fi->getName().str().find(orig_name) != std::string::npos)
{
- mangled_name = fi->getName().str();
+ mangled_name.SetCString(fi->getName().str().c_str());
return true;
}
}
@@ -453,19 +462,17 @@ static bool FindFunctionInModule (std::s
}
Error
-ClangExpressionParser::PrepareForExecution (lldb::addr_t &func_allocation_addr,
- lldb::addr_t &func_addr,
- lldb::addr_t &func_end,
+ClangExpressionParser::PrepareForExecution (lldb::addr_t &func_addr,
+ lldb::addr_t &func_end,
+ std::auto_ptr<IRExecutionUnit> &execution_unit_ap,
ExecutionContext &exe_ctx,
- IRForTarget::StaticDataAllocator *data_allocator,
bool &evaluated_statically,
lldb::ClangExpressionVariableSP &const_result,
ExecutionPolicy execution_policy)
{
- func_allocation_addr = LLDB_INVALID_ADDRESS;
func_addr = LLDB_INVALID_ADDRESS;
func_end = LLDB_INVALID_ADDRESS;
- lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
std::auto_ptr<llvm::ExecutionEngine> execution_engine_ap;
@@ -482,7 +489,7 @@ ClangExpressionParser::PrepareForExecuti
// Find the actual name of the function (it's often mangled somehow)
- std::string function_name;
+ ConstString function_name;
if (!FindFunctionInModule(function_name, module_ap.get(), m_expr.FunctionName()))
{
@@ -493,9 +500,14 @@ ClangExpressionParser::PrepareForExecuti
else
{
if (log)
- log->Printf("Found function %s for %s", function_name.c_str(), m_expr.FunctionName());
+ log->Printf("Found function %s for %s", function_name.AsCString(), m_expr.FunctionName());
}
+ m_execution_unit.reset(new IRExecutionUnit(module_ap, // handed off here
+ function_name,
+ exe_ctx.GetTargetSP(),
+ m_compiler->getTargetOpts().Features));
+
ClangExpressionDeclMap *decl_map = m_expr.DeclMap(); // result can be NULL
if (decl_map)
@@ -509,11 +521,11 @@ ClangExpressionParser::PrepareForExecuti
m_expr.NeedsVariableResolution(),
execution_policy,
const_result,
- data_allocator,
+ *m_execution_unit,
error_stream,
- function_name.c_str());
+ function_name.AsCString());
- bool ir_can_run = ir_for_target.runOnModule(*module_ap);
+ bool ir_can_run = ir_for_target.runOnModule(*m_execution_unit->GetModule());
Error &interpreter_error(ir_for_target.getInterpreterError());
@@ -572,9 +584,9 @@ ClangExpressionParser::PrepareForExecuti
log->Printf("== [ClangUserExpression::Evaluate] Finished installing dynamic checkers ==");
}
- IRDynamicChecks ir_dynamic_checks(*process->GetDynamicCheckers(), function_name.c_str());
+ IRDynamicChecks ir_dynamic_checks(*process->GetDynamicCheckers(), function_name.AsCString());
- if (!ir_dynamic_checks.runOnModule(*module_ap))
+ if (!ir_dynamic_checks.runOnModule(*m_execution_unit->GetModule()))
{
err.SetErrorToGenericError();
err.SetErrorString("Couldn't add dynamic checks to the expression");
@@ -583,246 +595,9 @@ ClangExpressionParser::PrepareForExecuti
}
}
- // llvm will own this pointer when llvm::ExecutionEngine::createJIT is called
- // below so we don't need to free it.
- RecordingMemoryManager *jit_memory_manager = new RecordingMemoryManager();
-
- std::string error_string;
-
- if (log)
- {
- std::string s;
- raw_string_ostream oss(s);
-
- module_ap->print(oss, NULL);
-
- oss.flush();
-
- log->Printf ("Module being sent to JIT: \n%s", s.c_str());
- }
- llvm::Triple triple(module_ap->getTargetTriple());
- llvm::Function *function = module_ap->getFunction (function_name.c_str());
- EngineBuilder builder(module_ap.release());
- builder.setEngineKind(EngineKind::JIT)
- .setErrorStr(&error_string)
- .setRelocationModel(llvm::Reloc::PIC_)
- .setJITMemoryManager(jit_memory_manager)
- .setOptLevel(CodeGenOpt::Less)
- .setAllocateGVsWithCode(true)
- .setCodeModel(CodeModel::Small)
- .setUseMCJIT(true);
-
- StringRef mArch;
- StringRef mCPU;
- SmallVector<std::string, 0> mAttrs;
-
- TargetMachine *target_machine = builder.selectTarget(triple,
- mArch,
- mCPU,
- mAttrs);
+ m_execution_unit->GetRunnableInfo(err, func_addr, func_end);
- execution_engine_ap.reset(builder.create(target_machine));
+ execution_unit_ap = m_execution_unit;
- if (!execution_engine_ap.get())
- {
- err.SetErrorToGenericError();
- err.SetErrorStringWithFormat("Couldn't JIT the function: %s", error_string.c_str());
- return err;
- }
-
- execution_engine_ap->DisableLazyCompilation();
-
-
- // We don't actually need the function pointer here, this just forces it to get resolved.
-
- void *fun_ptr = execution_engine_ap->getPointerToFunction(function);
-
- // Errors usually cause failures in the JIT, but if we're lucky we get here.
-
- if (!function)
- {
- err.SetErrorToGenericError();
- err.SetErrorStringWithFormat("Couldn't find '%s' in the JITted module", function_name.c_str());
- return err;
- }
-
- if (!fun_ptr)
- {
- err.SetErrorToGenericError();
- err.SetErrorStringWithFormat("'%s' was in the JITted module but wasn't lowered", function_name.c_str());
- return err;
- }
-
- m_jitted_functions.push_back (ClangExpressionParser::JittedFunction(function_name.c_str(), (lldb::addr_t)fun_ptr));
-
-
- Process *process = exe_ctx.GetProcessPtr();
- if (process == NULL)
- {
- err.SetErrorToGenericError();
- err.SetErrorString("Couldn't write the JIT compiled code into the target because there is no target");
return err;
- }
-
- jit_memory_manager->CommitAllocations(*process);
- jit_memory_manager->ReportAllocations(*execution_engine_ap);
- jit_memory_manager->WriteData(*process);
-
- std::vector<JittedFunction>::iterator pos, end = m_jitted_functions.end();
-
- for (pos = m_jitted_functions.begin(); pos != end; pos++)
- {
- (*pos).m_remote_addr = jit_memory_manager->GetRemoteAddressForLocal ((*pos).m_local_addr);
-
- if (!(*pos).m_name.compare(function_name.c_str()))
- {
- RecordingMemoryManager::AddrRange func_range = jit_memory_manager->GetRemoteRangeForLocal((*pos).m_local_addr);
- func_end = func_range.first + func_range.second;
- func_addr = (*pos).m_remote_addr;
- }
- }
-
- if (log)
- {
- log->Printf("Code can be run in the target.");
-
- StreamString disassembly_stream;
-
- Error err = DisassembleFunction(disassembly_stream, exe_ctx, jit_memory_manager);
-
- if (!err.Success())
- {
- log->Printf("Couldn't disassemble function : %s", err.AsCString("unknown error"));
- }
- else
- {
- log->Printf("Function disassembly:\n%s", disassembly_stream.GetData());
- }
- }
-
- err.Clear();
- return err;
-}
-
-Error
-ClangExpressionParser::DisassembleFunction (Stream &stream, ExecutionContext &exe_ctx, RecordingMemoryManager *jit_memory_manager)
-{
- lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-
- const char *name = m_expr.FunctionName();
-
- Error ret;
-
- ret.Clear();
-
- lldb::addr_t func_local_addr = LLDB_INVALID_ADDRESS;
- lldb::addr_t func_remote_addr = LLDB_INVALID_ADDRESS;
-
- std::vector<JittedFunction>::iterator pos, end = m_jitted_functions.end();
-
- for (pos = m_jitted_functions.begin(); pos < end; pos++)
- {
- if (strstr(pos->m_name.c_str(), name))
- {
- func_local_addr = pos->m_local_addr;
- func_remote_addr = pos->m_remote_addr;
- }
- }
-
- if (func_local_addr == LLDB_INVALID_ADDRESS)
- {
- ret.SetErrorToGenericError();
- ret.SetErrorStringWithFormat("Couldn't find function %s for disassembly", name);
- return ret;
- }
-
- if (log)
- log->Printf("Found function, has local address 0x%" PRIx64 " and remote address 0x%" PRIx64, (uint64_t)func_local_addr, (uint64_t)func_remote_addr);
-
- std::pair <lldb::addr_t, lldb::addr_t> func_range;
-
- func_range = jit_memory_manager->GetRemoteRangeForLocal(func_local_addr);
-
- if (func_range.first == 0 && func_range.second == 0)
- {
- ret.SetErrorToGenericError();
- ret.SetErrorStringWithFormat("Couldn't find code range for function %s", name);
- return ret;
- }
-
- if (log)
- log->Printf("Function's code range is [0x%" PRIx64 "+0x%" PRIx64 "]", func_range.first, func_range.second);
-
- Target *target = exe_ctx.GetTargetPtr();
- if (!target)
- {
- ret.SetErrorToGenericError();
- ret.SetErrorString("Couldn't find the target");
- return ret;
- }
-
- lldb::DataBufferSP buffer_sp(new DataBufferHeap(func_range.second, 0));
-
- Process *process = exe_ctx.GetProcessPtr();
- Error err;
- process->ReadMemory(func_remote_addr, buffer_sp->GetBytes(), buffer_sp->GetByteSize(), err);
-
- if (!err.Success())
- {
- ret.SetErrorToGenericError();
- ret.SetErrorStringWithFormat("Couldn't read from process: %s", err.AsCString("unknown error"));
- return ret;
- }
-
- ArchSpec arch(target->GetArchitecture());
-
- lldb::DisassemblerSP disassembler = Disassembler::FindPlugin(arch, NULL);
-
- if (!disassembler)
- {
- ret.SetErrorToGenericError();
- ret.SetErrorStringWithFormat("Unable to find disassembler plug-in for %s architecture.", arch.GetArchitectureName());
- return ret;
- }
-
- if (!process)
- {
- ret.SetErrorToGenericError();
- ret.SetErrorString("Couldn't find the process");
- return ret;
- }
-
- DataExtractor extractor(buffer_sp,
- process->GetByteOrder(),
- target->GetArchitecture().GetAddressByteSize());
-
- if (log)
- {
- log->Printf("Function data has contents:");
- extractor.PutToLog (log.get(),
- 0,
- extractor.GetByteSize(),
- func_remote_addr,
- 16,
- DataExtractor::TypeUInt8);
- }
-
- disassembler->DecodeInstructions (Address (func_remote_addr), extractor, 0, UINT32_MAX, false);
-
- InstructionList &instruction_list = disassembler->GetInstructionList();
- const uint32_t max_opcode_byte_size = instruction_list.GetMaxOpcocdeByteSize();
- for (uint32_t instruction_index = 0, num_instructions = instruction_list.GetSize();
- instruction_index < num_instructions;
- ++instruction_index)
- {
- Instruction *instruction = instruction_list.GetInstructionAtIndex(instruction_index).get();
- instruction->Dump (&stream,
- max_opcode_byte_size,
- true,
- true,
- &exe_ctx);
- stream.PutChar('\n');
- }
-
- return ret;
}
Modified: lldb/branches/windows/source/Expression/ClangFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Expression/ClangFunction.cpp?rev=179679&r1=179678&r2=179679&view=diff
==============================================================================
--- lldb/branches/windows/source/Expression/ClangFunction.cpp (original)
+++ lldb/branches/windows/source/Expression/ClangFunction.cpp Wed Apr 17 03:38:48 2013
@@ -136,7 +136,7 @@ ClangFunction::CompileFunction (Stream &
// to pull the defined arguments out of the function, then add the types from the
// arguments list for the variable arguments.
- uint32_t num_args = UINT32_MAX;
+ size_t num_args = UINT32_MAX;
bool trust_function = false;
// GetArgumentCount returns -1 for an unprototyped function.
if (m_function_ptr)
@@ -214,7 +214,7 @@ ClangFunction::CompileFunction (Stream &
m_wrapper_function_text.append (args_list_buffer);
m_wrapper_function_text.append (");\n}\n");
- lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
if (log)
log->Printf ("Expression: \n\n%s\n\n", m_wrapper_function_text.c_str());
@@ -264,19 +264,21 @@ ClangFunction::WriteFunctionWrapper (Exe
bool evaluated_statically = false; // should stay that way
- Error jit_error (m_parser->PrepareForExecution (m_jit_alloc,
- m_jit_start_addr,
+ Error jit_error (m_parser->PrepareForExecution (m_jit_start_addr,
m_jit_end_addr,
+ m_execution_unit_ap,
exe_ctx,
- NULL,
evaluated_statically,
const_result,
eExecutionPolicyAlways));
if (!jit_error.Success())
return false;
- if (process && m_jit_alloc != LLDB_INVALID_ADDRESS)
+
+ if (process && m_jit_start_addr)
m_jit_process_wp = lldb::ProcessWP(process->shared_from_this());
+
+ m_JITted = true;
return true;
}
@@ -336,7 +338,7 @@ ClangFunction::WriteFunctionArguments (E
// TODO: verify fun_addr needs to be a callable address
Scalar fun_addr (function_address.GetCallableLoadAddress(exe_ctx.GetTargetPtr()));
- int first_offset = m_member_offsets[0];
+ uint64_t first_offset = m_member_offsets[0];
process->WriteScalarToMemory(args_addr_ref + first_offset, fun_addr, process->GetAddressByteSize(), error);
// FIXME: We will need to extend this for Variadic functions.
@@ -354,7 +356,7 @@ ClangFunction::WriteFunctionArguments (E
{
// FIXME: We should sanity check sizes.
- int offset = m_member_offsets[i+1]; // Clang sizes are in bytes.
+ uint64_t offset = m_member_offsets[i+1]; // Clang sizes are in bytes.
Value *arg_value = arg_values.GetValueAtIndex(i);
// FIXME: For now just do scalars:
@@ -387,7 +389,7 @@ ClangFunction::InsertFunction (Execution
if (!WriteFunctionArguments(exe_ctx, args_addr_ref, errors))
return false;
- lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
if (log)
log->Printf ("Call Address: 0x%" PRIx64 " Struct Address: 0x%" PRIx64 ".\n", m_jit_start_addr, args_addr_ref);
@@ -400,10 +402,16 @@ ClangFunction::GetThreadPlanToCallFuncti
lldb::addr_t &args_addr,
Stream &errors,
bool stop_others,
- bool discard_on_error,
+ bool unwind_on_error,
+ bool ignore_breakpoints,
lldb::addr_t *this_arg,
lldb::addr_t *cmd_arg)
{
+ Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_EXPRESSIONS | LIBLLDB_LOG_STEP));
+
+ if (log)
+ log->Printf("-- [ClangFunction::GetThreadPlanToCallFunction] Creating thread plan to call function --");
+
// FIXME: Use the errors Stream for better error reporting.
Thread *thread = exe_ctx.GetThreadPtr();
if (thread == NULL)
@@ -420,7 +428,8 @@ ClangFunction::GetThreadPlanToCallFuncti
ClangASTType(),
args_addr,
stop_others,
- discard_on_error,
+ unwind_on_error,
+ ignore_breakpoints,
this_arg,
cmd_arg);
new_plan->SetIsMasterPlan(true);
@@ -435,6 +444,12 @@ ClangFunction::FetchFunctionResults (Exe
// FIXME: How does clang tell us there's no return value? We need to handle that case.
// FIXME: Create our ThreadPlanCallFunction with the return ClangASTType, and then use GetReturnValueObject
// to fetch the value. That way we can fetch any values we need.
+
+ Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_EXPRESSIONS | LIBLLDB_LOG_STEP));
+
+ if (log)
+ log->Printf("-- [ClangFunction::FetchFunctionResults] Fetching function results --");
+
Process *process = exe_ctx.GetProcessPtr();
if (process == NULL)
@@ -477,8 +492,10 @@ ExecutionResults
ClangFunction::ExecuteFunction(ExecutionContext &exe_ctx, Stream &errors, bool stop_others, Value &results)
{
const bool try_all_threads = false;
- const bool discard_on_error = true;
- return ExecuteFunction (exe_ctx, NULL, errors, stop_others, 0UL, try_all_threads, discard_on_error, results);
+ const bool unwind_on_error = true;
+ const bool ignore_breakpoints = true;
+ return ExecuteFunction (exe_ctx, NULL, errors, stop_others, 0UL, try_all_threads,
+ unwind_on_error, ignore_breakpoints, results);
}
ExecutionResults
@@ -490,9 +507,10 @@ ClangFunction::ExecuteFunction(
Value &results)
{
const bool stop_others = true;
- const bool discard_on_error = true;
+ const bool unwind_on_error = true;
+ const bool ignore_breakpoints = true;
return ExecuteFunction (exe_ctx, NULL, errors, stop_others, timeout_usec,
- try_all_threads, discard_on_error, results);
+ try_all_threads, unwind_on_error, ignore_breakpoints, results);
}
// This is the static function
@@ -503,17 +521,24 @@ ClangFunction::ExecuteFunction (
lldb::addr_t &void_arg,
bool stop_others,
bool try_all_threads,
- bool discard_on_error,
+ bool unwind_on_error,
+ bool ignore_breakpoints,
uint32_t timeout_usec,
Stream &errors,
lldb::addr_t *this_arg)
{
- lldb::ThreadPlanSP call_plan_sp (ClangFunction::GetThreadPlanToCallFunction (exe_ctx,
+ Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_EXPRESSIONS | LIBLLDB_LOG_STEP));
+
+ if (log)
+ log->Printf("== [ClangFunction::ExecuteFunction] Executing function ==");
+
+ lldb::ThreadPlanSP call_plan_sp (ClangFunction::GetThreadPlanToCallFunction (exe_ctx,
function_address,
void_arg,
errors,
stop_others,
- discard_on_error,
+ unwind_on_error,
+ ignore_breakpoints,
this_arg));
if (!call_plan_sp)
return eExecutionSetupError;
@@ -526,10 +551,23 @@ ClangFunction::ExecuteFunction (
ExecutionResults results = exe_ctx.GetProcessRef().RunThreadPlan (exe_ctx, call_plan_sp,
stop_others,
try_all_threads,
- discard_on_error,
+ unwind_on_error,
+ ignore_breakpoints,
timeout_usec,
errors);
+ if (log)
+ {
+ if (results != eExecutionCompleted)
+ {
+ log->Printf("== [ClangFunction::ExecuteFunction] Execution completed abnormally ==");
+ }
+ else
+ {
+ log->Printf("== [ClangFunction::ExecuteFunction] Execution completed normally ==");
+ }
+ }
+
if (exe_ctx.GetProcessPtr())
exe_ctx.GetProcessPtr()->SetRunningUserExpression(false);
@@ -544,7 +582,8 @@ ClangFunction::ExecuteFunction(
bool stop_others,
uint32_t timeout_usec,
bool try_all_threads,
- bool discard_on_error,
+ bool unwind_on_error,
+ bool ignore_breakpoints,
Value &results)
{
using namespace clang;
@@ -571,7 +610,8 @@ ClangFunction::ExecuteFunction(
args_addr,
stop_others,
try_all_threads,
- discard_on_error,
+ unwind_on_error,
+ ignore_breakpoints,
timeout_usec,
errors);
More information about the llvm-branch-commits
mailing list