Skip to content

Commit

Permalink
Debugger: Add type subclass for artificial types.
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
anevilyak committed Nov 8, 2014
1 parent 1af58b2 commit 1904b0c
Show file tree
Hide file tree
Showing 3 changed files with 140 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/apps/debugger/Jamfile
Expand Up @@ -250,6 +250,7 @@ Application Debugger :
GraphicalUserInterface.cpp

# user_interface/gui/model
SyntheticPrimitiveType.cpp
VariablesViewState.cpp
VariablesViewStateHistory.cpp

Expand Down
@@ -0,0 +1,95 @@
/*
* Copyright 2014, Rene Gollent, rene@gollent.com.
* Distributed under the terms of the MIT License.
*/


#include "SyntheticPrimitiveType.h"

#include <Variant.h>

#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));
}
@@ -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 <String.h>


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

0 comments on commit 1904b0c

Please sign in to comment.