Skip to content

Commit

Permalink
Add option to save a debug information report.
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
anevilyak committed Nov 22, 2012
1 parent f20eea8 commit 37ddff8
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp
Expand Up @@ -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>
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 37ddff8

Please sign in to comment.