Code Monkey home page Code Monkey logo

uni-trace's Introduction

* uni-trace

Universal Trace Debugger Engine. Currently, only support windbg on Windows, but the long term goal is to also support GDB or LLDB.

Introduction

History

This project is mainly inspired by BTrace for JAVA and DTrace. The initial purpose is to bring btrace like support for Windows (by using WinDBG), but since both GDB and LLDB support Python scripting, there is no reason we couldn’t port this to also support GDB or LLDB later.

Dependents

Pykd: Python extension to access Debug Engine

This is a great project, which allows us to write windbg extensions by Python 2.7, for current uni-trace, we will highly depends on this project to execute windbg commands.

MacroPy: Bring Macros to Python

Pykd is great, but to setup a break point, we need to do the following things.

from pykd import *
def SomeBreakPointerHandler(bpId):
    # do some handling for the break pointers.
    pass

setBp(expr("MyModule!MyNameSpace::MyClass::MyClass"), SomeBreakPointerHandler)

go()

There is many code to write. When there are a lot of code (especially book keeping code), it is less likely we will write some script to trace the program execution (It may be easier to manually debug the program in visual studio). So, the goal of this project is to make us write less code to trace our program.

Here Macros come into play. So, to trace all functions with name like “Create*” of a special class, one can write the following code in uni-trace.

with TraceFunctionEnter('MyModule', 'MyNameSpace::MyClass::Create*', 'TestTrace1'):
    dprintln("Trace Function Begin for MyNameSpace::MyClass::Create*")
    dprintln(dbgCommand("k 5"))    # this is a windbg command to show the top 5 call stack.

Some kind of DTrace like, right?

Usage

Install dependent softwares: Pykd and MacroPy

Download Uni-trace

The only file you need to change is the “utrace_sample1.py”.

Inside WinDBG

First load Pykd extension

.load pykd.pyd

Then, Run:

!py ~/uni_trace_folder/run_trace.py

Continue to run your target program, during this time, you will see the break point’s handler print your log messages in the windbg console. Press CTRL+BREAK to stop trace.

Happy Debugging (even on Windows)

uni-trace's People

Contributors

baoqi 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.