Skip to content

Commit 4be861f

Browse files
committed
[fix, WIP] Fix recording of initial event when recorder is empty.
1 parent 96f76cf commit 4be861f

4 files changed

Lines changed: 13 additions & 5 deletions

File tree

lib/Core/EventRecorder.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ bool EventRecorder::empty() const { return events.empty(); }
7878
ref<CodeEvent> EventRecorder::last() const { return events.back(); }
7979

8080
EventRecorder EventRecorder::tail(const Path::PathIndex &begin) const {
81-
assert(!events.empty());
81+
if (events.empty()) {
82+
return EventRecorder();
83+
}
8284
return inRange(begin, events.back()->location->pathIndex);
8385
}

lib/Core/ExecutionState.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,8 @@ class ExecutionState {
330330
/// @brief Constraints collected so far
331331
PathConstraints constraints;
332332

333-
// TODO: union into history object
333+
/// @brief Storage for the source code events (e.g. changing control flow or
334+
/// errors)
334335
EventRecorder eventsRecorder;
335336

336337
/// @brief Key points which should be visited through execution

lib/Core/Executor.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5032,11 +5032,10 @@ void Executor::terminateStateOnProgramError(ExecutionState &state,
50325032

50335033
if (reason->source.has_value()) {
50345034
const ref<CodeEvent> &sourceEvent = reason->source.value();
5035-
5036-
if (!state.eventsRecorder.empty() && sourceEvent->location) {
5035+
if (sourceEvent->location) {
50375036
EventRecorder traceRecorder;
5038-
traceRecorder.record(sourceEvent);
50395037

5038+
traceRecorder.record(sourceEvent);
50405039
traceRecorder.append(
50415040
state.eventsRecorder.tail(sourceEvent->location->pathIndex));
50425041

@@ -6593,6 +6592,7 @@ void Executor::executeMemoryOperation(
65936592
uniqueBase, baseTargetType,
65946593
baseID, uniqueBaseResolved)) {
65956594
terminateStateOnSolverError(*unbound, "Query timed out (resolve)");
6595+
return;
65966596
}
65976597

65986598
if (uniqueBaseResolved) {

lib/Module/LocationInfo.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ LocationInfo getLocationInfo(const llvm::GlobalVariable *globalVar) {
104104
}
105105
}
106106

107+
// For `extern` variables return `external` file.
108+
if (globalVar->hasExternalLinkage()) {
109+
return {"external", 0, {}};
110+
}
111+
107112
// Fallback to empty location if there is no appropriate debug
108113
// info.
109114
return {"", 0, {}};

0 commit comments

Comments
 (0)