diff options
| author | Glenn Smith <glenn@vector35.com> | 2022-09-26 17:07:52 -0400 |
|---|---|---|
| committer | Glenn Smith <glenn@vector35.com> | 2022-09-29 21:02:25 -0400 |
| commit | 571d4ed2f01c1117237b1a9684ad9b1d1ad8963a (patch) | |
| tree | d63530c2510fc123496e7550625e7ebfc8c594f5 /debuginfo.cpp | |
| parent | b6442a914783cb2861ff8d1cd6a3865fed29e0f7 (diff) | |
DebugInfo: make parseInfo have a progress callback
This will enable us to have progress bars and cancellation of debuginfo application
Diffstat (limited to 'debuginfo.cpp')
| -rw-r--r-- | debuginfo.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/debuginfo.cpp b/debuginfo.cpp index c9a6f319..9783cba8 100644 --- a/debuginfo.cpp +++ b/debuginfo.cpp @@ -337,19 +337,25 @@ string DebugInfoParser::GetName() const } -Ref<DebugInfo> DebugInfoParser::Parse(Ref<BinaryView> view, Ref<DebugInfo> existingDebugInfo) const +Ref<DebugInfo> DebugInfoParser::Parse(Ref<BinaryView> view, Ref<DebugInfo> existingDebugInfo, std::function<bool(size_t, size_t)> progress) const { + ProgressContext ctxt; + if (progress) + ctxt.callback = progress; + else + ctxt.callback = [=](size_t, size_t) { return true; }; + BNDebugInfo* info = nullptr; if (existingDebugInfo) { - info = BNParseDebugInfo(m_object, view->GetObject(), existingDebugInfo->GetObject()); + info = BNParseDebugInfo(m_object, view->GetObject(), existingDebugInfo->GetObject(), ProgressCallback, &ctxt); if (!info) return nullptr; info = BNNewDebugInfoReference(info); } else { - info = BNParseDebugInfo(m_object, view->GetObject(), nullptr); + info = BNParseDebugInfo(m_object, view->GetObject(), nullptr, ProgressCallback, &ctxt); if (!info) return nullptr; } @@ -375,10 +381,12 @@ bool CustomDebugInfoParser::IsValidCallback(void* ctxt, BNBinaryView* view) } -bool CustomDebugInfoParser::ParseCallback(void* ctxt, BNDebugInfo* debugInfo, BNBinaryView* view) +bool CustomDebugInfoParser::ParseCallback(void* ctxt, BNDebugInfo* debugInfo, BNBinaryView* view, bool (*progress)(void*, size_t, size_t), void* progressCtxt) { CustomDebugInfoParser* parser = (CustomDebugInfoParser*)ctxt; - return parser->ParseInfo(new DebugInfo(debugInfo), new BinaryView(view)); + return parser->ParseInfo(new DebugInfo(debugInfo), new BinaryView(view), [=](size_t cur, size_t max) { + return progress(progressCtxt, cur, max); + }); } |
