Dump area information in reports.

Implements part of #9510.
This commit is contained in:
Rene Gollent
2013-04-05 09:12:51 -04:00
parent 6d1e057cac
commit adf25fc437
3 changed files with 53 additions and 8 deletions
@@ -1,5 +1,5 @@
/* /*
* Copyright 2012, Rene Gollent, [email protected]. * Copyright 2012-2013, Rene Gollent, [email protected].
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
@@ -17,7 +17,9 @@
#include <StringForSize.h> #include <StringForSize.h>
#include "Architecture.h" #include "Architecture.h"
#include "AreaInfo.h"
#include "CpuState.h" #include "CpuState.h"
#include "DebuggerInterface.h"
#include "Image.h" #include "Image.h"
#include "MessageCodes.h" #include "MessageCodes.h"
#include "Register.h" #include "Register.h"
@@ -37,11 +39,12 @@
DebugReportGenerator::DebugReportGenerator(::Team* team, DebugReportGenerator::DebugReportGenerator(::Team* team,
UserInterfaceListener* listener) UserInterfaceListener* listener, DebuggerInterface* interface)
: :
BLooper("DebugReportGenerator"), BLooper("DebugReportGenerator"),
fTeam(team), fTeam(team),
fArchitecture(team->GetArchitecture()), fArchitecture(team->GetArchitecture()),
fDebuggerInterface(interface),
fTeamDataSem(-1), fTeamDataSem(-1),
fNodeManager(NULL), fNodeManager(NULL),
fListener(listener), fListener(listener),
@@ -88,9 +91,11 @@ DebugReportGenerator::Init()
DebugReportGenerator* DebugReportGenerator*
DebugReportGenerator::Create(::Team* team, UserInterfaceListener* listener) DebugReportGenerator::Create(::Team* team, UserInterfaceListener* listener,
DebuggerInterface* interface)
{ {
DebugReportGenerator* self = new DebugReportGenerator(team, listener); DebugReportGenerator* self = new DebugReportGenerator(team, listener,
interface);
try { try {
self->Init(); self->Init();
@@ -120,6 +125,10 @@ DebugReportGenerator::_GenerateReport(const entry_ref& outputPath)
if (result != B_OK) if (result != B_OK)
return result; return result;
result = _DumpAreas(output);
if (result != B_OK)
return result;
result = _DumpRunningThreads(output); result = _DumpRunningThreads(output);
if (result != B_OK) if (result != B_OK)
return result; return result;
@@ -259,6 +268,36 @@ DebugReportGenerator::_DumpLoadedImages(BString& _output)
} }
status_t
DebugReportGenerator::_DumpAreas(BString& _output)
{
BObjectList<AreaInfo> areas(20, true);
status_t result = fDebuggerInterface->GetAreaInfos(areas);
if (result != B_OK)
return result;
_output << "\nAreas:\n";
BString data;
AreaInfo* info;
for (int32 i = 0; (info = areas.ItemAt(i)) != NULL; i++) {
try {
data.SetToFormat("\t%s (%" B_PRId32 ") "
"Base: %#08" B_PRIx64 ", Size: %" B_PRId64
", RAM Size: %" B_PRId64 ", Locking: %#04" B_PRIx32
", Protection: %#04" B_PRIx32 "\n", info->Name().String(),
info->AreaID(), info->BaseAddress(), info->Size(),
info->RamSize(), info->Lock(), info->Protection());
_output << data;
} catch (...) {
return B_NO_MEMORY;
}
}
return B_OK;
}
status_t status_t
DebugReportGenerator::_DumpRunningThreads(BString& _output) DebugReportGenerator::_DumpRunningThreads(BString& _output)
{ {
@@ -1,5 +1,5 @@
/* /*
* Copyright 2012, Rene Gollent, [email protected]. * Copyright 2012-2013, Rene Gollent, [email protected].
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#ifndef DEBUG_REPORT_GENERATOR_H #ifndef DEBUG_REPORT_GENERATOR_H
@@ -16,6 +16,7 @@
class entry_ref; class entry_ref;
class Architecture; class Architecture;
class BString; class BString;
class DebuggerInterface;
class StackFrame; class StackFrame;
class Team; class Team;
class Thread; class Thread;
@@ -30,13 +31,15 @@ class DebugReportGenerator : public BLooper, private Team::Listener,
private TeamMemoryBlock::Listener, private ValueNodeContainer::Listener { private TeamMemoryBlock::Listener, private ValueNodeContainer::Listener {
public: public:
DebugReportGenerator(::Team* team, DebugReportGenerator(::Team* team,
UserInterfaceListener* listener); UserInterfaceListener* listener,
DebuggerInterface* interface);
~DebugReportGenerator(); ~DebugReportGenerator();
status_t Init(); status_t Init();
static DebugReportGenerator* Create(::Team* team, static DebugReportGenerator* Create(::Team* team,
UserInterfaceListener* listener); UserInterfaceListener* listener,
DebuggerInterface* interface);
virtual void MessageReceived(BMessage* message); virtual void MessageReceived(BMessage* message);
@@ -56,6 +59,7 @@ private:
status_t _GenerateReport(const entry_ref& outputPath); status_t _GenerateReport(const entry_ref& outputPath);
status_t _GenerateReportHeader(BString& _output); status_t _GenerateReportHeader(BString& _output);
status_t _DumpLoadedImages(BString& _output); status_t _DumpLoadedImages(BString& _output);
status_t _DumpAreas(BString& _output);
status_t _DumpRunningThreads(BString& _output); status_t _DumpRunningThreads(BString& _output);
status_t _DumpDebuggedThreadInfo(BString& _output, status_t _DumpDebuggedThreadInfo(BString& _output,
::Thread* thread); ::Thread* thread);
@@ -70,6 +74,7 @@ private:
private: private:
::Team* fTeam; ::Team* fTeam;
Architecture* fArchitecture; Architecture* fArchitecture;
DebuggerInterface* fDebuggerInterface;
sem_id fTeamDataSem; sem_id fTeamDataSem;
ValueNodeManager* fNodeManager; ValueNodeManager* fNodeManager;
UserInterfaceListener* fListener; UserInterfaceListener* fListener;
@@ -416,7 +416,8 @@ TeamDebugger::Init(team_id teamID, thread_id threadID, bool stopInMain)
return error; return error;
// create the debug report generator // create the debug report generator
fReportGenerator = new(std::nothrow) DebugReportGenerator(fTeam, this); fReportGenerator = new(std::nothrow) DebugReportGenerator(fTeam, this,
fDebuggerInterface);
if (fReportGenerator == NULL) if (fReportGenerator == NULL)
return B_NO_MEMORY; return B_NO_MEMORY;