Debugger: Split into core library and application.

- Add subfolder src/kits/debugger which contains the debugger's core
  functionality and lower layers. Correspondingly add headers/private/debugger
  for shared headers to be used by clients such as the Debugger application
  and eventual remote_debug_server. Adjust various files to account for
  differences as a result of the split and moves.
- Add libdebugger.so to minimal Jamfile.
This commit is contained in:
Rene Gollent
2016-06-04 13:18:39 -04:00
parent e6687e8f3d
commit fce4895d18
417 changed files with 492 additions and 390 deletions
@@ -0,0 +1,92 @@
/*
* Copyright 2009, Ingo Weinhold, [email protected].
* Copyright 2010, Rene Gollent, [email protected].
* Distributed under the terms of the MIT License.
*/
#ifndef FUNCTION_H
#define FUNCTION_H
#include <util/DoublyLinkedList.h>
#include <util/OpenHashTable.h>
#include "FunctionInstance.h"
#include "LocatableFile.h"
class FileSourceCode;
class Function : public BReferenceable, private LocatableFile::Listener {
public:
class Listener;
public:
Function();
~Function();
// team must be locked to access the instances
FunctionInstance* FirstInstance() const
{ return fInstances.Head(); }
FunctionInstance* LastInstance() const
{ return fInstances.Tail(); }
const FunctionInstanceList& Instances() const
{ return fInstances; }
const BString& Name() const
{ return FirstInstance()->Name(); }
const BString& PrettyName() const
{ return FirstInstance()->PrettyName(); }
LocatableFile* SourceFile() const
{ return FirstInstance()->SourceFile(); }
SourceLocation GetSourceLocation() const
{ return FirstInstance()
->GetSourceLocation(); }
FunctionID* GetFunctionID() const
{ return FirstInstance()->GetFunctionID(); }
// returns a reference
// mutable attributes follow (locking required)
FileSourceCode* GetSourceCode() const { return fSourceCode; }
function_source_state SourceCodeState() const
{ return fSourceCodeState; }
void SetSourceCode(FileSourceCode* source,
function_source_state state);
void AddListener(Listener* listener);
void RemoveListener(Listener* listener);
// package private
void AddInstance(FunctionInstance* instance);
void RemoveInstance(FunctionInstance* instance);
void NotifySourceCodeChanged();
void LocatableFileChanged(LocatableFile* file);
private:
typedef DoublyLinkedList<Listener> ListenerList;
private:
FunctionInstanceList fInstances;
FileSourceCode* fSourceCode;
function_source_state fSourceCodeState;
ListenerList fListeners;
int32 fNotificationsDisabled;
public:
// BOpenHashTable support
Function* fNext;
};
class Function::Listener : public DoublyLinkedListLinkImpl<Listener> {
public:
virtual ~Listener();
virtual void FunctionSourceCodeChanged(Function* function);
// called with lock held
};
#endif // FUNCTION_H
@@ -0,0 +1,38 @@
/*
* Copyright 2009, Ingo Weinhold, [email protected].
* Distributed under the terms of the MIT License.
*/
#ifndef FUNCTION_DEBUG_INFO_H
#define FUNCTION_DEBUG_INFO_H
#include <Referenceable.h>
#include "SourceLocation.h"
#include "Types.h"
class BString;
class LocatableFile;
class SpecificImageDebugInfo;
class FunctionDebugInfo : public BReferenceable {
public:
FunctionDebugInfo();
virtual ~FunctionDebugInfo();
virtual SpecificImageDebugInfo* GetSpecificImageDebugInfo() const = 0;
virtual target_addr_t Address() const = 0;
virtual target_size_t Size() const = 0;
virtual const BString& Name() const = 0;
virtual const BString& PrettyName() const = 0;
virtual bool IsMain() const = 0;
virtual LocatableFile* SourceFile() const = 0;
virtual SourceLocation SourceStartLocation() const = 0;
virtual SourceLocation SourceEndLocation() const = 0;
};
#endif // FUNCTION_DEBUG_INFO_H
@@ -0,0 +1,82 @@
/*
* Copyright 2009, Ingo Weinhold, [email protected].
* Distributed under the terms of the MIT License.
*/
#ifndef FUNCTION_INSTANCE_H
#define FUNCTION_INSTANCE_H
#include <util/DoublyLinkedList.h>
#include "FunctionDebugInfo.h"
enum function_source_state {
FUNCTION_SOURCE_NOT_LOADED,
FUNCTION_SOURCE_LOADING,
FUNCTION_SOURCE_LOADED,
FUNCTION_SOURCE_UNAVAILABLE
};
class DisassembledCode;
class Function;
class FunctionDebugInfo;
class FunctionID;
class ImageDebugInfo;
class FunctionInstance : public BReferenceable,
public DoublyLinkedListLinkImpl<FunctionInstance> {
public:
FunctionInstance(ImageDebugInfo* imageDebugInfo,
FunctionDebugInfo* functionDebugInfo);
~FunctionInstance();
ImageDebugInfo* GetImageDebugInfo() const
{ return fImageDebugInfo; }
Function* GetFunction() const
{ return fFunction; }
FunctionDebugInfo* GetFunctionDebugInfo() const
{ return fFunctionDebugInfo; }
target_addr_t Address() const
{ return fFunctionDebugInfo->Address(); }
target_size_t Size() const
{ return fFunctionDebugInfo->Size(); }
const BString& Name() const
{ return fFunctionDebugInfo->Name(); }
const BString& PrettyName() const
{ return fFunctionDebugInfo->PrettyName(); }
LocatableFile* SourceFile() const
{ return fFunctionDebugInfo->SourceFile(); }
SourceLocation GetSourceLocation() const
{ return fFunctionDebugInfo
->SourceStartLocation(); }
FunctionID* GetFunctionID() const;
// returns a reference
void SetFunction(Function* function);
// package private
// mutable attributes follow (locking required)
DisassembledCode* GetSourceCode() const
{ return fSourceCode; }
function_source_state SourceCodeState() const
{ return fSourceCodeState; }
void SetSourceCode(DisassembledCode* source,
function_source_state state);
private:
ImageDebugInfo* fImageDebugInfo;
Function* fFunction;
FunctionDebugInfo* fFunctionDebugInfo;
DisassembledCode* fSourceCode;
function_source_state fSourceCodeState;
};
typedef DoublyLinkedList<FunctionInstance> FunctionInstanceList;
#endif // FUNCTION_INSTANCE_H
@@ -0,0 +1,95 @@
/*
* Copyright 2009, Ingo Weinhold, [email protected].
* Copyright 2014, Rene Gollent, [email protected].
* Distributed under the terms of the MIT License.
*/
#ifndef GLOBAL_TYPE_LOOKUP_H
#define GLOBAL_TYPE_LOOKUP_H
#include <image.h>
#include <Locker.h>
#include <Referenceable.h>
#include <util/OpenHashTable.h>
class BString;
class Type;
class TypeLookupConstraints;
enum global_type_cache_scope {
GLOBAL_TYPE_CACHE_SCOPE_GLOBAL,
GLOBAL_TYPE_CACHE_SCOPE_COMPILATION_UNIT
};
class GlobalTypeCache : public BReferenceable {
public:
GlobalTypeCache();
~GlobalTypeCache();
status_t Init();
inline bool Lock();
inline void Unlock();
// cache must be locked
Type* GetType(const BString& name,
const TypeLookupConstraints &constraints
) const;
Type* GetTypeByID(const BString& id) const;
status_t AddType(Type* type);
void RemoveType(Type* type);
// cache locked by method
void RemoveTypes(image_id imageID);
private:
struct TypeEntry;
struct TypeEntryHashDefinitionByName;
struct TypeEntryHashDefinitionByID;
typedef BOpenHashTable<TypeEntryHashDefinitionByName> NameTable;
typedef BOpenHashTable<TypeEntryHashDefinitionByID> IDTable;
private:
BLocker fLock;
NameTable* fTypesByName;
IDTable* fTypesByID;
};
class GlobalTypeLookup {
public:
virtual ~GlobalTypeLookup();
virtual status_t GetType(GlobalTypeCache* cache,
const BString& name,
const TypeLookupConstraints& constraints,
Type*& _type) = 0;
// returns a reference
virtual bool HasType(GlobalTypeCache* cache,
const BString& name,
const TypeLookupConstraints& constraints)
= 0;
};
bool
GlobalTypeCache::Lock()
{
return fLock.Lock();
}
void
GlobalTypeCache::Unlock()
{
fLock.Unlock();
}
#endif // GLOBAL_TYPE_LOOKUP_H
@@ -0,0 +1,88 @@
/*
* Copyright 2009, Ingo Weinhold, [email protected].
* Copyright 2010-2013, Rene Gollent, [email protected].
* Distributed under the terms of the MIT License.
*/
#ifndef IMAGE_DEBUG_INFO_H
#define IMAGE_DEBUG_INFO_H
#include <String.h>
#include <ObjectList.h>
#include <Referenceable.h>
#include "AddressSectionTypes.h"
#include "ImageInfo.h"
#include "Types.h"
class Architecture;
class DebuggerInterface;
class FileSourceCode;
class FunctionDebugInfo;
class FunctionInstance;
class GlobalTypeCache;
class LocatableFile;
class SpecificImageDebugInfo;
class SymbolInfo;
class Type;
class TypeLookupConstraints;
class ImageDebugInfo : public BReferenceable {
public:
ImageDebugInfo(const ImageInfo& imageInfo);
~ImageDebugInfo();
const ImageInfo& GetImageInfo() const { return fImageInfo; }
bool AddSpecificInfo(SpecificImageDebugInfo* info);
status_t FinishInit(DebuggerInterface* interface);
status_t GetType(GlobalTypeCache* cache,
const BString& name,
const TypeLookupConstraints& constraints,
Type*& _type);
// returns a reference
bool HasType(const BString& name,
const TypeLookupConstraints& constraints)
const;
AddressSectionType GetAddressSectionType(target_addr_t address)
const;
int32 CountFunctions() const;
FunctionInstance* FunctionAt(int32 index) const;
FunctionInstance* FunctionAtAddress(target_addr_t address) const;
FunctionInstance* FunctionByName(const char* name) const;
FunctionInstance* MainFunction() const
{ return fMainFunction; }
status_t AddSourceCodeInfo(LocatableFile* file,
FileSourceCode* sourceCode) const;
private:
typedef BObjectList<SpecificImageDebugInfo> SpecificInfoList;
typedef BObjectList<FunctionInstance> FunctionList;
private:
static int _CompareFunctions(const FunctionInstance* a,
const FunctionInstance* b);
static int _CompareAddressFunction(
const target_addr_t* address,
const FunctionInstance* function);
static int _CompareSymbols(const SymbolInfo* a,
const SymbolInfo* b);
private:
ImageInfo fImageInfo;
SpecificInfoList fSpecificInfos;
FunctionList fFunctions;
FunctionInstance* fMainFunction;
};
#endif // IMAGE_DEBUG_INFO_H
@@ -0,0 +1,25 @@
/*
* Copyright 2009, Ingo Weinhold, [email protected].
* Distributed under the terms of the MIT License.
*/
#ifndef IMAGE_DEBUG_INFO_PROVIDER_H
#define IMAGE_DEBUG_INFO_PROVIDER_H
#include <SupportDefs.h>
class Image;
class ImageDebugInfo;
class ImageDebugInfoProvider {
public:
virtual ~ImageDebugInfoProvider();
virtual status_t GetImageDebugInfo(Image* image,
ImageDebugInfo*& _info) = 0;
// returns a reference
};
#endif // IMAGE_DEBUG_INFO_PROVIDER_H
@@ -0,0 +1,105 @@
/*
* Copyright 2009, Ingo Weinhold, [email protected].
* Copyright 2013-2014, Rene Gollent, [email protected].
* Distributed under the terms of the MIT License.
*/
#ifndef SPECIFIC_IMAGE_DEBUG_INFO_H
#define SPECIFIC_IMAGE_DEBUG_INFO_H
#include <ObjectList.h>
#include <Referenceable.h>
#include "AddressSectionTypes.h"
#include "ReturnValueInfo.h"
#include "Types.h"
class Architecture;
class BString;
class CpuState;
class DataMember;
class DebuggerInterface;
class FileSourceCode;
class FunctionDebugInfo;
class FunctionInstance;
class GlobalTypeCache;
class Image;
class ImageInfo;
class LocatableFile;
class SourceLanguage;
class SourceLocation;
class StackFrame;
class Statement;
class SymbolInfo;
class Type;
class TypeLookupConstraints;
class ValueLocation;
class SpecificImageDebugInfo : public BReferenceable {
public:
virtual ~SpecificImageDebugInfo();
virtual status_t GetFunctions(
const BObjectList<SymbolInfo>& symbols,
BObjectList<FunctionDebugInfo>& functions)
= 0;
// returns references
virtual status_t GetType(GlobalTypeCache* cache,
const BString& name,
const TypeLookupConstraints& constraints,
Type*& _type) = 0;
// returns a reference
virtual bool HasType(const BString& name,
const TypeLookupConstraints& constraints)
const = 0;
virtual AddressSectionType GetAddressSectionType(target_addr_t address)
= 0;
virtual status_t CreateFrame(Image* image,
FunctionInstance* functionInstance,
CpuState* cpuState,
bool getFullFrameInfo,
ReturnValueInfoList* returnValueInfos,
StackFrame*& _Frame,
CpuState*& _previousCpuState) = 0;
// returns reference to previous frame
// and CPU state; returned CPU state
// can be NULL; can return B_UNSUPPORTED
// getFullFrameInfo: try to retrieve
// variables/parameters if true
// (and supported)
virtual status_t GetStatement(FunctionDebugInfo* function,
target_addr_t address,
Statement*& _statement) = 0;
// returns reference
virtual status_t GetStatementAtSourceLocation(
FunctionDebugInfo* function,
const SourceLocation& sourceLocation,
Statement*& _statement) = 0;
// returns reference
virtual status_t GetSourceLanguage(FunctionDebugInfo* function,
SourceLanguage*& _language) = 0;
virtual ssize_t ReadCode(target_addr_t address, void* buffer,
size_t size) = 0;
virtual status_t AddSourceCodeInfo(LocatableFile* file,
FileSourceCode* sourceCode) = 0;
protected:
static status_t GetFunctionsFromSymbols(
const BObjectList<SymbolInfo>& symbols,
BObjectList<FunctionDebugInfo>& functions,
DebuggerInterface* interface,
const ImageInfo& imageInfo,
SpecificImageDebugInfo* info);
};
#endif // SPECIFIC_IMAGE_DEBUG_INFO_H
@@ -0,0 +1,29 @@
/*
* Copyright 2009, Ingo Weinhold, [email protected].
* Copyright 2014, Rene Gollent, [email protected].
* Distributed under the terms of the MIT License.
*/
#ifndef SPECIFIC_TEAM_DEBUG_INFO_H
#define SPECIFIC_TEAM_DEBUG_INFO_H
#include <SupportDefs.h>
class ImageDebugInfoLoadingState;
class ImageInfo;
class LocatableFile;
class SpecificImageDebugInfo;
class SpecificTeamDebugInfo {
public:
virtual ~SpecificTeamDebugInfo();
virtual status_t CreateImageDebugInfo(const ImageInfo& imageInfo,
LocatableFile* imageFile,
ImageDebugInfoLoadingState& _state,
SpecificImageDebugInfo*& _imageDebugInfo)
= 0;
};
#endif // SPECIFIC_TEAM_DEBUG_INFO_H
@@ -0,0 +1,31 @@
/*
* Copyright 2009, Ingo Weinhold, [email protected].
* Distributed under the terms of the MIT License.
*/
#ifndef STACK_FRAME_DEBUG_INFO_H
#define STACK_FRAME_DEBUG_INFO_H
#include <Referenceable.h>
#include "Types.h"
class ArrayIndexPath;
class ArrayType;
class Architecture;
class BaseType;
class DataMember;
class StackFrame;
class Type;
class ValueLocation;
class StackFrameDebugInfo : public BReferenceable {
public:
StackFrameDebugInfo();
virtual ~StackFrameDebugInfo();
};
#endif // STACK_FRAME_DEBUG_INFO_H
@@ -0,0 +1,118 @@
/*
* Copyright 2009, Ingo Weinhold, [email protected].
* Copyright 2014, Rene Gollent, [email protected].
* Distributed under the terms of the MIT License.
*/
#ifndef TEAM_DEBUG_INFO_H
#define TEAM_DEBUG_INFO_H
#include <Locker.h>
#include <ObjectList.h>
#include <Referenceable.h>
#include <util/OpenHashTable.h>
#include "GlobalTypeLookup.h"
#include "ImageInfo.h"
#include "TeamTypeInformation.h"
class Architecture;
class DebuggerInterface;
class DisassembledCode;
class FileManager;
class FileSourceCode;
class Function;
class FunctionID;
class FunctionInstance;
class ImageDebugInfo;
class ImageDebugInfoLoadingState;
class ImageInfo;
class LocatableFile;
class SourceCode;
class SourceLocation;
class SpecificTeamDebugInfo;
class TeamDebugInfo : public GlobalTypeLookup, public TeamTypeInformation {
public:
TeamDebugInfo(
DebuggerInterface* debuggerInterface,
Architecture* architecture,
FileManager* fileManager);
~TeamDebugInfo();
status_t Init();
virtual status_t GetType(GlobalTypeCache* cache,
const BString& name,
const TypeLookupConstraints& constraints,
Type*& _type);
virtual bool HasType(GlobalTypeCache* cache,
const BString& name,
const TypeLookupConstraints& constraints);
virtual status_t LookupTypeByName(const BString& name,
const TypeLookupConstraints& constraints,
Type*& _type);
virtual bool TypeExistsByName(const BString& name,
const TypeLookupConstraints& constraints);
status_t LoadImageDebugInfo(const ImageInfo& imageInfo,
LocatableFile* imageFile,
ImageDebugInfoLoadingState& state,
ImageDebugInfo*& _imageDebugInfo);
status_t LoadSourceCode(LocatableFile* file,
FileSourceCode*& _sourceCode);
// returns reference
void ClearSourceCode(LocatableFile* file);
status_t DisassembleFunction(
FunctionInstance* functionInstance,
DisassembledCode*& _sourceCode);
// returns reference
FunctionInstance* MainFunction() const
{ return fMainFunction; }
// team is locked
status_t AddImageDebugInfo(
ImageDebugInfo* imageDebugInfo);
void RemoveImageDebugInfo(
ImageDebugInfo* imageDebugInfo);
ImageDebugInfo* ImageDebugInfoByName(const char* name) const;
Function* FunctionAtSourceLocation(LocatableFile* file,
const SourceLocation& location) const;
Function* FunctionByID(FunctionID* functionID) const;
private:
struct FunctionHashDefinition;
struct SourceFileEntry;
struct SourceFileHashDefinition;
typedef BObjectList<SpecificTeamDebugInfo> SpecificInfoList;
typedef BObjectList<ImageDebugInfo> ImageList;
typedef BOpenHashTable<FunctionHashDefinition> FunctionTable;
typedef BOpenHashTable<SourceFileHashDefinition> SourceFileTable;
private:
status_t _AddFunction(Function* function);
void _RemoveFunction(Function* function);
private:
BLocker fLock;
DebuggerInterface* fDebuggerInterface;
Architecture* fArchitecture;
FileManager* fFileManager;
SpecificInfoList fSpecificInfos;
ImageList fImages;
FunctionTable* fFunctions;
SourceFileTable* fSourceFiles;
GlobalTypeCache* fTypeCache;
FunctionInstance* fMainFunction;
};
#endif // TEAM_DEBUG_INFO_H