本文整理汇总了C++中Breakpoint::AddUserBreakpoint方法的典型用法代码示例。如果您正苦于以下问题:C++ Breakpoint::AddUserBreakpoint方法的具体用法?C++ Breakpoint::AddUserBreakpoint怎么用?C++ Breakpoint::AddUserBreakpoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Breakpoint
的用法示例。
在下文中一共展示了Breakpoint::AddUserBreakpoint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: installLocker
status_t
BreakpointManager::InstallUserBreakpoint(UserBreakpoint* userBreakpoint,
bool enabled)
{
TRACE_CONTROL("BreakpointManager::InstallUserBreakpoint(%p, %d)\n",
userBreakpoint, enabled);
AutoLocker<BLocker> installLocker(fLock);
AutoLocker<Team> teamLocker(fTeam);
bool oldEnabled = userBreakpoint->IsEnabled();
if (userBreakpoint->IsValid() && enabled == oldEnabled) {
TRACE_CONTROL(" user breakpoint already valid and with same enabled "
"state\n");
return B_OK;
}
// get/create the breakpoints for all instances
TRACE_CONTROL(" creating breakpoints for breakpoint instances\n");
status_t error = B_OK;
for (int32 i = 0;
UserBreakpointInstance* instance = userBreakpoint->InstanceAt(i); i++) {
TRACE_CONTROL(" breakpoint instance %p\n", instance);
if (instance->GetBreakpoint() != NULL) {
TRACE_CONTROL(" -> already has breakpoint\n");
continue;
}
target_addr_t address = instance->Address();
Breakpoint* breakpoint = fTeam->BreakpointAtAddress(address);
if (breakpoint == NULL) {
TRACE_CONTROL(" -> no breakpoint at that address yet\n");
Image* image = fTeam->ImageByAddress(address);
if (image == NULL) {
TRACE_CONTROL(" -> no image at that address\n");
error = B_BAD_ADDRESS;
break;
}
breakpoint = new(std::nothrow) Breakpoint(image, address);
if (breakpoint == NULL || !fTeam->AddBreakpoint(breakpoint)) {
delete breakpoint;
error = B_NO_MEMORY;
break;
}
}
TRACE_CONTROL(" -> adding instance to breakpoint %p\n", breakpoint);
breakpoint->AddUserBreakpoint(instance);
instance->SetBreakpoint(breakpoint);
}
// If everything looks good so far mark the user breakpoint according to
// its new state.
if (error == B_OK)
userBreakpoint->SetEnabled(enabled);
// notify user breakpoint listeners
if (error == B_OK)
fTeam->NotifyUserBreakpointChanged(userBreakpoint);
teamLocker.Unlock();
// install/uninstall the breakpoints as needed
TRACE_CONTROL(" updating breakpoints\n");
if (error == B_OK) {
for (int32 i = 0;
UserBreakpointInstance* instance = userBreakpoint->InstanceAt(i);
i++) {
TRACE_CONTROL(" breakpoint instance %p\n", instance);
error = _UpdateBreakpointInstallation(instance->GetBreakpoint());
if (error != B_OK)
break;
}
}
if (error == B_OK) {
TRACE_CONTROL(" success, marking user breakpoint valid\n");
// everything went fine -- mark the user breakpoint valid
if (!userBreakpoint->IsValid()) {
teamLocker.Lock();
userBreakpoint->SetValid(true);
userBreakpoint->AcquireReference();
fTeam->AddUserBreakpoint(userBreakpoint);
fTeam->NotifyUserBreakpointChanged(userBreakpoint);
// notify again -- the breakpoint hadn't been added before
teamLocker.Unlock();
}
} else {
// something went wrong -- revert the situation
TRACE_CONTROL(" error, reverting\n");
//.........这里部分代码省略.........