Commit 49f06fb5 authored by Alexei Filippov's avatar Alexei Filippov Committed by Commit Bot

[inspector] Use random generator for isolate id

We cannot rely on base::OS::GetCurrentProcessId() as it is sandboxed.

BUG=chromium:823874

Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I6aaa7f7f7dacbc8aba43581f9d489e4cc47799ff
Reviewed-on: https://chromium-review.googlesource.com/985425Reviewed-by: 's avatarDmitry Gozman <dgozman@chromium.org>
Commit-Queue: Alexei Filippov <alph@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52303}
parent 5d15f941
......@@ -58,7 +58,8 @@ V8InspectorImpl::V8InspectorImpl(v8::Isolate* isolate,
m_debugger(new V8Debugger(isolate, this)),
m_capturingStackTracesCount(0),
m_lastExceptionId(0),
m_lastContextId(0) {
m_lastContextId(0),
m_isolateId(v8::debug::GetNextRandomInt64(m_isolate)) {
v8::debug::SetInspector(m_isolate, this);
v8::debug::SetConsoleDelegate(m_isolate, console());
}
......
......@@ -61,6 +61,7 @@ class V8InspectorImpl : public V8Inspector {
V8Debugger* debugger() { return m_debugger.get(); }
int contextGroupId(v8::Local<v8::Context>) const;
int contextGroupId(int contextId) const;
uint64_t isolateId() const { return m_isolateId; }
v8::MaybeLocal<v8::Value> compileAndRunInternalScript(v8::Local<v8::Context>,
v8::Local<v8::String>);
......@@ -128,6 +129,7 @@ class V8InspectorImpl : public V8Inspector {
unsigned m_lastExceptionId;
int m_lastContextId;
int m_lastSessionId = 0;
uint64_t m_isolateId;
using MuteExceptionsMap = protocol::HashMap<int, int>;
MuteExceptionsMap m_muteExceptionsMap;
......
......@@ -30,7 +30,8 @@
#include "src/inspector/v8-runtime-agent-impl.h"
#include "src/base/platform/platform.h"
#include <inttypes.h>
#include "src/debug/debug-interface.h"
#include "src/inspector/injected-script.h"
#include "src/inspector/inspected-context.h"
......@@ -612,8 +613,7 @@ Response V8RuntimeAgentImpl::globalLexicalScopeNames(
Response V8RuntimeAgentImpl::getIsolateId(String16* outIsolateId) {
char buf[40];
std::snprintf(buf, sizeof(buf), "%d.%p", v8::base::OS::GetCurrentProcessId(),
m_inspector->isolate());
std::snprintf(buf, sizeof(buf), "%" PRIx64, m_inspector->isolateId());
*outIsolateId = buf;
return Response::OK();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment