Update LLDB snapshot to upstream r225923 (git 2b588ecd)

Sponsored by:	DARPA, AFRL
This commit is contained in:
emaste 2015-02-06 22:25:21 +00:00
commit fa0e7b4169
665 changed files with 59047 additions and 34895 deletions

View File

@ -1,7 +1,7 @@
.Dd June 7, 2012 \" DATE
.Dt LLDB 1 \" Program name and manual section number
.Os Darwin \" Operating System
.Sh NAME \" Section Header - required - don't modify
.Sh NAME \" Section Header - required - don't modify
.Nm lldb
.Nd The debugger
.Sh SYNOPSIS \" Section Header - required - don't modify

View File

@ -29,6 +29,7 @@
#include "lldb/API/SBDeclaration.h"
#include "lldb/API/SBError.h"
#include "lldb/API/SBEvent.h"
#include "lldb/API/SBExecutionContext.h"
#include "lldb/API/SBFileSpec.h"
#include "lldb/API/SBFrame.h"
#include "lldb/API/SBFunction.h"

View File

@ -117,6 +117,7 @@ class SBAddress
friend class SBSymbolContext;
friend class SBTarget;
friend class SBThread;
friend class SBThreadPlan;
friend class SBValue;
friend class SBQueueItem;

View File

@ -123,6 +123,18 @@ class SBBreakpoint
SBError
SetScriptCallbackBody (const char *script_body_text);
bool
AddName (const char *new_name);
void
RemoveName (const char *name_to_remove);
bool
MatchesName (const char *name);
void
GetNames (SBStringList &names);
size_t
GetNumResolvedLocations() const;

View File

@ -15,6 +15,61 @@
namespace lldb {
class SBCommandInterpreterRunOptions
{
friend class SBDebugger;
friend class SBCommandInterpreter;
public:
SBCommandInterpreterRunOptions();
~SBCommandInterpreterRunOptions();
bool
GetStopOnContinue () const;
void
SetStopOnContinue (bool);
bool
GetStopOnError () const;
void
SetStopOnError (bool);
bool
GetStopOnCrash () const;
void
SetStopOnCrash (bool);
bool
GetEchoCommands () const;
void
SetEchoCommands (bool);
bool
GetPrintResults () const;
void
SetPrintResults (bool);
bool
GetAddToHistory () const;
void
SetAddToHistory (bool);
private:
lldb_private::CommandInterpreterRunOptions *
get () const;
lldb_private::CommandInterpreterRunOptions &
ref () const;
// This is set in the constructor and will always be valid.
mutable std::unique_ptr<lldb_private::CommandInterpreterRunOptions> m_opaque_up;
};
class SBCommandInterpreter
{
public:
@ -85,6 +140,15 @@ class SBCommandInterpreter
lldb::ReturnStatus
HandleCommand (const char *command_line, lldb::SBCommandReturnObject &result, bool add_to_history = false);
lldb::ReturnStatus
HandleCommand (const char *command_line, SBExecutionContext &exe_ctx, SBCommandReturnObject &result, bool add_to_history = false);
void
HandleCommandsFromFile (lldb::SBFileSpec &file,
lldb::SBExecutionContext &override_context,
lldb::SBCommandInterpreterRunOptions &options,
lldb::SBCommandReturnObject result);
// The pointer based interface is not useful in SWIG, since the cursor & last_char arguments are string pointers INTO current_line
// and you can't do that in a scripting language interface in general...
@ -175,9 +239,9 @@ class SBCommandPluginInterface
{
public:
virtual bool
DoExecute (lldb::SBDebugger debugger,
char** command,
lldb::SBCommandReturnObject &result)
DoExecute (lldb::SBDebugger /*debugger*/,
char** /*command*/,
lldb::SBCommandReturnObject & /*result*/)
{
return false;
}

View File

@ -78,6 +78,9 @@ class SBCompileUnit
lldb::SBTypeList
GetTypes (uint32_t type_mask = lldb::eTypeClassAny);
lldb::LanguageType
GetLanguage ();
bool
operator == (const lldb::SBCompileUnit &rhs) const;

View File

@ -169,6 +169,7 @@ class SBData
friend class SBInstruction;
friend class SBProcess;
friend class SBSection;
friend class SBTarget;
friend class SBValue;
lldb::DataExtractorSP m_opaque_sp;

View File

@ -27,6 +27,7 @@ class SBInputReader
void SetIsDone(bool);
bool IsActive() const;
};
class SBDebugger
{
public:
@ -321,6 +322,13 @@ class SBDebugger
RunCommandInterpreter (bool auto_handle_events,
bool spawn_thread);
void
RunCommandInterpreter (bool auto_handle_events,
bool spawn_thread,
SBCommandInterpreterRunOptions &options,
int &num_errors,
bool &quit_requested,
bool &stopped_for_crash);
private:
friend class SBCommandInterpreter;

View File

@ -35,6 +35,7 @@ class LLDB_API SBBreakpointLocation;
class LLDB_API SBBroadcaster;
class LLDB_API SBCommand;
class LLDB_API SBCommandInterpreter;
class LLDB_API SBCommandInterpreterRunOptions;
class LLDB_API SBCommandPluginInterface;
class LLDB_API SBCommandReturnObject;
class LLDB_API SBCommunication;
@ -45,6 +46,7 @@ class LLDB_API SBDeclaration;
class LLDB_API SBError;
class LLDB_API SBEvent;
class LLDB_API SBEventList;
class LLDB_API SBExecutionContext;
class LLDB_API SBExpressionOptions;
class LLDB_API SBFileSpec;
class LLDB_API SBFileSpecList;
@ -70,14 +72,18 @@ class LLDB_API SBSymbolContext;
class LLDB_API SBSymbolContextList;
class LLDB_API SBTarget;
class LLDB_API SBThread;
class LLDB_API SBThreadCollection;
class LLDB_API SBThreadPlan;
class LLDB_API SBType;
class LLDB_API SBTypeCategory;
class LLDB_API SBTypeEnumMember;
class LLDB_API SBTypeEnumMemberList;
class LLDB_API SBTypeFilter;
class LLDB_API SBTypeFormat;
class LLDB_API SBTypeMemberFunction;
class LLDB_API SBTypeNameSpecifier;
class LLDB_API SBTypeSummary;
class LLDB_API SBTypeSummaryOptions;
#ifndef LLDB_DISABLE_PYTHON
class LLDB_API SBTypeSynthetic;
#endif

View File

@ -30,6 +30,10 @@ class SBEvent
// Make an event that contains a C string.
SBEvent (uint32_t event, const char *cstr, uint32_t cstr_len);
SBEvent (lldb::EventSP &event_sp);
SBEvent (lldb_private::Event *event_sp);
~SBEvent();
const SBEvent &
@ -77,8 +81,6 @@ class SBEvent
friend class SBThread;
friend class SBWatchpoint;
SBEvent (lldb::EventSP &event_sp);
lldb::EventSP &
GetSP () const;

View File

@ -0,0 +1,74 @@
//===-- SBExecutionContext.h -----------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_SBExecutionContext_h_
#define LLDB_SBExecutionContext_h_
#include "lldb/API/SBDefines.h"
#include <stdio.h>
#include <vector>
namespace lldb {
class SBExecutionContext
{
friend class SBCommandInterpreter;
public:
SBExecutionContext();
SBExecutionContext (const lldb::SBExecutionContext &rhs);
SBExecutionContext (lldb::ExecutionContextRefSP exe_ctx_ref_sp);
SBExecutionContext (const lldb::SBTarget &target);
SBExecutionContext (const lldb::SBProcess &process);
SBExecutionContext (lldb::SBThread thread); // can't be a const& because SBThread::get() isn't itself a const function
SBExecutionContext (const lldb::SBFrame &frame);
~SBExecutionContext();
const SBExecutionContext &
operator = (const lldb::SBExecutionContext &rhs);
SBTarget
GetTarget () const;
SBProcess
GetProcess () const;
SBThread
GetThread () const;
SBFrame
GetFrame () const;
protected:
ExecutionContextRefSP &
GetSP () const;
void
reset (lldb::ExecutionContextRefSP &event_sp);
lldb_private::ExecutionContextRef *
get () const;
private:
mutable lldb::ExecutionContextRefSP m_exe_ctx_sp;
};
} // namespace lldb
#endif // LLDB_SBExecutionContext_h_

View File

@ -63,6 +63,7 @@ class SBFileSpec
private:
friend class SBAttachInfo;
friend class SBBlock;
friend class SBCommandInterpreter;
friend class SBCompileUnit;
friend class SBDeclaration;
friend class SBFileSpecList;

View File

@ -198,21 +198,6 @@ class SBFrame
lldb::SBValue
FindValue (const char *name, ValueType value_type, lldb::DynamicValueType use_dynamic);
/// Find and watch a variable using the frame as the scope.
/// It returns an SBValue, similar to FindValue() method, if find-and-watch
/// operation succeeds. Otherwise, an invalid SBValue is returned.
/// You can use LLDB_WATCH_TYPE_READ | LLDB_WATCH_TYPE_WRITE for 'rw' watch.
lldb::SBValue
WatchValue (const char *name, ValueType value_type, uint32_t watch_type);
/// Find and watch the location pointed to by a variable using the frame as
/// the scope.
/// It returns an SBValue, similar to FindValue() method, if find-and-watch
/// operation succeeds. Otherwise, an invalid SBValue is returned.
/// You can use LLDB_WATCH_TYPE_READ | LLDB_WATCH_TYPE_WRITE for 'rw' watch.
lldb::SBValue
WatchLocation (const char *name, ValueType value_type, uint32_t watch_type, size_t size);
bool
GetDescription (lldb::SBStream &description);
@ -221,6 +206,7 @@ class SBFrame
protected:
friend class SBBlock;
friend class SBExecutionContext;
friend class SBInstruction;
friend class SBThread;
friend class SBValue;

View File

@ -58,6 +58,9 @@ class SBFunction
lldb::SBBlock
GetBlock ();
lldb::LanguageType
GetLanguage ();
bool
operator == (const lldb::SBFunction &rhs) const;

View File

@ -99,13 +99,23 @@ class SBListener
HandleBroadcastEvent (const lldb::SBEvent &event);
protected:
friend class SBAttachInfo;
friend class SBBroadcaster;
friend class SBCommandInterpreter;
friend class SBDebugger;
friend class SBLaunchInfo;
friend class SBTarget;
SBListener (lldb_private::Listener &listener);
SBListener (const lldb::ListenerSP &listener_sp);
lldb::ListenerSP
GetSP ()
{
return m_opaque_sp;
}
private:
lldb_private::Listener *

View File

@ -316,6 +316,12 @@ class SBProcess
//------------------------------------------------------------------
const char *
GetExtendedBacktraceTypeAtIndex (uint32_t idx);
lldb::SBThreadCollection
GetHistoryThreads (addr_t addr);
bool
IsInstrumentationRuntimePresent(InstrumentationRuntimeType type);
protected:
friend class SBAddress;
@ -323,6 +329,7 @@ class SBProcess
friend class SBBreakpointLocation;
friend class SBCommandInterpreter;
friend class SBDebugger;
friend class SBExecutionContext;
friend class SBFunction;
friend class SBModule;
friend class SBTarget;

View File

@ -71,6 +71,18 @@ class SBSection
SectionType
GetSectionType ();
//------------------------------------------------------------------
/// Return the size of a target's byte represented by this section
/// in numbers of host bytes. Note that certain architectures have
/// varying minimum addressable unit (i.e. byte) size for their
/// CODE or DATA buses.
///
/// @return
/// The number of host (8-bit) bytes needed to hold a target byte
//------------------------------------------------------------------
uint32_t
GetTargetByteSize ();
bool
operator == (const lldb::SBSection &rhs);

View File

@ -85,8 +85,10 @@ class SBStream
friend class SBSymbolContextList;
friend class SBTarget;
friend class SBThread;
friend class SBThreadPlan;
friend class SBType;
friend class SBTypeEnumMember;
friend class SBTypeMemberFunction;
friend class SBTypeMember;
friend class SBValue;
friend class SBWatchpoint;

View File

@ -22,6 +22,8 @@
namespace lldb {
class SBPlatform;
class SBLaunchInfo
{
public:
@ -49,7 +51,7 @@ class SBLaunchInfo
SBFileSpec
GetExecutableFile ();
//----------------------------------------------------------------------
/// Set the executable file that will be used to launch the process and
/// optionally set it as the first argument in the argument vector.
@ -75,7 +77,29 @@ class SBLaunchInfo
//----------------------------------------------------------------------
void
SetExecutableFile (SBFileSpec exe_file, bool add_as_first_arg);
//----------------------------------------------------------------------
/// Get the listener that will be used to receive process events.
///
/// If no listener has been set via a call to
/// SBLaunchInfo::SetListener(), then an invalid SBListener will be
/// returned (SBListener::IsValid() will return false). If a listener
/// has been set, then the valid listener object will be returned.
//----------------------------------------------------------------------
SBListener
GetListener ();
//----------------------------------------------------------------------
/// Set the listener that will be used to receive process events.
///
/// By default the SBDebugger, which has a listener, that the SBTarget
/// belongs to will listen for the process events. Calling this function
/// allows a different listener to be used to listen for process events.
//----------------------------------------------------------------------
void
SetListener (SBListener &listener);
uint32_t
GetNumArguments ();
@ -256,7 +280,28 @@ class SBAttachInfo
bool
ParentProcessIDIsValid();
//----------------------------------------------------------------------
/// Get the listener that will be used to receive process events.
///
/// If no listener has been set via a call to
/// SBLaunchInfo::SetListener(), then an invalid SBListener will be
/// returned (SBListener::IsValid() will return false). If a listener
/// has been set, then the valid listener object will be returned.
//----------------------------------------------------------------------
SBListener
GetListener ();
//----------------------------------------------------------------------
/// Set the listener that will be used to receive process events.
///
/// By default the SBDebugger, which has a listener, that the SBTarget
/// belongs to will listen for the process events. Calling this function
/// allows a different listener to be used to listen for process events.
//----------------------------------------------------------------------
void
SetListener (SBListener &listener);
protected:
friend class SBTarget;
@ -308,6 +353,18 @@ class SBTarget
lldb::SBProcess
GetProcess ();
//------------------------------------------------------------------
/// Return the platform object associated with the target.
///
/// After return, the platform object should be checked for
/// validity.
///
/// @return
/// A platform object.
//------------------------------------------------------------------
lldb::SBPlatform
GetPlatform ();
//------------------------------------------------------------------
/// Install any binaries that need to be installed.
///
@ -563,6 +620,26 @@ class SBTarget
const char *
GetTriple ();
//------------------------------------------------------------------
/// Architecture data byte width accessor
///
/// @return
/// The size in 8-bit (host) bytes of a minimum addressable
/// unit from the Architecture's data bus
//------------------------------------------------------------------
uint32_t
GetDataByteSize ();
//------------------------------------------------------------------
/// Architecture code byte width accessor
///
/// @return
/// The size in 8-bit (host) bytes of a minimum addressable
/// unit from the Architecture's code bus
//------------------------------------------------------------------
uint32_t
GetCodeByteSize ();
//------------------------------------------------------------------
/// Set the base load address for a module section.
///
@ -683,10 +760,61 @@ class SBTarget
//------------------------------------------------------------------
lldb::SBValue
FindFirstGlobalVariable (const char* name);
//------------------------------------------------------------------
/// Find global and static variables by pattern.
///
/// @param[in] name
/// The pattern to search for global or static variables
///
/// @param[in] max_matches
/// Allow the number of matches to be limited to \a max_matches.
///
/// @param[in] matchtype
/// The match type to use.
///
/// @return
/// A list of matched variables in an SBValueList.
//------------------------------------------------------------------
lldb::SBValueList
FindGlobalVariables(const char *name,
uint32_t max_matches,
MatchType matchtype);
//------------------------------------------------------------------
/// Find global functions by their name with pattern matching.
///
/// @param[in] name
/// The pattern to search for global or static variables
///
/// @param[in] max_matches
/// Allow the number of matches to be limited to \a max_matches.
///
/// @param[in] matchtype
/// The match type to use.
///
/// @return
/// A list of matched variables in an SBValueList.
//------------------------------------------------------------------
lldb::SBSymbolContextList
FindGlobalFunctions(const char *name,
uint32_t max_matches,
MatchType matchtype);
void
Clear ();
//------------------------------------------------------------------
/// Resolve a current file address into a section offset address.
///
/// @param[in] file_addr
///
/// @return
/// An SBAddress which will be valid if...
//------------------------------------------------------------------
lldb::SBAddress
ResolveFileAddress (lldb::addr_t file_addr);
//------------------------------------------------------------------
/// Resolve a current load address into a section offset address.
///
@ -732,6 +860,31 @@ class SBTarget
ResolveSymbolContextForAddress (const SBAddress& addr,
uint32_t resolve_scope);
//------------------------------------------------------------------
/// Read target memory. If a target process is running then memory
/// is read from here. Otherwise the memory is read from the object
/// files. For a target whose bytes are sized as a multiple of host
/// bytes, the data read back will preserve the target's byte order.
///
/// @param[in] addr
/// A target address to read from.
///
/// @param[out] buf
/// The buffer to read memory into.
///
/// @param[in] size
/// The maximum number of host bytes to read in the buffer passed
/// into this call
///
/// @param[out] error
/// Error information is written here if the memory read fails.
///
/// @return
/// The amount of data read in host bytes.
//------------------------------------------------------------------
size_t
ReadMemory (const SBAddress addr, void *buf, size_t size, lldb::SBError &error);
lldb::SBBreakpoint
BreakpointCreateByLocation (const char *file, uint32_t line);
@ -845,6 +998,12 @@ class SBTarget
lldb::SBValue
CreateValueFromAddress (const char *name, lldb::SBAddress addr, lldb::SBType type);
lldb::SBValue
CreateValueFromData (const char *name, lldb::SBData data, lldb::SBType type);
lldb::SBValue
CreateValueFromExpression (const char *name, const char* expr);
SBSourceManager
GetSourceManager();
@ -893,6 +1052,7 @@ class SBTarget
friend class SBAddress;
friend class SBBlock;
friend class SBDebugger;
friend class SBExecutionContext;
friend class SBFunction;
friend class SBInstruction;
friend class SBModule;

View File

@ -78,7 +78,10 @@ class SBThread
//--------------------------------------------------------------------------
uint64_t
GetStopReasonDataAtIndex(uint32_t idx);
bool
GetStopReasonExtendedInfoAsJSON (lldb::SBStream &stream);
size_t
GetStopDescription (char *dst, size_t dst_len);
@ -126,6 +129,9 @@ class SBThread
lldb::SBFileSpec &file_spec,
uint32_t line);
SBError
StepUsingScriptedThreadPlan (const char *script_class_name);
SBError
JumpToLine (lldb::SBFileSpec &file_spec, uint32_t line);
@ -216,9 +222,19 @@ class SBThread
bool
SafeToCallFunctions ();
#ifndef SWIG
lldb_private::Thread *
operator->();
lldb_private::Thread *
get();
#endif
protected:
friend class SBBreakpoint;
friend class SBBreakpointLocation;
friend class SBExecutionContext;
friend class SBFrame;
friend class SBProcess;
friend class SBDebugger;

View File

@ -0,0 +1,68 @@
//===-- SBThreadCollection.h ------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_SBThreadCollection_h_
#define LLDB_SBThreadCollection_h_
#include "lldb/API/SBDefines.h"
namespace lldb {
class SBThreadCollection
{
public:
SBThreadCollection ();
SBThreadCollection (const SBThreadCollection &rhs);
const SBThreadCollection &
operator = (const SBThreadCollection &rhs);
~SBThreadCollection ();
bool
IsValid () const;
size_t
GetSize ();
lldb::SBThread
GetThreadAtIndex (size_t idx);
protected:
// Mimic shared pointer...
lldb_private::ThreadCollection *
get() const;
lldb_private::ThreadCollection *
operator->() const;
lldb::ThreadCollectionSP &
operator*();
const lldb::ThreadCollectionSP &
operator*() const;
SBThreadCollection (const lldb::ThreadCollectionSP &threads);
void
SetOpaque (const lldb::ThreadCollectionSP &threads);
private:
friend class SBProcess;
lldb::ThreadCollectionSP m_opaque_sp;
};
} // namespace lldb
#endif // LLDB_SBThreadCollection_h_

View File

@ -0,0 +1,129 @@
//===-- SBThread.h ----------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_SBThreadPlan_h_
#define LLDB_SBThreadPlan_h_
#include "lldb/API/SBDefines.h"
#include <stdio.h>
namespace lldb {
class SBThreadPlan
{
friend class lldb_private::ThreadPlan;
public:
SBThreadPlan ();
SBThreadPlan (const lldb::SBThreadPlan &threadPlan);
SBThreadPlan (const lldb::ThreadPlanSP& lldb_object_sp);
SBThreadPlan (lldb::SBThread &thread, const char *class_name);
~SBThreadPlan ();
bool
IsValid() const;
void
Clear ();
lldb::StopReason
GetStopReason();
/// Get the number of words associated with the stop reason.
/// See also GetStopReasonDataAtIndex().
size_t
GetStopReasonDataCount();
//--------------------------------------------------------------------------
/// Get information associated with a stop reason.
///
/// Breakpoint stop reasons will have data that consists of pairs of
/// breakpoint IDs followed by the breakpoint location IDs (they always come
/// in pairs).
///
/// Stop Reason Count Data Type
/// ======================== ===== =========================================
/// eStopReasonNone 0
/// eStopReasonTrace 0
/// eStopReasonBreakpoint N duple: {breakpoint id, location id}
/// eStopReasonWatchpoint 1 watchpoint id
/// eStopReasonSignal 1 unix signal number
/// eStopReasonException N exception data
/// eStopReasonExec 0
/// eStopReasonPlanComplete 0
//--------------------------------------------------------------------------
uint64_t
GetStopReasonDataAtIndex(uint32_t idx);
SBThread
GetThread () const;
const lldb::SBThreadPlan &
operator = (const lldb::SBThreadPlan &rhs);
bool
GetDescription (lldb::SBStream &description) const;
void
SetPlanComplete (bool success);
bool
IsPlanComplete();
bool
IsValid();
// This section allows an SBThreadPlan to push another of the common types of plans...
SBThreadPlan
QueueThreadPlanForStepOverRange (SBAddress &start_address,
lldb::addr_t range_size);
SBThreadPlan
QueueThreadPlanForStepInRange (SBAddress &start_address,
lldb::addr_t range_size);
SBThreadPlan
QueueThreadPlanForStepOut (uint32_t frame_idx_to_step_to, bool first_insn = false);
SBThreadPlan
QueueThreadPlanForRunToAddress (SBAddress address);
#ifndef SWIG
lldb_private::ThreadPlan *
get();
#endif
protected:
friend class SBBreakpoint;
friend class SBBreakpointLocation;
friend class SBFrame;
friend class SBProcess;
friend class SBDebugger;
friend class SBValue;
friend class lldb_private::QueueImpl;
friend class SBQueueItem;
#ifndef SWIG
void
SetThreadPlan (const lldb::ThreadPlanSP& lldb_object_sp);
#endif
private:
lldb::ThreadPlanSP m_opaque_sp;
};
} // namespace lldb
#endif // LLDB_SBThreadPlan_h_

View File

@ -67,6 +67,59 @@ class SBTypeMember
std::unique_ptr<lldb_private::TypeMemberImpl> m_opaque_ap;
};
class SBTypeMemberFunction
{
public:
SBTypeMemberFunction ();
SBTypeMemberFunction (const lldb::SBTypeMemberFunction& rhs);
~SBTypeMemberFunction();
lldb::SBTypeMemberFunction&
operator = (const lldb::SBTypeMemberFunction& rhs);
bool
IsValid() const;
const char *
GetName ();
lldb::SBType
GetType ();
lldb::SBType
GetReturnType ();
uint32_t
GetNumberOfArguments ();
lldb::SBType
GetArgumentTypeAtIndex (uint32_t);
lldb::MemberFunctionKind
GetKind();
bool
GetDescription (lldb::SBStream &description,
lldb::DescriptionLevel description_level);
protected:
friend class SBType;
void
reset (lldb_private::TypeMemberFunctionImpl *);
lldb_private::TypeMemberFunctionImpl &
ref ();
const lldb_private::TypeMemberFunctionImpl &
ref () const;
lldb::TypeMemberFunctionImplSP m_opaque_sp;
};
class SBType
{
@ -96,6 +149,12 @@ class SBType
bool
IsPolymorphicClass ();
bool
IsArrayType ();
bool
IsTypedefType ();
lldb::SBType
GetPointerType();
@ -113,6 +172,9 @@ class SBType
lldb::SBType
GetUnqualifiedType();
lldb::SBType
GetArrayElementType ();
lldb::SBType
GetCanonicalType();
@ -160,6 +222,12 @@ class SBType
lldb::SBTypeList
GetFunctionArgumentTypes ();
uint32_t
GetNumberOfMemberFunctions ();
lldb::SBTypeMemberFunction
GetMemberFunctionAtIndex (uint32_t idx);
const char*
GetName();
@ -172,6 +240,9 @@ class SBType
bool
IsTypeComplete ();
uint32_t
GetTypeFlags ();
bool
GetDescription (lldb::SBStream &description,
@ -209,6 +280,7 @@ class SBType
friend class SBTypeEnumMemberList;
friend class SBTypeNameSpecifier;
friend class SBTypeMember;
friend class SBTypeMemberFunction;
friend class SBTypeList;
friend class SBValue;

View File

@ -15,6 +15,56 @@
#ifndef LLDB_DISABLE_PYTHON
namespace lldb {
class SBTypeSummaryOptions
{
public:
SBTypeSummaryOptions();
SBTypeSummaryOptions (const lldb::SBTypeSummaryOptions &rhs);
SBTypeSummaryOptions (const lldb_private::TypeSummaryOptions *lldb_object_ptr);
~SBTypeSummaryOptions ();
bool
IsValid ();
lldb::LanguageType
GetLanguage ();
lldb::TypeSummaryCapping
GetCapping ();
void
SetLanguage (lldb::LanguageType);
void
SetCapping (lldb::TypeSummaryCapping);
protected:
friend class SBValue;
lldb_private::TypeSummaryOptions *
operator->();
const lldb_private::TypeSummaryOptions *
operator->() const;
lldb_private::TypeSummaryOptions *
get ();
lldb_private::TypeSummaryOptions &
ref();
const lldb_private::TypeSummaryOptions &
ref() const;
void
SetOptions (const lldb_private::TypeSummaryOptions *lldb_object_ptr);
private:
std::unique_ptr<lldb_private::TypeSummaryOptions> m_opaque_ap;
};
class SBTypeSummary
{

View File

@ -90,9 +90,16 @@ friend class ValueLocker;
const char *
GetSummary ();
const char *
GetSummary (lldb::SBStream& stream,
lldb::SBTypeSummaryOptions& options);
const char *
GetObjectDescription ();
const char *
GetTypeValidatorResult ();
lldb::SBValue
GetDynamicValue (lldb::DynamicValueType use_dynamic);
@ -152,6 +159,7 @@ friend class ValueLocker;
lldb::SBValue
CreateChildAtOffset (const char *name, uint32_t offset, lldb::SBType type);
// Deprecated - use the expression evaluator to perform type casting
lldb::SBValue
Cast (lldb::SBType type);
@ -345,6 +353,9 @@ friend class ValueLocker;
lldb::SBType
GetType();
lldb::SBValue
Persist ();
bool
GetDescription (lldb::SBStream &description);

View File

@ -43,6 +43,9 @@ class SBValueList
lldb::SBValue
GetValueAtIndex (uint32_t idx) const;
lldb::SBValue
GetFirstValueByName (const char* name) const;
lldb::SBValue
FindValueObjectByUID (lldb::user_id_t uid);

View File

@ -12,8 +12,11 @@
// C Includes
// C++ Includes
#include <unordered_set>
// Other libraries and framework includes
// Project includes
#include "lldb/Breakpoint/BreakpointID.h"
#include "lldb/Breakpoint/BreakpointLocationList.h"
#include "lldb/Breakpoint/BreakpointOptions.h"
#include "lldb/Breakpoint/BreakpointLocationCollection.h"
@ -203,13 +206,28 @@ class Breakpoint:
/// Tell this breakpoint to scan a given module list and resolve any
/// new locations that match the breakpoint's specifications.
///
/// @param[in] changed_modules
/// @param[in] module_list
/// The list of modules to look in for new locations.
///
/// @param[in] send_event
/// If \b true, send a breakpoint location added event for non-internal breakpoints.
//------------------------------------------------------------------
void
ResolveBreakpointInModules (ModuleList &changed_modules);
ResolveBreakpointInModules (ModuleList &module_list, bool send_event = true);
//------------------------------------------------------------------
/// Tell this breakpoint to scan a given module list and resolve any
/// new locations that match the breakpoint's specifications.
///
/// @param[in] changed_modules
/// The list of modules to look in for new locations.
///
/// @param[in] new_locations
/// Fills new_locations with the new locations that were made.
//------------------------------------------------------------------
void
ResolveBreakpointInModules (ModuleList &module_list, BreakpointLocationCollection &new_locations);
//------------------------------------------------------------------
/// Like ResolveBreakpointInModules, but allows for "unload" events, in
/// which case we will remove any locations that are in modules that got
@ -538,10 +556,19 @@ class Breakpoint:
/// This breakpoint's Target.
//------------------------------------------------------------------
Target &
GetTarget ();
GetTarget ()
{
return m_target;
}
const Target &
GetTarget () const;
GetTarget () const
{
return m_target;
}
const lldb::TargetSP
GetTargetSP ();
void
GetResolverDescription (Stream *s);
@ -600,6 +627,44 @@ class Breakpoint:
return m_hardware;
}
lldb::BreakpointResolverSP
GetResolver()
{
return m_resolver_sp;
}
lldb::SearchFilterSP
GetSearchFilter()
{
return m_filter_sp;
}
bool
AddName (const char *new_name, Error &error);
void
RemoveName (const char *name_to_remove)
{
if (name_to_remove)
m_name_list.erase(name_to_remove);
}
bool
MatchesName (const char *name)
{
return m_name_list.find(name) != m_name_list.end();
}
void
GetNames (std::vector<std::string> &names)
{
names.clear();
for (auto name : m_name_list)
{
names.push_back(name);
}
}
protected:
friend class Target;
//------------------------------------------------------------------
@ -650,12 +715,18 @@ class Breakpoint:
IgnoreCountShouldStop ();
private:
// This one should only be used by Target to copy breakpoints from target to target - primarily from the dummy
// target to prime new targets.
Breakpoint (Target &new_target,
Breakpoint &bp_to_copy_from);
//------------------------------------------------------------------
// For Breakpoint only
//------------------------------------------------------------------
bool m_being_created;
bool m_hardware; // If this breakpoint is required to use a hardware breakpoint
Target &m_target; // The target that holds this breakpoint.
std::unordered_set<std::string> m_name_list; // If not empty, this is the name of this breakpoint (many breakpoints can share the same name.)
lldb::SearchFilterSP m_filter_sp; // The filter that constrains the breakpoint's domain.
lldb::BreakpointResolverSP m_resolver_sp; // The resolver that defines this breakpoint.
BreakpointOptions m_options; // Settable breakpoint options

View File

@ -92,6 +92,21 @@ class BreakpointID
ParseCanonicalReference (const char *input, lldb::break_id_t *break_id, lldb::break_id_t *break_loc_id);
//------------------------------------------------------------------
/// Takes an input string and checks to see whether it is a breakpoint name.
/// If it is a mal-formed breakpoint name, error will be set to an appropriate
/// error string.
///
/// @param[in] input
/// A string containing JUST the breakpoint description.
/// @param[out] error
/// If the name is a well-formed breakpoint name, set to success, otherwise set to an error.
/// @return
/// \b true if the name is a breakpoint name (as opposed to an ID or range) false otherwise.
//------------------------------------------------------------------
static bool
StringIsBreakpointName (const char *name, Error &error);
//------------------------------------------------------------------
/// Takes a breakpoint ID and the breakpoint location id and returns
/// a string containing the canonical description for the breakpoint

View File

@ -68,7 +68,7 @@ class BreakpointIDList
StringContainsIDRangeExpression (const char *in_string, size_t *range_start_len, size_t *range_end_pos);
static void
FindAndReplaceIDRanges (Args &old_args, Target *target, CommandReturnObject &result, Args &new_args);
FindAndReplaceIDRanges (Args &old_args, Target *target, bool allow_locations, CommandReturnObject &result, Args &new_args);
private:
BreakpointIDArray m_breakpoint_ids;

View File

@ -204,11 +204,25 @@ class BreakpointList
bp_collection::const_iterator
GetBreakpointIDConstIterator(lldb::break_id_t breakID) const;
Mutex &
GetMutex () const
{
return m_mutex;
}
mutable Mutex m_mutex;
bp_collection m_breakpoints; // The breakpoint list, currently a list.
lldb::break_id_t m_next_break_id;
bool m_is_internal;
public:
typedef LockingAdaptedIterable<bp_collection, lldb::BreakpointSP, list_adapter> BreakpointIterable;
BreakpointIterable
Breakpoints()
{
return BreakpointIterable(m_breakpoints, GetMutex());
}
private:
DISALLOW_COPY_AND_ASSIGN (BreakpointList);
};

View File

@ -52,7 +52,6 @@ class BreakpointLocation :
public StoppointLocation
{
public:
~BreakpointLocation ();
//------------------------------------------------------------------
@ -374,7 +373,21 @@ class BreakpointLocation :
m_is_reexported = is_reexported;
}
//------------------------------------------------------------------
/// Returns whether the two breakpoint locations might represent "equivalent locations".
/// This is used when modules changed to determine if a Location in the old module might
/// be the "same as" the input location.
///
/// @param[in] location
/// The location to compare against.
///
/// @return
/// \b true or \b false as given in the description above.
//------------------------------------------------------------------
bool EquivalentToLocation(BreakpointLocation &location);
protected:
friend class BreakpointSite;
friend class BreakpointLocationList;
friend class Process;
@ -396,8 +409,14 @@ class BreakpointLocation :
bool
IgnoreCountShouldStop();
private:
void
SwapLocation (lldb::BreakpointLocationSP swap_from);
void
BumpHitCount();
//------------------------------------------------------------------
// Constructors and Destructors

View File

@ -16,6 +16,7 @@
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Utility/Iterable.h"
namespace lldb_private {
@ -202,6 +203,14 @@ class BreakpointLocationCollection
collection m_break_loc_collection;
public:
typedef AdaptedIterable<collection, lldb::BreakpointLocationSP, vector_adapter> BreakpointLocationCollectionIterable;
BreakpointLocationCollectionIterable
BreakpointLocations()
{
return BreakpointLocationCollectionIterable(m_break_loc_collection);
}
};
} // namespace lldb_private

View File

@ -19,6 +19,7 @@
#include "lldb/lldb-private.h"
#include "lldb/Core/Address.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Utility/Iterable.h"
namespace lldb_private {
@ -248,12 +249,18 @@ friend class Breakpoint;
AddLocation (const Address &addr,
bool resolve_indirect_symbols,
bool *new_location = NULL);
void
SwapLocation (lldb::BreakpointLocationSP to_location_sp, lldb::BreakpointLocationSP from_location_sp);
bool
RemoveLocation (const lldb::BreakpointLocationSP &bp_loc_sp);
void
RemoveInvalidLocations (const ArchSpec &arch);
void
Compact();
typedef std::vector<lldb::BreakpointLocationSP> collection;
typedef std::map<lldb_private::Address,
@ -266,6 +273,14 @@ friend class Breakpoint;
mutable Mutex m_mutex;
lldb::break_id_t m_next_id;
BreakpointLocationCollection *m_new_location_recorder;
public:
typedef AdaptedIterable<collection, lldb::BreakpointLocationSP, vector_adapter> BreakpointLocationIterable;
BreakpointLocationIterable
BreakpointLocations()
{
return BreakpointLocationIterable(m_locations);
}
};
} // namespace lldb_private

View File

@ -44,6 +44,8 @@ namespace lldb_private {
class BreakpointResolver :
public Searcher
{
friend class Breakpoint;
public:
//------------------------------------------------------------------
/// The breakpoint resolver need to have a breakpoint for "ResolveBreakpoint
@ -122,7 +124,8 @@ class BreakpointResolver :
AddressResolver, // This is an instance of BreakpointResolverAddress
NameResolver, // This is an instance of BreakpointResolverName
FileRegexResolver,
ExceptionResolver
ExceptionResolver,
LastKnownResolverType = ExceptionResolver
};
//------------------------------------------------------------------
@ -133,6 +136,9 @@ class BreakpointResolver :
return SubclassID;
}
virtual lldb::BreakpointResolverSP
CopyForBreakpoint (Breakpoint &breakpoint) = 0;
protected:
//------------------------------------------------------------------
/// SetSCMatchesByLine - Takes a symbol context list of matches which supposedly represent the same file and

View File

@ -34,27 +34,27 @@ class BreakpointResolverAddress:
virtual
~BreakpointResolverAddress ();
virtual void
ResolveBreakpoint (SearchFilter &filter);
void
ResolveBreakpoint (SearchFilter &filter) override;
virtual void
void
ResolveBreakpointInModules (SearchFilter &filter,
ModuleList &modules);
ModuleList &modules) override;
virtual Searcher::CallbackReturn
Searcher::CallbackReturn
SearchCallback (SearchFilter &filter,
SymbolContext &context,
Address *addr,
bool containing);
bool containing) override;
virtual Searcher::Depth
GetDepth ();
Searcher::Depth
GetDepth () override;
virtual void
GetDescription (Stream *s);
void
GetDescription (Stream *s) override;
virtual void
Dump (Stream *s) const;
void
Dump (Stream *s) const override;
/// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const BreakpointResolverAddress *) { return true; }
@ -62,6 +62,9 @@ class BreakpointResolverAddress:
return V->getResolverID() == BreakpointResolver::AddressResolver;
}
lldb::BreakpointResolverSP
CopyForBreakpoint (Breakpoint &breakpoint) override;
protected:
Address m_addr;

View File

@ -37,20 +37,20 @@ class BreakpointResolverFileLine :
virtual
~BreakpointResolverFileLine ();
virtual Searcher::CallbackReturn
Searcher::CallbackReturn
SearchCallback (SearchFilter &filter,
SymbolContext &context,
Address *addr,
bool containing);
bool containing) override;
virtual Searcher::Depth
GetDepth ();
Searcher::Depth
GetDepth () override;
virtual void
GetDescription (Stream *s);
void
GetDescription (Stream *s) override;
virtual void
Dump (Stream *s) const;
void
Dump (Stream *s) const override;
/// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const BreakpointResolverFileLine *) { return true; }
@ -58,6 +58,9 @@ class BreakpointResolverFileLine :
return V->getResolverID() == BreakpointResolver::FileLineResolver;
}
lldb::BreakpointResolverSP
CopyForBreakpoint (Breakpoint &breakpoint) override;
protected:
friend class Breakpoint;
FileSpec m_file_spec; // This is the file spec we are looking for.

View File

@ -34,20 +34,20 @@ class BreakpointResolverFileRegex :
virtual
~BreakpointResolverFileRegex ();
virtual Searcher::CallbackReturn
Searcher::CallbackReturn
SearchCallback (SearchFilter &filter,
SymbolContext &context,
Address *addr,
bool containing);
bool containing) override;
virtual Searcher::Depth
GetDepth ();
Searcher::Depth
GetDepth () override;
virtual void
GetDescription (Stream *s);
void
GetDescription (Stream *s) override;
virtual void
Dump (Stream *s) const;
void
Dump (Stream *s) const override;
/// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const BreakpointResolverFileRegex *) { return true; }
@ -55,6 +55,9 @@ class BreakpointResolverFileRegex :
return V->getResolverID() == BreakpointResolver::FileRegexResolver;
}
lldb::BreakpointResolverSP
CopyForBreakpoint (Breakpoint &breakpoint) override;
protected:
friend class Breakpoint;
RegularExpression m_regex; // This is the line expression that we are looking for.

View File

@ -64,20 +64,20 @@ class BreakpointResolverName:
virtual
~BreakpointResolverName ();
virtual Searcher::CallbackReturn
Searcher::CallbackReturn
SearchCallback (SearchFilter &filter,
SymbolContext &context,
Address *addr,
bool containing);
bool containing) override;
virtual Searcher::Depth
GetDepth ();
Searcher::Depth
GetDepth () override;
virtual void
GetDescription (Stream *s);
void
GetDescription (Stream *s) override;
virtual void
Dump (Stream *s) const;
void
Dump (Stream *s) const override;
/// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const BreakpointResolverName *) { return true; }
@ -85,7 +85,12 @@ class BreakpointResolverName:
return V->getResolverID() == BreakpointResolver::NameResolver;
}
lldb::BreakpointResolverSP
CopyForBreakpoint (Breakpoint &breakpoint) override;
protected:
BreakpointResolverName(const BreakpointResolverName &rhs);
struct LookupInfo
{
ConstString name;
@ -113,8 +118,6 @@ class BreakpointResolverName:
void
AddNameLookup (const ConstString &name, uint32_t name_type_mask);
private:
DISALLOW_COPY_AND_ASSIGN(BreakpointResolverName);
};
} // namespace lldb_private

View File

@ -259,6 +259,12 @@ class BreakpointSite :
private:
friend class Process;
friend class BreakpointLocation;
// The StopInfoBreakpoint knows when it is processing a hit for a thread for a site, so let it be the
// one to manage setting the location hit count once and only once.
friend class StopInfoBreakpoint;
void
BumpHitCounts();
//------------------------------------------------------------------
/// The method removes the owner at \a break_loc_id from this breakpoint list.

View File

@ -87,6 +87,7 @@ class Address
///< and file and line), to information about what the pointer points to
///< if the address is in a section (section of pointers, c strings, etc).
DumpStyleResolvedDescriptionNoModule,
DumpStyleResolvedDescriptionNoFunctionArguments,
DumpStyleDetailedSymbolContext, ///< Detailed symbol context information for an address for all symbol
///< context members.
DumpStyleResolvedPointerDescription ///< Dereference a pointer at the current address and then lookup the

View File

@ -104,7 +104,6 @@ class ArchSpec
eCore_uknownMach32,
eCore_uknownMach64,
eCore_kalimba,
eCore_kalimba3,
eCore_kalimba4,
eCore_kalimba5,
@ -142,10 +141,12 @@ class ArchSpec
kCore_hexagon_first = eCore_hexagon_generic,
kCore_hexagon_last = eCore_hexagon_hexagonv5,
kCore_kalimba_first = eCore_kalimba,
kCore_kalimba_first = eCore_kalimba3,
kCore_kalimba_last = eCore_kalimba5
};
typedef void (* StopInfoOverrideCallbackType)(lldb_private::Thread &thread);
//------------------------------------------------------------------
/// Default constructor.
///
@ -459,6 +460,30 @@ class ArchSpec
bool
IsCompatibleMatch (const ArchSpec& rhs) const;
//------------------------------------------------------------------
/// Get a stop info override callback for the current architecture.
///
/// Most platform specific code should go in lldb_private::Platform,
/// but there are cases where no matter which platform you are on
/// certain things hold true.
///
/// This callback is currently intended to handle cases where a
/// program stops at an instruction that won't get executed and it
/// allows the stop reasonm, like "breakpoint hit", to be replaced
/// with a different stop reason like "no stop reason".
///
/// This is specifically used for ARM in Thumb code when we stop in
/// an IT instruction (if/then/else) where the instruction won't get
/// executed and therefore it wouldn't be correct to show the program
/// stopped at the current PC. The code is generic and applies to all
/// ARM CPUs.
///
/// @return NULL or a valid stop info override callback for the
/// current architecture.
//------------------------------------------------------------------
StopInfoOverrideCallbackType
GetStopInfoOverrideCallback () const;
protected:
bool
IsEqualTo (const ArchSpec& rhs, bool exact_match) const;

View File

@ -12,6 +12,7 @@
// C Includes
// C++ Includes
#include <atomic>
#include <string>
// Other libraries and framework includes
@ -19,6 +20,7 @@
#include "lldb/lldb-private.h"
#include "lldb/Core/Broadcaster.h"
#include "lldb/Core/Error.h"
#include "lldb/Host/HostThread.h"
#include "lldb/Host/Mutex.h"
#include "lldb/lldb-private.h"
@ -350,8 +352,8 @@ class Communication : public Broadcaster
protected:
lldb::ConnectionSP m_connection_sp; ///< The connection that is current in use by this communications class.
lldb::thread_t m_read_thread; ///< The read thread handle in case we need to cancel the thread.
bool m_read_thread_enabled;
HostThread m_read_thread; ///< The read thread handle in case we need to cancel the thread.
std::atomic<bool> m_read_thread_enabled;
std::string m_bytes; ///< A buffer to cache bytes read in the ReadThread function.
Mutex m_bytes_mutex; ///< A mutex to protect multi-threaded access to the cached bytes.
Mutex m_write_mutex; ///< Don't let multiple threads write at the same time...

View File

@ -46,6 +46,8 @@ class Connection
virtual
~Connection ();
static Connection *CreateDefaultConnection(const char *url);
//------------------------------------------------------------------
/// Connect using the connect string \a url.
///

View File

@ -1,118 +0,0 @@
//===-- ConnectionFileDescriptor.h ------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef liblldb_ConnectionFileDescriptor_h_
#define liblldb_ConnectionFileDescriptor_h_
// C++ Includes
#include <memory>
#include "lldb/lldb-forward.h"
// Other libraries and framework includes
// Project includes
#include "lldb/Core/Connection.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Host/Pipe.h"
#include "lldb/Host/Predicate.h"
#include "lldb/Host/IOObject.h"
namespace lldb_private {
class Error;
class Socket;
class SocketAddress;
class ConnectionFileDescriptor :
public Connection
{
public:
ConnectionFileDescriptor ();
ConnectionFileDescriptor (int fd, bool owns_fd);
virtual
~ConnectionFileDescriptor ();
virtual bool
IsConnected () const;
virtual lldb::ConnectionStatus
Connect (const char *s, Error *error_ptr);
virtual lldb::ConnectionStatus
Disconnect (Error *error_ptr);
virtual size_t
Read (void *dst,
size_t dst_len,
uint32_t timeout_usec,
lldb::ConnectionStatus &status,
Error *error_ptr);
virtual size_t
Write (const void *src,
size_t src_len,
lldb::ConnectionStatus &status,
Error *error_ptr);
lldb::ConnectionStatus
BytesAvailable (uint32_t timeout_usec, Error *error_ptr);
bool
InterruptRead ();
lldb::IOObjectSP GetReadObject() { return m_read_sp; }
const lldb::IOObjectSP GetReadObject() const { return m_read_sp; }
uint16_t GetListeningPort(uint32_t timeout_sec);
protected:
void
OpenCommandPipe ();
void
CloseCommandPipe ();
lldb::ConnectionStatus
SocketListen (const char *host_and_port, Error *error_ptr);
lldb::ConnectionStatus
ConnectTCP (const char *host_and_port, Error *error_ptr);
lldb::ConnectionStatus
ConnectUDP (const char *args, Error *error_ptr);
lldb::ConnectionStatus
NamedSocketConnect (const char *socket_name, Error *error_ptr);
lldb::ConnectionStatus
NamedSocketAccept (const char *socket_name, Error *error_ptr);
lldb::IOObjectSP m_read_sp;
lldb::IOObjectSP m_write_sp;
Predicate<uint16_t> m_port_predicate; // Used when binding to port zero to wait for the thread
// that creates the socket, binds and listens to resolve
// the port number.
Pipe m_pipe;
Mutex m_mutex;
bool m_shutting_down; // This marks that we are shutting down so if we get woken up from
// BytesAvailable to disconnect, we won't try to read again.
bool m_waiting_for_accept;
private:
DISALLOW_COPY_AND_ASSIGN (ConnectionFileDescriptor);
};
} // namespace lldb_private
#endif // liblldb_ConnectionFileDescriptor_h_

View File

@ -14,6 +14,8 @@
#include <stdint.h>
#include <string.h>
#include "lldb/lldb-types.h"
namespace lldb_private {
//----------------------------------------------------------------------

View File

@ -13,9 +13,13 @@
#include "lldb/lldb-private.h"
#include "llvm/ADT/SmallVector.h"
#include <limits.h>
#include <stdint.h>
#include <string.h>
#include <vector>
namespace lldb_private {
@ -85,8 +89,11 @@ class DataExtractor
///
/// @param[in] addr_size
/// A new address byte size value.
///
/// @param[in] target_byte_size
/// A size of a target byte in 8-bit host bytes
//------------------------------------------------------------------
DataExtractor (const void* data, lldb::offset_t data_length, lldb::ByteOrder byte_order, uint32_t addr_size);
DataExtractor (const void* data, lldb::offset_t data_length, lldb::ByteOrder byte_order, uint32_t addr_size, uint32_t target_byte_size = 1);
//------------------------------------------------------------------
/// Construct with shared data.
@ -104,8 +111,11 @@ class DataExtractor
///
/// @param[in] addr_size
/// A new address byte size value.
///
/// @param[in] target_byte_size
/// A size of a target byte in 8-bit host bytes
//------------------------------------------------------------------
DataExtractor (const lldb::DataBufferSP& data_sp, lldb::ByteOrder byte_order, uint32_t addr_size);
DataExtractor (const lldb::DataBufferSP& data_sp, lldb::ByteOrder byte_order, uint32_t addr_size, uint32_t target_byte_size = 1);
//------------------------------------------------------------------
/// Construct with a subset of \a data.
@ -129,8 +139,11 @@ class DataExtractor
///
/// @param[in] length
/// The length in bytes of the subset of data.
///
/// @param[in] target_byte_size
/// A size of a target byte in 8-bit host bytes
//------------------------------------------------------------------
DataExtractor (const DataExtractor& data, lldb::offset_t offset, lldb::offset_t length);
DataExtractor (const DataExtractor& data, lldb::offset_t offset, lldb::offset_t length, uint32_t target_byte_size = 1);
DataExtractor (const DataExtractor& rhs);
//------------------------------------------------------------------
@ -863,7 +876,7 @@ class DataExtractor
*offset_ptr += 1;
return val;
}
uint16_t
GetU16_unchecked (lldb::offset_t *offset_ptr) const;
@ -1300,6 +1313,11 @@ class DataExtractor
return size - offset;
return 0;
}
void
Checksum (llvm::SmallVectorImpl<uint8_t> &dest,
uint64_t max_data = 0);
protected:
@ -1311,6 +1329,7 @@ class DataExtractor
lldb::ByteOrder m_byte_order; ///< The byte order of the data we are extracting from.
uint32_t m_addr_size; ///< The address size to use when extracting pointers or addresses
mutable lldb::DataBufferSP m_data_sp; ///< The shared pointer to data that can be shared among multilple instances
const uint32_t m_target_byte_size;
};
} // namespace lldb_private

View File

@ -25,6 +25,7 @@
#include "lldb/Core/UserID.h"
#include "lldb/Core/UserSettingsController.h"
#include "lldb/DataFormatters/FormatManager.h"
#include "lldb/Host/HostThread.h"
#include "lldb/Host/Terminal.h"
#include "lldb/Interpreter/OptionValueProperties.h"
#include "lldb/Target/ExecutionContext.h"
@ -249,6 +250,13 @@ friend class SourceManager; // For GetSourceFileCache.
Stream &s,
ValueObject* valobj = NULL);
static bool
FormatDisassemblerAddress (const char *format,
const SymbolContext *sc,
const SymbolContext *prev_sc,
const ExecutionContext *exe_ctx,
const Address *addr,
Stream &s);
void
ClearIOHandlers ();
@ -287,10 +295,13 @@ friend class SourceManager; // For GetSourceFileCache.
bool
GetAutoConfirm () const;
const char *
GetDisassemblyFormat() const;
const char *
GetFrameFormat() const;
const char *
GetThreadFormat() const;
@ -336,6 +347,9 @@ friend class SourceManager; // For GetSourceFileCache.
bool
GetAutoOneLineSummaries () const;
bool
GetEscapeNonPrintables () const;
bool
GetNotifyVoid () const;
@ -364,9 +378,14 @@ friend class SourceManager; // For GetSourceFileCache.
bool
IsHandlingEvents () const
{
return IS_VALID_LLDB_HOST_THREAD(m_event_handler_thread);
return m_event_handler_thread.IsJoinable();
}
// This is for use in the command interpreter, when you either want the selected target, or if no target
// is present you want to prime the dummy target with entities that will be copied over to new targets.
Target *GetSelectedOrDummyTarget(bool prefer_dummy = false);
Target *GetDummyTarget();
protected:
friend class CommandInterpreter;
@ -412,11 +431,16 @@ friend class SourceManager; // For GetSourceFileCache.
{
return m_source_file_cache;
}
void
InstanceInitialize ();
lldb::StreamFileSP m_input_file_sp;
lldb::StreamFileSP m_output_file_sp;
lldb::StreamFileSP m_error_file_sp;
TerminalState m_terminal_state;
TargetList m_target_list;
PlatformList m_platform_list;
Listener m_listener;
std::unique_ptr<SourceManager> m_source_manager_ap; // This is a scratch source manager that we return if we have no targets.
@ -432,12 +456,19 @@ friend class SourceManager; // For GetSourceFileCache.
static LoadPluginCallbackType g_load_plugin_callback;
typedef std::vector<llvm::sys::DynamicLibrary> LoadedPluginsList;
LoadedPluginsList m_loaded_plugins;
lldb::thread_t m_event_handler_thread;
lldb::thread_t m_io_handler_thread;
HostThread m_event_handler_thread;
HostThread m_io_handler_thread;
Broadcaster m_sync_broadcaster;
lldb::ListenerSP m_forward_listener_sp;
void
InstanceInitialize ();
//----------------------------------------------------------------------
// Events for m_sync_broadcaster
//----------------------------------------------------------------------
enum
{
eBroadcastBitEventThreadIsListening = (1 << 0),
};
private:
// Use Debugger::CreateInstance() to get a shared pointer to a new

View File

@ -77,12 +77,60 @@ class Instruction
m_address = addr;
}
//------------------------------------------------------------------
/// Dump the text representation of this Instruction to a Stream
///
/// Print the (optional) address, (optional) bytes, opcode,
/// operands, and instruction comments to a stream.
///
/// @param[in] s
/// The Stream to add the text to.
///
/// @param[in] show_address
/// Whether the address (using disassembly_addr_format_spec formatting)
/// should be printed.
///
/// @param[in] show_bytes
/// Whether the bytes of the assembly instruction should be printed.
///
/// @param[in] max_opcode_byte_size
/// The size (in bytes) of the largest instruction in the list that
/// we are printing (for text justification/alignment purposes)
/// Only needed if show_bytes is true.
///
/// @param[in] exe_ctx
/// The current execution context, if available. May be used in
/// the assembling of the operands+comments for this instruction.
/// Pass NULL if not applicable.
///
/// @param[in] sym_ctx
/// The SymbolContext for this instruction.
/// Pass NULL if not available/computed.
/// Only needed if show_address is true.
///
/// @param[in] prev_sym_ctx
/// The SymbolContext for the previous instruction. Depending on
/// the disassembly address format specification, a change in
/// Symbol / Function may mean that a line is printed with the new
/// symbol/function name.
/// Pass NULL if unavailable, or if this is the first instruction of
/// the InstructionList.
/// Only needed if show_address is true.
///
/// @param[in] disassembly_addr_format_spec
/// The format specification for how addresses are printed.
/// Only needed if show_address is true.
//------------------------------------------------------------------
virtual void
Dump (Stream *s,
uint32_t max_opcode_byte_size,
bool show_address,
bool show_bytes,
const ExecutionContext* exe_ctx);
const ExecutionContext* exe_ctx,
const SymbolContext *sym_ctx,
const SymbolContext *prev_sym_ctx,
const char *disassembly_addr_format_spec);
virtual bool
DoesBranch () = 0;

View File

@ -119,12 +119,15 @@ class FileSpecList
/// @param[in] full
/// Should FileSpec::Equal be called with "full" true or false.
///
/// @param[in] remove_backup_dots
/// Should FileSpec::Equal be called with "remove_backup_dots" true or false.
///
/// @return
/// The index of the file that matches \a file if it is found,
/// else UINT32_MAX is returned.
//------------------------------------------------------------------
size_t
FindFileIndex (size_t idx, const FileSpec &file, bool full) const;
FindFileIndex (size_t idx, const FileSpec &file, bool full, bool remove_backup_dots = false) const;
//------------------------------------------------------------------
/// Get file at index.

View File

@ -19,9 +19,11 @@
#include "lldb/Core/ConstString.h"
#include "lldb/Core/Error.h"
#include "lldb/Core/Flags.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/StringList.h"
#include "lldb/Core/ValueObjectList.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Host/Predicate.h"
namespace curses
{
@ -34,9 +36,23 @@ namespace lldb_private {
class IOHandler
{
public:
IOHandler (Debugger &debugger);
enum class Type {
CommandInterpreter,
CommandList,
Confirm,
Curses,
Expression,
ProcessIO,
PythonInterpreter,
PythonCode,
Other
};
IOHandler (Debugger &debugger,
IOHandler::Type type);
IOHandler (Debugger &debugger,
IOHandler::Type type,
const lldb::StreamFileSP &input_sp,
const lldb::StreamFileSP &output_sp,
const lldb::StreamFileSP &error_sp,
@ -97,6 +113,12 @@ namespace lldb_private {
return m_done;
}
Type
GetType () const
{
return m_type;
}
virtual void
Activate ()
{
@ -128,7 +150,19 @@ namespace lldb_private {
{
return ConstString();
}
virtual const char *
GetCommandPrefix ()
{
return NULL;
}
virtual const char *
GetHelpPrologue()
{
return NULL;
}
int
GetInputFD();
@ -206,13 +240,21 @@ namespace lldb_private {
//------------------------------------------------------------------
bool
GetIsRealTerminal ();
void
SetPopped (bool b);
void
WaitForPop ();
protected:
Debugger &m_debugger;
lldb::StreamFileSP m_input_sp;
lldb::StreamFileSP m_output_sp;
lldb::StreamFileSP m_error_sp;
Predicate<bool> m_popped;
Flags m_flags;
Type m_type;
void *m_user_data;
bool m_done;
bool m_active;
@ -254,7 +296,12 @@ namespace lldb_private {
IOHandlerActivated (IOHandler &io_handler)
{
}
virtual void
IOHandlerDeactivated (IOHandler &io_handler)
{
}
virtual int
IOHandlerComplete (IOHandler &io_handler,
const char *current_line,
@ -264,6 +311,44 @@ namespace lldb_private {
int max_matches,
StringList &matches);
virtual const char *
IOHandlerGetFixIndentationCharacters ()
{
return NULL;
}
//------------------------------------------------------------------
/// Called when a new line is created or one of an identifed set of
/// indentation characters is typed.
///
/// This function determines how much indentation should be added
/// or removed to match the recommended amount for the final line.
///
/// @param[in] io_handler
/// The IOHandler that responsible for input.
///
/// @param[in] lines
/// The current input up to the line to be corrected. Lines
/// following the line containing the cursor are not included.
///
/// @param[in] cursor_position
/// The number of characters preceeding the cursor on the final
/// line at the time.
///
/// @return
/// Returns an integer describing the number of spaces needed
/// to correct the indentation level. Positive values indicate
/// that spaces should be added, while negative values represent
/// spaces that should be removed.
//------------------------------------------------------------------
virtual int
IOHandlerFixIndentation (IOHandler &io_handler,
const StringList &lines,
int cursor_position)
{
return 0;
}
//------------------------------------------------------------------
/// Called when a line or lines have been retrieved.
///
@ -275,40 +360,55 @@ namespace lldb_private {
//------------------------------------------------------------------
virtual void
IOHandlerInputComplete (IOHandler &io_handler, std::string &data) = 0;
virtual void
IOHandlerInputInterrupted (IOHandler &io_handler, std::string &data)
{
}
//------------------------------------------------------------------
/// Called when a line in \a lines has been updated when doing
/// multi-line input.
/// Called to determine whether typing enter after the last line in
/// \a lines should end input. This function will not be called on
/// IOHandler objects that are getting single lines.
/// @param[in] io_handler
/// The IOHandler that responsible for updating the lines.
///
/// @param[in] lines
/// The current multi-line content. May be altered to provide
/// alternative input when complete.
///
/// @return
/// Return an enumeration to indicate the status of the current
/// line:
/// Success - The line is good and should be added to the
/// multiple lines
/// Error - There is an error with the current line and it
/// need to be re-edited before it is acceptable
/// Done - The lines collection is complete and ready to be
/// returned.
/// Return an boolean to indicate whether input is complete,
/// true indicates that no additional input is necessary, while
/// false indicates that more input is required.
//------------------------------------------------------------------
virtual LineStatus
IOHandlerLinesUpdated (IOHandler &io_handler,
StringList &lines,
uint32_t line_idx,
Error &error)
virtual bool
IOHandlerIsInputComplete (IOHandler &io_handler,
StringList &lines)
{
return LineStatus::Done; // Stop getting lines on the first line that is updated
// subclasses should do something more intelligent here.
// This function will not be called on IOHandler objects
// that are getting single lines.
// Impose no requirements for input to be considered
// complete. subclasses should do something more intelligent.
return true;
}
virtual ConstString
IOHandlerGetControlSequence (char ch)
{
return ConstString();
}
virtual const char *
IOHandlerGetCommandPrefix ()
{
return NULL;
}
virtual const char *
IOHandlerGetHelpPrologue ()
{
return NULL;
}
//------------------------------------------------------------------
// Intercept the IOHandler::Interrupt() calls and do something.
//
@ -356,30 +456,21 @@ namespace lldb_private {
return ConstString();
}
virtual LineStatus
IOHandlerLinesUpdated (IOHandler &io_handler,
StringList &lines,
uint32_t line_idx,
Error &error)
virtual bool
IOHandlerIsInputComplete (IOHandler &io_handler,
StringList &lines)
{
if (line_idx == UINT32_MAX)
// Determine whether the end of input signal has been entered
const size_t num_lines = lines.GetSize();
if (num_lines > 0 && lines[num_lines - 1] == m_end_line)
{
// Remove the last empty line from "lines" so it doesn't appear
// in our final expression and return true to indicate we are done
// Remove the terminal line from "lines" so it doesn't appear in
// the resulting input and return true to indicate we are done
// getting lines
lines.PopBack();
return LineStatus::Done;
return true;
}
else if (line_idx + 1 == lines.GetSize())
{
// The last line was edited, if this line is empty, then we are done
// getting our multiple lines.
if (lines[line_idx] == m_end_line)
{
return LineStatus::Done;
}
}
return LineStatus::Success;
return false;
}
protected:
const std::string m_end_line;
@ -390,20 +481,26 @@ namespace lldb_private {
{
public:
IOHandlerEditline (Debugger &debugger,
IOHandler::Type type,
const char *editline_name, // Used for saving history files
const char *prompt,
const char *continuation_prompt,
bool multi_line,
bool color_prompts,
uint32_t line_number_start, // If non-zero show line numbers starting at 'line_number_start'
IOHandlerDelegate &delegate);
IOHandlerEditline (Debugger &debugger,
IOHandler::Type type,
const lldb::StreamFileSP &input_sp,
const lldb::StreamFileSP &output_sp,
const lldb::StreamFileSP &error_sp,
uint32_t flags,
const char *editline_name, // Used for saving history files
const char *prompt,
const char *continuation_prompt,
bool multi_line,
bool color_prompts,
uint32_t line_number_start, // If non-zero show line numbers starting at 'line_number_start'
IOHandlerDelegate &delegate);
@ -429,11 +526,10 @@ namespace lldb_private {
GotEOF();
virtual void
Activate ()
{
IOHandler::Activate();
m_delegate.IOHandlerActivated(*this);
}
Activate ();
virtual void
Deactivate ();
virtual ConstString
GetControlSequence (char ch)
@ -441,12 +537,30 @@ namespace lldb_private {
return m_delegate.IOHandlerGetControlSequence (ch);
}
virtual const char *
GetCommandPrefix ()
{
return m_delegate.IOHandlerGetCommandPrefix ();
}
virtual const char *
GetHelpPrologue ()
{
return m_delegate.IOHandlerGetHelpPrologue ();
}
virtual const char *
GetPrompt ();
virtual bool
SetPrompt (const char *prompt);
const char *
GetContinuationPrompt ();
void
SetContinuationPrompt (const char *prompt);
bool
GetLine (std::string &line, bool &interrupted);
@ -456,14 +570,40 @@ namespace lldb_private {
void
SetBaseLineNumber (uint32_t line);
private:
static LineStatus
LineCompletedCallback (Editline *editline,
StringList &lines,
uint32_t line_idx,
Error &error,
void *baton);
bool
GetInterruptExits ()
{
return m_interrupt_exits;
}
void
SetInterruptExits (bool b)
{
m_interrupt_exits = b;
}
const StringList *
GetCurrentLines () const
{
return m_current_lines_ptr;
}
uint32_t
GetCurrentLineIndex () const;
private:
#ifndef LLDB_DISABLE_LIBEDIT
static bool
IsInputCompleteCallback (Editline *editline,
StringList &lines,
void *baton);
static int
FixIndentationCallback (Editline *editline,
const StringList &lines,
int cursor_position,
void *baton);
static int AutoCompleteCallback (const char *current_line,
const char *cursor,
const char *last_char,
@ -471,18 +611,28 @@ namespace lldb_private {
int max_matches,
StringList &matches,
void *baton);
#endif
protected:
#ifndef LLDB_DISABLE_LIBEDIT
std::unique_ptr<Editline> m_editline_ap;
#endif
IOHandlerDelegate &m_delegate;
std::string m_prompt;
std::string m_continuation_prompt;
StringList *m_current_lines_ptr;
uint32_t m_base_line_number; // If non-zero, then show line numbers in prompt
bool m_multi_line;
uint32_t m_curr_line_idx;
bool m_multi_line;
bool m_color_prompts;
bool m_interrupt_exits;
};
// The order of base classes is important. Look at the constructor of IOHandlerConfirm
// to see how.
class IOHandlerConfirm :
public IOHandlerEditline,
public IOHandlerDelegate
public IOHandlerDelegate,
public IOHandlerEditline
{
public:
IOHandlerConfirm (Debugger &debugger,
@ -607,7 +757,8 @@ namespace lldb_private {
if (sp)
{
Mutex::Locker locker (m_mutex);
m_stack.push (sp);
sp->SetPopped (false);
m_stack.push_back (sp);
// Set m_top the non-locking IsTop() call
m_top = sp.get();
}
@ -627,7 +778,7 @@ namespace lldb_private {
{
Mutex::Locker locker (m_mutex);
if (!m_stack.empty())
sp = m_stack.top();
sp = m_stack.back();
}
return sp;
}
@ -637,12 +788,16 @@ namespace lldb_private {
{
Mutex::Locker locker (m_mutex);
if (!m_stack.empty())
m_stack.pop();
{
lldb::IOHandlerSP sp (m_stack.back());
m_stack.pop_back();
sp->SetPopped (true);
}
// Set m_top the non-locking IsTop() call
if (m_stack.empty())
m_top = NULL;
else
m_top = m_stack.top().get();
m_top = m_stack.back().get();
}
Mutex &
@ -657,6 +812,19 @@ namespace lldb_private {
return m_top == io_handler_sp.get();
}
bool
CheckTopIOHandlerTypes (IOHandler::Type top_type, IOHandler::Type second_top_type)
{
Mutex::Locker locker (m_mutex);
const size_t num_io_handlers = m_stack.size();
if (num_io_handlers >= 2 &&
m_stack[num_io_handlers-1]->GetType() == top_type &&
m_stack[num_io_handlers-2]->GetType() == second_top_type)
{
return true;
}
return false;
}
ConstString
GetTopIOHandlerControlSequence (char ch)
{
@ -665,9 +833,26 @@ namespace lldb_private {
return ConstString();
}
protected:
const char *
GetTopIOHandlerCommandPrefix()
{
if (m_top)
return m_top->GetCommandPrefix();
return NULL;
}
std::stack<lldb::IOHandlerSP> m_stack;
const char *
GetTopIOHandlerHelpPrologue()
{
if (m_top)
return m_top->GetHelpPrologue();
return NULL;
}
protected:
typedef std::vector<lldb::IOHandlerSP> collection;
collection m_stack;
mutable Mutex m_mutex;
IOHandler *m_top;

View File

@ -37,7 +37,8 @@ class Mangled
enum NamePreference
{
ePreferMangled,
ePreferDemangled
ePreferDemangled,
ePreferDemangledWithoutArguments
};
//----------------------------------------------------------------------

View File

@ -278,6 +278,16 @@ class ModuleList
uint32_t name_type_mask,
SymbolContextList& sc_list);
//------------------------------------------------------------------
/// @see Module::FindFunctions ()
//------------------------------------------------------------------
size_t
FindFunctions(const RegularExpression &name,
bool include_symbols,
bool include_inlines,
bool append,
SymbolContextList& sc_list);
//------------------------------------------------------------------
/// Find global and static variables by name.
///
@ -586,6 +596,13 @@ class ModuleList
return ModuleIterable(m_modules, GetMutex());
}
typedef AdaptedIterable<collection, lldb::ModuleSP, vector_adapter> ModuleIterableNoLocking;
ModuleIterableNoLocking
ModulesNoLocking ()
{
return ModuleIterableNoLocking(m_modules);
}
};
} // namespace lldb_private

View File

@ -342,7 +342,46 @@ class PluginManager
static UnwindAssemblyCreateInstance
GetUnwindAssemblyCreateCallbackForPluginName (const ConstString &name);
//------------------------------------------------------------------
// MemoryHistory
//------------------------------------------------------------------
static bool
RegisterPlugin (const ConstString &name,
const char *description,
MemoryHistoryCreateInstance create_callback);
static bool
UnregisterPlugin (MemoryHistoryCreateInstance create_callback);
static MemoryHistoryCreateInstance
GetMemoryHistoryCreateCallbackAtIndex (uint32_t idx);
static MemoryHistoryCreateInstance
GetMemoryHistoryCreateCallbackForPluginName (const ConstString &name);
//------------------------------------------------------------------
// InstrumentationRuntime
//------------------------------------------------------------------
static bool
RegisterPlugin (const ConstString &name,
const char *description,
InstrumentationRuntimeCreateInstance create_callback,
InstrumentationRuntimeGetType get_type_callback);
static bool
UnregisterPlugin (InstrumentationRuntimeCreateInstance create_callback);
static InstrumentationRuntimeGetType
GetInstrumentationRuntimeGetTypeCallbackAtIndex (uint32_t idx);
static InstrumentationRuntimeCreateInstance
GetInstrumentationRuntimeCreateCallbackAtIndex (uint32_t idx);
static InstrumentationRuntimeCreateInstance
GetInstrumentationRuntimeCreateCallbackForPluginName (const ConstString &name);
//------------------------------------------------------------------
// Some plug-ins might register a DebuggerInitializeCallback
// callback when registering the plug-in. After a new Debugger

View File

@ -39,6 +39,9 @@ inline void regfree(llvm_regex_t * a)
}
#else
#if __ANDROID_NDK__
#include <regex>
#endif
#include <regex.h>
#endif
#include <stdint.h>

View File

@ -225,8 +225,10 @@ class SearchFilter
virtual void
Dump (Stream *s) const;
protected:
lldb::SearchFilterSP
CopyForBreakpoint (Breakpoint &breakpoint);
protected:
// These are utility functions to assist with the search iteration. They are used by the
// default Search method.
@ -248,26 +250,40 @@ class SearchFilter
const SymbolContext &context,
Searcher &searcher);
virtual lldb::SearchFilterSP
DoCopyForBreakpoint (Breakpoint &breakpoint) = 0;
void
SetTarget(lldb::TargetSP &target_sp)
{
m_target_sp = target_sp;
}
lldb::TargetSP m_target_sp; // Every filter has to be associated with a target for
// now since you need a starting place for the search.
};
//----------------------------------------------------------------------
/// @class SearchFilterForNonModuleSpecificSearches SearchFilter.h "lldb/Core/SearchFilter.h"
/// @brief This is a SearchFilter that searches through all modules. It also consults the Target::ModuleIsExcludedForNonModuleSpecificSearches.
/// @class SearchFilterForUnconstrainedSearches SearchFilter.h "lldb/Core/SearchFilter.h"
/// @brief This is a SearchFilter that searches through all modules. It also consults the Target::ModuleIsExcludedForUnconstrainedSearches.
//----------------------------------------------------------------------
class SearchFilterForNonModuleSpecificSearches :
class SearchFilterForUnconstrainedSearches :
public SearchFilter
{
public:
SearchFilterForNonModuleSpecificSearches (const lldb::TargetSP &targetSP) : SearchFilter(targetSP) {}
~SearchFilterForNonModuleSpecificSearches () {}
SearchFilterForUnconstrainedSearches (const lldb::TargetSP &target_sp) : SearchFilter(target_sp) {}
~SearchFilterForUnconstrainedSearches () {}
virtual bool
ModulePasses (const FileSpec &module_spec);
bool
ModulePasses (const FileSpec &module_spec) override;
virtual bool
ModulePasses (const lldb::ModuleSP &module_sp);
bool
ModulePasses (const lldb::ModuleSP &module_sp) override;
protected:
lldb::SearchFilterSP
DoCopyForBreakpoint (Breakpoint &breakpoint) override;
};
//----------------------------------------------------------------------
@ -301,32 +317,36 @@ class SearchFilterByModule :
const SearchFilterByModule&
operator=(const SearchFilterByModule& rhs);
virtual bool
ModulePasses (const lldb::ModuleSP &module_sp);
bool
ModulePasses (const lldb::ModuleSP &module_sp) override;
virtual bool
ModulePasses (const FileSpec &spec);
bool
ModulePasses (const FileSpec &spec) override;
virtual bool
AddressPasses (Address &address);
bool
AddressPasses (Address &address) override;
virtual bool
CompUnitPasses (FileSpec &fileSpec);
bool
CompUnitPasses (FileSpec &fileSpec) override;
virtual bool
CompUnitPasses (CompileUnit &compUnit);
bool
CompUnitPasses (CompileUnit &compUnit) override;
virtual void
GetDescription(Stream *s);
void
GetDescription(Stream *s) override;
virtual uint32_t
GetFilterRequiredItems ();
uint32_t
GetFilterRequiredItems () override;
virtual void
Dump (Stream *s) const;
void
Dump (Stream *s) const override;
virtual void
Search (Searcher &searcher);
void
Search (Searcher &searcher) override;
protected:
lldb::SearchFilterSP
DoCopyForBreakpoint (Breakpoint &breakpoint) override;
private:
FileSpec m_module_spec;
@ -358,32 +378,36 @@ class SearchFilterByModuleList :
const SearchFilterByModuleList&
operator=(const SearchFilterByModuleList& rhs);
virtual bool
ModulePasses (const lldb::ModuleSP &module_sp);
bool
ModulePasses (const lldb::ModuleSP &module_sp) override;
virtual bool
ModulePasses (const FileSpec &spec);
bool
ModulePasses (const FileSpec &spec) override;
virtual bool
AddressPasses (Address &address);
bool
AddressPasses (Address &address) override;
virtual bool
CompUnitPasses (FileSpec &fileSpec);
bool
CompUnitPasses (FileSpec &fileSpec) override;
virtual bool
CompUnitPasses (CompileUnit &compUnit);
bool
CompUnitPasses (CompileUnit &compUnit) override;
virtual void
GetDescription(Stream *s);
void
GetDescription(Stream *s) override;
virtual uint32_t
GetFilterRequiredItems ();
uint32_t
GetFilterRequiredItems () override;
virtual void
Dump (Stream *s) const;
void
Dump (Stream *s) const override;
virtual void
Search (Searcher &searcher);
void
Search (Searcher &searcher) override;
protected:
lldb::SearchFilterSP
DoCopyForBreakpoint (Breakpoint &breakpoint) override;
private:
FileSpecList m_module_spec_list;
@ -416,26 +440,30 @@ class SearchFilterByModuleListAndCU :
const SearchFilterByModuleListAndCU&
operator=(const SearchFilterByModuleListAndCU& rhs);
virtual bool
AddressPasses (Address &address);
bool
AddressPasses (Address &address) override;
virtual bool
CompUnitPasses (FileSpec &fileSpec);
bool
CompUnitPasses (FileSpec &fileSpec) override;
virtual bool
CompUnitPasses (CompileUnit &compUnit);
bool
CompUnitPasses (CompileUnit &compUnit) override;
virtual void
GetDescription(Stream *s);
void
GetDescription(Stream *s) override;
virtual uint32_t
GetFilterRequiredItems ();
uint32_t
GetFilterRequiredItems () override;
virtual void
Dump (Stream *s) const;
void
Dump (Stream *s) const override;
virtual void
Search (Searcher &searcher);
void
Search (Searcher &searcher) override;
protected:
lldb::SearchFilterSP
DoCopyForBreakpoint (Breakpoint &breakpoint) override;
private:
FileSpecList m_module_spec_list;

View File

@ -120,7 +120,8 @@ class Section :
lldb::offset_t file_offset,
lldb::offset_t file_size,
uint32_t log2align,
uint32_t flags);
uint32_t flags,
uint32_t target_byte_size = 1);
// Create a section that is a child of parent_section_sp
Section (const lldb::SectionSP &parent_section_sp, // NULL for top level sections, non-NULL for child sections
@ -134,7 +135,8 @@ class Section :
lldb::offset_t file_offset,
lldb::offset_t file_size,
uint32_t log2align,
uint32_t flags);
uint32_t flags,
uint32_t target_byte_size = 1);
~Section ();
@ -297,6 +299,12 @@ class Section :
m_log2align = align;
}
// Get the number of host bytes required to hold a target byte
uint32_t
GetTargetByteSize() const
{
return m_target_byte_size;
}
protected:
@ -317,6 +325,8 @@ class Section :
// hits unless the children contain the address.
m_encrypted:1, // Set to true if the contents are encrypted
m_thread_specific:1;// This section is thread specific
uint32_t m_target_byte_size; // Some architectures have non-8-bit byte size. This is specified as
// as a multiple number of a host bytes
private:
DISALLOW_COPY_AND_ASSIGN (Section);
};

View File

@ -46,6 +46,9 @@ class StreamString : public Stream
size_t
GetSize() const;
size_t
GetSizeOfLastLine () const;
std::string &
GetString();

View File

@ -0,0 +1,65 @@
//===-- ThreadSafeDenseMap.h ------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef liblldb_ThreadSafeDenseMap_h_
#define liblldb_ThreadSafeDenseMap_h_
// C Includes
// C++ Includes
// Other libraries and framework includes
#include "llvm/ADT/DenseMap.h"
// Project includes
#include "lldb/Host/Mutex.h"
namespace lldb_private {
template <typename _KeyType, typename _ValueType>
class ThreadSafeDenseMap
{
public:
typedef llvm::DenseMap<_KeyType,_ValueType> LLVMMapType;
ThreadSafeDenseMap(unsigned map_initial_capacity = 0,
Mutex::Type mutex_type = Mutex::eMutexTypeNormal) :
m_map(map_initial_capacity),
m_mutex(mutex_type)
{
}
void
Insert (_KeyType k, _ValueType v)
{
Mutex::Locker locker(m_mutex);
m_map.insert(std::make_pair(k,v));
}
void
Erase (_KeyType k)
{
Mutex::Locker locker(m_mutex);
m_map.erase(k);
}
_ValueType
Lookup (_KeyType k)
{
Mutex::Locker locker(m_mutex);
return m_map.lookup(k);
}
protected:
LLVMMapType m_map;
Mutex m_mutex;
};
} // namespace lldb_private
#endif // liblldb_ThreadSafeSTLMap_h_

View File

@ -16,6 +16,7 @@
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-defines.h"
#include "lldb/Host/Mutex.h"
namespace lldb_private {

View File

@ -14,9 +14,11 @@
// C++ Includes
#include <map>
#include <vector>
// Other libraries and framework includes
// Project includes
// Other libraries and framework includes
#include "llvm/ADT/SmallVector.h"
// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/Error.h"
@ -88,6 +90,7 @@ class ValueObject : public UserID
{
eExpressionPathScanEndReasonEndOfString = 1, // out of data to parse
eExpressionPathScanEndReasonNoSuchChild, // child element not found
eExpressionPathScanEndReasonNoSuchSyntheticChild, // (synthetic) child element not found
eExpressionPathScanEndReasonEmptyRangeNotAllowed, // [] only allowed for arrays
eExpressionPathScanEndReasonDotInsteadOfArrow, // . used when -> should be used
eExpressionPathScanEndReasonArrowInsteadOfDot, // -> used when . should be used
@ -129,6 +132,7 @@ class ValueObject : public UserID
eClearUserVisibleDataItemsLocation = 1u << 3,
eClearUserVisibleDataItemsDescription = 1u << 4,
eClearUserVisibleDataItemsSyntheticChildren = 1u << 5,
eClearUserVisibleDataItemsValidator = 1u << 6,
eClearUserVisibleDataItemsAllStrings = eClearUserVisibleDataItemsValue | eClearUserVisibleDataItemsSummary | eClearUserVisibleDataItemsLocation | eClearUserVisibleDataItemsDescription,
eClearUserVisibleDataItemsAll = 0xFFFF
};
@ -268,12 +272,6 @@ class ValueObject : public UserID
m_mod_id = new_id;
}
bool
IsFirstEvaluation () const
{
return m_first_update;
}
void
SetNeedsUpdate ()
{
@ -322,7 +320,6 @@ class ValueObject : public UserID
ProcessModID m_mod_id; // This is the stop id when this ValueObject was last evaluated.
ExecutionContextRef m_exe_ctx_ref;
bool m_needs_update;
bool m_first_update;
};
const EvaluationPoint &
@ -378,6 +375,9 @@ class ValueObject : public UserID
// this vends a TypeImpl that is useful at the SB API layer
virtual TypeImpl
GetTypeImpl ();
virtual bool
CanProvideValue ();
//------------------------------------------------------------------
// Subclasses must implement the functions below.
@ -607,6 +607,18 @@ class ValueObject : public UserID
GetSummaryAsCString (TypeSummaryImpl* summary_ptr,
std::string& destination);
bool
GetSummaryAsCString (std::string& destination,
const TypeSummaryOptions& options);
bool
GetSummaryAsCString (TypeSummaryImpl* summary_ptr,
std::string& destination,
const TypeSummaryOptions& options);
std::pair<TypeValidatorResult, std::string>
GetValidationStatus ();
const char *
GetObjectDescription ();
@ -700,6 +712,10 @@ class ValueObject : public UserID
virtual bool
IsSynthetic() { return false; }
lldb::ValueObjectSP
GetQualifiedRepresentationIfAvailable (lldb::DynamicValueType dynValue,
bool synthValue);
virtual lldb::ValueObjectSP
CreateConstantValue (const ConstString &name);
@ -752,6 +768,18 @@ class ValueObject : public UserID
return false;
}
virtual bool
DoesProvideSyntheticValue ()
{
return false;
}
bool
IsSyntheticChildrenGenerated ();
void
SetSyntheticChildrenGenerated (bool b);
virtual SymbolContextScope *
GetSymbolContextScope();
@ -767,12 +795,18 @@ class ValueObject : public UserID
const char* expression,
const ExecutionContext& exe_ctx);
static lldb::ValueObjectSP
CreateValueObjectFromExpression (const char* name,
const char* expression,
const ExecutionContext& exe_ctx,
const EvaluateExpressionOptions& options);
static lldb::ValueObjectSP
CreateValueObjectFromAddress (const char* name,
uint64_t address,
const ExecutionContext& exe_ctx,
ClangASTType type);
static lldb::ValueObjectSP
CreateValueObjectFromData (const char* name,
const DataExtractor& data,
@ -787,6 +821,9 @@ class ValueObject : public UserID
const DumpValueObjectOptions& options);
lldb::ValueObjectSP
Persist ();
// returns true if this is a char* or a char[]
// if it is a char* and check_pointer is true,
// it also checks that the pointer is valid
@ -794,7 +831,7 @@ class ValueObject : public UserID
IsCStringContainer (bool check_pointer = false);
size_t
ReadPointedString (Stream& s,
ReadPointedString (lldb::DataBufferSP& buffer_sp,
Error& error,
uint32_t max_length = 0,
bool honor_array = true,
@ -834,6 +871,10 @@ class ValueObject : public UserID
m_format = format;
}
virtual lldb::LanguageType
GetPreferredDisplayLanguage ();
lldb::TypeSummaryImplSP
GetSummaryFormat()
{
@ -848,6 +889,20 @@ class ValueObject : public UserID
ClearUserVisibleData(eClearUserVisibleDataItemsSummary);
}
lldb::TypeValidatorImplSP
GetValidator()
{
UpdateFormatsIfNeeded();
return m_type_validator_sp;
}
void
SetValidator(lldb::TypeValidatorImplSP format)
{
m_type_validator_sp = format;
ClearUserVisibleData(eClearUserVisibleDataItemsValidator);
}
void
SetValueFormat(lldb::TypeFormatImplSP format)
{
@ -1018,7 +1073,9 @@ class ValueObject : public UserID
std::string m_summary_str; // Cached summary string that will get cleared if/when the value is updated.
std::string m_object_desc_str; // Cached result of the "object printer". This differs from the summary
// in that the summary is consed up by us, the object_desc_string is builtin.
llvm::Optional<std::pair<TypeValidatorResult, std::string>> m_validation_result;
ClangASTType m_override_type;// If the type of the value object should be overridden, the type to impose.
ValueObjectManager *m_manager; // This object is managed by the root object (any ValueObject that gets created
@ -1043,9 +1100,12 @@ class ValueObject : public UserID
lldb::TypeSummaryImplSP m_type_summary_sp;
lldb::TypeFormatImplSP m_type_format_sp;
lldb::SyntheticChildrenSP m_synthetic_children_sp;
lldb::TypeValidatorImplSP m_type_validator_sp;
ProcessModID m_user_id_of_forced_summary;
AddressType m_address_type_of_ptr_or_ref_children;
llvm::SmallVector<uint8_t, 16> m_value_checksum;
bool m_value_is_valid:1,
m_value_did_change:1,
m_children_count_valid:1,
@ -1055,7 +1115,8 @@ class ValueObject : public UserID
m_is_bitfield_for_scalar:1,
m_is_child_at_offset:1,
m_is_getting_summary:1,
m_did_calculate_complete_objc_class_type:1;
m_did_calculate_complete_objc_class_type:1,
m_is_synthetic_children_generated:1;
friend class ClangExpressionDeclMap; // For GetValue
friend class ClangExpressionVariable; // For SetName
@ -1150,6 +1211,9 @@ class ValueObject : public UserID
GetLocationAsCStringImpl (const Value& value,
const DataExtractor& data);
bool
IsChecksumEmpty ();
private:
//------------------------------------------------------------------
// For ValueObject only

View File

@ -106,6 +106,7 @@ class ValueObjectChild : public ValueObject
protected:
friend class ValueObject;
friend class ValueObjectConstResult;
friend class ValueObjectConstResultImpl;
ValueObjectChild (ValueObject &parent,
const ClangASTType &clang_type,
const ConstString &name,

View File

@ -59,7 +59,8 @@ class ValueObjectConstResult : public ValueObject
static lldb::ValueObjectSP
Create (ExecutionContextScope *exe_scope,
Value &value,
const ConstString &name);
const ConstString &name,
Module* module = nullptr);
// When an expression fails to evaluate, we return an error
static lldb::ValueObjectSP
@ -126,6 +127,9 @@ class ValueObjectConstResult : public ValueObject
virtual lldb::ValueObjectSP
GetDynamicValue (lldb::DynamicValueType valueType);
virtual lldb::LanguageType
GetPreferredDisplayLanguage ();
protected:
virtual bool
@ -169,7 +173,8 @@ class ValueObjectConstResult : public ValueObject
ValueObjectConstResult (ExecutionContextScope *exe_scope,
const Value &value,
const ConstString &name);
const ConstString &name,
Module* module = nullptr);
ValueObjectConstResult (ExecutionContextScope *exe_scope,
const Error& error);

View File

@ -47,13 +47,6 @@ class ValueObjectConstResultImpl
lldb::ValueObjectSP
AddressOf (Error &error);
bool
NeedsDerefOnTarget()
{
m_impl_backend->UpdateValueIfNeeded(false);
return (m_impl_backend->GetValue().GetValueType() == Value::eValueTypeHostAddress);
}
lldb::addr_t
GetLiveAddress()
{
@ -68,9 +61,6 @@ class ValueObjectConstResultImpl
m_live_address_type = address_type;
}
lldb::ValueObjectSP
DerefOnTarget();
virtual lldb::addr_t
GetAddressOf (bool scalar_is_load_address = true,
AddressType *address_type = NULL);

View File

@ -12,10 +12,10 @@
// C Includes
// C++ Includes
#include <map>
#include <vector>
// Other libraries and framework includes
// Project includes
#include "lldb/Core/ThreadSafeSTLMap.h"
#include "lldb/Core/ValueObject.h"
namespace lldb_private {
@ -132,11 +132,12 @@ class ValueObjectSynthetic : public ValueObject
GetNonSyntheticValue ();
virtual bool
ResolveValue (Scalar &scalar)
CanProvideValue ();
virtual bool
DoesProvideSyntheticValue ()
{
if (m_parent)
return m_parent->ResolveValue(scalar);
return false;
return (UpdateValueIfNeeded(), m_provides_value == eLazyBoolYes);
}
protected:
@ -153,8 +154,8 @@ class ValueObjectSynthetic : public ValueObject
lldb::SyntheticChildrenSP m_synth_sp;
std::unique_ptr<SyntheticChildrenFrontEnd> m_synth_filter_ap;
typedef std::map<uint32_t, ValueObject*> ByIndexMap;
typedef std::map<const char*, uint32_t> NameToIndexMap;
typedef ThreadSafeSTLMap<uint32_t, ValueObject*> ByIndexMap;
typedef ThreadSafeSTLMap<const char*, uint32_t> NameToIndexMap;
typedef ByIndexMap::iterator ByIndexIterator;
typedef NameToIndexMap::iterator NameToIndexIterator;
@ -167,12 +168,14 @@ class ValueObjectSynthetic : public ValueObject
LazyBool m_might_have_children;
LazyBool m_provides_value;
private:
friend class ValueObject;
ValueObjectSynthetic (ValueObject &parent, lldb::SyntheticChildrenSP filter);
void
CopyParentData ();
CopyValueData (ValueObject *source);
//------------------------------------------------------------------
// For ValueObject only

View File

@ -61,419 +61,139 @@ namespace lldb_private {
GetOSXEpoch ();
bool
Char16StringSummaryProvider (ValueObject& valobj, Stream& stream); // char16_t* and unichar*
FunctionPointerSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // C++ function pointer
bool
Char32StringSummaryProvider (ValueObject& valobj, Stream& stream); // char32_t*
Char16StringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // char16_t* and unichar*
bool
WCharStringSummaryProvider (ValueObject& valobj, Stream& stream); // wchar_t*
Char32StringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // char32_t*
bool
Char16SummaryProvider (ValueObject& valobj, Stream& stream); // char16_t and unichar
WCharStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // wchar_t*
bool
Char32SummaryProvider (ValueObject& valobj, Stream& stream); // char32_t
Char16SummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // char16_t and unichar
bool
WCharSummaryProvider (ValueObject& valobj, Stream& stream); // wchar_t
Char32SummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // char32_t
bool
LibcxxStringSummaryProvider (ValueObject& valobj, Stream& stream); // libc++ std::string
WCharSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // wchar_t
bool
LibcxxStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // libc++ std::string
bool
LibcxxWStringSummaryProvider (ValueObject& valobj, Stream& stream); // libc++ std::wstring
LibcxxWStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // libc++ std::wstring
bool
LibcxxSmartPointerSummaryProvider (ValueObject& valobj, Stream& stream); // libc++ std::shared_ptr<> and std::weak_ptr<>
LibcxxSmartPointerSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // libc++ std::shared_ptr<> and std::weak_ptr<>
bool
ObjCClassSummaryProvider (ValueObject& valobj, Stream& stream);
ObjCClassSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
SyntheticChildrenFrontEnd* ObjCClassSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
template<bool name_entries>
bool
NSDictionarySummaryProvider (ValueObject& valobj, Stream& stream);
NSDictionarySummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
bool
NSIndexSetSummaryProvider (ValueObject& valobj, Stream& stream);
NSIndexSetSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
bool
NSArraySummaryProvider (ValueObject& valobj, Stream& stream);
NSArraySummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
template<bool cf_style>
bool
NSSetSummaryProvider (ValueObject& valobj, Stream& stream);
NSSetSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
template<bool needs_at>
bool
NSDataSummaryProvider (ValueObject& valobj, Stream& stream);
NSDataSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
bool
NSNumberSummaryProvider (ValueObject& valobj, Stream& stream);
NSNumberSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
bool
NSNotificationSummaryProvider (ValueObject& valobj, Stream& stream);
NSNotificationSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
bool
NSTimeZoneSummaryProvider (ValueObject& valobj, Stream& stream);
NSTimeZoneSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
bool
NSMachPortSummaryProvider (ValueObject& valobj, Stream& stream);
NSMachPortSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
bool
CFBagSummaryProvider (ValueObject& valobj, Stream& stream);
CFBagSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
bool
CFBinaryHeapSummaryProvider (ValueObject& valobj, Stream& stream);
CFBinaryHeapSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
bool
CFBitVectorSummaryProvider (ValueObject& valobj, Stream& stream);
CFBitVectorSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
bool
NSDateSummaryProvider (ValueObject& valobj, Stream& stream);
NSDateSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
bool
CFAbsoluteTimeSummaryProvider (ValueObject& valobj, Stream& stream);
CFAbsoluteTimeSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
bool
NSBundleSummaryProvider (ValueObject& valobj, Stream& stream);
NSBundleSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
bool
NSStringSummaryProvider (ValueObject& valobj, Stream& stream);
NSStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
bool
NSTaggedString_SummaryProvider (ObjCLanguageRuntime::ClassDescriptorSP descriptor, Stream& stream);
bool
NSAttributedStringSummaryProvider (ValueObject& valobj, Stream& stream);
NSAttributedStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
bool
NSMutableAttributedStringSummaryProvider (ValueObject& valobj, Stream& stream);
NSMutableAttributedStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
bool
NSURLSummaryProvider (ValueObject& valobj, Stream& stream);
NSURLSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
bool
ObjCBOOLSummaryProvider (ValueObject& valobj, Stream& stream);
ObjCBOOLSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
template <bool is_sel_ptr>
bool
ObjCSELSummaryProvider (ValueObject& valobj, Stream& stream);
ObjCSELSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
bool
RuntimeSpecificDescriptionSummaryProvider (ValueObject& valobj, Stream& stream);
RuntimeSpecificDescriptionSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
extern template bool
NSDictionarySummaryProvider<true> (ValueObject&, Stream&) ;
NSDictionarySummaryProvider<true> (ValueObject&, Stream&, const TypeSummaryOptions&) ;
extern template bool
NSDictionarySummaryProvider<false> (ValueObject&, Stream&) ;
NSDictionarySummaryProvider<false> (ValueObject&, Stream&, const TypeSummaryOptions&) ;
extern template bool
NSDataSummaryProvider<true> (ValueObject&, Stream&) ;
NSDataSummaryProvider<true> (ValueObject&, Stream&, const TypeSummaryOptions&) ;
extern template bool
NSDataSummaryProvider<false> (ValueObject&, Stream&) ;
NSDataSummaryProvider<false> (ValueObject&, Stream&, const TypeSummaryOptions&) ;
extern template bool
ObjCSELSummaryProvider<true> (ValueObject&, Stream&);
ObjCSELSummaryProvider<true> (ValueObject&, Stream&, const TypeSummaryOptions&);
extern template bool
ObjCSELSummaryProvider<false> (ValueObject&, Stream&);
ObjCSELSummaryProvider<false> (ValueObject&, Stream&, const TypeSummaryOptions&);
SyntheticChildrenFrontEnd* NSArraySyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
class NSDictionaryISyntheticFrontEnd : public SyntheticChildrenFrontEnd
{
private:
struct DataDescriptor_32
{
uint32_t _used : 26;
uint32_t _szidx : 6;
};
struct DataDescriptor_64
{
uint64_t _used : 58;
uint32_t _szidx : 6;
};
struct DictionaryItemDescriptor
{
lldb::addr_t key_ptr;
lldb::addr_t val_ptr;
lldb::ValueObjectSP valobj_sp;
};
public:
NSDictionaryISyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
virtual size_t
CalculateNumChildren ();
virtual lldb::ValueObjectSP
GetChildAtIndex (size_t idx);
virtual bool
Update();
virtual bool
MightHaveChildren ();
virtual size_t
GetIndexOfChildWithName (const ConstString &name);
virtual
~NSDictionaryISyntheticFrontEnd ();
private:
ExecutionContextRef m_exe_ctx_ref;
uint8_t m_ptr_size;
lldb::ByteOrder m_order;
DataDescriptor_32 *m_data_32;
DataDescriptor_64 *m_data_64;
lldb::addr_t m_data_ptr;
ClangASTType m_pair_type;
std::vector<DictionaryItemDescriptor> m_children;
};
class NSDictionaryMSyntheticFrontEnd : public SyntheticChildrenFrontEnd
{
private:
struct DataDescriptor_32
{
uint32_t _used : 26;
uint32_t _kvo : 1;
uint32_t _size;
uint32_t _mutations;
uint32_t _objs_addr;
uint32_t _keys_addr;
};
struct DataDescriptor_64
{
uint64_t _used : 58;
uint32_t _kvo : 1;
uint64_t _size;
uint64_t _mutations;
uint64_t _objs_addr;
uint64_t _keys_addr;
};
struct DictionaryItemDescriptor
{
lldb::addr_t key_ptr;
lldb::addr_t val_ptr;
lldb::ValueObjectSP valobj_sp;
};
public:
NSDictionaryMSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
virtual size_t
CalculateNumChildren ();
virtual lldb::ValueObjectSP
GetChildAtIndex (size_t idx);
virtual bool
Update();
virtual bool
MightHaveChildren ();
virtual size_t
GetIndexOfChildWithName (const ConstString &name);
virtual
~NSDictionaryMSyntheticFrontEnd ();
private:
ExecutionContextRef m_exe_ctx_ref;
uint8_t m_ptr_size;
lldb::ByteOrder m_order;
DataDescriptor_32 *m_data_32;
DataDescriptor_64 *m_data_64;
ClangASTType m_pair_type;
std::vector<DictionaryItemDescriptor> m_children;
};
class NSDictionaryCodeRunningSyntheticFrontEnd : public SyntheticChildrenFrontEnd
{
public:
NSDictionaryCodeRunningSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
virtual size_t
CalculateNumChildren ();
virtual lldb::ValueObjectSP
GetChildAtIndex (size_t idx);
virtual bool
Update();
virtual bool
MightHaveChildren ();
virtual size_t
GetIndexOfChildWithName (const ConstString &name);
virtual
~NSDictionaryCodeRunningSyntheticFrontEnd ();
};
SyntheticChildrenFrontEnd* NSDictionarySyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
class NSSetISyntheticFrontEnd : public SyntheticChildrenFrontEnd
{
private:
struct DataDescriptor_32
{
uint32_t _used : 26;
uint32_t _szidx : 6;
};
struct DataDescriptor_64
{
uint64_t _used : 58;
uint32_t _szidx : 6;
};
struct SetItemDescriptor
{
lldb::addr_t item_ptr;
lldb::ValueObjectSP valobj_sp;
};
public:
NSSetISyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
virtual size_t
CalculateNumChildren ();
virtual lldb::ValueObjectSP
GetChildAtIndex (size_t idx);
virtual bool
Update();
virtual bool
MightHaveChildren ();
virtual size_t
GetIndexOfChildWithName (const ConstString &name);
virtual
~NSSetISyntheticFrontEnd ();
private:
ExecutionContextRef m_exe_ctx_ref;
uint8_t m_ptr_size;
DataDescriptor_32 *m_data_32;
DataDescriptor_64 *m_data_64;
lldb::addr_t m_data_ptr;
std::vector<SetItemDescriptor> m_children;
};
class NSOrderedSetSyntheticFrontEnd : public SyntheticChildrenFrontEnd
{
private:
public:
NSOrderedSetSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
virtual size_t
CalculateNumChildren ();
virtual lldb::ValueObjectSP
GetChildAtIndex (size_t idx);
virtual bool
Update();
virtual bool
MightHaveChildren ();
virtual size_t
GetIndexOfChildWithName (const ConstString &name);
virtual
~NSOrderedSetSyntheticFrontEnd ();
private:
uint32_t m_count;
std::map<uint32_t,lldb::ValueObjectSP> m_children;
};
class NSSetMSyntheticFrontEnd : public SyntheticChildrenFrontEnd
{
private:
struct DataDescriptor_32
{
uint32_t _used : 26;
uint32_t _size;
uint32_t _mutations;
uint32_t _objs_addr;
};
struct DataDescriptor_64
{
uint64_t _used : 58;
uint64_t _size;
uint64_t _mutations;
uint64_t _objs_addr;
};
struct SetItemDescriptor
{
lldb::addr_t item_ptr;
lldb::ValueObjectSP valobj_sp;
};
public:
NSSetMSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
virtual size_t
CalculateNumChildren ();
virtual lldb::ValueObjectSP
GetChildAtIndex (size_t idx);
virtual bool
Update();
virtual bool
MightHaveChildren ();
virtual size_t
GetIndexOfChildWithName (const ConstString &name);
virtual
~NSSetMSyntheticFrontEnd ();
private:
ExecutionContextRef m_exe_ctx_ref;
uint8_t m_ptr_size;
DataDescriptor_32 *m_data_32;
DataDescriptor_64 *m_data_64;
std::vector<SetItemDescriptor> m_children;
};
class NSSetCodeRunningSyntheticFrontEnd : public SyntheticChildrenFrontEnd
{
public:
NSSetCodeRunningSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
virtual size_t
CalculateNumChildren ();
virtual lldb::ValueObjectSP
GetChildAtIndex (size_t idx);
virtual bool
Update();
virtual bool
MightHaveChildren ();
virtual size_t
GetIndexOfChildWithName (const ConstString &name);
virtual
~NSSetCodeRunningSyntheticFrontEnd ();
};
SyntheticChildrenFrontEnd* NSSetSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
SyntheticChildrenFrontEnd* NSIndexPathSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
class LibcxxVectorBoolSyntheticFrontEnd : public SyntheticChildrenFrontEnd
{
public:
@ -507,7 +227,7 @@ namespace lldb_private {
SyntheticChildrenFrontEnd* LibcxxVectorBoolSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
bool
LibcxxContainerSummaryProvider (ValueObject& valobj, Stream& stream);
LibcxxContainerSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
class LibstdcppVectorBoolSyntheticFrontEnd : public SyntheticChildrenFrontEnd
{
@ -665,148 +385,16 @@ namespace lldb_private {
SyntheticChildrenFrontEnd* LibcxxSharedPtrSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
class LibcxxStdVectorSyntheticFrontEnd : public SyntheticChildrenFrontEnd
{
public:
LibcxxStdVectorSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
virtual size_t
CalculateNumChildren ();
virtual lldb::ValueObjectSP
GetChildAtIndex (size_t idx);
virtual bool
Update();
virtual bool
MightHaveChildren ();
virtual size_t
GetIndexOfChildWithName (const ConstString &name);
virtual
~LibcxxStdVectorSyntheticFrontEnd ();
private:
ValueObject* m_start;
ValueObject* m_finish;
ClangASTType m_element_type;
uint32_t m_element_size;
std::map<size_t,lldb::ValueObjectSP> m_children;
};
SyntheticChildrenFrontEnd* LibcxxStdVectorSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
class LibcxxStdListSyntheticFrontEnd : public SyntheticChildrenFrontEnd
{
public:
LibcxxStdListSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
virtual size_t
CalculateNumChildren ();
virtual lldb::ValueObjectSP
GetChildAtIndex (size_t idx);
virtual bool
Update();
virtual bool
MightHaveChildren ();
virtual size_t
GetIndexOfChildWithName (const ConstString &name);
virtual
~LibcxxStdListSyntheticFrontEnd ();
private:
bool
HasLoop();
size_t m_list_capping_size;
static const bool g_use_loop_detect = true;
lldb::addr_t m_node_address;
ValueObject* m_head;
ValueObject* m_tail;
ClangASTType m_element_type;
size_t m_count;
std::map<size_t,lldb::ValueObjectSP> m_children;
};
SyntheticChildrenFrontEnd* LibcxxStdListSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
class LibcxxStdMapSyntheticFrontEnd : public SyntheticChildrenFrontEnd
{
public:
LibcxxStdMapSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
virtual size_t
CalculateNumChildren ();
virtual lldb::ValueObjectSP
GetChildAtIndex (size_t idx);
virtual bool
Update();
virtual bool
MightHaveChildren ();
virtual size_t
GetIndexOfChildWithName (const ConstString &name);
virtual
~LibcxxStdMapSyntheticFrontEnd ();
private:
bool
GetDataType();
void
GetValueOffset (const lldb::ValueObjectSP& node);
ValueObject* m_tree;
ValueObject* m_root_node;
ClangASTType m_element_type;
uint32_t m_skip_size;
size_t m_count;
std::map<size_t,lldb::ValueObjectSP> m_children;
};
SyntheticChildrenFrontEnd* LibcxxStdMapSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
class LibcxxStdUnorderedMapSyntheticFrontEnd : public SyntheticChildrenFrontEnd
{
public:
LibcxxStdUnorderedMapSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
virtual size_t
CalculateNumChildren ();
virtual lldb::ValueObjectSP
GetChildAtIndex (size_t idx);
virtual bool
Update();
virtual bool
MightHaveChildren ();
virtual size_t
GetIndexOfChildWithName (const ConstString &name);
virtual
~LibcxxStdUnorderedMapSyntheticFrontEnd ();
private:
ValueObject* m_tree;
size_t m_num_elements;
ValueObject* m_next_element;
std::map<size_t,lldb::ValueObjectSP> m_children;
std::vector<std::pair<ValueObject*, uint64_t> > m_elements_cache;
};
SyntheticChildrenFrontEnd* LibcxxStdUnorderedMapSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
SyntheticChildrenFrontEnd* LibcxxInitializerListSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
} // namespace formatters
} // namespace lldb_private

View File

@ -72,6 +72,13 @@ class DataVisualization
lldb::DynamicValueType use_dynamic);
#endif
static lldb::TypeValidatorImplSP
GetValidator (ValueObject& valobj,
lldb::DynamicValueType use_dynamic);
static lldb::TypeValidatorImplSP
GetValidatorForType (lldb::TypeNameSpecifierImplSP type_sp);
static bool
AnyMatches(ConstString type_name,
TypeCategoryImpl::FormatCategoryItems items = TypeCategoryImpl::ALL_ITEM_TYPES,
@ -136,6 +143,12 @@ class DataVisualization
static void
Disable (const lldb::TypeCategoryImplSP& category);
static void
EnableStar ();
static void
DisableStar ();
static void
LoopThrough (FormatManager::CategoryCallback callback, void* callback_baton);

View File

@ -31,16 +31,19 @@ class FormatCache
bool m_format_cached : 1;
bool m_summary_cached : 1;
bool m_synthetic_cached : 1;
bool m_validator_cached : 1;
lldb::TypeFormatImplSP m_format_sp;
lldb::TypeSummaryImplSP m_summary_sp;
lldb::SyntheticChildrenSP m_synthetic_sp;
lldb::TypeValidatorImplSP m_validator_sp;
public:
Entry ();
Entry (lldb::TypeFormatImplSP);
Entry (lldb::TypeSummaryImplSP);
Entry (lldb::SyntheticChildrenSP);
Entry (lldb::TypeFormatImplSP,lldb::TypeSummaryImplSP,lldb::SyntheticChildrenSP);
Entry (lldb::TypeValidatorImplSP);
Entry (lldb::TypeFormatImplSP,lldb::TypeSummaryImplSP,lldb::SyntheticChildrenSP,lldb::TypeValidatorImplSP);
bool
IsFormatCached ();
@ -51,6 +54,9 @@ class FormatCache
bool
IsSyntheticCached ();
bool
IsValidatorCached ();
lldb::TypeFormatImplSP
GetFormat ();
@ -60,6 +66,9 @@ class FormatCache
lldb::SyntheticChildrenSP
GetSynthetic ();
lldb::TypeValidatorImplSP
GetValidator ();
void
SetFormat (lldb::TypeFormatImplSP);
@ -68,6 +77,9 @@ class FormatCache
void
SetSynthetic (lldb::SyntheticChildrenSP);
void
SetValidator (lldb::TypeValidatorImplSP);
};
typedef std::map<ConstString,Entry> CacheMap;
CacheMap m_map;
@ -91,6 +103,9 @@ class FormatCache
bool
GetSynthetic (const ConstString& type,lldb::SyntheticChildrenSP& synthetic_sp);
bool
GetValidator (const ConstString& type,lldb::TypeValidatorImplSP& summary_sp);
void
SetFormat (const ConstString& type,lldb::TypeFormatImplSP& format_sp);
@ -100,6 +115,9 @@ class FormatCache
void
SetSynthetic (const ConstString& type,lldb::SyntheticChildrenSP& synthetic_sp);
void
SetValidator (const ConstString& type,lldb::TypeValidatorImplSP& synthetic_sp);
void
Clear ();

View File

@ -86,6 +86,18 @@ class FormatManager : public IFormatChangeListener
m_categories_map.Disable(category);
}
void
EnableAllCategories ()
{
m_categories_map.EnableAllCategories ();
}
void
DisableAllCategories ()
{
m_categories_map.DisableAllCategories ();
}
bool
DeleteCategory (const ConstString& category_name)
{
@ -148,6 +160,9 @@ class FormatManager : public IFormatChangeListener
GetSyntheticChildrenForType (lldb::TypeNameSpecifierImplSP type_sp);
#endif
lldb::TypeValidatorImplSP
GetValidatorForType (lldb::TypeNameSpecifierImplSP type_sp);
lldb::TypeFormatImplSP
GetFormat (ValueObject& valobj,
lldb::DynamicValueType use_dynamic);
@ -162,6 +177,10 @@ class FormatManager : public IFormatChangeListener
lldb::DynamicValueType use_dynamic);
#endif
lldb::TypeValidatorImplSP
GetValidator (ValueObject& valobj,
lldb::DynamicValueType use_dynamic);
bool
AnyMatches (ConstString type_name,
TypeCategoryImpl::FormatCategoryItems items = TypeCategoryImpl::ALL_ITEM_TYPES,
@ -272,6 +291,7 @@ class FormatManager : public IFormatChangeListener
HardcodedFormatterFinders<TypeFormatImpl> m_hardcoded_formats;
HardcodedFormatterFinders<TypeSummaryImpl> m_hardcoded_summaries;
HardcodedFormatterFinders<SyntheticChildren> m_hardcoded_synthetics;
HardcodedFormatterFinders<TypeValidatorImpl> m_hardcoded_validators;
lldb::TypeFormatImplSP
GetHardcodedFormat (ValueObject&,lldb::DynamicValueType);
@ -282,6 +302,9 @@ class FormatManager : public IFormatChangeListener
lldb::SyntheticChildrenSP
GetHardcodedSyntheticChildren (ValueObject&,lldb::DynamicValueType);
lldb::TypeValidatorImplSP
GetHardcodedValidator (ValueObject&,lldb::DynamicValueType);
TypeCategoryMap&
GetCategories ()
{

View File

@ -29,6 +29,7 @@
#include "lldb/DataFormatters/TypeFormat.h"
#include "lldb/DataFormatters/TypeSummary.h"
#include "lldb/DataFormatters/TypeSynthetic.h"
#include "lldb/DataFormatters/TypeValidator.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/ClangASTType.h"
@ -38,6 +39,8 @@
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/TargetList.h"
#include "lldb/Utility/StringLexer.h"
namespace lldb_private {
// this file (and its. cpp) contain the low-level implementation of LLDB Data Visualization
@ -58,18 +61,6 @@ class IFormatChangeListener
};
static inline bool
IsWhitespace (char c)
{
return ( (c == ' ') || (c == '\t') || (c == '\v') || (c == '\f') );
}
static inline bool
HasPrefix (const char* str1, const char* str2)
{
return ( ::strstr(str1, str2) == str1 );
}
// if the user tries to add formatters for, say, "struct Foo"
// those will not match any type because of the way we strip qualifiers from typenames
// this method looks for the case where the user is adding a "class","struct","enum" or "union" Foo
@ -77,32 +68,23 @@ HasPrefix (const char* str1, const char* str2)
static inline ConstString
GetValidTypeName_Impl (const ConstString& type)
{
int strip_len = 0;
if ((bool)type == false)
if (type.IsEmpty())
return type;
const char* type_cstr = type.AsCString();
std::string type_cstr(type.AsCString());
lldb_utility::StringLexer type_lexer(type_cstr);
if ( HasPrefix(type_cstr, "class ") )
strip_len = 6;
else if ( HasPrefix(type_cstr, "enum ") )
strip_len = 5;
else if ( HasPrefix(type_cstr, "struct ") )
strip_len = 7;
else if ( HasPrefix(type_cstr, "union ") )
strip_len = 6;
type_lexer.AdvanceIf("class ");
type_lexer.AdvanceIf("enum ");
type_lexer.AdvanceIf("struct ");
type_lexer.AdvanceIf("union ");
if (strip_len == 0)
return type;
type_cstr += strip_len;
while (IsWhitespace(*type_cstr) && ++type_cstr)
while (type_lexer.NextIf({' ','\t','\v','\f'}).first)
;
return ConstString(type_cstr);
return ConstString(type_lexer.GetUnlexed());
}
template<typename KeyType, typename ValueType>
class FormattersContainer;
@ -267,8 +249,7 @@ class FormattersContainer
FormattersContainer(std::string name,
IFormatChangeListener* lst) :
m_format_map(lst),
m_name(name),
m_id_cs(ConstString("id"))
m_name(name)
{
}
@ -345,15 +326,11 @@ class FormattersContainer
}
protected:
BackEndType m_format_map;
std::string m_name;
DISALLOW_COPY_AND_ASSIGN(FormattersContainer);
ConstString m_id_cs;
void
Add_Impl (const MapKeyType &type, const MapValueType& entry, lldb::RegularExpressionSP *dummy)
{

View File

@ -0,0 +1,290 @@
//===-- StringPrinter.h -----------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef liblldb_StringPrinter_h_
#define liblldb_StringPrinter_h_
#include "lldb/lldb-forward.h"
#include "lldb/Core/DataExtractor.h"
namespace lldb_private {
namespace formatters
{
enum class StringElementType {
ASCII,
UTF8,
UTF16,
UTF32
};
class ReadStringAndDumpToStreamOptions
{
public:
ReadStringAndDumpToStreamOptions () :
m_location(0),
m_process_sp(),
m_stream(NULL),
m_prefix_token(0),
m_quote('"'),
m_source_size(0),
m_needs_zero_termination(true),
m_escape_non_printables(true),
m_ignore_max_length(false)
{
}
ReadStringAndDumpToStreamOptions (ValueObject& valobj);
ReadStringAndDumpToStreamOptions&
SetLocation (uint64_t l)
{
m_location = l;
return *this;
}
uint64_t
GetLocation () const
{
return m_location;
}
ReadStringAndDumpToStreamOptions&
SetProcessSP (lldb::ProcessSP p)
{
m_process_sp = p;
return *this;
}
lldb::ProcessSP
GetProcessSP () const
{
return m_process_sp;
}
ReadStringAndDumpToStreamOptions&
SetStream (Stream* s)
{
m_stream = s;
return *this;
}
Stream*
GetStream () const
{
return m_stream;
}
ReadStringAndDumpToStreamOptions&
SetPrefixToken (char p)
{
m_prefix_token = p;
return *this;
}
char
GetPrefixToken () const
{
return m_prefix_token;
}
ReadStringAndDumpToStreamOptions&
SetQuote (char q)
{
m_quote = q;
return *this;
}
char
GetQuote () const
{
return m_quote;
}
ReadStringAndDumpToStreamOptions&
SetSourceSize (uint32_t s)
{
m_source_size = s;
return *this;
}
uint32_t
GetSourceSize () const
{
return m_source_size;
}
ReadStringAndDumpToStreamOptions&
SetNeedsZeroTermination (bool z)
{
m_needs_zero_termination = z;
return *this;
}
bool
GetNeedsZeroTermination () const
{
return m_needs_zero_termination;
}
ReadStringAndDumpToStreamOptions&
SetEscapeNonPrintables (bool e)
{
m_escape_non_printables = e;
return *this;
}
bool
GetEscapeNonPrintables () const
{
return m_escape_non_printables;
}
ReadStringAndDumpToStreamOptions&
SetIgnoreMaxLength (bool e)
{
m_ignore_max_length = e;
return *this;
}
bool
GetIgnoreMaxLength () const
{
return m_ignore_max_length;
}
private:
uint64_t m_location;
lldb::ProcessSP m_process_sp;
Stream* m_stream;
char m_prefix_token;
char m_quote;
uint32_t m_source_size;
bool m_needs_zero_termination;
bool m_escape_non_printables;
bool m_ignore_max_length;
};
class ReadBufferAndDumpToStreamOptions
{
public:
ReadBufferAndDumpToStreamOptions () :
m_data(),
m_stream(NULL),
m_prefix_token(0),
m_quote('"'),
m_source_size(0),
m_escape_non_printables(true)
{
}
ReadBufferAndDumpToStreamOptions (ValueObject& valobj);
ReadBufferAndDumpToStreamOptions&
SetData (DataExtractor d)
{
m_data = d;
return *this;
}
lldb_private::DataExtractor
GetData () const
{
return m_data;
}
ReadBufferAndDumpToStreamOptions&
SetStream (Stream* s)
{
m_stream = s;
return *this;
}
Stream*
GetStream () const
{
return m_stream;
}
ReadBufferAndDumpToStreamOptions&
SetPrefixToken (char p)
{
m_prefix_token = p;
return *this;
}
char
GetPrefixToken () const
{
return m_prefix_token;
}
ReadBufferAndDumpToStreamOptions&
SetQuote (char q)
{
m_quote = q;
return *this;
}
char
GetQuote () const
{
return m_quote;
}
ReadBufferAndDumpToStreamOptions&
SetSourceSize (uint32_t s)
{
m_source_size = s;
return *this;
}
uint32_t
GetSourceSize () const
{
return m_source_size;
}
ReadBufferAndDumpToStreamOptions&
SetEscapeNonPrintables (bool e)
{
m_escape_non_printables = e;
return *this;
}
bool
GetEscapeNonPrintables () const
{
return m_escape_non_printables;
}
private:
DataExtractor m_data;
Stream* m_stream;
char m_prefix_token;
char m_quote;
uint32_t m_source_size;
bool m_escape_non_printables;
};
template <StringElementType element_type>
bool
ReadStringAndDumpToStream (ReadStringAndDumpToStreamOptions options);
template <StringElementType element_type>
bool
ReadBufferAndDumpToStream (ReadBufferAndDumpToStreamOptions options);
} // namespace formatters
} // namespace lldb_private
#endif // liblldb_StringPrinter_h_

View File

@ -71,6 +71,7 @@ namespace lldb_private {
typedef FormatterContainerPair<TypeFormatImpl> FormatContainer;
typedef FormatterContainerPair<TypeSummaryImpl> SummaryContainer;
typedef FormatterContainerPair<TypeFilterImpl> FilterContainer;
typedef FormatterContainerPair<TypeValidatorImpl> ValidatorContainer;
#ifndef LLDB_DISABLE_PYTHON
typedef FormatterContainerPair<ScriptedSyntheticChildren> SynthContainer;
@ -94,6 +95,9 @@ namespace lldb_private {
typedef SynthContainer::RegexMatchContainerSP RegexSynthContainerSP;
#endif // #ifndef LLDB_DISABLE_PYTHON
typedef ValidatorContainer::ExactMatchContainerSP ValidatorContainerSP;
typedef ValidatorContainer::RegexMatchContainerSP RegexValidatorContainerSP;
TypeCategoryImpl (IFormatChangeListener* clist,
ConstString name);
@ -147,6 +151,9 @@ namespace lldb_private {
GetSyntheticForType (lldb::TypeNameSpecifierImplSP type_sp);
#endif
ValidatorContainer::MapValueType
GetValidatorForType (lldb::TypeNameSpecifierImplSP type_sp);
lldb::TypeNameSpecifierImplSP
GetTypeNameSpecifierForFormatAtIndex (size_t index);
@ -183,9 +190,26 @@ namespace lldb_private {
lldb::TypeNameSpecifierImplSP
GetTypeNameSpecifierForSyntheticAtIndex (size_t index);
#endif // #ifndef LLDB_DISABLE_PYTHON
ValidatorContainerSP
GetTypeValidatorsContainer ()
{
return m_validator_cont.GetExactMatch();
}
RegexValidatorContainerSP
GetRegexTypeValidatorsContainer ()
{
return m_validator_cont.GetRegexMatch();
}
ValidatorContainer::MapValueType
GetValidatorAtIndex (size_t index);
lldb::TypeNameSpecifierImplSP
GetTypeNameSpecifierForValidatorAtIndex (size_t index);
bool
IsEnabled () const
{
@ -219,6 +243,12 @@ namespace lldb_private {
lldb::SyntheticChildrenSP& entry,
uint32_t* reason = NULL);
bool
Get (ValueObject& valobj,
const FormattersMatchVector& candidates,
lldb::TypeValidatorImplSP& entry,
uint32_t* reason = NULL);
void
Clear (FormatCategoryItems items = ALL_ITEM_TYPES);
@ -246,14 +276,12 @@ namespace lldb_private {
private:
FormatContainer m_format_cont;
SummaryContainer m_summary_cont;
FilterContainer m_filter_cont;
#ifndef LLDB_DISABLE_PYTHON
SynthContainer m_synth_cont;
#endif // #ifndef LLDB_DISABLE_PYTHON
ValidatorContainer m_validator_cont;
bool m_enabled;
@ -274,6 +302,18 @@ namespace lldb_private {
Enable(false, UINT32_MAX);
}
uint32_t
GetLastEnabledPosition ()
{
return m_enabled_position;
}
void
SetEnabledPosition (uint32_t p)
{
m_enabled_position = p;
}
friend class TypeCategoryMap;
friend class FormattersContainer<ConstString, TypeFormatImpl>;
@ -289,6 +329,9 @@ namespace lldb_private {
friend class FormattersContainer<ConstString, ScriptedSyntheticChildren>;
friend class FormattersContainer<lldb::RegularExpressionSP, ScriptedSyntheticChildren>;
#endif // #ifndef LLDB_DISABLE_PYTHON
friend class FormattersContainer<ConstString, TypeValidatorImpl>;
friend class FormattersContainer<lldb::RegularExpressionSP, TypeValidatorImpl>;
};
} // namespace lldb_private

View File

@ -63,6 +63,12 @@ namespace lldb_private {
bool
Disable (ValueSP category);
void
EnableAllCategories ();
void
DisableAllCategories ();
void
Clear ();
@ -108,6 +114,10 @@ namespace lldb_private {
lldb::DynamicValueType use_dynamic);
#endif
lldb::TypeValidatorImplSP
GetValidator (ValueObject& valobj,
lldb::DynamicValueType use_dynamic);
private:
class delete_matching_categories

View File

@ -28,6 +28,32 @@
#include "lldb/Symbol/Type.h"
namespace lldb_private {
class TypeSummaryOptions
{
public:
TypeSummaryOptions ();
TypeSummaryOptions (const TypeSummaryOptions& rhs);
TypeSummaryOptions&
operator = (const TypeSummaryOptions& rhs);
lldb::LanguageType
GetLanguage () const;
lldb::TypeSummaryCapping
GetCapping () const;
TypeSummaryOptions&
SetLanguage (lldb::LanguageType);
TypeSummaryOptions&
SetCapping (lldb::TypeSummaryCapping);
~TypeSummaryOptions() = default;
private:
lldb::LanguageType m_lang;
lldb::TypeSummaryCapping m_capping;
};
class TypeSummaryImpl
{
@ -313,7 +339,8 @@ namespace lldb_private {
// for us to generate its summary
virtual bool
FormatObject (ValueObject *valobj,
std::string& dest) = 0;
std::string& dest,
const TypeSummaryOptions& options) = 0;
virtual std::string
GetDescription () = 0;
@ -372,7 +399,8 @@ namespace lldb_private {
virtual bool
FormatObject(ValueObject *valobj,
std::string& dest);
std::string& dest,
const TypeSummaryOptions& options);
virtual std::string
GetDescription();
@ -397,10 +425,11 @@ namespace lldb_private {
// summaries implemented via a C++ function
struct CXXFunctionSummaryFormat : public TypeSummaryImpl
{
// we should convert these to SBValue and SBStream if we ever cross
// the boundary towards the external world
typedef bool (*Callback)(ValueObject& valobj, Stream& dest);
typedef bool (*Callback)(ValueObject&,
Stream&,
const TypeSummaryOptions&);
Callback m_impl;
std::string m_description;
@ -443,7 +472,8 @@ namespace lldb_private {
virtual bool
FormatObject (ValueObject *valobj,
std::string& dest);
std::string& dest,
const TypeSummaryOptions& options);
virtual std::string
GetDescription ();
@ -517,7 +547,8 @@ namespace lldb_private {
virtual bool
FormatObject (ValueObject *valobj,
std::string& dest);
std::string& dest,
const TypeSummaryOptions& options);
virtual std::string
GetDescription ();

View File

@ -24,8 +24,6 @@
#include "lldb/lldb-enumerations.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Interpreter/ScriptInterpreterPython.h"
#include "lldb/Symbol/Type.h"
namespace lldb_private {
class SyntheticChildrenFrontEnd
@ -81,14 +79,71 @@ namespace lldb_private {
virtual bool
MightHaveChildren () = 0;
// if this function returns a non-null ValueObject, then the returned ValueObject will stand
// for this ValueObject whenever a "value" request is made to this ValueObject
virtual lldb::ValueObjectSP
GetSyntheticValue () { return nullptr; }
typedef std::shared_ptr<SyntheticChildrenFrontEnd> SharedPointer;
typedef std::unique_ptr<SyntheticChildrenFrontEnd> AutoPointer;
protected:
lldb::ValueObjectSP
CreateValueObjectFromExpression (const char* name,
const char* expression,
const ExecutionContext& exe_ctx);
lldb::ValueObjectSP
CreateValueObjectFromAddress (const char* name,
uint64_t address,
const ExecutionContext& exe_ctx,
ClangASTType type);
lldb::ValueObjectSP
CreateValueObjectFromData (const char* name,
const DataExtractor& data,
const ExecutionContext& exe_ctx,
ClangASTType type);
private:
bool m_valid;
DISALLOW_COPY_AND_ASSIGN(SyntheticChildrenFrontEnd);
};
class SyntheticValueProviderFrontEnd : public SyntheticChildrenFrontEnd
{
public:
SyntheticValueProviderFrontEnd (ValueObject &backend) :
SyntheticChildrenFrontEnd(backend)
{}
virtual
~SyntheticValueProviderFrontEnd ()
{
}
virtual size_t
CalculateNumChildren () { return 0; }
virtual lldb::ValueObjectSP
GetChildAtIndex (size_t idx) { return nullptr; }
virtual size_t
GetIndexOfChildWithName (const ConstString &name) { return UINT32_MAX; }
virtual bool
Update () { return false; }
virtual bool
MightHaveChildren () { return false; }
virtual lldb::ValueObjectSP
GetSyntheticValue () = 0;
private:
DISALLOW_COPY_AND_ASSIGN(SyntheticValueProviderFrontEnd);
};
class SyntheticChildren
{
public:
@ -328,37 +383,10 @@ namespace lldb_private {
}
void
AddExpressionPath (const std::string& path)
{
bool need_add_dot = true;
if (path[0] == '.' ||
(path[0] == '-' && path[1] == '>') ||
path[0] == '[')
need_add_dot = false;
// add a '.' symbol to help forgetful users
if(!need_add_dot)
m_expression_paths.push_back(path);
else
m_expression_paths.push_back(std::string(".") + path);
}
AddExpressionPath (const std::string& path);
bool
SetExpressionPathAtIndex (size_t i, const std::string& path)
{
if (i >= GetCount())
return false;
bool need_add_dot = true;
if (path[0] == '.' ||
(path[0] == '-' && path[1] == '>') ||
path[0] == '[')
need_add_dot = false;
// add a '.' symbol to help forgetful users
if(!need_add_dot)
m_expression_paths[i] = path;
else
m_expression_paths[i] = std::string(".") + path;
return true;
}
SetExpressionPathAtIndex (size_t i, const std::string& path);
bool
IsScripted ()
@ -410,24 +438,7 @@ namespace lldb_private {
}
virtual size_t
GetIndexOfChildWithName (const ConstString &name)
{
const char* name_cstr = name.GetCString();
for (size_t i = 0; i < filter->GetCount(); i++)
{
const char* expr_cstr = filter->GetExpressionPathAtIndex(i);
if (expr_cstr)
{
if (*expr_cstr == '.')
expr_cstr++;
else if (*expr_cstr == '-' && *(expr_cstr+1) == '>')
expr_cstr += 2;
}
if (!::strcmp(name_cstr, expr_cstr))
return i;
}
return UINT32_MAX;
}
GetIndexOfChildWithName (const ConstString &name);
typedef std::shared_ptr<SyntheticChildrenFrontEnd> SharedPointer;
@ -548,50 +559,28 @@ namespace lldb_private {
ValueObject &backend);
bool
IsValid ()
{
return m_wrapper_sp.get() != nullptr && m_wrapper_sp->operator bool() && m_interpreter != nullptr;
}
IsValid ();
virtual
~FrontEnd ();
virtual size_t
CalculateNumChildren ()
{
if (!m_wrapper_sp || m_interpreter == NULL)
return 0;
return m_interpreter->CalculateNumChildren(m_wrapper_sp);
}
CalculateNumChildren ();
virtual lldb::ValueObjectSP
GetChildAtIndex (size_t idx);
virtual bool
Update ()
{
if (!m_wrapper_sp || m_interpreter == NULL)
return false;
return m_interpreter->UpdateSynthProviderInstance(m_wrapper_sp);
}
Update ();
virtual bool
MightHaveChildren ()
{
if (!m_wrapper_sp || m_interpreter == NULL)
return false;
return m_interpreter->MightHaveChildrenSynthProviderInstance(m_wrapper_sp);
}
MightHaveChildren ();
virtual size_t
GetIndexOfChildWithName (const ConstString &name)
{
if (!m_wrapper_sp || m_interpreter == NULL)
return UINT32_MAX;
return m_interpreter->GetIndexOfChildWithName(m_wrapper_sp, name.GetCString());
}
GetIndexOfChildWithName (const ConstString &name);
virtual lldb::ValueObjectSP
GetSyntheticValue ();
typedef std::shared_ptr<SyntheticChildrenFrontEnd> SharedPointer;

View File

@ -0,0 +1,280 @@
//===-- TypeValidator.h ------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef lldb_TypeValidator_h_
#define lldb_TypeValidator_h_
// C Includes
// C++ Includes
#include <string>
#include <functional>
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-public.h"
#include "lldb/lldb-enumerations.h"
#include "lldb/lldb-private-enumerations.h"
namespace lldb_private {
class TypeValidatorImpl
{
public:
class Flags
{
public:
Flags () :
m_flags (lldb::eTypeOptionCascade)
{}
Flags (const Flags& other) :
m_flags (other.m_flags)
{}
Flags (uint32_t value) :
m_flags (value)
{}
Flags&
operator = (const Flags& rhs)
{
if (&rhs != this)
m_flags = rhs.m_flags;
return *this;
}
Flags&
operator = (const uint32_t& rhs)
{
m_flags = rhs;
return *this;
}
Flags&
Clear()
{
m_flags = 0;
return *this;
}
bool
GetCascades () const
{
return (m_flags & lldb::eTypeOptionCascade) == lldb::eTypeOptionCascade;
}
Flags&
SetCascades (bool value = true)
{
if (value)
m_flags |= lldb::eTypeOptionCascade;
else
m_flags &= ~lldb::eTypeOptionCascade;
return *this;
}
bool
GetSkipPointers () const
{
return (m_flags & lldb::eTypeOptionSkipPointers) == lldb::eTypeOptionSkipPointers;
}
Flags&
SetSkipPointers (bool value = true)
{
if (value)
m_flags |= lldb::eTypeOptionSkipPointers;
else
m_flags &= ~lldb::eTypeOptionSkipPointers;
return *this;
}
bool
GetSkipReferences () const
{
return (m_flags & lldb::eTypeOptionSkipReferences) == lldb::eTypeOptionSkipReferences;
}
Flags&
SetSkipReferences (bool value = true)
{
if (value)
m_flags |= lldb::eTypeOptionSkipReferences;
else
m_flags &= ~lldb::eTypeOptionSkipReferences;
return *this;
}
uint32_t
GetValue ()
{
return m_flags;
}
void
SetValue (uint32_t value)
{
m_flags = value;
}
private:
uint32_t m_flags;
};
TypeValidatorImpl (const Flags& flags = Flags());
typedef std::shared_ptr<TypeValidatorImpl> SharedPointer;
typedef bool(*ValueCallback)(void*, ConstString, const lldb::TypeValidatorImplSP&);
virtual ~TypeValidatorImpl ();
bool
Cascades () const
{
return m_flags.GetCascades();
}
bool
SkipsPointers () const
{
return m_flags.GetSkipPointers();
}
bool
SkipsReferences () const
{
return m_flags.GetSkipReferences();
}
void
SetCascades (bool value)
{
m_flags.SetCascades(value);
}
void
SetSkipsPointers (bool value)
{
m_flags.SetSkipPointers(value);
}
void
SetSkipsReferences (bool value)
{
m_flags.SetSkipReferences(value);
}
uint32_t
GetOptions ()
{
return m_flags.GetValue();
}
void
SetOptions (uint32_t value)
{
m_flags.SetValue(value);
}
uint32_t&
GetRevision ()
{
return m_my_revision;
}
enum class Type
{
eTypeUnknown,
eTypeCXX
};
struct ValidationResult {
TypeValidatorResult m_result;
std::string m_message;
};
virtual Type
GetType ()
{
return Type::eTypeUnknown;
}
// we are using a ValueObject* instead of a ValueObjectSP because we do not need to hold on to this for
// extended periods of time and we trust the ValueObject to stay around for as long as it is required
// for us to generate its value
virtual ValidationResult
FormatObject (ValueObject *valobj) const = 0;
virtual std::string
GetDescription() = 0;
static ValidationResult
Success ();
static ValidationResult
Failure (std::string message);
protected:
Flags m_flags;
uint32_t m_my_revision;
private:
DISALLOW_COPY_AND_ASSIGN(TypeValidatorImpl);
};
class TypeValidatorImpl_CXX : public TypeValidatorImpl
{
public:
typedef std::function<TypeValidatorImpl::ValidationResult(ValueObject* valobj)> ValidatorFunction;
TypeValidatorImpl_CXX (ValidatorFunction f, std::string d, const TypeValidatorImpl::Flags& flags = Flags());
typedef std::shared_ptr<TypeValidatorImpl_CXX> SharedPointer;
typedef bool(*ValueCallback)(void*, ConstString, const TypeValidatorImpl_CXX::SharedPointer&);
virtual ~TypeValidatorImpl_CXX ();
ValidatorFunction
GetValidatorFunction () const
{
return m_validator_function;
}
void
SetValidatorFunction (ValidatorFunction f)
{
m_validator_function = f;
}
virtual TypeValidatorImpl::Type
GetType ()
{
return TypeValidatorImpl::Type::eTypeCXX;
}
virtual ValidationResult
FormatObject (ValueObject *valobj) const;
virtual std::string
GetDescription();
protected:
std::string m_description;
ValidatorFunction m_validator_function;
private:
DISALLOW_COPY_AND_ASSIGN(TypeValidatorImpl_CXX);
};
} // namespace lldb_private
#endif // lldb_TypeValidator_h_

View File

@ -26,44 +26,43 @@ namespace lldb_private {
struct DumpValueObjectOptions
{
uint32_t m_max_ptr_depth;
uint32_t m_max_depth;
bool m_show_types;
bool m_show_location;
bool m_use_objc;
lldb::DynamicValueType m_use_dynamic;
bool m_use_synthetic;
bool m_scope_already_checked;
bool m_flat_output;
uint32_t m_omit_summary_depth;
bool m_ignore_cap;
lldb::Format m_format;
uint32_t m_max_ptr_depth = 0;
uint32_t m_max_depth = UINT32_MAX;
lldb::DynamicValueType m_use_dynamic = lldb::eNoDynamicValues;
uint32_t m_omit_summary_depth = 0;
lldb::Format m_format = lldb::eFormatDefault;
lldb::TypeSummaryImplSP m_summary_sp;
std::string m_root_valobj_name;
bool m_hide_root_type;
bool m_hide_name;
bool m_hide_value;
bool m_be_raw;
bool m_use_synthetic : 1;
bool m_scope_already_checked : 1;
bool m_flat_output : 1;
bool m_ignore_cap : 1;
bool m_show_types : 1;
bool m_show_location : 1;
bool m_use_objc : 1;
bool m_hide_root_type : 1;
bool m_hide_name : 1;
bool m_hide_value : 1;
bool m_run_validator : 1;
bool m_use_type_display_name : 1;
bool m_allow_oneliner_mode : 1;
DumpValueObjectOptions() :
m_max_ptr_depth(0),
m_max_depth(UINT32_MAX),
m_show_types(false),
m_show_location(false),
m_use_objc(false),
m_use_dynamic(lldb::eNoDynamicValues),
m_summary_sp(),
m_root_valobj_name(),
m_use_synthetic(true),
m_scope_already_checked(false),
m_flat_output(false),
m_omit_summary_depth(0),
m_ignore_cap(false),
m_format (lldb::eFormatDefault),
m_summary_sp(),
m_root_valobj_name(),
m_hide_root_type(false), // provide a special compact display for "po"
m_hide_name(false), // provide a special compact display for "po"
m_hide_value(false), // provide a special compact display for "po"
m_be_raw(false)
m_show_types(false),
m_show_location(false),
m_use_objc(false),
m_hide_root_type(false),
m_hide_name(false),
m_hide_value(false),
m_run_validator(false),
m_use_type_display_name(true),
m_allow_oneliner_mode(true)
{}
static const DumpValueObjectOptions
@ -74,26 +73,7 @@ struct DumpValueObjectOptions
return g_default_options;
}
DumpValueObjectOptions (const DumpValueObjectOptions& rhs) :
m_max_ptr_depth(rhs.m_max_ptr_depth),
m_max_depth(rhs.m_max_depth),
m_show_types(rhs.m_show_types),
m_show_location(rhs.m_show_location),
m_use_objc(rhs.m_use_objc),
m_use_dynamic(rhs.m_use_dynamic),
m_use_synthetic(rhs.m_use_synthetic),
m_scope_already_checked(rhs.m_scope_already_checked),
m_flat_output(rhs.m_flat_output),
m_omit_summary_depth(rhs.m_omit_summary_depth),
m_ignore_cap(rhs.m_ignore_cap),
m_format(rhs.m_format),
m_summary_sp(rhs.m_summary_sp),
m_root_valobj_name(rhs.m_root_valobj_name),
m_hide_root_type(rhs.m_hide_root_type),
m_hide_name(rhs.m_hide_name),
m_hide_value(rhs.m_hide_value),
m_be_raw(rhs.m_be_raw)
{}
DumpValueObjectOptions (const DumpValueObjectOptions& rhs) = default;
DumpValueObjectOptions&
SetMaximumPointerDepth(uint32_t depth = 0)
@ -183,26 +163,15 @@ struct DumpValueObjectOptions
}
DumpValueObjectOptions&
SetRawDisplay(bool raw = false)
SetRawDisplay()
{
if (raw)
{
SetUseSyntheticValue(false);
SetOmitSummaryDepth(UINT32_MAX);
SetIgnoreCap(true);
SetHideName(false);
SetHideValue(false);
m_be_raw = true;
}
else
{
SetUseSyntheticValue(true);
SetOmitSummaryDepth(0);
SetIgnoreCap(false);
SetHideName(false);
SetHideValue(false);
m_be_raw = false;
}
SetUseSyntheticValue(false);
SetOmitSummaryDepth(UINT32_MAX);
SetIgnoreCap(true);
SetHideName(false);
SetHideValue(false);
SetUseTypeDisplayName(false);
SetAllowOnelinerMode(false);
return *this;
}
@ -250,8 +219,30 @@ struct DumpValueObjectOptions
m_hide_value = hide_value;
return *this;
}
};
DumpValueObjectOptions&
SetRunValidator (bool run = true)
{
m_run_validator = run;
return *this;
}
DumpValueObjectOptions&
SetUseTypeDisplayName (bool dis = false)
{
m_use_type_display_name = dis;
return *this;
}
DumpValueObjectOptions&
SetAllowOnelinerMode (bool oneliner = false)
{
m_allow_oneliner_mode = oneliner;
return *this;
}
};
class ValueObjectPrinter
{
public:
@ -285,7 +276,7 @@ class ValueObjectPrinter
uint32_t curr_depth);
bool
GetDynamicValueIfNeeded ();
GetMostSpecializedValue ();
const char*
GetDescriptionForDisplay ();
@ -296,6 +287,9 @@ class ValueObjectPrinter
bool
ShouldPrintValueObject ();
bool
ShouldPrintValidation ();
bool
IsNil ();
@ -308,6 +302,12 @@ class ValueObjectPrinter
bool
IsAggregate ();
bool
PrintValidationMarkerIfNeeded ();
bool
PrintValidationErrorIfNeeded ();
bool
PrintLocationIfNeeded ();
@ -385,6 +385,7 @@ class ValueObjectPrinter
std::string m_value;
std::string m_summary;
std::string m_error;
std::pair<TypeValidatorResult,std::string> m_validation;
friend struct StringSummaryFormat;

View File

@ -147,6 +147,9 @@ class ClangExpressionParser
std::unique_ptr<clang::SelectorTable> m_selector_table; ///< Selector table for Objective-C methods
std::unique_ptr<clang::ASTContext> m_ast_context; ///< The AST context used to hold types and names for the parser
std::unique_ptr<clang::CodeGenerator> m_code_generator; ///< The Clang object that generates IR
class LLDBPreprocessorCallbacks;
LLDBPreprocessorCallbacks *m_pp_callbacks; ///< Called when the preprocessor encounters module imports
};
}

View File

@ -65,6 +65,11 @@ class ClangExpressionVariable
public:
ClangExpressionVariable(ExecutionContextScope *exe_scope, lldb::ByteOrder byte_order, uint32_t addr_byte_size);
ClangExpressionVariable (ExecutionContextScope *exe_scope,
Value &value,
const ConstString &name,
uint16_t flags = EVNone);
ClangExpressionVariable(const lldb::ValueObjectSP &valobj_sp);
//----------------------------------------------------------------------

View File

@ -285,9 +285,9 @@ class ClangFunction : public ClangExpression
/// True if the thread plan may simply be discarded if an error occurs.
///
/// @return
/// A ThreadPlan for executing the function.
/// A ThreadPlan shared pointer for executing the function.
//------------------------------------------------------------------
ThreadPlan *
lldb::ThreadPlanSP
GetThreadPlanToCallFunction (ExecutionContext &exe_ctx,
lldb::addr_t args_addr,
const EvaluateExpressionOptions &options,
@ -411,8 +411,10 @@ class ClangFunction : public ClangExpression
// For ClangFunction only
//------------------------------------------------------------------
std::unique_ptr<ClangExpressionParser> m_parser; ///< The parser responsible for compiling the function.
// Note: the parser needs to be destructed before the execution unit, so
// declare the the execution unit first.
std::shared_ptr<IRExecutionUnit> m_execution_unit_sp;
std::unique_ptr<ClangExpressionParser> m_parser; ///< The parser responsible for compiling the function.
lldb::ModuleWP m_jit_module_wp;
std::string m_name; ///< The name of this clang function - for debugging purposes.

View File

@ -0,0 +1,58 @@
//===-- ClangModulesDeclVendor.h --------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _liblldb_ClangModulesDeclVendor_
#define _liblldb_ClangModulesDeclVendor_
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/ClangForward.h"
#include "lldb/Symbol/DeclVendor.h"
#include "lldb/Target/Platform.h"
#include <vector>
namespace lldb_private
{
class ClangModulesDeclVendor : public DeclVendor
{
public:
//------------------------------------------------------------------
// Constructors and Destructors
//------------------------------------------------------------------
ClangModulesDeclVendor();
virtual
~ClangModulesDeclVendor();
static ClangModulesDeclVendor *
Create(Target &target);
//------------------------------------------------------------------
/// Add a module to the list of modules to search.
///
/// @param[in] path
/// The path to the exact module to be loaded. E.g., if the desired
/// module is std.io, then this should be { "std", "io" }.
///
/// @param[in] error_stream
/// A stream to populate with the output of the Clang parser when
/// it tries to load the module.
///
/// @return
/// True if the module could be loaded; false if not. If the
/// compiler encountered a fatal error during a previous module
/// load, then this will always return false for this ModuleImporter.
//------------------------------------------------------------------
virtual bool
AddModule(std::vector<llvm::StringRef> &path, Stream &error_stream) = 0;
};
}
#endif /* defined(_lldb_ClangModulesDeclVendor_) */

View File

@ -30,8 +30,6 @@
#include "lldb/Symbol/TaggedASTType.h"
#include "lldb/Target/ExecutionContext.h"
#include "llvm/ExecutionEngine/JITMemoryManager.h"
namespace lldb_private
{

View File

@ -25,7 +25,7 @@
#include "lldb/lldb-private.h"
#include "lldb/Core/ClangForward.h"
#include "lldb/Core/DataBufferHeap.h"
#include "llvm/ExecutionEngine/JITMemoryManager.h"
#include "llvm/ExecutionEngine/SectionMemoryManager.h"
#include "lldb/Expression/ClangExpression.h"
#include "lldb/Expression/ClangExpressionParser.h"
#include "lldb/Expression/IRMemoryMap.h"
@ -56,7 +56,7 @@ class Error;
/// then be used as input to the IR interpreter, or the address of the
/// executable code can be passed to a thread plan to run in the target.
///
/// This class creates a subclass of LLVM's JITMemoryManager, because that is
/// This class creates a subclass of LLVM's SectionMemoryManager, because that is
/// how the JIT emits code. Because LLDB needs to move JIT-compiled code
/// into the target process, the IRExecutionUnit knows how to copy the
/// emitted code into the target process.
@ -207,101 +207,12 @@ class IRExecutionUnit :
DisassembleFunction (Stream &stream,
lldb::ProcessSP &process_sp);
class MemoryManager : public llvm::JITMemoryManager
class MemoryManager : public llvm::SectionMemoryManager
{
public:
MemoryManager (IRExecutionUnit &parent);
virtual ~MemoryManager();
//------------------------------------------------------------------
/// Passthrough interface stub
//------------------------------------------------------------------
virtual void setMemoryWritable ();
//------------------------------------------------------------------
/// Passthrough interface stub
//------------------------------------------------------------------
virtual void setMemoryExecutable ();
//------------------------------------------------------------------
/// Passthrough interface stub
//------------------------------------------------------------------
virtual void setPoisonMemory (bool poison)
{
m_default_mm_ap->setPoisonMemory (poison);
}
//------------------------------------------------------------------
/// Passthrough interface stub
//------------------------------------------------------------------
virtual void AllocateGOT()
{
m_default_mm_ap->AllocateGOT();
}
//------------------------------------------------------------------
/// Passthrough interface stub
//------------------------------------------------------------------
virtual uint8_t *getGOTBase() const
{
return m_default_mm_ap->getGOTBase();
}
//------------------------------------------------------------------
/// Passthrough interface stub
//------------------------------------------------------------------
virtual uint8_t *startFunctionBody(const llvm::Function *F,
uintptr_t &ActualSize);
//------------------------------------------------------------------
/// Allocate room for a dyld stub for a lazy-referenced function,
/// and add it to the m_stubs map
///
/// @param[in] F
/// The function being referenced.
///
/// @param[in] StubSize
/// The size of the stub.
///
/// @param[in] Alignment
/// The required alignment of the stub.
///
/// @return
/// Allocated space for the stub.
//------------------------------------------------------------------
virtual uint8_t *allocateStub(const llvm::GlobalValue* F,
unsigned StubSize,
unsigned Alignment);
//------------------------------------------------------------------
/// Complete the body of a function, and add it to the m_functions map
///
/// @param[in] F
/// The function being completed.
///
/// @param[in] FunctionStart
/// The first instruction of the function.
///
/// @param[in] FunctionEnd
/// The last byte of the last instruction of the function.
//------------------------------------------------------------------
virtual void endFunctionBody(const llvm::Function *F,
uint8_t *FunctionStart,
uint8_t *FunctionEnd);
//------------------------------------------------------------------
/// Allocate space for an unspecified purpose, and add it to the
/// m_spaceBlocks map
///
/// @param[in] Size
/// The size of the area.
///
/// @param[in] Alignment
/// The required alignment of the area.
///
/// @return
/// Allocated space.
//------------------------------------------------------------------
virtual uint8_t *allocateSpace(intptr_t Size, unsigned Alignment);
//------------------------------------------------------------------
/// Allocate space for executable code, and add it to the
@ -346,22 +257,6 @@ class IRExecutionUnit :
llvm::StringRef SectionName,
bool IsReadOnly);
//------------------------------------------------------------------
/// Allocate space for a global variable, and add it to the
/// m_spaceBlocks map
///
/// @param[in] Size
/// The size of the variable.
///
/// @param[in] Alignment
/// The required alignment of the variable.
///
/// @return
/// Allocated space for the global.
//------------------------------------------------------------------
virtual uint8_t *allocateGlobal(uintptr_t Size,
unsigned Alignment);
//------------------------------------------------------------------
/// Called when object loading is complete and section page
/// permissions can be applied. Currently unimplemented for LLDB.
@ -380,52 +275,8 @@ class IRExecutionUnit :
return false;
}
//------------------------------------------------------------------
/// Passthrough interface stub
//------------------------------------------------------------------
virtual void deallocateFunctionBody(void *Body);
//------------------------------------------------------------------
/// Passthrough interface stub
//------------------------------------------------------------------
virtual size_t GetDefaultCodeSlabSize() {
return m_default_mm_ap->GetDefaultCodeSlabSize();
}
//------------------------------------------------------------------
/// Passthrough interface stub
//------------------------------------------------------------------
virtual size_t GetDefaultDataSlabSize() {
return m_default_mm_ap->GetDefaultDataSlabSize();
}
virtual size_t GetDefaultStubSlabSize() {
return m_default_mm_ap->GetDefaultStubSlabSize();
}
//------------------------------------------------------------------
/// Passthrough interface stub
//------------------------------------------------------------------
virtual unsigned GetNumCodeSlabs() {
return m_default_mm_ap->GetNumCodeSlabs();
}
//------------------------------------------------------------------
/// Passthrough interface stub
//------------------------------------------------------------------
virtual unsigned GetNumDataSlabs() {
return m_default_mm_ap->GetNumDataSlabs();
}
//------------------------------------------------------------------
/// Passthrough interface stub
//------------------------------------------------------------------
virtual unsigned GetNumStubSlabs() {
return m_default_mm_ap->GetNumStubSlabs();
}
virtual void registerEHFrames(uint8_t *Addr, uint64_t LoadAddr, size_t Size) {
return m_default_mm_ap->registerEHFrames(Addr, LoadAddr, Size);
return;
}
//------------------------------------------------------------------
@ -436,7 +287,7 @@ class IRExecutionUnit :
return m_default_mm_ap->getPointerToNamedFunction(Name, AbortOnFailure);
}
private:
std::unique_ptr<JITMemoryManager> m_default_mm_ap; ///< The memory allocator to use in actually creating space. All calls are passed through to it.
std::unique_ptr<SectionMemoryManager> m_default_mm_ap; ///< The memory allocator to use in actually creating space. All calls are passed through to it.
IRExecutionUnit &m_parent; ///< The execution unit this is a proxy for.
};

View File

@ -14,6 +14,10 @@
#include "lldb/Host/macosx/Config.h"
#elif defined(__ANDROID_NDK__)
#include "lldb/Host/android/Config.h"
#elif defined(__linux__) || defined(__GNU__)
#include "lldb/Host/linux/Config.h"

View File

@ -0,0 +1,15 @@
//===-- ConnectionFileDescriptor.h ------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef liblldb_Host_ConnectionFileDescriptor_h_
#define liblldb_Host_ConnectionFileDescriptor_h_
#include "lldb/Host/posix/ConnectionFileDescriptorPosix.h"
#endif

View File

@ -7,202 +7,360 @@
//
//===----------------------------------------------------------------------===//
//TODO: wire up window size changes
// If we ever get a private copy of libedit, there are a number of defects that would be nice to fix;
// a) Sometimes text just disappears while editing. In an 80-column editor paste the following text, without
// the quotes:
// "This is a test of the input system missing Hello, World! Do you disappear when it gets to a particular length?"
// Now press ^A to move to the start and type 3 characters, and you'll see a good amount of the text will
// disappear. It's still in the buffer, just invisible.
// b) The prompt printing logic for dealing with ANSI formatting characters is broken, which is why we're
// working around it here.
// c) When resizing the terminal window, if the cursor moves between rows libedit will get confused.
// d) The incremental search uses escape to cancel input, so it's confused by ANSI sequences starting with escape.
// e) Emoji support is fairly terrible, presumably it doesn't understand composed characters?
#ifndef liblldb_Editline_h_
#define liblldb_Editline_h_
#if defined(__cplusplus)
#include "lldb/lldb-private.h"
#include <sstream>
#include <vector>
#include <stdio.h>
#ifdef _WIN32
// components needed to handle wide characters ( <codecvt>, codecvt_utf8, libedit built with '--enable-widec' )
// are not consistenly available on non-OSX platforms. The wchar_t versions of libedit functions will only be
// used in cases where this is true. This is a compile time dependecy, for now selected per target Platform
#if defined (__APPLE__)
#define LLDB_EDITLINE_USE_WCHAR 1
#include <codecvt>
#else
#define LLDB_EDITLINE_USE_WCHAR 0
#endif
#include "lldb/lldb-private.h"
#include "lldb/Host/ConnectionFileDescriptor.h"
#if defined(_WIN32)
#include "lldb/Host/windows/editlinewin.h"
#else
#if !defined(__ANDROID_NDK__)
#include <histedit.h>
#endif
#endif
#include <string>
#include <vector>
#include "lldb/Core/ConnectionFileDescriptor.h"
#include "lldb/Host/Condition.h"
#include "lldb/Host/ConnectionFileDescriptor.h"
#include "lldb/Host/FileSpec.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Host/Predicate.h"
namespace lldb_private {
namespace line_editor {
//----------------------------------------------------------------------
/// @class Editline Editline.h "lldb/Host/Editline.h"
/// @brief A class that encapsulates editline functionality.
//----------------------------------------------------------------------
class EditlineHistory;
typedef std::shared_ptr<EditlineHistory> EditlineHistorySP;
class Editline
{
public:
typedef LineStatus (*LineCompletedCallbackType) (
Editline *editline,
StringList &lines,
uint32_t line_idx,
Error &error,
void *baton);
typedef int (*CompleteCallbackType) (
const char *current_line,
const char *cursor,
const char *last_char,
int skip_first_n_matches,
int max_matches,
StringList &matches,
void *baton);
// type alias's to help manage 8 bit and wide character versions of libedit
#if LLDB_EDITLINE_USE_WCHAR
using EditLineStringType = std::wstring;
using EditLineStringStreamType = std::wstringstream;
using EditLineCharType = wchar_t;
#else
using EditLineStringType=std::string;
using EditLineStringStreamType = std::stringstream;
using EditLineCharType = char;
#endif
typedef int (*GetCharCallbackType) (
::EditLine *,
char *c);
Editline(const char *prog, // Used for the history file and for editrc program name
const char *prompt,
bool configure_for_multiline,
FILE *fin,
FILE *fout,
FILE *ferr);
typedef int (* EditlineGetCharCallbackType)(::EditLine * editline, EditLineCharType * c);
typedef unsigned char (* EditlineCommandCallbackType)(::EditLine * editline, int ch);
typedef const char * (* EditlinePromptCallbackType)(::EditLine * editline);
~Editline();
class EditlineHistory;
typedef std::shared_ptr<EditlineHistory> EditlineHistorySP;
Error
GetLine (std::string &line,
bool &interrupted);
typedef bool (* IsInputCompleteCallbackType) (
Editline * editline,
StringList & lines,
void * baton);
typedef int (* FixIndentationCallbackType) (
Editline * editline,
const StringList & lines,
int cursor_position,
void * baton);
typedef int (* CompleteCallbackType) (
const char * current_line,
const char * cursor,
const char * last_char,
int skip_first_n_matches,
int max_matches,
StringList & matches,
void * baton);
/// Status used to decide when and how to start editing another line in multi-line sessions
enum class EditorStatus
{
/// The default state proceeds to edit the current line
Editing,
/// Editing complete, returns the complete set of edited lines
Complete,
/// End of input reported
EndOfInput,
Error
GetLines (const std::string &end_line,
StringList &lines,
bool &interrupted);
bool
LoadHistory ();
bool
SaveHistory ();
FILE *
GetInputFile ();
FILE *
GetOutputFile ();
FILE *
GetErrorFile ();
bool
GettingLine () const
{
return m_getting_line;
}
void
Hide ();
void
Refresh();
bool
Interrupt ();
void
SetAutoCompleteCallback (CompleteCallbackType callback,
void *baton)
{
m_completion_callback = callback;
m_completion_callback_baton = baton;
}
void
SetLineCompleteCallback (LineCompletedCallbackType callback,
void *baton)
{
m_line_complete_callback = callback;
m_line_complete_callback_baton = baton;
}
size_t
Push (const char *bytes, size_t len);
static int
GetCharFromInputFileCallback (::EditLine *e, char *c);
void
SetGetCharCallback (GetCharCallbackType callback);
const char *
GetPrompt();
void
SetPrompt (const char *p);
void
ShowLineNumbers (bool enable, uint32_t line_offset)
{
m_prompt_with_line_numbers = enable;
m_line_offset = line_offset;
/// Editing interrupted
Interrupted
};
/// Established locations that can be easily moved among with MoveCursor
enum class CursorLocation
{
/// The start of the first line in a multi-line edit session
BlockStart,
/// The start of the current line in a multi-line edit session
EditingPrompt,
/// The location of the cursor on the current line in a multi-line edit session
EditingCursor,
/// The location immediately after the last character in a multi-line edit session
BlockEnd
};
}
private:
Error
PrivateGetLine(std::string &line);
using namespace line_editor;
unsigned char
HandleCompletion (int ch);
static unsigned char
CallbackEditPrevLine (::EditLine *e, int ch);
static unsigned char
CallbackEditNextLine (::EditLine *e, int ch);
static unsigned char
CallbackComplete (::EditLine *e, int ch);
static const char *
GetPromptCallback (::EditLine *e);
static Editline *
GetClientData (::EditLine *e);
static FILE *
GetFilePointer (::EditLine *e, int fd);
enum class Command
/// Instances of Editline provide an abstraction over libedit's EditLine facility. Both
/// single- and multi-line editing are supported.
class Editline
{
None = 0,
EditPrevLine,
EditNextLine,
public:
Editline (const char * editor_name, FILE * input_file, FILE * output_file, FILE * error_file, bool color_prompts);
~Editline();
/// Uses the user data storage of EditLine to retrieve an associated instance of Editline.
static Editline *
InstanceFor (::EditLine * editline);
/// Sets a string to be used as a prompt, or combined with a line number to form a prompt.
void
SetPrompt (const char * prompt);
/// Sets an alternate string to be used as a prompt for the second line and beyond in multi-line
/// editing scenarios.
void
SetContinuationPrompt (const char * continuation_prompt);
/// Required to update the width of the terminal registered for I/O. It is critical that this
/// be correct at all times.
void
TerminalSizeChanged();
/// Returns the prompt established by SetPrompt()
const char *
GetPrompt();
/// Returns the index of the line currently being edited
uint32_t
GetCurrentLine();
/// Hides the current input session in preparation for output
void
Hide();
/// Prepare to return to editing after a call to Hide()
void
Refresh();
/// Interrupt the current edit as if ^C was pressed
bool
Interrupt();
/// Register a callback for the tab key
void
SetAutoCompleteCallback (CompleteCallbackType callback, void * baton);
/// Register a callback for testing whether multi-line input is complete
void
SetIsInputCompleteCallback (IsInputCompleteCallbackType callback, void * baton);
/// Register a callback for determining the appropriate indentation for a line
/// when creating a newline. An optional set of insertable characters can also
/// trigger the callback.
bool
SetFixIndentationCallback (FixIndentationCallbackType callback,
void * baton,
const char * indent_chars);
/// Prompts for and reads a single line of user input.
bool
GetLine (std::string &line, bool &interrupted);
/// Prompts for and reads a multi-line batch of user input.
bool
GetLines (int first_line_number, StringList &lines, bool &interrupted);
private:
/// Sets the lowest line number for multi-line editing sessions. A value of zero suppresses
/// line number printing in the prompt.
void
SetBaseLineNumber (int line_number);
/// Returns the complete prompt by combining the prompt or continuation prompt with line numbers
/// as appropriate. The line index is a zero-based index into the current multi-line session.
std::string
PromptForIndex (int line_index);
/// Sets the current line index between line edits to allow free movement between lines. Updates
/// the prompt to match.
void
SetCurrentLine (int line_index);
/// Determines the width of the prompt in characters. The width is guaranteed to be the same for
/// all lines of the current multi-line session.
int
GetPromptWidth();
/// Returns true if the underlying EditLine session's keybindings are Emacs-based, or false if
/// they are VI-based.
bool
IsEmacs();
/// Returns true if the current EditLine buffer contains nothing but spaces, or is empty.
bool
IsOnlySpaces();
/// Helper method used by MoveCursor to determine relative line position.
int
GetLineIndexForLocation (CursorLocation location, int cursor_row);
/// Move the cursor from one well-established location to another using relative line positioning
/// and absolute column positioning.
void
MoveCursor (CursorLocation from, CursorLocation to);
/// Clear from cursor position to bottom of screen and print input lines including prompts, optionally
/// starting from a specific line. Lines are drawn with an extra space at the end to reserve room for
/// the rightmost cursor position.
void
DisplayInput (int firstIndex = 0);
/// Counts the number of rows a given line of content will end up occupying, taking into account both
/// the preceding prompt and a single trailing space occupied by a cursor when at the end of the line.
int
CountRowsForLine (const EditLineStringType & content);
/// Save the line currently being edited
void
SaveEditedLine();
/// Convert the current input lines into a UTF8 StringList
StringList
GetInputAsStringList(int line_count = UINT32_MAX);
/// Replaces the current multi-line session with the next entry from history. When the parameter is
/// true it will take the next earlier entry from history, when it is false it takes the next most
/// recent.
unsigned char
RecallHistory (bool earlier);
/// Character reading implementation for EditLine that supports our multi-line editing trickery.
int
GetCharacter (EditLineCharType * c);
/// Prompt implementation for EditLine.
const char *
Prompt();
/// Line break command used when return is pressed in multi-line mode.
unsigned char
BreakLineCommand (int ch);
/// Delete command used when delete is pressed in multi-line mode.
unsigned char
DeleteNextCharCommand (int ch);
/// Delete command used when backspace is pressed in multi-line mode.
unsigned char
DeletePreviousCharCommand (int ch);
/// Line navigation command used when ^P or up arrow are pressed in multi-line mode.
unsigned char
PreviousLineCommand (int ch);
/// Line navigation command used when ^N or down arrow are pressed in multi-line mode.
unsigned char
NextLineCommand (int ch);
/// Buffer start command used when Esc < is typed in multi-line emacs mode.
unsigned char
BufferStartCommand (int ch);
/// Buffer end command used when Esc > is typed in multi-line emacs mode.
unsigned char
BufferEndCommand (int ch);
/// Context-sensitive tab insertion or code completion command used when the tab key is typed.
unsigned char
TabCommand (int ch);
/// Respond to normal character insertion by fixing line indentation
unsigned char
FixIndentationCommand (int ch);
/// Revert line command used when moving between lines.
unsigned char
RevertLineCommand (int ch);
/// Ensures that the current EditLine instance is properly configured for single or multi-line editing.
void
ConfigureEditor (bool multiline);
private:
#if LLDB_EDITLINE_USE_WCHAR
std::wstring_convert<std::codecvt_utf8<wchar_t>> m_utf8conv;
#endif
::EditLine * m_editline = nullptr;
EditlineHistorySP m_history_sp;
bool m_in_history = false;
std::vector<EditLineStringType> m_live_history_lines;
bool m_multiline_enabled = false;
std::vector<EditLineStringType> m_input_lines;
EditorStatus m_editor_status;
bool m_editor_getting_char = false;
bool m_color_prompts = true;
int m_terminal_width = 0;
int m_base_line_number = 0;
unsigned m_current_line_index = 0;
int m_current_line_rows = -1;
int m_revert_cursor_index = 0;
int m_line_number_digits = 3;
std::string m_set_prompt;
std::string m_set_continuation_prompt;
std::string m_current_prompt;
bool m_needs_prompt_repaint = false;
std::string m_editor_name;
FILE * m_input_file;
FILE * m_output_file;
FILE * m_error_file;
ConnectionFileDescriptor m_input_connection;
IsInputCompleteCallbackType m_is_input_complete_callback = nullptr;
void * m_is_input_complete_callback_baton = nullptr;
FixIndentationCallbackType m_fix_indentation_callback = nullptr;
void * m_fix_indentation_callback_baton = nullptr;
const char * m_fix_indentation_callback_chars = nullptr;
CompleteCallbackType m_completion_callback = nullptr;
void * m_completion_callback_baton = nullptr;
};
::EditLine *m_editline;
EditlineHistorySP m_history_sp;
std::string m_prompt;
std::string m_lines_prompt;
lldb_private::Predicate<bool> m_getting_char;
CompleteCallbackType m_completion_callback;
void *m_completion_callback_baton;
LineCompletedCallbackType m_line_complete_callback;
void *m_line_complete_callback_baton;
Command m_lines_command;
uint32_t m_line_offset;
uint32_t m_lines_curr_line;
uint32_t m_lines_max_line;
ConnectionFileDescriptor m_file;
bool m_prompt_with_line_numbers;
bool m_getting_line;
bool m_got_eof; // Set to true when we detect EOF
bool m_interrupted;
DISALLOW_COPY_AND_ASSIGN(Editline);
};
} // namespace lldb_private
}
#endif // #if defined(__cplusplus)
#endif // liblldb_Host_h_
#endif // liblldb_Editline_h_

View File

@ -246,7 +246,7 @@ class FileSpec
Compare (const FileSpec& lhs, const FileSpec& rhs, bool full);
static bool
Equal (const FileSpec& a, const FileSpec& b, bool full);
Equal (const FileSpec& a, const FileSpec& b, bool full, bool remove_backups = false);
//------------------------------------------------------------------
/// Dump this object to a Stream.
@ -582,6 +582,20 @@ class FileSpec
static void Normalize(llvm::SmallVectorImpl<char> &path, PathSyntax syntax = ePathSyntaxHostNative);
static void DeNormalize(llvm::SmallVectorImpl<char> &path, PathSyntax syntax = ePathSyntaxHostNative);
//------------------------------------------------------------------
/// Run through the input string, replaying the effect of any ".." and produce
/// the resultant path. The input path is not required to be in the host file system
/// format, but it is required to be normalized to that system.
///
/// @param[in] input
/// The input path to analyze.
///
/// @param[out] result
/// The backup-resolved path will be written here.
//------------------------------------------------------------------
static void RemoveBackupDots (const ConstString &input_const_str, ConstString &result_const_str);
//------------------------------------------------------------------
/// Change the file specified with a new path.
///

View File

@ -21,6 +21,7 @@
#include "lldb/Core/StringList.h"
#include "lldb/Host/File.h"
#include "lldb/Host/FileSpec.h"
#include "lldb/Host/HostThread.h"
namespace lldb_private {
@ -38,9 +39,6 @@ class Host
{
public:
/// A value of std::numeric_limits<uint32_t>::max() is used if there is no practical limit.
static const uint32_t MAX_THREAD_NAME_LENGTH;
typedef bool (*MonitorChildProcessCallback) (void *callback_baton,
lldb::pid_t pid,
bool exited,
@ -86,11 +84,8 @@ class Host
///
/// @see static void Host::StopMonitoringChildProcess (uint32_t)
//------------------------------------------------------------------
static lldb::thread_t
StartMonitoringChildProcess (MonitorChildProcessCallback callback,
void *callback_baton,
lldb::pid_t pid,
bool monitor_signals);
static HostThread StartMonitoringChildProcess(MonitorChildProcessCallback callback, void *callback_baton, lldb::pid_t pid,
bool monitor_signals);
enum SystemLogType
{
@ -140,36 +135,6 @@ class Host
static void
WillTerminate ();
//------------------------------------------------------------------
/// Host specific thread created function call.
///
/// This function call lets the current host OS do any thread
/// specific initialization that it needs, including naming the
/// thread. No cleanup routine is expected to be called
///
/// @param[in] name
/// The current thread's name in the current process.
//------------------------------------------------------------------
static void
ThreadCreated (const char *name);
static lldb::thread_t
ThreadCreate (const char *name,
lldb::thread_func_t function,
lldb::thread_arg_t thread_arg,
Error *err);
static bool
ThreadCancel (lldb::thread_t thread,
Error *error);
static bool
ThreadDetach (lldb::thread_t thread,
Error *error);
static bool
ThreadJoin (lldb::thread_t thread,
lldb::thread_result_t *thread_result_ptr,
Error *error);
typedef void (*ThreadLocalStorageCleanupCallback) (void *p);
@ -182,65 +147,6 @@ class Host
static void
ThreadLocalStorageSet(lldb::thread_key_t key, void *value);
//------------------------------------------------------------------
/// Gets the name of a thread in a process.
///
/// This function will name a thread in a process using it's own
/// thread name pool, and also will attempt to set a thread name
/// using any supported host OS APIs.
///
/// @param[in] pid
/// The process ID in which we are trying to get the name of
/// a thread.
///
/// @param[in] tid
/// The thread ID for which we are trying retrieve the name of.
///
/// @return
/// A std::string containing the thread name.
//------------------------------------------------------------------
static std::string
GetThreadName (lldb::pid_t pid, lldb::tid_t tid);
//------------------------------------------------------------------
/// Sets the name of a thread in the current process.
///
/// @param[in] pid
/// The process ID in which we are trying to name a thread.
///
/// @param[in] tid
/// The thread ID which we are trying to name.
///
/// @param[in] name
/// The current thread's name in the current process to \a name.
///
/// @return
/// \b true if the thread name was able to be set, \b false
/// otherwise.
//------------------------------------------------------------------
static bool
SetThreadName (lldb::pid_t pid, lldb::tid_t tid, const char *name);
//------------------------------------------------------------------
/// Sets a shortened name of a thread in the current process.
///
/// @param[in] pid
/// The process ID in which we are trying to name a thread.
///
/// @param[in] tid
/// The thread ID which we are trying to name.
///
/// @param[in] name
/// The current thread's name in the current process to \a name.
///
/// @param[in] len
/// The maximum length for the thread's shortened name.
///
/// @return
/// \b true if the thread name was able to be set, \b false
/// otherwise.
static bool
SetShortThreadName (lldb::pid_t pid, lldb::tid_t tid, const char *name, size_t len);
//------------------------------------------------------------------
/// Given an address in the current process (the process that
@ -330,11 +236,9 @@ class Host
GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &proc_info);
#if defined (__APPLE__) || defined (__linux__) || defined (__FreeBSD__) || defined (__GLIBC__) || defined (__NetBSD__)
static short
GetPosixspawnFlags (ProcessLaunchInfo &launch_info);
static short GetPosixspawnFlags(const ProcessLaunchInfo &launch_info);
static Error
LaunchProcessPosixSpawn (const char *exe_path, ProcessLaunchInfo &launch_info, ::pid_t &pid);
static Error LaunchProcessPosixSpawn(const char *exe_path, const ProcessLaunchInfo &launch_info, lldb::pid_t &pid);
static bool AddPosixSpawnFileAction(void *file_actions, const FileAction *info, Log *log, Error &error);
#endif
@ -355,7 +259,7 @@ class Host
int *signo_ptr, // Pass NULL if you don't want the signal that caused the process to exit
std::string *command_output, // Pass NULL if you don't want the command output
uint32_t timeout_sec,
const char *shell = LLDB_DEFAULT_SHELL);
bool run_in_default_shell = true);
static lldb::DataBufferSP
GetAuxvData (lldb_private::Process *process);
@ -363,9 +267,6 @@ class Host
static lldb::DataBufferSP
GetAuxvData (lldb::pid_t pid);
static lldb::TargetSP
GetDummyTarget (Debugger &debugger);
static bool
OpenFileInExternalEditor (const FileSpec &file_spec,
uint32_t line_no);

View File

@ -44,6 +44,14 @@ class HostInfoBase
//------------------------------------------------------------------
static uint32_t GetNumberCPUS();
//------------------------------------------------------------------
/// Returns the maximum length of a thread name on this platform.
///
/// @return
/// Maximum length of a thread name on this platform.
//------------------------------------------------------------------
static uint32_t GetMaxThreadNameLength();
//------------------------------------------------------------------
/// Gets the host vendor string.
///
@ -110,6 +118,7 @@ class HostInfoBase
static bool ComputeTempFileDirectory(FileSpec &file_spec);
static bool ComputeHeaderDirectory(FileSpec &file_spec);
static bool ComputeSystemPluginsDirectory(FileSpec &file_spec);
static bool ComputeClangDirectory(FileSpec &file_spec);
static bool ComputeUserPluginsDirectory(FileSpec &file_spec);
static void ComputeHostArchitectureSupport(ArchSpec &arch_32, ArchSpec &arch_64);

View File

@ -0,0 +1,27 @@
//===-- HostNativeProcess.h -------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef lldb_Host_HostNativeProcess_h_
#define lldb_Host_HostNativeProcess_h_
#if defined(_WIN32)
#include "lldb/Host/windows/HostProcessWindows.h"
namespace lldb_private
{
typedef HostProcessWindows HostNativeProcess;
}
#else
#include "lldb/Host/posix/HostProcessPosix.h"
namespace lldb_private
{
typedef HostProcessPosix HostNativeProcess;
}
#endif
#endif

View File

@ -0,0 +1,57 @@
//===-- HostNativeProcessBase.h ---------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef lldb_Host_HostNativeProcessBase_h_
#define lldb_Host_HostNativeProcessBase_h_
#include "lldb/Core/Error.h"
#include "lldb/Host/HostProcess.h"
#include "lldb/lldb-defines.h"
#include "lldb/lldb-types.h"
namespace lldb_private
{
class HostThread;
class HostNativeProcessBase
{
DISALLOW_COPY_AND_ASSIGN(HostNativeProcessBase);
public:
HostNativeProcessBase()
: m_process(LLDB_INVALID_PROCESS)
{
}
explicit HostNativeProcessBase(lldb::process_t process)
: m_process(process)
{}
virtual ~HostNativeProcessBase() {}
virtual Error Terminate() = 0;
virtual Error GetMainModule(FileSpec &file_spec) const = 0;
virtual lldb::pid_t GetProcessId() const = 0;
virtual bool IsRunning() const = 0;
lldb::process_t
GetSystemHandle() const
{
return m_process;
}
virtual HostThread StartMonitoring(HostProcess::MonitorCallback callback, void *callback_baton, bool monitor_signals) = 0;
protected:
lldb::process_t m_process;
};
}
#endif

View File

@ -0,0 +1,25 @@
//===-- HostNativeThread.h --------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef lldb_Host_HostNativeThread_h_
#define lldb_Host_HostNativeThread_h_
#include "HostNativeThreadForward.h"
#if defined(_WIN32)
#include "lldb/Host/windows/HostThreadWindows.h"
#elif defined(__linux__)
#include "lldb/Host/linux/HostThreadLinux.h"
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#include "lldb/Host/freebsd/HostThreadFreeBSD.h"
#elif defined(__APPLE__)
#include "lldb/Host/macosx/HostThreadMacOSX.h"
#endif
#endif

View File

@ -0,0 +1,53 @@
//===-- HostNativeThreadBase.h ----------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef lldb_Host_HostNativeThreadBase_h_
#define lldb_Host_HostNativeThreadBase_h_
#include "lldb/Core/Error.h"
#include "lldb/lldb-defines.h"
#include "lldb/lldb-types.h"
namespace lldb_private
{
#if defined(_WIN32)
#define THREAD_ROUTINE __stdcall
#else
#define THREAD_ROUTINE
#endif
class HostNativeThreadBase
{
friend class ThreadLauncher;
DISALLOW_COPY_AND_ASSIGN(HostNativeThreadBase);
public:
HostNativeThreadBase();
explicit HostNativeThreadBase(lldb::thread_t thread);
virtual ~HostNativeThreadBase() {}
virtual Error Join(lldb::thread_result_t *result) = 0;
virtual Error Cancel() = 0;
virtual bool IsJoinable() const;
virtual void Reset();
lldb::thread_t Release();
lldb::thread_t GetSystemHandle() const;
lldb::thread_result_t GetResult() const;
protected:
static lldb::thread_result_t THREAD_ROUTINE ThreadCreateTrampoline(lldb::thread_arg_t arg);
lldb::thread_t m_thread;
lldb::thread_result_t m_result;
};
}
#endif

View File

@ -0,0 +1,30 @@
//===-- HostNativeThreadForward.h -------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef lldb_Host_HostNativeThreadForward_h_
#define lldb_Host_HostNativeThreadForward_h_
namespace lldb_private
{
#if defined(_WIN32)
class HostThreadWindows;
typedef HostThreadWindows HostNativeThread;
#elif defined(__linux__)
class HostThreadLinux;
typedef HostThreadLinux HostNativeThread;
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
class HostThreadFreeBSD;
typedef HostThreadFreeBSD HostNativeThread;
#elif defined(__APPLE__)
class HostThreadMacOSX;
typedef HostThreadMacOSX HostNativeThread;
#endif
}
#endif

View File

@ -10,6 +10,8 @@
#ifndef lldb_Host_HostProcess_h_
#define lldb_Host_HostProcess_h_
#include "lldb/lldb-types.h"
//----------------------------------------------------------------------
/// @class HostInfo HostInfo.h "lldb/Host/HostProcess.h"
/// @brief A class that represents a running process on the host machine.
@ -26,19 +28,36 @@
///
//----------------------------------------------------------------------
#if defined(_WIN32)
#include "lldb/Host/windows/HostProcessWindows.h"
#define HOST_PROCESS_TYPE HostProcessWindows
#else
#include "lldb/Host/posix/HostProcessPosix.h"
#define HOST_PROCESS_TYPE HostProcessPosix
#endif
namespace lldb_private
{
typedef HOST_PROCESS_TYPE HostProcess;
class HostNativeProcessBase;
class HostThread;
class HostProcess
{
public:
typedef bool (*MonitorCallback)(void *callback_baton, lldb::pid_t process, bool exited, int signal, int status);
HostProcess();
HostProcess(lldb::process_t process);
~HostProcess();
Error Terminate();
Error GetMainModule(FileSpec &file_spec) const;
lldb::pid_t GetProcessId() const;
bool IsRunning() const;
HostThread StartMonitoring(MonitorCallback callback, void *callback_baton, bool monitor_signals);
HostNativeProcessBase &GetNativeProcess();
const HostNativeProcessBase &GetNativeProcess() const;
private:
std::shared_ptr<HostNativeProcessBase> m_native_process;
};
}
#undef HOST_PROCESS_TYPE
#endif

View File

@ -0,0 +1,56 @@
//===-- HostThread.h --------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef lldb_Host_HostThread_h_
#define lldb_Host_HostThread_h_
#include "lldb/Core/Error.h"
#include "lldb/Host/HostNativeThreadForward.h"
#include "lldb/lldb-types.h"
#include <memory>
namespace lldb_private
{
class HostNativeThreadBase;
//----------------------------------------------------------------------
/// @class HostInfo HostInfo.h "lldb/Host/HostThread.h"
/// @brief A class that represents a thread running inside of a process on the
/// local machine.
///
/// HostThread allows querying and manipulation of threads running on the host
/// machine.
///
//----------------------------------------------------------------------
class HostThread
{
public:
HostThread();
HostThread(lldb::thread_t thread);
Error Join(lldb::thread_result_t *result);
Error Cancel();
void Reset();
lldb::thread_t Release();
bool IsJoinable() const;
HostNativeThread &GetNativeThread();
const HostNativeThread &GetNativeThread() const;
lldb::thread_result_t GetResult() const;
bool EqualsThread(lldb::thread_t thread) const;
private:
std::shared_ptr<HostNativeThreadBase> m_native_thread;
};
}
#endif

View File

@ -0,0 +1,30 @@
//===-- MonitoringProcessLauncher.h -----------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef lldb_Host_MonitoringProcessLauncher_h_
#define lldb_Host_MonitoringProcessLauncher_h_
#include "lldb/Host/ProcessLauncher.h"
namespace lldb_private
{
class MonitoringProcessLauncher : public ProcessLauncher
{
public:
explicit MonitoringProcessLauncher(std::unique_ptr<ProcessLauncher> delegate_launcher);
virtual HostProcess LaunchProcess(const ProcessLaunchInfo &launch_info, Error &error);
private:
std::unique_ptr<ProcessLauncher> m_delegate_launcher;
};
}
#endif

View File

@ -7,77 +7,21 @@
//
//===----------------------------------------------------------------------===//
#ifndef liblldb_Pipe_h_
#define liblldb_Pipe_h_
#if defined(__cplusplus)
#ifndef liblldb_Host_Pipe_h_
#define liblldb_Host_Pipe_h_
#include <stdarg.h>
#include <stdio.h>
#include <sys/types.h>
#include "lldb/lldb-private.h"
namespace lldb_private {
//----------------------------------------------------------------------
/// @class Pipe Pipe.h "lldb/Host/Pipe.h"
/// @brief A class that abtracts unix style pipes.
///
/// A class that abstracts the LLDB core from host pipe functionality.
//----------------------------------------------------------------------
class Pipe
#if defined(_WIN32)
#include "lldb/Host/windows/PipeWindows.h"
namespace lldb_private
{
public:
static int kInvalidDescriptor;
Pipe();
~Pipe();
bool
Open();
typedef PipeWindows Pipe;
}
#else
#include "lldb/Host/posix/PipePosix.h"
namespace lldb_private
{
typedef PipePosix Pipe;
}
#endif
bool
IsValid() const;
bool
ReadDescriptorIsValid() const;
bool
WriteDescriptorIsValid() const;
int
GetReadFileDescriptor() const;
int
GetWriteFileDescriptor() const;
// Close both descriptors
void
Close();
bool
CloseReadFileDescriptor();
bool
CloseWriteFileDescriptor();
int
ReleaseReadFileDescriptor();
int
ReleaseWriteFileDescriptor();
size_t
Read (void *buf, size_t size);
size_t
Write (const void *buf, size_t size);
private:
int m_fds[2];
};
} // namespace lldb_private
#endif // #if defined(__cplusplus)
#endif // liblldb_Pipe_h_
#endif // liblldb_Host_Pipe_h_

View File

@ -0,0 +1,54 @@
//===-- PipeBase.h -----------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef liblldb_Host_PipeBase_h_
#define liblldb_Host_PipeBase_h_
#include <chrono>
#include <string>
#include "lldb/Core/Error.h"
#include "llvm/ADT/StringRef.h"
namespace lldb_private
{
class PipeBase
{
public:
virtual ~PipeBase();
virtual Error CreateNew(bool child_process_inherit) = 0;
virtual Error CreateNew(llvm::StringRef name, bool child_process_inherit) = 0;
virtual Error OpenAsReader(llvm::StringRef name, bool child_process_inherit) = 0;
Error OpenAsWriter(llvm::StringRef name, bool child_process_inherit);
virtual Error OpenAsWriterWithTimeout(llvm::StringRef name, bool child_process_inherit, const std::chrono::microseconds &timeout) = 0;
virtual bool CanRead() const = 0;
virtual bool CanWrite() const = 0;
virtual int GetReadFileDescriptor() const = 0;
virtual int GetWriteFileDescriptor() const = 0;
virtual int ReleaseReadFileDescriptor() = 0;
virtual int ReleaseWriteFileDescriptor() = 0;
// Close both descriptors
virtual void Close() = 0;
// Delete named pipe.
virtual Error Delete(llvm::StringRef name) = 0;
virtual Error Write(const void *buf, size_t size, size_t &bytes_written) = 0;
virtual Error ReadWithTimeout(void *buf, size_t size, const std::chrono::microseconds &timeout, size_t &bytes_read) = 0;
Error Read(void *buf, size_t size, size_t &bytes_read);
};
}
#endif

View File

@ -11,6 +11,7 @@
#define liblldb_Predicate_h_
#if defined(__cplusplus)
#include "lldb/lldb-defines.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Host/Condition.h"
#include <stdint.h>

View File

@ -0,0 +1,28 @@
//===-- ProcessLauncher.h ---------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef lldb_Host_ProcessLauncher_h_
#define lldb_Host_ProcessLauncher_h_
namespace lldb_private
{
class ProcessLaunchInfo;
class Error;
class HostProcess;
class ProcessLauncher
{
public:
virtual ~ProcessLauncher() {}
virtual HostProcess LaunchProcess(const ProcessLaunchInfo &launch_info, Error &error) = 0;
};
}
#endif

Some files were not shown because too many files have changed in this diff Show More