Skip to content

Commit

Permalink
feat(dap): printing symbolicated crashes from physical devices
Browse files Browse the repository at this point in the history
  • Loading branch information
wojciech-kulik committed Feb 5, 2025
1 parent 8bc62ad commit 81934a8
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
11 changes: 9 additions & 2 deletions lua/xcodebuild/integrations/dap-symbolicate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,13 @@ end
function M.process_logs(output, on_symbolicate)
for _, line in ipairs(output) do
if foundException then
if line == ")" then
if line == ")" or line:find("%(0x%x+%s.*%)") then
if line:find("%(0x%x+%s.*%)") then
for address in line:gmatch("0x%x+") do
table.insert(crashCallStack, address .. " XYZ")
end
end

foundException = false

-- defer to allow DAP print the original output
Expand All @@ -109,11 +115,12 @@ function M.process_logs(output, on_symbolicate)
end, 100)

break
else
elseif line ~= "(" then
table.insert(crashCallStack, line)
end
else
foundException = line:find("__exceptionPreprocess") ~= nil
or line:find(escape_magic("*** First throw call stack:")) ~= nil
end
end
end
Expand Down
5 changes: 5 additions & 0 deletions lua/xcodebuild/integrations/dap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,11 @@ function M.clear_console()
return
end

if vim.bo.buftype == "terminal" then
notifications.send_error("Cannot clear DAP console while debugging macOS apps.")
return
end

vim.bo[bufnr].modifiable = true
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, {})
vim.bo[bufnr].modified = false
Expand Down
16 changes: 15 additions & 1 deletion lua/xcodebuild/integrations/remote_debugger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,21 @@ local function setup_connection_listeners()
buffer = splitted[#splitted]
table.remove(splitted, #splitted)

appdata.append_app_logs(splitted)
-- filters out output used for symbolication when debugger stops
local filtered = {}
local status = require("dap").status()

if status:find("Stopped") then
for _, line in ipairs(splitted) do
if not line:find("%s+Summary: ") and not line:find("%s+Address: ") then
table.insert(filtered, line)
end
end
else
filtered = splitted
end

appdata.append_app_logs(filtered)
end
end
end
Expand Down

0 comments on commit 81934a8

Please sign in to comment.