我的应用程序是使用Electron(v11.1.1)开发的,它使用crashpad从每个进程中捕获所有崩溃的dmp文件。如何从小型转储文件中获取崩溃的进程id或其他元数据
发布于 2021-04-14 00:08:18
我发现我们可以直接从dmp文件中解析一些字段
async function parseProcessDetailFromDump(dumpPath) {
return new Promise((ok, fail) => {
const readStream = fs.createReadStream(dumpPath)
let ptype = null
let pid = null
readStream.on("data", (chunk) => {
const text = chunk.toString(`utf-8`)
const lines = text.split(path.sep)
for (const line of lines) {
const found = line.match(/ptype/)
if (found != null && found.length > 0) {
const regPtype = /(?<=ptype[^0-9a-zA-Z]+)[0-9a-zA-Z]+/gu
const regPid = /(?<=pid[^0-9a-zA-Z]+)[0-9a-zA-Z]+/gu
ptype = line.match(regPtype)[0]
pid = line.match(regPid)[0]
}
}
})
readStream.on("error" , () => {
rejects()
})
readStream.on("end", () => {
ok({pid, ptype})
})
})
}https://stackoverflow.com/questions/65665654
复制相似问题