auxtrace.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Copyright(C) 2015 Linaro Limited. All rights reserved.
  3. * Author: Mathieu Poirier <mathieu.poirier@linaro.org>
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License version 2 as published by
  7. * the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #include <stdbool.h>
  18. #include <linux/coresight-pmu.h>
  19. #include "../../util/auxtrace.h"
  20. #include "../../util/evlist.h"
  21. #include "../../util/pmu.h"
  22. #include "cs-etm.h"
  23. struct auxtrace_record
  24. *auxtrace_record__init(struct perf_evlist *evlist, int *err)
  25. {
  26. struct perf_pmu *cs_etm_pmu;
  27. struct perf_evsel *evsel;
  28. bool found_etm = false;
  29. cs_etm_pmu = perf_pmu__find(CORESIGHT_ETM_PMU_NAME);
  30. if (evlist) {
  31. evlist__for_each_entry(evlist, evsel) {
  32. if (cs_etm_pmu &&
  33. evsel->attr.type == cs_etm_pmu->type)
  34. found_etm = true;
  35. }
  36. }
  37. if (found_etm)
  38. return cs_etm_record_init(err);
  39. /*
  40. * Clear 'err' even if we haven't found a cs_etm event - that way perf
  41. * record can still be used even if tracers aren't present. The NULL
  42. * return value will take care of telling the infrastructure HW tracing
  43. * isn't available.
  44. */
  45. *err = 0;
  46. return NULL;
  47. }