This repository has been archived by the owner on Nov 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 39
[RFC] Systrace's custom events formatting #243
Open
derkling
wants to merge
3
commits into
ARM-software:master
Choose a base branch
from
derkling:aosp-events-parsing
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,10 @@ | |
# limitations under the License. | ||
# | ||
|
||
import re | ||
|
||
from trappy.ftrace import GenericFTrace | ||
from trappy.utils import listify | ||
|
||
class drop_before_trace(object): | ||
"""Object that, when called, returns True if the line is not part of | ||
|
@@ -54,6 +57,13 @@ def __init__(self, path=".", name="", normalize_time=True, scope="all", | |
|
||
self.trace_path = path | ||
|
||
# Android injects useful events from userspace, unfortunately not using | ||
# a specific attention word. Thus, let's capture tracing_mark events | ||
# and reformat them in a local format_data callback. | ||
events = listify(events) | ||
if 'tracing_mark_write' not in events: | ||
events.append('tracing_mark_write') | ||
|
||
super(SysTrace, self).__init__(name, normalize_time, scope, events, | ||
window, abs_window) | ||
|
||
|
@@ -75,3 +85,24 @@ def trace_hasnt_finished(self): | |
|
||
""" | ||
return lambda x: not x.endswith("</script>\n") | ||
|
||
def format_data(self, unique_word, data_str): | ||
if unique_word != 'tracing_mark_write:': | ||
return data_str | ||
|
||
# Disacrd not useful clock synchronization events | ||
if 'trace_event_clock_sync' in data_str: | ||
return '' | ||
|
||
match = SYSTRACE_EVENT.match(data_str) | ||
if match: | ||
data_str = "event={} pid={} func={} data={}".format( | ||
match.group('event'), match.group('pid'), | ||
match.group('func'), match.group('data')) | ||
return data_str | ||
|
||
raise ValueError('Unexpected systrace marker: {}'.format(data_str)) | ||
return data_str | ||
|
||
SYSTRACE_EVENT = re.compile( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a comment about what this regular expression does. I know regexes are cool, but really hard to read and get right 😄 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually a sample from the trace here would be good. |
||
r'^ (?P<event>[A-Z])(\|(?P<pid>\d+)\|(?P<func>.*)(\|(?P<data>\d+))?)?') |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it should be an error, anyone could put stuff in
tracing_mark_write
. Maybe log a warning?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. Logging a warning would be better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, that was mainly for me while it's in development to check that with many different traces I'm actually matching all the possible custom events. Will change it to a warning.