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 16:54:30 -04:00
parent 854b341612
commit 65a10b5000
6 changed files with 45 additions and 11 deletions
@@ -2122,6 +2122,7 @@ TeamDebugger::_LoadSettings()
BReference<UserBreakpoint> breakpointReference(breakpoint, true); BReference<UserBreakpoint> breakpointReference(breakpoint, true);
breakpoint->SetHidden(breakpointSetting->IsHidden()); breakpoint->SetHidden(breakpointSetting->IsHidden());
breakpoint->SetCondition(breakpointSetting->Condition());
// install it // install it
fBreakpointManager->InstallUserBreakpoint(breakpoint, fBreakpointManager->InstallUserBreakpoint(breakpoint,
+10 -2
View File
@@ -1,6 +1,6 @@
/* /*
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. * 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. * Distributed under the terms of the MIT License.
*/ */
@@ -101,7 +101,8 @@ UserBreakpoint::UserBreakpoint(const UserBreakpointLocation& location)
fLocation(location), fLocation(location),
fValid(false), fValid(false),
fEnabled(false), fEnabled(false),
fHidden(false) fHidden(false),
fConditionExpression()
{ {
} }
@@ -169,3 +170,10 @@ UserBreakpoint::SetHidden(bool hidden)
{ {
fHidden = hidden; fHidden = hidden;
} }
void
UserBreakpoint::SetCondition(const BString& conditionExpression)
{
fConditionExpression = conditionExpression;
}
+10 -1
View File
@@ -1,6 +1,6 @@
/* /*
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. * 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. * Distributed under the terms of the MIT License.
*/ */
#ifndef USER_BREAKPOINT_H #ifndef USER_BREAKPOINT_H
@@ -12,6 +12,7 @@
#include <util/DoublyLinkedList.h> #include <util/DoublyLinkedList.h>
#include "SourceLocation.h" #include "SourceLocation.h"
#include "String.h"
#include "Types.h" #include "Types.h"
@@ -104,6 +105,13 @@ public:
bool IsHidden() const { return fHidden; } bool IsHidden() const { return fHidden; }
void SetHidden(bool hidden); void SetHidden(bool hidden);
bool HasCondition() const
{ return !fConditionExpression.IsEmpty(); }
const BString& Condition() const
{ return fConditionExpression; }
void SetCondition(
const BString& conditionExpression);
private: private:
typedef BObjectList<UserBreakpointInstance> InstanceList; typedef BObjectList<UserBreakpointInstance> InstanceList;
@@ -113,6 +121,7 @@ private:
bool fValid; bool fValid;
bool fEnabled; bool fEnabled;
bool fHidden; bool fHidden;
BString fConditionExpression;
}; };
@@ -1,6 +1,6 @@
/* /*
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. * 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. * Distributed under the terms of the MIT License.
*/ */
@@ -22,7 +22,8 @@ BreakpointSetting::BreakpointSetting()
fSourceLocation(), fSourceLocation(),
fRelativeAddress(0), fRelativeAddress(0),
fEnabled(false), fEnabled(false),
fHidden(false) fHidden(false),
fConditionExpression()
{ {
} }
@@ -34,7 +35,8 @@ BreakpointSetting::BreakpointSetting(const BreakpointSetting& other)
fSourceLocation(other.fSourceLocation), fSourceLocation(other.fSourceLocation),
fRelativeAddress(other.fRelativeAddress), fRelativeAddress(other.fRelativeAddress),
fEnabled(other.fEnabled), fEnabled(other.fEnabled),
fHidden(other.fHidden) fHidden(other.fHidden),
fConditionExpression(other.fConditionExpression)
{ {
if (fFunctionID != NULL) if (fFunctionID != NULL)
fFunctionID->AcquireReference(); fFunctionID->AcquireReference();
@@ -49,7 +51,7 @@ BreakpointSetting::~BreakpointSetting()
status_t status_t
BreakpointSetting::SetTo(const UserBreakpointLocation& location, bool enabled, BreakpointSetting::SetTo(const UserBreakpointLocation& location, bool enabled,
bool hidden) bool hidden, const BString& conditionExpression)
{ {
_Unset(); _Unset();
@@ -64,6 +66,7 @@ BreakpointSetting::SetTo(const UserBreakpointLocation& location, bool enabled,
fRelativeAddress = location.RelativeAddress(); fRelativeAddress = location.RelativeAddress();
fEnabled = enabled; fEnabled = enabled;
fHidden = hidden; fHidden = hidden;
fConditionExpression = conditionExpression;
return B_OK; return B_OK;
} }
@@ -100,6 +103,9 @@ BreakpointSetting::SetTo(const BMessage& archive)
if (archive.FindBool("hidden", &fHidden) != B_OK) if (archive.FindBool("hidden", &fHidden) != B_OK)
fHidden = false; fHidden = false;
if (archive.FindString("condition", &fConditionExpression) != B_OK)
fConditionExpression.Truncate(0);
return B_OK; return B_OK;
} }
@@ -122,7 +128,9 @@ BreakpointSetting::WriteTo(BMessage& archive) const
|| (error = archive.AddUInt64("relativeAddress", fRelativeAddress)) || (error = archive.AddUInt64("relativeAddress", fRelativeAddress))
!= B_OK != B_OK
|| (error = archive.AddBool("enabled", fEnabled)) != 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; return error;
} }
@@ -147,6 +155,7 @@ BreakpointSetting::operator=(const BreakpointSetting& other)
fRelativeAddress = other.fRelativeAddress; fRelativeAddress = other.fRelativeAddress;
fEnabled = other.fEnabled; fEnabled = other.fEnabled;
fHidden = other.fHidden; fHidden = other.fHidden;
fConditionExpression = other.fConditionExpression;
return *this; return *this;
} }
@@ -164,4 +173,5 @@ BreakpointSetting::_Unset()
fSourceLocation = SourceLocation(); fSourceLocation = SourceLocation();
fRelativeAddress = 0; fRelativeAddress = 0;
fEnabled = false; fEnabled = false;
fConditionExpression.Truncate(0);
} }
@@ -1,6 +1,6 @@
/* /*
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. * 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. * Distributed under the terms of the MIT License.
*/ */
#ifndef BREAKPOINT_SETTING_H #ifndef BREAKPOINT_SETTING_H
@@ -28,7 +28,8 @@ public:
~BreakpointSetting(); ~BreakpointSetting();
status_t SetTo(const UserBreakpointLocation& location, 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 SetTo(const BMessage& archive);
status_t WriteTo(BMessage& archive) const; status_t WriteTo(BMessage& archive) const;
@@ -42,6 +43,9 @@ public:
bool IsEnabled() const { return fEnabled; } bool IsEnabled() const { return fEnabled; }
bool IsHidden() const { return fHidden; } bool IsHidden() const { return fHidden; }
const BString& Condition() const
{ return fConditionExpression; }
BreakpointSetting& operator=(const BreakpointSetting& other); BreakpointSetting& operator=(const BreakpointSetting& other);
private: private:
@@ -54,6 +58,7 @@ private:
target_addr_t fRelativeAddress; target_addr_t fRelativeAddress;
bool fEnabled; bool fEnabled;
bool fHidden; bool fHidden;
BString fConditionExpression;
}; };
+2 -1
View File
@@ -64,7 +64,8 @@ TeamSettings::SetTo(Team* team)
return B_NO_MEMORY; return B_NO_MEMORY;
status_t error = breakpointSetting->SetTo(breakpoint->Location(), status_t error = breakpointSetting->SetTo(breakpoint->Location(),
breakpoint->IsEnabled(), breakpoint->IsHidden()); breakpoint->IsEnabled(), breakpoint->IsHidden(),
breakpoint->Condition());
if (error == B_OK && !fBreakpoints.AddItem(breakpointSetting)) if (error == B_OK && !fBreakpoints.AddItem(breakpointSetting))
error = B_NO_MEMORY; error = B_NO_MEMORY;
if (error != B_OK) { if (error != B_OK) {