PrevNextUpHome SophiaFramework UNIVERSE 5.3

27.1. Macro for Diagnosing

Table 27.1. Macro for Diagnosing

Macro Description
TRACE Display the messages for debugging in the BREW Output window.
ASSERT Display an alert message in the BREW Output window if the evaluated value of specified argument is false. (The specified argument will not be evaluated if the application is built for the BREW device.)
VERIFY Display an alert message in the BREW Output window if the evaluated value of specified argument is false. (The specified argument is always evaluated even if the application is built for the BREW device.)
[Caution] Caution
The macros for diagnosing are valid only when the TARGET_BUILD_DEBUG macro is defined.

27.1.1. TRACE Macro

To display the messages for debugging in the BREW Output window, use the TRACE macro.

If the TARGET_ENVIRONMENT_SIMULATOR macro is defined, the TRACE macro is replaced with SFXHelper::dbgprintf (BREW helper function: DBGPRINTF).

Example

SInt16 ComplicatedCaculation(SInt16 data);

Void Evaluate(Void)
{
  SInt16 val = 0;
  
   ... //  "val" will be changed during processing

  SInt16 result = ComplicatedCalculation(val);
  TRACE("result = %d (in Evaluate, Line = %d)", result, __LINE__);
  ...
}
[Note] Note
The return value of ComplicatedCaculation function and the current line of source code are displayed on the BREW Output window.
[Caution] If the TARGET_ENVIRONMENT_SIMULATOR macro is not defined

The TRACE macro is defined to be "empty". Therefore, be careful about the TRACE macro when assigning the value to its arguments or calling the function that will change the value of member variable.

27.1.2. ASSERT Macro

The ASSERT macro which has only one argument of Bool type is used during development to verify the condition that must be always satisfied. (The behaviour of application build for BREW Simulator might be different from that for the BREW device.)

If the TARGET_ENVIRONMENT_SIMULATOR macro is defined(if build for the BREW Simulator), when the evaluated value of specified argument is false, alert messages with the source file name and the line number will be displayed on the BREW Output window.

Example

// Example.cpp

SFMTYPEDEFCLASS(MyClass)
class MyClass{
public:
  Initialize(Void);
...
};

...
// here is line 4093
Void Function(MyClassConstPtr obj)
{
  ASSERT(obj != null);  // verify that argument value of Function is not NULL
  obj->Initialize;
...
}
...
[Note] Note
Make sure that obj is not the null pointer. If obj is the null pointer, the following alert message will be displayed on the BREW Output window.
ASSERT failed: line 4096, file 'Example.cpp'
[Caution] If the TARGET_ENVIRONMENT_SIMULATOR macro is not defined(if build for the BREW device)

The ASSERT macro is defined to be "empty". Therefore, be careful about the ASSERT macro when assigning the value to its arguments or calling the function that will change the value of member variable.

[Caution] Others

The ASSERT macro only displays the alert messages if the evaluated value of specified argument is false, and execution processing never stop at this macro.

27.1.3. VERIFY Macro

The VERIFY macro which has only one argument of Bool type is used during development to verify the condition that must be always satisfied. (The behaviour of application build for BREW Simulator is the same as that for the BREW device.)

If the TARGET_ENVIRONMENT_SIMULATOR macro is defined(if build for the BREW Simulator), when the evaluated value of specified argument is false, alert messages with the source file name and the line number will be displayed on the BREW Output window.

If the TARGET_ENVIRONMENT_SIMULATOR macro is not defined(if build for the BREW device), only the value of argument are evaluated.

[Note] Note
The VERIFY macro is the same as ASSERT, except that the argument of Bool type is evaluated if the TARGET_ENVIRONMENT_SIMULATOR macro is not defined,