Add "operator bool" to SB APIs

Summary:
Our python version of the SB API has (the python equivalent of)
operator bool, but the C++ version doesn't.

This is because our python operators are added by modify-python-lldb.py,
which performs postprocessing on the swig-generated interface files.

In this patch, I add the "operator bool" to all SB classes which have an
IsValid method (which is the same logic used by modify-python-lldb.py).
This way, we make the two interfaces more constent, and it allows us to
rely on swig's automatic syntesis of python __nonzero__ methods instead
of doing manual fixups.

Reviewers: zturner, jingham, clayborg, jfb, serge-sans-paille

Subscribers: jdoerfert, lldb-commits

Differential Revision: https://reviews.llvm.org/D58792

llvm-svn: 355824
This commit is contained in:
Pavel Labath 2019-03-11 13:58:46 +00:00
parent 52760bf435
commit 7f5237bccc
168 changed files with 551 additions and 18 deletions

View File

@ -29,6 +29,8 @@ public:
const lldb::SBAddress &operator=(const lldb::SBAddress &rhs);
explicit operator bool() const;
bool IsValid() const;
void Clear();

View File

@ -28,6 +28,8 @@ public:
bool IsInlined() const;
explicit operator bool() const;
bool IsValid() const;
const char *GetInlinedName() const;

View File

@ -36,6 +36,8 @@ public:
break_id_t GetID() const;
explicit operator bool() const;
bool IsValid() const;
void ClearAllBreakpointSites();

View File

@ -27,6 +27,8 @@ public:
break_id_t GetID();
explicit operator bool() const;
bool IsValid() const;
lldb::SBAddress GetAddress();

View File

@ -39,6 +39,8 @@ public:
bool operator!=(const lldb::SBBreakpointName &rhs);
explicit operator bool() const;
bool IsValid() const;
const char *GetName() const;

View File

@ -25,6 +25,8 @@ public:
~SBBroadcaster();
explicit operator bool() const;
bool IsValid() const;
void Clear();

View File

@ -87,6 +87,8 @@ public:
static bool EventIsCommandInterpreterEvent(const lldb::SBEvent &event);
explicit operator bool() const;
bool IsValid() const;
bool CommandExists(const char *cmd);
@ -272,6 +274,8 @@ class SBCommand {
public:
SBCommand();
explicit operator bool() const;
bool IsValid();
const char *GetName();

View File

@ -32,6 +32,8 @@ public:
lldb_private::CommandReturnObject *Release();
explicit operator bool() const;
bool IsValid() const;
const char *GetOutput();

View File

@ -37,6 +37,8 @@ public:
SBCommunication(const char *broadcaster_name);
~SBCommunication();
explicit operator bool() const;
bool IsValid() const;
lldb::SBBroadcaster GetBroadcaster();

View File

@ -24,6 +24,8 @@ public:
const lldb::SBCompileUnit &operator=(const lldb::SBCompileUnit &rhs);
explicit operator bool() const;
bool IsValid() const;
lldb::SBFileSpec GetFileSpec() const;

View File

@ -29,6 +29,8 @@ public:
void Clear();
explicit operator bool() const;
bool IsValid();
size_t GetByteSize();

View File

@ -62,6 +62,8 @@ public:
static void MemoryPressureDetected();
explicit operator bool() const;
bool IsValid() const;
void Clear();

View File

@ -25,6 +25,8 @@ public:
const lldb::SBDeclaration &operator=(const lldb::SBDeclaration &rhs);
explicit operator bool() const;
bool IsValid() const;
lldb::SBFileSpec GetFileSpec() const;

View File

@ -46,6 +46,8 @@ public:
int SetErrorStringWithFormat(const char *format, ...)
__attribute__((format(printf, 2, 3)));
explicit operator bool() const;
bool IsValid() const;
bool GetDescription(lldb::SBStream &description);

View File

@ -35,6 +35,8 @@ public:
const SBEvent &operator=(const lldb::SBEvent &rhs);
explicit operator bool() const;
bool IsValid() const;
const char *GetDataFlavor();

View File

@ -28,6 +28,8 @@ public:
const SBFileSpec &operator=(const lldb::SBFileSpec &rhs);
explicit operator bool() const;
bool IsValid() const;
bool Exists() const;

View File

@ -26,6 +26,8 @@ public:
bool IsEqual(const lldb::SBFrame &that) const;
explicit operator bool() const;
bool IsValid() const;
uint32_t GetFrameID() const;

View File

@ -25,6 +25,8 @@ public:
~SBFunction();
explicit operator bool() const;
bool IsValid() const;
const char *GetName() const;

View File

@ -31,6 +31,8 @@ public:
~SBInstruction();
explicit operator bool() const;
bool IsValid();
SBAddress GetAddress();

View File

@ -25,6 +25,8 @@ public:
~SBInstructionList();
explicit operator bool() const;
bool IsValid() const;
size_t GetSize();

View File

@ -29,6 +29,8 @@ public:
lldb::SBAddress GetEndAddress() const;
explicit operator bool() const;
bool IsValid() const;
lldb::SBFileSpec GetFileSpec() const;

View File

@ -29,6 +29,8 @@ public:
void Clear();
explicit operator bool() const;
bool IsValid() const;
uint32_t StartListeningForEventClass(SBDebugger &debugger,

View File

@ -31,6 +31,8 @@ public:
~SBModule();
explicit operator bool() const;
bool IsValid() const;
void Clear();

View File

@ -24,6 +24,8 @@ public:
const SBModuleSpec &operator=(const SBModuleSpec &rhs);
explicit operator bool() const;
bool IsValid() const;
void Clear();

View File

@ -91,6 +91,8 @@ public:
~SBPlatform();
explicit operator bool() const;
bool IsValid() const;
void Clear();

View File

@ -51,6 +51,8 @@ public:
void Clear();
explicit operator bool() const;
bool IsValid() const;
lldb::SBTarget GetTarget() const;

View File

@ -22,6 +22,8 @@ public:
SBProcessInfo &operator=(const SBProcessInfo &rhs);
explicit operator bool() const;
bool IsValid() const;
const char *GetName();

View File

@ -28,6 +28,8 @@ public:
~SBQueue();
explicit operator bool() const;
bool IsValid() const;
void Clear();

View File

@ -22,6 +22,8 @@ public:
~SBQueueItem();
explicit operator bool() const;
bool IsValid() const;
void Clear();

View File

@ -24,6 +24,8 @@ public:
const lldb::SBSection &operator=(const lldb::SBSection &rhs);
explicit operator bool() const;
bool IsValid() const;
const char *GetName();

View File

@ -23,6 +23,8 @@ public:
~SBStream();
explicit operator bool() const;
bool IsValid() const;
// If this stream is not redirected to a file, it will maintain a local cache

View File

@ -23,6 +23,8 @@ public:
~SBStringList();
explicit operator bool() const;
bool IsValid() const;
void AppendString(const char *str);

View File

@ -28,6 +28,8 @@ public:
lldb::SBStructuredData &operator=(const lldb::SBStructuredData &rhs);
explicit operator bool() const;
bool IsValid() const;
lldb::SBError SetFromJSON(lldb::SBStream &stream);

View File

@ -26,6 +26,8 @@ public:
const lldb::SBSymbol &operator=(const lldb::SBSymbol &rhs);
explicit operator bool() const;
bool IsValid() const;
const char *GetName() const;

View File

@ -29,6 +29,8 @@ public:
~SBSymbolContext();
explicit operator bool() const;
bool IsValid() const;
const lldb::SBSymbolContext &operator=(const lldb::SBSymbolContext &rhs);

View File

@ -25,6 +25,8 @@ public:
const lldb::SBSymbolContextList &
operator=(const lldb::SBSymbolContextList &rhs);
explicit operator bool() const;
bool IsValid() const;
uint32_t GetSize() const;

View File

@ -55,6 +55,8 @@ public:
const lldb::SBTarget &operator=(const lldb::SBTarget &rhs);
explicit operator bool() const;
bool IsValid() const;
static bool EventIsTargetEvent(const lldb::SBEvent &event);

View File

@ -39,6 +39,8 @@ public:
lldb::SBQueue GetQueue() const;
explicit operator bool() const;
bool IsValid() const;
void Clear();

View File

@ -23,6 +23,8 @@ public:
~SBThreadCollection();
explicit operator bool() const;
bool IsValid() const;
size_t GetSize();

View File

@ -30,6 +30,8 @@ public:
~SBThreadPlan();
explicit operator bool() const;
bool IsValid() const;
void Clear();

View File

@ -100,6 +100,8 @@ public:
lldb::user_id_t GetTraceUID();
explicit operator bool() const;
bool IsValid();
protected:

View File

@ -44,6 +44,8 @@ public:
lldb::tid_t getThreadID();
explicit operator bool() const;
bool IsValid();
protected:

View File

@ -25,6 +25,8 @@ public:
lldb::SBTypeMember &operator=(const lldb::SBTypeMember &rhs);
explicit operator bool() const;
bool IsValid() const;
const char *GetName();
@ -64,6 +66,8 @@ public:
lldb::SBTypeMemberFunction &operator=(const lldb::SBTypeMemberFunction &rhs);
explicit operator bool() const;
bool IsValid() const;
const char *GetName();
@ -105,6 +109,8 @@ public:
~SBType();
explicit operator bool() const;
bool IsValid() const;
uint64_t GetByteSize();
@ -235,6 +241,8 @@ public:
lldb::SBTypeList &operator=(const lldb::SBTypeList &rhs);
explicit operator bool() const;
bool IsValid();
void Append(lldb::SBType type);

View File

@ -22,6 +22,8 @@ public:
~SBTypeCategory();
explicit operator bool() const;
bool IsValid() const;
bool GetEnabled();

View File

@ -24,6 +24,8 @@ public:
SBTypeEnumMember &operator=(const SBTypeEnumMember &rhs);
explicit operator bool() const;
bool IsValid() const;
int64_t GetValueAsSigned();
@ -62,6 +64,8 @@ public:
SBTypeEnumMemberList &operator=(const SBTypeEnumMemberList &rhs);
explicit operator bool() const;
bool IsValid();
void Append(SBTypeEnumMember entry);

View File

@ -24,6 +24,8 @@ public:
~SBTypeFilter();
explicit operator bool() const;
bool IsValid() const;
uint32_t GetNumberOfExpressionPaths();

View File

@ -28,6 +28,8 @@ public:
~SBTypeFormat();
explicit operator bool() const;
bool IsValid() const;
lldb::Format GetFormat();

View File

@ -26,6 +26,8 @@ public:
~SBTypeNameSpecifier();
explicit operator bool() const;
bool IsValid() const;
const char *GetName();

View File

@ -23,6 +23,8 @@ public:
~SBTypeSummaryOptions();
explicit operator bool() const;
bool IsValid();
lldb::LanguageType GetLanguage();
@ -79,6 +81,8 @@ public:
~SBTypeSummary();
explicit operator bool() const;
bool IsValid() const;
bool IsFunctionCode();

View File

@ -32,6 +32,8 @@ public:
~SBTypeSynthetic();
explicit operator bool() const;
bool IsValid() const;
bool IsClassCode();

View File

@ -26,6 +26,8 @@ public:
void Clear();
explicit operator bool() const;
bool IsValid() const;
const char *GetSignalAsCString(int32_t signo) const;

View File

@ -28,6 +28,8 @@ public:
~SBValue();
explicit operator bool() const;
bool IsValid();
void Clear();

View File

@ -23,6 +23,8 @@ public:
~SBValueList();
explicit operator bool() const;
bool IsValid() const;
void Clear();

View File

@ -26,6 +26,8 @@ public:
~SBVariablesOptions();
explicit operator bool() const;
bool IsValid() const;
bool GetIncludeArguments() const;

View File

@ -25,6 +25,8 @@ public:
const lldb::SBWatchpoint &operator=(const lldb::SBWatchpoint &rhs);
explicit operator bool() const;
bool IsValid() const;
SBError GetError();

View File

@ -91,16 +91,6 @@ len_def = " def __len__(self): return self.%s()"
eq_def = " def __eq__(self, other): return isinstance(other, %s) and %s"
ne_def = " def __ne__(self, other): return not self.__eq__(other)"
# Called to implement truth value testing and the built-in operation bool();
# Note that Python 2 uses __nonzero__(), whereas Python 3 uses __bool__()
# should return False or True, or their integer equivalents 0 or 1.
# Delegate to self.IsValid() if it is defined for the current lldb object.
if six.PY2:
nonzero_def = " def __nonzero__(self): return self.IsValid()"
else:
nonzero_def = " def __bool__(self): return self.IsValid()"
# A convenience iterator for SBSymbol!
symbol_in_section_iter_def = '''
def symbol_in_section_iter(self, section):
@ -332,11 +322,6 @@ for line in content.splitlines():
if one_liner_docstring_pattern.match(line):
line = char_to_str_xform(line)
# Look for 'def IsValid(*args):', and once located, add implementation
# of truth value testing for this object by delegation.
if isvalid_pattern.search(line):
new_content.add_line(nonzero_def)
# Pass the original line of content to new_content.
new_content.add_line(line)

View File

@ -62,6 +62,8 @@ public:
bool
IsValid () const;
explicit operator bool() const;
void
Clear ();

View File

@ -30,6 +30,8 @@ public:
bool
IsValid () const;
explicit operator bool() const;
%feature("docstring", "
Get the function name if this block represents an inlined function;
otherwise, return None.

View File

@ -91,6 +91,8 @@ public:
bool
IsValid() const;
explicit operator bool() const;
void
ClearAllBreakpointSites ();

View File

@ -34,6 +34,8 @@ public:
bool
IsValid() const;
explicit operator bool() const;
lldb::SBAddress
GetAddress();

View File

@ -42,6 +42,8 @@ public:
bool operator!=(const lldb::SBBreakpointName &rhs);
explicit operator bool() const;
bool IsValid() const;
const char *GetName() const;

View File

@ -33,6 +33,8 @@ public:
bool
IsValid () const;
explicit operator bool() const;
void
Clear ();

View File

@ -145,6 +145,8 @@ public:
bool
IsValid() const;
explicit operator bool() const;
const char *
GetIOHandlerControlSequence(char ch);

View File

@ -28,6 +28,8 @@ public:
bool
IsValid() const;
explicit operator bool() const;
const char *
GetOutput ();

View File

@ -30,6 +30,8 @@ public:
bool
IsValid () const;
explicit operator bool() const;
lldb::SBBroadcaster
GetBroadcaster ();

View File

@ -56,6 +56,8 @@ public:
bool
IsValid () const;
explicit operator bool() const;
lldb::SBFileSpec
GetFileSpec () const;

View File

@ -31,6 +31,8 @@ public:
bool
IsValid();
explicit operator bool() const;
size_t
GetByteSize ();

View File

@ -152,6 +152,8 @@ public:
bool
IsValid() const;
explicit operator bool() const;
void
Clear ();

View File

@ -24,6 +24,8 @@ namespace lldb {
bool
IsValid () const;
explicit operator bool() const;
lldb::SBFileSpec
GetFileSpec () const;

View File

@ -101,6 +101,8 @@ public:
bool
IsValid () const;
explicit operator bool() const;
bool
GetDescription (lldb::SBStream &description);

View File

@ -124,6 +124,8 @@ public:
bool
IsValid() const;
explicit operator bool() const;
const char *
GetDataFlavor ();

View File

@ -45,6 +45,8 @@ public:
bool
IsValid() const;
explicit operator bool() const;
bool
Exists () const;

View File

@ -59,6 +59,8 @@ public:
bool
IsValid() const;
explicit operator bool() const;
uint32_t
GetFrameID () const;

View File

@ -55,6 +55,8 @@ public:
bool
IsValid () const;
explicit operator bool() const;
const char *
GetName() const;

View File

@ -26,6 +26,8 @@ public:
bool
IsValid();
explicit operator bool() const;
lldb::SBAddress
GetAddress();

View File

@ -37,6 +37,8 @@ public:
bool
IsValid () const;
explicit operator bool() const;
size_t
GetSize ();

View File

@ -55,6 +55,8 @@ public:
bool
IsValid () const;
explicit operator bool() const;
lldb::SBFileSpec
GetFileSpec () const;

View File

@ -33,6 +33,8 @@ public:
bool
IsValid () const;
explicit operator bool() const;
uint32_t
StartListeningForEventClass (SBDebugger &debugger,
const char *broadcaster_class,

View File

@ -130,6 +130,8 @@ public:
bool
IsValid () const;
explicit operator bool() const;
void
Clear();

View File

@ -21,6 +21,8 @@ public:
bool
IsValid () const;
explicit operator bool() const;
void
Clear();

View File

@ -118,6 +118,8 @@ public:
bool
IsValid () const;
explicit operator bool() const;
void
Clear ();

View File

@ -68,6 +68,8 @@ public:
bool
IsValid() const;
explicit operator bool() const;
lldb::SBTarget
GetTarget() const;

View File

@ -25,6 +25,8 @@ public:
bool
IsValid ();
explicit operator bool() const;
const char *
GetName ();

View File

@ -20,6 +20,8 @@ public:
bool
IsValid() const;
explicit operator bool() const;
void
Clear ();

View File

@ -20,6 +20,8 @@ public:
bool
IsValid() const;
explicit operator bool() const;
void
Clear ();

View File

@ -49,6 +49,8 @@ public:
bool
IsValid () const;
explicit operator bool() const;
const char *
GetName ();

View File

@ -48,6 +48,8 @@ public:
bool
IsValid() const;
explicit operator bool() const;
%feature("docstring", "
//--------------------------------------------------------------------------
/// If this stream is not redirected to a file, it will maintain a local

View File

@ -21,6 +21,8 @@ public:
bool
IsValid() const;
explicit operator bool() const;
void
AppendString (const char *str);

View File

@ -28,6 +28,8 @@ namespace lldb {
bool
IsValid() const;
explicit operator bool() const;
void
Clear();

View File

@ -27,6 +27,8 @@ public:
bool
IsValid () const;
explicit operator bool() const;
const char *
GetName() const;

View File

@ -57,6 +57,8 @@ public:
bool
IsValid () const;
explicit operator bool() const;
lldb::SBModule GetModule ();
lldb::SBCompileUnit GetCompileUnit ();
lldb::SBFunction GetFunction ();

View File

@ -41,6 +41,8 @@ public:
bool
IsValid () const;
explicit operator bool() const;
uint32_t
GetSize() const;

View File

@ -80,6 +80,8 @@ public:
bool
IsValid() const;
explicit operator bool() const;
static bool
EventIsTargetEvent (const lldb::SBEvent &event);

View File

@ -74,6 +74,8 @@ public:
bool
IsValid() const;
explicit operator bool() const;
void
Clear ();

View File

@ -26,6 +26,8 @@ public:
bool
IsValid () const;
explicit operator bool() const;
size_t
GetSize ();

View File

@ -40,6 +40,8 @@ public:
bool
IsValid() const;
explicit operator bool() const;
void
Clear ();
@ -90,6 +92,8 @@ public:
bool
IsValid();
explicit operator bool() const;
// This section allows an SBThreadPlan to push another of the common types of plans...
SBThreadPlan
QueueThreadPlanForStepOverRange (SBAddress &start_address,

View File

@ -27,6 +27,8 @@ public:
lldb::user_id_t GetTraceUID();
explicit operator bool() const;
bool IsValid();
};

View File

@ -32,6 +32,8 @@ public:
lldb::tid_t getThreadID();
explicit operator bool() const;
bool IsValid();
};
}

View File

@ -24,6 +24,8 @@ public:
bool
IsValid() const;
explicit operator bool() const;
const char *
GetName ();
@ -79,6 +81,8 @@ public:
bool
IsValid() const;
explicit operator bool() const;
const char *
GetName ();
@ -196,6 +200,8 @@ public:
bool
IsValid();
explicit operator bool() const;
uint64_t
GetByteSize();
@ -487,6 +493,8 @@ public:
bool
IsValid();
explicit operator bool() const;
void
Append (lldb::SBType type);

View File

@ -25,6 +25,8 @@ namespace lldb {
bool
IsValid() const;
explicit operator bool() const;
bool
GetEnabled ();

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