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.
This commit is contained in:
Rene Gollent 2013-04-12 21:39:12 -04:00
parent 5a1b505fa1
commit 2298b5fc23
4 changed files with 32 additions and 11 deletions

View File

@ -154,6 +154,7 @@ Application Debugger :
StackTrace.cpp StackTrace.cpp
Statement.cpp Statement.cpp
SymbolInfo.cpp SymbolInfo.cpp
SystemInfo.cpp
Team.cpp Team.cpp
TeamMemory.cpp TeamMemory.cpp
TeamMemoryBlock.cpp TeamMemoryBlock.cpp

View File

@ -6,8 +6,6 @@
#include "DebugReportGenerator.h" #include "DebugReportGenerator.h"
#include <sys/utsname.h>
#include <cpu_type.h> #include <cpu_type.h>
#include <AutoLocker.h> #include <AutoLocker.h>
@ -27,6 +25,7 @@
#include "StackFrame.h" #include "StackFrame.h"
#include "StackTrace.h" #include "StackTrace.h"
#include "StringUtils.h" #include "StringUtils.h"
#include "SystemInfo.h"
#include "Team.h" #include "Team.h"
#include "Thread.h" #include "Thread.h"
#include "Type.h" #include "Type.h"
@ -212,11 +211,10 @@ DebugReportGenerator::_GenerateReportHeader(BString& _output)
fTeam->Name(), fTeam->ID()); fTeam->Name(), fTeam->ID());
_output << data; _output << data;
// TODO: this information should probably be requested via the debugger SystemInfo sysInfo;
// interface, since e.g. in the case of a remote team, the report should
// include data about the target, not the debugging host if (fDebuggerInterface->GetSystemInfo(sysInfo) == B_OK) {
system_info info; const system_info &info = sysInfo.GetSystemInfo();
if (get_system_info(&info) == B_OK) {
data.SetToFormat("CPU(s): %" B_PRId32 "x %s %s\n", data.SetToFormat("CPU(s): %" B_PRId32 "x %s %s\n",
info.cpu_count, get_cpu_vendor_string(info.cpu_type), info.cpu_count, get_cpu_vendor_string(info.cpu_type),
get_cpu_model_string(&info)); get_cpu_model_string(&info));
@ -230,11 +228,12 @@ DebugReportGenerator::_GenerateReportHeader(BString& _output)
BPrivate::string_for_size((int64)info.used_pages * B_PAGE_SIZE, BPrivate::string_for_size((int64)info.used_pages * B_PAGE_SIZE,
usedSize, sizeof(usedSize))); usedSize, sizeof(usedSize)));
_output << data; _output << data;
}
utsname name; const utsname& name = sysInfo.GetSystemName();
uname(&name); data.SetToFormat("Haiku revision: %s (%s)\n", name.version,
data.SetToFormat("Haiku revision: %s (%s)\n", name.version, name.machine); name.machine);
_output << data; _output << data;
}
return B_OK; return B_OK;
} }

View File

@ -29,6 +29,7 @@
#include "ImageInfo.h" #include "ImageInfo.h"
#include "SemaphoreInfo.h" #include "SemaphoreInfo.h"
#include "SymbolInfo.h" #include "SymbolInfo.h"
#include "SystemInfo.h"
#include "ThreadInfo.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 status_t
DebuggerInterface::GetThreadInfos(BObjectList<ThreadInfo>& infos) DebuggerInterface::GetThreadInfos(BObjectList<ThreadInfo>& infos)
{ {

View File

@ -21,6 +21,7 @@ class AreaInfo;
class ImageInfo; class ImageInfo;
class SemaphoreInfo; class SemaphoreInfo;
class SymbolInfo; class SymbolInfo;
class SystemInfo;
class ThreadInfo; class ThreadInfo;
namespace BPrivate { namespace BPrivate {
@ -54,6 +55,7 @@ public:
uint32 type, int32 length); uint32 type, int32 length);
virtual status_t UninstallWatchpoint(target_addr_t address); virtual status_t UninstallWatchpoint(target_addr_t address);
virtual status_t GetSystemInfo(SystemInfo& info);
virtual status_t GetThreadInfos(BObjectList<ThreadInfo>& infos); virtual status_t GetThreadInfos(BObjectList<ThreadInfo>& infos);
virtual status_t GetImageInfos(BObjectList<ImageInfo>& infos); virtual status_t GetImageInfos(BObjectList<ImageInfo>& infos);
virtual status_t GetAreaInfos(BObjectList<AreaInfo>& infos); virtual status_t GetAreaInfos(BObjectList<AreaInfo>& infos);