Changeset View
Changeset View
Standalone View
Standalone View
debuggers/gdb/debugsession.cpp
Show First 20 Lines • Show All 90 Lines • ▼ Show 20 Line(s) | |||||
91 | 91 | | |||
92 | GdbDebugger *DebugSession::createDebugger() const | 92 | GdbDebugger *DebugSession::createDebugger() const | ||
93 | { | 93 | { | ||
94 | return new GdbDebugger; | 94 | return new GdbDebugger; | ||
95 | } | 95 | } | ||
96 | 96 | | |||
97 | void DebugSession::initializeDebugger() | 97 | void DebugSession::initializeDebugger() | ||
98 | { | 98 | { | ||
99 | //queueCmd(new GDBCommand(GDBMI::EnableTimings, "yes")); | 99 | //addCommand(new GDBCommand(GDBMI::EnableTimings, "yes")); | ||
100 | 100 | | |||
101 | queueCmd(new CliCommand(MI::GdbShow, "version", this, &DebugSession::handleVersion)); | 101 | addCommand(new CliCommand(MI::GdbShow, "version", this, &DebugSession::handleVersion)); | ||
102 | 102 | | |||
103 | // This makes gdb pump a variable out on one line. | 103 | // This makes gdb pump a variable out on one line. | ||
104 | queueCmd(new MICommand(MI::GdbSet, "width 0")); | 104 | addCommand(MI::GdbSet, "width 0"); | ||
105 | queueCmd(new MICommand(MI::GdbSet, "height 0")); | 105 | addCommand(MI::GdbSet, "height 0"); | ||
106 | 106 | | |||
107 | queueCmd(new MICommand(MI::SignalHandle, "SIG32 pass nostop noprint")); | 107 | addCommand(MI::SignalHandle, "SIG32 pass nostop noprint"); | ||
108 | queueCmd(new MICommand(MI::SignalHandle, "SIG41 pass nostop noprint")); | 108 | addCommand(MI::SignalHandle, "SIG41 pass nostop noprint"); | ||
109 | queueCmd(new MICommand(MI::SignalHandle, "SIG42 pass nostop noprint")); | 109 | addCommand(MI::SignalHandle, "SIG42 pass nostop noprint"); | ||
110 | queueCmd(new MICommand(MI::SignalHandle, "SIG43 pass nostop noprint")); | 110 | addCommand(MI::SignalHandle, "SIG43 pass nostop noprint"); | ||
111 | 111 | | |||
112 | queueCmd(new MICommand(MI::EnablePrettyPrinting)); | 112 | addCommand(MI::EnablePrettyPrinting); | ||
113 | 113 | | |||
114 | queueCmd(new MICommand(MI::GdbSet, "charset UTF-8")); | 114 | addCommand(MI::GdbSet, "charset UTF-8"); | ||
115 | queueCmd(new MICommand(MI::GdbSet, "print sevenbit-strings off")); | 115 | addCommand(MI::GdbSet, "print sevenbit-strings off"); | ||
116 | 116 | | |||
117 | QString fileName = QStandardPaths::locate(QStandardPaths::GenericDataLocation, | 117 | QString fileName = QStandardPaths::locate(QStandardPaths::GenericDataLocation, | ||
118 | "kdevgdb/printers/gdbinit"); | 118 | "kdevgdb/printers/gdbinit"); | ||
119 | if (!fileName.isEmpty()) { | 119 | if (!fileName.isEmpty()) { | ||
120 | QFileInfo fileInfo(fileName); | 120 | QFileInfo fileInfo(fileName); | ||
121 | QString quotedPrintersPath = fileInfo.dir().path() | 121 | QString quotedPrintersPath = fileInfo.dir().path() | ||
122 | .replace('\\', "\\\\") | 122 | .replace('\\', "\\\\") | ||
123 | .replace('"', "\\\""); | 123 | .replace('"', "\\\""); | ||
124 | queueCmd(new MICommand(MI::NonMI, | 124 | addCommand(MI::NonMI, | ||
125 | QString("python sys.path.insert(0, \"%0\")").arg(quotedPrintersPath))); | 125 | QString("python sys.path.insert(0, \"%0\")").arg(quotedPrintersPath)); | ||
126 | queueCmd(new MICommand(MI::NonMI, "source " + fileName)); | 126 | addCommand(MI::NonMI, "source " + fileName); | ||
127 | } | 127 | } | ||
128 | 128 | | |||
129 | qCDebug(DEBUGGERGDB) << "Initialized GDB"; | 129 | qCDebug(DEBUGGERGDB) << "Initialized GDB"; | ||
130 | } | 130 | } | ||
131 | 131 | | |||
132 | void DebugSession::configure(ILaunchConfiguration *cfg) | 132 | void DebugSession::configure(ILaunchConfiguration *cfg) | ||
133 | { | 133 | { | ||
134 | // Read Configuration values | 134 | // Read Configuration values | ||
Show All 16 Lines | 140 | if (breakOnStart) { | |||
151 | } | 151 | } | ||
152 | } | 152 | } | ||
153 | // Needed so that breakpoint widget has a chance to insert breakpoints. | 153 | // Needed so that breakpoint widget has a chance to insert breakpoints. | ||
154 | // FIXME: a bit hacky, as we're really not ready for new commands. | 154 | // FIXME: a bit hacky, as we're really not ready for new commands. | ||
155 | setDebuggerStateOn(s_dbgBusy); | 155 | setDebuggerStateOn(s_dbgBusy); | ||
156 | raiseEvent(debugger_ready); | 156 | raiseEvent(debugger_ready); | ||
157 | 157 | | |||
158 | if (displayStaticMembers) { | 158 | if (displayStaticMembers) { | ||
159 | queueCmd(new MICommand(MI::GdbSet, "print static-members on")); | 159 | addCommand(MI::GdbSet, "print static-members on"); | ||
160 | } else { | 160 | } else { | ||
161 | queueCmd(new MICommand(MI::GdbSet, "print static-members off")); | 161 | addCommand(MI::GdbSet, "print static-members off"); | ||
162 | } | 162 | } | ||
163 | 163 | | |||
164 | if (asmDemangle) { | 164 | if (asmDemangle) { | ||
165 | queueCmd(new MICommand(MI::GdbSet, "print asm-demangle on")); | 165 | addCommand(MI::GdbSet, "print asm-demangle on"); | ||
166 | } else { | 166 | } else { | ||
167 | queueCmd(new MICommand(MI::GdbSet, "print asm-demangle off")); | 167 | addCommand(MI::GdbSet, "print asm-demangle off"); | ||
168 | } | 168 | } | ||
169 | 169 | | |||
170 | qCDebug(DEBUGGERGDB) << "Per inferior configuration done"; | 170 | qCDebug(DEBUGGERGDB) << "Per inferior configuration done"; | ||
171 | } | 171 | } | ||
172 | 172 | | |||
173 | bool DebugSession::execInferior(ILaunchConfiguration *cfg, const QString &executable) | 173 | bool DebugSession::execInferior(ILaunchConfiguration *cfg, const QString &executable) | ||
174 | { | 174 | { | ||
175 | qCDebug(DEBUGGERGDB) << "Executing inferior"; | 175 | qCDebug(DEBUGGERGDB) << "Executing inferior"; | ||
176 | 176 | | |||
177 | // debugger specific config | 177 | // debugger specific config | ||
178 | configure(cfg); | 178 | configure(cfg); | ||
179 | 179 | | |||
180 | KConfigGroup grp = cfg->config(); | 180 | KConfigGroup grp = cfg->config(); | ||
181 | QUrl configGdbScript = grp.readEntry(KDevMI::remoteGdbConfigEntry, QUrl()); | 181 | QUrl configGdbScript = grp.readEntry(KDevMI::remoteGdbConfigEntry, QUrl()); | ||
182 | QUrl runShellScript = grp.readEntry(KDevMI::remoteGdbShellEntry, QUrl()); | 182 | QUrl runShellScript = grp.readEntry(KDevMI::remoteGdbShellEntry, QUrl()); | ||
183 | QUrl runGdbScript = grp.readEntry(KDevMI::remoteGdbRunEntry, QUrl()); | 183 | QUrl runGdbScript = grp.readEntry(KDevMI::remoteGdbRunEntry, QUrl()); | ||
184 | 184 | | |||
185 | // handle remote debug | 185 | // handle remote debug | ||
186 | if (configGdbScript.isValid()) { | 186 | if (configGdbScript.isValid()) { | ||
187 | queueCmd(new MICommand(MI::NonMI, "source " + KShell::quoteArg(configGdbScript.toLocalFile()))); | 187 | addCommand(MI::NonMI, "source " + KShell::quoteArg(configGdbScript.toLocalFile())); | ||
188 | } | 188 | } | ||
189 | 189 | | |||
190 | // FIXME: have a check box option that controls remote debugging | 190 | // FIXME: have a check box option that controls remote debugging | ||
191 | if (runShellScript.isValid()) { | 191 | if (runShellScript.isValid()) { | ||
192 | // Special for remote debug, the remote inferior is started by this shell script | 192 | // Special for remote debug, the remote inferior is started by this shell script | ||
193 | QByteArray tty(m_tty->getSlave().toLatin1()); | 193 | QByteArray tty(m_tty->getSlave().toLatin1()); | ||
194 | QByteArray options = QByteArray(">") + tty + QByteArray(" 2>&1 <") + tty; | 194 | QByteArray options = QByteArray(">") + tty + QByteArray(" 2>&1 <") + tty; | ||
195 | 195 | | |||
Show All 14 Lines | 207 | if (runGdbScript.isValid()) { | |||
210 | // Race notice: wait for the remote gdbserver/executable | 210 | // Race notice: wait for the remote gdbserver/executable | ||
211 | // - but that might be an issue for this script to handle... | 211 | // - but that might be an issue for this script to handle... | ||
212 | 212 | | |||
213 | // Note: script could contain "run" or "continue" | 213 | // Note: script could contain "run" or "continue" | ||
214 | 214 | | |||
215 | // Future: the shell script should be able to pass info (like pid) | 215 | // Future: the shell script should be able to pass info (like pid) | ||
216 | // to the gdb script... | 216 | // to the gdb script... | ||
217 | 217 | | |||
218 | queueCmd(new SentinelCommand([this, runGdbScript]() { | 218 | addCommand(new SentinelCommand([this, runGdbScript]() { | ||
219 | breakpointController()->initSendBreakpoints(); | 219 | breakpointController()->initSendBreakpoints(); | ||
220 | 220 | | |||
221 | breakpointController()->setDeleteDuplicateBreakpoints(true); | 221 | breakpointController()->setDeleteDuplicateBreakpoints(true); | ||
222 | qCDebug(DEBUGGERGDB) << "Running gdb script " << KShell::quoteArg(runGdbScript.toLocalFile()); | 222 | qCDebug(DEBUGGERGDB) << "Running gdb script " << KShell::quoteArg(runGdbScript.toLocalFile()); | ||
223 | 223 | | |||
224 | queueCmd(new MICommand(MI::NonMI, "source " + KShell::quoteArg(runGdbScript.toLocalFile()), | 224 | addCommand(MI::NonMI, "source " + KShell::quoteArg(runGdbScript.toLocalFile()), | ||
225 | [this](const MI::ResultRecord&) { | 225 | [this](const MI::ResultRecord&) { | ||
226 | breakpointController()->setDeleteDuplicateBreakpoints(false); | 226 | breakpointController()->setDeleteDuplicateBreakpoints(false); | ||
227 | }, | 227 | }, | ||
228 | CmdMaybeStartsRunning)); | 228 | CmdMaybeStartsRunning); | ||
229 | raiseEvent(connected_to_program); | 229 | raiseEvent(connected_to_program); | ||
230 | }, CmdMaybeStartsRunning)); | 230 | }, CmdMaybeStartsRunning)); | ||
231 | } else { | 231 | } else { | ||
232 | // normal local debugging | 232 | // normal local debugging | ||
233 | queueCmd(new MICommand(MI::FileExecAndSymbols, KShell::quoteArg(executable), | 233 | addCommand(MI::FileExecAndSymbols, KShell::quoteArg(executable), | ||
234 | this, &DebugSession::handleFileExecAndSymbols, | 234 | this, &DebugSession::handleFileExecAndSymbols, | ||
235 | CmdHandlesError)); | 235 | CmdHandlesError); | ||
236 | raiseEvent(connected_to_program); | 236 | raiseEvent(connected_to_program); | ||
237 | 237 | | |||
238 | queueCmd(new SentinelCommand([this]() { | 238 | addCommand(new SentinelCommand([this]() { | ||
239 | breakpointController()->initSendBreakpoints(); | 239 | breakpointController()->initSendBreakpoints(); | ||
240 | queueCmd(new MICommand(MI::ExecRun, QString(), CmdMaybeStartsRunning)); | 240 | addCommand(MI::ExecRun, QString(), CmdMaybeStartsRunning); | ||
241 | }, CmdMaybeStartsRunning)); | 241 | }, CmdMaybeStartsRunning)); | ||
242 | } | 242 | } | ||
243 | return true; | 243 | return true; | ||
244 | } | 244 | } | ||
245 | 245 | | |||
246 | void DebugSession::handleVersion(const QStringList& s) | 246 | void DebugSession::handleVersion(const QStringList& s) | ||
247 | { | 247 | { | ||
248 | qCDebug(DEBUGGERGDB) << s.first(); | 248 | qCDebug(DEBUGGERGDB) << s.first(); | ||
Show All 30 Lines |