1 /* 2 * Copyright 2012, Rene Gollent, rene@gollent.com. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 #include "Watchpoint.h" 7 8 9 Watchpoint::Watchpoint(target_addr_t address, uint32 type, int32 length) 10 : 11 fAddress(address), 12 fType(type), 13 fLength(length), 14 fInstalled(false), 15 fEnabled(false) 16 { 17 } 18 19 20 Watchpoint::~Watchpoint() 21 { 22 } 23 24 25 void 26 Watchpoint::SetInstalled(bool installed) 27 { 28 fInstalled = installed; 29 } 30 31 32 void 33 Watchpoint::SetEnabled(bool enabled) 34 { 35 fEnabled = enabled; 36 } 37 38 39 bool 40 Watchpoint::Contains(target_addr_t address) const 41 { 42 return address >= fAddress && address <= (fAddress + fLength); 43 } 44 45 46 int 47 Watchpoint::CompareWatchpoints(const Watchpoint* a, const Watchpoint* b) 48 { 49 if (a->Address() < b->Address()) 50 return -1; 51 return a->Address() == b->Address() ? 0 : 1; 52 } 53 54 55 int 56 Watchpoint::CompareAddressWatchpoint(const target_addr_t* address, 57 const Watchpoint* watchpoint) 58 { 59 if (*address < watchpoint->Address()) 60 return -1; 61 return *address == watchpoint->Address() ? 0 : 1; 62 } 63 64 65 66