【问题标题】:How to get crashed process id from a minidump file如何从小型转储文件中获取崩溃的进程 ID
【发布时间】:2021-01-11 11:01:31
【问题描述】:

我的应用程序是使用 Electron(v11.1.1) 开发的,它使用 crashpad 来捕获来自每个进程的所有崩溃 dmp 文件。 如何从 minidump 文件中获取崩溃的进程 ID 或其他元数据

【问题讨论】:

标签: crashpad


【解决方案1】:

我发现我们可以直接从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})
    })
  })
}

【讨论】:

    猜你喜欢
    • 2010-12-05
    • 1970-01-01
    • 2010-09-08
    • 1970-01-01
    • 2016-03-22
    • 1970-01-01
    • 2019-06-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多