Skip to content

Commit

Permalink
cpu: nullptr in a DPRINTF statement
Browse files Browse the repository at this point in the history
This change fixes the crashing of gem5 when `Branch` debug flag
is enabled. A DPRINTF statement had a nullptr. This change
prints `INVALID_TARGET` if the nullptr is encountered.

Signed-off-by: Kaustav Goswami <[email protected]>
Change-Id: I40bd42c07de25a493a3dd1094a2fd8cc0ce0a79b
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/59109
Tested-by: kokoro <[email protected]>
Reviewed-by: Jason Lowe-Power <[email protected]>
Maintainer: Jason Lowe-Power <[email protected]>
  • Loading branch information
kaustav-goswami committed Apr 28, 2022
1 parent f8589a4 commit fda0759
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/cpu/pred/bpred_unit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -335,10 +335,19 @@ BPredUnit::squash(const InstSeqNum &squashed_sn, ThreadID tid)
while (!pred_hist.empty() &&
pred_hist.front().seqNum > squashed_sn) {
if (pred_hist.front().usedRAS) {
DPRINTF(Branch, "[tid:%i] [squash sn:%llu]"
" Restoring top of RAS to: %i,"
" target: %s\n", tid, squashed_sn,
pred_hist.front().RASIndex, *pred_hist.front().RASTarget);
if (pred_hist.front().RASTarget != nullptr) {
DPRINTF(Branch, "[tid:%i] [squash sn:%llu]"
" Restoring top of RAS to: %i,"
" target: %s\n", tid, squashed_sn,
pred_hist.front().RASIndex,
*pred_hist.front().RASTarget);
}
else {
DPRINTF(Branch, "[tid:%i] [squash sn:%llu]"
" Restoring top of RAS to: %i,"
" target: INVALID_TARGET\n", tid, squashed_sn,
pred_hist.front().RASIndex);
}

RAS[tid].restore(pred_hist.front().RASIndex,
pred_hist.front().RASTarget.get());
Expand Down

0 comments on commit fda0759

Please sign in to comment.