Skip to content

Commit c3f6547

Browse files
committed
update doctor
1 parent ec0ce17 commit c3f6547

File tree

1 file changed

+37
-11
lines changed

1 file changed

+37
-11
lines changed

script/doctor.lua

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ local function private(o)
161161
end
162162

163163
local m = private {}
164+
165+
m._ignoreMainThread = true
166+
164167
--- 获取内存快照,生成一个内部数据结构。
165168
--- 一般不用这个API,改用 report 或 catch。
166169
---@return table
@@ -191,7 +194,6 @@ m.snapshot = private(function ()
191194
local find
192195
local mark = private {}
193196

194-
195197
local function findTable(t, result)
196198
result = result or {}
197199
local mt = getmetatable(t)
@@ -211,21 +213,45 @@ m.snapshot = private(function ()
211213
if not wk then
212214
local keyInfo = find(k)
213215
if keyInfo then
214-
result[#result+1] = private {
215-
type = 'key',
216-
name = formatName(k),
217-
info = keyInfo,
218-
}
216+
if wv then
217+
find(v)
218+
local valueResults = mark[v]
219+
if valueResults then
220+
valueResults[#valueResults+1] = private {
221+
type = 'weakvalue-key',
222+
name = formatName(t) .. '|' .. formatName(v),
223+
info = keyInfo,
224+
}
225+
end
226+
else
227+
result[#result+1] = private {
228+
type = 'key',
229+
name = formatName(k),
230+
info = keyInfo,
231+
}
232+
end
219233
end
220234
end
221235
if not wv then
222236
local valueInfo = find(v)
223237
if valueInfo then
224-
result[#result+1] = private {
225-
type = 'field',
226-
name = formatName(k) .. '|' .. formatName(v),
227-
info = valueInfo,
228-
}
238+
if wk then
239+
find(k)
240+
local keyResults = mark[k]
241+
if keyResults then
242+
keyResults[#keyResults+1] = private {
243+
type = 'weakkey-field',
244+
name = formatName(t) .. '|' .. formatName(k),
245+
info = valueInfo,
246+
}
247+
end
248+
else
249+
result[#result+1] = private {
250+
type = 'field',
251+
name = formatName(k) .. '|' .. formatName(v),
252+
info = valueInfo,
253+
}
254+
end
229255
end
230256
end
231257
end

0 commit comments

Comments
 (0)