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