[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]

General Programming Concepts: Writing and Debugging Programs


Multi-Threaded Call Back Functions

Purpose

Provide access to facilities needed by the pthread debug library and supplied by the debugger or application.

Library

These functions are provided by the debugger which links in the pthread debug library.

Syntax


#include <sys/pthdebug.h>


int symbol_addrs(pthdb_user_t user,
pthdb_symbol_t symbols[],
int count)


int read_data(pthdb_user_t user,
void * buf,
pthdb_addr_t addr,
int size)


int write_data(pthdb_user_t user,
void * buf,
pthdb_addr_t addr,
int size)


int read_regs(pthdb_user_t user,
tid_t tid,
unsigned long long flags,
struct context64 * context)


int write_regs(pthdb_user_t user,
tid_t tid,
unsigned long long flags,
struct context64 * context)


int alloc(pthdb_user_t user,
size_t len,
void ** bufp)


int realloc(pthdb_user_t user,
void * buf,
size_t len,
void ** bufp)


int dealloc(pthdb_user_t user,
void * buf)


int print(pthdb_user_t user,
char * str)

Description

int symbol_addrs()
Resolves the address of symbols in the debuggee. The pthread debug library will call this function to get the address of known debug symbols. If symbol has a name of NULL or "", then just set the address to 0LL, instead of doing a lookup or returning an error. If successful, 0 is returned, else non-zero is returned. In introspective mode, when the PTHDB_FLAG_SUSPEND flag is set, the application can use the pthread debug library provided symbol_addrs call back function, by passing NULL or it can use one of it's own.

int read_data()
Reads the requested number of bytes of data at requested location from an active process or from a core file and returns the data through a buffer. If successful then return 0 else return non-zero. This call back function is always required.

int write_data()
Writes the requested number of bytes of data at requested location. The pthdebug library may use this to write data to the active process. If successful return 0, else non-zero is returned. This call back function is required when the PTHDB_FLAG_HOLD flag is set and when using the pthdb_pthread_setcontext() function.

int read_regs()
Read registers call back function should be able to read the context information of a debuggee kernel thread from an active process or from a core file. The information should be formatted in context64 form for both 32-bit and 64-bit process. If successful return 0, else non-zero is returned. This function is only required when using the pthdb_pthread_context() and pthdb_pthread_setcontext() functions.

int write_regs()
Write register function should be able to write requested context information to specified debuggee's kernel thread id. If successful return 0, else non-zero is returned. This function is only required when using the pthdb_pthread_setcontext() functions.

int alloc()
Takes len and allocates len bytes of memory and returns the address. If successful return 0, else non-zero is returned. This call back function is always required.

int realloc()
Takes len and the buf and re-allocates the memory and returns an address to the realloc memory. If successful return 0, else non-zero is returned. This call back function is always required.

int dealloc()
Takes a buffer and frees it. If successful return 0, else non-zero is returned. This call back function is always required.

int print()
Prints the character string on the debugger's stdout. If successful return 0, else non-zero is returned. This call back is for debugging the library only, the messages printed will not be translated and will not be explained in our user level documentation. If not debugging the pthread debug library pass a NULL value for this call back.

Note: If write_data() and write_regs() are NULL then the pthread debug library will not try to write data or write regs. If pthdb_pthread_set_context() is called when write_data() and write_regs() are NULL, then it will return PTHDB_NOTSUP.

Parameters


user User handle.
symbols Array of symbols.
count Number of symbols.
buf Buffer.
addr Address to be read from or wrote to.
size Size of buffer.
flags Session flags, must accept PTHDB_FLAG_GPRS, PTHDB_FLAG_SPRS, PTHDB_FLAG_FPRS and PTHDB_FLAG_REGS.
tid Thread id.
flags Flags which control which registers are read or wrote.
context Context structure.
len Length of buffer to be allocated or re-allocated.
bufp Pointer to buffer.
str String to be printed.

Return Values

If successful these function returns 0 else returns a non-zero value.

Related Information

The pthdebug.h file.


[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]