Please enable JavaScript to view this site.

Thread Validator Help

Navigation: API

Native API Reference

Scroll Prev Top Next More

 

Unicode or ANSI?

 

All the API functions are provided in Unicode and ANSI variants where strings are used. We've also provided a character width neutral #define in the same fashion that the Windows.h header files do.

 

For example the function for naming a heap is provided as tvSetThreadNameA(), tvSetThreadNameW() with the character width neutral tvSetThreadName() mapping to tvSetThreadNameW() for unicode and tvSetThreadNameA() for ANSI.

 

In this document we're going to use TCHAR like the Window.h header files do.

 

All the API functions are declared as extern "C", so they can be used by C users and C++ users.

 

To use these functions #include svlTVAPI.h into your code.

 

You do not need to link with any libraries to use the Native API.

 

 

tvLoadProfiler

 

Loads the profiler DLL into memory, but does not start the profiler.

 

Use this for:

32 bit applications with a 32 bit Thread Validator GUI

64 bit applications with a 64 bit Thread Validator GUI

 

For most use cases won't need to load the profiler, as the profiler will have been loaded when your launched your program from Thread Validator, or when you injected into your program using Inject or Wait For Application.

 

However if you're running your program from outside of Thread Validator and want to load the profiler from inside your program you can use tvLoadProfiler() to do that. You'll then need to call tvStartProfiler() or tvStartProfilerWithOwnGUI() to start it.

 

extern "C" 

int tvLoadProfiler();

 

Returns:
TRUE   Successfully loaded TV DLL into target application.
FALSE Failed to load the TV DLL.into target application.

      Check that the PATH environment variable points to the Thread Validator install directory contains svlThreadValidatorStub*.dll.

 

Do not use this function if you are working with services, use the NT Service API.

 

 

 

tvLoadProfiler6432

 

Loads the profiler DLL into memory, but does not start the profiler.

 

Use this for:

32 bit applications with a 64 bit Thread Validator GUI

 

For most use cases won't need to load the profiler, as the profiler will have been loaded when your launched your program from Thread Validator, or when you injected into your program using Inject or Wait For Application.

 

However if you're running your program from outside of Thread Validator and want to load the profiler from inside your program you can use tvLoadProfiler6432() to do that. You'll then need to call tvStartProfiler() or tvStartProfilerWithOwnGUI() to start it.

 

extern "C" 

int pvLoadProfiler6432();

 

Returns:
TRUE   Successfully loaded TV DLL into target application.
FALSE Failed to load the TV DLL.into target application.

      Check that the PATH environment variable points to the Thread Validator install directory contains svlThreadValidatorStub*.dll.

 

Do not use this function if you are working with services, use the NT Service API.

 

 

tvStartProfiler

 

To start the profiler from your API code you need to call the function tvStartProfiler() from your code before you call any API functions. Ideally you should call this function as early in your program as possible.

 

This will look for an existing Thread Validator user interface and send profiling results to that. If no Thread Validator user interface is running, tvStartProfiler() will start a new Thread Validator user interface.

 

extern "C" 

int tvStartProfiler();

 

Returns:
TRUE   Successfully started TV profiler.
FALSE Failed to start the TV profiler.

 

If you prefer to start the profiler from the user interface or command line you can omit the tvStartProfiler() call. You can leave it present if you wish to start Thread Validator from your program.

 

Do not use this function if you are working with services, use the NT Service API.

 

 

tvStartProfilerWithOwnGUI

 

This function is the same as tvStartProfiler() except that this always starts a new Thread Validator user interface to receive the profiling results.

 

Use this function if you want to profile multiple processes at the same time (one Thread Validator user interface per process being profiled).

 

extern "C" 

int tvStartProfilerWithOwnGUI();

 

Returns:
TRUE   Successfully started TV profiler.
FALSE Failed to start the TV profiler.

 

If you prefer to start the profiler from the user interface or command line you can omit the tvStartProfilerWithOwnGUI() call. You can leave it present if you wish to start Thread Validator from your program.

 

Do not use this function if you are working with services, use the NT Service API.

 

 

tvStartProfilerWaitForAPI

 

This function is how you start the profiler from the API if you are using the -waitForAPI command line option.

 

Use this function if you want to use Thread Validator from the command line and have it wait for an application connect to it via the API.

 

 

extern "C" 

int tvStartProfilerWaitForAPI(const int   insistOnNoSessions,
                              const DWORD waitTimeout,
                              const int   launchNewGUIIfTimeoutExpired);

 

 

The API will search for Thread Validator instances that meet the insistOnNoSessions criteria for a maximum of waitTimeout seconds.

 

If the timeout expires and launchNewGUIIfTimeoutExpired is TRUE a new Thread Validator instance is launched, otherwise attaching to Thread Validator fails.

 

If insistOnNoSessions is FALSE any Thread Validator that is found that is in the Ready state will be connected with.

 

If insistOnNoSessions is TRUE any Thread Validator that is found that is in the Ready state will be connected with if it does not have any recorded sessions.

 

 

Returns:
TRUE   Successfully started CV profiler.
FALSE Failed to start the CV profiler.

 

Do not use this function if you are working with services, use the NT Service API.

 

 

tvSetThreadName()

 

Sets the name of a thread.

 

extern "C" 
void tvSetThreadName(DWORD                threadID

                     const TCHAR        *name);

 

 

tvSetThreadNameA()

 

Sets the name of a thread.

 

extern "C" 
void tvSetThreadNameA(DWORD                threadID

                      const char        *name);

 

 

tvSetThreadNameW()

 

Sets the name of a thread.

 

extern "C" 
void tvSetThreadNameW(DWORD                threadID

                      const wchar_t        *name);

 

 

tvSetCollect()

 

Enables or disables data collection - i.e. whether data is sent to Thread Validator from your target application.

 

extern "C" 
void tvSetCollect(int enable); // TRUE to enable, FALSE to disable

 

 

tvGetCollect()

 

Returns whether data collection is on.

 

extern "C" 
int tvGetCollect();                 // Returns TRUE or FALSE