From 698ad09748bc7e6c117d2028e324d633f2935c55 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Fri, 1 Jul 2011 02:36:32 +0000 Subject: [PATCH] * Add interface TeamTypeInformation and implement in TeamDebugInfo. Pass along to various classes that need a reference to it in order to allow value nodes to look up type information from the target team. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42354 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/debugger/Jamfile | 1 + src/apps/debugger/Jobs.cpp | 16 ++++++---- src/apps/debugger/Jobs.h | 4 +++ src/apps/debugger/TeamDebugger.cpp | 8 ++--- .../debugger/debug_info/TeamDebugInfo.cpp | 7 +++++ src/apps/debugger/debug_info/TeamDebugInfo.h | 8 ++++- src/apps/debugger/model/Team.cpp | 3 +- src/apps/debugger/model/Team.h | 9 +++++- .../debugger/model/TeamTypeInformation.cpp | 12 ++++++++ src/apps/debugger/model/TeamTypeInformation.h | 30 +++++++++++++++++++ src/apps/debugger/value/ValueLoader.cpp | 13 +++++++- src/apps/debugger/value/ValueLoader.h | 14 ++++++++- 12 files changed, 111 insertions(+), 14 deletions(-) create mode 100644 src/apps/debugger/model/TeamTypeInformation.cpp create mode 100644 src/apps/debugger/model/TeamTypeInformation.h diff --git a/src/apps/debugger/Jamfile b/src/apps/debugger/Jamfile index d01647e4c8..d5029bacc4 100644 --- a/src/apps/debugger/Jamfile +++ b/src/apps/debugger/Jamfile @@ -130,6 +130,7 @@ Application Debugger : Team.cpp TeamMemory.cpp TeamMemoryBlock.cpp + TeamTypeInformation.cpp Thread.cpp ThreadInfo.cpp Type.cpp diff --git a/src/apps/debugger/Jobs.cpp b/src/apps/debugger/Jobs.cpp index 45ec9f4fe9..2e0d189812 100644 --- a/src/apps/debugger/Jobs.cpp +++ b/src/apps/debugger/Jobs.cpp @@ -25,9 +25,10 @@ #include "StackFrameValues.h" #include "StackTrace.h" #include "Team.h" +#include "TeamDebugInfo.h" #include "TeamMemory.h" #include "TeamMemoryBlock.h" -#include "TeamDebugInfo.h" +#include "TeamTypeInformation.h" #include "Thread.h" #include "Tracing.h" #include "Type.h" @@ -416,12 +417,14 @@ LoadSourceCodeJob::Do() ResolveValueNodeValueJob::ResolveValueNodeValueJob( DebuggerInterface* debuggerInterface, Architecture* architecture, - CpuState* cpuState, ValueNodeContainer* container, ValueNode* valueNode) + CpuState* cpuState, TeamTypeInformation* typeInformation, + ValueNodeContainer* container, ValueNode* valueNode) : fKey(valueNode, JOB_TYPE_RESOLVE_VALUE_NODE_VALUE), fDebuggerInterface(debuggerInterface), fArchitecture(architecture), fCpuState(cpuState), + fTypeInformation(typeInformation), fContainer(container), fValueNode(valueNode) { @@ -534,7 +537,8 @@ ResolveValueNodeValueJob::_ResolveNodeValue() } // resolve the node location and value - ValueLoader valueLoader(fArchitecture, fDebuggerInterface, fCpuState); + ValueLoader valueLoader(fArchitecture, fDebuggerInterface, + fTypeInformation, fCpuState); ValueLocation* location; Value* value; status_t error = fValueNode->ResolvedLocationAndValue(&valueLoader, @@ -565,7 +569,8 @@ status_t ResolveValueNodeValueJob::_ResolveNodeChildLocation(ValueNodeChild* nodeChild) { // resolve the location - ValueLoader valueLoader(fArchitecture, fDebuggerInterface, fCpuState); + ValueLoader valueLoader(fArchitecture, fDebuggerInterface, + fTypeInformation, fCpuState); ValueLocation* location = NULL; status_t error = nodeChild->ResolveLocation(&valueLoader, location); BReference locationReference(location, true); @@ -605,7 +610,8 @@ ResolveValueNodeValueJob::_ResolveParentNodeValue(ValueNode* parentNode) // schedule the job status_t error = GetWorker()->ScheduleJob( new(std::nothrow) ResolveValueNodeValueJob(fDebuggerInterface, - fArchitecture, fCpuState, fContainer, parentNode)); + fArchitecture, fCpuState, fTypeInformation, fContainer, + parentNode)); if (error != B_OK) { // scheduling failed -- set the value to invalid parentNode->SetLocationAndValue(NULL, NULL, error); diff --git a/src/apps/debugger/Jobs.h b/src/apps/debugger/Jobs.h index a8c03d97a9..1cf7a06925 100644 --- a/src/apps/debugger/Jobs.h +++ b/src/apps/debugger/Jobs.h @@ -24,6 +24,7 @@ class StackFrameValues; class Team; class TeamMemory; class TeamMemoryBlock; +class TeamTypeInformation; class Thread; class Type; class TypeComponentPath; @@ -158,6 +159,7 @@ public: DebuggerInterface* debuggerInterface, Architecture* architecture, CpuState* cpuState, + TeamTypeInformation* typeInformation, ValueNodeContainer* container, ValueNode* valueNode); virtual ~ResolveValueNodeValueJob(); @@ -177,6 +179,8 @@ private: DebuggerInterface* fDebuggerInterface; Architecture* fArchitecture; CpuState* fCpuState; + TeamTypeInformation* + fTypeInformation; ValueNodeContainer* fContainer; ValueNode* fValueNode; }; diff --git a/src/apps/debugger/TeamDebugger.cpp b/src/apps/debugger/TeamDebugger.cpp index 4d7d149b8b..09031d0b9c 100644 --- a/src/apps/debugger/TeamDebugger.cpp +++ b/src/apps/debugger/TeamDebugger.cpp @@ -252,7 +252,8 @@ TeamDebugger::Init(team_id teamID, thread_id threadID, bool stopInMain) // create a team object fTeam = new(std::nothrow) ::Team(fTeamID, fDebuggerInterface, - fDebuggerInterface->GetArchitecture(), teamDebugInfo); + fDebuggerInterface->GetArchitecture(), teamDebugInfo, + teamDebugInfo); if (fTeam == NULL) return B_NO_MEMORY; @@ -625,9 +626,8 @@ TeamDebugger::ValueNodeValueRequested(CpuState* cpuState, // schedule the job status_t error = fWorker->ScheduleJob( new(std::nothrow) ResolveValueNodeValueJob(fDebuggerInterface, - fDebuggerInterface->GetArchitecture(), cpuState, container, - valueNode), - this); + fDebuggerInterface->GetArchitecture(), cpuState, + fTeam->GetTeamTypeInformation(), container, valueNode), this); if (error != B_OK) { // scheduling failed -- set the value to invalid valueNode->SetLocationAndValue(NULL, NULL, error); diff --git a/src/apps/debugger/debug_info/TeamDebugInfo.cpp b/src/apps/debugger/debug_info/TeamDebugInfo.cpp index 6a766c6180..95341dde12 100644 --- a/src/apps/debugger/debug_info/TeamDebugInfo.cpp +++ b/src/apps/debugger/debug_info/TeamDebugInfo.cpp @@ -361,6 +361,13 @@ TeamDebugInfo::Init() } +status_t +TeamDebugInfo::LookupTypeByName(const BString& name, + const TypeLookupConstraints& constraints, Type*& _type) +{ + return GetType(fTypeCache, name, constraints, _type); +} + status_t TeamDebugInfo::GetType(GlobalTypeCache* cache, const BString& name, const TypeLookupConstraints& constraints, Type*& _type) diff --git a/src/apps/debugger/debug_info/TeamDebugInfo.h b/src/apps/debugger/debug_info/TeamDebugInfo.h index adffe2df16..c4411a49be 100644 --- a/src/apps/debugger/debug_info/TeamDebugInfo.h +++ b/src/apps/debugger/debug_info/TeamDebugInfo.h @@ -14,6 +14,7 @@ #include "GlobalTypeLookup.h" #include "ImageInfo.h" +#include "TeamTypeInformation.h" class Architecture; @@ -32,7 +33,8 @@ class SourceLocation; class SpecificTeamDebugInfo; -class TeamDebugInfo : public BReferenceable, public GlobalTypeLookup { +class TeamDebugInfo : public BReferenceable, public GlobalTypeLookup, + public TeamTypeInformation { public: TeamDebugInfo( DebuggerInterface* debuggerInterface, @@ -47,6 +49,10 @@ public: const TypeLookupConstraints& constraints, Type*& _type); + virtual status_t LookupTypeByName(const BString& name, + const TypeLookupConstraints& constraints, + Type*& _type); + status_t LoadImageDebugInfo(const ImageInfo& imageInfo, LocatableFile* imageFile, ImageDebugInfo*& _imageDebugInfo); diff --git a/src/apps/debugger/model/Team.cpp b/src/apps/debugger/model/Team.cpp index 7b9844050f..6e2fad0771 100644 --- a/src/apps/debugger/model/Team.cpp +++ b/src/apps/debugger/model/Team.cpp @@ -50,11 +50,12 @@ private: Team::Team(team_id teamID, TeamMemory* teamMemory, Architecture* architecture, - TeamDebugInfo* debugInfo) + TeamDebugInfo* debugInfo, TeamTypeInformation* typeInformation) : fLock("team lock"), fID(teamID), fTeamMemory(teamMemory), + fTypeInformation(typeInformation), fArchitecture(architecture), fDebugInfo(debugInfo) { diff --git a/src/apps/debugger/model/Team.h b/src/apps/debugger/model/Team.h index 9483eb44b1..8a2f26918a 100644 --- a/src/apps/debugger/model/Team.h +++ b/src/apps/debugger/model/Team.h @@ -48,6 +48,7 @@ class SourceLocation; class Statement; class TeamDebugInfo; class TeamMemory; +class TeamTypeInformation; class UserBreakpoint; @@ -63,7 +64,8 @@ public: public: Team(team_id teamID, TeamMemory* teamMemory, Architecture* architecture, - TeamDebugInfo* debugInfo); + TeamDebugInfo* debugInfo, + TeamTypeInformation* typeInformation); ~Team(); status_t Init(); @@ -77,6 +79,9 @@ public: Architecture* GetArchitecture() const { return fArchitecture; } TeamDebugInfo* DebugInfo() const { return fDebugInfo; } + TeamTypeInformation* + GetTeamTypeInformation() const + { return fTypeInformation; } const char* Name() const { return fName.String(); } void SetName(const BString& name); @@ -172,6 +177,8 @@ private: BLocker fLock; team_id fID; TeamMemory* fTeamMemory; + TeamTypeInformation* + fTypeInformation; Architecture* fArchitecture; TeamDebugInfo* fDebugInfo; BString fName; diff --git a/src/apps/debugger/model/TeamTypeInformation.cpp b/src/apps/debugger/model/TeamTypeInformation.cpp new file mode 100644 index 0000000000..b4390bcf15 --- /dev/null +++ b/src/apps/debugger/model/TeamTypeInformation.cpp @@ -0,0 +1,12 @@ +/* + * Copyright 2011, Rene Gollent, rene@gollent.com. + * Distributed under the terms of the MIT License. + */ + + +#include "TeamTypeInformation.h" + + +TeamTypeInformation::~TeamTypeInformation() +{ +} diff --git a/src/apps/debugger/model/TeamTypeInformation.h b/src/apps/debugger/model/TeamTypeInformation.h new file mode 100644 index 0000000000..929d1acbe0 --- /dev/null +++ b/src/apps/debugger/model/TeamTypeInformation.h @@ -0,0 +1,30 @@ +/* + * Copyright 2011, Rene Gollent, rene@gollent.com. + * Distributed under the terms of the MIT License. + */ +#ifndef TEAM_TYPE_INFORMATION_H +#define TEAM_TYPE_INFORMATION_H + + +#include +#include + + +class BString; +class Type; +class TypeLookupConstraints; + + +class TeamTypeInformation { +public: + virtual ~TeamTypeInformation(); + + + virtual status_t LookupTypeByName(const BString& name, + const TypeLookupConstraints& constraints, + Type*& _type) = 0; + // returns reference +}; + + +#endif // TEAM_TYPE_INFORMATION_H diff --git a/src/apps/debugger/value/ValueLoader.cpp b/src/apps/debugger/value/ValueLoader.cpp index ef24e9521d..52d3e00028 100644 --- a/src/apps/debugger/value/ValueLoader.cpp +++ b/src/apps/debugger/value/ValueLoader.cpp @@ -11,15 +11,18 @@ #include "CpuState.h" #include "Register.h" #include "TeamMemory.h" +#include "TeamTypeInformation.h" #include "Tracing.h" +#include "TypeLookupConstraints.h" #include "ValueLocation.h" ValueLoader::ValueLoader(Architecture* architecture, TeamMemory* teamMemory, - CpuState* cpuState) + TeamTypeInformation* typeInformation, CpuState* cpuState) : fArchitecture(architecture), fTeamMemory(teamMemory), + fTypeInformation(typeInformation), fCpuState(cpuState) { // TODO: TeamMemory is not BReferenceable! @@ -208,3 +211,11 @@ ValueLoader::LoadStringValue(BVariant& location, size_t maxSize, BString& _value return fTeamMemory->ReadMemoryString(location.ToUInt64(), std::min(maxSize, kMaxStringSize), _value); } + + +status_t +ValueLoader::LookupTypeByName(const BString& name, + const TypeLookupConstraints& constraints, Type*& _type) +{ + return fTypeInformation->LookupTypeByName(name, constraints, _type); +} diff --git a/src/apps/debugger/value/ValueLoader.h b/src/apps/debugger/value/ValueLoader.h index 5a1eb4c676..26d72a6a15 100644 --- a/src/apps/debugger/value/ValueLoader.h +++ b/src/apps/debugger/value/ValueLoader.h @@ -14,13 +14,18 @@ class Architecture; class CpuState; class TeamMemory; +class TeamTypeInformation; +class Type; +class TypeLookupConstraints; class ValueLocation; class ValueLoader { public: ValueLoader(Architecture* architecture, - TeamMemory* teamMemory, CpuState* cpuState); + TeamMemory* teamMemory, + TeamTypeInformation* typeInformation, + CpuState* cpuState); // cpuState can be NULL ~ValueLoader(); @@ -37,9 +42,16 @@ public: status_t LoadStringValue(BVariant& location, size_t maxSize, BString& _value); + status_t LookupTypeByName(const BString& name, + const TypeLookupConstraints& constraints, + Type*& _type); + // returns reference + private: Architecture* fArchitecture; TeamMemory* fTeamMemory; + TeamTypeInformation* + fTypeInformation; CpuState* fCpuState; };