Debugger: Add a "Write core file" menu item alongside "Save debug report".

This commit is contained in:
Augustin Cavalier
2019-05-02 16:35:25 -04:00
parent c2cbf95810
commit 5ef0649658
2 changed files with 51 additions and 4 deletions
@@ -74,6 +74,8 @@ enum {
enum { enum {
MSG_CHOOSE_DEBUG_REPORT_LOCATION = 'ccrl', MSG_CHOOSE_DEBUG_REPORT_LOCATION = 'ccrl',
MSG_DEBUG_REPORT_SAVED = 'drsa', MSG_DEBUG_REPORT_SAVED = 'drsa',
MSG_CHOOSE_CORE_FILE_LOCATION = 'ccfl',
MSG_CORE_FILE_WRITTEN = 'cfsa',
MSG_LOCATE_SOURCE_IF_NEEDED = 'lsin', MSG_LOCATE_SOURCE_IF_NEEDED = 'lsin',
MSG_SOURCE_ENTRY_QUERY_COMPLETE = 'seqc', MSG_SOURCE_ENTRY_QUERY_COMPLETE = 'seqc',
MSG_CLEAR_STACK_TRACE = 'clst', MSG_CLEAR_STACK_TRACE = 'clst',
@@ -375,13 +377,19 @@ TeamWindow::MessageReceived(BMessage* message)
break; break;
} }
case MSG_CHOOSE_DEBUG_REPORT_LOCATION: case MSG_CHOOSE_DEBUG_REPORT_LOCATION:
case MSG_CHOOSE_CORE_FILE_LOCATION:
{ {
try { try {
char filename[B_FILE_NAME_LENGTH]; char filename[B_FILE_NAME_LENGTH];
UiUtils::ReportNameForTeam(fTeam, filename, sizeof(filename)); if (message->what == MSG_CHOOSE_DEBUG_REPORT_LOCATION)
UiUtils::ReportNameForTeam(fTeam, filename, sizeof(filename));
else
UiUtils::CoreFileNameForTeam(fTeam, filename, sizeof(filename));
BMessenger msgr(this); BMessenger msgr(this);
fFilePanel = new BFilePanel(B_SAVE_PANEL, &msgr, fFilePanel = new BFilePanel(B_SAVE_PANEL, &msgr,
NULL, 0, false, new BMessage(MSG_GENERATE_DEBUG_REPORT)); NULL, 0, false, new BMessage(
message->what == MSG_CHOOSE_DEBUG_REPORT_LOCATION ?
MSG_GENERATE_DEBUG_REPORT : MSG_WRITE_CORE_FILE));
fFilePanel->SetSaveText(filename); fFilePanel->SetSaveText(filename);
fFilePanel->Show(); fFilePanel->Show();
} catch (...) { } catch (...) {
@@ -391,6 +399,7 @@ TeamWindow::MessageReceived(BMessage* message)
break; break;
} }
case MSG_GENERATE_DEBUG_REPORT: case MSG_GENERATE_DEBUG_REPORT:
case MSG_WRITE_CORE_FILE:
{ {
delete fFilePanel; delete fFilePanel;
fFilePanel = NULL; fFilePanel = NULL;
@@ -401,8 +410,12 @@ TeamWindow::MessageReceived(BMessage* message)
&& message->HasString("name")) { && message->HasString("name")) {
path.SetTo(&ref); path.SetTo(&ref);
path.Append(message->FindString("name")); path.Append(message->FindString("name"));
if (get_ref_for_path(path.Path(), &ref) == B_OK) if (get_ref_for_path(path.Path(), &ref) == B_OK) {
fListener->DebugReportRequested(&ref); if (message->what == MSG_GENERATE_DEBUG_REPORT)
fListener->DebugReportRequested(&ref);
else
fListener->WriteCoreFileRequested(&ref);
}
} }
break; break;
} }
@@ -427,6 +440,27 @@ TeamWindow::MessageReceived(BMessage* message)
alert->Go(); alert->Go();
break; break;
} }
case MSG_CORE_FILE_WRITTEN:
{
status_t finalStatus = message->GetInt32("status", B_OK);
BString data;
if (finalStatus == B_OK) {
data.SetToFormat("Core file successfully written to '%s'",
message->FindString("path"));
} else {
data.SetToFormat("Failed to write core file: '%s'",
strerror(finalStatus));
}
BAlert *alert = new(std::nothrow) BAlert("Core file written",
data.String(), "Close");
if (alert == NULL)
break;
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
alert->Go();
break;
}
case MSG_SHOW_INSPECTOR_WINDOW: case MSG_SHOW_INSPECTOR_WINDOW:
{ {
if (fInspectorWindow) { if (fInspectorWindow) {
@@ -1079,6 +1113,15 @@ TeamWindow::DebugReportChanged(const Team::DebugReportEvent& event)
} }
void
TeamWindow::CoreFileChanged(const Team::CoreFileChangedEvent& event)
{
BMessage message(MSG_CORE_FILE_WRITTEN);
message.AddString("path", event.GetTargetPath());
PostMessage(&message);
}
void void
TeamWindow::FunctionSourceCodeChanged(Function* function) TeamWindow::FunctionSourceCodeChanged(Function* function)
{ {
@@ -1233,6 +1276,8 @@ TeamWindow::_Init()
fMenuBar->AddItem(menu); fMenuBar->AddItem(menu);
item = new BMenuItem("Save debug report", item = new BMenuItem("Save debug report",
new BMessage(MSG_CHOOSE_DEBUG_REPORT_LOCATION)); new BMessage(MSG_CHOOSE_DEBUG_REPORT_LOCATION));
item = new BMenuItem("Write core file",
new BMessage(MSG_CHOOSE_CORE_FILE_LOCATION));
menu->AddItem(item); menu->AddItem(item);
item->SetTarget(this); item->SetTarget(this);
item = new BMenuItem("Inspect memory", item = new BMenuItem("Inspect memory",
@@ -164,6 +164,8 @@ private:
const Team::WatchpointEvent& event); const Team::WatchpointEvent& event);
virtual void DebugReportChanged( virtual void DebugReportChanged(
const Team::DebugReportEvent& event); const Team::DebugReportEvent& event);
virtual void CoreFileChanged(
const Team::CoreFileChangedEvent& event);
// Function::Listener // Function::Listener