More plumbing for breakpoints.

This commit is contained in:
Ben Vanik
2013-12-22 22:03:06 -08:00
parent 5e9a2c6d27
commit 5881a58c49
10 changed files with 194 additions and 0 deletions

View File

@@ -18,9 +18,43 @@ using namespace alloy::runtime;
Function::Function(Type type, uint64_t address) :
type_(type), address_(address), debug_info_(0) {
// TODO(benvanik): create on demand?
lock_ = AllocMutex();
}
Function::~Function() {
FreeMutex(lock_);
}
int Function::AddBreakpoint(Breakpoint* breakpoint) {
LockMutex(lock_);
bool found = false;
for (auto it = breakpoints_.begin(); it != breakpoints_.end(); ++it) {
if (*it == breakpoint) {
found = true;
}
}
if (!found) {
breakpoints_.push_back(breakpoint);
AddBreakpointImpl(breakpoint);
}
UnlockMutex(lock_);
return found ? 1 : 0;
}
int Function::RemoveBreakpoint(Breakpoint* breakpoint) {
LockMutex(lock_);
bool found = false;
for (auto it = breakpoints_.begin(); it != breakpoints_.end(); ++it) {
if (*it == breakpoint) {
breakpoints_.erase(it);
RemoveBreakpointImpl(breakpoint);
found = true;
break;
}
}
UnlockMutex(lock_);
return found ? 0 : 1;
}
int Function::Call(ThreadState* thread_state, uint64_t return_address) {