Commit c3afba0f authored by hjk's avatar hjk

debugger: add a context menu action to the stackview to create a full

backtrace in the main editor.

Useful for sending bug reports.
parent 89196e5c
......@@ -444,6 +444,10 @@ DebuggerSettings *DebuggerSettings::instance()
item->setText(tr("Reload Full Stack"));
instance->insertItem(ExpandStack, item);
item = new SavedAction(instance);
item->setText(tr("Create Full Backtrace"));
instance->insertItem(CreateFullBacktrace, item);
item = new SavedAction(instance);
item->setText(tr("Execute Line"));
instance->insertItem(ExecuteCommand, item);
......
......@@ -112,6 +112,7 @@ enum DebuggerActionCode
// Stack
MaximalStackDepth,
ExpandStack,
CreateFullBacktrace,
// Watchers & Locals
WatchExpression,
......
......@@ -129,6 +129,7 @@ enum DebuggerCapabilities
ReloadModuleSymbolsCapability = 0x100,
BreakOnThrowAndCatchCapability = 0x200,
ReturnFromFunctionCapability = 0x400,
CreateFullBacktraceCapability = 0x800,
};
enum LogChannel
......
......@@ -1947,6 +1947,12 @@ void DebuggerManager::updateWatchersWindow()
d->m_watchHandler->model(WatchersWatch)->rowCount(QModelIndex()) > 0);
}
void DebuggerManager::openTextEditor(const QString &titlePattern,
const QString &contents)
{
d->m_plugin->openTextEditor(titlePattern, contents);
}
//////////////////////////////////////////////////////////////////////
//
// AbstractDebuggerEngine
......
......@@ -345,6 +345,8 @@ private:
Internal::BreakpointData *findBreakpoint(const QString &fileName, int lineNumber);
void setToolTipExpression(const QPoint &mousePos,
TextEditor::ITextEditor *editor, int cursorPos);
void openTextEditor(const QString &titlePattern,
const QString &contents);
DebuggerManagerPrivate *d;
};
......
......@@ -1233,6 +1233,18 @@ void DebuggerPlugin::gotoLocation(const QString &file, int line, bool setMarker)
}
}
void DebuggerPlugin::openTextEditor(const QString &titlePattern0,
const QString &contents)
{
QString titlePattern = titlePattern0;
EditorManager *editorManager = EditorManager::instance();
QTC_ASSERT(editorManager, return);
Core::IEditor *editor = editorManager->openEditorWithContents(
Core::Constants::K_DEFAULT_TEXT_EDITOR_ID, &titlePattern, contents);
QTC_ASSERT(editor, return);
editorManager->activateEditor(editor);
}
void DebuggerPlugin::handleStateChanged(int state)
{
// Prevent it from beeing triggered on setup.
......
......@@ -107,6 +107,8 @@ private slots:
void resetLocation();
void gotoLocation(const QString &file, int line, bool setMarker);
void openTextEditor(const QString &titlePattern, const QString &contents);
void breakpointSetRemoveMarginActionTriggered();
void breakpointEnableDisableMarginActionTriggered();
void onModeChanged(Core::IMode *mode);
......
......@@ -188,6 +188,8 @@ GdbEngine::GdbEngine(DebuggerManager *manager) : IDebuggerEngine(manager)
connect(theDebuggerAction(AutoDerefPointers), SIGNAL(valueChanged(QVariant)),
this, SLOT(setAutoDerefPointers(QVariant)));
connect(theDebuggerAction(CreateFullBacktrace), SIGNAL(triggered()),
this, SLOT(createFullBacktrace()));
}
void GdbEngine::connectDebuggingHelperActions()
......@@ -1795,7 +1797,8 @@ unsigned GdbEngine::debuggerCapabilities() const
| RegisterCapability | ShowMemoryCapability
| JumpToLineCapability | ReloadModuleCapability
| ReloadModuleSymbolsCapability | BreakOnThrowAndCatchCapability
| ReturnFromFunctionCapability;
| ReturnFromFunctionCapability
| CreateFullBacktraceCapability;
}
void GdbEngine::continueInferiorInternal()
......@@ -4350,6 +4353,20 @@ bool GdbEngine::hasPython() const
return m_hasPython;
}
void GdbEngine::createFullBacktrace()
{
postCommand("thread apply all bt", NeedsStop, CB(handleCreateFullBacktrace));
}
void GdbEngine::handleCreateFullBacktrace(const GdbResponse &response)
{
if (response.resultClass == GdbResultDone) {
m_manager->openTextEditor(_("Backtrace $"),
_(response.data.findChild("consolestreamoutput").data()));
}
}
//
// Factory
//
......
......@@ -479,6 +479,9 @@ private: ////////// View & Data Stuff //////////
void handleDebuggingHelperEditValue(const GdbResponse &response);
void handleDebuggingHelperSetup(const GdbResponse &response);
Q_SLOT void createFullBacktrace();
void handleCreateFullBacktrace(const GdbResponse &response);
void updateLocals(const QVariant &cookie = QVariant());
void updateLocalsClassic(const QVariant &cookie);
void updateLocalsPython(const QByteArray &varList);
......
......@@ -102,12 +102,14 @@ void StackWindow::contextMenuEvent(QContextMenuEvent *ev)
const unsigned engineCapabilities = m_manager->debuggerCapabilities();
menu.addAction(theDebuggerAction(ExpandStack));
QAction *actCopyContents = menu.addAction(tr("Copy contents to clipboard"));
QAction *actCopyContents = menu.addAction(tr("Copy Contents to Clipboard"));
actCopyContents->setEnabled(model() != 0);
menu.addAction(theDebuggerAction(CreateFullBacktrace));
QAction *actShowMemory = menu.addAction(QString());
if (address.isEmpty()) {
actShowMemory->setText(tr("Open memory editor"));
actShowMemory->setText(tr("Open Memory Editor"));
actShowMemory->setEnabled(false);
} else {
actShowMemory->setText(tr("Open Memory Editor at %1").arg(address));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment