Commit 40657deb authored by Z Nguyen-Huu's avatar Z Nguyen-Huu Committed by Commit Bot

[v8windbg] Show bitset name of compiler type

Get value from type payload, check and show bitset name.

Change-Id: I6d0e0f30fca0b2aaddfd5f18abf948886552f2dc
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2258815
Commit-Queue: Z Nguyen-Huu <duongn@microsoft.com>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarSeth Brenith <seth.brenith@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#68495}
parent e7bd239a
...@@ -76,6 +76,7 @@ v8_component("v8_debug_helper") { ...@@ -76,6 +76,7 @@ v8_component("v8_debug_helper") {
"$target_gen_dir/../../torque-generated/class-debug-readers-tq.h", "$target_gen_dir/../../torque-generated/class-debug-readers-tq.h",
"$target_gen_dir/../../torque-generated/instance-types-tq.h", "$target_gen_dir/../../torque-generated/instance-types-tq.h",
"$target_gen_dir/heap-constants-gen.cc", "$target_gen_dir/heap-constants-gen.cc",
"compiler-types.cc",
"debug-helper-internal.cc", "debug-helper-internal.cc",
"debug-helper-internal.h", "debug-helper-internal.h",
"debug-helper.h", "debug-helper.h",
......
// 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.
#include "debug-helper-internal.h"
#include "src/compiler/types.h"
namespace ic = v8::internal::compiler;
extern "C" {
V8_DEBUG_HELPER_EXPORT const char* _v8_debug_helper_BitsetName(
uint64_t payload) {
// Check if payload is a bitset and return the bitset type.
// This line is duplicating the logic from Type::IsBitset.
bool is_bit_set = payload & 1;
if (!is_bit_set) return nullptr;
ic::BitsetType::bitset bits =
static_cast<ic::BitsetType::bitset>(payload ^ 1u);
switch (bits) {
#define RETURN_NAMED_TYPE(type, value) \
case ic::BitsetType::k##type: \
return #type;
PROPER_BITSET_TYPE_LIST(RETURN_NAMED_TYPE)
INTERNAL_BITSET_TYPE_LIST(RETURN_NAMED_TYPE)
#undef RETURN_NAMED_TYPE
default:
return nullptr;
}
}
}
...@@ -195,6 +195,8 @@ V8_DEBUG_HELPER_EXPORT void _v8_debug_helper_Free_ObjectPropertiesResult( ...@@ -195,6 +195,8 @@ V8_DEBUG_HELPER_EXPORT void _v8_debug_helper_Free_ObjectPropertiesResult(
v8::debug_helper::ObjectPropertiesResult* result); v8::debug_helper::ObjectPropertiesResult* result);
V8_DEBUG_HELPER_EXPORT const v8::debug_helper::ClassList* V8_DEBUG_HELPER_EXPORT const v8::debug_helper::ClassList*
_v8_debug_helper_ListObjectClasses(); _v8_debug_helper_ListObjectClasses();
V8_DEBUG_HELPER_EXPORT const char* _v8_debug_helper_BitsetName(
uint64_t payload);
} }
namespace v8 { namespace v8 {
...@@ -229,6 +231,12 @@ inline const ClassList* ListObjectClasses() { ...@@ -229,6 +231,12 @@ inline const ClassList* ListObjectClasses() {
return _v8_debug_helper_ListObjectClasses(); return _v8_debug_helper_ListObjectClasses();
} }
// Return a bitset name for a v8::internal::compiler::Type with payload or null
// if the payload is not a bitset.
inline const char* BitsetName(uint64_t payload) {
return _v8_debug_helper_BitsetName(payload);
}
} // namespace debug_helper } // namespace debug_helper
} // namespace v8 } // namespace v8
......
...@@ -633,6 +633,31 @@ IFACEMETHODIMP V8InternalCompilerNodeIdProperty::SetValue( ...@@ -633,6 +633,31 @@ IFACEMETHODIMP V8InternalCompilerNodeIdProperty::SetValue(
return E_NOTIMPL; return E_NOTIMPL;
} }
IFACEMETHODIMP V8InternalCompilerBitsetNameProperty::GetValue(
PCWSTR pwsz_key, IModelObject* p_v8_compiler_type_instance,
IModelObject** pp_value) noexcept {
WRL::ComPtr<IModelObject> sp_payload;
RETURN_IF_FAIL(p_v8_compiler_type_instance->GetRawValue(
SymbolKind::SymbolField, L"payload_", RawSearchNone, &sp_payload));
uint64_t payload_value;
RETURN_IF_FAIL(
UnboxULong64(sp_payload.Get(), &payload_value, true /*convert*/));
const char* bitset_name = ::BitsetName(payload_value);
if (!bitset_name) return E_FAIL;
std::string name(bitset_name);
RETURN_IF_FAIL(CreateString(ConvertToU16String(name), pp_value));
return S_OK;
}
IFACEMETHODIMP V8InternalCompilerBitsetNameProperty::SetValue(
PCWSTR /*pwsz_key*/, IModelObject* /*p_process_instance*/,
IModelObject* /*p_value*/) noexcept {
return E_NOTIMPL;
}
constexpr wchar_t usage[] = constexpr wchar_t usage[] =
LR"(Invalid arguments. LR"(Invalid arguments.
First argument should be a uint64 representing the tagged value to investigate. First argument should be a uint64 representing the tagged value to investigate.
......
...@@ -261,6 +261,22 @@ class V8InternalCompilerNodeIdProperty ...@@ -261,6 +261,22 @@ class V8InternalCompilerNodeIdProperty
IModelObject* /*p_value*/); IModelObject* /*p_value*/);
}; };
// The implemention of the "bitset_name" getter for v8::internal::compiler::Type
// type.
class V8InternalCompilerBitsetNameProperty
: public WRL::RuntimeClass<
WRL::RuntimeClassFlags<WRL::RuntimeClassType::ClassicCom>,
IModelPropertyAccessor> {
public:
IFACEMETHOD(GetValue)
(PCWSTR pwsz_key, IModelObject* p_v8_compiler_type_instance,
IModelObject** pp_value);
IFACEMETHOD(SetValue)
(PCWSTR /*pwsz_key*/, IModelObject* /*p_process_instance*/,
IModelObject* /*p_value*/);
};
// A way that someone can directly inspect a tagged value, even if that value // A way that someone can directly inspect a tagged value, even if that value
// isn't in memory (from a register, or the user's imagination, etc.). // isn't in memory (from a register, or the user's imagination, etc.).
class InspectV8ObjectMethod class InspectV8ObjectMethod
......
...@@ -155,3 +155,5 @@ std::vector<std::u16string> ListObjectClasses() { ...@@ -155,3 +155,5 @@ std::vector<std::u16string> ListObjectClasses() {
} }
return result; return result;
} }
const char* BitsetName(uint64_t payload) { return d::BitsetName(payload); }
...@@ -135,4 +135,6 @@ inline uint64_t ExpandCompressedPointer(uint32_t ptr) { return ptr; } ...@@ -135,4 +135,6 @@ inline uint64_t ExpandCompressedPointer(uint32_t ptr) { return ptr; }
std::vector<std::u16string> ListObjectClasses(); std::vector<std::u16string> ListObjectClasses();
const char* BitsetName(uint64_t payload);
#endif // V8_TOOLS_V8WINDBG_SRC_V8_DEBUG_HELPER_INTEROP_H_ #endif // V8_TOOLS_V8WINDBG_SRC_V8_DEBUG_HELPER_INTEROP_H_
...@@ -280,31 +280,45 @@ HRESULT Extension::Initialize() { ...@@ -280,31 +280,45 @@ HRESULT Extension::Initialize() {
RETURN_IF_FAIL(OverrideLocalsGetter(stack_frame.Get(), L"Parameters", RETURN_IF_FAIL(OverrideLocalsGetter(stack_frame.Get(), L"Parameters",
/*is_parameters=*/true)); /*is_parameters=*/true));
/* v8::internal::compiler::Node */ // Add node_id property for v8::internal::compiler::Node.
// Create an instance of the DataModel parent class for RETURN_IF_FAIL(
// v8::internal::compiler::Node type. RegisterAndAddPropertyForClass<V8InternalCompilerNodeIdProperty>(
auto compiler_node_data_model{WRL::Make<V8LocalDataModel>()}; L"v8::internal::compiler::Node", L"node_id",
sp_compiler_node_data_model_));
// Add bitset_name property for v8::internal::compiler::Type.
RETURN_IF_FAIL(
RegisterAndAddPropertyForClass<V8InternalCompilerBitsetNameProperty>(
L"v8::internal::compiler::Type", L"bitset_name",
sp_compiler_type_data_model_));
return S_OK;
}
template <class PropertyClass>
HRESULT Extension::RegisterAndAddPropertyForClass(
const wchar_t* class_name, const wchar_t* property_name,
WRL::ComPtr<IModelObject> sp_data_model) {
// Create an instance of the DataModel parent class.
auto instance_data_model{WRL::Make<V8LocalDataModel>()};
RETURN_IF_FAIL(sp_data_model_manager->CreateDataModelObject( RETURN_IF_FAIL(sp_data_model_manager->CreateDataModelObject(
compiler_node_data_model.Get(), &sp_compiler_node_data_model_)); instance_data_model.Get(), &sp_data_model));
// Register that parent model for v8::internal::compiler::Node. // Register that parent model.
const wchar_t* compiler_node_class_name = L"v8::internal::compiler::Node"; WRL::ComPtr<IDebugHostTypeSignature> class_signature;
WRL::ComPtr<IDebugHostTypeSignature> compiler_node_class_signature; RETURN_IF_FAIL(sp_debug_host_symbols->CreateTypeSignature(class_name, nullptr,
RETURN_IF_FAIL(sp_debug_host_symbols->CreateTypeSignature( &class_signature));
compiler_node_class_name, nullptr, &compiler_node_class_signature));
RETURN_IF_FAIL(sp_data_model_manager->RegisterModelForTypeSignature( RETURN_IF_FAIL(sp_data_model_manager->RegisterModelForTypeSignature(
compiler_node_class_signature.Get(), sp_compiler_node_data_model_.Get())); class_signature.Get(), sp_data_model.Get()));
registered_types_.push_back({compiler_node_class_signature.Get(), registered_types_.push_back({class_signature.Get(), sp_data_model.Get()});
sp_compiler_node_data_model_.Get()});
// Add the property to the parent model.
// Add the 'node_id' property to the parent model. auto property{WRL::Make<PropertyClass>()};
auto node_id_property{WRL::Make<V8InternalCompilerNodeIdProperty>()}; WRL::ComPtr<IModelObject> sp_property_model;
WRL::ComPtr<IModelObject> sp_node_id_property_model; RETURN_IF_FAIL(CreateProperty(sp_data_model_manager.Get(), property.Get(),
RETURN_IF_FAIL(CreateProperty(sp_data_model_manager.Get(), &sp_property_model));
node_id_property.Get(), RETURN_IF_FAIL(
&sp_node_id_property_model)); sp_data_model->SetKey(property_name, sp_property_model.Get(), nullptr));
RETURN_IF_FAIL(sp_compiler_node_data_model_->SetKey(
L"node_id", sp_node_id_property_model.Get(), nullptr));
return S_OK; return S_OK;
} }
......
...@@ -46,6 +46,11 @@ class Extension { ...@@ -46,6 +46,11 @@ class Extension {
HRESULT OverrideLocalsGetter(IModelObject* parent, const wchar_t* key_name, HRESULT OverrideLocalsGetter(IModelObject* parent, const wchar_t* key_name,
bool is_parameters); bool is_parameters);
template <class PropertyClass>
HRESULT RegisterAndAddPropertyForClass(
const wchar_t* class_name, const wchar_t* property_name,
WRL::ComPtr<IModelObject> sp_data_model);
// A property that has been overridden by this extension. The original value // A property that has been overridden by this extension. The original value
// must be put back in place during ~Extension. // must be put back in place during ~Extension.
struct PropertyOverride { struct PropertyOverride {
...@@ -79,6 +84,7 @@ class Extension { ...@@ -79,6 +84,7 @@ class Extension {
WRL::ComPtr<IModelObject> sp_object_data_model_; WRL::ComPtr<IModelObject> sp_object_data_model_;
WRL::ComPtr<IModelObject> sp_local_data_model_; WRL::ComPtr<IModelObject> sp_local_data_model_;
WRL::ComPtr<IModelObject> sp_compiler_node_data_model_; WRL::ComPtr<IModelObject> sp_compiler_node_data_model_;
WRL::ComPtr<IModelObject> sp_compiler_type_data_model_;
WRL::ComPtr<IModelObject> sp_indexed_field_model_; WRL::ComPtr<IModelObject> sp_indexed_field_model_;
WRL::ComPtr<IDebugHostModule> sp_v8_module_; WRL::ComPtr<IDebugHostModule> sp_v8_module_;
......
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