• Stars
    star
    144
  • Rank 247,813 (Top 6 %)
  • Language
    C#
  • License
    MIT License
  • Created over 7 years ago
  • Updated about 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Command-line tool for ETW tracing on files and real-time events

Introduction

Build status

etrace is a command-line tool for realtime tracing of ETW events and for processing existing .etl recording files. It was inspired by the Microsoft ELT tool.

Most use-cases for etrace involve a production environment where you want quick trace results without creating a long-running recording and then opening it with a tool like WPA or PerfView. It can also be used for a quick query over an existing trace file to see some basic event information without opening the entire trace.

etrace is under active development -- it is not at all ready for production use yet. In fact, I am writing these lines after a talk for which I published etrace on GitHub just so that I can mention it during the talk :-) Contributions are very welcome!

Installation

You can either compile etrace from source (Visual Studio 2015 required), or use the precompiled binaries from AppVeyor.

Examples

To run these examples yourself, build the etrace solution and run a command prompt as administrator. (ETW collection requires administrative privileges; you can process existing .etl files with standard user privileges.)

Collect garbage collection allocation ticks across all processes and print the raw events:

> etrace --clr GC --event GC/AllocationTick

Processing start time: 9/17/2016 12:14:20 PM
Session start time: 9/17/2016 12:14:20 PM
GC/AllocationTick [PID=14380 TID=12464 TIME=9/17/2016 12:14:20 PM]
  AllocationAmount     = 107136
  AllocationKind       = Small
  ClrInstanceID        = 9
  AllocationAmount64   = 107136
  TypeID               = 84331216
  TypeName             = Microsoft.Diagnostics.Tracing.Parsers.Kernel.FileIONameTraceData
  HeapIndex            = 0
  Address              = 45424572
GC/AllocationTick [PID=1308 TID=5216 TIME=9/17/2016 12:14:20 PM]
  AllocationAmount     = 106876
  AllocationKind       = Small
  ClrInstanceID        = 47
  AllocationAmount64   = 106876
  TypeID               = 1917056168
  TypeName             = System.Double
  HeapIndex            = 0
  Address              = 904193672
^C

Print a message every time a process is started, with the parent process and image file name:

> etrace --kernel Process --event Process/Start --field ParentID,ImageFileName
Processing start time: 9/17/2016 12:15:23 PM
Session start time: 9/17/2016 12:15:23 PM
ParentID                       ImageFileName
--------------------------------------------------------------
4840                           notepad.exe
Events lost: 0
^C

Filter out file accesses to all DLLs and print their details:

> etrace --kernel Process,Thread,FileIO,FileIOInit --event FileIO/Create --where "FileName=\.dll$"
FileIO/Create [PID=2148 TID=14540 TIME=9/17/2016 12:17:34 PM]
  IrpPtr               = 18446717194321646184
  FileObject           = 18446717194317992256
  CreateOptions        = FILE_SYNCHRONOUS_IO_NONALERT, FILE_OPEN_FOR_BACKUP_INTENT
  FileAttributes       = 0
  ShareAccess          = ReadWrite, Delete
  FileName             = C:\Windows\System32\rmclient.dll
FileIO/Create [PID=9396 TID=8880 TIME=9/17/2016 12:17:34 PM]
  IrpPtr               = 18446717194308377208
  FileObject           = 18446717194278651104
  CreateOptions        = NONE
  FileAttributes       = 0
  ShareAccess          = ReadWrite, Delete
  FileName             = C:\WINDOWS\system32\directmanipulation.dll

Process an existing .etl recording and print out statistics about specific events:

> etrace --file trace.etl --event GC/Start,GC/AllocationTick --stats
Processing start time: 9/17/2016 12:19:19 PM
Session start time: 6/2/2016 3:55:46 PM
Events by name
 -----------------------------
 | Event             | Count |
 -----------------------------
 | GC/AllocationTick | 33745 |
 -----------------------------
 | GC/Start          | 4212  |
 -----------------------------

 Count: 2

Events by process
 --------------------------
 | Process      | Count   |
 --------------------------
 | JackCompiler | 37709   |
 --------------------------
 |              | 215     |
 --------------------------
 | devenv       | 18      |
 --------------------------
 | PerfView     | 15      |
 --------------------------

 Count: 4


Processing end time:           9/17/2016 12:19:21 PM
Processing duration:           00:00:01.3438275
Processed events:              638233
Displayed events:              37957

To get a list of CLR keywords, kernel keywords, or registered providers on your system:

> etrace --list CLR

Supported CLR keywords (use with --clr):

        None
        GC
        GCHandle
        Binder
        Loader
        Jit
        NGen
        StartEnumeration
        StopEnumeration
        Security
        AppDomainResourceManagement
        JitTracing
        Interop
        Contention
        Exception
		... output snipped for brevity

To see the usage message, run etrace --help:

etrace 1.0.0.0
Copyright Sasha Goldshtein 2016

  --raw         Regular expression to match against the entire event
                description. This is not very efficient; prefer using --where
                if possible.

  --where       Filter payload fields with a regular expression. For example:
                ImageFileName=notepad,ParentID=4840

  --pid         (Default: -1) Filter only events from this process.

  --tid         (Default: -1) Filter only events from this thread.

  --event       Filter only these events. For example:
                FileIO/Create,Process/Start

  --clr         The CLR keywords to enable.

  --kernel      The kernel keywords to enable.

  --other       Other (non-kernel, non-CLR) providers to enable. A list of
                GUIDs or friendly names.

  --file        The ETL file to process.

  --list        List keywords and/or providers. Options include: CLR, Kernel,
                Registered, Published, or a comma-separated combination thereof.

  --stats       Display only statistics and not individual events.

  --field       Display only these payload fields (if they exist). The special
                fields Event, PID, TID, Time can be specified for all events.
                An optional width specifier can be provided in square brackets.
                For example: PID,TID,ProcessName[16],Receiver[30],Time

  --duration    Number of seconds after which to stop the trace. Relevant for
                realtime sessions only.

  --help        Display this help screen.


Examples:
  etrace --clr GC --event GC/AllocationTick
  etrace --kernel Process,Thread,FileIO,FileIOInit --event FileIO/Create
  etrace --file trace.etl --stats
  etrace --clr GC --event GC/Start --field PID,TID,Reason[12],Type
  etrace --kernel Process --event Process/Start --where ImageFileName=myapp
  etrace --kernel Process --where ProcessName=myProcessName
  etrace --kernel Process --event Thread/Stop --where ProcessId=4
  etrace --kernel Process --event Thread/Stop --where ThreadId=10272	
  etrace --kernel Process --event --where "ThreadId > 1 && ProcessName=git-lfs"
  etrace --clr GC --event GC/Start --duration 60
  etrace --other Microsoft-Windows-Win32k --event QueuePostMessage
  etrace --list CLR,Kernel

More Repositories

1

linux-tracing-workshop

Examples and hands-on labs for Linux tracing tools workshops
HTML
1,225
star
2

minidumper

Write minidumps of .NET processes with full memory, only CLR heaps, or no memory at all
C#
220
star
3

windbg-extensions

Various extensions for WinDbg
C
163
star
4

msos

Command-line environment a-la WinDbg for executing SOS commands without having SOS available.
C#
95
star
5

shmemq-blog

Shared memory queue benchmarks and tracing for blog
C
68
star
6

template-metaprogramming-day

Materials for the C++ Template Metaprogramming one-day workshop
C++
61
star
7

LiveStacks

Collect, aggregate, and display live stack traces for ETW events, including CPU sampling, of native and .NET processes.
C#
52
star
8

simd-workshop

Exercises and sample code for a C# SIMD (vectorization) workshop
C#
34
star
9

spark-workshop

Labs and data files for a full-day Spark workshop
Shell
24
star
10

Memory

Test program for allocating various kinds of memory
C++
23
star
11

dntrace

Trace .NET Core runtime events and summarize them
Python
22
star
12

jobrun

Run a process in a job and control its resource quotas
C++
21
star
13

marshalfx

Extensions for the Visual Studio C++/CLI marshaling framework
C++
17
star
14

AdvancedDotNetDebugging

Slides and demos for my Advanced .NET Debugging with WinDbg and SOS talk.
11
star
15

rentahome

Rent a Home demo application for Android, iOS, Windows Phone 8, and Windows 8. Used as a demo in Windows Azure Mobile Services presentations.
Objective-C
10
star
16

wams-android

Windows Azure Mobile Services unofficial Android SDK
Java
9
star
17

libstapsdt-jni

Java wrapper for libstapsdt: enables JVM applications to create USDT probes dynamically
C++
8
star
18

production-diagnostics-day

Materials and hands-on labs for a production diagnostics workshop
C#
5
star
19

cool-cpp-things

C++
4
star
20

docker-aci-workshop

Docker and Azure Container Instances workshop
HTML
3
star
21

pinvoke-stack-bug

Demo code for a P/Invoke bug caused by structure packing in output parameters overwriting an unrelated stack variable
C#
2
star
22

sosloader

Automatically loads SOS based on information present in the dump file
C#
2
star
23

ETLFlameGraph

Generate flame graphs from Event Tracing for Windows (ETW) stack trace recordings
C#
2
star
24

swift-simple-weather

Simple weather iOS app in Swift that demonstrates unit tests and UI tests with SBTUITestTunnel
Swift
2
star
25

r-workshop

R workshop with tutorial and data exploration exercises
HTML
2
star
26

offset2source

A tool that converts module (and optional method) instruction offsets back to the .cpp source file and line number.
C++
1
star
27

playground

Sasha's Git Playground
JavaScript
1
star
28

wbext

Example WinDbg extension written in C#
C#
1
star
29

dotfiles

My dotfiles (Vim, bash, screen, etc.)
Vim Script
1
star
30

PostPCDemos

Demos from PostPC HUJI course
Java
1
star
31

invtsc

Print the CPU clock cycle counter as reported by rdtsc on Intel processors, and report invariant TSC availability
C
1
star