1 Diagnostic Tools : Tracing Method Calls

Tracing Method Calls
Tracing capability can be enabled either through environment variables or the provider-specific Trace class. The data provider traces the input arguments to all of its public method calls, as well as the outputs and returns from those methods (anything that a user could potentially call). Each call contains trace entries for entering and exiting the method.
During debugging, sensitive data can be read, even if it is stored as a private or internal variable and access is limited to the same assembly. To maintain security, trace logs show passwords as five asterisks (*****).
Using Environment Variables
Using environment variables to enable tracing means that you do not have to modify your application. If you change the value of an environment variable, you must restart the application for the new value to take effect.
Table 1-1 describes the environment variables used to enable and control tracing.
NOTE: If tracing is enabled and no trace file is specified by either the connection string option or the environment variable, the data provider saves the results to a file named DDTekTrace.txt.
Using Static Methods
Some users may find that using static methods on the data provider’s Trace class to be a more convenient way to enable tracing.
The following C# code fragment uses static methods on the .NET Trace object to create a SybaseTrace class with a trace file named MyTrace.txt. The values set override the values set in the environmental variables. All subsequent calls to the data provider will be traced to MyTrace.txt.
SybaseTrace.TraceFile="C:\\MyTrace.txt";
SybaseTrace.RecreateTrace = 1;
SybaseTrace.EnableTrace = 1;
The trace output has the following format:
<Correlation#> <Timestamp> <CurrentThreadName>
   <Object Address> <ObjectName.MethodName> ENTER (or EXIT)
      Argument #1 : <Argument#1 Value>
      Argument #2 : <Argument#2 Value>
      ...
      RETURN: <Method ReturnValue> // This line only exists for EXIT
where:
Correlation# is a unique number that can be used to match up ENTER and EXIT entries for the same method call in an application.
Value is the hash code of an object appropriate to the individual function calls.