diff options
| author | hachem <im@hachem.wtf> | 2026-09-16 12:25:58 +0200 |
|---|---|---|
| committer | hachem <im@hachem.wtf> | 2026-09-16 12:25:58 +0200 |
| commit | abf4747f6c83350ec1c57db53cdda82b7aee5ec8 (patch) | |
| tree | 7559becc40bcb2349b2960725311bb1fe27b2d0e /src/debugger | |
| parent | 61ef54dd242d26f3668e306750e623d337978307 (diff) | |
feat: improve layout and themes
Diffstat (limited to 'src/debugger')
| -rw-r--r-- | src/debugger/debugger.cpp | 39 | ||||
| -rw-r--r-- | src/debugger/debugger.h | 2 | ||||
| -rw-r--r-- | src/debugger/types.h | 5 |
3 files changed, 44 insertions, 2 deletions
diff --git a/src/debugger/debugger.cpp b/src/debugger/debugger.cpp index 7091c57..b7ccfa6 100644 --- a/src/debugger/debugger.cpp +++ b/src/debugger/debugger.cpp @@ -534,6 +534,18 @@ namespace Hsdbg lldb::SBDebugger::Terminate(); } + auto Debugger::backend_version() -> std::string + { + 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; @@ -2054,6 +2066,17 @@ namespace Hsdbg frame.line = entry.GetLine(); } + 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)); } } @@ -2074,13 +2097,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(); diff --git a/src/debugger/debugger.h b/src/debugger/debugger.h index d487712..d7885b5 100644 --- a/src/debugger/debugger.h +++ b/src/debugger/debugger.h @@ -31,6 +31,8 @@ namespace Hsdbg auto operator=(const Debugger&) -> Debugger& = delete; auto operator=(Debugger&&) -> Debugger& = delete; + static auto backend_version() -> std::string; + auto load_target(const std::filesystem::path& executable) -> Result<void>; auto unload_target() -> void; auto launch(const LaunchSpec& spec) -> Result<void>; diff --git a/src/debugger/types.h b/src/debugger/types.h index 6f16562..7086384 100644 --- a/src/debugger/types.h +++ b/src/debugger/types.h @@ -104,6 +104,9 @@ namespace Hsdbg std::string function; std::filesystem::path file; uint32_t line = 0; + + uint32_t function_first_line = 0; + uint32_t function_last_line = 0; }; struct Thread @@ -119,6 +122,8 @@ namespace Hsdbg std::string type; std::string value; std::vector<Variable> children; + + uint32_t declaration_line = 0; }; struct Register |
