From 3fa429781c54a21dd23f1ac128b4e2b79b7e1b82 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Wed, 27 Mar 2013 23:27:03 -0400 Subject: [PATCH] Add ReturnValueInfo class for storing function return information. --- src/apps/debugger/model/ReturnValueInfo.cpp | 47 +++++++++++++++++++++ src/apps/debugger/model/ReturnValueInfo.h | 38 +++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 src/apps/debugger/model/ReturnValueInfo.cpp create mode 100644 src/apps/debugger/model/ReturnValueInfo.h diff --git a/src/apps/debugger/model/ReturnValueInfo.cpp b/src/apps/debugger/model/ReturnValueInfo.cpp new file mode 100644 index 0000000000..e44da3541f --- /dev/null +++ b/src/apps/debugger/model/ReturnValueInfo.cpp @@ -0,0 +1,47 @@ +/* + * Copyright 2013, Rene Gollent, rene@gollent.com. + * Distributed under the terms of the MIT License. + */ + +#include "ReturnValueInfo.h" + +#include "CpuState.h" + + +ReturnValueInfo::ReturnValueInfo() + : + BReferenceable(), + fAddress(0), + fState(NULL) +{ +} + + +ReturnValueInfo::ReturnValueInfo(target_addr_t address, CpuState* state) + : + BReferenceable(), + fAddress(address), + fState(state) +{ + state->AcquireReference(); +} + + +ReturnValueInfo::~ReturnValueInfo() +{ + if (fState != NULL) + fState->ReleaseReference(); +} + + +void +ReturnValueInfo::SetTo(target_addr_t address, CpuState* state) +{ + fAddress = address; + + if (fState != NULL) + fState->ReleaseReference(); + + fState = state; + fState->AcquireReference(); +} diff --git a/src/apps/debugger/model/ReturnValueInfo.h b/src/apps/debugger/model/ReturnValueInfo.h new file mode 100644 index 0000000000..693da13199 --- /dev/null +++ b/src/apps/debugger/model/ReturnValueInfo.h @@ -0,0 +1,38 @@ +/* + * Copyright 2013, Rene Gollent, rene@gollent.com. + * Distributed under the terms of the MIT License. + */ +#ifndef RETURN_VALUE_INFO_H +#define RETURN_VALUE_INFO_H + +#include "ObjectList.h" +#include "Referenceable.h" +#include "Types.h" + + +class CpuState; + + +class ReturnValueInfo : public BReferenceable { +public: + ReturnValueInfo(); + ReturnValueInfo(target_addr_t address, + CpuState* state); + ~ReturnValueInfo(); + + void SetTo(target_addr_t address, CpuState* state); + + target_addr_t SubroutineAddress() const + { return fAddress; } + CpuState* State() const { return fState; } + +private: + target_addr_t fAddress; + CpuState* fState; +}; + + +typedef BObjectList ReturnValueInfoList; + + +#endif // RETURN_VALUE_INFO_H