GithubHelp home page GithubHelp logo

lbirchler / strace-perfetto Goto Github PK

View Code? Open in Web Editor NEW
6.0 1.0 3.0 76 KB

strace-perfetto runs strace and converts the raw output to a Trace Event JSON file. The JSON file can then be analyzed using Google's Perfetto UI

License: MIT License

Go 100.00%
perfetto strace syscalls race-conditions

strace-perfetto's Introduction

strace-perfetto

strace-perfetto runs strace and converts the raw output to a Trace Event JSON file. The JSON file can then be analyzed using Google's Perfetto UI

example

Install

go install github.com/lbirchler/strace-perfetto@latest

Usage

Usage: strace-perfetto [OPTIONS] command
  -e string
        only trace specified syscalls
  -o string
        json output file (default "stracefile.json")
  -t int
        strace timeout (secs) (default 10)

Examples

Trace program/script/command

$ strace-perfetto ./x.py
JSON output
$ jq '.[-3:]' stracefile.json                                                                                                            
[
  {
    "name": "munmap",
    "cat": "successful",
    "ph": "X",
    "pid": 83283,
    "tid": 83283,
    "ts": 1651010489317416,
    "dur": 27,
    "args": {
      "first": "(0x7fc75d49f000, 262144)",
      "returnValue": "0"
    }
  },
  {
    "name": "munmap",
    "cat": "successful",
    "ph": "X",
    "pid": 83283,
    "tid": 83283,
    "ts": 1651010489317475,
    "dur": 25,
    "args": {
      "first": "(0x7fc79f115000, 262144)",
      "returnValue": "0"
    }
  },
  {
    "name": "munmap",
    "cat": "successful",
    "ph": "X",
    "pid": 83283,
    "tid": 83283,
    "ts": 1651010489317520,
    "dur": 24,
    "args": {
      "first": "(0x7fc79eef8000, 262144)",
      "returnValue": "0"
    }
  }
]

Trace specific syscalls

$ strace-perfetto -e symlink,unlink,openat ./x.py 
JSON output
$ jq '.[-3:]' stracefile.json 
[
  {
    "name": "symlink",
    "cat": "successful",
    "ph": "X",
    "pid": 85018,
    "tid": 85018,
    "ts": 1651015267210572,
    "dur": 12,
    "args": {
      "first": "(\"/flag\", \"x\")",
      "returnValue": "0"
    }
  },
  {
    "name": "unlink",
    "cat": "successful",
    "ph": "X",
    "pid": 85018,
    "tid": 85018,
    "ts": 1651015267210598,
    "dur": 14,
    "args": {
      "first": "(\"x\")",
      "returnValue": "0"
    }
  },
  {
    "name": "openat",
    "cat": "successful",
    "ph": "X",
    "pid": 85018,
    "tid": 85018,
    "ts": 1651015267210626,
    "dur": 34,
    "args": {
      "first": "(AT_FDCWD, \"x\", O_WRONLY|O_CREAT|O_CLOEXEC, 0777)",
      "returnValue": "3"
    }
  }
]

Kill trace after n seconds

$ strace-perfetto -t 2 ./x.py 

NOTE: The cat (category) field for each event is used to represent the status of each syscall

successful: syscall returned without an error code
failed:     syscall returned with an error code
unfinished: syscall didn't finish
detached:   strace detached from syscall before returning due to another one being called by a different thread/process

strace-perfetto's People

Contributors

lbirchler avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.