From 37ddff87ec1e472d4ec6ca9863d41a01f5347037 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Thu, 22 Nov 2012 00:21:18 -0500 Subject: [PATCH] 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. --- .../gui/team_window/TeamWindow.cpp | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp b/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp index 9042ff3e166..3560d07fd94 100644 --- a/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp +++ b/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp @@ -10,7 +10,9 @@ #include #include +#include #include +#include #include #include #include @@ -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);