Add option to save a debug information report.

- The Tools menu now contains an option to save a debug report for the currently
  debugged team. For now this report contains the following:
  	A list of all loaded images, their base address and their size.
  	A list of all threads active in their team, and their state.
  		* For each thread that is in a debug or exception state,
  		  a stack trace, and a register dump at the top frame will also be emitted.

  Feedback on report format + included details welcome.

  For now, when the option is requested, the report is saved to the desktop
  with an auto-generated name based on the target team and the current
  date/time.
This commit is contained in:
Rene Gollent 2012-11-22 00:21:18 -05:00
parent f20eea8ca9
commit 37ddff87ec
1 changed files with 32 additions and 0 deletions

View File

@ -10,7 +10,9 @@
#include <stdio.h>
#include <Button.h>
#include <DateTime.h>
#include <FilePanel.h>
#include <FindDirectory.h>
#include <LayoutBuilder.h>
#include <Menu.h>
#include <MenuBar.h>
@ -215,6 +217,32 @@ void
TeamWindow::MessageReceived(BMessage* message)
{
switch (message->what) {
case MSG_GENERATE_DEBUG_REPORT:
{
try {
BPath path;
BPath teamPath(fTeam->Name());
find_directory(B_DESKTOP_DIRECTORY, &path);
BDateTime currentTime;
currentTime.SetTime_t(time(NULL));
BString filename;
filename.SetToFormat("%s-%" B_PRId32 "-debug-%02"
B_PRId32 "-%02" B_PRId32 "-%02" B_PRId32 "-%02"
B_PRId32 "-%02" B_PRId32 "-%02" B_PRId32 ".report",
teamPath.Leaf(), fTeam->ID(), currentTime.Date().Day(),
currentTime.Date().Month(), currentTime.Date().Year(),
currentTime.Time().Hour(), currentTime.Time().Minute(),
currentTime.Time().Second());
path.Append(filename);
entry_ref ref;
status_t result = get_ref_for_path(path.Path(), &ref);
if (result == B_OK)
fListener->DebugReportRequested(&ref);
} catch (...) {
// TODO: notify user
}
break;
}
case MSG_SHOW_INSPECTOR_WINDOW:
{
if (fInspectorWindow) {
@ -799,6 +827,10 @@ TeamWindow::_Init()
item->SetTarget(this);
menu = new BMenu("Tools");
fMenuBar->AddItem(menu);
item = new BMenuItem("Save Debug Report",
new BMessage(MSG_GENERATE_DEBUG_REPORT));
menu->AddItem(item);
item->SetTarget(this);
item = new BMenuItem("Inspect Memory",
new BMessage(MSG_SHOW_INSPECTOR_WINDOW), 'I');
menu->AddItem(item);