• Home
  • Raw
  • Download

Lines Matching full:query

5 // Use trace_analyzer::Query and trace_analyzer::TraceAnalyzer to search for
15 // A Query is a boolean expression tree that evaluates to true or false for a
34 // analyzer.FindEvents(Query(EVENT_NAME) == "my_event", &events);
38 // Query q = (Query(EVENT_NAME) == Query::String("my_event") &&
39 // Query(EVENT_PHASE) == Query::Phase(TRACE_EVENT_PHASE_BEGIN) &&
40 // Query(EVENT_DURATION) > Query::Double(1000000.0));
58 // Query begin(Query(EVENT_NAME) == Query::String("timing1_begin"));
59 // Query end(Query(EVENT_NAME) == Query::String("timing1_end"));
60 // Query match(Query(EVENT_ARG, "id") == Query(OTHER_ARG, "id"));
64 // Query q = (Query(EVENT_NAME) == Query::String("timing1_begin") &&
65 // Query(EVENT_HAS_OTHER));
146 // Query(EVENT_HAS_OTHER) or by calling has_other_event().
165 // Query(HAS_NUMBER_ARG) or Query(HAS_STRING_ARG).
208 class Query {
210 Query(const Query& query);
212 ~Query();
215 // Query literal values
218 static Query String(const std::string& str);
221 static Query Double(double num);
222 static Query Int(int32_t num);
223 static Query Uint(uint32_t num);
226 static Query Bool(bool boolean);
229 static Query Phase(char phase);
232 // Example: Query(EVENT_NAME) == Query::Pattern("MyEvent*")
233 static Query Pattern(const std::string& pattern);
236 // Query event members
238 static Query EventPid() { return Query(EVENT_PID); } in EventPid()
240 static Query EventTid() { return Query(EVENT_TID); } in EventTid()
243 static Query EventTime() { return Query(EVENT_TIME); } in EventTime()
246 // Only works if Query::EventHasOther() == true.
247 static Query EventDuration() { return Query(EVENT_DURATION); } in EventDuration()
250 static Query EventCompleteDuration() { in EventCompleteDuration()
251 return Query(EVENT_COMPLETE_DURATION); in EventCompleteDuration()
254 static Query EventPhase() { return Query(EVENT_PHASE); } in EventPhase()
256 static Query EventCategory() { return Query(EVENT_CATEGORY); } in EventCategory()
258 static Query EventName() { return Query(EVENT_NAME); } in EventName()
260 static Query EventId() { return Query(EVENT_ID); } in EventId()
262 static Query EventPidIs(int process_id) { in EventPidIs()
263 return Query(EVENT_PID) == Query::Int(process_id); in EventPidIs()
266 static Query EventTidIs(int thread_id) { in EventTidIs()
267 return Query(EVENT_TID) == Query::Int(thread_id); in EventTidIs()
270 static Query EventThreadIs(const TraceEvent::ProcessThreadID& thread) { in EventThreadIs()
274 static Query EventTimeIs(double timestamp) { in EventTimeIs()
275 return Query(EVENT_TIME) == Query::Double(timestamp); in EventTimeIs()
278 static Query EventDurationIs(double duration) { in EventDurationIs()
279 return Query(EVENT_DURATION) == Query::Double(duration); in EventDurationIs()
282 static Query EventPhaseIs(char phase) { in EventPhaseIs()
283 return Query(EVENT_PHASE) == Query::Phase(phase); in EventPhaseIs()
286 static Query EventCategoryIs(const std::string& category) { in EventCategoryIs()
287 return Query(EVENT_CATEGORY) == Query::String(category); in EventCategoryIs()
290 static Query EventNameIs(const std::string& name) { in EventNameIs()
291 return Query(EVENT_NAME) == Query::String(name); in EventNameIs()
294 static Query EventIdIs(const std::string& id) { in EventIdIs()
295 return Query(EVENT_ID) == Query::String(id); in EventIdIs()
299 static Query EventHasStringArg(const std::string& arg_name) { in EventHasStringArg()
300 return Query(EVENT_HAS_STRING_ARG, arg_name); in EventHasStringArg()
305 static Query EventHasNumberArg(const std::string& arg_name) { in EventHasNumberArg()
306 return Query(EVENT_HAS_NUMBER_ARG, arg_name); in EventHasNumberArg()
310 static Query EventArg(const std::string& arg_name) { in EventArg()
311 return Query(EVENT_ARG, arg_name); in EventArg()
315 static Query EventHasOther() { return Query(EVENT_HAS_OTHER); } in EventHasOther()
319 static Query OtherPid() { return Query(OTHER_PID); } in OtherPid()
321 static Query OtherTid() { return Query(OTHER_TID); } in OtherTid()
323 static Query OtherTime() { return Query(OTHER_TIME); } in OtherTime()
325 static Query OtherPhase() { return Query(OTHER_PHASE); } in OtherPhase()
327 static Query OtherCategory() { return Query(OTHER_CATEGORY); } in OtherCategory()
329 static Query OtherName() { return Query(OTHER_NAME); } in OtherName()
331 static Query OtherId() { return Query(OTHER_ID); } in OtherId()
333 static Query OtherPidIs(int process_id) { in OtherPidIs()
334 return Query(OTHER_PID) == Query::Int(process_id); in OtherPidIs()
337 static Query OtherTidIs(int thread_id) { in OtherTidIs()
338 return Query(OTHER_TID) == Query::Int(thread_id); in OtherTidIs()
341 static Query OtherThreadIs(const TraceEvent::ProcessThreadID& thread) { in OtherThreadIs()
345 static Query OtherTimeIs(double timestamp) { in OtherTimeIs()
346 return Query(OTHER_TIME) == Query::Double(timestamp); in OtherTimeIs()
349 static Query OtherPhaseIs(char phase) { in OtherPhaseIs()
350 return Query(OTHER_PHASE) == Query::Phase(phase); in OtherPhaseIs()
353 static Query OtherCategoryIs(const std::string& category) { in OtherCategoryIs()
354 return Query(OTHER_CATEGORY) == Query::String(category); in OtherCategoryIs()
357 static Query OtherNameIs(const std::string& name) { in OtherNameIs()
358 return Query(OTHER_NAME) == Query::String(name); in OtherNameIs()
361 static Query OtherIdIs(const std::string& id) { in OtherIdIs()
362 return Query(OTHER_ID) == Query::String(id); in OtherIdIs()
366 static Query OtherHasStringArg(const std::string& arg_name) { in OtherHasStringArg()
367 return Query(OTHER_HAS_STRING_ARG, arg_name); in OtherHasStringArg()
372 static Query OtherHasNumberArg(const std::string& arg_name) { in OtherHasNumberArg()
373 return Query(OTHER_HAS_NUMBER_ARG, arg_name); in OtherHasNumberArg()
377 static Query OtherArg(const std::string& arg_name) { in OtherArg()
378 return Query(OTHER_ARG, arg_name); in OtherArg()
383 static Query PrevPid() { return Query(PREV_PID); } in PrevPid()
385 static Query PrevTid() { return Query(PREV_TID); } in PrevTid()
387 static Query PrevTime() { return Query(PREV_TIME); } in PrevTime()
389 static Query PrevPhase() { return Query(PREV_PHASE); } in PrevPhase()
391 static Query PrevCategory() { return Query(PREV_CATEGORY); } in PrevCategory()
393 static Query PrevName() { return Query(PREV_NAME); } in PrevName()
395 static Query PrevId() { return Query(PREV_ID); } in PrevId()
397 static Query PrevPidIs(int process_id) { in PrevPidIs()
398 return Query(PREV_PID) == Query::Int(process_id); in PrevPidIs()
401 static Query PrevTidIs(int thread_id) { in PrevTidIs()
402 return Query(PREV_TID) == Query::Int(thread_id); in PrevTidIs()
405 static Query PrevThreadIs(const TraceEvent::ProcessThreadID& thread) { in PrevThreadIs()
409 static Query PrevTimeIs(double timestamp) { in PrevTimeIs()
410 return Query(PREV_TIME) == Query::Double(timestamp); in PrevTimeIs()
413 static Query PrevPhaseIs(char phase) { in PrevPhaseIs()
414 return Query(PREV_PHASE) == Query::Phase(phase); in PrevPhaseIs()
417 static Query PrevCategoryIs(const std::string& category) { in PrevCategoryIs()
418 return Query(PREV_CATEGORY) == Query::String(category); in PrevCategoryIs()
421 static Query PrevNameIs(const std::string& name) { in PrevNameIs()
422 return Query(PREV_NAME) == Query::String(name); in PrevNameIs()
425 static Query PrevIdIs(const std::string& id) { in PrevIdIs()
426 return Query(PREV_ID) == Query::String(id); in PrevIdIs()
430 static Query PrevHasStringArg(const std::string& arg_name) { in PrevHasStringArg()
431 return Query(PREV_HAS_STRING_ARG, arg_name); in PrevHasStringArg()
436 static Query PrevHasNumberArg(const std::string& arg_name) { in PrevHasNumberArg()
437 return Query(PREV_HAS_NUMBER_ARG, arg_name); in PrevHasNumberArg()
441 static Query PrevArg(const std::string& arg_name) { in PrevArg()
442 return Query(PREV_ARG, arg_name); in PrevArg()
449 static Query MatchBeginWithEnd() { in MatchBeginWithEnd()
450 return (Query(EVENT_PHASE) == Query::Phase(TRACE_EVENT_PHASE_BEGIN)) && in MatchBeginWithEnd()
451 Query(EVENT_HAS_OTHER); in MatchBeginWithEnd()
455 static Query MatchComplete() { in MatchComplete()
456 return (Query(EVENT_PHASE) == Query::Phase(TRACE_EVENT_PHASE_COMPLETE)); in MatchComplete()
460 static Query MatchAsyncBeginWithNext() { in MatchAsyncBeginWithNext()
461 return (Query(EVENT_PHASE) == in MatchAsyncBeginWithNext()
462 Query::Phase(TRACE_EVENT_PHASE_ASYNC_BEGIN)) && in MatchAsyncBeginWithNext()
463 Query(EVENT_HAS_OTHER); in MatchAsyncBeginWithNext()
467 static Query MatchBeginName(const std::string& name) { in MatchBeginName()
468 return (Query(EVENT_NAME) == Query(name)) && MatchBeginWithEnd(); in MatchBeginName()
472 static Query MatchCompleteName(const std::string& name) { in MatchCompleteName()
473 return (Query(EVENT_NAME) == Query(name)) && MatchComplete(); in MatchCompleteName()
477 static Query MatchThread(const TraceEvent::ProcessThreadID& thread) { in MatchThread()
478 return (Query(EVENT_PID) == Query::Int(thread.process_id)) && in MatchThread()
479 (Query(EVENT_TID) == Query::Int(thread.thread_id)); in MatchThread()
483 static Query MatchCrossThread() { in MatchCrossThread()
484 return (Query(EVENT_PID) != Query(OTHER_PID)) || in MatchCrossThread()
485 (Query(EVENT_TID) != Query(OTHER_TID)); in MatchCrossThread()
492 Query operator==(const Query& rhs) const;
493 Query operator!=(const Query& rhs) const;
494 Query operator< (const Query& rhs) const;
495 Query operator<=(const Query& rhs) const;
496 Query operator> (const Query& rhs) const;
497 Query operator>=(const Query& rhs) const;
498 Query operator&&(const Query& rhs) const;
499 Query operator||(const Query& rhs) const;
500 Query operator!() const;
504 Query operator+(const Query& rhs) const;
505 Query operator-(const Query& rhs) const;
506 Query operator*(const Query& rhs) const;
507 Query operator/(const Query& rhs) const;
508 Query operator-() const;
510 Query operator%(const Query& rhs) const;
512 // Return true if the given event matches this query tree.
513 // This is a recursive method that walks the query tree.
592 explicit Query(TraceEventMember member);
595 Query(TraceEventMember member, const std::string& arg_name);
598 explicit Query(const std::string& str);
601 explicit Query(double num);
603 // Construct a boolean Query that returns (left <binary_op> right).
604 Query(const Query& left, const Query& right, Operator binary_op);
606 // Construct a boolean Query that returns (<binary_op> left).
607 Query(const Query& left, Operator unary_op);
619 // Attempt to convert this Query to a double. On success, true is returned
623 // Attempt to convert this Query to a string. On success, true is returned
627 // Evaluate this Query as an arithmetic operator on left_ and right_.
631 // For QUERY_EVENT_MEMBER Query: attempt to get the double value of the Query.
634 // For QUERY_EVENT_MEMBER Query: attempt to get the string value of the Query.
637 // Does this Query represent a value?
651 const Query& left() const;
652 const Query& right() const;
666 // QueryNode allows Query to store a ref-counted query tree.
669 explicit QueryNode(const Query& query);
670 const Query& query() const { return query_; } in query() function
676 Query query_;
696 // Associate BEGIN and END events with each other. This allows Query(OTHER_*)
697 // to access the associated event and enables Query(EVENT_DURATION).
721 // |first| - Eligible |first| events match this query.
722 // |second| - Eligible |second| events match this query.
723 // |match| - This query is run on the |first| event. The OTHER_* EventMember
724 // queries will point to an eligible |second| event. The query
737 void AssociateEvents(const Query& first,
738 const Query& second,
739 const Query& match);
745 // Find all events that match query and replace output vector.
746 size_t FindEvents(const Query& query, TraceEventVector* output);
748 // Find first event that matches query or NULL if not found.
749 const TraceEvent* FindFirstOf(const Query& query);
751 // Find last event that matches query or NULL if not found.
752 const TraceEvent* FindLastOf(const Query& query);
802 // Starting from |position|, find the first event that matches |query|.
805 const Query& query,
809 // Starting from |position|, find the last event that matches |query|.
812 const Query& query,
816 // Find the closest events to |position| in time that match |query|.
822 const Query& query,
829 const Query& query,
834 inline size_t CountMatches(const TraceEventVector& events, const Query& query) { in CountMatches() argument
835 return CountMatches(events, query, 0u, events.size()); in CountMatches()