threads and frames
This commit is contained in:
@@ -15,6 +15,16 @@ Target::Target(std::string filename)
|
||||
backend = std::make_shared<backend::LLDBBackend>(this->filename.c_str());
|
||||
}
|
||||
|
||||
Frontend::Frontend()
|
||||
{
|
||||
_open_popup_name_buf.resize(512);
|
||||
const char *str = "/home/klee/projects/dbgui/tmp/main";
|
||||
std::memcpy(_open_popup_name_buf.data(), str, strlen(str) + 1);
|
||||
_windows.push_back(Window::create_regs(window_id++));
|
||||
_windows.push_back(Window::create_threads(window_id++));
|
||||
_windows.push_back(Window::create_frames(window_id++));
|
||||
}
|
||||
|
||||
void Frontend::run_frame()
|
||||
{
|
||||
this->handle_msgs();
|
||||
@@ -38,6 +48,12 @@ void Frontend::run_frame()
|
||||
|
||||
if (ImGui::Begin("Test", nullptr, win_flags))
|
||||
{
|
||||
// TODO: if we just do SetNextWindowDockID in each of the windows
|
||||
// this seems to crash once the first window is docked to it?
|
||||
// so some id change is necessary
|
||||
// so we should try to figure out what the dock id for the "topleft"
|
||||
// window is or whatever and use that for new windows
|
||||
// spawning them floating looks bad (and might reuse saved positions)
|
||||
this->dock_id = ImGui::GetID("MyDockSpace");
|
||||
ImGui::DockSpace(this->dock_id, ImVec2{0, 0},
|
||||
ImGuiDockNodeFlags_PassthruCentralNode);
|
||||
@@ -45,6 +61,7 @@ void Frontend::run_frame()
|
||||
for (auto &window : _windows)
|
||||
{
|
||||
window.draw(*this);
|
||||
//this->dock_id = ImGui::GetWindowDockID();
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
@@ -104,8 +121,19 @@ void Frontend::draw_header()
|
||||
break;
|
||||
|
||||
case stopped: ImGui::Button("Run"); break;
|
||||
case paused: ImGui::Button("Continue"); break;
|
||||
case running: ImGui::Button("Pause"); break;
|
||||
case paused:
|
||||
if (ImGui::Button("Continue"))
|
||||
{
|
||||
this->target->backend->cont();
|
||||
// TODO: mark target already as running to prevent input?
|
||||
}
|
||||
break;
|
||||
case running:
|
||||
if (ImGui::Button("Pause"))
|
||||
{
|
||||
this->target->backend->pause();
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else
|
||||
{
|
||||
@@ -244,6 +272,22 @@ void Frontend::handle_msgs()
|
||||
case regs_changed:
|
||||
this->handle_reg_change(std::get<BackToFront::RegsChanged>(msg->data));
|
||||
break;
|
||||
case thread_changed:
|
||||
this->handle_thread_change(
|
||||
std::move(std::get<BackToFront::ThreadChange>(msg->data)));
|
||||
break;
|
||||
case thread_removed:
|
||||
this->handle_thread_remove(
|
||||
std::get<BackToFront::ThreadRemoved>(msg->data));
|
||||
break;
|
||||
case frame_changed:
|
||||
this->handle_frame_change(
|
||||
std::move(std::get<BackToFront::FrameChanged>(msg->data)));
|
||||
break;
|
||||
case frame_removed:
|
||||
this->handle_frame_remove(
|
||||
std::get<BackToFront::FrameRemoved>(msg->data));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -290,4 +334,90 @@ void Frontend::handle_reg_change(const BackToFront::RegsChanged &info)
|
||||
// TODO: opt for uint64?
|
||||
std::copy(val.begin(), val.end(), reg.bytes.begin());
|
||||
}
|
||||
}
|
||||
|
||||
void Frontend::handle_thread_remove(const BackToFront::ThreadRemoved &info)
|
||||
{
|
||||
auto &threads = this->target->threads;
|
||||
if (threads.size() >= info.idx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
threads[info.idx] = {};
|
||||
}
|
||||
|
||||
void Frontend::handle_thread_change(BackToFront::ThreadChange &&info)
|
||||
{
|
||||
auto &threads = this->target->threads;
|
||||
if (threads.size() <= info.idx)
|
||||
{
|
||||
threads.resize(info.idx + 1);
|
||||
}
|
||||
|
||||
auto &thread = threads[info.idx];
|
||||
if (!thread)
|
||||
{
|
||||
thread = Target::Thread{
|
||||
.id = info.id,
|
||||
.ip = info.ip,
|
||||
.stop_extra = info.stop_extra,
|
||||
.stop_reason = info.stop_reason,
|
||||
};
|
||||
if (info.name)
|
||||
{
|
||||
thread->name = std::move(*info.name);
|
||||
}
|
||||
if (info.cur_display_fn)
|
||||
{
|
||||
thread->cur_display_fn = std::move(*info.cur_display_fn);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
thread->id = info.id;
|
||||
thread->ip = info.ip;
|
||||
thread->stop_reason = info.stop_reason;
|
||||
thread->stop_extra = info.stop_extra;
|
||||
if (info.name)
|
||||
{
|
||||
thread->name = std::move(*info.name);
|
||||
}
|
||||
if (info.cur_display_fn)
|
||||
{
|
||||
thread->cur_display_fn = std::move(*info.cur_display_fn);
|
||||
}
|
||||
}
|
||||
|
||||
void Frontend::handle_frame_remove(const BackToFront::FrameRemoved &info)
|
||||
{
|
||||
auto &frames = this->target->frames;
|
||||
if (frames.size() >= info.idx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
frames[info.idx] = {};
|
||||
}
|
||||
|
||||
void Frontend::handle_frame_change(BackToFront::FrameChanged &&info)
|
||||
{
|
||||
auto &frames = this->target->frames;
|
||||
if (frames.size() <= info.idx)
|
||||
{
|
||||
frames.resize(info.idx + 1);
|
||||
}
|
||||
|
||||
auto &frame = frames[info.idx];
|
||||
if (!frame)
|
||||
{
|
||||
frame = Target::Frame{
|
||||
.ip = info.ip,
|
||||
.display_name = info.display_name,
|
||||
};
|
||||
return;
|
||||
}
|
||||
|
||||
frame->ip = info.ip;
|
||||
frame->display_name = info.display_name;
|
||||
}
|
||||
Reference in New Issue
Block a user