Giter Club home page Giter Club logo

tracex_parser's Introduction

TraceX Parser

Documentation Status CircleCI Coverage Status PyPI - Python Version PyPI - Downloads

This python package parses ThreadX trace buffers into both human and machine-readable formats. Don't know where to begin? Check out the quick-start documentation. More documentation about ThreadX trace buffers can be found here.

Install

Via pip

$ python3 -m pip install tracex-parser

Via snap

Note

This installation method only allows you to use the command line file parser, not the Python library

$ sudo snap install tracex-parser
$ sudo snap alias tracex-parser.parse-trx parse-trx  # Register the `parse-trx` command, otherwise you will need to use tracex-parser.parse-trx
$ sudo snap connect tracex-parser:removable-media  # Required to allow reading of files outside of /home

Note

Due to how snap packages work, there are restrictions on which files snaps are allowed to access. Currently only /home, /media, /run/media, /mnt are able to be read. For example attempting to read a file in /tmp will throw a No such file or directory error

Example trace buffers

In the repository source there are a couple example TraceX traces which can be used to verify that things are working correctly.

As a python module

documentation

>>> from tracex_parser.file_parser import parse_tracex_buffer
>>> events, obj_map = parse_tracex_buffer('./demo_threadx.trx')
>>> events
[4265846278:thread 7 threadResume(thread_ptr=thread 6,prev_state=0xd,stack_ptr=0x12980,next_thread=), 4265846441:thread 7 mtxPut(obj_id=mutex 0,owning_thread=0x6adc,own_cnt=0x1,stack_ptr=0x129a0), 4265846566:thread 7 mtxPut(obj_id=mutex 0,owning_thread=0x6adc,own_cnt=0x2,stack_ptr=0x129a0)]
>>> obj_map[0xeea4]
{'obj_reg_entry_obj_available **': '0x0', 'obj_reg_entry_obj_type **': '0x1', 'thread_reg_entry_obj_ptr': '0xeea4', 'obj_reg_entry_obj_parameter_1': '0xef4c', 'obj_reg_entry_obj_parameter_2': '0x3fc', 'thread_reg_entry_obj_name': b'System Timer Thread'}

As a command line utility

documentation The file_parser module can also be run as a script, which will provide simple statistics on the trace as well as dumping all the events in the trace. It can be run by either:

  • Running the module manually: python3 -m tracex_parser.file_parser
  • Using the newly installed command: parse-trx

Both run methods are identical.

$ parse-trx -vvv ./demo_threadx.trx
Parsing ./demo_threadx.trx
total events: 974
object registry size: 16
delta ticks: 40402
Event Histogram:
queueSend     493
queueReceive  428
threadResume  19
threadSuspend 16
mtxPut        4
isrEnter      3
isrExit       3
semPut        2
semGet        2
mtxGet        2
threadSleep   2
All events:
2100:thread 2 queueReceive(queue_ptr=0x6b84,dst_ptr=0x115a0,timeout=WaitForever,enqueued=0x13)
1939:thread 2 queueReceive(queue_ptr=0x6b84,dst_ptr=0x115a0,timeout=WaitForever,enqueued=0x12)
1778:thread 2 queueReceive(queue_ptr=0x6b84,dst_ptr=0x115a0,timeout=WaitForever,enqueued=0x11)
1617:thread 2 queueReceive(queue_ptr=0x6b84,dst_ptr=0x115a0,timeout=WaitForever,enqueued=0x10)
1456:thread 2 queueReceive(queue_ptr=0x6b84,dst_ptr=0x115a0,timeout=WaitForever,enqueued=0xf)
...

tracex_parser's People

Contributors

julianneswinoga avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

s05427226

tracex_parser's Issues

Strange `TX_RUNNING` not parsed/created

When comparing tracex_parser output with Azure TraceX Windows app output there is sometimes a minor (but consistent) dependency. It is visible in demo_netx_udp.trx/tests/demo_netx_udp.txt.
This line (permalink) is shown in the Windows app output:

Event Number     Relative Time                   Event                          Context                        Priority                Next Context                    Info1           Info2           Info3           Info4        Raw Time Stamp    Priority Inversion   Raw Event        Raw Priority
     536        00000000000000536000    TX EVENT FLAG GET          (   32)       NetX IP Instance (0000F7F0)           1 (   ?)           NetX IP Instance (0000F7F0)    I1: 0000F89C    I2: FFFFFFFF    I3: 00000000    I4: 00000001        0308B008            0-0             00000020          00000001
     537        00000000000000537000    TX INTERNAL RESUME         (    1)       Interrupt                      0000F7F0                  NetX IP Instance (0000F7F0)    I1: 0000FEA4    I2: 00000003    I3: 00029C8C    I4: 0000F7F0        0308B3F0            0-0             00000001          0000F7F0
 >>> 538        00000000000000537012    TX RUNNING                 (    6)       NetX IP Instance (0000F7F0)           1 (   ?)           NetX IP Instance (0000F7F0)    I1: 00000000    I2: 00000000    I3: 00000000    I4: 00000000        0308B3FC            0-0             --------          --------
     539        00000000000000538000    TX TIME SLICE              (    5)       Interrupt                      0000F7F0                  NetX IP Instance (0000F7F0)    I1: 0000FEA4    I2: 00000001    I3: 00000001    I4: 00029CA4        0308B7D8            0-0             00000005          0000F7F0
     540        00000000000000539000    TX INTERNAL SUSPEND        (    2)       NetX IP Instance (0000F7F0)           1 (   ?)           System Timer Thr (0000FEA4)    I1: 0000F7F0    I2: 00000007    I3: 0002C434    I4: 0000FEA4        0308BBC0            0-0             00000002          00000001

This is very strange because that line (or any of the resulting values) do not appear anywhere else in the raw trace dump! The time of the event is also pretty strange (offset by 12? Everything else is on 1000) but perhaps this could be explained because it is in an interrupt context?
The ThreadX source code doesn't really tell us anything special about TX_RUNNING either...

☹️ ☹️ ☹️

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.