Debugger: Fix race condition.
- For the functionality added to address #10283, we need to wait until we receive the Team listener's thread state change notification before submitting the report generation request, else the thread might not actually be stopped yet when the generator walks the thread list. Should fix some lingering issues with stack traces sometimes not being returned when using this mode of operation.
This commit is contained in:
@@ -226,11 +226,26 @@ CommandLineUserInterface::Run()
|
||||
fReportTargetThread);
|
||||
args.Parse(buffer, &parseErrorLocation);
|
||||
_ExecuteCommand(args.ArgumentCount(), args.Arguments());
|
||||
} else
|
||||
_SubmitSaveReport();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CommandLineUserInterface::ThreadStateChanged(const Team::ThreadEvent& event)
|
||||
{
|
||||
if (fSaveReport) {
|
||||
Thread* thread = event.GetThread();
|
||||
// If we were asked to attach/report on a specific thread
|
||||
// rather than a team, and said thread was still
|
||||
// running, when we attached, we need to wait for its corresponding
|
||||
// stop state before generating a report, else we might not get its
|
||||
// stack trace.
|
||||
if (thread->ID() == fReportTargetThread
|
||||
&& thread->State() == THREAD_STATE_STOPPED) {
|
||||
_SubmitSaveReport();
|
||||
}
|
||||
snprintf(buffer, sizeof(buffer), "save-report %s",
|
||||
fReportPath != NULL ? fReportPath : "");
|
||||
args.Parse(buffer, &parseErrorLocation);
|
||||
_ExecuteCommand(args.ArgumentCount(), args.Arguments());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -465,3 +480,16 @@ CommandLineUserInterface::_ReportTargetThreadStopNeeded() const
|
||||
|
||||
return thread->State() != THREAD_STATE_STOPPED;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CommandLineUserInterface::_SubmitSaveReport()
|
||||
{
|
||||
ArgumentVector args;
|
||||
char buffer[256];
|
||||
const char* parseErrorLocation;
|
||||
snprintf(buffer, sizeof(buffer), "save-report %s",
|
||||
fReportPath != NULL ? fReportPath : "");
|
||||
args.Parse(buffer, &parseErrorLocation);
|
||||
_ExecuteCommand(args.ArgumentCount(), args.Arguments());
|
||||
}
|
||||
|
||||
@@ -50,6 +50,8 @@ public:
|
||||
// input loop.
|
||||
|
||||
// Team::Listener
|
||||
virtual void ThreadStateChanged(
|
||||
const Team::ThreadEvent& event);
|
||||
virtual void DebugReportChanged(
|
||||
const Team::DebugReportEvent& event);
|
||||
|
||||
@@ -78,6 +80,7 @@ private:
|
||||
const CommandEntry* command2);
|
||||
|
||||
bool _ReportTargetThreadStopNeeded() const;
|
||||
void _SubmitSaveReport();
|
||||
|
||||
private:
|
||||
CliContext fContext;
|
||||
|
||||
Reference in New Issue
Block a user