From 2298b5fc2315f40da1674a9774cc157250f9121f Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Fri, 12 Apr 2013 21:39:12 -0400 Subject: [PATCH] Resolve TODO. - Added GetSystemInfo() to DebuggerInterface. Use that from DebugReportGenerator instead of calling get_system_info()/utsname() directly since otherwise we'd get the information for the wrong system in the eventual case when we have remote debugging support. --- src/apps/debugger/Jamfile | 1 + .../controllers/DebugReportGenerator.cpp | 21 +++++++++---------- .../debugger_interface/DebuggerInterface.cpp | 19 +++++++++++++++++ .../debugger_interface/DebuggerInterface.h | 2 ++ 4 files changed, 32 insertions(+), 11 deletions(-) diff --git a/src/apps/debugger/Jamfile b/src/apps/debugger/Jamfile index b0049c4f36..139f5a9adb 100644 --- a/src/apps/debugger/Jamfile +++ b/src/apps/debugger/Jamfile @@ -154,6 +154,7 @@ Application Debugger : StackTrace.cpp Statement.cpp SymbolInfo.cpp + SystemInfo.cpp Team.cpp TeamMemory.cpp TeamMemoryBlock.cpp diff --git a/src/apps/debugger/controllers/DebugReportGenerator.cpp b/src/apps/debugger/controllers/DebugReportGenerator.cpp index bab6e60a93..03fad008e9 100644 --- a/src/apps/debugger/controllers/DebugReportGenerator.cpp +++ b/src/apps/debugger/controllers/DebugReportGenerator.cpp @@ -6,8 +6,6 @@ #include "DebugReportGenerator.h" -#include - #include #include @@ -27,6 +25,7 @@ #include "StackFrame.h" #include "StackTrace.h" #include "StringUtils.h" +#include "SystemInfo.h" #include "Team.h" #include "Thread.h" #include "Type.h" @@ -212,11 +211,10 @@ DebugReportGenerator::_GenerateReportHeader(BString& _output) fTeam->Name(), fTeam->ID()); _output << data; - // TODO: this information should probably be requested via the debugger - // interface, since e.g. in the case of a remote team, the report should - // include data about the target, not the debugging host - system_info info; - if (get_system_info(&info) == B_OK) { + SystemInfo sysInfo; + + if (fDebuggerInterface->GetSystemInfo(sysInfo) == B_OK) { + const system_info &info = sysInfo.GetSystemInfo(); data.SetToFormat("CPU(s): %" B_PRId32 "x %s %s\n", info.cpu_count, get_cpu_vendor_string(info.cpu_type), get_cpu_model_string(&info)); @@ -230,11 +228,12 @@ DebugReportGenerator::_GenerateReportHeader(BString& _output) BPrivate::string_for_size((int64)info.used_pages * B_PAGE_SIZE, usedSize, sizeof(usedSize))); _output << data; + + const utsname& name = sysInfo.GetSystemName(); + data.SetToFormat("Haiku revision: %s (%s)\n", name.version, + name.machine); + _output << data; } - utsname name; - uname(&name); - data.SetToFormat("Haiku revision: %s (%s)\n", name.version, name.machine); - _output << data; return B_OK; } diff --git a/src/apps/debugger/debugger_interface/DebuggerInterface.cpp b/src/apps/debugger/debugger_interface/DebuggerInterface.cpp index a2bb1c0476..d4305348df 100644 --- a/src/apps/debugger/debugger_interface/DebuggerInterface.cpp +++ b/src/apps/debugger/debugger_interface/DebuggerInterface.cpp @@ -29,6 +29,7 @@ #include "ImageInfo.h" #include "SemaphoreInfo.h" #include "SymbolInfo.h" +#include "SystemInfo.h" #include "ThreadInfo.h" @@ -464,6 +465,24 @@ DebuggerInterface::UninstallWatchpoint(target_addr_t address) } +status_t +DebuggerInterface::GetSystemInfo(SystemInfo& info) +{ + system_info sysInfo; + status_t result = get_system_info(&sysInfo); + if (result != B_OK) + return result; + + utsname name; + result = uname(&name); + if (result != B_OK) + return result; + + info.SetTo(fTeamID, sysInfo, name); + return B_OK; +} + + status_t DebuggerInterface::GetThreadInfos(BObjectList& infos) { diff --git a/src/apps/debugger/debugger_interface/DebuggerInterface.h b/src/apps/debugger/debugger_interface/DebuggerInterface.h index 2befa2ed74..f726074da5 100644 --- a/src/apps/debugger/debugger_interface/DebuggerInterface.h +++ b/src/apps/debugger/debugger_interface/DebuggerInterface.h @@ -21,6 +21,7 @@ class AreaInfo; class ImageInfo; class SemaphoreInfo; class SymbolInfo; +class SystemInfo; class ThreadInfo; namespace BPrivate { @@ -54,6 +55,7 @@ public: uint32 type, int32 length); virtual status_t UninstallWatchpoint(target_addr_t address); + virtual status_t GetSystemInfo(SystemInfo& info); virtual status_t GetThreadInfos(BObjectList& infos); virtual status_t GetImageInfos(BObjectList& infos); virtual status_t GetAreaInfos(BObjectList& infos);