OC Systems

Home | Contact | Advanced Search 

Technology

How do I reference enumeration literals in APC?

Here is an example C++ program:

a.cpp:
------
#include <iostream.h>
#define VALUE satu

enum TYPE {sund, mond, tues, wedn, thur, frid, satu};

int main (void)
{
  TYPE bar = satu;
  cout << "Hello World\n";
}

Here is a probe that references enumeration literals of the above program:

a.apc:
------
probe thread
{
  probe "main"
  {
    on_line (11)
    {
      if ($bar == $satu)
      {
        log ("Match");
      }
      else
      {
        log ("No Match");
      }
    }
  }
}



If the enumeration literals are defined in a C++ class, you can qualify them. So for example:

class my_class
{
  enum TYPE {sund, mond, tues, wedn, thur, frid, satu};

  private:
    TYPE bar;

  public:
    void setmy_class(){ bar = VALUE; }
};

my_class test;

You could use this in your probe:

  if ($test.bar == ($("my_class::satu")))

Aprobe Technology Overview

Schedule a web demo

Contact us