WIP
This commit is contained in:
@@ -123,6 +123,8 @@ void LLDBBackend::handle_state_change(lldb::StateType state)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->dump_threads();
|
||||||
|
|
||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
case eStateStopped:
|
case eStateStopped:
|
||||||
@@ -280,6 +282,63 @@ void LLDBBackend::dump_threads()
|
|||||||
if (sel.IsValid())
|
if (sel.IsValid())
|
||||||
{
|
{
|
||||||
printf("Selected Thread: %lu\n", sel.GetThreadID());
|
printf("Selected Thread: %lu\n", sel.GetThreadID());
|
||||||
|
|
||||||
|
auto frame = sel.GetFrameAtIndex(0);
|
||||||
|
auto symctx = frame.GetSymbolContext(eSymbolContextEverything);
|
||||||
|
auto stream = SBStream{};
|
||||||
|
symctx.GetDescription(stream);
|
||||||
|
|
||||||
|
printf("Symctx: %.*s\n", static_cast<int>(stream.GetSize()),
|
||||||
|
stream.GetData());
|
||||||
|
|
||||||
|
auto list = _target.FindTypes("test::MyType");
|
||||||
|
printf("List len: %lu\n", list.GetSize());
|
||||||
|
auto len = list.GetSize();
|
||||||
|
for (uint32_t i = 0; i < len; ++i)
|
||||||
|
{
|
||||||
|
auto typ = list.GetTypeAtIndex(i);
|
||||||
|
stream.Clear();
|
||||||
|
typ.GetDescription(stream, eDescriptionLevelFull);
|
||||||
|
|
||||||
|
printf("Type %u: %.*s\n", i, static_cast<int>(stream.GetSize()),
|
||||||
|
stream.GetData());
|
||||||
|
}
|
||||||
|
|
||||||
|
stream.Clear();
|
||||||
|
auto sc =
|
||||||
|
frame.GetSymbolContext(eSymbolContextFunction | eSymbolContextSymbol);
|
||||||
|
|
||||||
|
uint64_t start, end;
|
||||||
|
if (sc.GetFunction().IsValid())
|
||||||
|
{
|
||||||
|
auto fn = sc.GetFunction();
|
||||||
|
start = fn.GetStartAddress().GetLoadAddress(_target);
|
||||||
|
end = fn.GetEndAddress().GetLoadAddress(_target);
|
||||||
|
} else if (sc.GetSymbol().IsValid()
|
||||||
|
&& sc.GetSymbol().GetStartAddress().IsValid())
|
||||||
|
{
|
||||||
|
auto sym = sc.GetSymbol();
|
||||||
|
start = sym.GetStartAddress().GetLoadAddress(_target);
|
||||||
|
end = sym.GetEndAddress().GetLoadAddress(_target);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
start = frame.GetPC();
|
||||||
|
end = start + 0x100;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto buf = std::vector<uint8_t>{};
|
||||||
|
buf.resize(end - start);
|
||||||
|
auto err = SBError{};
|
||||||
|
_target.ReadMemory(SBAddress{start, _target}, buf.data(), buf.size(), err);
|
||||||
|
|
||||||
|
auto inst_list =
|
||||||
|
_target.GetInstructionsWithFlavor(start, "intel", buf.data(), buf.size());
|
||||||
|
stream.Clear();
|
||||||
|
inst_list.GetDescription(stream);
|
||||||
|
printf("InstList: %.*s\n", static_cast<int>(stream.GetSize()),
|
||||||
|
stream.GetData());
|
||||||
|
|
||||||
|
//printf("Disasm: %s\n", frame.Disassemble());
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
printf("Selected thread not valid\n");
|
printf("Selected thread not valid\n");
|
||||||
|
|||||||
43
src/data.h
Normal file
43
src/data.h
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <variant>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace dbgui::data
|
||||||
|
{
|
||||||
|
struct DataSource
|
||||||
|
{
|
||||||
|
enum class Type : uint8_t
|
||||||
|
{
|
||||||
|
reg,
|
||||||
|
// TODO: special IP/SP source? so that scope selection can apply to that?
|
||||||
|
// variable,
|
||||||
|
// const,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Reg
|
||||||
|
{
|
||||||
|
// TODO: identify through names?
|
||||||
|
uint16_t set;
|
||||||
|
uint16_t idx;
|
||||||
|
};
|
||||||
|
|
||||||
|
Type type;
|
||||||
|
std::variant<std::monostate, Reg> data;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct DataNode
|
||||||
|
{
|
||||||
|
size_t id;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct DataResult
|
||||||
|
{
|
||||||
|
// TODO: needs indicator that data was failed to be retrieved
|
||||||
|
size_t id;
|
||||||
|
std::vector<uint8_t> data;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dbgui::data
|
||||||
@@ -27,6 +27,16 @@ Frontend::Frontend()
|
|||||||
|
|
||||||
void Frontend::run_frame()
|
void Frontend::run_frame()
|
||||||
{
|
{
|
||||||
|
if (_draw_metric_window)
|
||||||
|
{
|
||||||
|
ImGui::ShowMetricsWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_draw_stack_tool)
|
||||||
|
{
|
||||||
|
ImGui::ShowStackToolWindow();
|
||||||
|
}
|
||||||
|
|
||||||
this->handle_msgs();
|
this->handle_msgs();
|
||||||
this->draw_open_popup();
|
this->draw_open_popup();
|
||||||
this->draw_header();
|
this->draw_header();
|
||||||
@@ -98,6 +108,13 @@ void Frontend::draw_header()
|
|||||||
}
|
}
|
||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ImGui::BeginMenu("Debug"))
|
||||||
|
{
|
||||||
|
ImGui::MenuItem("Metrics", nullptr, &_draw_metric_window);
|
||||||
|
ImGui::MenuItem("Stack Tool", nullptr, &_draw_stack_tool);
|
||||||
|
ImGui::EndMenu();
|
||||||
|
}
|
||||||
ImGui::EndMainMenuBar();
|
ImGui::EndMainMenuBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,9 @@ namespace dbgui::frontend
|
|||||||
|
|
||||||
bool _draw_second = false;
|
bool _draw_second = false;
|
||||||
|
|
||||||
|
bool _draw_metric_window = false;
|
||||||
|
bool _draw_stack_tool = false;
|
||||||
|
|
||||||
bool _draw_open_popup = false;
|
bool _draw_open_popup = false;
|
||||||
ImGuiID _open_popup_id = 0;
|
ImGuiID _open_popup_id = 0;
|
||||||
std::vector<char> _open_popup_name_buf = {};
|
std::vector<char> _open_popup_name_buf = {};
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ void RegWindow::draw(const Frontend &frontend)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: formatting options
|
||||||
switch (reg.bytes.size())
|
switch (reg.bytes.size())
|
||||||
{
|
{
|
||||||
case 1: std::snprintf(buf, sizeof(buf), "%X", reg.bytes[0]); break;
|
case 1: std::snprintf(buf, sizeof(buf), "%X", reg.bytes[0]); break;
|
||||||
@@ -109,7 +110,24 @@ void RegWindow::draw(const Frontend &frontend)
|
|||||||
default: std::snprintf(buf, sizeof(buf), "<val too large>"); break;
|
default: std::snprintf(buf, sizeof(buf), "<val too large>"); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImGui::PushID(set_idx * 1000 + i);
|
||||||
ImGui::Text(buf);
|
ImGui::Text(buf);
|
||||||
|
if (ImGui::IsItemHovered()
|
||||||
|
&& ImGui::IsMouseClicked(ImGuiMouseButton_Right))
|
||||||
|
{
|
||||||
|
ImGui::OpenPopup("Context");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImGui::BeginPopup("Context"))
|
||||||
|
{
|
||||||
|
if (ImGui::Selectable("Copy"))
|
||||||
|
{
|
||||||
|
ImGui::SetClipboardText(buf);
|
||||||
|
}
|
||||||
|
ImGui::EndPopup();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::PopID();
|
||||||
}
|
}
|
||||||
ImGui::EndTable();
|
ImGui::EndTable();
|
||||||
}
|
}
|
||||||
|
|||||||
11
tmp/main.c
11
tmp/main.c
@@ -1,11 +0,0 @@
|
|||||||
#include <stdint.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
|
||||||
int tmp = 10;
|
|
||||||
while (tmp != 0) {
|
|
||||||
sleep(1);
|
|
||||||
tmp--;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
19
tmp/main.cpp
Normal file
19
tmp/main.cpp
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#include <stdint.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
struct MyType {
|
||||||
|
int data;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void helper_fn();
|
||||||
|
|
||||||
|
int main(int argc, char* argv[]) {
|
||||||
|
MyType tmp = MyType{10};
|
||||||
|
while (tmp.data != 0) {
|
||||||
|
helper_fn();
|
||||||
|
tmp.data--;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
13
tmp/sec.cpp
Normal file
13
tmp/sec.cpp
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#include <cstdint>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
namespace test {
|
||||||
|
struct MyType {
|
||||||
|
int data;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void helper_fn() {
|
||||||
|
test::MyType tmp = test::MyType{1};
|
||||||
|
sleep(tmp.data);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user