Oso Memory Profiler

2.6 - Defining expressions

Warning and error expressions allow you to customise exactly which conditions should be flagged by the Oso Memory Profiler as problems. Events that are flagged will be highlighted in the Oso Memory Profiler's views and the expressions that failed will be displayed in the Problems tab of an event's detailed information.

Custom expressions will generate errors or warnings for any events for which they evaluate as true.

Expressions should be UTF8-Latin1 (ASCII) only strings, and may contain the following:
  • &&
    Logical AND operator. Evaluates to true if both of the expressions on both sides are true.

  • ||
    Logical OR operator. Evalues to true if one of the expressions on either side is true.

  • ==, !=, <, <=, >, >=
    Relational operators. Compare the numerical or string values on each side with each other and evaluate to true or false accordingly.

  • *, /
    Multiplication and division operators. Can be applied to numerical values only.

  • %
    Modulus operator. Calculates the remainder from dividing the left hand numerical value by the right.

  • +, -
    Addition and subtraction. Adds or subtracts the two numerical values together. The addition operator can also be used to concatenate two string values together (but the left hand value must be a string - if only the right hand value is a string, it will be evaluated as the same numerical type as the left hand value.
Literal values
  • Strings
    Strings should be enclosed in double quotes.

  • Numbers
    Numbers are any base 10 numerical value. They can be integral or real values (floating point).
References References are used to access attributes from the profiler events being evaluated.

References take one of the following forms:

  • {F:<num>}
    References the attribute with the specified number from the first (allocation or message) event.

  • {F:<name>}
    References the attribute with the specified name from the first (allocation or message) event.

  • {S:<num>}
    References the attribute with the specified number from the second (free) event.

  • {S:<name>}
    References the attribute with the specified name from the second (free) event.

Names are simplified versions of the name passed to OsoMP_NewAttribute. A simplified name is one that has been converted to lowercase, and had all spacing and punctuation removed. For example, the simplified name of 'Thread 34' is 'thread34'.

Attribute numbers are the IDs specified when registering custom attributes.

In addition to any custom defined attributes, it is also possible to reference any of the standard attributes that are defined in the Oso Memory Profiler SDK: size, address, threadid, threadname, time.
Some example expressions are given below:

Is attribute 107 for the second event minus the value of the same attribute for the first event less than two?

({S:107} - {F:107}) <= 1

Is the size of each block a multiple of four?

({F:size} % 4) != 0

Was the memory allocated and freed in the same thread? (This is the inverse of one of the standard warnings available in the Oso Memory Profiler.)

{F:threadid} == {S:threadid}