aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/debugger/stackwindow.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <[email protected]>2014-01-08 17:40:45 +0100
committerhjk <[email protected]>2014-01-08 18:04:02 +0100
commit8361ade08d04cf222fabf9a93d7e6f8f9ca87684 (patch)
tree2d7052a056d99c78762de1c2412d904b76ca923a /src/plugins/debugger/stackwindow.cpp
parent8ebb6aa9f6896ba9aaf4a8da065c1e7b0df70a50 (diff)
Debugger: Add context menu option to save stack as *.tasks file.
The task files can be attached to bug reports and then conveniently loaded into the build issues pane for later investigation. Change-Id: I463de957bf545ab89f630ab108f92cc253d81fa5 Reviewed-by: hjk <[email protected]>
Diffstat (limited to 'src/plugins/debugger/stackwindow.cpp')
-rw-r--r--src/plugins/debugger/stackwindow.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/plugins/debugger/stackwindow.cpp b/src/plugins/debugger/stackwindow.cpp
index 1ca9c467737..b86178b1250 100644
--- a/src/plugins/debugger/stackwindow.cpp
+++ b/src/plugins/debugger/stackwindow.cpp
@@ -40,11 +40,16 @@
#include <utils/savedaction.h>
#include <QDebug>
+#include <QTextStream>
+#include <QFile>
+#include <QDir>
#include <QApplication>
#include <QClipboard>
#include <QContextMenuEvent>
#include <QInputDialog>
+#include <QFileDialog>
+#include <QMessageBox>
#include <QMenu>
namespace Debugger {
@@ -115,6 +120,31 @@ static inline StackFrame inputFunctionForDisassembly()
return frame;
}
+// Write stack frames as task file for displaying it in the build issues pane.
+void saveTaskFile(QWidget *parent, const StackHandler *sh)
+{
+ QFile file;
+ QFileDialog fileDialog(parent);
+ fileDialog.setAcceptMode(QFileDialog::AcceptSave);
+ fileDialog.selectFile(QDir::currentPath() + QLatin1String("/stack.tasks"));
+ while (!file.isOpen()) {
+ if (fileDialog.exec() != QDialog::Accepted)
+ return;
+ const QString fileName = fileDialog.selectedFiles().front();
+ file.setFileName(fileName);
+ if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
+ QMessageBox::warning(parent, StackTreeView::tr("Cannot Open Task File"),
+ StackTreeView::tr("Cannot open \"%1\": %2").arg(QDir::toNativeSeparators(fileName), file.errorString()));
+ }
+ }
+
+ QTextStream str(&file);
+ foreach (const StackFrame &frame, sh->frames()) {
+ if (frame.isUsable())
+ str << frame.file << '\t' << frame.line << "\tstack\tFrame #" << frame.level << '\n';
+ }
+}
+
void StackTreeView::contextMenuEvent(QContextMenuEvent *ev)
{
DebuggerEngine *engine = currentEngine();
@@ -132,6 +162,9 @@ void StackTreeView::contextMenuEvent(QContextMenuEvent *ev)
QAction *actCopyContents = menu.addAction(tr("Copy Contents to Clipboard"));
actCopyContents->setEnabled(model() != 0);
+ QAction *actSaveTaskFile = menu.addAction(tr("Save as Task File..."));
+ actSaveTaskFile->setEnabled(model() != 0);
+
if (engine->hasCapability(CreateFullBacktraceCapability))
menu.addAction(debuggerCore()->action(CreateFullBacktrace));
@@ -207,6 +240,8 @@ void StackTreeView::contextMenuEvent(QContextMenuEvent *ev)
engine->openDisassemblerView(frame);
else if (act == actLoadSymbols)
engine->loadSymbolsForStack();
+ else if (act == actSaveTaskFile)
+ saveTaskFile(this, handler);
else
handleBaseContextAction(act);
}