From: hjk Date: Wed, 2 Feb 2011 10:52:39 +0000 (+0100) Subject: debugger: rework 'Run to Outermost Function' feature X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=face88a3d2216cfef80f98d2346b7ebbbaec04db;p=qt-creator-jp%2Fqt-creator-jp.git debugger: rework 'Run to Outermost Function' feature Remove from the debug menu, and assign Ctrl-F6 to it by default also on non-Mac. --- diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index eb52788d52..1302e743dd 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -370,61 +370,61 @@ namespace Constants { const char * const M_DEBUG_START_DEBUGGING = "QtCreator.Menu.Debug.StartDebugging"; -const char * const STARTEXTERNAL = "Debugger.StartExternal"; -const char * const ATTACHEXTERNAL = "Debugger.AttachExternal"; -const char * const ATTACHCORE = "Debugger.AttachCore"; -const char * const ATTACHTCF = "Debugger.AttachTcf"; -const char * const ATTACHREMOTE = "Debugger.AttachRemote"; -const char * const ATTACHREMOTECDB = "Debugger.AttachRemoteCDB"; -const char * const STARTREMOTELLDB = "Debugger.StartRemoteLLDB"; -const char * const DETACH = "Debugger.Detach"; - -const char * const RUN_TO_LINE1 = "Debugger.RunToLine1"; -const char * const RUN_TO_LINE2 = "Debugger.RunToLine2"; -const char * const RUN_TO_FUNCTION = "Debugger.RunToFunction"; -const char * const JUMP_TO_LINE1 = "Debugger.JumpToLine1"; -const char * const JUMP_TO_LINE2 = "Debugger.JumpToLine2"; -const char * const RETURN_FROM_FUNCTION = "Debugger.ReturnFromFunction"; -const char * const SNAPSHOT = "Debugger.Snapshot"; -const char * const TOGGLE_BREAK = "Debugger.ToggleBreak"; -const char * const BREAK_BY_FUNCTION = "Debugger.BreakByFunction"; -const char * const BREAK_AT_MAIN = "Debugger.BreakAtMain"; -const char * const ADD_TO_WATCH1 = "Debugger.AddToWatch1"; -const char * const ADD_TO_WATCH2 = "Debugger.AddToWatch2"; -const char * const OPERATE_BY_INSTRUCTION = "Debugger.OperateByInstruction"; -const char * const FRAME_UP = "Debugger.FrameUp"; -const char * const FRAME_DOWN = "Debugger.FrameDown"; +const char * const STARTEXTERNAL = "Debugger.StartExternal"; +const char * const ATTACHEXTERNAL = "Debugger.AttachExternal"; +const char * const ATTACHCORE = "Debugger.AttachCore"; +const char * const ATTACHTCF = "Debugger.AttachTcf"; +const char * const ATTACHREMOTE = "Debugger.AttachRemote"; +const char * const ATTACHREMOTECDB = "Debugger.AttachRemoteCDB"; +const char * const STARTREMOTELLDB = "Debugger.StartRemoteLLDB"; +const char * const DETACH = "Debugger.Detach"; + +const char * const RUN_TO_LINE1 = "Debugger.RunToLine1"; +const char * const RUN_TO_LINE2 = "Debugger.RunToLine2"; +const char * const RUN_TO_SELECTED_FUNCTION = "Debugger.RunToSelectedFunction"; +const char * const JUMP_TO_LINE1 = "Debugger.JumpToLine1"; +const char * const JUMP_TO_LINE2 = "Debugger.JumpToLine2"; +const char * const RETURN_FROM_FUNCTION = "Debugger.ReturnFromFunction"; +const char * const SNAPSHOT = "Debugger.Snapshot"; +const char * const TOGGLE_BREAK = "Debugger.ToggleBreak"; +const char * const BREAK_BY_FUNCTION = "Debugger.BreakByFunction"; +const char * const BREAK_AT_MAIN = "Debugger.BreakAtMain"; +const char * const ADD_TO_WATCH1 = "Debugger.AddToWatch1"; +const char * const ADD_TO_WATCH2 = "Debugger.AddToWatch2"; +const char * const OPERATE_BY_INSTRUCTION = "Debugger.OperateByInstruction"; +const char * const FRAME_UP = "Debugger.FrameUp"; +const char * const FRAME_DOWN = "Debugger.FrameDown"; #ifdef Q_WS_MAC -const char * const STOP_KEY = "Shift+Ctrl+Y"; -const char * const RESET_KEY = "Ctrl+Shift+F5"; -const char * const STEP_KEY = "Ctrl+Shift+I"; -const char * const STEPOUT_KEY = "Ctrl+Shift+T"; -const char * const NEXT_KEY = "Ctrl+Shift+O"; -const char * const REVERSE_KEY = ""; -const char * const RUN_TO_LINE_KEY = "Shift+F8"; -const char * const RUN_TO_FUNCTION_KEY = "Ctrl+F6"; -const char * const JUMP_TO_LINE_KEY = "Ctrl+D,Ctrl+L"; -const char * const TOGGLE_BREAK_KEY = "F8"; -const char * const BREAK_BY_FUNCTION_KEY = "Ctrl+D,Ctrl+F"; -const char * const BREAK_AT_MAIN_KEY = "Ctrl+D,Ctrl+M"; -const char * const ADD_TO_WATCH_KEY = "Ctrl+D,Ctrl+W"; -const char * const SNAPSHOT_KEY = "Ctrl+D,Ctrl+S"; +const char * const STOP_KEY = "Shift+Ctrl+Y"; +const char * const RESET_KEY = "Ctrl+Shift+F5"; +const char * const STEP_KEY = "Ctrl+Shift+I"; +const char * const STEPOUT_KEY = "Ctrl+Shift+T"; +const char * const NEXT_KEY = "Ctrl+Shift+O"; +const char * const REVERSE_KEY = ""; +const char * const RUN_TO_LINE_KEY = "Shift+F8"; +const char * const RUN_TO_SELECTED_FUNCTION_KEY = "Ctrl+F6"; +const char * const JUMP_TO_LINE_KEY = "Ctrl+D,Ctrl+L"; +const char * const TOGGLE_BREAK_KEY = "F8"; +const char * const BREAK_BY_FUNCTION_KEY = "Ctrl+D,Ctrl+F"; +const char * const BREAK_AT_MAIN_KEY = "Ctrl+D,Ctrl+M"; +const char * const ADD_TO_WATCH_KEY = "Ctrl+D,Ctrl+W"; +const char * const SNAPSHOT_KEY = "Ctrl+D,Ctrl+S"; #else -const char * const STOP_KEY = "Shift+F5"; -const char * const RESET_KEY = "Ctrl+Shift+F5"; -const char * const STEP_KEY = "F11"; -const char * const STEPOUT_KEY = "Shift+F11"; -const char * const NEXT_KEY = "F10"; -const char * const REVERSE_KEY = "F12"; -const char * const RUN_TO_LINE_KEY = ""; -const char * const RUN_TO_FUNCTION_KEY = ""; -const char * const JUMP_TO_LINE_KEY = ""; -const char * const TOGGLE_BREAK_KEY = "F9"; -const char * const BREAK_BY_FUNCTION_KEY = ""; -const char * const BREAK_AT_MAIN_KEY = ""; -const char * const ADD_TO_WATCH_KEY = "Ctrl+Alt+Q"; -const char * const SNAPSHOT_KEY = "Ctrl+D,Ctrl+S"; +const char * const STOP_KEY = "Shift+F5"; +const char * const RESET_KEY = "Ctrl+Shift+F5"; +const char * const STEP_KEY = "F11"; +const char * const STEPOUT_KEY = "Shift+F11"; +const char * const NEXT_KEY = "F10"; +const char * const REVERSE_KEY = "F12"; +const char * const RUN_TO_LINE_KEY = ""; +const char * const RUN_TO_SELECTED_FUNCTION_KEY = "Ctrl+F6"; +const char * const JUMP_TO_LINE_KEY = ""; +const char * const TOGGLE_BREAK_KEY = "F9"; +const char * const BREAK_BY_FUNCTION_KEY = ""; +const char * const BREAK_AT_MAIN_KEY = ""; +const char * const ADD_TO_WATCH_KEY = "Ctrl+Alt+Q"; +const char * const SNAPSHOT_KEY = "Ctrl+D,Ctrl+S"; #endif } // namespace Constants @@ -885,7 +885,7 @@ struct DebuggerActions QAction *stepAction; QAction *stepOutAction; QAction *runToLineAction; // Debug menu - QAction *runToFunctionAction; + QAction *runToSelectedFunctionAction; QAction *jumpToLineAction; // in the Debug menu QAction *returnFromFunctionAction; QAction *nextAction; @@ -1164,9 +1164,8 @@ public slots: currentEngine()->executeRunToLine(fileName, lineNumber); } - void handleExecRunToFunction() + void handleExecRunToSelectedFunction() { - currentEngine()->resetLocation(); ITextEditor *textEditor = currentTextEditor(); QTC_ASSERT(textEditor, return); QPlainTextEdit *ed = qobject_cast(textEditor->widget()); @@ -1191,8 +1190,14 @@ public slots: } } - if (!functionName.isEmpty()) + if (functionName.isEmpty()) { + showStatusMessage(tr("No function selected.")); + } else { + showStatusMessage(tr("Running to function \"%1\".") + .arg(functionName)); + currentEngine()->resetLocation(); currentEngine()->executeRunToFunction(functionName); + } } void slotEditBreakpoint() @@ -2108,7 +2113,7 @@ void DebuggerPluginPrivate::setInitialState() m_actions.stepAction->setEnabled(false); m_actions.stepOutAction->setEnabled(false); m_actions.runToLineAction->setEnabled(false); - m_actions.runToFunctionAction->setEnabled(false); + m_actions.runToSelectedFunctionAction->setEnabled(true); m_actions.returnFromFunctionAction->setEnabled(false); m_actions.jumpToLineAction->setEnabled(false); m_actions.nextAction->setEnabled(false); @@ -2235,7 +2240,7 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine) m_actions.stepAction->setEnabled(stopped); m_actions.stepOutAction->setEnabled(stopped); m_actions.runToLineAction->setEnabled(stopped); - m_actions.runToFunctionAction->setEnabled(stopped); + m_actions.runToSelectedFunctionAction->setEnabled(stopped); m_actions.returnFromFunctionAction-> setEnabled(stopped && (caps & ReturnFromFunctionCapability)); @@ -2699,9 +2704,9 @@ void DebuggerPluginPrivate::extensionsInitialized() act = m_actions.runToLineAction = new QAction(tr("Run to Line"), this); connect(act, SIGNAL(triggered()), SLOT(handleExecRunToLine())); - act = m_actions.runToFunctionAction = - new QAction(tr("Run to Outermost Function"), this); - connect(act, SIGNAL(triggered()), SLOT(handleExecRunToFunction())); + act = m_actions.runToSelectedFunctionAction = + new QAction(tr("Run to Selected Function"), this); + connect(act, SIGNAL(triggered()), SLOT(handleExecRunToSelectedFunction())); act = m_actions.returnFromFunctionAction = new QAction(tr("Immediately Return From Inner Function"), this); @@ -2946,11 +2951,14 @@ void DebuggerPluginPrivate::extensionsInitialized() cmd->setAttribute(Command::CA_Hide); debugMenu->addAction(cmd); - cmd = am->registerAction(m_actions.runToFunctionAction, - Constants::RUN_TO_FUNCTION, cppDebuggercontext); - cmd->setDefaultKeySequence(QKeySequence(Constants::RUN_TO_FUNCTION_KEY)); + cmd = am->registerAction(m_actions.runToSelectedFunctionAction, + Constants::RUN_TO_SELECTED_FUNCTION, cppDebuggercontext); + cmd->setDefaultKeySequence(QKeySequence( + Constants::RUN_TO_SELECTED_FUNCTION_KEY)); cmd->setAttribute(Command::CA_Hide); - debugMenu->addAction(cmd); + // Don't add to menu by default as keeping its enabled state + // and text up-to-date is a lot of hassle. + // debugMenu->addAction(cmd); cmd = am->registerAction(m_actions.jumpToLineAction, Constants::JUMP_TO_LINE1, cppDebuggercontext); diff --git a/src/plugins/debugger/watchutils.cpp b/src/plugins/debugger/watchutils.cpp index d11f0465e2..004ee58f75 100644 --- a/src/plugins/debugger/watchutils.cpp +++ b/src/plugins/debugger/watchutils.cpp @@ -190,45 +190,51 @@ bool isLeavableFunction(const QString &funcName, const QString &fileName) return true; if (funcName.endsWith(QLatin1String("QMutexPool::get"))) return true; - if (fileName.endsWith(QLatin1String("kernel/qmetaobject.cpp")) - && funcName.endsWith(QLatin1String("QMetaObject::methodOffset"))) - return true; - if (fileName.endsWith(QLatin1String("kernel/qobject.h"))) - return true; - if (fileName.endsWith(QLatin1String("kernel/qobject.cpp")) - && funcName.endsWith(QLatin1String("QObjectConnectionListVector::at"))) - return true; - if (fileName.endsWith(QLatin1String("kernel/qobject.cpp")) - && funcName.endsWith(QLatin1String("~QObject"))) - return true; - if (fileName.endsWith(QLatin1String("thread/qmutex.cpp"))) - return true; - if (fileName.endsWith(QLatin1String("thread/qthread.cpp"))) - return true; - if (fileName.endsWith(QLatin1String("thread/qthread_unix.cpp"))) - return true; - if (fileName.endsWith(QLatin1String("thread/qmutex.h"))) - return true; - if (fileName.contains(QLatin1String("thread/qbasicatomic"))) - return true; - if (fileName.contains(QLatin1String("thread/qorderedmutexlocker_p"))) - return true; - if (fileName.contains(QLatin1String("arch/qatomic"))) - return true; - if (fileName.endsWith(QLatin1String("tools/qvector.h"))) - return true; - if (fileName.endsWith(QLatin1String("tools/qlist.h"))) - return true; - if (fileName.endsWith(QLatin1String("tools/qhash.h"))) - return true; - if (fileName.endsWith(QLatin1String("tools/qmap.h"))) - return true; - if (fileName.endsWith(QLatin1String("tools/qshareddata.h"))) - return true; - if (fileName.endsWith(QLatin1String("tools/qstring.h"))) - return true; - if (fileName.endsWith(QLatin1String("global/qglobal.h"))) - return true; + + if (fileName.endsWith(QLatin1String(".cpp"))) { + if (fileName.endsWith(QLatin1String("/qmetaobject.cpp")) + && funcName.endsWith(QLatin1String("QMetaObject::methodOffset"))) + return true; + if (fileName.endsWith(QLatin1String("/qobject.cpp")) + && (funcName.endsWith(QLatin1String("QObjectConnectionListVector::at")) + || funcName.endsWith(QLatin1String("~QObject")))) + return true; + if (fileName.endsWith(QLatin1String("/qmutex.cpp"))) + return true; + if (fileName.endsWith(QLatin1String("/qthread.cpp"))) + return true; + if (fileName.endsWith(QLatin1String("/qthread_unix.cpp"))) + return true; + } else if (fileName.endsWith(QLatin1String(".h"))) { + + if (fileName.endsWith(QLatin1String("/qobject.h"))) + return true; + if (fileName.endsWith(QLatin1String("/qmutex.h"))) + return true; + if (fileName.endsWith(QLatin1String("/qvector.h"))) + return true; + if (fileName.endsWith(QLatin1String("/qlist.h"))) + return true; + if (fileName.endsWith(QLatin1String("/qhash.h"))) + return true; + if (fileName.endsWith(QLatin1String("/qmap.h"))) + return true; + if (fileName.endsWith(QLatin1String("/qshareddata.h"))) + return true; + if (fileName.endsWith(QLatin1String("/qstring.h"))) + return true; + if (fileName.endsWith(QLatin1String("/qglobal.h"))) + return true; + + } else { + + if (fileName.contains(QLatin1String("/qbasicatomic"))) + return true; + if (fileName.contains(QLatin1String("/qorderedmutexlocker_p"))) + return true; + if (fileName.contains(QLatin1String("/qatomic"))) + return true; + } return false; } diff --git a/tests/manual/gdbdebugger/simple/simple_gdbtest_app.cpp b/tests/manual/gdbdebugger/simple/simple_gdbtest_app.cpp index c36e4fe744..94291b96be 100644 --- a/tests/manual/gdbdebugger/simple/simple_gdbtest_app.cpp +++ b/tests/manual/gdbdebugger/simple/simple_gdbtest_app.cpp @@ -1996,7 +1996,7 @@ void testTypedef() ++k; ++t1; ++t2; -}; +} void testConditional(const QString &str) { @@ -2019,7 +2019,10 @@ void testChar() void testStuff() { + typedef unsigned char byte; + byte f = '2'; testConditional("foo"); + testConditional(fooxx()); testConditional("bar"); testConditional("zzz"); Foo *f1 = new Foo(1);