@@ -389,10 +389,15 @@ std::string JSFunction::Inspect(InspectOptions* options, Error& err) {
389389 snprintf (tmp, sizeof (tmp), " \n context=0x%016" PRIx64, context.raw ());
390390 res += tmp;
391391
392- std::string context_str = context.Inspect (err);
393- if (err.Fail ()) return std::string ();
392+ {
393+ InspectOptions ctx_options;
394+ ctx_options.detailed = true ;
395+ ctx_options.indent_depth = options->indent_depth + 1 ;
396+ std::string context_str = context.Inspect (&ctx_options, err);
397+ if (err.Fail ()) return std::string ();
394398
395- if (!context_str.empty ()) res += " :" + context_str;
399+ if (!context_str.empty ()) res += " :" + context_str;
400+ }
396401
397402 if (options->print_source ) {
398403 SharedFunctionInfo info = Info (err);
@@ -821,6 +826,12 @@ std::string HeapObject::Inspect(InspectOptions* options, Error& err) {
821826 return pre + str.Inspect (options, err);
822827 }
823828
829+ if (type >= v8 ()->types ()->kFirstContextType &&
830+ type <= v8 ()->types ()->kLastContextType ) {
831+ Context ctx (this );
832+ return pre + ctx.Inspect (options, err);
833+ }
834+
824835 if (type == v8 ()->types ()->kFixedArrayType ) {
825836 FixedArray arr (this );
826837 return pre + arr.Inspect (options, err);
@@ -1060,13 +1071,19 @@ HeapObject Context::GetScopeInfo(Error& err) {
10601071 return info.GetScopeInfo (err);
10611072}
10621073
1063- std::string Context::Inspect (Error& err) {
1074+ std::string Context::Inspect (InspectOptions* options, Error& err) {
10641075 // Not enough postmortem information, return bare minimum
10651076 if (v8 ()->shared_info ()->kScopeInfoOffset == -1 &&
10661077 v8 ()->shared_info ()->kNameOrScopeInfoOffset == -1 )
10671078 return std::string ();
10681079
1069- std::string res = " <Context: {\n " ;
1080+ std::string res = " <Context" ;
1081+
1082+ if (!options->detailed ) {
1083+ return res + " >" ;
1084+ }
1085+
1086+ res += " : {\n " ;
10701087
10711088 Value previous = Previous (err);
10721089 if (err.Fail ()) return std::string ();
@@ -1083,12 +1100,10 @@ std::string Context::Inspect(Error& err) {
10831100 Smi local_count_smi = scope.ContextLocalCount (err);
10841101 if (err.Fail ()) return std::string ();
10851102
1086- InspectOptions options;
1087-
10881103 HeapObject heap_previous = HeapObject (previous);
10891104 if (heap_previous.Check ()) {
10901105 char tmp[128 ];
1091- snprintf (tmp, sizeof (tmp), " (previous)=0x%016" PRIx64, previous.raw ());
1106+ snprintf (tmp, sizeof (tmp), (options-> get_indent_spaces () + " (previous)=0x%016" PRIx64). c_str () , previous.raw ());
10921107 res += std::string (tmp) + " :<Context>," ;
10931108 }
10941109
@@ -1098,16 +1113,16 @@ std::string Context::Inspect(Error& err) {
10981113 JSFunction closure = Closure (err);
10991114 if (err.Fail ()) return std::string ();
11001115 char tmp[128 ];
1101- snprintf (tmp, sizeof (tmp), " (closure)=0x%016" PRIx64 " {" ,
1116+ snprintf (tmp, sizeof (tmp), (options-> get_indent_spaces () + " (closure)=0x%016" PRIx64 " {" ). c_str () ,
11021117 closure.raw ());
11031118 res += tmp;
11041119
1105- InspectOptions options ;
1106- res += closure.Inspect (&options , err) + " }" ;
1120+ InspectOptions closure_options ;
1121+ res += closure.Inspect (&closure_options , err) + " }" ;
11071122 if (err.Fail ()) return std::string ();
11081123 } else {
11091124 char tmp[128 ];
1110- snprintf (tmp, sizeof (tmp), " (scope_info)=0x%016" PRIx64,
1125+ snprintf (tmp, sizeof (tmp), (options-> get_indent_spaces () + " (scope_info)=0x%016" PRIx64). c_str () ,
11111126 scope.raw ());
11121127
11131128 res += std::string (tmp) + " :<ScopeInfo" ;
@@ -1131,17 +1146,18 @@ std::string Context::Inspect(Error& err) {
11311146
11321147 if (!res.empty ()) res += " ,\n " ;
11331148
1134- res += " " + name.ToString (err) + " =" ;
1149+ res += options-> get_indent_spaces () + name.ToString (err) + " =" ;
11351150 if (err.Fail ()) return std::string ();
11361151
11371152 Value value = ContextSlot (i, err);
11381153 if (err.Fail ()) return std::string ();
11391154
1140- res += value.Inspect (&options, err);
1155+ InspectOptions val_options;
1156+ res += value.Inspect (&val_options, err);
11411157 if (err.Fail ()) return std::string ();
11421158 }
11431159
1144- return res + " }>" ;
1160+ return res + " }>" ;
11451161}
11461162
11471163
0 commit comments