socorro签名生成的实验提取

siggen的Python项目详细描述


这是对socorro签名生成码的实验性提取。

Code:https://github.com/willkg/socorro-siggen
Documentation:Check the ^{tt1}$ file
Changelog:Check the ^{tt2}$ file
Issue tracker:https://github.com/willkg/socorro-siggen/issues
License:MPLv2
Status:Alpha
Community Participation Guidelines:
Guidelines

安装

Socorro Siggen在PyPI上可用。你可以安装它 使用:

$ pip install siggen

基本用途

您可以使用socorro siggen作为命令行:

$ signify <JSONFILE>
SIGNATURE HERE

或者:

$ cat <JSONFILE> | signify

您可以使用Socorro Siggen作为库:

from siggen.generator import SignatureGenerator

generator = SignatureGenerator()

crash_data = {
    ...
}

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

要知道的事情

关于Siggen的一些知识:

  1. 确保使用最新版本的siggen并经常更新。 我们使用语义版本控制,因此api不会因为 以及补丁发布。请随意限制主要版本。

  2. 生成的签名将在siggen版本之间更改。美国石油学会 可能是稳定的,但是错误修复和对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.

  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"
}

释放过程

  1. 创建分支

  2. siggen/__init__.py

    中更新版本和发布日期
  3. 更新HISTORY.rst

  4. 推动分支,创建PR,查看它,合并它

  5. 创建签名标记,推送到github:

    git tag -s v0.1.0
    git push --tags [REMOTE] master
    
  6. 生成:

    python setup.py sdist bdist_wheel
    
  7. 上传到pypi:

    twine upload dist/*
    

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java无法启动应用程序:JNLP错误   java根据用户输入在PreparedStatement中使用setTime()或setNull()   java EJB与同步   java以object为键通过hashmap进行搜索   java中的模10^9+7   针对包含其他对象的对象的java OOP最佳实践   如何将字符串作为HTML代码从Java文件读取到JSP页面?   java我的POM怎么了?“解析表达式..检测到递归表达式循环”   用于Hbase的Mapreduce的java NoSuchMethodError   JAVAlang.SecurityException:权限拒绝:启动意图{act=安卓.Intent.action.MAIN cat=[安卓.Intent.category.LAUNCHER]   数组初始化谜语Java   通过arraylist搜索时的java句柄关联