From d3d0015ff002800b4e6393ab71f0391ff165db5e Mon Sep 17 00:00:00 2001 From: Brian Hackett Date: Thu, 27 Dec 2018 13:27:58 -1000 Subject: [PATCH] Bug 1516578 Part 2 - Add ToString methods for breakpoint positions and execution points, r=lsmyth. --HG-- extra : rebase_source : 4f0d872e618da7fc109074e25ad665f21848b5ba extra : source : 0426a61d27a9c9c047b4d489e4a2586b4c7a6491 --- toolkit/recordreplay/ipc/ChildNavigation.cpp | 23 +++----------------- toolkit/recordreplay/ipc/JSControl.cpp | 20 ++++++++++++++++- toolkit/recordreplay/ipc/JSControl.h | 3 +++ 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/toolkit/recordreplay/ipc/ChildNavigation.cpp b/toolkit/recordreplay/ipc/ChildNavigation.cpp index deb95f995439..2f46ae1f04ed 100644 --- a/toolkit/recordreplay/ipc/ChildNavigation.cpp +++ b/toolkit/recordreplay/ipc/ChildNavigation.cpp @@ -15,23 +15,6 @@ namespace navigation { typedef js::BreakpointPosition BreakpointPosition; typedef js::ExecutionPoint ExecutionPoint; -static void BreakpointPositionToString(const BreakpointPosition& aPos, - nsAutoCString& aStr) { - aStr.AppendPrintf("{ Kind: %s, Script: %d, Offset: %d, Frame: %d }", - aPos.KindString(), (int)aPos.mScript, (int)aPos.mOffset, - (int)aPos.mFrameIndex); -} - -static void ExecutionPointToString(const ExecutionPoint& aPoint, - nsAutoCString& aStr) { - aStr.AppendPrintf("{ Checkpoint %d", (int)aPoint.mCheckpoint); - if (aPoint.HasPosition()) { - aStr.AppendPrintf(" Progress %llu Position ", aPoint.mProgress); - BreakpointPositionToString(aPoint.mPosition, aStr); - } - aStr.AppendPrintf(" }"); -} - /////////////////////////////////////////////////////////////////////////////// // Navigation State /////////////////////////////////////////////////////////////////////////////// @@ -232,10 +215,10 @@ class ReachBreakpointPhase final : public NavigationPhase { void ToString(nsAutoCString& aStr) override { aStr.AppendPrintf("ReachBreakpoint: "); - ExecutionPointToString(mPoint, aStr); + mPoint.ToString(aStr); if (mTemporaryCheckpoint.isSome()) { aStr.AppendPrintf(" TemporaryCheckpoint: "); - ExecutionPointToString(mTemporaryCheckpoint.ref(), aStr); + mTemporaryCheckpoint.ref().ToString(aStr); } } @@ -781,7 +764,7 @@ void ForwardPhase::PositionHit(const ExecutionPoint& aPoint) { void ForwardPhase::HitRecordingEndpoint(const ExecutionPoint& aPoint) { nsAutoCString str; - ExecutionPointToString(aPoint, str); + aPoint.ToString(str); gNavigation->mPausedPhase.Enter(aPoint, /* aRewind = */ false, /* aRecordingEndpoint = */ true); diff --git a/toolkit/recordreplay/ipc/JSControl.cpp b/toolkit/recordreplay/ipc/JSControl.cpp index bd2735ab384a..60118e0801bd 100644 --- a/toolkit/recordreplay/ipc/JSControl.cpp +++ b/toolkit/recordreplay/ipc/JSControl.cpp @@ -106,7 +106,7 @@ bool BreakpointPosition::Decode(JSContext* aCx, HandleObject aObject) { return false; } - RootedString str(aCx, ToString(aCx, v)); + RootedString str(aCx, ::ToString(aCx, v)); for (size_t i = BreakpointPosition::Invalid + 1; i < BreakpointPosition::sKindCount; i++) { BreakpointPosition::Kind kind = (BreakpointPosition::Kind)i; @@ -134,6 +134,13 @@ bool BreakpointPosition::Decode(JSContext* aCx, HandleObject aObject) { return true; } +void +BreakpointPosition::ToString(nsCString& aStr) const +{ + aStr.AppendPrintf("{ Kind: %s, Script: %d, Offset: %d, Frame: %d }", + KindString(), (int) mScript, (int) mOffset, (int) mFrameIndex); +} + /////////////////////////////////////////////////////////////////////////////// // ExecutionPoint Conversion /////////////////////////////////////////////////////////////////////////////// @@ -171,6 +178,17 @@ bool ExecutionPoint::Decode(JSContext* aCx, HandleObject aObject) { GetNumberProperty(aCx, aObject, gProgressProperty, &mProgress); } +void +ExecutionPoint::ToString(nsCString& aStr) const +{ + aStr.AppendPrintf("{ Checkpoint %d", (int) mCheckpoint); + if (HasPosition()) { + aStr.AppendPrintf(" Progress %llu Position ", mProgress); + mPosition.ToString(aStr); + } + aStr.AppendPrintf(" }"); +} + /////////////////////////////////////////////////////////////////////////////// // Middleman Methods /////////////////////////////////////////////////////////////////////////////// diff --git a/toolkit/recordreplay/ipc/JSControl.h b/toolkit/recordreplay/ipc/JSControl.h index 325e960f8050..ce69766aa288 100644 --- a/toolkit/recordreplay/ipc/JSControl.h +++ b/toolkit/recordreplay/ipc/JSControl.h @@ -13,6 +13,7 @@ #include "ProcessRewind.h" #include "mozilla/DefineEnum.h" +#include "nsString.h" namespace mozilla { namespace recordreplay { @@ -135,6 +136,7 @@ struct BreakpointPosition { JSObject* Encode(JSContext* aCx) const; bool Decode(JSContext* aCx, JS::HandleObject aObject); + void ToString(nsCString& aStr) const; }; // Identification for a point in the execution of a child process where it may @@ -182,6 +184,7 @@ struct ExecutionPoint { JSObject* Encode(JSContext* aCx) const; bool Decode(JSContext* aCx, JS::HandleObject aObject); + void ToString(nsCString& aStr) const; }; // Buffer type used for encoding object data.