2 * Copyright 2012-2013, Rene Gollent, rene@gollent.com.
3 * Distributed under the terms of the MIT License.
5 #ifndef DEBUG_REPORT_GENERATOR_H
6 #define DEBUG_REPORT_GENERATOR_H
13 #include "TeamMemoryBlock.h"
14 #include "ValueNodeContainer.h"
21 class DebuggerInterface
;
26 class UserInterfaceListener
;
30 class ValueNodeManager
;
33 class DebugReportGenerator
: public BLooper
, private Team::Listener
,
34 private TeamMemoryBlock::Listener
, private ValueNodeContainer::Listener
,
35 private Function::Listener
{
37 DebugReportGenerator(::Team
* team
,
38 UserInterfaceListener
* listener
,
39 DebuggerInterface
* interface
);
40 ~DebugReportGenerator();
44 static DebugReportGenerator
* Create(::Team
* team
,
45 UserInterfaceListener
* listener
,
46 DebuggerInterface
* interface
);
48 virtual void MessageReceived(BMessage
* message
);
52 virtual void ThreadStackTraceChanged(
53 const Team::ThreadEvent
& event
);
55 // TeamMemoryBlock::Listener
56 virtual void MemoryBlockRetrieved(TeamMemoryBlock
* block
);
57 virtual void MemoryBlockRetrievalFailed(
58 TeamMemoryBlock
* block
, status_t result
);
60 // ValueNodeContainer::Listener
61 virtual void ValueNodeValueChanged(ValueNode
* node
);
64 virtual void FunctionSourceCodeChanged(Function
* function
);
67 status_t
_GenerateReport(const entry_ref
& outputPath
);
68 status_t
_GenerateReportHeader(BFile
& _output
);
69 status_t
_DumpLoadedImages(BFile
& _output
);
70 status_t
_DumpAreas(BFile
& _output
);
71 status_t
_DumpSemaphores(BFile
& _output
);
72 status_t
_DumpRunningThreads(BFile
& _output
);
73 status_t
_DumpDebuggedThreadInfo(BFile
& _output
,
75 status_t
_DumpFunctionDisassembly(BFile
& _output
,
76 target_addr_t instructionPointer
);
77 status_t
_DumpStackFrameMemory(BFile
& _output
,
79 target_addr_t framePointer
,
80 uint8 stackDirection
);
82 status_t
_ResolveValueIfNeeded(ValueNode
* node
,
83 StackFrame
* frame
, int32 maxDepth
);
85 void _HandleMemoryBlockRetrieved(
86 TeamMemoryBlock
* block
, status_t result
);
88 static int _CompareAreas(const AreaInfo
* a
,
90 static int _CompareImages(const Image
* a
, const Image
* b
);
91 static int _CompareSemaphores(const SemaphoreInfo
* a
,
92 const SemaphoreInfo
* b
);
93 static int _CompareThreads(const ::Thread
* a
,
97 Architecture
* fArchitecture
;
98 DebuggerInterface
* fDebuggerInterface
;
100 ValueNodeManager
* fNodeManager
;
101 UserInterfaceListener
* fListener
;
102 ValueNode
* fWaitingNode
;
103 TeamMemoryBlock
* fCurrentBlock
;
104 status_t fBlockRetrievalStatus
;
105 ::Thread
* fTraceWaitingThread
;
106 Function
* fSourceWaitingFunction
;
109 #endif // DEBUG_REPORT_GENERATOR_H