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.
*/
@@ -17,7 +17,9 @@
#include <StringForSize.h>
#include "Architecture.h"
#include "AreaInfo.h"
#include "CpuState.h"
#include "DebuggerInterface.h"
#include "Image.h"
#include "MessageCodes.h"
#include "Register.h"
@@ -37,11 +39,12 @@
DebugReportGenerator::DebugReportGenerator(::Team* team,
UserInterfaceListener* listener)
UserInterfaceListener* listener, DebuggerInterface* interface)
:
BLooper("DebugReportGenerator"),
fTeam(team),
fArchitecture(team->GetArchitecture()),
fDebuggerInterface(interface),
fTeamDataSem(-1),
fNodeManager(NULL),
fListener(listener),
@@ -88,9 +91,11 @@ DebugReportGenerator::Init()
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 {
self->Init();
@@ -120,6 +125,10 @@ DebugReportGenerator::_GenerateReport(const entry_ref& outputPath)
if (result != B_OK)
return result;
result = _DumpAreas(output);
if (result != B_OK)
return result;
result = _DumpRunningThreads(output);
if (result != B_OK)
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
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.
*/
#ifndef DEBUG_REPORT_GENERATOR_H
@@ -16,6 +16,7 @@
class entry_ref;
class Architecture;
class BString;
class DebuggerInterface;
class StackFrame;
class Team;
class Thread;
@@ -30,13 +31,15 @@ class DebugReportGenerator : public BLooper, private Team::Listener,
private TeamMemoryBlock::Listener, private ValueNodeContainer::Listener {
public:
DebugReportGenerator(::Team* team,
UserInterfaceListener* listener);
UserInterfaceListener* listener,
DebuggerInterface* interface);
~DebugReportGenerator();
status_t Init();
static DebugReportGenerator* Create(::Team* team,
UserInterfaceListener* listener);
UserInterfaceListener* listener,
DebuggerInterface* interface);
virtual void MessageReceived(BMessage* message);
@@ -56,6 +59,7 @@ private:
status_t _GenerateReport(const entry_ref& outputPath);
status_t _GenerateReportHeader(BString& _output);
status_t _DumpLoadedImages(BString& _output);
status_t _DumpAreas(BString& _output);
status_t _DumpRunningThreads(BString& _output);
status_t _DumpDebuggedThreadInfo(BString& _output,
::Thread* thread);
@@ -70,6 +74,7 @@ private:
private:
::Team* fTeam;
Architecture* fArchitecture;
DebuggerInterface* fDebuggerInterface;
sem_id fTeamDataSem;
ValueNodeManager* fNodeManager;
UserInterfaceListener* fListener;
@@ -416,7 +416,8 @@ TeamDebugger::Init(team_id teamID, thread_id threadID, bool stopInMain)
return error;
// create the debug report generator
fReportGenerator = new(std::nothrow) DebugReportGenerator(fTeam, this);
fReportGenerator = new(std::nothrow) DebugReportGenerator(fTeam, this,
fDebuggerInterface);
if (fReportGenerator == NULL)
return B_NO_MEMORY;