簡體   English   中英

如何從小型轉儲文件中獲取崩潰的進程 ID

[英]How to get crashed process id from a minidump file

我的應用程序是用 Electron(v11.1.1) 開發的,它使用 crashpad 來捕獲來自每個進程的所有崩潰 dmp 文件。 如何從小型轉儲文件中獲取崩潰的進程 ID 或其他元數據

我發現我們可以直接從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})
    })
  })
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM