Debugger: Add condition expression member to UserBreakpoint.

- UserBreakpoint and its corresponding settings classes now
  store/recall an optional condition expression.
This commit is contained in:
Rene Gollent 2014-10-30 10:12:21 -04:00
parent 854b341612
commit 65a10b5000
6 changed files with 45 additions and 11 deletions

View File

@ -2122,6 +2122,7 @@ TeamDebugger::_LoadSettings()
BReference<UserBreakpoint> breakpointReference(breakpoint, true);
breakpoint->SetHidden(breakpointSetting->IsHidden());
breakpoint->SetCondition(breakpointSetting->Condition());
// install it
fBreakpointManager->InstallUserBreakpoint(breakpoint,

View File

@ -1,6 +1,6 @@
/*
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Copyright 2013, Rene Gollent, rene@gollent.com.
* Copyright 2013-2014, Rene Gollent, rene@gollent.com.
* Distributed under the terms of the MIT License.
*/
@ -101,7 +101,8 @@ UserBreakpoint::UserBreakpoint(const UserBreakpointLocation& location)
fLocation(location),
fValid(false),
fEnabled(false),
fHidden(false)
fHidden(false),
fConditionExpression()
{
}
@ -169,3 +170,10 @@ UserBreakpoint::SetHidden(bool hidden)
{
fHidden = hidden;
}
void
UserBreakpoint::SetCondition(const BString& conditionExpression)
{
fConditionExpression = conditionExpression;
}

View File

@ -1,6 +1,6 @@
/*
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Copyright 2013, Rene Gollent, rene@gollent.com.
* Copyright 2013-2014, Rene Gollent, rene@gollent.com.
* Distributed under the terms of the MIT License.
*/
#ifndef USER_BREAKPOINT_H
@ -12,6 +12,7 @@
#include <util/DoublyLinkedList.h>
#include "SourceLocation.h"
#include "String.h"
#include "Types.h"
@ -104,6 +105,13 @@ public:
bool IsHidden() const { return fHidden; }
void SetHidden(bool hidden);
bool HasCondition() const
{ return !fConditionExpression.IsEmpty(); }
const BString& Condition() const
{ return fConditionExpression; }
void SetCondition(
const BString& conditionExpression);
private:
typedef BObjectList<UserBreakpointInstance> InstanceList;
@ -113,6 +121,7 @@ private:
bool fValid;
bool fEnabled;
bool fHidden;
BString fConditionExpression;
};

View File

@ -1,6 +1,6 @@
/*
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Copyright 2013, Rene Gollent, rene@gollent.com.
* Copyright 2013-2014, Rene Gollent, rene@gollent.com.
* Distributed under the terms of the MIT License.
*/
@ -22,7 +22,8 @@ BreakpointSetting::BreakpointSetting()
fSourceLocation(),
fRelativeAddress(0),
fEnabled(false),
fHidden(false)
fHidden(false),
fConditionExpression()
{
}
@ -34,7 +35,8 @@ BreakpointSetting::BreakpointSetting(const BreakpointSetting& other)
fSourceLocation(other.fSourceLocation),
fRelativeAddress(other.fRelativeAddress),
fEnabled(other.fEnabled),
fHidden(other.fHidden)
fHidden(other.fHidden),
fConditionExpression(other.fConditionExpression)
{
if (fFunctionID != NULL)
fFunctionID->AcquireReference();
@ -49,7 +51,7 @@ BreakpointSetting::~BreakpointSetting()
status_t
BreakpointSetting::SetTo(const UserBreakpointLocation& location, bool enabled,
bool hidden)
bool hidden, const BString& conditionExpression)
{
_Unset();
@ -64,6 +66,7 @@ BreakpointSetting::SetTo(const UserBreakpointLocation& location, bool enabled,
fRelativeAddress = location.RelativeAddress();
fEnabled = enabled;
fHidden = hidden;
fConditionExpression = conditionExpression;
return B_OK;
}
@ -100,6 +103,9 @@ BreakpointSetting::SetTo(const BMessage& archive)
if (archive.FindBool("hidden", &fHidden) != B_OK)
fHidden = false;
if (archive.FindString("condition", &fConditionExpression) != B_OK)
fConditionExpression.Truncate(0);
return B_OK;
}
@ -122,7 +128,9 @@ BreakpointSetting::WriteTo(BMessage& archive) const
|| (error = archive.AddUInt64("relativeAddress", fRelativeAddress))
!= B_OK
|| (error = archive.AddBool("enabled", fEnabled)) != B_OK
|| (error = archive.AddBool("hidden", fHidden)) != B_OK) {
|| (error = archive.AddBool("hidden", fHidden)) != B_OK
|| (error = archive.AddString("condition", fConditionExpression))
!= B_OK) {
return error;
}
@ -147,6 +155,7 @@ BreakpointSetting::operator=(const BreakpointSetting& other)
fRelativeAddress = other.fRelativeAddress;
fEnabled = other.fEnabled;
fHidden = other.fHidden;
fConditionExpression = other.fConditionExpression;
return *this;
}
@ -164,4 +173,5 @@ BreakpointSetting::_Unset()
fSourceLocation = SourceLocation();
fRelativeAddress = 0;
fEnabled = false;
fConditionExpression.Truncate(0);
}

View File

@ -1,6 +1,6 @@
/*
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Copyright 2013, Rene Gollent, rene@gollent.com.
* Copyright 2013-2014, Rene Gollent, rene@gollent.com.
* Distributed under the terms of the MIT License.
*/
#ifndef BREAKPOINT_SETTING_H
@ -28,7 +28,8 @@ public:
~BreakpointSetting();
status_t SetTo(const UserBreakpointLocation& location,
bool enabled, bool hidden);
bool enabled, bool hidden,
const BString& conditionExpression);
status_t SetTo(const BMessage& archive);
status_t WriteTo(BMessage& archive) const;
@ -42,6 +43,9 @@ public:
bool IsEnabled() const { return fEnabled; }
bool IsHidden() const { return fHidden; }
const BString& Condition() const
{ return fConditionExpression; }
BreakpointSetting& operator=(const BreakpointSetting& other);
private:
@ -54,6 +58,7 @@ private:
target_addr_t fRelativeAddress;
bool fEnabled;
bool fHidden;
BString fConditionExpression;
};

View File

@ -64,7 +64,8 @@ TeamSettings::SetTo(Team* team)
return B_NO_MEMORY;
status_t error = breakpointSetting->SetTo(breakpoint->Location(),
breakpoint->IsEnabled(), breakpoint->IsHidden());
breakpoint->IsEnabled(), breakpoint->IsHidden(),
breakpoint->Condition());
if (error == B_OK && !fBreakpoints.AddItem(breakpointSetting))
error = B_NO_MEMORY;
if (error != B_OK) {