WIP
This commit is contained in:
@@ -468,17 +468,18 @@ bool DisasmWindow::draw(Frontend &frontend)
|
||||
|
||||
this->ip_src_id = frontend.target->data_node_id++;
|
||||
this->disas_src_id = frontend.target->data_node_id++;
|
||||
using namespace data::source;
|
||||
frontend.target->backend->add_data_node(
|
||||
data::DataNode{.id = this->ip_src_id,
|
||||
.type = data::DataNode::Type::data_source,
|
||||
.data = data::DataSource{
|
||||
.type = data::DataSource::Type::frame_ip,
|
||||
}});
|
||||
Node{.id = this->ip_src_id,
|
||||
.type = Node::Type::source,
|
||||
.data = Source{
|
||||
.type = Source::Type::frame_ip,
|
||||
}});
|
||||
|
||||
frontend.target->backend->add_data_node(
|
||||
data::DataNode{.id = this->disas_src_id,
|
||||
.type = data::DataNode::Type::disassemble,
|
||||
.data = data::Disassemble{.src_id = this->ip_src_id}});
|
||||
Node{.id = this->disas_src_id,
|
||||
.type = Node::Type::disassemble,
|
||||
.data = Disassemble{.src_id = this->ip_src_id}});
|
||||
|
||||
first = false;
|
||||
}
|
||||
@@ -760,17 +761,18 @@ bool SourceWindow::draw(Frontend &frontend)
|
||||
|
||||
this->ip_src_id = frontend.target->data_node_id++;
|
||||
this->line_entry_src_id = frontend.target->data_node_id++;
|
||||
using namespace data::source;
|
||||
frontend.target->backend->add_data_node(
|
||||
data::DataNode{.id = this->ip_src_id,
|
||||
.type = data::DataNode::Type::data_source,
|
||||
.data = data::DataSource{
|
||||
.type = data::DataSource::Type::frame_ip,
|
||||
}});
|
||||
Node{.id = this->ip_src_id,
|
||||
.type = Node::Type::source,
|
||||
.data = Source{
|
||||
.type = Source::Type::frame_ip,
|
||||
}});
|
||||
|
||||
frontend.target->backend->add_data_node(
|
||||
data::DataNode{.id = this->line_entry_src_id,
|
||||
.type = data::DataNode::Type::line_entry,
|
||||
.data = data::LineEntry{.src_id = this->ip_src_id}});
|
||||
Node{.id = this->line_entry_src_id,
|
||||
.type = Node::Type::line_entry,
|
||||
.data = LineEntry{.src_id = this->ip_src_id}});
|
||||
|
||||
first = false;
|
||||
}
|
||||
@@ -968,29 +970,29 @@ bool SourceWindow::draw(Frontend &frontend)
|
||||
return false;
|
||||
}
|
||||
|
||||
void Window::handle_data_res(const BackToFront::DataResult &result)
|
||||
void Window::handle_source_updated(Target &target, size_t id)
|
||||
{
|
||||
switch (this->type)
|
||||
{
|
||||
using enum WindowType;
|
||||
|
||||
case disassembly:
|
||||
std::get<DisasmWindow>(this->data).handle_data_res(result);
|
||||
std::get<DisasmWindow>(this->data).handle_source_updated(target, id);
|
||||
break;
|
||||
case source:
|
||||
std::get<SourceWindow>(this->data).handle_data_res(result);
|
||||
std::get<SourceWindow>(this->data).handle_source_updated(target, id);
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
void DisasmWindow::handle_data_res(
|
||||
const BackToFront::DataResult &result_wrapper)
|
||||
void DisasmWindow::handle_source_updated(Target &target, size_t id)
|
||||
{
|
||||
const auto &result = result_wrapper.result;
|
||||
if (result.id == this->ip_src_id)
|
||||
if (id == this->ip_src_id)
|
||||
{
|
||||
if (!result.success || result.type.type != data::TypeInfo::Type::u64)
|
||||
auto result = target.data_node_for_src_id(id);
|
||||
if (!result || !result->success
|
||||
|| result->type_id.type != data::type_info::Type::u64)
|
||||
{
|
||||
this->ip_unsuccessful = true;
|
||||
return;
|
||||
@@ -998,17 +1000,19 @@ void DisasmWindow::handle_data_res(
|
||||
|
||||
this->ip_unsuccessful = false;
|
||||
this->ip_changed = true;
|
||||
this->ip = *reinterpret_cast<const uint64_t *>(result.data.data());
|
||||
this->ip = std::get<uint64_t>(result->data);
|
||||
printf("IP changed to %lX\n", this->ip);
|
||||
return;
|
||||
}
|
||||
|
||||
if (result.id != this->disas_src_id)
|
||||
if (id != this->disas_src_id)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!result.success || result.type.type != data::TypeInfo::Type::custom)
|
||||
auto result = target.data_node_for_src_id(id);
|
||||
if (!result || !result->success
|
||||
|| result->type_id.type != data::type_info::Type::custom)
|
||||
{
|
||||
this->disas_unsuccessful = true;
|
||||
this->insts.clear();
|
||||
@@ -1035,21 +1039,20 @@ void DisasmWindow::handle_data_res(
|
||||
|
||||
uint8_t max_mnem_len = 0;
|
||||
uint8_t max_op_len = 0;
|
||||
while (idx < result.data.size())
|
||||
const auto &data = result->vec_data();
|
||||
while (idx < data.size())
|
||||
{
|
||||
if (result.data.size() - idx < 12)
|
||||
if (data.size() - idx < 12)
|
||||
{
|
||||
break;
|
||||
}
|
||||
uint64_t addr = *reinterpret_cast<const uint64_t *>(&result.data[idx]);
|
||||
uint8_t mnem_len =
|
||||
*reinterpret_cast<const uint8_t *>(&result.data[idx + 8]);
|
||||
uint8_t op_len = *reinterpret_cast<const uint8_t *>(&result.data[idx + 9]);
|
||||
uint8_t comment_len =
|
||||
*reinterpret_cast<const uint8_t *>(&result.data[idx + 10]);
|
||||
uint64_t addr = *reinterpret_cast<const uint64_t *>(&data[idx]);
|
||||
uint8_t mnem_len = *reinterpret_cast<const uint8_t *>(&data[idx + 8]);
|
||||
uint8_t op_len = *reinterpret_cast<const uint8_t *>(&data[idx + 9]);
|
||||
uint8_t comment_len = *reinterpret_cast<const uint8_t *>(&data[idx + 10]);
|
||||
// dc about inst_len rn
|
||||
idx += 12;
|
||||
if (result.data.size() - idx < mnem_len + op_len + comment_len)
|
||||
if (data.size() - idx < mnem_len + op_len + comment_len)
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -1057,12 +1060,12 @@ void DisasmWindow::handle_data_res(
|
||||
if (comment_len)
|
||||
{
|
||||
std::snprintf(buf, sizeof(buf), "%.*s%%*c%.*s%%.*c ; %.*s", mnem_len,
|
||||
&result.data[idx], op_len, &result.data[idx + mnem_len],
|
||||
comment_len, &result.data[idx + mnem_len + op_len]);
|
||||
&data[idx], op_len, &data[idx + mnem_len], comment_len,
|
||||
&data[idx + mnem_len + op_len]);
|
||||
} else
|
||||
{
|
||||
std::snprintf(buf, sizeof(buf), "%.*s%%*c%.*s%%.*c", mnem_len,
|
||||
&result.data[idx], op_len, &result.data[idx + mnem_len]);
|
||||
std::snprintf(buf, sizeof(buf), "%.*s%%*c%.*s%%.*c", mnem_len, &data[idx],
|
||||
op_len, &data[idx + mnem_len]);
|
||||
}
|
||||
idx += mnem_len + op_len + comment_len;
|
||||
|
||||
@@ -1086,22 +1089,22 @@ void DisasmWindow::handle_data_res(
|
||||
this->max_op_len = max_op_len;
|
||||
}
|
||||
|
||||
void SourceWindow::handle_data_res(
|
||||
const BackToFront::DataResult &result_wrapper)
|
||||
void SourceWindow::handle_source_updated(Target &target, size_t id)
|
||||
{
|
||||
const auto &result = result_wrapper.result;
|
||||
if (result.id == this->ip_src_id)
|
||||
if (id == this->ip_src_id)
|
||||
{
|
||||
// should not need to care
|
||||
return;
|
||||
}
|
||||
|
||||
if (result.id != this->line_entry_src_id)
|
||||
if (id != this->line_entry_src_id)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!result.success || result.type.type != data::TypeInfo::Type::custom)
|
||||
auto result = target.data_node_for_src_id(id);
|
||||
if (!result || !result->success
|
||||
|| result->type_id.type != data::type_info::Type::custom)
|
||||
{
|
||||
this->lines.clear();
|
||||
this->file_data.clear();
|
||||
@@ -1117,7 +1120,8 @@ void SourceWindow::handle_data_res(
|
||||
// char file_name[];
|
||||
// };
|
||||
|
||||
if (result.data.size() < 8)
|
||||
const auto &data = result->vec_data();
|
||||
if (data.size() < 8)
|
||||
{
|
||||
this->lines.clear();
|
||||
this->file_data.clear();
|
||||
@@ -1126,10 +1130,9 @@ void SourceWindow::handle_data_res(
|
||||
return;
|
||||
}
|
||||
|
||||
const auto line = *reinterpret_cast<const uint32_t *>(result.data.data());
|
||||
const auto name_len =
|
||||
*reinterpret_cast<const uint32_t *>(result.data.data() + 4);
|
||||
if (result.data.size() < 8 + name_len)
|
||||
const auto line = *reinterpret_cast<const uint32_t *>(data.data());
|
||||
const auto name_len = *reinterpret_cast<const uint32_t *>(data.data() + 4);
|
||||
if (data.size() < 8 + name_len)
|
||||
{
|
||||
this->lines.clear();
|
||||
this->file_data.clear();
|
||||
@@ -1138,8 +1141,8 @@ void SourceWindow::handle_data_res(
|
||||
return;
|
||||
}
|
||||
|
||||
const auto file_view = std::string_view{
|
||||
reinterpret_cast<const char *>(result.data.data() + 8), name_len};
|
||||
const auto file_view =
|
||||
std::string_view{reinterpret_cast<const char *>(data.data() + 8), name_len};
|
||||
|
||||
printf("New LE: %.*s:%u", static_cast<int>(file_view.size()),
|
||||
file_view.data(), line);
|
||||
|
||||
Reference in New Issue
Block a user