1 /* 2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Copyright 2013-2014, Rene Gollent, rene@gollent.com. 4 * Distributed under the terms of the MIT License. 5 */ 6 #ifndef USER_BREAKPOINT_H 7 #define USER_BREAKPOINT_H 8 9 10 #include <ObjectList.h> 11 #include <Referenceable.h> 12 #include <util/DoublyLinkedList.h> 13 14 #include "SourceLocation.h" 15 #include "String.h" 16 #include "Types.h" 17 18 19 class Breakpoint; 20 class Function; 21 class FunctionID; 22 class LocatableFile; 23 class UserBreakpoint; 24 25 26 class UserBreakpointLocation { 27 public: 28 UserBreakpointLocation(FunctionID* functionID, 29 LocatableFile* sourceFile, 30 const SourceLocation& sourceLocation, 31 target_addr_t relativeAddress); 32 UserBreakpointLocation( 33 const UserBreakpointLocation& other); 34 virtual ~UserBreakpointLocation(); 35 36 FunctionID* GetFunctionID() const { return fFunctionID; } 37 LocatableFile* SourceFile() const { return fSourceFile; } 38 SourceLocation GetSourceLocation() const 39 { return fSourceLocation; } 40 target_addr_t RelativeAddress() const 41 { return fRelativeAddress; } 42 43 UserBreakpointLocation& operator=( 44 const UserBreakpointLocation& other); 45 46 private: 47 FunctionID* fFunctionID; 48 LocatableFile* fSourceFile; 49 SourceLocation fSourceLocation; 50 target_addr_t fRelativeAddress; 51 }; 52 53 54 class UserBreakpointInstance 55 : public DoublyLinkedListLinkImpl<UserBreakpointInstance> { 56 public: 57 UserBreakpointInstance( 58 UserBreakpoint* userBreakpoint, 59 target_addr_t address); 60 61 UserBreakpoint* GetUserBreakpoint() const 62 { return fUserBreakpoint; } 63 target_addr_t Address() const { return fAddress; } 64 65 Breakpoint* GetBreakpoint() const { return fBreakpoint; } 66 void SetBreakpoint(Breakpoint* breakpoint); 67 68 private: 69 target_addr_t fAddress; 70 UserBreakpoint* fUserBreakpoint; 71 Breakpoint* fBreakpoint; 72 }; 73 74 75 typedef DoublyLinkedList<UserBreakpointInstance> UserBreakpointInstanceList; 76 77 78 class UserBreakpoint : public BReferenceable, 79 public DoublyLinkedListLinkImpl<UserBreakpoint> { 80 public: 81 UserBreakpoint( 82 const UserBreakpointLocation& location); 83 ~UserBreakpoint(); 84 85 const UserBreakpointLocation& Location() const { return fLocation; } 86 87 int32 CountInstances() const; 88 UserBreakpointInstance* InstanceAt(int32 index) const; 89 90 // Note: After known to the BreakpointManager, those can only be 91 // invoked with the breakpoint manager lock held. 92 bool AddInstance(UserBreakpointInstance* instance); 93 void RemoveInstance( 94 UserBreakpointInstance* instance); 95 UserBreakpointInstance* RemoveInstanceAt(int32 index); 96 97 bool IsValid() const { return fValid; } 98 void SetValid(bool valid); 99 // BreakpointManager only 100 101 bool IsEnabled() const { return fEnabled; } 102 void SetEnabled(bool enabled); 103 // BreakpointManager only 104 105 bool IsHidden() const { return fHidden; } 106 void SetHidden(bool hidden); 107 108 bool HasCondition() const 109 { return !fConditionExpression.IsEmpty(); } 110 const BString& Condition() const 111 { return fConditionExpression; } 112 void SetCondition( 113 const BString& conditionExpression); 114 115 private: 116 typedef BObjectList<UserBreakpointInstance> InstanceList; 117 118 private: 119 UserBreakpointLocation fLocation; 120 InstanceList fInstances; 121 bool fValid; 122 bool fEnabled; 123 bool fHidden; 124 BString fConditionExpression; 125 }; 126 127 128 typedef DoublyLinkedList<UserBreakpoint> UserBreakpointList; 129 130 131 #endif // USER_BREAKPOINT_H 132