Bug 1516578 Part 2 - Add ToString methods for breakpoint positions and execution points, r=lsmyth.
authorBrian Hackett <bhackett1024@gmail.com>
Thu, 27 Dec 2018 13:27:58 -1000
changeset 510801 a42a0f3a48744666791f1827c7f57488cec85fa9
parent 510800 e2af5f75beaf4ec851514352d62ff6f4b8a1d037
child 510802 a2018dda265485061f8df13f14ee856af7613f95
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslsmyth
bugs1516578
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1516578 Part 2 - Add ToString methods for breakpoint positions and execution points, r=lsmyth.
toolkit/recordreplay/ipc/ChildNavigation.cpp
toolkit/recordreplay/ipc/JSControl.cpp
toolkit/recordreplay/ipc/JSControl.h
--- a/toolkit/recordreplay/ipc/ChildNavigation.cpp
+++ b/toolkit/recordreplay/ipc/ChildNavigation.cpp
@@ -10,33 +10,16 @@
 
 namespace mozilla {
 namespace recordreplay {
 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
 ///////////////////////////////////////////////////////////////////////////////
 
 // The navigation state of a recording/replaying process describes where the
 // process currently is and what it is doing in order to respond to messages
 // from the middleman process.
 //
@@ -227,20 +210,20 @@ class ReachBreakpointPhase final : publi
 
  public:
   void Enter(const CheckpointId& aStart, bool aRewind,
              const ExecutionPoint& aPoint,
              const Maybe<ExecutionPoint>& aTemporaryCheckpoint);
 
   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);
     }
   }
 
   void AfterCheckpoint(const CheckpointId& aCheckpoint) override;
   void PositionHit(const ExecutionPoint& aPoint) override;
 };
 
 // Phase when the replaying process is searching forward from a checkpoint to
@@ -776,17 +759,17 @@ void ForwardPhase::PositionHit(const Exe
 
   if (hitBreakpoint) {
     gNavigation->mPausedPhase.Enter(aPoint);
   }
 }
 
 void ForwardPhase::HitRecordingEndpoint(const ExecutionPoint& aPoint) {
   nsAutoCString str;
-  ExecutionPointToString(aPoint, str);
+  aPoint.ToString(str);
 
   gNavigation->mPausedPhase.Enter(aPoint, /* aRewind = */ false,
                                   /* aRecordingEndpoint = */ true);
 }
 
 ///////////////////////////////////////////////////////////////////////////////
 // ReachBreakpointPhase
 ///////////////////////////////////////////////////////////////////////////////
--- a/toolkit/recordreplay/ipc/JSControl.cpp
+++ b/toolkit/recordreplay/ipc/JSControl.cpp
@@ -101,17 +101,17 @@ JSObject* BreakpointPosition::Encode(JSC
 }
 
 bool BreakpointPosition::Decode(JSContext* aCx, HandleObject aObject) {
   RootedValue v(aCx);
   if (!JS_GetProperty(aCx, aObject, gKindProperty, &v)) {
     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;
     bool match;
     if (!JS_StringEqualsAscii(
             aCx, str, BreakpointPosition::StaticKindString(kind), &match))
       return false;
     if (match) {
@@ -129,16 +129,23 @@ bool BreakpointPosition::Decode(JSContex
       !MaybeGetNumberProperty(aCx, aObject, gFrameIndexProperty,
                               &mFrameIndex)) {
     return false;
   }
 
   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
 ///////////////////////////////////////////////////////////////////////////////
 
 // Names of properties which JS code uses to specify the contents of an
 // ExecutionPoint.
 static const char gCheckpointProperty[] = "checkpoint";
 static const char gProgressProperty[] = "progress";
@@ -166,16 +173,27 @@ bool ExecutionPoint::Decode(JSContext* a
   }
 
   RootedObject positionObject(aCx, NonNullObject(aCx, v));
   return positionObject && mPosition.Decode(aCx, positionObject) &&
          GetNumberProperty(aCx, aObject, gCheckpointProperty, &mCheckpoint) &&
          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
 ///////////////////////////////////////////////////////////////////////////////
 
 // There can be at most one replay debugger in existence.
 static PersistentRootedObject* gReplayDebugger;
 
 static bool Middleman_RegisterReplayDebugger(JSContext* aCx, unsigned aArgc,
--- a/toolkit/recordreplay/ipc/JSControl.h
+++ b/toolkit/recordreplay/ipc/JSControl.h
@@ -8,16 +8,17 @@
 #define mozilla_recordreplay_JSControl_h
 
 #include "jsapi.h"
 
 #include "InfallibleVector.h"
 #include "ProcessRewind.h"
 
 #include "mozilla/DefineEnum.h"
+#include "nsString.h"
 
 namespace mozilla {
 namespace recordreplay {
 namespace js {
 
 // This file manages interactions between the record/replay infrastructure and
 // JS code. This interaction can occur in two ways:
 //
@@ -130,16 +131,17 @@ struct BreakpointPosition {
     }
     MOZ_CRASH("Bad BreakpointPosition kind");
   }
 
   const char* KindString() const { return StaticKindString(mKind); }
 
   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
 // pause and be inspected by the middleman. A particular execution point will
 // be reached exactly once during the execution of the process.
 struct ExecutionPoint {
   // ID of the last normal checkpoint prior to this point.
   size_t mCheckpoint;
@@ -177,16 +179,17 @@ struct ExecutionPoint {
   }
 
   inline bool operator!=(const ExecutionPoint& o) const {
     return !(*this == o);
   }
 
   JSObject* Encode(JSContext* aCx) const;
   bool Decode(JSContext* aCx, JS::HandleObject aObject);
+  void ToString(nsCString& aStr) const;
 };
 
 // Buffer type used for encoding object data.
 typedef InfallibleVector<char16_t> CharBuffer;
 
 // Called in the middleman when the child has hit a checkpoint or breakpoint.
 // The return value is whether there is a ReplayDebugger available which the
 // notification was sent to.