Commit 9f8b5af3 authored by hjk's avatar hjk
Browse files

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

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