// SPDX-FileCopyrightText: 2002-2024 PCSX2 Dev Team // SPDX-License-Identifier: LGPL-3.0+ #pragma once #include #include #include "SymbolTreeLocation.h" class DebugInterface; // A node in a symbol tree model. struct SymbolTreeNode { public: enum Tag { ROOT, UNKNOWN_GROUP, GROUP, OBJECT }; Tag tag = OBJECT; ccc::MultiSymbolHandle symbol; QString name; QString mangled_name; SymbolTreeLocation location; bool is_location_editable = false; std::optional size; ccc::NodeHandle type; std::unique_ptr temporary_type; ccc::AddressRange live_range; SymbolTreeNode() {} ~SymbolTreeNode() {} SymbolTreeNode(const SymbolTreeNode& rhs) = delete; SymbolTreeNode& operator=(const SymbolTreeNode& rhs) = delete; SymbolTreeNode(SymbolTreeNode&& rhs) = delete; SymbolTreeNode& operator=(SymbolTreeNode&& rhs) = delete; // Generated from VM state, to be updated regularly. const QVariant& value() const; const QString& display_value() const; std::optional liveness(); // Read the value from the VM memory, update liveness information, and // generate a display string. Returns true if the data changed. bool readFromVM(DebugInterface& cpu, const ccc::SymbolDatabase& database); // Write the value back to the VM memory. Returns true on success. bool writeToVM(QVariant value, DebugInterface& cpu, const ccc::SymbolDatabase& database); QVariant readValueAsVariant(const ccc::ast::Node& physical_type, DebugInterface& cpu, const ccc::SymbolDatabase& database) const; bool writeValueFromVariant(QVariant value, const ccc::ast::Node& physical_type, DebugInterface& cpu) const; bool updateDisplayString(DebugInterface& cpu, const ccc::SymbolDatabase& database); QString generateDisplayString(const ccc::ast::Node& physical_type, DebugInterface& cpu, const ccc::SymbolDatabase& database, s32 depth) const; bool updateLiveness(DebugInterface& cpu); bool updateMatchesMemory(DebugInterface& cpu, const ccc::SymbolDatabase& database); bool matchesMemory() const; static void updateSymbolHashes(std::span nodes, DebugInterface& cpu, ccc::SymbolDatabase& database); bool anySymbolsValid(const ccc::SymbolDatabase& database) const; const SymbolTreeNode* parent() const; const std::vector>& children() const; bool childrenFetched() const; void setChildren(std::vector> new_children); void insertChildren(std::vector> new_children); void emplaceChild(std::unique_ptr new_child); void clearChildren(); void sortChildrenRecursively(bool sort_by_if_type_is_known); protected: QVariant m_value; QString m_display_value; std::optional m_liveness; bool m_matches_memory = true; SymbolTreeNode* m_parent = nullptr; std::vector> m_children; bool m_children_fetched = false; };