dread-trace 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +68 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/dread.gemspec +31 -0
- data/exe/dread +6 -0
- data/lib/dread/bitfield.rb +9 -0
- data/lib/dread/endpoint_event.rb +136 -0
- data/lib/dread/event.rb +19 -0
- data/lib/dread/factories/event_factory.rb +20 -0
- data/lib/dread/factories/trace_factory.rb +14 -0
- data/lib/dread/gadget_event.rb +91 -0
- data/lib/dread/runner.rb +27 -0
- data/lib/dread/trace.rb +49 -0
- data/lib/dread/version.rb +3 -0
- data/lib/dread.rb +13 -0
- metadata +110 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3ad1776670d14c7eabfd49e22c023ce3d76f8bc7
|
4
|
+
data.tar.gz: 2c0293ad52bdb96810c7b146583cd0d38cc161ec
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a5d057cd105edabff576fb7b2c4253e5d20bd9abd9b272202adebf53368a4b319145c7ae7218248ddddcd5360298df86d4256060a35144e1b59049a22398d97f
|
7
|
+
data.tar.gz: 576ee309c8d07cbf342057645e20c25abcd5aac9c079a1faab3d7cfafbdeaa2d5837e5bd1799d033e933dc69b4c152d9b135548312cba989e1d3e4c6e39d7c6f
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at felipe.balbi@linux.intel.com. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Felipe Balbi
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
# Dread
|
2
|
+
|
3
|
+
Dread is a decode for DWC3 Tracepoint Output.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
You can install the gem from rubygems.org with:
|
8
|
+
|
9
|
+
```
|
10
|
+
$ gem install dread
|
11
|
+
```
|
12
|
+
|
13
|
+
Alternatively, you can clone the repository:
|
14
|
+
|
15
|
+
```
|
16
|
+
$ git clone https://github.com/felipebalbi/dread.git
|
17
|
+
$ cd dread
|
18
|
+
```
|
19
|
+
|
20
|
+
Build and install the gem:
|
21
|
+
|
22
|
+
```
|
23
|
+
$ rake install
|
24
|
+
```
|
25
|
+
|
26
|
+
## Usage
|
27
|
+
|
28
|
+
You can either pipe strings to dread's STDIN:
|
29
|
+
|
30
|
+
```
|
31
|
+
$ dread < file
|
32
|
+
```
|
33
|
+
|
34
|
+
Or you can pass a file as argument:
|
35
|
+
|
36
|
+
```
|
37
|
+
$ dread file.txt
|
38
|
+
```
|
39
|
+
|
40
|
+
This is good if you wanna build pipelines.
|
41
|
+
|
42
|
+
## Development
|
43
|
+
|
44
|
+
After checking out the repo, run `bin/setup` to install
|
45
|
+
dependencies. Then, run `rake spec` to run the tests. You can also run
|
46
|
+
`bin/console` for an interactive prompt that will allow you to
|
47
|
+
experiment.
|
48
|
+
|
49
|
+
To install this gem onto your local machine, run `bundle exec rake
|
50
|
+
install`. To release a new version, update the version number in
|
51
|
+
`version.rb`, and then run `bundle exec rake release`, which will
|
52
|
+
create a git tag for the version, push git commits and tags, and push
|
53
|
+
the `.gem` file to [rubygems.org](https://rubygems.org).
|
54
|
+
|
55
|
+
## Contributing
|
56
|
+
|
57
|
+
Bug reports and pull requests are welcome on GitHub at
|
58
|
+
https://github.com/felipebalbi/dread. This project is intended to be a
|
59
|
+
safe, welcoming space for collaboration, and contributors are expected
|
60
|
+
to adhere to the [Contributor
|
61
|
+
Covenant](http://contributor-covenant.org) code of conduct.
|
62
|
+
|
63
|
+
|
64
|
+
## License
|
65
|
+
|
66
|
+
The gem is available as open source under the terms of the [MIT
|
67
|
+
License](http://opensource.org/licenses/MIT).
|
68
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "dread"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/dread.gemspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'dread/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "dread-trace"
|
8
|
+
spec.version = Dread::VERSION
|
9
|
+
spec.authors = ["Felipe Balbi"]
|
10
|
+
spec.email = ["felipe.balbi@linux.intel.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Dwc3 Register and Event Advanced Decoder}
|
13
|
+
spec.description = %q{Decodes DWC3 Trace output into human readable strings}
|
14
|
+
spec.homepage = "https://github.com/felipebalbi/dread"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
if spec.respond_to?(:metadata)
|
18
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
19
|
+
else
|
20
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
21
|
+
end
|
22
|
+
|
23
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
24
|
+
spec.bindir = "exe"
|
25
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
26
|
+
spec.require_paths = ["lib"]
|
27
|
+
|
28
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
29
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
30
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
31
|
+
end
|
data/exe/dread
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require 'dread'
|
3
|
+
|
4
|
+
module Dread
|
5
|
+
class EndpointEvent < Event
|
6
|
+
attr_reader :epnum
|
7
|
+
attr_reader :type
|
8
|
+
attr_reader :status
|
9
|
+
attr_reader :parameters
|
10
|
+
|
11
|
+
DEPEVT_XFERCOMPLETE = 0x01
|
12
|
+
DEPEVT_XFERINPROGRESS = 0x02
|
13
|
+
DEPEVT_XFERNOTREADY = 0x03
|
14
|
+
DEPEVT_RXTXFIFOEVT = 0x04
|
15
|
+
DEPEVT_STREAMEVT = 0x06
|
16
|
+
DEPEVT_EPCMDCMPLT = 0x07
|
17
|
+
|
18
|
+
STREAMEVT_FOUND = 1
|
19
|
+
STREAMEVT_NOTFOUND = 2
|
20
|
+
|
21
|
+
CONTROL_DATA = (1 << 0)
|
22
|
+
CONTROL_STATUS = (2 << 0)
|
23
|
+
|
24
|
+
TRANSFER_ACTIVE = (1 << 3)
|
25
|
+
|
26
|
+
XFERCOMPLETE_LST = (1 << 3)
|
27
|
+
XFERCOMPLETE_IOC = (1 << 2)
|
28
|
+
XFERCOMPLETE_SHORT = (1 << 1)
|
29
|
+
|
30
|
+
def initialize(line)
|
31
|
+
super
|
32
|
+
|
33
|
+
@event_type = {
|
34
|
+
DEPEVT_XFERCOMPLETE => "Transfer Complete",
|
35
|
+
DEPEVT_XFERINPROGRESS => "Transfer In Progress",
|
36
|
+
DEPEVT_XFERNOTREADY => "Transfer Not Ready",
|
37
|
+
DEPEVT_RXTXFIFOEVT => "FIFO Event",
|
38
|
+
DEPEVT_STREAMEVT => "Stream",
|
39
|
+
DEPEVT_EPCMDCMPLT => "Command Complete",
|
40
|
+
}
|
41
|
+
|
42
|
+
decode
|
43
|
+
end
|
44
|
+
|
45
|
+
def decode
|
46
|
+
@event_data = super
|
47
|
+
|
48
|
+
@epnum = field(@event_data, 5, 1)
|
49
|
+
@type = field(@event_data, 9, 6)
|
50
|
+
@status = field(@event_data, 15, 12)
|
51
|
+
@parameters = field(@event_data, 31, 16)
|
52
|
+
end
|
53
|
+
|
54
|
+
def to_s
|
55
|
+
str = super
|
56
|
+
|
57
|
+
str += ": #{endpoint}: "
|
58
|
+
str += @event_type[@type]
|
59
|
+
|
60
|
+
case @type
|
61
|
+
when DEPEVT_XFERCOMPLETE
|
62
|
+
str += xfer_complete_status
|
63
|
+
when DEPEVT_XFERNOTREADY
|
64
|
+
str += xfer_not_ready_status
|
65
|
+
when DEPEVT_STREAMEVT
|
66
|
+
str += stream_extras
|
67
|
+
end
|
68
|
+
|
69
|
+
str
|
70
|
+
end
|
71
|
+
|
72
|
+
def endpoint
|
73
|
+
num = @epnum >> 1
|
74
|
+
dir = (@epnum & 1) == 1 ? "in" : "out"
|
75
|
+
|
76
|
+
"ep#{num}#{dir}"
|
77
|
+
end
|
78
|
+
|
79
|
+
private
|
80
|
+
|
81
|
+
def xfer_complete_status
|
82
|
+
str = " ["
|
83
|
+
|
84
|
+
if ((@status & XFERCOMPLETE_SHORT) == XFERCOMPLETE_SHORT)
|
85
|
+
str += "S"
|
86
|
+
else
|
87
|
+
str += "s"
|
88
|
+
end
|
89
|
+
|
90
|
+
if ((@status & XFERCOMPLETE_IOC) == XFERCOMPLETE_IOC)
|
91
|
+
str += "I"
|
92
|
+
else
|
93
|
+
str += 'i'
|
94
|
+
end
|
95
|
+
|
96
|
+
if ((@status & XFERCOMPLETE_LST) == XFERCOMPLETE_LST)
|
97
|
+
str += "L"
|
98
|
+
else
|
99
|
+
str += "l"
|
100
|
+
end
|
101
|
+
|
102
|
+
str += "] "
|
103
|
+
str
|
104
|
+
end
|
105
|
+
|
106
|
+
def xfer_not_ready_status
|
107
|
+
str = ""
|
108
|
+
|
109
|
+
if ((@status & TRANSFER_ACTIVE) == TRANSFER_ACTIVE)
|
110
|
+
str += " (Active)"
|
111
|
+
else
|
112
|
+
str += " (Not Active)"
|
113
|
+
end
|
114
|
+
|
115
|
+
if @epnum == 0 || @epnum == 1
|
116
|
+
case (@status & (3 << 0))
|
117
|
+
when CONTROL_DATA
|
118
|
+
str += " [ Data Phase ]"
|
119
|
+
when CONTROL_STATUS
|
120
|
+
str += " [ Status Phase ]"
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
str
|
125
|
+
end
|
126
|
+
|
127
|
+
def stream_extras
|
128
|
+
case @status
|
129
|
+
when STREAMEVT_FOUND
|
130
|
+
"#{@parameters} Found"
|
131
|
+
when STREAMEVT_NOTFOUND
|
132
|
+
"#{@parameters} Not Found"
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
data/lib/dread/event.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'dread'
|
2
|
+
|
3
|
+
module Dread
|
4
|
+
module EventFactory
|
5
|
+
def self.build(line)
|
6
|
+
re = /event ([0-9a-f]{8})$/
|
7
|
+
md = line.match(re)
|
8
|
+
type = md[0].split.last.to_i(16)
|
9
|
+
|
10
|
+
case (type & 1)
|
11
|
+
when 1
|
12
|
+
GadgetEvent.new(line)
|
13
|
+
when 0
|
14
|
+
EndpointEvent.new(line)
|
15
|
+
else
|
16
|
+
e
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'dread'
|
2
|
+
|
3
|
+
module Dread
|
4
|
+
class GadgetEvent < Event
|
5
|
+
attr_reader :link
|
6
|
+
attr_reader :type
|
7
|
+
|
8
|
+
LINK_STATE_U0 = 0
|
9
|
+
LINK_STATE_U1 = 1
|
10
|
+
LINK_STATE_U2 = 2
|
11
|
+
LINK_STATE_U3 = 3
|
12
|
+
LINK_STATE_SS_DIS = 4
|
13
|
+
LINK_STATE_RX_DET = 5
|
14
|
+
LINK_STATE_SS_INACT = 6
|
15
|
+
LINK_STATE_POLL = 7
|
16
|
+
LINK_STATE_RECOV = 8
|
17
|
+
LINK_STATE_HRESET = 9
|
18
|
+
LINK_STATE_CMPLY = 10
|
19
|
+
LINK_STATE_LPBK = 11
|
20
|
+
LINK_STATE_RESET = 14
|
21
|
+
LINK_STATE_RESUME = 15
|
22
|
+
|
23
|
+
EVENT_DISCONNECT = 0
|
24
|
+
EVENT_RESET = 1
|
25
|
+
EVENT_CONNECT_DONE = 2
|
26
|
+
EVENT_LINK_STATE_CHANGE = 3
|
27
|
+
EVENT_WAKEUP = 4
|
28
|
+
EVENT_HIBER_REQ = 5
|
29
|
+
EVENT_EOPF = 6
|
30
|
+
EVENT_SOF = 7
|
31
|
+
EVENT_L1SUSP = 8
|
32
|
+
EVENT_ERRATIC_ERROR = 9
|
33
|
+
EVENT_CMD_CMPL = 10
|
34
|
+
EVENT_OVERFLOW = 11
|
35
|
+
EVENT_VNDRDEVTSTRCVED = 12
|
36
|
+
EVENT_STOPPEDONDISCONNECT= 13
|
37
|
+
EVENT_L1RESUME = 14
|
38
|
+
|
39
|
+
def initialize(line)
|
40
|
+
super
|
41
|
+
|
42
|
+
@event_type = {
|
43
|
+
EVENT_DISCONNECT => "Disconnect",
|
44
|
+
EVENT_RESET => "Reset",
|
45
|
+
EVENT_CONNECT_DONE => "Connect Done",
|
46
|
+
EVENT_LINK_STATE_CHANGE => "Link State Change",
|
47
|
+
EVENT_WAKEUP => "Wakeup",
|
48
|
+
EVENT_HIBER_REQ => "Hibernation Request",
|
49
|
+
EVENT_EOPF => "End Of Packet Frame",
|
50
|
+
EVENT_SOF => "Start Of Frame",
|
51
|
+
EVENT_L1SUSP => "L1 Suspend",
|
52
|
+
EVENT_ERRATIC_ERROR => "Erratic Error",
|
53
|
+
EVENT_CMD_CMPL => "Command Complete",
|
54
|
+
EVENT_OVERFLOW => "Overflow",
|
55
|
+
EVENT_VNDRDEVTSTRCVED => "Vendor Device Test LMP Received",
|
56
|
+
EVENT_STOPPEDONDISCONNECT => "Stopped On Disconnect",
|
57
|
+
EVENT_L1RESUME => "L1 Resume / Remote Wake",
|
58
|
+
}
|
59
|
+
|
60
|
+
@link_state = {
|
61
|
+
LINK_STATE_U0 => "U0",
|
62
|
+
LINK_STATE_U1 => "U1",
|
63
|
+
LINK_STATE_U2 => "U2",
|
64
|
+
LINK_STATE_U3 => "U3",
|
65
|
+
LINK_STATE_SS_DIS => "SS.Disconnect",
|
66
|
+
LINK_STATE_RX_DET => "Rx.Detect",
|
67
|
+
LINK_STATE_SS_INACT => "SS.Inactive",
|
68
|
+
LINK_STATE_POLL => "Polling",
|
69
|
+
LINK_STATE_RECOV => "Recovery",
|
70
|
+
LINK_STATE_HRESET => "Hot Reset",
|
71
|
+
LINK_STATE_CMPLY => "Compliance",
|
72
|
+
LINK_STATE_LPBK => "Loopback",
|
73
|
+
LINK_STATE_RESET => "Reset",
|
74
|
+
LINK_STATE_RESUME => "Resume",
|
75
|
+
}
|
76
|
+
|
77
|
+
decode
|
78
|
+
end
|
79
|
+
|
80
|
+
def decode
|
81
|
+
@event_data = super
|
82
|
+
|
83
|
+
@type = field(@event_data, 11, 8)
|
84
|
+
@link = field(@event_data, 19, 16)
|
85
|
+
end
|
86
|
+
|
87
|
+
def to_s
|
88
|
+
super + ": #{@event_type[@type]} [#{@link_state[@link]}]"
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
data/lib/dread/runner.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'dread'
|
2
|
+
|
3
|
+
module Dread
|
4
|
+
class Runner
|
5
|
+
def initialize(argf)
|
6
|
+
@argf = argf
|
7
|
+
end
|
8
|
+
|
9
|
+
def run!
|
10
|
+
argf.each_line do |line|
|
11
|
+
next if comment?(line)
|
12
|
+
|
13
|
+
t = TraceFactory.build(line)
|
14
|
+
puts t
|
15
|
+
#t.format_output if t
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def comment?(line)
|
22
|
+
line =~ /^#/
|
23
|
+
end
|
24
|
+
|
25
|
+
attr_reader :argf
|
26
|
+
end
|
27
|
+
end
|
data/lib/dread/trace.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'dread'
|
2
|
+
|
3
|
+
module Dread
|
4
|
+
class Trace
|
5
|
+
attr_reader :cpu
|
6
|
+
attr_reader :data
|
7
|
+
attr_reader :function
|
8
|
+
attr_reader :pid
|
9
|
+
attr_reader :task
|
10
|
+
attr_reader :timestamp
|
11
|
+
|
12
|
+
def initialize(line)
|
13
|
+
@line = line
|
14
|
+
@task = ''
|
15
|
+
@pid = 0
|
16
|
+
@cpu = 0
|
17
|
+
@timestamp = 0
|
18
|
+
@function = ''
|
19
|
+
@data = ''
|
20
|
+
|
21
|
+
parse!
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_s
|
25
|
+
"#{'%.9f' % timestamp}: #{task}-#{pid} [#{cpu}] #{function}: #{data}"
|
26
|
+
end
|
27
|
+
|
28
|
+
protected
|
29
|
+
|
30
|
+
def parse!
|
31
|
+
md = @line.match(re)
|
32
|
+
|
33
|
+
raise "Can't parse '#{@line}'" unless md
|
34
|
+
|
35
|
+
@cpu = md[:cpu].to_i
|
36
|
+
@data = md[:data]
|
37
|
+
@function = md[:function]
|
38
|
+
@pid = md[:pid].to_i
|
39
|
+
@task = md[:task]
|
40
|
+
@timestamp = md[:timestamp].to_f
|
41
|
+
end
|
42
|
+
|
43
|
+
def re
|
44
|
+
/(?<task>[a-z0-9\/-]+)-(?<pid>\d+)\s+\[(?<cpu>\d+)\]\s+....\s+(?<timestamp>[0-9.]+):\s+(?<function>\w+):\s+(?<data>.*)$/
|
45
|
+
end
|
46
|
+
|
47
|
+
attr_reader :line
|
48
|
+
end
|
49
|
+
end
|
data/lib/dread.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require "dread/bitfield"
|
2
|
+
require "dread/trace"
|
3
|
+
require "dread/event"
|
4
|
+
require "dread/endpoint_event"
|
5
|
+
require "dread/gadget_event"
|
6
|
+
require "dread/runner"
|
7
|
+
require "dread/version"
|
8
|
+
|
9
|
+
require "dread/factories/event_factory"
|
10
|
+
require "dread/factories/trace_factory"
|
11
|
+
|
12
|
+
module Dread
|
13
|
+
end
|
metadata
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dread-trace
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Felipe Balbi
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-09-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.12'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.12'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: Decodes DWC3 Trace output into human readable strings
|
56
|
+
email:
|
57
|
+
- felipe.balbi@linux.intel.com
|
58
|
+
executables:
|
59
|
+
- dread
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- ".rspec"
|
65
|
+
- ".travis.yml"
|
66
|
+
- CODE_OF_CONDUCT.md
|
67
|
+
- Gemfile
|
68
|
+
- LICENSE.txt
|
69
|
+
- README.md
|
70
|
+
- Rakefile
|
71
|
+
- bin/console
|
72
|
+
- bin/setup
|
73
|
+
- dread.gemspec
|
74
|
+
- exe/dread
|
75
|
+
- lib/dread.rb
|
76
|
+
- lib/dread/bitfield.rb
|
77
|
+
- lib/dread/endpoint_event.rb
|
78
|
+
- lib/dread/event.rb
|
79
|
+
- lib/dread/factories/event_factory.rb
|
80
|
+
- lib/dread/factories/trace_factory.rb
|
81
|
+
- lib/dread/gadget_event.rb
|
82
|
+
- lib/dread/runner.rb
|
83
|
+
- lib/dread/trace.rb
|
84
|
+
- lib/dread/version.rb
|
85
|
+
homepage: https://github.com/felipebalbi/dread
|
86
|
+
licenses:
|
87
|
+
- MIT
|
88
|
+
metadata:
|
89
|
+
allowed_push_host: https://rubygems.org
|
90
|
+
post_install_message:
|
91
|
+
rdoc_options: []
|
92
|
+
require_paths:
|
93
|
+
- lib
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
requirements: []
|
105
|
+
rubyforge_project:
|
106
|
+
rubygems_version: 2.5.1
|
107
|
+
signing_key:
|
108
|
+
specification_version: 4
|
109
|
+
summary: Dwc3 Register and Event Advanced Decoder
|
110
|
+
test_files: []
|