breakpoints; thread/frame selection that should work; TODO: is slow

This commit is contained in:
T0b1
2023-06-08 01:07:57 +02:00
parent 78e7f5cca7
commit b393f3dd28
14 changed files with 1098 additions and 73 deletions

View File

@@ -25,6 +25,7 @@ Frontend::Frontend()
_windows.push_back(Window::create_frames(window_id++));
_windows.push_back(Window::create_disas(window_id++));
_windows.push_back(Window::create_bp(window_id++));
_windows.push_back(Window::create_source(window_id++));
}
void Frontend::run_frame()
@@ -132,7 +133,6 @@ void Frontend::draw_header()
{
if (ImGui::BeginMenuBar())
{
const auto orig_cursor_x = ImGui::GetCursorPosX();
if (this->target)
{
switch (this->target->state)
@@ -155,7 +155,7 @@ void Frontend::draw_header()
}
break;
case running:
if (ImGui::Button("Pause"))
if (ImGui::Button("Pause "))
{
this->target->backend->pause();
}
@@ -168,9 +168,6 @@ void Frontend::draw_header()
ImGui::EndDisabled();
}
// TODO: this depends on font-size, we just want to make sure the the other buttons don't flicker even if the state is changed
ImGui::SetCursorPosX(orig_cursor_x + 71.f);
ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical, 2.f);
const auto is_paused =
@@ -185,14 +182,14 @@ void Frontend::draw_header()
if (ImGui::Button("Step Over"))
{
if (this->target->backend->step_over())
if (this->target->backend->step_over(!this->target->step_instruction))
{
// TODO: already disable the UI into running mode
}
}
if (ImGui::Button("Step Into"))
{
if (this->target->backend->step_into())
if (this->target->backend->step_into(!this->target->step_instruction))
{
// TODO: already disable the UI into running mode
}
@@ -225,6 +222,28 @@ void Frontend::draw_header()
ImGui::EndDisabled();
}
ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical, 2.f);
if (!this->target)
{
ImGui::Button("Step Mode: Source");
} else
{
if (this->target->step_instruction)
{
if (ImGui::Button("Step Mode: Instruction"))
{
this->target->step_instruction = false;
}
} else
{
if (ImGui::Button("Step Mode: Source"))
{
this->target->step_instruction = true;
}
}
}
ImGui::EndMenuBar();
}
ImGui::End();
@@ -334,6 +353,25 @@ void Frontend::handle_msgs()
{
window.handle_data_res(result);
}
break;
}
case selected_frame_changed:
{
if (this->target)
{
this->target->selected_frame =
std::get<BackToFront::SelectedFrameChanged>(msg->data).idx;
}
break;
}
case selected_thread_changed:
{
if (this->target)
{
this->target->selected_thread =
std::get<BackToFront::SelectedThreadChanged>(msg->data).idx;
}
break;
}
}
}
@@ -386,7 +424,7 @@ void Frontend::handle_reg_change(const BackToFront::RegsChanged &info)
void Frontend::handle_thread_remove(const BackToFront::ThreadRemoved &info)
{
auto &threads = this->target->threads;
if (threads.size() >= info.idx)
if (threads.size() <= info.idx)
{
return;
}
@@ -439,7 +477,7 @@ void Frontend::handle_thread_change(BackToFront::ThreadChange &&info)
void Frontend::handle_frame_remove(const BackToFront::FrameRemoved &info)
{
auto &frames = this->target->frames;
if (frames.size() >= info.idx)
if (frames.size() <= info.idx)
{
return;
}
@@ -458,6 +496,8 @@ void Frontend::handle_frame_change(BackToFront::FrameChanged &&info)
auto &frame = frames[info.idx];
if (!frame)
{
printf("Adding new frame at %u with name '%s'\n", info.idx,
info.display_name.c_str());
frame = Target::Frame{
.ip = info.ip,
.display_name = info.display_name,
@@ -465,6 +505,8 @@ void Frontend::handle_frame_change(BackToFront::FrameChanged &&info)
return;
}
printf("Updating frame at %u with name '%s'\n", info.idx,
info.display_name.c_str());
frame->ip = info.ip;
frame->display_name = info.display_name;
}