Reviewers: mvstanton,

Description:
Debugger: consistently ignore native and extension scripts for debugging.

[email protected]

Please review this at https://codereview.chromium.org/1216193002/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+19, -11 lines):
  M src/debug.cc
  M src/isolate.cc
  M src/objects.h
  M src/objects-inl.h
  M src/runtime/runtime-debug.cc


Index: src/debug.cc
diff --git a/src/debug.cc b/src/debug.cc
index d62586a2e5c7a796135ac3e44ba25f855510e529..b1c52230eeef1397ba6f810c4e4ac84ccfb085a0 100644
--- a/src/debug.cc
+++ b/src/debug.cc
@@ -1083,8 +1083,8 @@ void Debug::ClearAllBreakPoints() {

 void Debug::FloodWithOneShot(Handle<JSFunction> function,
                              BreakLocatorType type) {
-  // Do not ever break in native functions.
-  if (function->IsFromNativeScript()) return;
+  // Do not ever break in native and extension functions.
+  if (!function->IsSubjectToDebugging()) return;

   PrepareForBreakPoints();

@@ -1109,7 +1109,7 @@ void Debug::FloodBoundFunctionWithOneShot(Handle<JSFunction> function) {
                         isolate_);

   if (!bindee.is_null() && bindee->IsJSFunction() &&
-      !JSFunction::cast(*bindee)->IsFromNativeScript()) {
+      JSFunction::cast(*bindee)->IsSubjectToDebugging()) {
     Handle<JSFunction> bindee_function(JSFunction::cast(*bindee));
     FloodWithOneShotGeneric(bindee_function);
   }
@@ -1307,9 +1307,9 @@ void Debug::PrepareStep(StepAction step_action,
       DCHECK(location.IsExit());
       frames_it.Advance();
     }
-    // Skip builtin functions on the stack.
+    // Skip native and extension functions on the stack.
     while (!frames_it.done() &&
-           frames_it.frame()->function()->IsFromNativeScript()) {
+           !frames_it.frame()->function()->IsSubjectToDebugging()) {
       frames_it.Advance();
     }
     // Step out: If there is a JavaScript caller frame, we need to
Index: src/isolate.cc
diff --git a/src/isolate.cc b/src/isolate.cc
index f3d047f0a484dc9f1eb09f74d2d56f1755885d9e..e9d526a4538925d3cb146814a2be7ed6a72621a7 100644
--- a/src/isolate.cc
+++ b/src/isolate.cc
@@ -320,7 +320,7 @@ static bool IsVisibleInStackTrace(JSFunction* fun,
     if (receiver->IsJSBuiltinsObject()) return false;
     if (fun->IsBuiltin()) {
       return fun->shared()->native();
-    } else if (fun->IsFromNativeScript() || fun->IsFromExtensionScript()) {
+    } else if (!fun->IsSubjectToDebugging()) {
       return false;
     }
   }
@@ -1324,7 +1324,7 @@ bool Isolate::ComputeLocationFromStackTrace(MessageLocation* target,
   for (int i = 1; i < elements_limit; i += 4) {
     Handle<JSFunction> fun =
         handle(JSFunction::cast(elements->get(i + 1)), this);
-    if (fun->IsFromNativeScript()) continue;
+    if (!fun->IsSubjectToDebugging()) continue;

     Object* script = fun->shared()->script();
     if (script->IsScript() &&
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index 1e40ac5d9c12f6b253f75530812d4f4bc41573ea..4f15846f62b1d88c652a5c96d064586666ad36bd 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -5606,6 +5606,11 @@ bool JSFunction::IsFromExtensionScript() {
 }


+bool JSFunction::IsSubjectToDebugging() {
+  return !IsFromNativeScript() && !IsFromExtensionScript();
+}
+
+
 bool JSFunction::NeedsArgumentsAdaption() {
   return shared()->internal_formal_parameter_count() !=
          SharedFunctionInfo::kDontAdaptArgumentsSentinel;
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index 70e219390964376ad583cc952b9d61d87fe6a58b..7f42ce6f601353c1a28bdf8976995cab8c459776 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -7284,6 +7284,9 @@ class JSFunction: public JSObject {
   // Tells whether this function is defined in an extension script.
   inline bool IsFromExtensionScript();

+  // Tells whether this function should be subject to debugging.
+  inline bool IsSubjectToDebugging();
+
   // Tells whether or not the function needs arguments adaption.
   inline bool NeedsArgumentsAdaption();

Index: src/runtime/runtime-debug.cc
diff --git a/src/runtime/runtime-debug.cc b/src/runtime/runtime-debug.cc
index 8ddc494428f9726df604c0c4808e5666b1cf6c28..b72bb3e9dbfbd3884a954949ad85b6bbb48462d3 100644
--- a/src/runtime/runtime-debug.cc
+++ b/src/runtime/runtime-debug.cc
@@ -457,8 +457,8 @@ RUNTIME_FUNCTION(Runtime_GetFrameCount) {
     List<FrameSummary> frames(FLAG_max_inlining_levels + 1);
     it.frame()->Summarize(&frames);
     for (int i = frames.length() - 1; i >= 0; i--) {
-      // Omit functions from native scripts.
-      if (!frames[i].function()->IsFromNativeScript()) n++;
+      // Omit functions from native and extension scripts.
+      if (frames[i].function()->IsSubjectToDebugging()) n++;
     }
   }
   return Smi::FromInt(n);
@@ -583,8 +583,8 @@ int Runtime::FindIndexedNonNativeFrame(JavaScriptFrameIterator* it, int index) {
     List<FrameSummary> frames(FLAG_max_inlining_levels + 1);
     it->frame()->Summarize(&frames);
     for (int i = frames.length() - 1; i >= 0; i--) {
-      // Omit functions from native scripts.
-      if (frames[i].function()->IsFromNativeScript()) continue;
+      // Omit functions from native and extension scripts.
+      if (!frames[i].function()->IsSubjectToDebugging()) continue;
       if (++count == index) return i;
     }
   }


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to