alloc, dealloc, print, read_data, read_regs, symbol_addrs, write_data, and write_regs Subroutine
Purpose
Provide access to facilities needed by the pthread debug library and supplied by the debugger or application.
Library
pthread debug library (libpthdebug.a)
Syntax
#include <sys/pthdebug.h>
int alloc (user, len, bufp)
pthdb_user_t user;
size_t len;
void **bufp; int dealloc (user, buf)
pthdb_user_t user;
void *buf; int print (user, str)
pthdb_user_t user;
char *str; int read_data (user, buf, addr, size)
pthdb_user_t user;
void *buf;
pthdb_addr_t addr;
int size; int read_regs (user, tid, flags, context)
pthdb_user_t user;
tid_t tid;
unsigned long long flags;
struct context64 *context; int symbol_addrs (user, symbols[],count)
pthdb_user_t user;
pthdb_symbol_t symbols[];
int count; int write_data (user, buf, addr, size)
pthdb_user_t user;
void *buf;
pthdb_addr_t addr;
int size; int write_regs (user, tid, flags, context)
pthdb_user_t user;
tid_t tid;
unsigned long long flags;
struct context64 *context;Description
- int alloc()
- Allocates len bytes of memory and returns the address. If successful, 0 is returned; otherwise, a nonzero number is returned. This call back function is always required.
- int dealloc()
- Takes a buffer and frees it. If successful, 0 is returned; otherwise, a nonzero number is returned. This call back function is always required.
- int print()
- Prints the character string to the debugger's stdout. If successful, 0 is returned; otherwise, a nonzero number is returned. This call back is for debugging the library only. If you aren't debugging the pthread debug library, pass a NULL value for this call back.
- int read_data()
- Reads the requested number of bytes of data at the requested location from an active process or core file and returns the data through a buffer. If successful, 0 is returned; otherwise, a nonzero number is returned. This call back function is always required.
- int read_regs()
- Reads 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 a 32-bit and a 64-bit process. If successful, 0 is returned; otherwise, a nonzero number is returned. This function is only required when using the pthdb_pthread_context and pthdb_pthread_setcontext subroutines.
- int symbol_addrs()
- Resolves the address of symbols in the debuggee. The pthread debug library calls this subroutine to get the address of known debug symbols. If the symbol has a name of NULL or "", set the address to 0LL instead of doing a lookup or returning an error. If successful, 0 is returned; otherwise, a nonzero number is returned. In introspective mode, when the PTHDB_FLAG_SUSPEND flag is set, the application can use the pthread debug library by passing NULL, or it can use one of its own.
- int write_data()
- Writes the requested number of bytes of data to the requested location. The libpthdebug.a library may use this to write data to the active process. If successful, 0 is returned; otherwise, a nonzero number is returned. This call back function is required when the PTHDB_FLAG_HOLD flag is set and when using the pthdb_pthread_setcontext subroutine.
- int write_regs()
- Writes requested context information to specified debuggee's kernel thread id. If successful, 0 is returned; otherwise, a nonzero number is returned. This subroutine is only required when using the pthdb_pthread_setcontext subroutine.
Note: If the write_data and write_regs subroutines
are NULL, the pthread debug library will not try to write data or
regs. If the pthdb_pthread_set_context subroutine is called
when the write_data and write_regs subroutines are NULL, PTHDB_NOTSUP is
returned.
Parameters
| Item | Description |
|---|---|
| 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 the buffer. |
| flags | Session flags, must accept PTHDB_FLAG_GPRS, PTHDB_FLAG_SPRS, PTHDB_FLAG_FPRS, and PTHDB_FLAG_REGS. |
| tid | Thread id. |
| flags | Flags that control which registers are read or wrote. |
| context | Context structure. |
| len | Length of buffer to be allocated or reallocated. |
| bufp | Pointer to buffer. |
| str | String to be printed. |
Return Values
If successful, these subroutines return 0; otherwise they return a nonzero value.