aboutsummaryrefslogtreecommitdiff
path: root/src/debugger/debugger.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/debugger/debugger.cpp')
-rw-r--r--src/debugger/debugger.cpp42
1 files changed, 40 insertions, 2 deletions
diff --git a/src/debugger/debugger.cpp b/src/debugger/debugger.cpp
index 525ad65..c2b4c22 100644
--- a/src/debugger/debugger.cpp
+++ b/src/debugger/debugger.cpp
@@ -558,6 +558,19 @@ namespace Hsdbg
lldb::SBDebugger::Terminate();
}
+ auto Debugger::backend_version() -> std::string
+ {
+ // "lldb version 22.1.0 (https://… revision …)\n clang revision …": keep the number
+ std::string banner = lldb::SBDebugger::GetVersionString();
+ if (const size_t cut = banner.find_first_of("(\n"); cut != std::string::npos)
+ banner.resize(cut);
+ if (banner.starts_with("lldb version "))
+ banner.erase(0, 13);
+ while (!banner.empty() && banner.back() == ' ')
+ banner.pop_back();
+ return banner;
+ }
+
auto Debugger::load_target(const std::filesystem::path& executable) -> Result<void>
{
std::error_code error;
@@ -2142,6 +2155,19 @@ namespace Hsdbg
frame.line = entry.GetLine();
}
+ // the function's first and last line entries: its opening and, via
+ // the last instruction, its closing line
+ if (lldb::SBFunction function = source.GetFunction(); function.IsValid())
+ {
+ if (lldb::SBLineEntry first = function.GetStartAddress().GetLineEntry(); first.IsValid())
+ frame.function_first_line = first.GetLine();
+
+ const lldb::addr_t end = function.GetEndAddress().GetLoadAddress(m_session->target);
+ lldb::SBAddress tail = m_session->target.ResolveLoadAddress(end - 1);
+ if (lldb::SBLineEntry last = tail.GetLineEntry(); last.IsValid())
+ frame.function_last_line = std::max(last.GetLine(), frame.line);
+ }
+
m_call_stack.push_back(std::move(frame));
}
}
@@ -2162,13 +2188,25 @@ namespace Hsdbg
return;
lldb::SBValueList variables = frame.GetVariables(true, true, false, true);
+ const std::filesystem::path frame_file = path_of(frame.GetLineEntry().GetFileSpec());
for (uint32_t index = 0; index < variables.GetSize(); ++index)
{
lldb::SBValue value = variables.GetValueAtIndex(index);
- if (value.IsValid())
- m_locals.push_back(to_variable(value, 0));
+ if (!value.IsValid())
+ continue;
+
+ Variable variable = to_variable(value, 0);
+
+ if (lldb::SBDeclaration declaration = value.GetDeclaration();
+ declaration.IsValid() && !frame_file.empty() &&
+ path_of(declaration.GetFileSpec()) == frame_file)
+ {
+ variable.declaration_line = declaration.GetLine();
+ }
+
+ m_locals.push_back(std::move(variable));
}
lldb::SBValueList sets = frame.GetRegisters();