This tutorial version is obsolete - jump to the newest one

Search through all states with your own queries

Estimated reading time: 4 mins

Search dialog can be opened either through RevDeBug menu:

RevDeBug marker view toolbar:

Or by executing Find usages / Find executions commands:

Additionally, if you use Find usages/Find executions command, query dialog will already have query generated based on selected command.

Search is available in two modes: Basic and Advanced.

The Basic mode can be used for fast and easy variables search. Just enter the value you are searching for.

In the Advanced mode you can change the basic query, and search for anything you want.

Use Predefined queries button , for more examples.

The results of your search can be found in Exceptions/Search window.

The number near the blue marker displays the total count of your results .

Click on any of these results, to find where and when this value appears in your code.

Read further to see which identifiers are available and how you can use them, to solve your bugs.

Available identifiers

BaseState provides access to basic information about a single application state.

Available fields:
* id - state identifier,
* Timestamp - timestamp associated with current application state, * ApplicationId - unique assembly identifier * ThreadId - thread identifier * statementId - linked statement

VariableState is a specific application state that is linked to an expression, that can be evaluated (variable, member access, function invocation, etc.).

Available fields (besides those, that are inherited from BaseState):
* Value - stored result of linked expression evaluation, * TypeName - string containing the name of the value’s type, * DeclarationId - if current variable state stores a variable or object’s member value, this field will contain statement id declaring this variable or member.

Each application state is linked with a single statement, providing additional information about this state’s context. Statements can describe any syntax structure available: from variable assignments and binary expressions, to class declarations.

Available fields: * id - unique statement identifier * Identifier – fields functionality depends on statement’s type. In many cases this field contains original source code.

Current state and statement
User can reference current application state within TMQL query using “Current” prefix.

  • How do I find all application states, that occurred in specified timespan?

    Each state has a Timestamp field. Reference that field, and compare it to the start and the end of your desired time.

    new DateTime($BaseState.Timestamp) > DateTime.Parse("2017-01-01 12:00:30") && new DateTime($BaseState.Timestamp) < DateTime.Parse("2017-01-01 12:00:35")
  • How do I find all states, that are referencing current Variable?

    Move to the state, that references desired variable and open Search Window. You have to find all the states with the same DeclarationId as the current one.

    $CurrentVariableState.DeclarationId == $VariableState.DeclarationId
  • How do I get all states with Value equal to 1000?

    Refer to the Value field in the VariableState and compare it to your number.

    Remember, that VariableState.Value is converted to string - no matter what type it might be. So this query will return integers that are equal 1000, as well as bytes, strings, etc.

    $VariableState.Value == "1000"
  • How do I find integers with value greater than 1000?

    To ensure that you'll get integers, write: $VariableState.TypeName == "System.Int32". Because all Values are converted to string, you have to parse it to integer before comparision: Int32.Parse($VariableState.Value).

    $VariableState.TypeName == "System.Int32" && Int32.Parse($VariableState.Value) > 1000
  • How to find variables of type string that contain only number?

    To get only strings write: $VariableState.TypeName == "System.String". Then check, if the Value isn't null (otherwise you could get an exception):!String.IsNullOrWhiteSpace($VariableState.Value). To filter out non-numeric values, you can use Regex: Regex.IsMatch($VariableState.Value, @"^\d+([,.]\d+)?$").

    $VariableState.TypeName == "System.String" && !String.IsNullOrWhiteSpace($VariableState.Value) && Regex.IsMatch($VariableState.Value, @"^\d+([,.]\d+)?$")
  • How to find nulls that occurred in my application?
    $VariableState.TypeName == "{null}"
  • I right clicked on variable in my code and selected "Find Usages". What is going on with that query?

    After calling Find Usages you probably saw something like this

    ($VariableState.DeclarationId == 1390 || $Statement.Id == 1441) && $BaseState.ApplicationId.SequenceEqual(new Guid("6e03a9c5-2a50-4462-8a23-91b4ee93d381").ToByteArray())

    Lets analyse it step by step.

    $VariableState.DeclarationId == 1390

    1390 in this line is a DeclarationId of the variable you have just clicked. This query will find other states with the same DeclarationId.

    $Statement.Id == 1441

    Will get all states, that are bounded to the same statement as your variable.

    $BaseState.ApplicationId.SequenceEqual(new Guid("6e03a9c5-2a50-4462-8a23-91b4ee93d381").ToByteArray())

    That condition ensures, that states will come from the same assembly. It is needed, since Id's can duplicate in sequent compilations.

Known Issues

State id shown within marker view may deviate from values shown in control panel. That is, when jumping to application state from a result in marker view, application state id shown in control panel may be different from application state shown in marker view.

Go to the next chapter, to learn how to get previous values of variables.

Didn't find what you were looking for?
Contact us at