如何调试 chrome 崩溃日志(MAC)

引言

在使用 Chrome 浏览器的过程中,偶尔会遇到浏览器崩溃的情况。为了找出崩溃的原因并修复问题,我们需要对崩溃后的 .dmp 文件进行详细分析。本文将详细介绍如何从用户的系统中获取崩溃日志文件,使用 minidump_stackwalk 查看浏览器版本信息,下载对应的 symbols 文件,并使用 LLDB 进行详细分析。

第一步:获取崩溃日志文件

1.1 收集 .dmp 文件
当 Chrome 浏览器崩溃时,系统通常会生成一个 .dmp 文件,该文件包含了崩溃时的堆栈信息。用户可以在 Chrome 的崩溃报告目录中找到这些文件。路径通常为:

  • Windows: C:\Users<Username>\AppData\Local\Google\Chrome\User Data\Crash Reports
  • macOS: ~/Library/Application Support/Google/Chrome/Crash Reports
  • Linux: ~/.config/google-chrome/Crash Reports

第二步:使用 minidump_stackwalk 查看浏览器版本信息

2.1 安装 minidump_stackwalk

确保你的系统上安装了 minidump_stackwalk。你可以通过以下命令安装:

# macOS 和 Linux
brew install breakpad

或者从源码编译安装:

git clone https://chromium.googlesource.com/breakpad/breakpad
cd breakpad
./configure
make
sudo make install

2.2 使用 minidump_stackwalk 查看信息

使用 minidump_stackwalk 工具查看 .dmp 文件中的浏览器版本信息:

minidump_stackwalk your_crash.dmp /path/to/symbols

该命令会输出崩溃的详细信息,包括浏览器版本、模块列表等。根据输出的版本信息,

第三步:下载 symbols 文件

3.1 访问 Chrome 官方网站

根据 minidump_stackwalk 输出的版本信息,访问 Chrome 官方下载页面 下载对应的 symbols 文件。通常,symbols 文件可以在 Chrome 的开发者资源页面找到。
github 上有一个辅助下载脚本(download_symbols.py),有些处理过时了,略作修改如下所示:

#!/usr/bin/env python3
# Copyright 2021 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Downloads symbols for official, Google Chrome builds.

Usage:
    ./download_symbols.py -v 91.0.4449.6 -a x86_64 -c stable -o /dest/path

This can also be used as a Python module.
"""

import argparse
import csv
import os.path
import platform
import subprocess
import sys
import urllib.request as request

# 这个地址已经失效了,channel 需要手动指定(比如 【stable】,可以在 https://chromiumdash.appspot.com/releases?platform=Mac 中查看)
_OMAHAPROXY_HISTORY = 'https://omahaproxy.appspot.com/history?os=mac&format=json'

_DSYM_URL_TEMPLATE = 'https://dl.google.com/chrome/mac/{channel}/dsym/googlechrome-{version}-{arch}-dsym.tar.bz2'


def download_chrome_symbols(version, channel, arch, dest_dir):
    """Downloads and extracts the official Google Chrome dSYM files to a
    subdirectory of `dest_dir`.

    Args:
        version: The version to download symbols for.
        channel: The release channel to download symbols for. If None, attempts
                 to guess the channel.
        arch: The CPU architecture to download symbols for.
        dest_dir: The location to download symbols to. The dSYMs will be
                  extracted to a subdirectory of this directory.

    Returns:
        The path to the directory containing the dSYMs, which will be a
        subdirectory of `dest_dir`.
    """
    if channel is None:
        channel = _identify_channel(version, arch)
        if channel:
            print('Using release channel {} for {}'.format(channel, version),
                  file=sys.stderr)
        else:
            print(
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值