diff options
Diffstat (limited to 'src/plugins/debugger/lldb/lldbengine.cpp')
-rw-r--r-- | src/plugins/debugger/lldb/lldbengine.cpp | 143 |
1 files changed, 71 insertions, 72 deletions
diff --git a/src/plugins/debugger/lldb/lldbengine.cpp b/src/plugins/debugger/lldb/lldbengine.cpp index 995879601c..7c3e8f54f0 100644 --- a/src/plugins/debugger/lldb/lldbengine.cpp +++ b/src/plugins/debugger/lldb/lldbengine.cpp @@ -32,7 +32,6 @@ #include <debugger/debuggermainwindow.h> #include <debugger/debuggerprotocol.h> #include <debugger/debuggerstartparameters.h> -#include <debugger/debuggerstringutils.h> #include <debugger/debuggertooltipmanager.h> #include <debugger/breakhandler.h> @@ -117,18 +116,18 @@ void LldbEngine::runCommand(const DebuggerCommand &cmd) if (m_lldbProc.state() != QProcess::Running) { // This can legally happen e.g. through a reloadModule() // triggered by changes in view visibility. - showMessage(_("NO LLDB PROCESS RUNNING, CMD IGNORED: %1 %2") - .arg(_(cmd.function)).arg(state())); + showMessage(QString("NO LLDB PROCESS RUNNING, CMD IGNORED: %1 %2") + .arg(cmd.function).arg(state())); return; } const int tok = ++currentToken(); DebuggerCommand command = cmd; command.arg("token", tok); QByteArray token = QByteArray::number(tok); - QByteArray function = command.function + "(" + command.argsToPython() + ")"; - showMessage(_(token + function + '\n'), LogInput); + QString function = command.function + "(" + command.argsToPython() + ")"; + showMessage(token + function + '\n', LogInput); m_commandForToken[currentToken()] = command; - m_lldbProc.write("script theDumper." + function + "\n"); + m_lldbProc.write("script theDumper." + function.toUtf8() + "\n"); } void LldbEngine::debugLastCommand() @@ -155,11 +154,11 @@ void LldbEngine::abortDebugger() { if (targetState() == DebuggerFinished) { // We already tried. Try harder. - showMessage(_("ABORTING DEBUGGER. SECOND TIME.")); + showMessage("ABORTING DEBUGGER. SECOND TIME."); m_lldbProc.kill(); } else { // Be friendly the first time. This will change targetState(). - showMessage(_("ABORTING DEBUGGER. FIRST TIME.")); + showMessage("ABORTING DEBUGGER. FIRST TIME."); quitDebugger(); } } @@ -206,7 +205,7 @@ void LldbEngine::setupEngine() #endif QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state()); - showMessage(_("TRYING TO START ADAPTER")); + showMessage("TRYING TO START ADAPTER"); // Currently, adapters are not re-used // // We leave the console open, so recycle it now. @@ -261,7 +260,7 @@ void LldbEngine::startLldb() connect(this, &LldbEngine::outputReady, this, &LldbEngine::handleResponse, Qt::QueuedConnection); - showMessage(_("STARTING LLDB: ") + m_lldbCmd); + showMessage("STARTING LLDB: " + m_lldbCmd); m_lldbProc.setEnvironment(runParameters().debuggerEnvironment); if (!runParameters().inferior.workingDirectory.isEmpty()) m_lldbProc.setWorkingDirectory(runParameters().inferior.workingDirectory); @@ -273,7 +272,7 @@ void LldbEngine::startLldb() const QString msg = tr("Unable to start LLDB \"%1\": %2") .arg(m_lldbCmd, m_lldbProc.errorString()); notifyEngineSetupFailed(); - showMessage(_("ADAPTER START FAILED")); + showMessage("ADAPTER START FAILED"); if (!msg.isEmpty()) ICore::showWarningWithOptions(tr("Adapter start failed."), msg); return; @@ -285,7 +284,7 @@ void LldbEngine::startLldb() // FIXME: splitting of startLldb() necessary to support LLDB <= 310 - revert asap void LldbEngine::startLldbStage2() { - showMessage(_("ADAPTER STARTED")); + showMessage("ADAPTER STARTED"); showStatusMessage(tr("Setting up inferior...")); const QByteArray dumperSourcePath = @@ -308,23 +307,23 @@ void LldbEngine::setupInferior() foreach (const EnvironmentItem &item, sysEnv.diff(runEnv)) { DebuggerCommand cmd("executeDebuggerCommand"); if (item.unset) - cmd.arg("command", "settings remove target.env-vars " + item.name.toUtf8()); + cmd.arg("command", "settings remove target.env-vars " + item.name); else - cmd.arg("command", "settings set target.env-vars '" + item.name.toUtf8() + '=' + item.value.toUtf8() + '\''); + cmd.arg("command", "settings set target.env-vars '" + item.name + '=' + item.value + '\''); runCommand(cmd); } const QString path = stringSetting(ExtraDumperFile); if (!path.isEmpty() && QFileInfo(path).isReadable()) { DebuggerCommand cmd("addDumperModule"); - cmd.arg("path", path.toUtf8()); + cmd.arg("path", path); runCommand(cmd); } const QString commands = stringSetting(ExtraDumperCommands); if (!commands.isEmpty()) { DebuggerCommand cmd("executeDebuggerCommand"); - cmd.arg("command", commands.toUtf8()); + cmd.arg("command", commands); runCommand(cmd); } @@ -348,9 +347,9 @@ void LldbEngine::setupInferior() cmd2.arg("startmode", rp.startMode); cmd2.arg("nativemixed", isNativeMixedActive()); - cmd2.arg("dyldimagesuffix", rp.inferior.environment.value(_("DYLD_IMAGE_SUFFIX"))); - cmd2.arg("dyldframeworkpath", rp.inferior.environment.value(_("DYLD_LIBRARY_PATH"))); - cmd2.arg("dyldlibrarypath", rp.inferior.environment.value(_("DYLD_FRAMEWORK_PATH"))); + cmd2.arg("dyldimagesuffix", rp.inferior.environment.value("DYLD_IMAGE_SUFFIX")); + cmd2.arg("dyldframeworkpath", rp.inferior.environment.value("DYLD_LIBRARY_PATH")); + cmd2.arg("dyldlibrarypath", rp.inferior.environment.value("DYLD_FRAMEWORK_PATH")); QJsonArray processArgs; foreach (const QString &arg, args.toUnixArgs()) @@ -394,7 +393,7 @@ void LldbEngine::setupInferior() bp.setEngine(this); insertBreakpoint(bp); } else { - showMessage(_("BREAKPOINT %1 IN STATE %2 IS NOT ACCEPTABLE") + showMessage(QString("BREAKPOINT %1 IN STATE %2 IS NOT ACCEPTABLE") .arg(bp.id().toString()).arg(bp.state())); } } @@ -464,21 +463,21 @@ void LldbEngine::continueInferior() runCommand(cmd); } -void LldbEngine::handleResponse(const QByteArray &response) +void LldbEngine::handleResponse(const QString &response) { GdbMi all; all.fromStringMultiple(response); foreach (const GdbMi &item, all.children()) { - const QByteArray name = item.name(); + const QString name = item.name(); if (name == "result") { - QString msg = item["status"].toUtf8(); + QString msg = item["status"].data(); if (msg.size()) msg[0] = msg.at(0).toUpper(); showStatusMessage(msg); int token = item["token"].toInt(); - showMessage(QString::fromLatin1("%1^").arg(token), LogOutput); + showMessage(QString("%1^").arg(token), LogOutput); if (m_commandForToken.contains(token)) { DebuggerCommand cmd = m_commandForToken.take(token); DebuggerResponse response; @@ -596,7 +595,7 @@ void LldbEngine::changeBreakpoint(Breakpoint bp) { const BreakpointResponse &response = bp.response(); DebuggerCommand cmd("changeBreakpoint"); - cmd.arg("lldbid", response.id.toByteArray()); + cmd.arg("lldbid", response.id.toString()); cmd.callback = [this, bp](const DebuggerResponse &response) { QTC_CHECK(!bp.isValid() || bp.state() == BreakpointChangeProceeding); updateBreakpointData(bp, response.data, false); @@ -611,7 +610,7 @@ void LldbEngine::removeBreakpoint(Breakpoint bp) const BreakpointResponse &response = bp.response(); if (response.id.isValid()) { DebuggerCommand cmd("removeBreakpoint"); - cmd.arg("lldbid", response.id.toByteArray()); + cmd.arg("lldbid", response.id.toString()); cmd.callback = [this, bp](const DebuggerResponse &) { QTC_CHECK(bp.state() == BreakpointRemoveProceeding); Breakpoint bp0 = bp; @@ -635,9 +634,9 @@ void LldbEngine::updateBreakpointData(Breakpoint bp, const GdbMi &bkpt, bool add response.address = 0; response.enabled = bkpt["enabled"].toInt(); response.ignoreCount = bkpt["ignorecount"].toInt(); - response.condition = QByteArray::fromHex(bkpt["condition"].data()); + response.condition = fromHex(bkpt["condition"].data()); response.hitCount = bkpt["hitcount"].toInt(); - response.fileName = bkpt["file"].toUtf8(); + response.fileName = bkpt["file"].data(); response.lineNumber = bkpt["line"].toInt(); GdbMi locations = bkpt["locations"]; @@ -649,8 +648,8 @@ void LldbEngine::updateBreakpointData(Breakpoint bp, const GdbMi &bkpt, bool add sub.id = BreakpointResponseId(rid.majorPart(), locid); sub.type = response.type; sub.address = location["addr"].toAddress(); - sub.functionName = location["func"].toUtf8(); - sub.fileName = location["file"].toUtf8(); + sub.functionName = location["func"].data(); + sub.fileName = location["file"].data(); sub.lineNumber = location["line"].toInt(); bp.insertSubBreakpoint(sub); } @@ -658,11 +657,11 @@ void LldbEngine::updateBreakpointData(Breakpoint bp, const GdbMi &bkpt, bool add } else if (numChild == 1) { const GdbMi location = locations.childAt(0); response.address = location["addr"].toAddress(); - response.functionName = location["func"].toUtf8(); + response.functionName = location["func"].data(); response.pending = false; } else { // This can happen for pending breakpoints. - showMessage(_("NO LOCATIONS (YET) FOR BP %1").arg(response.toString())); + showMessage(QString("NO LOCATIONS (YET) FOR BP %1").arg(response.toString())); } bp.setResponse(response); if (added) @@ -673,14 +672,14 @@ void LldbEngine::updateBreakpointData(Breakpoint bp, const GdbMi &bkpt, bool add void LldbEngine::handleOutputNotification(const GdbMi &output) { - QByteArray channel = output["channel"].data(); - QByteArray data = QByteArray::fromHex(output["data"].data()); + QString channel = output["channel"].data(); + QString data = fromHex(output["data"].data()); LogChannel ch = AppStuff; if (channel == "stdout") ch = AppOutput; else if (channel == "stderr") ch = AppError; - showMessage(QString::fromUtf8(data), ch); + showMessage(data, ch); } void LldbEngine::loadSymbols(const QString &moduleName) @@ -701,8 +700,8 @@ void LldbEngine::reloadModules() handler->beginUpdateAll(); foreach (const GdbMi &item, modules.children()) { Module module; - module.modulePath = item["file"].toUtf8(); - module.moduleName = item["name"].toUtf8(); + module.modulePath = item["file"].data(); + module.moduleName = item["name"].data(); module.symbolsRead = Module::UnknownReadState; module.startAddress = item["loaded_addr"].toAddress(); module.endAddress = 0; // FIXME: End address not easily available. @@ -719,15 +718,15 @@ void LldbEngine::requestModuleSymbols(const QString &moduleName) cmd.arg("module", moduleName); cmd.callback = [this, moduleName](const DebuggerResponse &response) { const GdbMi &symbols = response.data["symbols"]; - QString moduleName = response.data["module"].toUtf8(); + QString moduleName = response.data["module"].data(); Symbols syms; foreach (const GdbMi &item, symbols.children()) { Symbol symbol; - symbol.address = item["address"].toUtf8(); - symbol.name = item["name"].toUtf8(); - symbol.state = item["state"].toUtf8(); - symbol.section = item["section"].toUtf8(); - symbol.demangled = item["demangled"].toUtf8(); + symbol.address = item["address"].data(); + symbol.name = item["name"].data(); + symbol.state = item["state"].data(); + symbol.section = item["section"].data(); + symbol.demangled = item["demangled"].data(); syms.append(symbol); } Internal::showModuleSymbols(moduleName, syms); @@ -789,8 +788,8 @@ void LldbEngine::assignValueInDebugger(WatchItem *, const QString &expression, const QVariant &value) { DebuggerCommand cmd("assignValue"); - cmd.arg("exp", expression.toLatin1().toHex()); - cmd.arg("value", value.toString().toLatin1().toHex()); + cmd.arg("exp", toHex(expression)); + cmd.arg("value", toHex(value.toString())); cmd.callback = [this](const DebuggerResponse &) { updateLocals(); }; runCommand(cmd); } @@ -830,7 +829,7 @@ void LldbEngine::doUpdateLocals(const UpdateParameters ¶ms) void LldbEngine::handleLldbError(QProcess::ProcessError error) { - showMessage(_("LLDB PROCESS ERROR: %1").arg(error)); + showMessage(QString("LLDB PROCESS ERROR: %1").arg(error)); switch (error) { case QProcess::Crashed: break; // will get a processExited() as well @@ -869,7 +868,7 @@ QString LldbEngine::errorMessage(QProcess::ProcessError error) const return tr("An error occurred when attempting to read from " "the Lldb process. For example, the process may not be running."); default: - return tr("An unknown error in the LLDB process occurred.") + QLatin1Char(' '); + return tr("An unknown error in the LLDB process occurred.") + ' '; } } @@ -880,22 +879,23 @@ void LldbEngine::handleLldbFinished(int exitCode, QProcess::ExitStatus exitStatu void LldbEngine::readLldbStandardError() { - QByteArray err = m_lldbProc.readAllStandardError(); + QString err = QString::fromUtf8(m_lldbProc.readAllStandardError()); qDebug() << "\nLLDB STDERR UNEXPECTED: " << err; - showMessage(_("Lldb stderr: " + err), LogError); + showMessage("Lldb stderr: " + err, LogError); } void LldbEngine::readLldbStandardOutput() { - QByteArray out = m_lldbProc.readAllStandardOutput(); - out.replace("\r\n", "\n"); - showMessage(_(out), LogOutput); + QByteArray outba = m_lldbProc.readAllStandardOutput(); + outba.replace("\r\n", "\n"); + QString out = QString::fromUtf8(outba); + showMessage(out, LogOutput); m_inbuffer.append(out); while (true) { int pos = m_inbuffer.indexOf("@\n"); if (pos == -1) break; - QByteArray response = m_inbuffer.left(pos).trimmed(); + QString response = m_inbuffer.left(pos).trimmed(); m_inbuffer = m_inbuffer.mid(pos + 2); if (response == "lldbstartupok") startLldbStage2(); @@ -906,7 +906,7 @@ void LldbEngine::readLldbStandardOutput() void LldbEngine::handleStateNotification(const GdbMi &reportedState) { - QByteArray newState = reportedState.data(); + QString newState = reportedState.data(); if (newState == "running") notifyInferiorRunOk(); else if (newState == "inferiorrunfailed") @@ -956,8 +956,8 @@ void LldbEngine::handleStateNotification(const GdbMi &reportedState) void LldbEngine::handleLocationNotification(const GdbMi &reportedLocation) { qulonglong address = reportedLocation["address"].toAddress(); - QString fileName = reportedLocation["file"].toUtf8(); - QByteArray function = reportedLocation["function"].data(); + QString fileName = reportedLocation["file"].data(); + QString function = reportedLocation["function"].data(); int lineNumber = reportedLocation["line"].toInt(); Location loc = Location(fileName, lineNumber); if (boolSetting(OperateByInstruction) || !QFileInfo::exists(fileName) || lineNumber <= 0) { @@ -985,7 +985,7 @@ void LldbEngine::reloadRegisters() foreach (const GdbMi &item, regs.children()) { Register reg; reg.name = item["name"].data(); - reg.value.fromByteArray(item["value"].data(), HexadecimalFormat); + reg.value.fromString(item["value"].data(), HexadecimalFormat); reg.size = item["size"].data().toInt(); reg.reportedType = item["type"].data(); if (reg.reportedType.startsWith("unsigned")) @@ -1023,20 +1023,20 @@ void LldbEngine::fetchDisassembler(DisassemblerAgent *agent) foreach (const GdbMi &line, response.data["lines"].children()) { DisassemblerLine dl; dl.address = line["address"].toAddress(); - //dl.data = line["data"].toUtf8(); + //dl.data = line["data"].data(); //dl.rawData = line["rawdata"].data(); - dl.data = line["rawdata"].toUtf8(); + dl.data = line["rawdata"].data(); if (!dl.data.isEmpty()) dl.data += QString(30 - dl.data.size(), QLatin1Char(' ')); - dl.data += line["data"].toUtf8(); + dl.data += line["data"].data(); dl.offset = line["offset"].toInt(); dl.lineNumber = line["line"].toInt(); - dl.fileName = line["file"].toUtf8(); - dl.function = line["function"].toUtf8(); + dl.fileName = line["file"].data(); + dl.function = line["function"].data(); dl.hunk = line["hunk"].toInt(); - QByteArray comment = QByteArray::fromHex(line["comment"].data()); + QString comment = fromHex(line["comment"].data()); if (!comment.isEmpty()) - dl.data += QString::fromUtf8(" # " + comment); + dl.data += " # " + comment; result.appendLine(dl); } agent->setContents(result); @@ -1049,8 +1049,7 @@ void LldbEngine::fetchFullBacktrace() { DebuggerCommand cmd("fetchFullBacktrace"); cmd.callback = [](const DebuggerResponse &response) { - Internal::openTextEditor(_("Backtrace $"), - QString::fromUtf8(QByteArray::fromHex(response.data.data()))); + Internal::openTextEditor("Backtrace $", fromHex(response.data.data())); }; runCommand(cmd); } @@ -1074,7 +1073,7 @@ void LldbEngine::fetchMemory(MemoryAgent *agent, QObject *editorToken, if (!agent.isNull()) { QPointer<QObject> token = m_memoryAgentTokens.value(id); QTC_ASSERT(!token.isNull(), return); - QByteArray ba = QByteArray::fromHex(response.data["contents"].data()); + QByteArray ba = QByteArray::fromHex(response.data["contents"].data().toUtf8()); agent->addLazyData(token.data(), addr, ba); } }; @@ -1092,12 +1091,12 @@ void LldbEngine::changeMemory(MemoryAgent *agent, QObject *editorToken, } DebuggerCommand cmd("writeMemory"); cmd.arg("address", addr); - cmd.arg("data", data.toHex()); + cmd.arg("data", QString::fromUtf8(data.toHex())); cmd.callback = [this, id](const DebuggerResponse &response) { Q_UNUSED(response); }; runCommand(cmd); } -void LldbEngine::setRegisterValue(const QByteArray &name, const QString &value) +void LldbEngine::setRegisterValue(const QString &name, const QString &value) { DebuggerCommand cmd("setRegister"); cmd.arg("name", name); @@ -1153,7 +1152,7 @@ void LldbEngine::notifyEngineRemoteSetupFinished(const RemoteSetupResult &result if (result.success) { startLldb(); } else { - showMessage(_("ADAPTER START FAILED")); + showMessage("ADAPTER START FAILED"); if (!result.reason.isEmpty()) { const QString title = tr("Adapter start failed"); ICore::showWarningWithOptions(title, result.reason); @@ -1176,10 +1175,10 @@ void LldbEngine::stubError(const QString &msg) void LldbEngine::stubExited() { if (state() == EngineShutdownRequested || state() == DebuggerFinished) { - showMessage(_("STUB EXITED EXPECTEDLY")); + showMessage("STUB EXITED EXPECTEDLY"); return; } - showMessage(_("STUB EXITED")); + showMessage("STUB EXITED"); notifyEngineIll(); } |