ftrace.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Copyright 2017 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef CHROMECAST_TRACING_FTRACE_H_
  5. #define CHROMECAST_TRACING_FTRACE_H_
  6. #include <string>
  7. #include <vector>
  8. #include "base/files/scoped_file.h"
  9. #include "base/strings/string_piece.h"
  10. namespace chromecast {
  11. namespace tracing {
  12. // Returns true if |category| is valid for system tracing.
  13. bool IsValidCategory(base::StringPiece category);
  14. // Starts ftrace for the specified categories.
  15. //
  16. // This must be paired with StopFtrace() or the kernel will continue tracing
  17. // indefinitely. Returns false if an error occurs writing to tracefs - this
  18. // usually indicates a configuration issue (e.g. tracefs not mounted).
  19. bool StartFtrace(const std::vector<std::string>& categories);
  20. // Writes time synchronization marker.
  21. //
  22. // This is used by trace-viewer to align ftrace clock with userspace
  23. // tracing. Since CLOCK_MONOTONIC is used in both cases, this merely
  24. // writes a zero offset. Call it at the end of tracing right before
  25. // StopFtrace(). Returns false if an error occurs writing to tracefs.
  26. bool WriteFtraceTimeSyncMarker();
  27. // Stops ftrace.
  28. //
  29. // This is safe to call even if tracing isn't started. Returns false if an error
  30. // occurs writing to tracefs.
  31. bool StopFtrace();
  32. // Opens ftrace buffer for reading.
  33. base::ScopedFD GetFtraceData();
  34. // Clears ftrace buffer. Returns false if an error occurs writing to tracefs.
  35. bool ClearFtrace();
  36. } // namespace tracing
  37. } // namespace chromecast
  38. #endif // CHROMECAST_TRACING_FTRACE_H_