add way to get the address of variable

This commit is contained in:
T0b1
2024-05-06 04:10:13 +02:00
parent 53899ef3c3
commit eb98d911f6
7 changed files with 200 additions and 104 deletions

View File

@@ -1119,13 +1119,15 @@ bool WatchWindow::draw(Frontend &frontend)
if (slot.buf[0] != '\0')
{
frontend.target->backend->remove_data_node(slot.id);
using namespace data::source;
frontend.target->backend->add_data_node(Node{
.id = slot.id,
.type = Node::Type::source,
.data =
Source{.type = Source::Type::variable,
.data = Source::Variable{.expr_path = slot.buf}}});
frontend.target->backend->add_data_node(
Node{.id = slot.id,
.type = Node::Type::source,
.data = Source{.type = Source::Type::variable,
.data = Source::Variable{
.expr_path = slot.buf,
.address_of_or_pointer = false}}});
}
slot.bak = slot.buf;
@@ -1172,14 +1174,23 @@ bool WatchWindow::draw(Frontend &frontend)
{
if (this->add_slot_buf[0] != '\0')
{
auto id = frontend.target->data_node_id++;
auto id = frontend.target->data_node_id++;
const auto *expr_path_buf = this->add_slot_buf;
bool address_of_or_pointer = false;
if (expr_path_buf[0] == '+')
{
address_of_or_pointer = true;
++expr_path_buf;
}
using namespace data::source;
frontend.target->backend->add_data_node(Node{
.id = id,
.type = Node::Type::source,
.data =
Source{.type = Source::Type::variable,
.data = Source::Variable{.expr_path = this->add_slot_buf}}});
.data = Source{.type = Source::Type::variable,
.data = Source::Variable{.expr_path = expr_path_buf,
.address_of_or_pointer =
address_of_or_pointer}}});
extra_slots.push_back(ExtraSlot{.id = id, .bak = this->add_slot_buf});
memcpy(extra_slots.back().buf, this->add_slot_buf,
sizeof(this->add_slot_buf));
@@ -1402,8 +1413,11 @@ void WatchWindow::draw_value(Frontend &frontend,
for (size_t i = 0; i < el_count; ++i)
{
std::snprintf(buf, sizeof(buf), "[%lu]", i);
auto expr_path_size = expr_path.size();
expr_path.back().array_idx = i;
this->draw_value(frontend, member_ty_id, buf, node_idx,
off + member_off, expr_path);
assert(expr_path.size() == expr_path_size);
member_off += member_size;
}

View File

@@ -139,8 +139,9 @@ namespace dbgui::frontend
struct ExprPathPart
{
std::string_view ident;
bool deref = false;
bool array = false;
bool deref = false;
bool array = false;
uint64_t array_idx = 0;
};
bool draw(Frontend &);