This commit is contained in:
T0b1
2023-06-03 01:32:24 +02:00
parent ec2eeb10f7
commit 4f0f320ac4
9 changed files with 172 additions and 11 deletions

View File

@@ -123,6 +123,8 @@ void LLDBBackend::handle_state_change(lldb::StateType state)
}
}
this->dump_threads();
switch (state)
{
case eStateStopped:
@@ -280,6 +282,63 @@ void LLDBBackend::dump_threads()
if (sel.IsValid())
{
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
{
printf("Selected thread not valid\n");