Commit eb44cfc0 authored by hjk's avatar hjk

Debugger: Fix loading of Linux core files with LLDB

Change-Id: I76183591c5242589c25d8e5695367d61b6cc5afc
Reviewed-by: default avatarChristian Stenger <christian.stenger@theqtcompany.com>
Reviewed-by: default avatarhjk <hjk@theqtcompany.com>
parent 6e7f07c3
......@@ -647,8 +647,15 @@ class Dumper(DumperBase):
self.platform_ = args.get('platform', '')
self.ignoreStops = 0
if self.useTerminal_ and platform.system() == "Linux":
self.ignoreStops = 2
self.silentStops = 0
if platform.system() == "Linux":
if self.startMode_ == AttachCore:
pass
else:
if self.useTerminal_:
self.ignoreStops = 2
else:
self.silentStops = 1
if self.platform_:
self.debugger.SetCurrentPlatform(self.platform_)
......@@ -656,6 +663,7 @@ class Dumper(DumperBase):
if self.sysRoot_:
self.debugger.SetCurrentPlatformSDKRoot(self.sysRoot_)
if os.path.isfile(self.executable_):
self.target = self.debugger.CreateTarget(self.executable_, None, None, True, error)
else:
......@@ -668,12 +676,12 @@ class Dumper(DumperBase):
state = "inferiorsetupok" if self.target.IsValid() else "inferiorsetupfailed"
self.report('state="%s",msg="%s",exe="%s"' % (state, error, self.executable_))
def runEngine(self, _):
self.prepare()
def runEngine(self, args):
self.prepare(args)
s = threading.Thread(target=self.loop, args=[])
s.start()
def prepare(self):
def prepare(self, args):
error = lldb.SBError()
listener = self.debugger.GetListener()
......@@ -700,6 +708,11 @@ class Dumper(DumperBase):
# and later detects that it did stop after all, so it is be
# better to mirror that and wait for the spontaneous stop.
self.reportState("enginerunandinferiorrunok")
elif self.startMode_ == AttachCore:
coreFile = args.get('coreFile', '');
self.process = self.target.LoadCore(coreFile)
self.reportState("enginerunokandinferiorunrunnable")
#self.reportContinuation(args)
else:
launchInfo = lldb.SBLaunchInfo(self.processArgs_)
launchInfo.SetWorkingDirectory(os.getcwd())
......@@ -747,10 +760,11 @@ class Dumper(DumperBase):
def reportLocation(self):
thread = self.currentThread()
frame = thread.GetSelectedFrame()
file = fileName(frame.line_entry.file)
line = frame.line_entry.line
self.report('location={file="%s",line="%s",addr="%s"}'
% (file, line, frame.pc))
if int(frame.pc) != 0xffffffffffffffff:
file = fileName(frame.line_entry.file)
line = frame.line_entry.line
self.report('location={file="%s",line="%s",addr="%s"}'
% (file, line, frame.pc))
def firstStoppedThread(self):
for i in xrange(0, self.process.GetNumThreads()):
......@@ -1308,6 +1322,8 @@ class Dumper(DumperBase):
elif self.ignoreStops > 0:
self.ignoreStops -= 1
self.process.Continue()
elif self.silentStops > 0:
self.silentStops -= 1
#elif bp and bp in self.qmlBreakpointResolvers:
# self.report("RESOLVER HIT")
# self.qmlBreakpointResolvers[bp]()
......
......@@ -574,16 +574,18 @@ void DebuggerEngine::gotoLocation(const Location &loc)
{
d->resetLocation();
if ((hasCapability(OperateByInstructionCapability) &&
boolSetting(OperateByInstruction)) || !loc.hasDebugInfo()) {
if (loc.canBeDisassembled()
&& ((hasCapability(OperateByInstructionCapability) && boolSetting(OperateByInstruction))
|| !loc.hasDebugInfo()) )
{
d->m_disassemblerAgent.setLocation(loc);
return;
}
// CDB might hit on breakpoints while shutting down.
//if (m_shuttingDown)
// return;
if (loc.fileName().isEmpty()) {
showMessage(QLatin1String("CANNOT GO TO THIS LOCATION"));
return;
}
const QString file = QDir::cleanPath(loc.fileName());
const int line = loc.lineNumber();
bool newEditor = false;
......
......@@ -103,6 +103,8 @@ public:
bool needsRaise() const { return m_needsRaise; }
bool needsMarker() const { return m_needsMarker; }
bool hasDebugInfo() const { return m_hasDebugInfo; }
bool canBeDisassembled() const
{ return m_address != quint64(-1) || !m_functionName.isEmpty(); }
quint64 address() const { return m_address; }
private:
......
......@@ -362,9 +362,15 @@ void LldbEngine::setupInferior()
void LldbEngine::runEngine()
{
const DebuggerStartParameters &sp = startParameters();
QTC_ASSERT(state() == EngineRunRequested, qDebug() << state(); return);
showStatusMessage(tr("Running requested..."), 5000);
runCommand("runEngine");
DebuggerCommand cmd("runEngine");
if (sp.startMode == AttachCore) {
cmd.arg("coreFile", sp.coreFile);
cmd.arg("continuation", "updateAll");
}
runCommand(cmd);
}
void LldbEngine::interruptInferior()
......@@ -475,9 +481,11 @@ void LldbEngine::handleContinuation(const GdbMi &data)
{
if (data.data() == "updateLocals") {
updateLocals();
return;
} else if (data.data() == "updateAll") {
updateAll();
} else {
QTC_ASSERT(false, qDebug() << "Unknown continuation: " << data.data());
}
QTC_ASSERT(false, qDebug() << "Unknown continuation: " << data.data());
}
void LldbEngine::showFullBacktrace(const GdbMi &data)
......@@ -1122,6 +1130,8 @@ void LldbEngine::refreshState(const GdbMi &reportedState)
notifyEngineRunAndInferiorRunOk();
} else if (newState == "enginerunandinferiorstopok")
notifyEngineRunAndInferiorStopOk();
else if (newState == "enginerunokandinferiorunrunnable")
notifyEngineRunOkAndInferiorUnrunnable();
else if (newState == "inferiorshutdownok")
notifyInferiorShutdownOk();
else if (newState == "inferiorshutdownfailed")
......
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