Chromium Code Reviews| Index: systrace/systrace/tracing_agents/ftrace_agent.py |
| diff --git a/systrace/systrace/agents/ftrace_agent.py b/systrace/systrace/tracing_agents/ftrace_agent.py |
| similarity index 90% |
| rename from systrace/systrace/agents/ftrace_agent.py |
| rename to systrace/systrace/tracing_agents/ftrace_agent.py |
| index 758fc617e5e10dea6140501b7a7d678e6dbf49ce..f942b9a6429c541fcbf49baf2fddba3bc732ca9c 100644 |
| --- a/systrace/systrace/agents/ftrace_agent.py |
| +++ b/systrace/systrace/tracing_agents/ftrace_agent.py |
| @@ -6,8 +6,7 @@ import os |
| import sys |
| import time |
| -from systrace import systrace_agent |
| - |
| +from systrace.tracing_agents import TracingAgent, TraceResults |
|
Zhen Wang
2016/03/24 22:13:05
Separate this to 2 lines
alexandermont
2016/03/24 23:54:09
Done
|
| class FtraceAgentIo(object): |
| @@ -90,7 +89,7 @@ def try_create_agent(options, categories): |
| return FtraceAgent(options, categories, FtraceAgentIo) |
| -class FtraceAgent(systrace_agent.SystraceAgent): |
| +class FtraceAgent(TracingAgent): |
| def __init__(self, options, categories, fio=FtraceAgentIo): |
| """Initialize a systrace agent. |
| @@ -99,13 +98,16 @@ class FtraceAgent(systrace_agent.SystraceAgent): |
| options: The command-line options. |
| categories: The trace categories to capture. |
| """ |
| - super(FtraceAgent, self).__init__(options, categories) |
| - if not self._categories: |
| + super(FtraceAgent, self).__init__() |
| + if not categories: |
| self._categories = ["sched"] |
| + else: |
| + self._categories = categories |
| self._fio = fio |
| + self._options = options |
| self._categories = [x for x in self._categories |
| if self._is_category_available(x)] |
| - self._expect_trace = False |
| + self._should_output_trace = False |
| def _get_trace_buffer_size(self): |
| buffer_size = 4096 |
| @@ -121,13 +123,13 @@ class FtraceAgent(systrace_agent.SystraceAgent): |
| wait_time = self._options.trace_time |
| return wait_time |
| - def start(self): |
| + def StartAgentTracing(self): |
| """Start tracing. |
| """ |
| if self._options.list_categories or len(self._categories) == 0: |
| - self._expect_trace = False |
| + self._should_output_trace = False |
| else: |
| - self._expect_trace = True |
| + self._should_output_trace = True |
| self._fio.writeFile(FT_BUFFER_SIZE, str(self._get_trace_buffer_size())) |
| @@ -148,8 +150,9 @@ class FtraceAgent(systrace_agent.SystraceAgent): |
| sys.stdout.flush() |
| self._fio.writeFile(FT_TRACE_ON, '1') |
| + return True |
| - def collect_result(self): |
| + def StopAgentTracing(self): |
| """Collect the result of tracing. |
| This function will block while collecting the result. For sync mode, it |
| @@ -172,17 +175,9 @@ class FtraceAgent(systrace_agent.SystraceAgent): |
| print "WARN: tgid fixing is not yet supported." |
| if self._options.fix_circular: |
| print "WARN: circular buffer fixups are not yet supported." |
| + return True |
| - def expect_trace(self): |
| - """Check if the agent is returning a trace or not. |
| - |
| - This will be determined in collect_result(). |
| - Returns: |
| - Whether the agent is expecting a trace or not. |
| - """ |
| - return self._expect_trace |
| - |
| - def get_trace_data(self): |
| + def GetResults(self): |
| """Get the trace data. |
| Returns: |
| @@ -190,10 +185,13 @@ class FtraceAgent(systrace_agent.SystraceAgent): |
| """ |
| d = self._fio.readFile(FT_TRACE) |
| self._fio.writeFile(FT_BUFFER_SIZE, "1") |
| - return d |
| + return TraceResults('systemTraceEvents', d, self._should_output_trace) |
| + |
| + def SupportsExplicitClockSync(self): |
| + return False |
| - def get_class_name(self): |
| - return 'trace-data' |
| + def RecordClockSyncMarker(self, sync_id, callback): |
| + raise NotImplementedError |
| def _is_category_available(self, category): |
| if category not in all_categories: |