[Haiku-commits] r31321 - in haiku/trunk/src/apps/debugger: . arch arch/x86/disasm debug_info debugger_interface dwarf elf gui/team_window model types
bonefish at BerliOS
bonefish at mail.berlios.de
Tue Jun 30 00:38:20 CEST 2009
Author: bonefish
Date: 2009-06-30 00:38:15 +0200 (Tue, 30 Jun 2009)
New Revision: 31321
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31321&view=rev
Added:
haiku/trunk/src/apps/debugger/debug_info/DwarfFunctionDebugInfo.cpp
haiku/trunk/src/apps/debugger/debug_info/DwarfFunctionDebugInfo.h
haiku/trunk/src/apps/debugger/dwarf/DwarfUtils.cpp
haiku/trunk/src/apps/debugger/dwarf/DwarfUtils.h
haiku/trunk/src/apps/debugger/types/
haiku/trunk/src/apps/debugger/types/SourceLocation.h
haiku/trunk/src/apps/debugger/types/TargetAddressRange.h
haiku/trunk/src/apps/debugger/types/TargetAddressRangeList.cpp
haiku/trunk/src/apps/debugger/types/TargetAddressRangeList.h
haiku/trunk/src/apps/debugger/types/Types.h
Removed:
haiku/trunk/src/apps/debugger/arch/ArchitectureTypes.h
haiku/trunk/src/apps/debugger/arch/TargetAddressRange.h
haiku/trunk/src/apps/debugger/model/SourceLocation.h
Modified:
haiku/trunk/src/apps/debugger/Array.h
haiku/trunk/src/apps/debugger/Jamfile
haiku/trunk/src/apps/debugger/arch/Architecture.h
haiku/trunk/src/apps/debugger/arch/CpuState.h
haiku/trunk/src/apps/debugger/arch/InstructionInfo.h
haiku/trunk/src/apps/debugger/arch/x86/disasm/DisassemblerX86.h
haiku/trunk/src/apps/debugger/arch/x86/disasm/Jamfile
haiku/trunk/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp
haiku/trunk/src/apps/debugger/debug_info/DwarfImageDebugInfo.h
haiku/trunk/src/apps/debugger/debug_info/FunctionDebugInfo.h
haiku/trunk/src/apps/debugger/debug_info/ImageDebugInfo.h
haiku/trunk/src/apps/debugger/debug_info/SpecificImageDebugInfo.h
haiku/trunk/src/apps/debugger/debugger_interface/DebugEvent.h
haiku/trunk/src/apps/debugger/dwarf/AttributeValue.h
haiku/trunk/src/apps/debugger/dwarf/DebugInfoEntries.cpp
haiku/trunk/src/apps/debugger/dwarf/DebugInfoEntries.h
haiku/trunk/src/apps/debugger/dwarf/DebugInfoEntry.cpp
haiku/trunk/src/apps/debugger/dwarf/DebugInfoEntry.h
haiku/trunk/src/apps/debugger/dwarf/DwarfFile.cpp
haiku/trunk/src/apps/debugger/dwarf/DwarfFile.h
haiku/trunk/src/apps/debugger/dwarf/Jamfile
haiku/trunk/src/apps/debugger/elf/ElfFile.cpp
haiku/trunk/src/apps/debugger/elf/ElfFile.h
haiku/trunk/src/apps/debugger/gui/team_window/SourceView.h
haiku/trunk/src/apps/debugger/model/Breakpoint.h
haiku/trunk/src/apps/debugger/model/ImageInfo.h
haiku/trunk/src/apps/debugger/model/StackFrame.h
haiku/trunk/src/apps/debugger/model/Statement.h
haiku/trunk/src/apps/debugger/model/SymbolInfo.h
Log:
* Renamed ArchitectureTypes.h to Types.h.
* Created "types" subdirectory for basic types and moved Types.h,
SourceLocation, TargetAddressRange there.
* Added TargetAddressRangeList, representing a list of address ranges.
* Array: Added copy constructor and assignment operator.
* Added DwarfFunctionDebugInfo.
* ElfFile: Also read the program headers and provide access to the segment
information.
* DWARF:
- Some work on DIECompileUnitBase and DIESubprogram to handle attributes we
need.
- Added DwarfUtils class which provides static utility methods. Currently some
to get DIE names. Only provisionally implemented yet.
- Read range list attribute values from the .debug_ranges section. Extended
AttributeValue to handle them correctly (ref-counting).
* DwarfImageDebugInfo:
- Implemented GetFunctions() for real, i.e. we return functions for all
subprogram debug info entries we find (those that refer to actual
functions, that is).
- Implemented the fallback part of LoadSourceCode() (reading the code from the
file and disassembling it).
Things should hopefully work as before, just a bit slower and with less accurate
function names, if DWARF debug info is available. Promising, eh? ;-)
Modified: haiku/trunk/src/apps/debugger/Array.h
===================================================================
--- haiku/trunk/src/apps/debugger/Array.h 2009-06-29 22:12:20 UTC (rev 31320)
+++ haiku/trunk/src/apps/debugger/Array.h 2009-06-29 22:38:15 UTC (rev 31321)
@@ -14,6 +14,7 @@
class Array {
public:
inline Array();
+ Array(const Array<Element>& other);
~Array();
inline int Size() const { return fSize; }
@@ -34,6 +35,8 @@
inline Element& operator[](int index);
inline const Element& operator[](int index) const;
+ Array<Element>& operator=(const Array<Element>& other);
+
private:
static const int kMinCapacity = 8;
@@ -57,6 +60,17 @@
template<typename Element>
+Array<Element>::Array(const Array<Element>& other)
+ :
+ fElements(NULL),
+ fSize(0),
+ fCapacity(0)
+{
+ *this = other;
+}
+
+
+template<typename Element>
Array<Element>::~Array()
{
free(fElements);
@@ -178,6 +192,21 @@
template<typename Element>
+Array<Element>&
+Array<Element>::operator=(const Array<Element>& other)
+{
+ Clear();
+
+ if (other.fSize > 0 && _Resize(0, other.fSize)) {
+ fSize = other.fSize;
+ memcpy(fElements, other.fElements, fSize * sizeof(Element));
+ }
+
+ return *this;
+}
+
+
+template<typename Element>
bool
Array<Element>::_Resize(int index, int delta)
{
Modified: haiku/trunk/src/apps/debugger/Jamfile
===================================================================
--- haiku/trunk/src/apps/debugger/Jamfile 2009-06-29 22:12:20 UTC (rev 31320)
+++ haiku/trunk/src/apps/debugger/Jamfile 2009-06-29 22:38:15 UTC (rev 31321)
@@ -13,6 +13,7 @@
SEARCH_SOURCE += [ FDirName $(SUBDIR) elf ] ;
SEARCH_SOURCE += [ FDirName $(SUBDIR) gui team_window ] ;
SEARCH_SOURCE += [ FDirName $(SUBDIR) model ] ;
+SEARCH_SOURCE += [ FDirName $(SUBDIR) types ] ;
local debugAnalyzerSources
= [ FDirName $(HAIKU_TOP) src apps debuganalyzer ] ;
@@ -22,6 +23,7 @@
SubDirHdrs [ FDirName $(debugAnalyzerSources) gui ] ;
SourceHdrs
+ DwarfFunctionDebugInfo.cpp
DwarfImageDebugInfo.cpp
DwarfTeamDebugInfo.cpp
: [ FDirName $(SUBDIR) dwarf ]
@@ -49,6 +51,7 @@
BasicFunctionDebugInfo.cpp
DebuggerImageDebugInfo.cpp
DebuggerTeamDebugInfo.cpp
+ DwarfFunctionDebugInfo.cpp
DwarfImageDebugInfo.cpp
DwarfTeamDebugInfo.cpp
FunctionDebugInfo.cpp
@@ -90,6 +93,9 @@
Thread.cpp
ThreadInfo.cpp
+ # types
+ TargetAddressRangeList.cpp
+
:
<nogrist>Debugger_demangler.o
<nogrist>Debugger_disasm_x86.o
Modified: haiku/trunk/src/apps/debugger/arch/Architecture.h
===================================================================
--- haiku/trunk/src/apps/debugger/arch/Architecture.h 2009-06-29 22:12:20 UTC (rev 31320)
+++ haiku/trunk/src/apps/debugger/arch/Architecture.h 2009-06-29 22:38:15 UTC (rev 31321)
@@ -9,7 +9,7 @@
#include <Referenceable.h>
-#include "ArchitectureTypes.h"
+#include "Types.h"
class CpuState;
Deleted: haiku/trunk/src/apps/debugger/arch/ArchitectureTypes.h
Modified: haiku/trunk/src/apps/debugger/arch/CpuState.h
===================================================================
--- haiku/trunk/src/apps/debugger/arch/CpuState.h 2009-06-29 22:12:20 UTC (rev 31320)
+++ haiku/trunk/src/apps/debugger/arch/CpuState.h 2009-06-29 22:38:15 UTC (rev 31321)
@@ -10,7 +10,7 @@
#include <Referenceable.h>
#include <Variant.h>
-#include "ArchitectureTypes.h"
+#include "Types.h"
class Register;
Modified: haiku/trunk/src/apps/debugger/arch/InstructionInfo.h
===================================================================
--- haiku/trunk/src/apps/debugger/arch/InstructionInfo.h 2009-06-29 22:12:20 UTC (rev 31320)
+++ haiku/trunk/src/apps/debugger/arch/InstructionInfo.h 2009-06-29 22:38:15 UTC (rev 31321)
@@ -7,7 +7,7 @@
#include <String.h>
-#include "ArchitectureTypes.h"
+#include "Types.h"
enum instruction_type {
Deleted: haiku/trunk/src/apps/debugger/arch/TargetAddressRange.h
Modified: haiku/trunk/src/apps/debugger/arch/x86/disasm/DisassemblerX86.h
===================================================================
--- haiku/trunk/src/apps/debugger/arch/x86/disasm/DisassemblerX86.h 2009-06-29 22:12:20 UTC (rev 31320)
+++ haiku/trunk/src/apps/debugger/arch/x86/disasm/DisassemblerX86.h 2009-06-29 22:38:15 UTC (rev 31321)
@@ -7,7 +7,7 @@
#include <String.h>
-#include "ArchitectureTypes.h"
+#include "Types.h"
class DisassemblerX86 {
Modified: haiku/trunk/src/apps/debugger/arch/x86/disasm/Jamfile
===================================================================
--- haiku/trunk/src/apps/debugger/arch/x86/disasm/Jamfile 2009-06-29 22:12:20 UTC (rev 31320)
+++ haiku/trunk/src/apps/debugger/arch/x86/disasm/Jamfile 2009-06-29 22:38:15 UTC (rev 31321)
@@ -7,6 +7,7 @@
UseHeaders [ LibraryHeaders [ FDirName udis86 libudis86 ] ] ;
SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) $(DOTDOT) ] ;
+SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) $(DOTDOT) $(DOTDOT) types ] ;
MergeObject Debugger_disasm_x86.o
Added: haiku/trunk/src/apps/debugger/debug_info/DwarfFunctionDebugInfo.cpp
===================================================================
--- haiku/trunk/src/apps/debugger/debug_info/DwarfFunctionDebugInfo.cpp 2009-06-29 22:12:20 UTC (rev 31320)
+++ haiku/trunk/src/apps/debugger/debug_info/DwarfFunctionDebugInfo.cpp 2009-06-29 22:38:15 UTC (rev 31321)
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de.
+ * Distributed under the terms of the MIT License.
+ */
+
+#include "DwarfFunctionDebugInfo.h"
+
+#include "DebugInfoEntries.h"
+#include "DwarfImageDebugInfo.h"
+#include "TargetAddressRangeList.h"
+
+
+DwarfFunctionDebugInfo::DwarfFunctionDebugInfo(
+ DwarfImageDebugInfo* imageDebugInfo, DIESubprogram* subprogramEntry,
+ TargetAddressRangeList* addressRanges, const BString& name)
+ :
+ fImageDebugInfo(imageDebugInfo),
+ fAddressRanges(addressRanges),
+ fName(name)
+{
+ fImageDebugInfo->AddReference();
+ fAddressRanges->AddReference();
+}
+
+
+DwarfFunctionDebugInfo::~DwarfFunctionDebugInfo()
+{
+ fAddressRanges->RemoveReference();
+ fImageDebugInfo->RemoveReference();
+}
+
+
+SpecificImageDebugInfo*
+DwarfFunctionDebugInfo::GetSpecificImageDebugInfo() const
+{
+ return fImageDebugInfo;
+}
+
+
+target_addr_t
+DwarfFunctionDebugInfo::Address() const
+{
+ return fAddressRanges->LowestAddress() + fImageDebugInfo->RelocationDelta();
+}
+
+
+target_size_t
+DwarfFunctionDebugInfo::Size() const
+{
+ return fAddressRanges->CoveringRange().Size();
+}
+
+
+const char*
+DwarfFunctionDebugInfo::Name() const
+{
+ return fName.String();
+}
+
+
+const char*
+DwarfFunctionDebugInfo::PrettyName() const
+{
+ return fName.String();
+}
+
+
+const char*
+DwarfFunctionDebugInfo::SourceFileName() const
+{
+ return NULL;
+}
+
+
+SourceLocation
+DwarfFunctionDebugInfo::SourceStartLocation() const
+{
+ return SourceLocation();
+}
+
+
+SourceLocation
+DwarfFunctionDebugInfo::SourceEndLocation() const
+{
+ return SourceLocation();
+}
Added: haiku/trunk/src/apps/debugger/debug_info/DwarfFunctionDebugInfo.h
===================================================================
--- haiku/trunk/src/apps/debugger/debug_info/DwarfFunctionDebugInfo.h 2009-06-29 22:12:20 UTC (rev 31320)
+++ haiku/trunk/src/apps/debugger/debug_info/DwarfFunctionDebugInfo.h 2009-06-29 22:38:15 UTC (rev 31321)
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de.
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef DWARF_FUNCTION_DEBUG_INFO_H
+#define DWARF_FUNCTION_DEBUG_INFO_H
+
+#include <String.h>
+
+#include "FunctionDebugInfo.h"
+
+
+class DIESubprogram;
+class DwarfImageDebugInfo;
+class TargetAddressRangeList;
+
+
+class DwarfFunctionDebugInfo : public FunctionDebugInfo {
+public:
+ DwarfFunctionDebugInfo(
+ DwarfImageDebugInfo* imageDebugInfo,
+ DIESubprogram* subprogramEntry,
+ TargetAddressRangeList* addressRanges,
+ const BString& name);
+ virtual ~DwarfFunctionDebugInfo();
+
+ virtual SpecificImageDebugInfo* GetSpecificImageDebugInfo() const;
+ virtual target_addr_t Address() const;
+ virtual target_size_t Size() const;
+ virtual const char* Name() const;
+ virtual const char* PrettyName() const;
+
+ virtual const char* SourceFileName() const;
+ virtual SourceLocation SourceStartLocation() const;
+ virtual SourceLocation SourceEndLocation() const;
+
+private:
+ DwarfImageDebugInfo* fImageDebugInfo;
+ TargetAddressRangeList* fAddressRanges;
+ const BString fName;
+};
+
+
+#endif // DWARF_FUNCTION_DEBUG_INFO_H
Modified: haiku/trunk/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp
===================================================================
--- haiku/trunk/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp 2009-06-29 22:12:20 UTC (rev 31320)
+++ haiku/trunk/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp 2009-06-29 22:38:15 UTC (rev 31321)
@@ -6,6 +6,7 @@
#include "DwarfImageDebugInfo.h"
#include <stdio.h>
+#include <unistd.h>
#include <new>
@@ -16,6 +17,9 @@
#include "DebugInfoEntries.h"
#include "Dwarf.h"
#include "DwarfFile.h"
+#include "DwarfFunctionDebugInfo.h"
+#include "DwarfUtils.h"
+#include "ElfFile.h"
DwarfImageDebugInfo::DwarfImageDebugInfo(const ImageInfo& imageInfo,
@@ -23,7 +27,9 @@
:
fImageInfo(imageInfo),
fArchitecture(architecture),
- fFile(file)
+ fFile(file),
+ fTextSegment(NULL),
+ fRelocationDelta(0)
{
}
@@ -36,6 +42,12 @@
status_t
DwarfImageDebugInfo::Init()
{
+ fTextSegment = fFile->GetElfFile()->TextSegment();
+ if (fTextSegment == NULL)
+ return B_ENTRY_NOT_FOUND;
+
+ fRelocationDelta = fImageInfo.TextBase() - fTextSegment->LoadAddress();
+
return B_OK;
}
@@ -48,22 +60,94 @@
for (int32 i = 0; CompilationUnit* unit = fFile->CompilationUnitAt(i);
i++) {
- printf(" %s:\n", unit->UnitEntry()->Name());
+ DIECompileUnitBase* unitEntry = unit->UnitEntry();
+// printf(" %s:\n", unitEntry->Name());
+// printf(" address ranges:\n");
+// TargetAddressRangeList* rangeList = unitEntry->AddressRanges();
+// if (rangeList != NULL) {
+// int32 count = rangeList->CountRanges();
+// for (int32 i = 0; i < count; i++) {
+// TargetAddressRange range = rangeList->RangeAt(i);
+// printf(" %#llx - %#llx\n", range.Start(), range.End());
+// }
+// } else {
+// printf(" %#llx - %#llx\n", (target_addr_t)unitEntry->LowPC(),
+// (target_addr_t)unitEntry->HighPC());
+// }
+// printf(" functions:\n");
for (DebugInfoEntryList::ConstIterator it
- = unit->UnitEntry()->OtherChildren().GetIterator();
+ = 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());
+
+ // ignore declarations, prototypes, and inlined functions
+ if (subprogramEntry->IsDeclaration()
+ || subprogramEntry->IsPrototyped()
+ || subprogramEntry->Inline() == DW_INL_inlined
+ || subprogramEntry->Inline() == DW_INL_declared_inlined
+ || subprogramEntry->AbstractOrigin() != NULL) {
+ continue;
+ }
+
+ // get the name
+ BString name;
+ DwarfUtils::GetFullyQualifiedDIEName(subprogramEntry, name);
+ if (name.Length() == 0)
+ continue;
+
+ // get the address ranges
+ TargetAddressRangeList* rangeList
+ = subprogramEntry->AddressRanges();
+ Reference<TargetAddressRangeList> rangeListReference(rangeList);
+ if (rangeList == NULL) {
+ target_addr_t lowPC = subprogramEntry->LowPC();
+ target_addr_t highPC = subprogramEntry->HighPC();
+ if (lowPC >= highPC)
+ continue;
+
+ rangeList = new(std::nothrow) TargetAddressRangeList(
+ TargetAddressRange(lowPC, highPC - lowPC));
+ if (rangeList == NULL)
+ return B_NO_MEMORY;
+ // TODO: Clean up already added functions!
+ rangeListReference.SetTo(rangeList, true);
+ }
+
+ // create and add the functions
+ DwarfFunctionDebugInfo* function
+ = new(std::nothrow) DwarfFunctionDebugInfo(this,
+ subprogramEntry, rangeList, name);
+ if (function == NULL || !functions.AddItem(function)) {
+ delete function;
+ return B_NO_MEMORY;
+ // TODO: Clean up already added functions!
+ }
+
+// BString name;
+// DwarfUtils::GetFullyQualifiedDIEName(subprogramEntry, name);
+// printf(" subprogram entry: %p, name: %s, declaration: %d\n",
+// subprogramEntry, name.String(),
+// subprogramEntry->IsDeclaration());
+//
+// rangeList = subprogramEntry->AddressRanges();
+// if (rangeList != NULL) {
+// int32 count = rangeList->CountRanges();
+// for (int32 i = 0; i < count; i++) {
+// TargetAddressRange range = rangeList->RangeAt(i);
+// printf(" %#llx - %#llx\n", range.Start(), range.End());
+// }
+// } else {
+// printf(" %#llx - %#llx\n",
+// (target_addr_t)subprogramEntry->LowPC(),
+// (target_addr_t)subprogramEntry->HighPC());
+// }
}
}
- // TODO:...
return B_OK;
}
@@ -82,8 +166,25 @@
DwarfImageDebugInfo::LoadSourceCode(FunctionDebugInfo* function,
SourceCode*& _sourceCode)
{
- // TODO:...
- return B_UNSUPPORTED;
+ // TODO: Load the actual source code!
+
+ static const target_size_t kMaxBufferSize = 64 * 1024;
+ target_size_t bufferSize = std::min(function->Size(), kMaxBufferSize);
+ void* buffer = malloc(bufferSize);
+ if (buffer == NULL)
+ return B_NO_MEMORY;
+ MemoryDeleter bufferDeleter(buffer);
+
+ // read the function code
+ target_addr_t functionOffset = function->Address() - fRelocationDelta
+ - fTextSegment->LoadAddress() + fTextSegment->FileOffset();
+ ssize_t bytesRead = pread(fFile->GetElfFile()->FD(), buffer, bufferSize,
+ functionOffset);
+ if (bytesRead < 0)
+ return bytesRead;
+
+ return fArchitecture->DisassembleCode(function, buffer, bytesRead,
+ _sourceCode);
}
Modified: haiku/trunk/src/apps/debugger/debug_info/DwarfImageDebugInfo.h
===================================================================
--- haiku/trunk/src/apps/debugger/debug_info/DwarfImageDebugInfo.h 2009-06-29 22:12:20 UTC (rev 31320)
+++ haiku/trunk/src/apps/debugger/debug_info/DwarfImageDebugInfo.h 2009-06-29 22:38:15 UTC (rev 31321)
@@ -11,6 +11,7 @@
class Architecture;
class DwarfFile;
+class ElfSegment;
class DwarfImageDebugInfo : public SpecificImageDebugInfo {
@@ -22,6 +23,9 @@
status_t Init();
+ target_addr_t RelocationDelta() const
+ { return fRelocationDelta; }
+
virtual status_t GetFunctions(
BObjectList<FunctionDebugInfo>& functions);
virtual status_t CreateFrame(Image* image,
@@ -39,6 +43,8 @@
ImageInfo fImageInfo;
Architecture* fArchitecture;
DwarfFile* fFile;
+ ElfSegment* fTextSegment;
+ target_addr_t fRelocationDelta;
};
Modified: haiku/trunk/src/apps/debugger/debug_info/FunctionDebugInfo.h
===================================================================
--- haiku/trunk/src/apps/debugger/debug_info/FunctionDebugInfo.h 2009-06-29 22:12:20 UTC (rev 31320)
+++ haiku/trunk/src/apps/debugger/debug_info/FunctionDebugInfo.h 2009-06-29 22:38:15 UTC (rev 31321)
@@ -8,8 +8,8 @@
#include <Referenceable.h>
#include <util/DoublyLinkedList.h>
-#include "ArchitectureTypes.h"
#include "SourceLocation.h"
+#include "Types.h"
enum function_source_state {
Modified: haiku/trunk/src/apps/debugger/debug_info/ImageDebugInfo.h
===================================================================
--- haiku/trunk/src/apps/debugger/debug_info/ImageDebugInfo.h 2009-06-29 22:12:20 UTC (rev 31320)
+++ haiku/trunk/src/apps/debugger/debug_info/ImageDebugInfo.h 2009-06-29 22:38:15 UTC (rev 31321)
@@ -10,8 +10,8 @@
#include <ObjectList.h>
#include <Referenceable.h>
-#include "ArchitectureTypes.h"
#include "ImageInfo.h"
+#include "Types.h"
class Architecture;
Modified: haiku/trunk/src/apps/debugger/debug_info/SpecificImageDebugInfo.h
===================================================================
--- haiku/trunk/src/apps/debugger/debug_info/SpecificImageDebugInfo.h 2009-06-29 22:12:20 UTC (rev 31320)
+++ haiku/trunk/src/apps/debugger/debug_info/SpecificImageDebugInfo.h 2009-06-29 22:38:15 UTC (rev 31321)
@@ -8,7 +8,7 @@
#include <ObjectList.h>
#include <Referenceable.h>
-#include "ArchitectureTypes.h"
+#include "Types.h"
class Architecture;
Modified: haiku/trunk/src/apps/debugger/debugger_interface/DebugEvent.h
===================================================================
--- haiku/trunk/src/apps/debugger/debugger_interface/DebugEvent.h 2009-06-29 22:12:20 UTC (rev 31320)
+++ haiku/trunk/src/apps/debugger/debugger_interface/DebugEvent.h 2009-06-29 22:38:15 UTC (rev 31321)
@@ -7,8 +7,8 @@
#include <debugger.h>
-#include "ArchitectureTypes.h"
#include "ImageInfo.h"
+#include "Types.h"
class CpuState;
Modified: haiku/trunk/src/apps/debugger/dwarf/AttributeValue.h
===================================================================
--- haiku/trunk/src/apps/debugger/dwarf/AttributeValue.h 2009-06-29 22:12:20 UTC (rev 31320)
+++ haiku/trunk/src/apps/debugger/dwarf/AttributeValue.h 2009-06-29 22:38:15 UTC (rev 31321)
@@ -7,6 +7,7 @@
#include "AttributeClasses.h"
#include "DwarfTypes.h"
+#include "TargetAddressRangeList.h"
class DebugInfoEntry;
@@ -21,6 +22,7 @@
} block;
uint64 constant;
bool flag;
+ TargetAddressRangeList* rangeList;
dwarf_off_t pointer;
DebugInfoEntry* reference;
const char* string;
@@ -30,6 +32,100 @@
uint8 attributeClass;
bool isSigned;
+ AttributeValue()
+ :
+ attributeClass(ATTRIBUTE_CLASS_UNKNOWN)
+ {
+ }
+
+ ~AttributeValue()
+ {
+ Unset();
+ }
+
+ void SetToAddress(dwarf_addr_t address)
+ {
+ Unset();
+ attributeClass = ATTRIBUTE_CLASS_ADDRESS;
+ this->address = address;
+ }
+
+ void SetToBlock(const void* data, dwarf_size_t length)
+ {
+ Unset();
+ attributeClass = ATTRIBUTE_CLASS_BLOCK;
+ block.data = data;
+ block.length = length;
+ }
+
+ void SetToConstant(uint64 value, bool isSigned)
+ {
+ Unset();
+ attributeClass = ATTRIBUTE_CLASS_CONSTANT;
+ this->constant = value;
+ this->isSigned = isSigned;
+ }
+
+ void SetToFlag(bool value)
+ {
+ Unset();
+ attributeClass = ATTRIBUTE_CLASS_FLAG;
+ this->flag = value;
+ }
+
+ void SetToLinePointer(dwarf_off_t value)
+ {
+ Unset();
+ attributeClass = ATTRIBUTE_CLASS_LINEPTR;
+ this->pointer = value;
+ }
+
+ void SetToLocationListPointer(dwarf_off_t value)
+ {
+ Unset();
+ attributeClass = ATTRIBUTE_CLASS_LOCLISTPTR;
+ this->pointer = value;
+ }
+
+ void SetToMacroPointer(dwarf_off_t value)
+ {
+ Unset();
+ attributeClass = ATTRIBUTE_CLASS_MACPTR;
+ this->pointer = value;
+ }
+
+ void SetToRangeList(TargetAddressRangeList* rangeList)
+ {
+ Unset();
+ attributeClass = ATTRIBUTE_CLASS_RANGELISTPTR;
+ this->rangeList = rangeList;
+ if (rangeList != NULL)
+ rangeList->AddReference();
+ }
+
+ void SetToReference(DebugInfoEntry* entry)
+ {
+ Unset();
+ attributeClass = ATTRIBUTE_CLASS_REFERENCE;
+ this->reference = entry;
+ }
+
+ void SetToString(const char* string)
+ {
+ Unset();
+ attributeClass = ATTRIBUTE_CLASS_STRING;
+ this->string = string;
+ }
+
+ void Unset()
+ {
+ if (attributeClass == ATTRIBUTE_CLASS_RANGELISTPTR
+ && rangeList != NULL) {
+ rangeList->RemoveReference();
+ }
+ attributeClass = ATTRIBUTE_CLASS_UNKNOWN;
+ }
+
const char* ToString(char* buffer, size_t size);
};
Modified: haiku/trunk/src/apps/debugger/dwarf/DebugInfoEntries.cpp
===================================================================
--- haiku/trunk/src/apps/debugger/dwarf/DebugInfoEntries.cpp 2009-06-29 22:12:20 UTC (rev 31320)
+++ haiku/trunk/src/apps/debugger/dwarf/DebugInfoEntries.cpp 2009-06-29 22:38:15 UTC (rev 31321)
@@ -24,6 +24,7 @@
fStatementListOffset(0),
fMacroInfoOffset(0),
// TODO: Is 0 a good invalid offset?
+ fAddressRanges(NULL),
fBaseTypesUnit(NULL),
fLanguage(0),
fIdentifierCase(0),
@@ -32,6 +33,13 @@
}
+DIECompileUnitBase::~DIECompileUnitBase()
+{
+ if (fAddressRanges != NULL)
+ fAddressRanges->RemoveReference();
+}
+
+
status_t
DIECompileUnitBase::InitAfterAttributes(DebugInfoEntryInitInfo& info)
{
@@ -65,6 +73,16 @@
}
+dwarf_addr_t
+DIECompileUnitBase::AddressRangeBase() const
+{
+ if (fAddressRanges != NULL)
+ return fAddressRanges->LowestAddress();
+
+ return fLowPC;
+}
+
+
status_t
DIECompileUnitBase::AddChild(DebugInfoEntry* child)
{
@@ -175,6 +193,22 @@
}
+status_t
+DIECompileUnitBase::AddAttribute_ranges(uint16 attributeName,
+ const AttributeValue& value)
+{
+ if (fAddressRanges != NULL)
+ fAddressRanges->RemoveReference();
+
+ fAddressRanges = value.rangeList;
+
+ if (fAddressRanges != NULL)
+ fAddressRanges->AddReference();
+
+ return B_OK;
+}
+
+
// #pragma mark - DIEType
@@ -285,6 +319,13 @@
}
+DebugInfoEntry*
+DIEDeclaredType::AbstractOrigin() const
+{
+ return fAbstractOrigin;
+}
+
+
status_t
DIEDeclaredType::AddAttribute_accessibility(uint16 attributeName,
const AttributeValue& value)
@@ -359,6 +400,20 @@
}
+bool
+DIECompoundType::IsNamespace() const
+{
+ return true;
+}
+
+
+DebugInfoEntry*
+DIECompoundType::Specification() const
+{
+ return fSpecification;
+}
+
+
status_t
DIECompoundType::AddChild(DebugInfoEntry* child)
{
@@ -569,6 +624,13 @@
}
+DebugInfoEntry*
+DIEArrayType::Specification() const
+{
+ return fSpecification;
+}
+
+
status_t
DIEArrayType::AddChild(DebugInfoEntry* child)
{
@@ -672,6 +734,13 @@
}
+DebugInfoEntry*
+DIEEnumerationType::Specification() const
+{
+ return fSpecification;
+}
+
+
status_t
DIEEnumerationType::AddChild(DebugInfoEntry* child)
{
@@ -809,6 +878,13 @@
}
+DebugInfoEntry*
+DIEPointerType::Specification() const
+{
+ return fSpecification;
+}
+
+
status_t
DIEPointerType::AddAttribute_specification(uint16 attributeName,
const AttributeValue& value)
@@ -1461,10 +1537,27 @@
DIESubprogram::DIESubprogram()
+ :
+ fLowPC(0),
+ fHighPC(0),
+ fAddressRanges(NULL),
+ fSpecification(NULL),
+ fAbstractOrigin(NULL),
+ fReturnType(NULL),
+ fAddressClass(0),
+ fPrototyped(false),
+ fInline(DW_INL_not_inlined)
{
}
+DIESubprogram::~DIESubprogram()
+{
+ if (fAddressRanges != NULL)
+ fAddressRanges->RemoveReference();
+}
+
+
uint16
DIESubprogram::Tag() const
{
@@ -1472,6 +1565,111 @@
}
+DebugInfoEntry*
+DIESubprogram::Specification() const
+{
+ return fSpecification;
+}
+
+
+
+DebugInfoEntry*
+DIESubprogram::AbstractOrigin() const
+{
+ return fAbstractOrigin;
+}
+
+
+status_t
+DIESubprogram::AddAttribute_low_pc(uint16 attributeName,
+ const AttributeValue& value)
+{
+ fLowPC = value.address;
+ return B_OK;
+}
+
+
+status_t
+DIESubprogram::AddAttribute_high_pc(uint16 attributeName,
+ const AttributeValue& value)
+{
+ fHighPC = value.address;
+ return B_OK;
+}
+
+
+status_t
+DIESubprogram::AddAttribute_ranges(uint16 attributeName,
+ const AttributeValue& value)
+{
+ if (fAddressRanges != NULL)
+ fAddressRanges->RemoveReference();
+
+ fAddressRanges = value.rangeList;
+
+ if (fAddressRanges != NULL)
+ fAddressRanges->AddReference();
+
+ return B_OK;
+}
+
+
+status_t
+DIESubprogram::AddAttribute_specification(uint16 attributeName,
+ const AttributeValue& value)
+{
+ fSpecification = dynamic_cast<DIESubprogram*>(value.reference);
+ return fSpecification != NULL ? B_OK : B_BAD_DATA;
+}
+
+
+status_t
+DIESubprogram::AddAttribute_address_class(uint16 attributeName,
+ const AttributeValue& value)
+{
+// TODO: How is the address class handled?
+ fAddressClass = value.constant;
+ return B_OK;
+}
+
+
+status_t
+DIESubprogram::AddAttribute_prototyped(uint16 attributeName,
+ const AttributeValue& value)
+{
+ fPrototyped = value.flag;
+ return B_OK;
+}
+
+
+status_t
+DIESubprogram::AddAttribute_type(uint16 attributeName,
+ const AttributeValue& value)
+{
+ fReturnType = dynamic_cast<DIEType*>(value.reference);
+ return fReturnType != NULL ? B_OK : B_BAD_DATA;
+}
+
+
+status_t
+DIESubprogram::AddAttribute_inline(uint16 attributeName,
+ const AttributeValue& value)
+{
+// TODO: How is the address class handled?
+ fInline = value.constant;
+ return B_OK;
+}
+
+
+status_t
+DIESubprogram::AddAttribute_abstract_origin(uint16 attributeName,
+ const AttributeValue& value)
+{
+ fAbstractOrigin = dynamic_cast<DIESubprogram*>(value.reference);
+ return fAbstractOrigin != NULL ? B_OK : B_BAD_DATA;
+}
+
+
// #pragma mark - DIETemplateTypeParameter
@@ -1664,6 +1862,21 @@
}
+bool
+DIENamespace::IsNamespace() const
+{
+ return true;
+}
+
+
+status_t
[... truncated: 1266 lines follow ...]
More information about the Haiku-commits
mailing list