add some C escaping to relevant MI commands

This commit is contained in:
Oswald Buddenhagen
2009-05-05 15:53:17 +02:00
parent f0c1244cbe
commit 57a93374cd
3 changed files with 29 additions and 10 deletions

View File

@@ -1824,9 +1824,9 @@ void GdbEngine::sendInsertBreakpoint(int index)
//if (where.isEmpty())
// where = data->fileName;
#endif
// we need something like "\"file name.cpp\":100" to
// survive the gdb command line parser with file names intact
where = _("\"\\\"") + where + _("\\\":") + data->lineNumber + _c('"');
// The argument is simply a C-quoted version of the argument to the
// non-MI "break" command, including the "original" quoting it wants.
where = _("\"\\\"") + GdbMi::escapeCString(where) + _("\\\":") + data->lineNumber + _c('"');
} else {
where = data->funcName;
}
@@ -1987,6 +1987,8 @@ void GdbEngine::handleBreakInsert(const GdbResultRecord &record, const QVariant
handler->updateMarkers();
} else if (record.resultClass == GdbResultError) {
const BreakpointData *data = handler->at(index);
// Note that it is perfectly correct that the file name is put
// in quotes but not escaped. GDB simply is like that.
#ifdef Q_OS_LINUX
//QString where = "\"\\\"" + data->fileName + "\\\":"
// + data->lineNumber + "\"";
@@ -3848,13 +3850,13 @@ void GdbEngine::tryLoadDebuggingHelpers()
execCommand(_("sharedlibrary .*")); // for LoadLibraryA
//execCommand(_("handle SIGSEGV pass stop print"));
//execCommand(_("set unwindonsignal off"));
execCommand(_("call LoadLibraryA(\"") + lib + _("\")"),
execCommand(_("call LoadLibraryA(\"") + GdbMi::escapeCString(lib) + _("\")"),
CB(handleDebuggingHelperSetup));
execCommand(_("sharedlibrary ") + dotEscape(lib));
#elif defined(Q_OS_MAC)
//execCommand(_("sharedlibrary libc")); // for malloc
//execCommand(_("sharedlibrary libdl")); // for dlopen
execCommand(_("call (void)dlopen(\"") + lib + _("\", " STRINGIFY(RTLD_NOW) ")"),
execCommand(_("call (void)dlopen(\"") + GdbMi::escapeCString(lib) + _("\", " STRINGIFY(RTLD_NOW) ")"),
CB(handleDebuggingHelperSetup));
//execCommand(_("sharedlibrary ") + dotEscape(lib));
m_debuggingHelperState = DebuggingHelperLoadTried;
@@ -3863,10 +3865,10 @@ void GdbEngine::tryLoadDebuggingHelpers()
QString flag = QString::number(RTLD_NOW);
execCommand(_("sharedlibrary libc")); // for malloc
execCommand(_("sharedlibrary libdl")); // for dlopen
execCommand(_("call (void*)dlopen(\"") + lib + _("\", " STRINGIFY(RTLD_NOW) ")"),
execCommand(_("call (void*)dlopen(\"") + GdbMi::escapeCString(lib) + _("\", " STRINGIFY(RTLD_NOW) ")"),
CB(handleDebuggingHelperSetup));
// some older systems like CentOS 4.6 prefer this:
execCommand(_("call (void*)__dlopen(\"") + lib + _("\", " STRINGIFY(RTLD_NOW) ")"),
execCommand(_("call (void*)__dlopen(\"") + GdbMi::escapeCString(lib) + _("\", " STRINGIFY(RTLD_NOW) ")"),
CB(handleDebuggingHelperSetup));
execCommand(_("sharedlibrary ") + dotEscape(lib));
#endif