BPred: Add new trace flag 'TestBPred' to isolate an incorrect update problem.

diff --git a/src/cpu/o3/SConscript b/src/cpu/o3/SConscript
--- a/src/cpu/o3/SConscript
+++ b/src/cpu/o3/SConscript
@@ -72,6 +72,7 @@
     TraceFlag('Rename')
     TraceFlag('Scoreboard')
     TraceFlag('StoreSet')
+    TraceFlag('TestBPred')
     TraceFlag('Writeback')
 
     CompoundFlag('O3CPUAll', [ 'Fetch', 'Decode', 'Rename', 'IEW', 'Commit',
diff --git a/src/cpu/o3/bpred_unit_impl.hh b/src/cpu/o3/bpred_unit_impl.hh
--- a/src/cpu/o3/bpred_unit_impl.hh
+++ b/src/cpu/o3/bpred_unit_impl.hh
@@ -182,6 +182,8 @@
     PredictorHistory predict_record(inst->seqNum, PC, pred_taken,
                                     bp_history, tid);
 
+    bool initial_pred_taken = pred_taken;
+
     // Now lookup in the BTB or RAS.
     if (pred_taken) {
         if (inst->isReturn()) {
@@ -249,6 +251,10 @@
     DPRINTF(Fetch, "BranchPred: [tid:%i]: [sn:%i]: History entry added."
             "predHist.size(): %i\n", tid, inst->seqNum, predHist[tid].size());
 
+    DPRINTF(TestBPred, "First predicted %#x %staken, now %staken target %#x\n",
+            inst->readPC(), initial_pred_taken ? "" : "not ",
+            pred_taken ? "" : "not ", target);
+
     return pred_taken;
 }
 
@@ -261,6 +267,9 @@
 
     while (!predHist[tid].empty() &&
            predHist[tid].back().seqNum <= done_sn) {
+        DPRINTF(TestBPred, "Updating bpred for insn %#x as %staken\n",
+                predHist[tid].back().PC,
+                predHist[tid].back().predTaken ? "" : "not ");
         // Update the branch predictor with the correct results.
         BPUpdate(predHist[tid].back().PC,
                  predHist[tid].back().predTaken,
@@ -299,6 +308,8 @@
 
         DPRINTF(Fetch, "BranchPred: [tid:%i]: Removing history for [sn:%i] "
                 "PC %#x.\n", tid, pred_hist.front().seqNum, pred_hist.front().PC);
+        DPRINTF(TestBPred, "Squashing prediction for %#x\n",
+                pred_hist.front().PC);
 
         pred_hist.pop_front();
 
diff --git a/src/cpu/o3/commit_impl.hh b/src/cpu/o3/commit_impl.hh
--- a/src/cpu/o3/commit_impl.hh
+++ b/src/cpu/o3/commit_impl.hh
@@ -897,6 +897,7 @@
 
             if (commit_success) {
                 ++num_committed;
+                DPRINTF(TestBPred, "Committed %#x\n", head_inst->readPC());
 
                 changedROBNumEntries[tid] = true;
 
