Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(921)

Side by Side Diff: src/inspector/wasm-translation.h

Issue 2493773003: [inspector] Introduce translation of wasm frames (Closed)
Patch Set: Fix last patch Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef V8_INSPECTOR_WASMTRANSLATION_H_
6 #define V8_INSPECTOR_WASMTRANSLATION_H_
7
8 #include <unordered_map>
9
10 #include "include/v8.h"
11 #include "src/base/macros.h"
12 #include "src/inspector/string-16.h"
13
14 namespace v8_inspector {
15
16 // Forward declarations.
17 class V8DebuggerAgentImpl;
18 class V8DebuggerScript;
19 struct ScriptBreakpoint;
20 namespace protocol {
21 namespace Debugger {
22 class Location;
23 }
24 }
25
26 class WasmTranslation {
27 public:
28 enum Mode { Raw, Disassemble };
29
30 WasmTranslation(v8::Isolate* isolate, V8DebuggerAgentImpl* debugger);
31 ~WasmTranslation();
32
33 // Set translation mode.
34 void SetMode(Mode mode) { mode_ = mode; }
35
36 // Make a wasm script known to the translation. Only locations referencing a
37 // registered script will be translated by the Translate functions below.
38 void AddScript(v8::Local<v8::Object> script_wrapper);
39
40 // Clear all registered scripts.
41 void Clear();
42
43 // Translate a location as generated by V8 to a location that should be sent
44 // over protocol.
45 // Does nothing for locations referencing a script which was not registered
46 // before via AddScript.
47 // Line and column are 0-based.
48 // If the script was registered and the respective wasm function was not seen
49 // before, a new artificial script representing this function will be created
50 // and made public to the frontend.
51 // Returns true if the location was translated, false otherwise.
52 bool TranslateWasmScriptLocationToProtocolLocation(String16* script_id,
53 int* line_number,
54 int* column_number);
55
56 // Translate back from protocol locations (potentially referencing artificial
57 // scripts for individual wasm functions) to locations that make sense to V8.
58 // Does nothing if the location was not generated by the translate method
59 // above.
60 // Returns true if the location was translated, false otherwise.
61 bool TranslateProtocolLocationToWasmScriptLocation(String16* script_id,
62 int* line_number,
63 int* column_number);
64
65 private:
66 class TranslatorImpl;
67 friend class TranslatorImpl;
68
69 void AddFakeScript(std::unique_ptr<V8DebuggerScript> fake_script,
70 TranslatorImpl* translator);
71
72 v8::Isolate* isolate_;
73 V8DebuggerAgentImpl* debugger_agent_;
74 std::unordered_map<int, std::unique_ptr<TranslatorImpl>> wasm_translators_;
75 std::unordered_map<String16, TranslatorImpl*> fake_scripts_;
76 Mode mode_;
77 DISALLOW_COPY_AND_ASSIGN(WasmTranslation);
78 };
79
80 } // namespace v8_inspector
81
82 #endif // V8_INSPECTOR_WASMTRANSLATION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698