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
9Watchpoint::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
20Watchpoint::~Watchpoint()
21{
22}
23
24
25void
26Watchpoint::SetInstalled(bool installed)
27{
28	fInstalled = installed;
29}
30
31
32void
33Watchpoint::SetEnabled(bool enabled)
34{
35	fEnabled = enabled;
36}
37
38
39bool
40Watchpoint::Contains(target_addr_t address) const
41{
42	return address >= fAddress && address <= (fAddress + fLength);
43}
44
45
46int
47Watchpoint::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
55int
56Watchpoint::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