From c07e2b1fe4a2dc46ab64dca162647e985f9cbfdb Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Fri, 29 Mar 2013 21:04:20 -0400 Subject: [PATCH] Add optional cpu state to Variable. - Used to preserve the CPU state for variables representing return values, since they may potentially be retrieved from registers, and these might be overwritten later in the same statement. --- src/apps/debugger/model/Variable.cpp | 10 ++++++++-- src/apps/debugger/model/Variable.h | 6 +++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/apps/debugger/model/Variable.cpp b/src/apps/debugger/model/Variable.cpp index 8e01442930..08653abcc6 100644 --- a/src/apps/debugger/model/Variable.cpp +++ b/src/apps/debugger/model/Variable.cpp @@ -6,22 +6,26 @@ #include "Variable.h" +#include "CpuState.h" #include "ObjectID.h" #include "Type.h" #include "ValueLocation.h" Variable::Variable(ObjectID* id, const BString& name, Type* type, - ValueLocation* location) + ValueLocation* location, CpuState* state) : fID(id), fName(name), fType(type), - fLocation(location) + fLocation(location), + fCpuState(state) { fID->AcquireReference(); fType->AcquireReference(); fLocation->AcquireReference(); + if (fCpuState != NULL) + fCpuState->AcquireReference(); } @@ -30,4 +34,6 @@ Variable::~Variable() fID->ReleaseReference(); fType->ReleaseReference(); fLocation->ReleaseReference(); + if (fCpuState != NULL) + fCpuState->ReleaseReference(); } diff --git a/src/apps/debugger/model/Variable.h b/src/apps/debugger/model/Variable.h index 9462c9a5d3..33fad51d78 100644 --- a/src/apps/debugger/model/Variable.h +++ b/src/apps/debugger/model/Variable.h @@ -11,6 +11,7 @@ #include +class CpuState; class ObjectID; class Type; class ValueLocation; @@ -19,19 +20,22 @@ class ValueLocation; class Variable : public BReferenceable { public: Variable(ObjectID* id, const BString& name, - Type* type, ValueLocation* location); + Type* type, ValueLocation* location, + CpuState* state = NULL); ~Variable(); ObjectID* ID() const { return fID; } const BString& Name() const { return fName; } Type* GetType() const { return fType; } ValueLocation* Location() const { return fLocation; } + CpuState* GetCpuState() const { return fCpuState; } private: ObjectID* fID; BString fName; Type* fType; ValueLocation* fLocation; + CpuState* fCpuState; };