From adf25fc437a0898a87e060876e25a32dae1debeb Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Fri, 5 Apr 2013 09:04:49 -0400 Subject: [PATCH] Dump area information in reports. Implements part of #9510. --- .../controllers/DebugReportGenerator.cpp | 47 +++++++++++++++++-- .../controllers/DebugReportGenerator.h | 11 +++-- .../debugger/controllers/TeamDebugger.cpp | 3 +- 3 files changed, 53 insertions(+), 8 deletions(-) diff --git a/src/apps/debugger/controllers/DebugReportGenerator.cpp b/src/apps/debugger/controllers/DebugReportGenerator.cpp index e5aa62da9b..49c37995b6 100644 --- a/src/apps/debugger/controllers/DebugReportGenerator.cpp +++ b/src/apps/debugger/controllers/DebugReportGenerator.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2012, Rene Gollent, rene@gollent.com. + * Copyright 2012-2013, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ @@ -17,7 +17,9 @@ #include #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 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) { diff --git a/src/apps/debugger/controllers/DebugReportGenerator.h b/src/apps/debugger/controllers/DebugReportGenerator.h index 5ff78b484d..457bc9cf6f 100644 --- a/src/apps/debugger/controllers/DebugReportGenerator.h +++ b/src/apps/debugger/controllers/DebugReportGenerator.h @@ -1,5 +1,5 @@ /* - * Copyright 2012, Rene Gollent, rene@gollent.com. + * Copyright 2012-2013, Rene Gollent, rene@gollent.com. * 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; diff --git a/src/apps/debugger/controllers/TeamDebugger.cpp b/src/apps/debugger/controllers/TeamDebugger.cpp index 634eba0d0d..433e8ef61c 100644 --- a/src/apps/debugger/controllers/TeamDebugger.cpp +++ b/src/apps/debugger/controllers/TeamDebugger.cpp @@ -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;