blob: d54f43c847eaf134e2ddae807a651ccae86e806c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
// Copyright 2020 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_TOOLS_V8WINDBG_SRC_V8WINDBG_EXTENSION_H_
#define V8_TOOLS_V8WINDBG_SRC_V8WINDBG_EXTENSION_H_
#include <memory>
#include <unordered_map>
#include <vector>
#include "tools/v8windbg/base/utilities.h"
// Responsible for initializing and uninitializing the extension. Also provides
// various convenience functions.
class Extension {
public:
Extension();
HRESULT Initialize();
~Extension();
WRL::ComPtr<IDebugHostModule> GetV8Module(
WRL::ComPtr<IDebugHostContext>& sp_ctx);
WRL::ComPtr<IDebugHostType> GetTypeFromV8Module(
WRL::ComPtr<IDebugHostContext>& sp_ctx, const char16_t* type_name);
WRL::ComPtr<IDebugHostType> GetV8ObjectType(
WRL::ComPtr<IDebugHostContext>& sp_ctx);
void TryRegisterType(WRL::ComPtr<IDebugHostType>& sp_type,
std::u16string type_name);
bool DoesTypeDeriveFromObject(const WRL::ComPtr<IDebugHostType>& sp_type);
static Extension* Current() { return current_extension_.get(); }
static void SetExtension(std::unique_ptr<Extension> new_extension) {
current_extension_ = std::move(new_extension);
}
// Returns the parent model for instances of v8::internal::Object and similar
// classes, which contain as their first and only field a tagged V8 value.
IModelObject* GetObjectDataModel() { return sp_object_data_model_.Get(); }
// Returns the parent model that provides indexing support for fields that
// contain arrays of something more complicated than basic native types.
IModelObject* GetIndexedFieldDataModel() {
return sp_indexed_field_model_.Get();
}
private:
HRESULT OverrideLocalsGetter(IModelObject* parent, const wchar_t* key_name,
bool is_parameters);
// A property that has been overridden by this extension. The original value
// must be put back in place during ~Extension.
struct PropertyOverride {
PropertyOverride();
PropertyOverride(IModelObject* parent, std::u16string key_name,
IModelObject* original_value,
IKeyStore* original_metadata);
~PropertyOverride();
PropertyOverride(const PropertyOverride&);
PropertyOverride& operator=(const PropertyOverride&);
WRL::ComPtr<IModelObject> parent;
std::u16string key_name;
WRL::ComPtr<IModelObject> original_value;
WRL::ComPtr<IKeyStore> original_metadata;
};
static std::unique_ptr<Extension> current_extension_;
WRL::ComPtr<IModelObject> sp_object_data_model_;
WRL::ComPtr<IModelObject> sp_local_data_model_;
WRL::ComPtr<IModelObject> sp_indexed_field_model_;
WRL::ComPtr<IDebugHostModule> sp_v8_module_;
std::unordered_map<std::u16string, WRL::ComPtr<IDebugHostType>>
cached_v8_module_types_;
std::vector<WRL::ComPtr<IDebugHostTypeSignature>> registered_object_types_;
std::vector<WRL::ComPtr<IDebugHostTypeSignature>> registered_handle_types_;
std::vector<PropertyOverride> overridden_properties_;
WRL::ComPtr<IDebugHostContext> sp_v8_module_ctx_;
ULONG v8_module_proc_id_;
};
#endif // V8_TOOLS_V8WINDBG_SRC_V8WINDBG_EXTENSION_H_
|