From 1904b0c99ae89ceb38012e6737389796c55799de Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Thu, 6 Nov 2014 22:49:45 -0500 Subject: [PATCH] Debugger: Add type subclass for artificial types. - For expressions we need a Type object to represent their result type. However, this doesn't need to map to an actual DwarfType, as we won't need e.g. location and storage format information to read it out of the target team, so instead derive a simple subclass representing the appropriate result type. --- src/apps/debugger/Jamfile | 1 + .../gui/model/SyntheticPrimitiveType.cpp | 95 +++++++++++++++++++ .../gui/model/SyntheticPrimitiveType.h | 44 +++++++++ 3 files changed, 140 insertions(+) create mode 100644 src/apps/debugger/user_interface/gui/model/SyntheticPrimitiveType.cpp create mode 100644 src/apps/debugger/user_interface/gui/model/SyntheticPrimitiveType.h diff --git a/src/apps/debugger/Jamfile b/src/apps/debugger/Jamfile index f6b0694ce63..75a30b9efe4 100644 --- a/src/apps/debugger/Jamfile +++ b/src/apps/debugger/Jamfile @@ -250,6 +250,7 @@ Application Debugger : GraphicalUserInterface.cpp # user_interface/gui/model + SyntheticPrimitiveType.cpp VariablesViewState.cpp VariablesViewStateHistory.cpp diff --git a/src/apps/debugger/user_interface/gui/model/SyntheticPrimitiveType.cpp b/src/apps/debugger/user_interface/gui/model/SyntheticPrimitiveType.cpp new file mode 100644 index 00000000000..52c6c78c979 --- /dev/null +++ b/src/apps/debugger/user_interface/gui/model/SyntheticPrimitiveType.cpp @@ -0,0 +1,95 @@ +/* + * Copyright 2014, Rene Gollent, rene@gollent.com. + * Distributed under the terms of the MIT License. + */ + + +#include "SyntheticPrimitiveType.h" + +#include + +#include "UiUtils.h" + + +SyntheticPrimitiveType::SyntheticPrimitiveType(uint32 typeConstant) + : + PrimitiveType(), + fTypeConstant(typeConstant), + fID(), + fName() +{ + _Init(); +} + + +SyntheticPrimitiveType::~SyntheticPrimitiveType() +{ +} + + +uint32 +SyntheticPrimitiveType::TypeConstant() const +{ + return fTypeConstant; +} + + +image_id +SyntheticPrimitiveType::ImageID() const +{ + return -1; +} + + +const BString& +SyntheticPrimitiveType::ID() const +{ + return fID; +} + + +const BString& +SyntheticPrimitiveType::Name() const +{ + return fName; +} + + +type_kind +SyntheticPrimitiveType::Kind() const +{ + return TYPE_PRIMITIVE; +} + + +target_size_t +SyntheticPrimitiveType::ByteSize() const +{ + return BVariant::SizeOfType(fTypeConstant); +} + + +status_t +SyntheticPrimitiveType::ResolveObjectDataLocation( + const ValueLocation& objectLocation, ValueLocation*& _location) +{ + _location = NULL; + return B_NOT_SUPPORTED; +} + + +status_t +SyntheticPrimitiveType::ResolveObjectDataLocation(target_addr_t objectAddress, + ValueLocation*& _location) +{ + _location = NULL; + return B_NOT_SUPPORTED; +} + + +void +SyntheticPrimitiveType::_Init() +{ + fID.SetToFormat("%p", this); + fName.SetTo(UiUtils::TypeCodeToString(fTypeConstant)); +} diff --git a/src/apps/debugger/user_interface/gui/model/SyntheticPrimitiveType.h b/src/apps/debugger/user_interface/gui/model/SyntheticPrimitiveType.h new file mode 100644 index 00000000000..19dae5875b5 --- /dev/null +++ b/src/apps/debugger/user_interface/gui/model/SyntheticPrimitiveType.h @@ -0,0 +1,44 @@ +/* + * Copyright 2014, Rene Gollent, rene@gollent.com. + * Distributed under the terms of the MIT License. + */ +#ifndef SYNTHETIC_PRIMITIVE_TYPE_H +#define SYNTHETIC_PRIMITIVE_TYPE_H + + +#include "Type.h" + +#include + + +class SyntheticPrimitiveType : public PrimitiveType { +public: + SyntheticPrimitiveType(uint32 typeConstant); + virtual ~SyntheticPrimitiveType(); + + virtual uint32 TypeConstant() const; + + virtual image_id ImageID() const; + virtual const BString& ID() const; + virtual const BString& Name() const; + virtual type_kind Kind() const; + virtual target_size_t ByteSize() const; + + virtual status_t ResolveObjectDataLocation( + const ValueLocation& objectLocation, + ValueLocation*& _location); + virtual status_t ResolveObjectDataLocation( + target_addr_t objectAddress, + ValueLocation*& _location); + +private: + void _Init(); + +private: + uint32 fTypeConstant; + BString fID; + BString fName; +}; + + +#endif // SYNTHETIC_PRIMITIVE_TYPE