Skip to content

Commit

Permalink
fixup! src: fix context inpection for V8 6.8
Browse files Browse the repository at this point in the history
  • Loading branch information
Matheus Marchini committed Jul 27, 2018
1 parent fa125ea commit e716e29
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions src/llv8.cc
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ std::string JSFunction::Inspect(InspectOptions* options, Error& err) {
std::string context_str = context.Inspect(err);
if (err.Fail()) return std::string();

if (!context_str.empty()) res += "{\n" + context_str + "}";
if (!context_str.empty()) res += ":" + context_str;

if (options->print_source) {
SharedFunctionInfo info = Info(err);
Expand Down Expand Up @@ -1061,11 +1061,12 @@ HeapObject Context::GetScopeInfo(Error& err) {
}

std::string Context::Inspect(Error& err) {
std::string res;
// Not enough postmortem information, return bare minimum
if (v8()->shared_info()->kScopeInfoOffset == -1 &&
v8()->shared_info()->kNameOrScopeInfoOffset == -1)
return res;
return std::string();

std::string res = "<Context: {\n";

Value previous = Previous(err);
if (err.Fail()) return std::string();
Expand All @@ -1088,14 +1089,13 @@ std::string Context::Inspect(Error& err) {
if (heap_previous.Check()) {
char tmp[128];
snprintf(tmp, sizeof(tmp), " (previous)=0x%016" PRIx64, previous.raw());
res += tmp;
res += std::string(tmp) + ":<Context>,";
}

if (!res.empty()) res += "\n";

if (v8()->context()->kClosureIndex != -1) {
JSFunction closure;
closure = Closure(err);
JSFunction closure = Closure(err);
if (err.Fail()) return std::string();
char tmp[128];
snprintf(tmp, sizeof(tmp), " (closure)=0x%016" PRIx64 " {",
Expand All @@ -1105,6 +1105,21 @@ std::string Context::Inspect(Error& err) {
InspectOptions options;
res += closure.Inspect(&options, err) + "}";
if (err.Fail()) return std::string();
} else {
char tmp[128];
snprintf(tmp, sizeof(tmp), " (scope_info)=0x%016" PRIx64,
scope.raw());

res += std::string(tmp) + ":<ScopeInfo";

Error function_name_error;
HeapObject maybe_function_name = scope.MaybeFunctionName(function_name_error);

if (function_name_error.Success()) {
res += ": for function " + String(maybe_function_name).ToString(err);
}

res += ">";
}

int param_count = param_count_smi.GetValue();
Expand All @@ -1126,7 +1141,7 @@ std::string Context::Inspect(Error& err) {
if (err.Fail()) return std::string();
}

return res;
return res + " }>";
}


Expand Down

0 comments on commit e716e29

Please sign in to comment.