@@ -392,7 +392,7 @@ std::string JSFunction::Inspect(InspectOptions* options, Error& err) {
392392 std::string context_str = context.Inspect (err);
393393 if (err.Fail ()) return std::string ();
394394
395- if (!context_str.empty ()) res += " { \n " + context_str + " } " ;
395+ if (!context_str.empty ()) res += " : " + context_str;
396396
397397 if (options->print_source ) {
398398 SharedFunctionInfo info = Info (err);
@@ -1047,24 +1047,31 @@ std::string FixedArray::InspectContents(int length, Error& err) {
10471047 return res;
10481048}
10491049
1050+ HeapObject Context::GetScopeInfo (Error& err) {
1051+ if (v8 ()->context ()->kScopeInfoIndex != -1 ) {
1052+ return FixedArray::Get<HeapObject>(v8 ()->context ()->kScopeInfoIndex , err);
1053+ }
1054+ JSFunction closure = Closure (err);
1055+ if (err.Fail ()) return HeapObject ();
1056+
1057+ SharedFunctionInfo info = closure.Info (err);
1058+ if (err.Fail ()) return HeapObject ();
1059+
1060+ return info.GetScopeInfo (err);
1061+ }
10501062
10511063std::string Context::Inspect (Error& err) {
1052- std::string res;
10531064 // Not enough postmortem information, return bare minimum
10541065 if (v8 ()->shared_info ()->kScopeInfoOffset == -1 &&
10551066 v8 ()->shared_info ()->kNameOrScopeInfoOffset == -1 )
1056- return res ;
1067+ return std::string () ;
10571068
1058- Value previous = Previous (err);
1059- if (err.Fail ()) return std::string ();
1069+ std::string res = " <Context: {\n " ;
10601070
1061- JSFunction closure = Closure (err);
1062- if (err.Fail ()) return std::string ();
1063-
1064- SharedFunctionInfo info = closure.Info (err);
1071+ Value previous = Previous (err);
10651072 if (err.Fail ()) return std::string ();
10661073
1067- HeapObject scope_obj = info. GetScopeInfo (err);
1074+ HeapObject scope_obj = GetScopeInfo (err);
10681075 if (err.Fail ()) return std::string ();
10691076
10701077 ScopeInfo scope (scope_obj);
@@ -1082,11 +1089,14 @@ std::string Context::Inspect(Error& err) {
10821089 if (heap_previous.Check ()) {
10831090 char tmp[128 ];
10841091 snprintf (tmp, sizeof (tmp), " (previous)=0x%016" PRIx64, previous.raw ());
1085- res += tmp;
1092+ res += std::string ( tmp) + " :<Context>, " ;
10861093 }
10871094
10881095 if (!res.empty ()) res += " \n " ;
1089- {
1096+
1097+ if (v8 ()->context ()->hasClosure ()) {
1098+ JSFunction closure = Closure (err);
1099+ if (err.Fail ()) return std::string ();
10901100 char tmp[128 ];
10911101 snprintf (tmp, sizeof (tmp), " (closure)=0x%016" PRIx64 " {" ,
10921102 closure.raw ());
@@ -1095,6 +1105,21 @@ std::string Context::Inspect(Error& err) {
10951105 InspectOptions options;
10961106 res += closure.Inspect (&options, err) + " }" ;
10971107 if (err.Fail ()) return std::string ();
1108+ } else {
1109+ char tmp[128 ];
1110+ snprintf (tmp, sizeof (tmp), " (scope_info)=0x%016" PRIx64,
1111+ scope.raw ());
1112+
1113+ res += std::string (tmp) + " :<ScopeInfo" ;
1114+
1115+ Error function_name_error;
1116+ HeapObject maybe_function_name = scope.MaybeFunctionName (function_name_error);
1117+
1118+ if (function_name_error.Success ()) {
1119+ res += " : for function " + String (maybe_function_name).ToString (err);
1120+ }
1121+
1122+ res += " >" ;
10981123 }
10991124
11001125 int param_count = param_count_smi.GetValue ();
@@ -1116,7 +1141,7 @@ std::string Context::Inspect(Error& err) {
11161141 if (err.Fail ()) return std::string ();
11171142 }
11181143
1119- return res;
1144+ return res + " }> " ;
11201145}
11211146
11221147
0 commit comments