Giter VIP home page Giter VIP logo

straceexec's Introduction

straceexec

Build Status PyPI version

straceexec is a python script that allows for playback and analysis of execve commands from strace logs. This is useful for debugging commands embedded several layers deep with significant automated setup. One specific use case would be debugging specific commands from a build system that setup many environment variables or have complex command line invocations.

Usage

# strace -f -v -s 10000 -o strace.log ninja
# straceexec strace.log
0: ninja -:ENV:- LANG=en_US.UTF-8 USERNAME=ddedrick SHELL=/bin/bash output=default GDM_LANG=en_US.UTF EDITOR=vimx PATH=/u
1: /bin/sh -c /usr/lib64/ccache/cc -Dfoo_EXPORTS  -fPIC -MD -MT CMakeFiles/foo.dir/foo.c.o -MF CMakeFiles/foo.dir/foo.c.o
2: /usr/lib64/ccache/cc -Dfoo_EXPORTS -fPIC -MD -MT CMakeFiles/foo.dir/foo.c.o -MF CMakeFiles/foo.dir/foo.c.o.d -o CMakeF
3: /bin/sh -c : && /usr/lib64/ccache/cc -fPIC    -shared -Wl,-soname,libfoo.so.0 -o libfoo.so.0.3.0 CMakeFiles/foo.dir/fo
4: /usr/lib64/ccache/cc -fPIC -shared -Wl,-soname,libfoo.so.0 -o libfoo.so.0.3.0 CMakeFiles/foo.dir/foo.c.o -:ENV:- LANG=
5: /usr/bin/cc -fPIC -shared -Wl,-soname,libfoo.so.0 -o libfoo.so.0.3.0 CMakeFiles/foo.dir/foo.c.o -:ENV:- LANG=en_US.UTF
6: /usr/libexec/gcc/x86_64-redhat-linux/8/collect2 -plugin /usr/libexec/gcc/x86_64-redhat-linux/8/liblto_plugin.so -plugi
7: /usr/bin/ld -plugin /usr/libexec/gcc/x86_64-redhat-linux/8/liblto_plugin.so -plugin-opt=/usr/libexec/gcc/x86_64-redhat
8: /bin/sh -c /usr/bin/cmake -E cmake_symlink_library libfoo.so.0.3.0  libfoo.so.0 libfoo.so && : -:ENV:- LANG=en_US.UTF-
9: /usr/bin/cmake -E cmake_symlink_library libfoo.so.0.3.0 libfoo.so.0 libfoo.so -:ENV:- LANG=en_US.UTF-8 USERNAME=ddedri
Enter the number of the command you would like to execute
	Append an n to not copy the environment
	Append a p to print the full command and exit
	Append a g to run under gdb
Select: 1

strace output should be collected with -v to ensure that arguments are not left off and -s with a sufficiently large size so that they are not truncated.

By default the command will be run and will have the same environment setup as is found in the strace output. Several options are available for modifying this behavior. Appending an n will use the current environment instead of the one present in the strace log. Appending a p will not exec the command but instead print it in full along with its environment. Appending a g will start start up gdb with the executable, arguments, and environment already setup. Appending an s will generate a script named command.sh that will set the environment and run the the command.

Contributing

Contributions, issues, and feature requests are welcome. Feel free to open pull requests or issues as needed.

Author

Written by Dan Dedrick to simplify isolating, reproducing and tweaking build system issues.

License

straceexec is distributed under the MIT license. See the included LICENSE file for details.

straceexec's People

Watchers

Dan Dedrick avatar

straceexec's Issues

Handle truncated/missing environment

If the right options aren't passed to strace the the environment can be missing or truncated. It would be nice to be able to ignore these issues and allow the commands to be run with the current environment instead.

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.