Commit 9f8b5af3 authored by hjk's avatar hjk

debugger: make parsing of cli-style commands in python more robust

parent d747efed
......@@ -173,9 +173,19 @@ def catchCliOutput(command):
gdb.execute("set logging file %s" % filename)
gdb.execute("set logging redirect on")
gdb.execute("set logging on")
gdb.execute(command)
msg = ""
try:
gdb.execute(command)
except RuntimeError, error:
# For the first phase of core file loading this yield
# "No symbol table is loaded. Use the \"file\" command."
msg = str(error)
except:
msg = "Unknown error";
gdb.execute("set logging off")
gdb.execute("set logging redirect off")
if len(msg):
warn("CLI ERROR: %s " % msg)
temp = open(filename, "r")
lines = []
for line in temp:
......@@ -860,29 +870,32 @@ class SetupCommand(gdb.Command):
super(SetupCommand, self).__init__("bbsetup", gdb.COMMAND_OBSCURE)
def invoke(self, args, from_tty):
module = sys.modules[__name__]
for key, value in module.__dict__.items():
if key.startswith("qdump__"):
name = key[7:]
qqDumpers[name] = value
qqFormats[name] = qqFormats.get(name, "");
elif key.startswith("qform__"):
name = key[7:]
formats = ""
try:
formats = value()
except:
pass
qqFormats[name] = formats
result = "dumpers=["
qqNs = qtNamespace()
for key, value in qqFormats.items():
result += '{type="%s",formats="%s"},' % (key, value)
result += '],namespace="%s"' % qqNs
print(result)
print bbsetup()
SetupCommand()
def bbsetup():
module = sys.modules[__name__]
for key, value in module.__dict__.items():
if key.startswith("qdump__"):
name = key[7:]
qqDumpers[name] = value
qqFormats[name] = qqFormats.get(name, "");
elif key.startswith("qform__"):
name = key[7:]
formats = ""
try:
formats = value()
except:
pass
qqFormats[name] = formats
result = "dumpers=["
qqNs = qtNamespace()
for key, value in qqFormats.items():
result += '{type="%s",formats="%s"},' % (key, value)
result += '],namespace="%s"' % qqNs
return result
#######################################################################
#
......
......@@ -46,6 +46,10 @@ namespace Internal {
static_cast<GdbEngine::AdapterCallback>(&CoreGdbAdapter::callback), \
STRINGIFY(callback)
#ifdef Q_OS_LINUX
# define EXE_FROM_CORE
#endif
///////////////////////////////////////////////////////////////////////
//
// CoreGdbAdapter
......@@ -53,7 +57,7 @@ namespace Internal {
///////////////////////////////////////////////////////////////////////
CoreGdbAdapter::CoreGdbAdapter(GdbEngine *engine, QObject *parent)
: AbstractGdbAdapter(engine, parent)
: AbstractGdbAdapter(engine, parent), m_round(1)
{
}
......@@ -94,6 +98,7 @@ void CoreGdbAdapter::setupInferior()
void CoreGdbAdapter::loadExeAndSyms()
{
QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
// Do that first, otherwise no symbols are loaded.
QFileInfo fi(m_executable);
QByteArray path = fi.absoluteFilePath().toLocal8Bit();
......@@ -116,6 +121,7 @@ void CoreGdbAdapter::handleFileExecAndSymbols(const GdbResponse &response)
void CoreGdbAdapter::loadCoreFile()
{
QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
// Quoting core name below fails in gdb 6.8-debian.
QFileInfo fi(startParameters().coreFile);
QByteArray coreName = fi.absoluteFilePath().toLocal8Bit();
......
......@@ -34,9 +34,6 @@
#include "abstractgdbprocess.h"
#ifdef Q_OS_LINUX
# define EXE_FROM_CORE
#endif
namespace Debugger {
namespace Internal {
......@@ -71,9 +68,7 @@ private:
void handleFileExecAndSymbols(const GdbResponse &response);
void handleTargetCore(const GdbResponse &response);
#ifdef EXE_FROM_CORE
int m_round;
#endif
int m_round; // Round 1: read executable name from core, Round 2: use it.
QString m_executable;
LocalGdbProcess m_gdbProc;
};
......
......@@ -4140,7 +4140,7 @@ bool GdbEngine::startGdb(const QStringList &args, const QString &gdb, const QStr
postCommand("python execfile('" + dumperSourcePath + "gdbmacros.py')",
ConsoleCommand|NonCriticalResponse);
postCommand("bbsetup",
ConsoleCommand,CB(handleHasPython));
ConsoleCommand, CB(handleHasPython));
return true;
}
......
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