Added DwarfTeamDebugInfo and DwarfImageDebugInfo, the classes to interface with

the DWARF code. Not doing much yet.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31284 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2009-06-27 23:40:32 +00:00
parent bf4603576b
commit b5713f228a
6 changed files with 270 additions and 3 deletions
+8
View File
@@ -21,6 +21,12 @@ SubDirHdrs [ FDirName $(SUBDIR) demangler ] ;
SubDirHdrs [ FDirName $(HAIKU_TOP) src bin debug ] ;
SubDirHdrs [ FDirName $(debugAnalyzerSources) gui ] ;
SourceHdrs
DwarfImageDebugInfo.cpp
DwarfTeamDebugInfo.cpp
: [ FDirName $(SUBDIR) dwarf ]
;
Application Debugger :
BreakpointManager.cpp
Debugger.cpp
@@ -43,6 +49,8 @@ Application Debugger :
BasicFunctionDebugInfo.cpp
DebuggerImageDebugInfo.cpp
DebuggerTeamDebugInfo.cpp
DwarfImageDebugInfo.cpp
DwarfTeamDebugInfo.cpp
FunctionDebugInfo.cpp
ImageDebugInfo.cpp
ImageDebugInfoProvider.cpp
@@ -0,0 +1,96 @@
/*
* Copyright 2009, Ingo Weinhold, [email protected].
* Distributed under the terms of the MIT License.
*/
#include "DwarfImageDebugInfo.h"
#include <stdio.h>
#include <new>
#include <AutoDeleter.h>
#include "Architecture.h"
#include "CompilationUnit.h"
#include "DebugInfoEntries.h"
#include "Dwarf.h"
#include "DwarfFile.h"
DwarfImageDebugInfo::DwarfImageDebugInfo(const ImageInfo& imageInfo,
Architecture* architecture, DwarfFile* file)
:
fImageInfo(imageInfo),
fArchitecture(architecture),
fFile(file)
{
}
DwarfImageDebugInfo::~DwarfImageDebugInfo()
{
}
status_t
DwarfImageDebugInfo::Init()
{
return B_OK;
}
status_t
DwarfImageDebugInfo::GetFunctions(BObjectList<FunctionDebugInfo>& functions)
{
printf("DwarfImageDebugInfo::GetFunctions()\n");
printf(" %ld compilation units\n", fFile->CountCompilationUnits());
for (int32 i = 0; CompilationUnit* unit = fFile->CompilationUnitAt(i);
i++) {
printf(" %s:\n", unit->UnitEntry()->Name());
for (DebugInfoEntryList::ConstIterator it
= unit->UnitEntry()->OtherChildren().GetIterator();
DebugInfoEntry* entry = it.Next();) {
if (entry->Tag() != DW_TAG_subprogram)
continue;
DIESubprogram* subprogramEntry = static_cast<DIESubprogram*>(entry);
printf(" subprogram entry: %p, name: %s, declaration: %d\n",
subprogramEntry, subprogramEntry->Name(),
subprogramEntry->IsDeclaration());
}
}
// TODO:...
return B_OK;
}
status_t
DwarfImageDebugInfo::CreateFrame(Image* image, FunctionDebugInfo* function,
CpuState* cpuState, StackFrame*& _previousFrame,
CpuState*& _previousCpuState)
{
// TODO:...
return B_UNSUPPORTED;
}
status_t
DwarfImageDebugInfo::LoadSourceCode(FunctionDebugInfo* function,
SourceCode*& _sourceCode)
{
// TODO:...
return B_UNSUPPORTED;
}
status_t
DwarfImageDebugInfo::GetStatement(FunctionDebugInfo* function,
target_addr_t address, Statement*& _statement)
{
// TODO:...
return fArchitecture->GetStatement(function, address, _statement);
}
@@ -0,0 +1,45 @@
/*
* Copyright 2009, Ingo Weinhold, [email protected].
* Distributed under the terms of the MIT License.
*/
#ifndef DWARF_IMAGE_DEBUG_INFO_H
#define DWARF_IMAGE_DEBUG_INFO_H
#include "ImageInfo.h"
#include "SpecificImageDebugInfo.h"
class Architecture;
class DwarfFile;
class DwarfImageDebugInfo : public SpecificImageDebugInfo {
public:
DwarfImageDebugInfo(const ImageInfo& imageInfo,
Architecture* architecture,
DwarfFile* file);
virtual ~DwarfImageDebugInfo();
status_t Init();
virtual status_t GetFunctions(
BObjectList<FunctionDebugInfo>& functions);
virtual status_t CreateFrame(Image* image,
FunctionDebugInfo* function,
CpuState* cpuState,
StackFrame*& _previousFrame,
CpuState*& _previousCpuState);
virtual status_t LoadSourceCode(FunctionDebugInfo* function,
SourceCode*& _sourceCode);
virtual status_t GetStatement(FunctionDebugInfo* function,
target_addr_t address,
Statement*& _statement);
private:
ImageInfo fImageInfo;
Architecture* fArchitecture;
DwarfFile* fFile;
};
#endif // DWARF_IMAGE_DEBUG_INFO_H
@@ -0,0 +1,75 @@
/*
* Copyright 2009, Ingo Weinhold, [email protected].
* Distributed under the terms of the MIT License.
*/
#include "DwarfTeamDebugInfo.h"
#include <new>
#include <string.h>
#include "DwarfImageDebugInfo.h"
#include "DwarfManager.h"
DwarfTeamDebugInfo::DwarfTeamDebugInfo(Architecture* architecture)
:
fArchitecture(architecture),
fManager(NULL)
{
}
DwarfTeamDebugInfo::~DwarfTeamDebugInfo()
{
delete fManager;
}
status_t
DwarfTeamDebugInfo::Init()
{
fManager = new(std::nothrow) DwarfManager;
if (fManager == NULL)
return B_NO_MEMORY;
status_t error = fManager->Init();
if (error != B_OK)
return error;
return B_OK;
}
status_t
DwarfTeamDebugInfo::CreateImageDebugInfo(const ImageInfo& imageInfo,
SpecificImageDebugInfo*& _imageDebugInfo)
{
// We only want images that belong to shared objects.
if (strchr(imageInfo.Name(), '/') == NULL)
return B_ENTRY_NOT_FOUND;
// try to load the DWARF file
DwarfFile* file;
status_t error = fManager->LoadFile(imageInfo.Name(), file);
if (error == B_OK)
error = fManager->FinishLoading();
if (error != B_OK)
return error;
// create the image debug info
DwarfImageDebugInfo* debuggerInfo = new(std::nothrow) DwarfImageDebugInfo(
imageInfo, fArchitecture, file);
if (debuggerInfo == NULL)
return B_NO_MEMORY;
error = debuggerInfo->Init();
if (error != B_OK) {
delete debuggerInfo;
return error;
}
_imageDebugInfo = debuggerInfo;
return B_OK;
}
@@ -0,0 +1,32 @@
/*
* Copyright 2009, Ingo Weinhold, [email protected].
* Distributed under the terms of the MIT License.
*/
#ifndef DWARF_TEAM_DEBUG_INFO_H
#define DWARF_TEAM_DEBUG_INFO_H
#include "SpecificTeamDebugInfo.h"
class Architecture;
class DwarfManager;
class ImageInfo;
class DwarfTeamDebugInfo : public SpecificTeamDebugInfo {
public:
DwarfTeamDebugInfo(Architecture* architecture);
virtual ~DwarfTeamDebugInfo();
status_t Init();
virtual status_t CreateImageDebugInfo(const ImageInfo& imageInfo,
SpecificImageDebugInfo*& _imageDebugInfo);
private:
Architecture* fArchitecture;
DwarfManager* fManager;
};
#endif // DWARF_TEAM_DEBUG_INFO_H
+14 -3
View File
@@ -10,6 +10,7 @@
#include <AutoDeleter.h>
#include "DebuggerTeamDebugInfo.h"
#include "DwarfTeamDebugInfo.h"
#include "ImageDebugInfo.h"
#include "SpecificImageDebugInfo.h"
@@ -32,10 +33,20 @@ TeamDebugInfo::~TeamDebugInfo()
status_t
TeamDebugInfo::Init()
{
// create specific infos for all types of debug info we support
// Create specific infos for all types of debug info we support, in
// descending order of expressiveness.
// DWARF
// TODO:...
DwarfTeamDebugInfo* dwarfInfo = new(std::nothrow) DwarfTeamDebugInfo(
fArchitecture);
if (dwarfInfo == NULL || !fSpecificInfos.AddItem(dwarfInfo)) {
delete dwarfInfo;
return B_NO_MEMORY;
}
status_t error = dwarfInfo->Init();
if (error != B_OK)
return error;
// debugger based info
DebuggerTeamDebugInfo* debuggerInfo
@@ -46,7 +57,7 @@ TeamDebugInfo::Init()
return B_NO_MEMORY;
}
status_t error = debuggerInfo->Init();
error = debuggerInfo->Init();
if (error != B_OK)
return error;