跳转到主要内容

Socorro签名生成代码提取为Python库

项目描述

这是Socorro崩溃签名生成代码的提取。

代码::

https://github.com/willkg/socorro-siggen

文档::

查看README.rst文件

变更日志::

查看HISTORY.rst文件

问题跟踪::

https://github.com/willkg/socorro-siggen/issues

许可证::

MPLv2

状态::

稳定

社区参与指南::

https://github.com/willkg/socorro-siggen/blob/main/CODE_OF_CONDUCT.md

安装

socorro-siggen可在PyPI上获取。您可以使用以下命令安装用于库使用:

$ pip install siggen

您可以使用以下命令安装用于命令行界面使用:

$ pip install 'siggen[cli]'

安装用于破解

$ pip install -r requirements-dev.txt

版本管理

siggen是Socorro中签名生成代码的提取。如果您正在对崩溃数据进行签名生成,并且希望签名与Socorro中的等效崩溃报告相匹配,那么您需要保持siggen的最新状态。

siggen使用calver方案

MAJOR.MINOR.yyyymmdd

  • MAJOR:表示不兼容的API更改 - 在HISTORY.rst中列为例行更改

  • MINOR:表示向后兼容的更改

  • yyyymmdd:发布日期

基本用法

在命令行中使用它进行签名生成调试

siggen附带了一些命令行工具用于签名生成。

signify

通过stdin接收签名生成崩溃数据文件,执行签名生成,并打印输出。

这对于生成崩溃数据的签名非常有帮助。

用法

signify --help

示例

$ fetch-data 04e52a99-67d4-4d19-ad21-e29d10220905 > crash_data.json
$ cat crash_data.json | signify

如果您传递了--verbose标志,您将获得有关签名如何生成的详细输出。

fetch-data

从Crash Stats下载处理过的崩溃数据,并将其转换为签名生成崩溃数据。

用法

fetch-data --help

示例

$ fetch-data 04e52a99-67d4-4d19-ad21-e29d10220905 > crash_data.json
signature

从Crash Stats下载处理过的崩溃数据,将其转换为签名生成崩溃数据格式,并生成签名。

这还会告诉您新签名是否与旧签名匹配。

这对于调整签名列表和调试签名生成问题非常有帮助。

用法

$ signature --help

示例

$ signature 04e52a99-67d4-4d19-ad21-e29d10220905 > crash_data.json

用作库

您可以将socorro-siggen用作库

from siggen.generator import SignatureGenerator

generator = SignatureGenerator()

crash_data = {
    ...
}

ret = generator.generate(crash_data)
print(ret['signature'])

注意事项

关于siggen的注意事项

  1. 请确保使用siggen的最新版本,并定期更新。

  2. 生成的签名将在siggen版本之间发生变化。API可能是稳定的,但错误修复和对siglist文件的更改将影响签名生成输出。希望是朝着更好的方向发展!

  3. 如果您有问题,请提交一个问题。请包含siggen的版本。

    在使用siggen时,您可以像这样查找版本

    import siggen
    print(siggen.__version__)

签名生成崩溃数据架构

这是签名生成崩溃数据结构的架构

{
  crashing_thread: <int or null>,    // Optional, The index of the crashing thread in threads.
                                     // This defaults to None which indicates there was no
                                     // crashing thread identified in the crash report.

  threads: [                         // Optional, list of stack traces for c/c++/rust code.
    {
      frames: [                      // List of one or more frames.
        {
          function: <string>,        // Optional, The name of the function.
                                     // If this is ``None`` or not in the frame, then signature
                                     // generation will calculate something using other data in
                                     // the frame.

          module: <string>,          // Optional, name of the module
          file: <string>,            // Optional, name of the file
          line: <int>,               // Optional, line in the file
          module_offset: <string>,   // Optional, offset in hex in the module for this frame
          offset: <string>           // Optional, offset in hex for this frame

                                     // Signature parts are computed using frame data in this
                                     // order:

                                     // 1. if there's a function (and optionally line)--use
                                     //    that
                                     // 2. if there's a file and a line--use that
                                     // 3. if there's an offset and no module/module_offset--use
                                     //    that
                                     // 4. use module/module_offset
        }
        // ... additional frames
      ],

      thread_name: <string>,         // Optional, The name of the thread.
                                     // This isn't used, yet, but might be in the future for
                                     // debugging purposes.

      frame_count: <int>             // Optional, This is the total number of frames. This
                                     // isn't used.
    },
    // ... additional threads
  ],

  java_stack_trace: <string>,        // Optional, If the crash is a Java crash, then this will
                                     // be the Java traceback as a single string. Signature
                                     // generation will split this string into lines and then
                                     // extract frame information from it to generate the
                                     // signature.

                                     // FIXME(willkg): Write up better description of this.

  oom_allocation_size: <int>,        // Optional, The allocation size that triggered an
                                     // out-of-memory error. This will get added to the
                                     // signature if one of the indicator functions appears in
                                     // the stack of the crashing thread.

  abort_message: <string>,           // Optional, The abort message for the crash, if there is
                                     // one. This is added to the beginning of the signature.

  hang_type: <int>,                  // Optional.
                                     // 1 here indicates this is a chrome hang and we look at
                                     // thread 0 for generation.
                                     // -1 indicates another kind of hang.

  async_shutdown_timeout: <text>,    // Optional, This is a text field encoded in JSON with
                                     // "phase" and "conditions" keys.
                                     // FIXME(willkg): Document this structure better.

  jit_category: <string>,            // Optional, If there's a JIT classification in the
                                     // crash, then that will override the signature

  ipc_channel_error: <string>,       // Optional, If there is an IPC channel error, it
                                     // replaces the signature.

  ipc_message_name: <string>,        // Optional, This gets added to the signature if there
                                     // was an IPC message name in the crash.

  additional_minidumps: <string>,    // Optional, A crash report can contain multiple minidumps.
                                     // This is a comma-delimited list of minidumps other than
                                     // the main one that the crash had.

                                     // Example: "browser,flash1,flash2,content"

  mdsw_status_string: <string>,      // Optional, Socorro-generated
                                     // This is the minidump-stackwalk status string. This
                                     // gets generated when the Socorro processor runs the
                                     // minidump through minidump-stackwalk. If you're not
                                     // using minidump-stackwalk, you can ignore this.

  reason: <string>,                  // Optional, The crash_info type value. This can indicate
                                     // the crash was a OOM.

  moz_crash_reason: <string>,        // Optional, This is the MOZ_CRASH_REASON value. This
                                     // doesn't affect anything unless the value is
                                     // "MOZ_RELEASE_ASSERT(parentBuildID == childBuildID)".

  os: <string>,                      // Optional, The name of the operating system. This
                                     // doesn't affect anything unless the name is "Windows
                                     // NT" in which case it will lowercase module names when
                                     // iterating through frames to build the signature.
}

在结构中缺少的键被视为None,因此您可以传递一个仅包含您定义的部分的最小结构。

示例

几乎最小、有点荒谬的crash_data.json

{
    "os": "Linux",
    "crashing_thread": 0,
    "threads": [
        {
            "frames": [
                {
                    "frame": 0,
                    "function": "SomeFunc",
                    "line": 20,
                    "file": "somefile.cpp",
                    "module": "foo.so.5.15.0",
                    "module_offset": "0x37a92",
                    "offset": "0x7fc641052a92"
                },
                {
                    "frame": 1,
                    "function": "SomeOtherFunc",
                    "line": 444,
                    "file": "someotherfile.cpp",
                    "module": "bar.so",
                    "module_offset": "0x39a55",
                    "offset": "0x7fc641044a55"
                }
            ]
        }
    ]
}

这会产生以下输出

$ cat crash_data.json | signify
{
  "notes": [],
  "proto_signature": "SomeFunc | SomeOtherFunc",
  "signature": "SomeFunc"
}

项目详情


下载文件

下载您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源分布

siggen-2.1.20240726.tar.gz (68.2 kB 查看哈希)

上传时间:

构建分布

siggen-2.1.20240726-py3-none-any.whl (66.6 kB 查看哈希)

上传时间: Python 3

支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面