(tid, state, events)
| 300 | } |
| 301 | |
| 302 | function drainEvents(tid, state, events) { |
| 303 | let parsed; |
| 304 | try { |
| 305 | parsed = Stalker.parse(events, { annotate: true, stringify: false }); |
| 306 | } catch (e) { return; } |
| 307 | |
| 308 | const lines = []; |
| 309 | for (const ev of parsed) { |
| 310 | if (state.count >= CONFIG.maxEventsPerThread) { |
| 311 | stopStalk(tid, `event cap ${CONFIG.maxEventsPerThread} reached`); |
| 312 | break; |
| 313 | } |
| 314 | const line = formatEvent(state, ev); |
| 315 | if (line == null) continue; // filtered out by scope |
| 316 | state.count++; |
| 317 | if (lines.length < CONFIG.flushBatch) lines.push(line); |
| 318 | else state.dropped++; |
| 319 | } |
| 320 | if (lines.length) { |
| 321 | const tag = `${C.dim}#${tid}${C.reset}`; |
| 322 | console.log(lines.map((l) => `${tag} ${l}`).join("\n")); |
| 323 | } |
| 324 | } |
| 325 | |
| 326 | function sym(addr) { |
| 327 | if (!CONFIG.symbolicate) return addr.toString(); |
no test coverage detected